sources.cylinder

A closed faceted cylinder along Y: two flat polygon caps and side quads, with a hard rim and persistent ids.

GeometricSince 0.15.0

Usage

TypeScript
Sources.cylinder(params?: SourceCylinderParams): Result<Geometry>

Parameters

  • params.radiusnumber

    Distance from the axis to every rim point. Default 0.5. In model.

  • params.heightnumber

    Length along y, from −height/2 to +height/2. Default 1. In model.

  • params.segmentsnumber

    Side quads around the axis; an integer. Default 16. Range [3, 1024] count.

  • params.addIdsboolean

    Accepted for hosts that send it; point and face ids (id, idFrom, primId, primIdFrom) are always written, whatever its value. Default true.

  • params.scopestring

    The host’s node id; ids are minted under it. Default undefined (index ids, minter 0).

Returns

Ok with polygon geometry of 2 · segments points (the top rim, then the bottom rim) and segments + 2 faces (the top cap, the bottom cap, then one quad per segment); N (Float32 ×3) per corner, axial on the caps and radial on the side.

Errors

Guarantees

  • volume equals (segments / 2) · radius² · sin(2π / segments) · height, the prism’s
  • closed
  • the same parameters give the same bytes (geometryContentHash), natively and in WASM
  • The same result on every machine.

Example

TypeScript
const r = Sources.cylinder({ radius: 0.5, height: 2, segments: 32 })
r.ok || r.diagnostics[0].code // → 64 points and 34 faces once loadGeometryKernel() has run

See also