Skip to content

Documentation / @ripl/3d / computeFaceNormal

Function: computeFaceNormal() ​

computeFaceNormal(vertices): Vector3

Defined in: 3d/src/core/shading.ts:55

Computes the surface normal of a face from its first three vertices via the cross product.

Delegates to vec3TriangleNormal so the CPU painter and the GPU mesh path agree on degenerate faces — the two used to disagree, one shading a collapsed face black and the other treating it as facing up.

Parameters ​

ParameterTypeDescription
verticesVector3[]The face's vertices; only the first three are read.

Returns ​

Vector3

The face's unit normal.