fileFormats.exportObj

An OBJ file of polygon geometry in a target unit and up axis, numbers in the shortest decimal that reads back to the same f64.

GeometricSince 0.18.0

Usage

TypeScript
FileFormats.exportObj(geometry: Uint8Array | Geometry | VerbValue, options?: FileExportOptions): Result<VerbBytes>

Parameters

  • geometryUint8Array | Geometry | VerbValue

    Polygon geometry: an HGT1 transport, or a kernel3d value (encoded with to_transport, which needs kernel3d).

    Required

  • options.targetUnit'mm' | 'cm' | 'm' | 'in' | 'ft'

    The unit the file is written in. Default 'mm'. One of mm, cm, m, in, ft.

  • options.targetUp'y' | 'z'

    The file’s up axis. Default 'z'. One of y, z.

Returns

Ok with the OBJ as bytes and their ref (sha256: of them): one v line per point, one f line per face; no vn, vt, o or g.

Errors

Guarantees

  • an export in metres with +Y up reads back through importObj to the same topology and P bit for bit
  • the same geometry and options give the same bytes and ref
  • The same result on every machine.

Example

TypeScript
const r = FileFormats.exportObj(new Uint8Array(0))
r.ok || r.diagnostics[0].code // → TRANSPORT_MAGIC for bytes that are no transport once loadKernelIo() has run

See also