Bitbybit Docs
    Preparing search index...

    Class JSCAD

    The entry point to the JSCAD kernel, a mesh-based solid modeler with three kinds of geometry: a solid, held as a closed set of polygons; a flat 2D shape, held as a region in the XY plane; and a 2D path, an open or closed polyline in that plane. shapes and polygon build them, booleans, extrusions, expansions and hulls combine and grow them, text writes with them and colors tints them. Flat shapes live in the XY plane and extrude along Z. The methods on the service itself convert solids to mesh data, move them with matrices and write STL, DXF and 3MF files. Credit to the JSCAD community for the kernel.

    Index

    Constructors

    Properties

    booleans: JSCADBooleans
    expansions: JSCADExpansions
    extrusions: JSCADExtrusions
    hulls: JSCADHulls
    path: JSCADPath
    polygon: JSCADPolygon
    shapes: JSCADShapes
    text: JSCADText
    colors: JSCADColors

    conversions

    • Turns a solid into a list of triangles, each given as three points, with the solid's own transform already applied.

      A flat 2D shape is given a tiny thickness first so it has faces at all. An entity with no polygons gives an empty list.

      Parameters

      Returns Promise<Mesh3>

      The triangles as lists of three points

      const cube = await bitbybit.jscad.shapes.cube({ center: [0, 0, 0], size: 10 });
      const triangles = await bitbybit.jscad.toPolygonPoints({ mesh: cube });

    io

    • Writes a solid as a binary STL file, the common format for 3D printing, and downloads it in the browser as fileName plus .stl.

      Parameters

      Returns Promise<void>

      The STL file as a blob; the asynchronous API starts the download instead and returns nothing

      await bitbybit.jscad.downloadSolidSTL({ mesh: cube, fileName: "cube" });
      
    • Writes several solids into one binary STL file and downloads it in the browser as fileName plus .stl.

      Parameters

      Returns Promise<void>

      The STL file as a blob; the asynchronous API starts the download instead and returns nothing

      await bitbybit.jscad.downloadSolidsSTL({ meshes: [cube, sphere], fileName: "parts" });
      
    • Writes a solid, a 2D shape, a path or a list of them as a DXF drawing file and downloads it in the browser as fileName plus .dxf.

      options is passed to the DXF writer as it is and can stay out.

      Parameters

      Returns Promise<void>

      The DXF file as a blob; the asynchronous API starts the download instead and returns nothing

      const circle = await bitbybit.jscad.polygon.circle({ center: [0, 0], radius: 5, segments: 32 });
      await bitbybit.jscad.downloadGeometryDxf({ geometry: circle, fileName: "circle", options: {} });
    • Writes a solid, a 2D shape, a path or a list of them as a 3MF file, a modern 3D printing format, and downloads it in the browser as fileName plus .3mf.

      options is passed to the 3MF writer as it is and can stay out.

      Parameters

      Returns Promise<void>

      The 3MF file as a blob; the asynchronous API starts the download instead and returns nothing

      await bitbybit.jscad.downloadGeometry3MF({ geometry: [cube, sphere], fileName: "parts", options: {} });
      

    transforms

    • Moves, rotates or scales several solids with the same transformation, giving new solids in the same order.

      transformation is one 4x4 matrix, a list of matrices applied in order, or a list of such lists; a flat 2D shape or a path throws an error.

      Parameters

      Returns Promise<JSCADEntity[]>

      The transformed solids, in the same order

      const translation = bitbybit.transforms.translationXYZ({ translation: [10, 0, 0] });
      const moved = await bitbybit.jscad.transformSolids({ meshes: [cube, sphere], transformation: translation });
    • Moves, rotates or scales a solid with a transformation, giving a new solid.

      transformation is one 4x4 matrix, a list of matrices applied in order, or a list of such lists; a flat 2D shape or a path throws an error.

      Parameters

      Returns Promise<JSCADEntity>

      The transformed solid

      const rotation = bitbybit.transforms.rotationCenterAxis({ angle: 45, axis: [0, 1, 0], center: [0, 0, 0] });
      const turned = await bitbybit.jscad.transformSolid({ mesh: cube, transformation: rotation });