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

Function togglePrecisionMasking

js/main.js:4215–4233  ·  view source on GitHub ↗

Toggle precision masking on/off.

(enable)

Source from the content-addressed store, hash-verified

4213 vC.set(pos[(i+2) * 3], pos[(i+2) * 3 + 1], pos[(i+2) * 3 + 2]);
4214 e1.subVectors(vB, vA);
4215 e2.subVectors(vC, vA);
4216 n.crossVectors(e1, e2).normalize();
4217 for (let v = 0; v < 3; v++) {
4218 fn[(i + v) * 3] = n.x;
4219 fn[(i + v) * 3 + 1] = n.y;
4220 fn[(i + v) * 3 + 2] = n.z;
4221 }
4222 }
4223 geometry.setAttribute('faceNormal', new THREE.Float32BufferAttribute(fn, 3));
4224}
4225
4226/**
4227 * Compute area-weighted smooth normals for a non-indexed geometry and store
4228 * them as a `smoothNormal` vec3 attribute. Every copy of the same position
4229 * gets the same averaged normal so vertex-shader displacement is watertight.
4230 */
4231function addSmoothNormals(geometry) {
4232 const pos = geometry.attributes.position.array;
4233 const count = geometry.attributes.position.count;
4234 const nrm = geometry.attributes.normal.array;
4235
4236 // Vertex-dedup pass: assign a numeric ID to each unique quantised position.

Callers 1

wireEventsFunction · 0.85

Calls 3

refreshPrecisionMeshFunction · 0.85

Tested by

no test coverage detected