meshEdits.copyToPoints
One copy of a polygon mesh at each point of another geometry, scaled by the point’s pscale and optionally turned to its normal.
Usage
MeshEdits.copyToPoints(geometry: Geometry | VerbValue, points: Geometry | VerbValue, params?: MeshCopyToPointsParams): Result<VerbValue>Parameters
geometryGeometry | VerbValueThe template: polygon geometry; pass a VerbValue to keep its roles.
pointsGeometry | VerbValueWhere the copies go: any geometry with a P of three floats per point (a point cloud, a mesh, curves); only its points are read.
params.scalenumberA uniform scale for every copy; negative mirrors it, 0 collapses it to its point. Default
1. In ratio.params.usePscalebooleanMultiply the scale by each point’s pscale (one float per point), when the points have one. Default
true.params.alignToNormalbooleanTurn each copy so the template’s +Z meets the point’s N (three floats per point, which it then needs). Default
false.params.scopestringThe host’s node id, for minted ids. Default
none: minted under 'copy_to_points' with minter 0 (untrusted).
Returns
Ok with a VerbValue (the caller frees it): the copies in point order, each with the template’s points, corners and faces; data has points, faces and copies.
Errors
Guarantees
- copy i is the template scaled by s = scale · pscale[i], turned by the shortest rotation taking +Z to N[i] when aligned, then moved to point i; a negative s mirrors the copy and reverses its faces’ winding (each keeps its first corner), so they still face out
- points out = points × template points, faces out = points × template faces; no points gives an empty geometry with the template’s attributes
- every template attribute is copied onto each copy: positions and directions as placed, a normal unit length and turned (flipped with a mirror), a vector scaled and turned, a detail attribute once
- every point gets a fresh id when the template has id, and every face when it has primId, keyed by its target point’s key and its template element’s key; when the target’s ids are positive and unique, a copy keeps its ids when the points are reordered; lineage records each element as one term of its template element (slot 0) and its target point (slot 1)
- the same input and parameters give the same bytes (geometryContentHash), natively and in WASM
- The same result on every machine.
Example
const r = MeshEdits.copyToPoints(Mesh.box().value, Samples.scatter(Mesh.box().value, { scope: 's' }).value, { scale: 0.1 })
r.ok || r.diagnostics[0].code // → a small box at every sample once loadGeometryKernel() has run