How can I use 2D CSG functions?


I’m using csg.js with three.js and it seems it only supports 3D CSG.

I would like to intersect and union 2D (three.js) geometries. Is there any way I can do 2D CSG with three.js ?

Besides holes/subtract there is no such boolean operation like union as far as i remember, but there are small to larger libraries you can use like clipperjs.

Thanks! Is it possible to use clipper.js for three.js geometries ?

Not directly, you need to pass paths and it will spit out paths. Clipper works with paths/contours instead triangles, i’m not sure if this fits your need. You can insert each triangle as path of three points and just union this triangle soup for example. For the output paths you can use three again to triangulate them.

If your input are paths/contours like you use with three, you can directly insert the coordinates.