computeNormals method
void
computeNormals()
Compute the normals of the faces.
Will reuse existing Vec3 objects in the faceNormals
array if they exist.
Implementation
void computeNormals() {
faceNormals.length = faces.length;
// Generate normals
for (int i = 0; i < faces.length; i++) {
final Vec3 n = faceNormals[i] ?? Vec3();
getFaceNormal(i, n);
n.negate(n);
faceNormals[i] = n;
final Vec3 vertex = vertices[faces[i][0]];
if (n.dot(vertex) < 0) {
logger?.warning(
'.faceNormals[$i] = Vec3(${n.toString()}) looks like it points into the shape? The vertices follow. Make sure they are ordered CCW around the normal, using the right hand rule.'
);
int len =faces[i].length;
for (int j = 0; j < len; j++) {
logger?.verbose('.vertices[${faces[i][j]}] = Vec3(${vertices[faces[i][j]].toString()})');
}
}
}
}