mesh.fromFaces
A mesh from point positions and faces given as lists of point indices.
Usage
Mesh.fromFaces(positions: ArrayLike<number>, faces: readonly (readonly number[])[]): Result<Mesh>Parameters
positionsArrayLike<number>Point positions, three numbers per point. Required. In model.
facesreadonly (readonly number[])[]Each face as point indices in winding order; at least three per face.
Returns
Ok with the mesh; the arrays are copied, so later changes to the inputs do not reach it.
Errors
Guarantees
- mesh.faceCount equals faces.length and mesh.face(i) equals faces[i]
- The same result on every machine.
Example
const r = Mesh.fromFaces([0, 0, 0, 1, 0, 0, 0, 1, 0], [[0, 1, 2]])
r.ok && r.value.faceCount // → 1