Welded corners in meters
64-bitMerges corners that coincide and converts them from millimeters to meters.
key = round(x ÷ q), round(y ÷ q), round(z ÷ q); p (m) = p (mm) × 0.001
The constant MM = 0.001 has no exact binary value, so each product can differ from the correctly rounded p ÷ 1000 by one unit in the last place. The kept corner is the first one seen in its cell, with its own coordinates.
const q = Math.max(read.tol * 0.05, 1e-9); // corners closer than this are one (a face's edge points meet its neighbour's)
const I = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
read.solids.forEach((s, si) => {
const keyOf = new Map(), pts = [];
const P = s.positions, nV = P.length / 3;
const map = new Int32Array(nV);
for (let v = 0; v < nV; v++) {
const k = Math.round(P[v * 3] / q) + ',' + Math.round(P[v * 3 + 1] / q) + ',' + Math.round(P[v * 3 + 2] / q);
let w = keyOf.get(k);
if (w === undefined) { w = pts.length / 3; keyOf.set(k, w); pts.push(P[v * 3] * MM, P[v * 3 + 1] * MM, P[v * 3 + 2] * MM); }
map[v] = w;
}