Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

computeVertexNormals

Tags:

three.js

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":

enter image description here

On the left is shading after computeVertexNormals(), on the right is the original shading.

How can I update the shading after the geometry changes?

like image 275
user1800306 Avatar asked Nov 05 '12 13:11

user1800306


1 Answers

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

like image 92
WestLangley Avatar answered Jan 03 '23 21:01

WestLangley