Bitbybit Docs
    Preparing search index...

    Class ManifoldShapes

    Building Manifold solids: the cube, sphere, cylinder and tetrahedron primitives, and solids from triangle meshes or lists of triangles. The kernel keeps Z as its up axis, so a cylinder stands along Z and a cube's size runs along X, Y and Z; every solid comes back as a closed triangle mesh.

    Index

    Constructors

    create

    • Builds a solid from plain mesh data, the form manifoldToMesh hands out, so a mesh can make a round trip through other tools.

      The mesh must be closed and consistently oriented, or an error is thrown; degenerate triangles and unneeded vertices are removed on the way in.

      Parameters

      Returns Promise<ManifoldPointer>

      The solid

      const solid = await bitbybit.manifold.manifold.shapes.manifoldFromMesh({ mesh });
      
    • Builds a solid from a list of triangles, each given as three points, merging points that coincide.

      The triangles must form a closed, consistently oriented surface; entries that are not three points are skipped, and points with missing coordinates throw an error.

      Parameters

      Returns Promise<ManifoldPointer>

      The solid

      const solid = await bitbybit.manifold.manifold.shapes.fromPolygonPoints({ polygonPoints: triangles });
      

    primitives

    • Creates a cube solid with the given side length.

      With center true the cube is centered on the origin; otherwise its corner sits on the origin and it extends along the positive axes.

      Parameters

      Returns Promise<ManifoldPointer>

      The box solid

      const box = await bitbybit.manifold.manifold.shapes.cube({ size: 10, center: true });
      
    • Creates a sphere solid of the given radius, centered on the origin.

      circularSegments is the number of segments around the sphere; it is rounded up to a multiple of four, since the sphere is built by refining an octahedron.

      Parameters

      Returns Promise<ManifoldPointer>

      The sphere solid

      const ball = await bitbybit.manifold.manifold.shapes.sphere({ radius: 5, circularSegments: 32 });
      
    • Creates a tetrahedron solid centered on the origin, with one corner at [1, 1, 1] and the others placed symmetrically.

      Returns Promise<ManifoldPointer>

      The tetrahedron solid

      const tetra = await bitbybit.manifold.manifold.shapes.tetrahedron();
      
    • Creates a cylinder solid standing along Z, or a cone when the top radius differs from the bottom one.

      radiusLow is the bottom radius and must be above 0, radiusHigh the top radius, which may be 0 for a point; circularSegments sets how round the sides are. center centers the cylinder on the origin instead of standing it on it.

      Parameters

      Returns Promise<ManifoldPointer>

      The cylinder or cone solid

      const cone = await bitbybit.manifold.manifold.shapes.cylinder({ height: 10, radiusLow: 4, radiusHigh: 1, circularSegments: 32, center: false });