sources.box
An axis-aligned box of eight points and six outward quads, with a flat normal per face and persistent ids.
Usage
Sources.box(params?: SourceBoxParams): Result<Geometry>Parameters
params.widthnumberEdge length along x. Default
1. In model.params.heightnumberEdge length along y. Default
1. In model.params.depthnumberEdge length along z. Default
1. In model.params.addIdsbooleanAccepted for hosts that send it; point and face ids (id, idFrom, primId, primIdFrom) are always written, whatever its value. Default
true.params.scopestringThe 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
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