CSG alternatives

We are using CSG successfully here to cut meshes but the time it takes to perform these cuts depends greatly on the complexity of the meshes. Given that we can’t control for the mesh complexity (the meshes are coming from an external source), I’m exploring different options for how we can perform the CSG operations.

We have currently offloaded the cutting to our NodeJS server and are using a NullEngine, but the process isn’t any faster, it’s just non-blocking at that point.

What I’d like to do is to offload the CSG cutting to a stand-alone service and not use Javascript for the CSG operation.

So my question to the forum is, what technologies are out there for performing CSG operations that ARENT javascript based and are fast.

Any help is appreciated!


Hello! CSG is certainly a pretty heavy operation :slight_smile: I think CGAL ( The Computational Geometry Algorithms Library (cgal.org)) which is C++ based, might be a good option.

You should consider a web worker for that, I offload compute work like retargeting matrices, mesh computation, game minimap, and various assets loading.

Using web workers has been a (literally) game changer for me.


We looked into web workers, but that only solved the problem of doing the boolean operations off thread, the performance was still terrible.

1 Like

Thanks for the suggestion, I ended up finding JSCAD (https://github.com/jscad/OpenJSCAD.org) which has boolean operations that are “insanely” fast.

For comparison, a cut that would take 20+ minutes in BabylonJS, takes 23 seconds using JSCAD.

It was relatively easy to integrate the 2 systems as well. I used the STLExport.CreateSTL function to get the methods as STL, turn them into a Buffer that I loaded into JSCAD to perform the operations (boolean subtract and turning that back into an STL).

The “hard” part is getting the resulting cut STL back into BabylonJS. There is no easy “load this ArrayBuffer into a BabylonJS scene” like ThreeJS has. Its either Base64 (which is broken for STLs), or what I ended up doing, uploading the STL to a server a loading it into the scene from the resulting URL.

Anyhow, thanks again for the suggestion!

1 Like

@bghgary were the base64 improvments you did not available for all loaders ?

I do remember when I was making the STL exporter supporting binary was skipped cause screw that noise, so I assume the importer is the same its been so long now I don’t remember though.

update Actually I am mistaken looks like I did add binary support to the serializer at some point. Assumingly because Gary had/has the support for the import working.

1 Like

Wasn’t my changes, but it is glTF only.


Hello @jeffpennal just checking in, was your question answered? :slight_smile:

Yes it was thanks!

1 Like