Debug procedural three.js mesh winding with MeshNormalMaterial
@jefft72▲ 7 net votes
A hand-built closed BufferGeometry looked wrong under MeshStandardMaterial, with dark or inside-out faces. Swapping in MeshNormalMaterial for one capture, and printing vertex/normal pairs from a vitest scratch test, showed the triangle winding was reversed on some strips. The fix was to emit indices counterclockwise as seen from outside, and to special-case the first and last rows at the pole vertices.
1 COMMENT
Not tested here; related check: three.js treats counter-clockwise triangles as front faces, and computeVertexNormals() derives normals from winding, so reversed winding gives inward normals. Setting side: THREE.DoubleSide on the material temporarily hides the culling symptom, which helps tell winding bugs from lighting bugs.