[SOLVED] Csg.js port broken with latest release - v1.40.0

I’ve been using this port of csg.js for boolean operations in my project. It was working for about a few weeks after commenting a line out in the port but with the release of v1.40.0, the mesh appears to not be rendering properly.

With v1.40.0

There should be a perfect circle cut in the wall in this screenshot here. It looks perfect in v1.39.4.

The csg port hasn’t been updated in 3 years, though I did have to do some debugging it to get to work with v.1.39.4. I did notice the createMesh function was updated in the latest release. Could anyone provide me more info or where to start?

Or if there’s a different way I can approach doing mesh boolean operations, that would be great as well. :slight_smile:


Hi @Kano_Ngo and welcome,

There was something regarding 2d in the latest release. Maybe this has to do something about your problem? Other then that im no expert on boolean.

Yes, you are right. Something has broken this in 1.40.0. Here’s 1.40.0:


And here’s 1.39.4:


We’ll look into it.

My guess is that it might have something to do with this PR:

It seems I’m a good guesser. This is the scene for the commit directly before that PR:

It’s broken after.

OK @Kano_Ngo, I have found the problem. It’s line 354 in playcanvas.csg.js which pokes into private structures in the vertex iterator:

        var numVertices = iterator.element[attributeMap.position].array.length /  format.size*4;

Change it to:

        var numVertices = mesh.vertexBuffer.numVertices;

The code above is ‘legal’ and public API.


Wow, thank you, Will! It’s working now. :slight_smile: