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.
Usage
FileFormats.importStl(file: Uint8Array, options?: FileImportOptions): Result<FileImport>Parameters
fileUint8ArrayThe STL file: binary, or ASCII with one or more solids.
options.scopestringThe 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 ofmm,cm,m,in,ft.options.sourceUp'y' | 'z'The file’s up axis. Default
'z'. One ofy,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
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