Drawing coordinates to scene coordinates
32-bit, display onlyThe positions sent to the GPU: centered on the drawing and scaled to about 100 units across.
scene = (p − center) × 100 ÷ largest extent
The subtraction and the scaling are done in 64-bit and the result is stored in a Float32Array. Because the center is taken off first, the 32-bit values hold the position within the drawing, not the full coordinate.
const toScene = (src) => {
const a = new Float32Array(src.length);
for (let i = 0; i < src.length; i += 3) { a[i] = (src[i] - c[0]) * s; a[i + 1] = (src[i + 1] - c[1]) * s; a[i + 2] = (src[i + 2] - c[2]) * s; }
return a;
};