meshEdits.sweep
A triangle mesh made by sliding one polyline along another: every point is a rail sample plus a section sample, with no turning.
Usage
MeshEdits.sweep(rail: Geometry | VerbValue, section: Geometry | VerbValue, params?: MeshSweepParams): Result<VerbValue>Parameters
railGeometry | VerbValueThe path: any geometry with at least two points, read as a polyline in point index order; the input is not modified.
sectionGeometry | VerbValueThe cross-section, read the same way. It keeps its own coordinates: draw it at the origin to have the surface on the rail.
params.resolutionUnumberHow many samples are taken along the rail, 2–4096. Default
10. In count.params.resolutionVnumberHow many samples are taken along the section, 2–4096. Default
8. In count.params.scopestringThe host’s node id, for the ids. Default
none: index ids with minter 0 (untrusted).
Returns
Ok with a VerbValue (the caller frees it): resolutionU rows of resolutionV points, point (u, v) at rail sample u plus section sample v, joined by two triangles per cell, with a smooth point normal and point and face ids; data has points and faces.
Errors
Guarantees
- points out = resolutionU × resolutionV; faces out = 2 × (resolutionU − 1) × (resolutionV − 1)
- point (u, v), at index u × resolutionV + v, is rail sample u plus section sample v, so every row is the section moved, never turned
- sample i of count along a polyline of n points lies at (i / (count − 1)) × (n − 1) in its point index, between the two points around it: its first and last samples are its first and last points, and the samples are even by point index, not by length
- ids are the same on every call with the same scope and resolutions, whatever the inputs’ point counts, and all change when a resolution changes
- the same input and parameters give the same bytes (geometryContentHash), natively and in WASM
- The same result on every machine.
Example
const rail = Mesh.fromFaces([0, 0, 0, 0, 0, 2, 1, 0, 4], [[0, 1, 2]]).value.toGeometry()
const section = Mesh.fromFaces([-0.5, 0, 0, 0, 0.5, 0, 0.5, 0, 0], [[0, 1, 2]]).value.toGeometry()
const r = MeshEdits.sweep(rail, section, { resolutionU: 6, resolutionV: 4 })
r.ok || r.diagnostics[0].code // → 24 points and 30 faces once loadGeometryKernel() has run