CSG with BufferGeometry (three >= r125)

As part of my project enable3d, I maintain a CGS version that works with BufferGeometries.

It uses Geometry, DirectGeometry, Face3 and the old BufferGeometry().fromGeometry under the hood. But it works great!

You can install it from npm and use it in any three.js (>=0.125.2) project.

// for now, install the latest dev version
npm install @enable3d/three-graphics@0.22.0-dev.1
import { CSG } from '@enable3d/three-graphics/jsm/csg'

const meshC = CSG.intersect(meshA, meshB)
const meshD = CSG.subtract(meshA, meshB)
const meshE = CSG.union(meshA, meshB)

scene.add(meshC, meshD, meshE)

To see it in action, check out the threejs-ammojs-webpack-example.


Hi Yannick,

Does this work with custom made geometries (irregular geometries) with thousands of vertices of both meshes ?

Looks great !

Thanks :slight_smile:

I don’t know if there is a limit. But in this post, I have subtracted two boxes from Suzanne and it works great!

1 Like