Smooth surface for display
32-bit, display onlyThe limit positions of the refined cage as a triangle mesh.
Each limit point is computed in 64-bit and written into a Float32Array. ws-form.js draws this mesh; form-brep.js builds the solid from patches() instead.
/** The smooth surface for display: limit positions of the cage refined `level` (≥ 1) times, as triangles. */
export function limitMesh(form, level = 2) {
if (!form.faces.length) return { positions: new Float32Array(0), indices: new Uint32Array(0), triFace: [] };
const m = refine(form, Math.max(1, level), { track: true });
const t = topo(m);
const positions = new Float32Array(m.P.length * 3);
m.P.forEach((_, v) => { if (!t.ve[v].length) return; const p = limitPoint(m, t, v); positions.set(p, v * 3); });
const idx = [], triFace = [];
m.F.forEach((f, fi) => { idx.push(f[0], f[1], f[2], f[0], f[2], f[3]); triFace.push(m.track[fi].root, m.track[fi].root); });
return { positions, indices: Uint32Array.from(idx), triFace };
}