Bitbybit Docs
    Preparing search index...

    Class ManifoldBooleans

    Combining Manifold solids: fusing, cutting and intersecting two or many at once, and splitting a solid with another solid or a plane. Because the kernel works on closed triangle meshes, these are fast and always give a watertight result; the two-shape and many-shape forms give the same results and exist for convenience. Every method returns new solids and leaves the inputs as they are.

    Index

    Constructors

    2 manifolds

    • Cuts the second solid out of the first, the same as subtract.

      Parameters

      Returns Promise<ManifoldPointer>

      The first solid minus the second

      const holed = await bitbybit.manifold.manifold.booleans.differenceTwo({ manifold1: cube, manifold2: sphere });
      

    a to b

    • Cuts the second solid out of the first, leaving what remains of the first.

      Parameters

      Returns Promise<ManifoldPointer>

      The first solid minus the second

      const holed = await bitbybit.manifold.manifold.booleans.subtract({ manifold1: cube, manifold2: sphere });
      

    minkowski

    • Sweeps the second solid over the whole surface of the first and fuses everything it passes through, growing the first solid by the shape of the second - the Minkowski sum, which is how a solid is rounded or padded by a sphere.

      Parameters

      Returns Promise<ManifoldPointer>

      The grown solid

      const padded = await bitbybit.manifold.manifold.booleans.minkowskiSum({ manifold1: cube, manifold2: sphere });
      
    • Sweeps the second solid over the whole surface of the first and cuts away everything it passes through, shrinking the first solid by the shape of the second - the Minkowski difference, the erosion that undoes a Minkowski sum.

      Parameters

      Returns Promise<ManifoldPointer>

      The shrunken solid

      const eroded = await bitbybit.manifold.manifold.booleans.minkowskiDifference({ manifold1: cube, manifold2: sphere });
      

    multiple

    • Cuts every further solid in the list out of the first one.

      Parameters

      Returns Promise<ManifoldPointer>

      The first solid minus all the others

      const holed = await bitbybit.manifold.manifold.booleans.difference({ manifolds: [cube, sphere, cylinder] });
      

    split

    • Cuts a solid with another solid and keeps both pieces: the part inside the cutter and the part outside it.

      Cheaper than an intersection followed by a subtraction when both are needed.

      Parameters

      Returns Promise<ManifoldPointer[]>

      Two solids: the part inside the cutter, then the part outside it

      const [inside, outside] = await bitbybit.manifold.manifold.booleans.split({ manifoldToSplit: cube, manifoldCutter: sphere });
      
    • Cuts a solid with a plane and keeps both pieces.

      The plane is given by its normal and its distance from the origin along that normal; the first piece lies on the side the normal points to, the second on the other side.

      Parameters

      Returns Promise<ManifoldPointer[]>

      Two solids: the part on the normal's side, then the rest

      const [top, bottom] = await bitbybit.manifold.manifold.booleans.splitByPlane({ manifold: cube, normal: [0, 0, 1], originOffset: 0.5 });
      
    • Cuts a solid into slabs with several parallel planes, all with the same normal, at the given distances from the origin.

      Each cut keeps the part on the far side of the normal as a finished piece and carries the rest to the next distance, so the offsets should increase; n offsets give n + 1 pieces, empty ones dropped.

      Parameters

      Returns Promise<ManifoldPointer[]>

      The slabs, one more than the offsets given

      const slabs = await bitbybit.manifold.manifold.booleans.splitByPlaneOnOffsets({ manifold: cube, normal: [0, 0, 1], originOffsets: [0.25, 0.5, 0.75] });
      

    trim

    • Cuts a solid with a plane and keeps only the part on the side the normal points to.

      The plane is given by its normal and its distance from the origin along that normal.

      Parameters

      Returns Promise<ManifoldPointer>

      The part of the solid on the normal's side

      const half = await bitbybit.manifold.manifold.booleans.trimByPlane({ manifold: sphere, normal: [0, 0, 1], originOffset: 0 });