Skip to content
Shapemetry

@huukhanhnguyen/model / nodeMethods/mesh

nodeMethods/mesh

faceToMesh

const faceToMesh: (data) => ObjectData & { wholeArray: true; }

Planar no-hole faces → one n-gon each (welded shared vertices). Curved or holed faces tessellate to triangle faces (3-gons).


meshLattice

const meshLattice: (data, offset, boundary) => ObjectData & { wholeArray: true; }

Hollow every mesh into a strut frame from polygon faces (no triangle roundtrip — wireframe follows design edges, not face diagonals).


meshSubdivision

const meshSubdivision: (data, iterations) => ObjectData & { wholeArray: true; }

Catmull-Clark subdivide every mesh in the stream (mesh→mesh). Channels drop (topology changes); normals rebuild when the input had them.


chunkTriangleIndices()

chunkTriangleIndices(indices): MeshFace[]

Chunk a flat triangle index pool into 3-gon faces (a tessellation's index buffer, displacement output, migrated data).

Parameters

indices

number[]

Returns

MeshFace[]


computeVertexNormals()

computeVertexNormals(positions, faces): number[]

Area-weighted smooth vertex normals over triangulated faces.

Parameters

positions

number[]

faces

number[][]

Returns

number[]


isBoundMesh()

isBoundMesh(data): boolean

Bound meshes (skin / morphs / weightsTrack) stay unmerged — the assembler splits them onto their own object.

Parameters

data

MeshData

Returns

boolean


mergeMeshData()

mergeMeshData(documents): MeshData

Concatenate mesh documents into one buffer. Face ORDER is source order so indices stay predictable; each MeshFace, each EdgeMark and each MeshVertex carries its own claims (array-of-structs, no parallel array to keep in step).

Vertices concatenate; every face/edge index is offset by the running vertex count. A source missing a per-vertex field leaves that field absent on its vertices — never zero-filled. Skin / morphs / weightsTrack refuse.

Single-source fast path: the same document reference, untouched.

Parameters

documents

MeshData[]

Returns

MeshData


meshFacesToTriangles()

meshFacesToTriangles(positions, faces): number[]

Pure: n-gon faces → flat triangle indices. Same input → byte-identical.

Parameters

positions

number[]

faces

number[][]

Returns

number[]


meshPositions()

meshPositions(mesh): number[]

Flatten MeshVertex.position into the kernel/TriangleMesh door layout.

Parameters

mesh

MeshData

Returns

number[]


splitMeshIslands()

splitMeshIslands(mesh): MeshData[]

Connectivity pass: faces that share a vertex index are one island. One island → the same document reference. Used by looseToBlocks.

Parameters

mesh

MeshData

Returns

MeshData[]


verticesFromChannels()

verticesFromChannels(positions, channels?): MeshVertex[]

Build vertices from a flat position buffer plus optional per-vertex channels. A present channel must cover every vertex — short arrays throw rather than zero-fill. Absent channel = the field stays absent on each vertex.

Parameters

positions

number[]

channels?

attributes?

(Record<string, unknown> | null)[]

normals?

number[]

skin?

{ indices: number[]; weights: number[]; }

skin.indices

number[]

skin.weights

number[]

uvs?

number[]

uvs2?

number[]

Returns

MeshVertex[]

Last updated: 📖 3 min readEdit on GitHub