fileFormats.importStl

Polygon geometry from a binary or ASCII STL file, corners welded exactly, in metres and the kernel’s frame, with ids in file order.

GeometricSince 0.18.0

Usage

TypeScript
FileFormats.importStl(file: Uint8Array, options?: FileImportOptions): Result<FileImport>

Parameters

  • fileUint8Array

    The STL file: binary, or ASCII with one or more solids.

    Required

  • options.scopestring

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

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

    The file’s unit. Default 'mm'. One of mm, cm, m, in, ft.

  • options.sourceUp'y' | 'z'

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

Returns

Ok with a FileImport: the HGT1 transport and its ref, points, faces, droppedFaces and ignored. P (Float64 ×3, metres), id, idFrom, primId, primIdFrom; no normals.

Errors

Guarantees

  • every face is a triangle and no face has a zero-length edge
  • points are the file’s distinct corners, equal bit for bit, in order of first appearance
  • the same bytes and options give the same transport and ref on every target
  • The same result on every machine.

Example

TypeScript
const r = FileFormats.importStl(new Uint8Array(84), { scope: 'import1' })
r.ok || r.diagnostics[0].code // → IO_EMPTY for an STL with no triangles once loadKernelIo() has run

See also