geom-normals
v2.1.0
Published
Compute normals for a simplicial complex geometry based on faces/cells information.
Downloads
40
Maintainers
Readme
geom-normals
Compute normals for a simplicial complex geometry based on faces/cells information.
Installation
npm install geom-normals
Usage
import normals from "geom-normals";
import { plane } from "primitive-geometry";
const geometry = plane();
// Modify geometry.positions
// ...
// Recompute normals
normals(geometry.positions, geometry.cells, geometry.normals);
API
normals(positions, cells, [out]): normals
Parameters
- positions:
TypedArray | Array | Array<[x, y, z]>
– simplicial complex geometry positions (eg.new Float32Array([x, y, z, x, y, z, ...])/new Array(x, y, z, x, y, z, ...)
ornew Array([x, y, z], [x, y, z], ...)
) - cells:
TypedArray | Array | Array<[x, y, z]>
– simplicial complex geometry cells (eg.new Uint32Array([a, b, c, a, b, c, ...])/new Array(a, b, c, a, b, c, ...)
ornew Array([a, b, c], [a, b, c], ...)
) - out (optional):
TypedArray | Array | Array<[x, y, z]>
– simplicial complex geometry normals to write to (eg.new Float32Array([x, y, z, x, y, z, ...])/new Array(x, y, z, x, y, z, ...)
ornew Array([x, y, z], [x, y, z], ...)
)
Returns
- normals:
TypedArray | Array | Array<[x, y, z]>
– The normals parameter array updated (or created) with per vertex computed normals.
Note: If there are two vertices with the same position but different index there will be discontinuity (hard edge)
License
MIT. See license file.