meshEdits.loft

A triangle mesh through two or more polylines in order: each is resampled, and rows are interpolated linearly between neighbouring sections.

GeometricSince 0.17.0

Usage

TypeScript
MeshEdits.loft(curves: readonly (Geometry | VerbValue)[], params?: MeshLoftParams): Result<VerbValue>

Parameters

  • curvesreadonly (Geometry | VerbValue)[]

    The sections, 2 to 256, in order: each any geometry with at least two points, read as a polyline in point index order. The same value may appear twice; the inputs are not modified.

    Required

  • params.closedboolean

    Take the first section again as the last, so the surface returns to where it started. Default false.

  • params.resolutionUnumber

    How many samples are taken along each section, 2–4096. Default 10. In count.

  • params.resolutionVnumber

    How many rows the surface has from the first section to the last, 2–4096. Default 10. In count.

  • params.scopestring

    The host’s node id, for the ids. Default none: index ids with minter 0 (untrusted).

Returns

Ok with a VerbValue (the caller frees it): resolutionV rows of resolutionU points, row v interpolated linearly between the two sections around (v / (resolutionV − 1)) × (sections − 1), 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 (v, u), at index v × resolutionU + u, lies on the straight line between sample u of two neighbouring sections; row 0 is the first section’s samples and the last row the last section’s, or with closed the first section’s again, to rounding
  • a row lies on an inner section only when resolutionV − 1 is a multiple of the section count less one, or with closed of the section count
  • ids are the same on every call with the same scope, section count, closed and resolutions, and all change when one of them changes
  • the same input and parameters give the same bytes (geometryContentHash), natively and in WASM
  • The same result on every machine.

Example

TypeScript
const arc = (y, r) => Mesh.fromFaces([r, y, 0, 0, y, r, -r, y, 0], [[0, 1, 2]]).value.toGeometry()
const r = MeshEdits.loft([arc(0, 1), arc(1, 2), arc(2, 1)], { resolutionU: 4, resolutionV: 5 })
r.ok || r.diagnostics[0].code // → 20 points and 24 faces once loadGeometryKernel() has run

See also