Transforming vertex normals in three.js

I'm having difficulties with vertex normals in THREE.js. (For reference I'm using revision 58.) For various reasons I'd like to first calculate the face vertex normals when I setup my geometry, then be free to transform it, merge and whatnot.

While I realize the normals depend on the vertices which are transformed when you apply a matrix, I thought geometry.applyMatrix was able to transform them as well. However, while the following works fine:

geometry.applyMatrix(new THREE.Matrix4().makeScale(1, -1, 1));

...the following order of operations yields reversed vertex normals:

geometry.applyMatrix(new THREE.Matrix4().makeScale(1, -1, 1));

So I'm simply wondering, is this working as intended? Do I need to first do all the transformations on the geometry before I calculate the vertex normals?



three.js does not support reflections in the object matrix. By setting a negative scale factor, you are reflecting the geometry of the object.

You are free to apply such a matrix to your geometry directly, however, which of course, is what you are doing.

However, this will result in a number of undesirable consequences, one of which is the geometry faces will no longer have counterclockwise winding order, but clockwise. It will also result in reversed face normals as calculated by geometry.computeFaceNormals().

I would advise against doing this unless you are familiar with the inner-workings of the library.

three.js r.58


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.