meshEdits.subdivide
A copy of a polygon mesh subdivided one level, linearly or by Catmull-Clark.
Usage
MeshEdits.subdivide(geometry: Geometry | VerbValue, params?: MeshSubdivideParams): Result<VerbValue>Parameters
geometryGeometry | VerbValuePolygon geometry; the input is not modified.
params.scheme'linear' | 'catmull-clark'linear: new points at edge middles and face centres, a triangle into four triangles and any other face into one quad per corner; catmull-clark: one quad per corner, every point smoothed. Default
'linear'.params.scopestringThe host’s node id, for minted ids. Default
none: minted under 'subdivide' with minter 0 (untrusted).
Returns
Ok with a VerbValue (the caller frees it): one point per edge and per face (linear: per non-triangle face) added, each face split; data has points and faces. Chain the verb for more levels.
Errors
Guarantees
- linear keeps every input point where it was; catmull-clark moves them by its rules (boundary points along the boundary, corners fixed)
- neighbouring faces share their new points (no cracks)
- carried point ids are unchanged; every face and new point gets a fresh id keyed by its parents; lineage records each edge point as generated from its two ends, each face point from its face and each face as a piece of its parent
- the same input and parameters give the same bytes (geometryContentHash), natively and in WASM
- The same result on every machine.
Example
const r = MeshEdits.subdivide(Mesh.box().value, { scheme: 'catmull-clark' })
r.ok || r.diagnostics[0].code // → 26 points and 24 faces once loadGeometryKernel() has run