INNER CODE UNIT · TypeScript
ia
voxelize/voxelize · packages/core/src/core/world/index.ts:86
const ia = indices[i] * 3;
const ib = indices[i + 1] * 3;
const ic = indices[i + 2] * 3;
const e1x = positions[ib] - positions[ia];
const e1y = positions[ib + 1] - positions[ia + 1];
const e1z = positions[ib + 2] - positions[ia + 2];
const e2x = positions[ic] - positions[ia];
const e2y = positions[ic + 1] - positions[ia + 1];
const e2z = positions[ic + 2] - positions[ia + 2];
let nx = e1y * e2z - e1z * e2y;
let ny = e1z * e2x - e1x * e2z;
let nz = e1x * e2y - e1y * e2x;
const len = Math.sqrt(nx * nx + ny * ny + nz * nz);
if (len > 0) {
nx /= len;
ny /= len;
nz /= len;
}