MCPcopy Create free account
hub / github.com/CNCKitchen/stlTexturizer / normalizeStoreNormals

Function normalizeStoreNormals

js/subdivision.js:443–454  ·  view source on GitHub ↗
(verts)

Source from the content-addressed store, hash-verified

441 }
442
443 normalizeStoreNormals(verts);
444 return { verts, indices };
445}
446
447// Normalise accumulated normal sums in place (shared by both indexers).
448function normalizeStoreNormals(verts) {
449 const nrm = verts.nrm;
450 for (let i = 0; i < verts.count; i++) {
451 const nx = nrm[i * 3];
452 const ny = nrm[i * 3 + 1];
453 const nz = nrm[i * 3 + 2];
454 const len = Math.sqrt(nx * nx + ny * ny + nz * nz) || 1;
455 nrm[i * 3] = nx / len;
456 nrm[i * 3 + 1] = ny / len;
457 nrm[i * 3 + 2] = nz / len;

Callers 2

toIndexedFastFunction · 0.85
toIndexedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected