问题
I followed this stackoverflow example: ThreeJS geometry flipping
I successfully mirrored my geometry. However now my geometry is black. Can I flip my normals at the same time as the geometry to correct this? Or should I have used a different approach to mirror the geometry from the beginning?
EDIT:
Tried adding the updates to this code and still have inverted geometry.
#transformation
mS.elements[5] = -1;
mesh.applyMatrix(mS);
#updates
mesh.geometry.verticesNeedUpdate = true;
mesh.geometry.normalsNeedUpdate = true;
mesh.geometry.computeBoundingSphere();
mesh.geometry.computeFaceNormals();
mesh.geometry.computeVertexNormals();
回答1:
mesh.geometry.verticesNeedUpdate = true;
mesh.geometry.normalsNeedUpdate = true;
mesh.geometry.computeBoundingSphere();
mesh.geometry.computeFaceNormals();
mesh.geometry.computeVertexNormals();
https://github.com/mrdoob/three.js/wiki/Updates
回答2:
This is an old question, but for those still lost: the face normal is calculated by looking at the counter clockwise order of the vertices.
So if you need to flip the normals you have to reorder the vertices that are assigned to a face. For example:
var tmp;
for(var f = 0; f < geometry.faces.length; f++) {
tmp = geometry.faces[f].clone();
geometry.faces[f].a = tmp.c;
geometry.faces[f].c = tmp.a;
}
回答3:
You could try:
mesh.geometry.reverse(computeFaceNormals());
mesh.geometry.reverse(computeVertexNormals());
来源:https://stackoverflow.com/questions/25795538/flip-normals-three-js-after-flipping-geometry