Two-dimensional cross sections guaranteed to be without self-intersections, or overlaps between polygons (from construction onwards). This class makes use of the Clipper2 library for polygon clipping (boolean) and offsetting operations.
This library's internal representation of an oriented, 2-manifold, triangle mesh - a simple boundary-representation of a solid object. Use this class to store and operate on solids, and use MeshGL for input and output, or potentially Mesh if only basic geometry is required.
In addition to storing geometric data, a Manifold can also store an arbitrary number of vertex properties. These could be anything, e.g. normals, UV coordinates, colors, etc, but this library is completely agnostic. All properties are merely float values indexed by channel number. It is up to the user to associate channel numbers with meaning.
Manifold allows vertex properties to be shared for efficient storage, or to have multiple property verts associated with a single geometric vertex, allowing sudden property changes, e.g. at Boolean intersections, without sacrificing manifoldness.
Manifolds also keep track of their relationships to their inputs, via OriginalIDs and the faceIDs and transforms accessible through MeshGL. This allows object-level properties to be re-associated with the output after many operations, particularly useful for materials. Since separate object's properties are not mixed, there is no requirement that channels have consistent meaning between different inputs.
Import a model, and convert it to a Manifold object for manipulation.
Import a model, for display only.
Triangulates a set of /epsilon-valid polygons.
Define a material using the glTF metallic-roughness physically-based
rendering model. Materials can be applied to a model through setMaterial(),
or set as a GLTFNode property.
Wrap any shape object with this method to display it and any copies as the
result, while ghosting out the final result in transparent gray. Helpful for
debugging as it allows you to see objects that may be hidden in the interior
of the result. Multiple objects marked only() will all be shown.
Return a shallow copy of the input manifold with the given material properties applied. They will be carried along through operations.
Wrap any shape object with this method to display it and any copies in
transparent red. This is particularly useful for debugging subtract() as it
will allow you find the object even if it doesn't currently intersect the
result.
The abstract class from which other classes inherit. Common methods and properties live here.
Position a manifold model for later export.
Include an imported model for visualization purposes.
Get a list of GLTF nodes that have been created in this model.
Clear the list of cached GLTF nodes.
Get the current duruation of the animation, in seconds.
Get the current animation frame rate.
Get the current animation repeat mode.
Apply a morphing animation to the input manifold. Specify the end function which will be applied to the vertex positions of the last frame and linearly interpolated across the length of the overall animation. This animation will only be shown if this manifold is used directly on a GLTFNode.
Apply a morphing animation to the input manifold. Specify the start function which will be applied to the vertex positions of the first frame and linearly interpolated across the length of the overall animation. This animation will only be shown if this manifold is used directly on a GLTFNode.
Determine the appropriate number of segments for a given radius.
Get the current angle constraint.
Get the current edge length constraint.
Is this module running in manifoldCAD.org or the ManifoldCAD CLI?
A three dimensional box, aligned to the coordinate system.
3x3 matrix stored in column-major order.
4x4 matrix stored in column-major order.
A two dimensional rectangle, aligned to the coordinate system.
A vector in two dimensional space.
A vector in three dimensional space.
A manifold mesh is a mesh that represents a solid object, and so is very important in manufacturing, CAD, structural analysis, etc. 'Manifold' implies that there are no gaps or tears, and that all faces are oriented outwards.
Manifold Library
[ Using Manifold | Examples | Manifold WASM Developer Guide ]
Manifold is a geometry library dedicated to creating and operating on manifold triangle meshes. It is available as a WASM module that runs in any modern browser.
Our primary goal is reliability: guaranteed manifold output without caveats or edge cases. Our secondary goal is performance: efficient algorithms that make extensive use of parallelization, or pipelining when only a single thread is available.
ManifoldCAD.org
[ ManifoldCAD | ManifoldCAD User Guide ]
If you like OpenSCAD / JSCAD, you might also like ManifoldCAD - our own solid modelling web app where you script in JS/TS and save a GLB or 3MF file. It contains several examples showing how to use our API to make interesting shapes. You may notice that some of these examples bare a certain resemblance to my OpenSCAD designs on Thingiverse, which is no accident. Much as I love OpenSCAD, this library is dramatically faster and the code is more flexible.
manifoldCAD = manifold + TypeScript + glTF
Running ManifoldCAD
With a Browser
Just go to ManifoldCAD.org, and check out the examples!
On the Command Line
ManifoldCAD has a command line interface. It can be run directly as
./bin/manifold-cad. It can also be run vianpx. If Manifold is not already present, usenpx manifold-3d manifold-cadornpx manifold-3d. If Manifold is already installed,npx manifold-cadwill suffice.The output file can be in either
.glbor.3mfformat, determined by extension.Coordinate Systems
ManifoldCAD uses a right-handed coordinate system where '+Z' is up. Length units are assumed to be millimetres. This is slightly at odds with glTF, which also uses a right handed coordinate system, but specifies '+Y' as up, and length units are in metres.
ManifoldCAD will scale and rotate automatically when importing or exporting glTF models. This means that an arrow pointing in the '+Z' direction in will point in the '+Y' direction after export. However, that arrow will still point up, and will still be the same size.