brepjs API Reference
    Preparing search index...

    Function importSTL

    • Import an STL file from a Blob.

      Reads the triangle mesh and sews its facets together. A closed mesh becomes a Solid (one planar face per facet), so booleans and volume measurement work on it directly. An open mesh has no interior, so it comes back as a sewn Shell. A file with several bodies comes back as a Compound holding a Solid per closed body and a Shell per open one.

      Parameters

      • blob: Blob

        A Blob or File containing STL data (binary or ASCII).

      Returns Promise<Result<UnknownDimShape>>

      A Result wrapping the imported solid (a shell for an open mesh, a compound for several bodies), or an error if parsing fails.

      Every triangle becomes its own B-Rep face, so import time grows with the triangle count. On the default occt-wasm kernel a mesh whose shared edges each join two consistently wound triangles takes about 0.3 seconds per 10,000 triangles (about 1.7 seconds for 50,000). One that needs its winding repaired takes about 2 seconds per 10,000 (about 13 seconds for 50,000), and up to about twice that when the file holds several bodies. The temporary file on the WASM FS is cleaned up automatically.

      const shape = unwrap(await importSTL(stlBlob));