Bitbybit Docs
    Preparing search index...

    Class JSCADShapes

    Building JSCAD solids: cubes, cuboids, spheres, ellipsoids, cylinders, a torus and a solid from raw polygon points, each with a variant that places one copy on every point of a list. The kernel keeps Z as its own axis, so a cylinder stands along Z and a torus lies flat in the XY plane; every solid is a closed mesh of polygons and segments says how many flat facets approximate a round surface.

    Index

    Constructors

    primitives

    • Builds a cube of edge length size centered on center, with its faces parallel to the axes.

      Parameters

      Returns Promise<JSCADEntity>

      The cube solid

      const cube = await bitbybit.jscad.shapes.cube({ center: [0, 0, 0], size: 10 });
      
    • Builds a box centered on center with width along X, height along Y and length along Z, its faces parallel to the axes.

      Parameters

      • inputs: CuboidDto

        The center and the three side lengths

      Returns Promise<JSCADEntity>

      The box solid

      const box = await bitbybit.jscad.shapes.cuboid({ center: [0, 0, 0], width: 10, height: 5, length: 20 });
      
    • Builds a cylinder with an elliptical cross-section whose radii can differ at the two ends, standing along Z and centered on center.

      startRadius is the X and Y radius at the bottom end and endRadius at the top, so unequal pairs make a tapered or cone-like solid; height is split evenly above and below center.

      Parameters

      Returns Promise<JSCADEntity>

      The elliptic cylinder solid

      const cone = await bitbybit.jscad.shapes.cylinderElliptic({ center: [0, 0, 0], height: 10, startRadius: [4, 2], endRadius: [1, 0.5], segments: 32 });
      
    • Builds a round cylinder of the given radius standing along Z, with height split evenly above and below center.

      segments is the number of flat sides around it; more makes it rounder.

      Parameters

      • inputs: CylidnerDto

        The center, the height, the radius and the segment count

      Returns Promise<JSCADEntity>

      The cylinder solid

      const cylinder = await bitbybit.jscad.shapes.cylinder({ center: [0, 0, 0], height: 10, radius: 3, segments: 32 });
      
    • Builds an ellipsoid, a sphere stretched separately along X, Y and Z, centered on center.

      radius holds the three half-sizes in [x, y, z] order; equal values make a sphere.

      Parameters

      • inputs: EllipsoidDto

        The center, the three radii and the segment count

      Returns Promise<JSCADEntity>

      The ellipsoid solid

      const egg = await bitbybit.jscad.shapes.ellipsoid({ center: [0, 0, 0], radius: [5, 3, 8], segments: 32 });
      
    • Builds a sphere from evenly sized triangles, the way a geodesic dome is built, centered on center.

      frequency is how finely the twenty starting faces are subdivided; it is used in whole multiples of 6 and must be at least 6, and higher values give a rounder sphere.

      Parameters

      Returns Promise<JSCADEntity>

      The geodesic sphere solid

      const dome = await bitbybit.jscad.shapes.geodesicSphere({ center: [0, 0, 0], radius: 5, frequency: 12 });
      
    • Builds a box with all its edges and corners rounded by roundRadius, centered on center with width along X, height along Y and length along Z.

      roundRadius must be less than half of the smallest side or an error is thrown; segments sets how smoothly the rounding is faceted.

      Parameters

      • inputs: RoundedCuboidDto

        The center, the three side lengths, the rounding radius and the segment count

      Returns Promise<JSCADEntity>

      The rounded box solid

      const soft = await bitbybit.jscad.shapes.roundedCuboid({ center: [0, 0, 0], width: 10, height: 5, length: 20, roundRadius: 1, segments: 16 });
      
    • Builds a cylinder standing along Z whose two rims are rounded by roundRadius, with height split evenly above and below center.

      height must be more than twice roundRadius or an error is thrown.

      Parameters

      • inputs: RoundedCylidnerDto

        The center, the rounding radius, the height, the radius and the segment count

      Returns Promise<JSCADEntity>

      The rounded cylinder solid

      const pill = await bitbybit.jscad.shapes.roundedCylinder({ center: [0, 0, 0], roundRadius: 1, height: 10, radius: 3, segments: 32 });
      
    • Builds a sphere of the given radius centered on center; segments is the number of facets around it, so more makes it rounder.

      Parameters

      Returns Promise<JSCADEntity>

      The sphere solid

      const ball = await bitbybit.jscad.shapes.sphere({ center: [0, 0, 0], radius: 5, segments: 32 });
      
    • Builds a torus, a ring with a round cross-section, lying flat in the XY plane around center with Z through its hole.

      outerRadius is the distance from the center to the middle of the tube and innerRadius the tube's own radius, which must be smaller. Rotations and startAngle are in degrees; an outerRotation below 360 leaves the ring open.

      Parameters

      • inputs: Bit.Inputs.JSCAD.TorusDto

        The center, the two radii, the two segment counts, the two rotations and the start angle

      Returns Promise<JSCADEntity>

      The torus solid

      const ring = await bitbybit.jscad.shapes.torus({ center: [0, 0, 0], innerRadius: 1, outerRadius: 5, innerSegments: 16, outerSegments: 48, innerRotation: 0, outerRotation: 360, startAngle: 0 });
      

    primitives on centers

    • Builds one cube of edge length size on every point of centers, in the same order.

      Parameters

      Returns Promise<JSCADEntity[]>

      One cube per center point

      const cubes = await bitbybit.jscad.shapes.cubesOnCenterPoints({ centers: [[0, 0, 0], [20, 0, 0], [40, 0, 0]], size: 10 });
      
    • Builds one box of the given width, height and length on every point of centers, in the same order.

      Parameters

      Returns Promise<JSCADEntity[]>

      One box per center point

      const boxes = await bitbybit.jscad.shapes.cuboidsOnCenterPoints({ centers: [[0, 0, 0], [20, 0, 0]], width: 10, height: 5, length: 20 });
      
    • Builds one elliptic cylinder with the given radii and height on every point of centers, in the same order, as cylinderElliptic does for one.

      Parameters

      Returns Promise<JSCADEntity[]>

      One elliptic cylinder per center point

      const cones = await bitbybit.jscad.shapes.cylinderEllipticOnCenterPoints({ centers: [[0, 0, 0], [20, 0, 0]], height: 10, startRadius: [4, 2], endRadius: [1, 0.5], segments: 32 });
      
    • Builds one cylinder of the given radius and height on every point of centers, in the same order, as cylinder does for one.

      Parameters

      • inputs: CylidnerCentersDto

        The center points, the height, the radius and the segment count

      Returns Promise<JSCADEntity[]>

      One cylinder per center point

      const posts = await bitbybit.jscad.shapes.cylindersOnCenterPoints({ centers: [[0, 0, 0], [20, 0, 0], [40, 0, 0]], height: 10, radius: 1, segments: 16 });
      
    • Builds one ellipsoid with the given radii on every point of centers, in the same order, as ellipsoid does for one.

      Parameters

      Returns Promise<JSCADEntity[]>

      One ellipsoid per center point

      const eggs = await bitbybit.jscad.shapes.ellipsoidsOnCenterPoints({ centers: [[0, 0, 0], [20, 0, 0]], radius: [5, 3, 8], segments: 32 });
      
    • Builds one geodesic sphere of the given radius on every point of centers, in the same order, as geodesicSphere does for one.

      Parameters

      Returns Promise<JSCADEntity[]>

      One geodesic sphere per center point

      const domes = await bitbybit.jscad.shapes.geodesicSpheresOnCenterPoints({ centers: [[0, 0, 0], [20, 0, 0]], radius: 5, frequency: 12 });
      
    • Builds one rounded box with the given sides and rounding on every point of centers, in the same order, as roundedCuboid does for one.

      Parameters

      • inputs: RoundedCuboidCentersDto

        The center points, the three side lengths, the rounding radius and the segment count

      Returns Promise<JSCADEntity[]>

      One rounded box per center point

      const softBoxes = await bitbybit.jscad.shapes.roundedCuboidsOnCenterPoints({ centers: [[0, 0, 0], [20, 0, 0]], width: 10, height: 5, length: 20, roundRadius: 1, segments: 16 });
      
    • Builds one rounded cylinder with the given size and rounding on every point of centers, in the same order, as roundedCylinder does for one.

      Parameters

      Returns Promise<JSCADEntity[]>

      One rounded cylinder per center point

      const pills = await bitbybit.jscad.shapes.roundedCylindersOnCenterPoints({ centers: [[0, 0, 0], [20, 0, 0]], roundRadius: 1, height: 10, radius: 3, segments: 32 });
      
    • Builds one sphere of the given radius on every point of centers, in the same order, as sphere does for one.

      Parameters

      Returns Promise<JSCADEntity[]>

      One sphere per center point

      const balls = await bitbybit.jscad.shapes.spheresOnCenterPoints({ centers: [[0, 0, 0], [20, 0, 0], [40, 0, 0]], radius: 5, segments: 32 });
      

    shapes

    • Builds a solid from its faces, each given as a list of points that go around the face.

      List the points of every face clockwise as seen from outside the solid; the faces must close the solid for booleans to work on it. Each list is read in reverse order and the input is not changed.

      Parameters

      Returns Promise<JSCADEntity>

      The solid

      const tetrahedron = await bitbybit.jscad.shapes.fromPolygonPoints({ polygonPoints: [
      [[0, 0, 0], [10, 0, 0], [0, 10, 0]],
      [[0, 0, 0], [0, 10, 0], [0, 0, 10]],
      [[0, 0, 0], [0, 0, 10], [10, 0, 0]],
      [[10, 0, 0], [0, 0, 10], [0, 10, 0]],
      ] });