I am using 3d modifiers https://github.com/foo123/MOD3 to bend a cube. After the geometry is updated (vertex positions are changed) the lights are not updated, the cube is still shaded as if nothing changed. So I tried
cube.geometry.computeVertexNormals()
and
cube.geometry.computeFaceNormals()
but after that the cube is not rendered like a cube anymore but like an "ugly sphere":
On the left is shading after computeVertexNormals()
, on the right is the original shading.
How can I update the shading after the geometry changes?
If you use MOD3 to modify just the geometry, then you are going to have to update the normals yourself.
geometry.computeVertexNormals();
Each new vertex normal will be the normalized sum of the face normals of the neighboring faces that share that vertex.
If you don't like the way that three.js does it, your only choice is to modify the vertex normals yourself.
three.js r.85
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With