Empty Geometry Normals - LambertMaterial

Hi All,

I created I buffer Geometry from a given 3D software but I couldn’t get the vertex or face normals to compute using the two functions :

The reason I need the normals is to show the MeshLambertMaterial and to apply a lookup table (Lut) - same as the example (three.js webgl - lookup table). For now I have a “black” mesh.

Here is fiddle of the example : https://jsfiddle.net/x9mp8db0/1/

Could you please assist with this (i.e. displaying the colors according to the pressures on each vertex)

Any good Samaritan who can assist with this ?

Thanks in advance!

You are not generating the geometry for your mesh correctly in the first place. The following WebGL warning is logged in the browser console:

[.WebGL-0x7fa2c7870200]GL ERROR :GL_INVALID_OPERATION : glDrawElements: attempt to access out of range vertices in attribute 2

That happens because you generate your geometry with empty normal and uv buffers.

Also computeFaceNormals() has no effect when using with BufferGeometry.

Fiddle without warnings: https://jsfiddle.net/pt638xf9/

1 Like

Thanks for your answer Michael,

The way I retrieved data from the given software, I only have the vertex positions and the faces indices. I don’t have normals or uvs.

Is there any way to calculate automatically or via a function the normals ? I believe this is what causing the black mesh.

Once I’m able to calculate the normals, I can apply LUT and get my vertex colors according to the user data (pressures array in this case)