Skip to main content

Library for geometric robustness

Project description

codecov PyPI version npm version twitter


OpenSCAD, IFCjs, Grid.Space, and OCADml have all integrated our Manifold geometry kernel! Why? Because its reliability is guaranteed and it's 1,000 times faster than other libraries. See our usage and performance discussions for all the latest and to add your own projects & analyses.

If you like OpenSCAD / JSCAD, you might also like ManifoldCAD - our own solid modelling web app. Our WASM is not multithreaded yet, but it's still quite fast and a good way to test out our Manifold library.

A metallic Menger sponge

Note for Firefox users

If you find the editor is stuck on Loading..., setting dom.workers.modules.enabled: true in your about:config, as mentioned in the discussion of the issue#328 of this repository may solve the problem.


API Documentation | Algorithm Documentation | Blog Posts | Web Examples

Manifold is a geometry library dedicated to creating and operating on manifold triangle meshes. A manifold mesh is a mesh that represents a solid object, and so is very important in manufacturing, CAD, structural analysis, etc. Further information can be found on the wiki.

This is a modern C++ library that Github's CI verifies builds and runs on a variety of platforms. Additionally, we build bindings for JavaScript (manifold-3d on npm), Python (manifold3d), and C to make this library more portable and easy to use.

System Dependencies (note that we will automatically download the dependency if there is no such package on the system):

  • GLM: A compact header-only vector library.
  • Thrust: NVIDIA's parallel algorithms library (basically a superset of C++17 std::parallel_algorithms)
  • tbb: Intel's thread building blocks library. (only when MANIFOLD_PAR=TBB is enabled)
  • gtest: Google test library (only when test is enabled, i.e. MANIFOLD_TEST=ON)

Other dependencies:

What's here

This library is fast with guaranteed manifold output. As such you need manifold meshes as input, which this library can create using constructors inspired by the OpenSCAD API, as well as more advanced features like smoothing and signed-distance function (SDF) level sets. You can also pass in your own mesh data, but you'll get an error status if the imported mesh isn't manifold. Various automated repair tools exist online for fixing non manifold models, usually for 3D printing.

The most significant contribution here is a guaranteed-manifold mesh Boolean algorithm, which I believe is the first of its kind. If you know of another, please open a discussion - a mesh Boolean algorithm robust to edge cases has been an open problem for many years. Likewise, if the Boolean here ever fails you, please submit an issue! This Boolean forms the basis of a CAD kernel, as it allows simple shapes to be combined into more complex ones.

To aid in speed, this library makes extensive use of parallelization, generally through Nvidia's Thrust library. You can switch between the TBB, and serial C++ backends by setting a CMake flag. Not everything is so parallelizable, for instance a polygon triangulation algorithm is included which is serial. Even if compiled with parallel backend, the code will still fall back to the serial version of the algorithms if the problem size is small. The WASM build is serial-only for now, but still fast.

Note: OMP and CUDA backends are now removed

Look in the samples directory for examples of how to use this library to make interesting 3D models. 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, my library is dramatically faster and the code is more flexible.


Only CMake, a C++ compiler, and Python are required to be installed and set up to build this library (it has been tested with GCC, LLVM, MSVC). However, a variety of optional dependencies can bring in more functionality, see below.

Build and test (Ubuntu or similar):

git clone --recurse-submodules
cd manifold
mkdir build
cd build

CMake flags (usage e.g. -DMANIFOLD_DEBUG=ON):

  • MANIFOLD_JSBIND=[OFF, <ON>]: Build js binding when using emscripten.
  • MANIFOLD_CBIND=[<OFF>, ON]: Build C FFI binding.
  • MANIFOLD_PYBIND=[OFF, <ON>]: Build python binding.
  • MANIFOLD_PAR=[<NONE>, TBB]: Provides multi-thread parallelization, requires libtbb-dev if TBB backend is selected.
  • MANIFOLD_EXPORT=[<OFF>, ON]: Enables GLB export of 3D models from the tests, requires libassimp-dev.
  • MANIFOLD_DEBUG=[<OFF>, ON]: Enables internal assertions and exceptions.
  • MANIFOLD_TEST=[OFF, <ON>]: Build unittests.
  • TRACY_ENABLE=[<OFF>, ON]: Enable integration with tracy profiler. See profiling section below.
  • BUILD_TEST_CGAL=[<OFF>, ON]: Builds a CGAL-based performance comparison, requires libcgal-dev.

Offline building:

  • FETCHCONTENT_SOURCE_DIR_GLM: path to glm source.
  • FETCHCONTENT_SOURCE_DIR_GOOGLETEST: path to googletest source.

The build instructions used by our CI are in manifold.yml, which is a good source to check if something goes wrong and for instructions specific to other platforms, like Windows.


To build the JS WASM library, first install NodeJS and set up emscripten:

(on Mac):

brew install nodejs
brew install emscripten

(on Linux):

sudo apt install nodejs
git clone
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk/

Then build:

cd manifold
mkdir buildWASM
cd buildWASM
emcmake cmake -DCMAKE_BUILD_TYPE=Release .. && emmake make
node test/manifold_test.js


The CMake script will build the python binding manifold3d automatically. To use the extension, please add $BUILD_DIR/bindings/python to your PYTHONPATH, where $BUILD_DIR is the build directory for CMake. Examples using the python binding can be found in bindings/python/examples. To see exported samples, run:

sudo apt install pkg-config libpython3-dev python3 python3-distutils python3-pip
pip install trimesh
python3 -e

Run the following code in the interpreter for python binding documentation:

>>> import manifold3d
>>> help(manifold3d)

For more detailed documentation, please refer to the C++ API.


Contributions are welcome! A lower barrier contribution is to simply make a PR that adds a test, especially if it repros an issue you've found. Simply name it prepended with DISABLED_, so that it passes the CI. That will be a very strong signal to me to fix your issue. However, if you know how to fix it yourself, then including the fix in your PR would be much appreciated!


There is now basic support for the Tracy profiler for our tests. To enable tracing, compile with -DTRACY_ENABLE=on cmake option, and run the test with Tracy server running.

About the author

This library was started by Emmett Lalish. I am currently a Google employee and this is my 20% project, not an official Google project. At my day job I'm the maintainer of <model-viewer>. I was the first employee at a 3D video startup, Omnivor, and before that I worked on 3D printing at Microsoft, including 3D Builder. Originally an aerospace engineer, I started at a small DARPA contractor doing seedling projects, one of which became Sea Hunter. I earned my doctorate from the University of Washington in control theory and published some papers.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

manifold3d-2.2.1.tar.gz (374.9 kB view hashes)

Uploaded Source

Built Distributions

manifold3d-2.2.1-cp312-cp312-win_amd64.whl (799.6 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

manifold3d-2.2.1-cp312-cp312-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

manifold3d-2.2.1-cp312-cp312-macosx_11_0_arm64.whl (604.4 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

manifold3d-2.2.1-cp312-cp312-macosx_10_14_x86_64.whl (723.9 kB view hashes)

Uploaded CPython 3.12 macOS 10.14+ x86-64

manifold3d-2.2.1-cp311-cp311-win_amd64.whl (800.2 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

manifold3d-2.2.1-cp311-cp311-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

manifold3d-2.2.1-cp311-cp311-macosx_11_0_arm64.whl (604.9 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

manifold3d-2.2.1-cp311-cp311-macosx_10_14_x86_64.whl (724.1 kB view hashes)

Uploaded CPython 3.11 macOS 10.14+ x86-64

manifold3d-2.2.1-cp310-cp310-win_amd64.whl (800.3 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

manifold3d-2.2.1-cp310-cp310-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

manifold3d-2.2.1-cp310-cp310-macosx_11_0_arm64.whl (605.2 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

manifold3d-2.2.1-cp310-cp310-macosx_10_14_x86_64.whl (724.2 kB view hashes)

Uploaded CPython 3.10 macOS 10.14+ x86-64

manifold3d-2.2.1-cp39-cp39-win_amd64.whl (801.0 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

manifold3d-2.2.1-cp39-cp39-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

manifold3d-2.2.1-cp39-cp39-macosx_11_0_arm64.whl (605.3 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

manifold3d-2.2.1-cp39-cp39-macosx_10_14_x86_64.whl (724.4 kB view hashes)

Uploaded CPython 3.9 macOS 10.14+ x86-64

manifold3d-2.2.1-cp38-cp38-win_amd64.whl (821.5 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

manifold3d-2.2.1-cp38-cp38-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

manifold3d-2.2.1-cp38-cp38-macosx_11_0_arm64.whl (604.9 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

manifold3d-2.2.1-cp38-cp38-macosx_10_14_x86_64.whl (724.2 kB view hashes)

Uploaded CPython 3.8 macOS 10.14+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page