sources.box

An axis-aligned box of eight points and six outward quads, with a flat normal per face and persistent ids.

GeometricSince 0.15.0

Usage

TypeScript
Sources.box(params?: SourceBoxParams): Result<Geometry>

Parameters

  • params.widthnumber

    Edge length along x. Default 1. In model.

  • params.heightnumber

    Edge length along y. Default 1. In model.

  • params.depthnumber

    Edge length along z. Default 1. In model.

  • 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: P (Float64 ×3) at (±width/2, ±height/2, ±depth/2), points (−,−,−), (+,−,−), (+,+,−), (−,+,−), then the same at +z; faces −z, +z, −y, +y, +x, −x; N (Float32 ×3) per face; id, idFrom, primId, primIdFrom (Int32).

Errors

Guarantees

  • volume equals width · height · depth and the area is the sum of the six faces
  • every edge has two faces, wound opposite ways (closed)
  • the same parameters give the same bytes (geometryContentHash), natively and in WASM
  • The same result on every machine.

Example

TypeScript
const r = Sources.box({ width: 2, height: 1, depth: 1, scope: 'box1' })
r.ok || r.diagnostics[0].code // → 8 points and 6 faces once loadGeometryKernel() has run

See also