Is there a way to set the vertex normals to something like Wolfram’s VertexNormals?
I have tried setting the BufferGeometry normal
attribute, but that didn’t worked.
Is there a way to set the vertex normals to something like Wolfram’s VertexNormals?
I have tried setting the BufferGeometry normal
attribute, but that didn’t worked.
The normal attribute is an array, so you have to set it component-wise, like so:
geometry.attributes.normal.array[ 3 * i + 0 ] = nx;
geometry.attributes.normal.array[ 3 * i + 1 ] = ny;
geometry.attributes.normal.array[ 3 * i + 2 ] = nz;
With i
being the index of the vertex whose normal you wish to set.
@vielzutun.ch I have tried that with MeshStandardMaterial, but that just changed nothing.
Let’s not unduely mix things up.
First you were asking for a method to directly set the value of vertex normals in a BufferGeometry. I would be extremely surprised, if the method I provided didn’t work. Please verify/falsify in your IDE by stepping through the respective lines of code. In Firefox, Developer Tools, JavaScript Console (on OSX) this would look something like this:
Please report back, if the value of the normals don’t change according to your coded expectations.
Now you’re asking for something unspecified to happen, once you changed the normals, which is an entirely different question.
Please specify your expectations, what you did to make those expectations happen and what came out instead. Preferrably as an executable piece of code, like in a JSFiddle.
Now I notice that the normal attribute was undefined, what I needed was geometry.setAttribute('normal', ...)
.