meshEdits.revolve

A triangle mesh made by turning a polyline, a geometry’s points in index order, about a coordinate axis through the origin.

GeometricSince 0.17.0

Usage

TypeScript
MeshEdits.revolve(geometry: Geometry | VerbValue, params?: MeshRevolveParams): Result<VerbValue>

Parameters

  • geometryGeometry | VerbValue

    The profile: any geometry with at least two points, read as a polyline in point index order; the input is not modified.

    Required

  • params.axis'x' | 'y' | 'z'

    The axis to turn about, through the origin. Default 'y'.

  • params.anglenumber

    How far the profile turns, by the right hand about the axis; within 0.01° of a full turn (2π) the surface closes on itself, any other angle leaves its seam open. Default 2 * Math.PI. In radians.

  • params.resolutionnumber

    How many copies of the profile are placed around the axis, 3–4096. Default 16. 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): resolution rows of the profile’s points, row v turned by (v / d) · angle, d being resolution for a full turn and resolution − 1 otherwise, 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 = profile points × resolution; faces out = 2 × (profile points − 1) × resolution for a full turn and 2 × (profile points − 1) × (resolution − 1) otherwise
  • point (v, u), at index v × profile points + u, is profile point u turned by (v / d) · angle: row 0 is the profile itself, and every point keeps its coordinate along the axis and its distance to it
  • a full turn joins its last row to its first; nothing is welded, so a profile point on the axis gives one point per row at the same place
  • ids are the same on every call with the same scope and counts, and all change when the profile’s point count, the resolution or whether the turn is full changes
  • the same input and parameters give the same bytes (geometryContentHash), natively and in WASM
  • The same result on every machine.

Example

TypeScript
const profile = Mesh.fromFaces([1, 0, 0, 1, 1, 0, 0.5, 2, 0], [[0, 1, 2]]).value.toGeometry()
const r = MeshEdits.revolve(profile, { axis: 'y', resolution: 8 })
r.ok || r.diagnostics[0].code // → 24 points and 32 faces once loadGeometryKernel() has run

See also