Looking for Updated plug-in for CSG

We have a project that is using Chandler Prall’s CSG Plug-in ( https://github.com/chandlerprall/ThreeCSG ) however, this plug-in has not been updated in years. We would like to update all of our code to use BufferGeometry, however, the CSG Plug-in does not support it.

Has somebody already updated this plug-in to use BufferGeometry or is there an alternative plug-in for ThreeCSG, or would somebody like to fork that project and create a new one updated one with BufferGeometry support?

Or even better, how about adding CSG to Threejs … Babylon.js comes with CSG…

1 Like

Hi @3DFish,

there’s nothing to it, honourable :fish: , just check out an earlier version of three.js, and copy the Geometry → BufferredGeometry conversion code from there.

Regarding your proposal of integrating CSG(Constructive Solid Geometry) into three.js - I don’t really believe it belongs in three.js, at least not in the main build. If you’re interested in contributing an example though - I would love to to see that, many people would find that useful! :cat:

1 Like

Hi Alex,

There are a lot of earlier versions of ThreeJS… would you happen to know what version I should look at to find this? Would you be interested in updating the plug-in… I would even be willing to provide some compensation for the update and make the updated plug-in public… It doesn’t need to be part of the main build of ThreeJS, but if you could get it included as part of the official build, maybe as part of the official examples, or like the optional loaders, I do think it should be somehow connected to the official build so that it gets maintained. This is a very important feature… and something that Babylon.js has built-in ( which I just found out when I was searching for an updated solution for ThreeJS.)

Hello Alex,

Could you please take a look at this issue a that I raised on Github related to this? https://github.com/mrdoob/three.js/issues/16099

Thanks,

1 Like
1 Like

@Usnul what do you mean by this? To my knowledge there has never been CSG code in the repo.

@looeee

Ha, you’re right! I mean that… if you have a piece of code that does CSG on Geometry (old three.js data) and you have a converter from Geometry to BufferGeometry - you’re golden :+1:

But to be honest, I see CSG everywhere, when I walk outside in the morning and see a tree :deciduous_tree: - I immediately start thinking about how many smaller cubes :black_square_button: needed to be subtracted from a very large cube to result in this marvel of nature, and then I go back home :house: in the evening, since I tend to get pretty hungry :apple: at that point.

2 Likes

Well, as long as you don’t care about performance. If you’re trying to do things in real-time then you’re gonna get a lot of pauses while you convert.

Here’s a list of the projects that have been suggested so far:




It doesn’t look like any of these support BufferGeometry currently (unless I missed something).

@3DFish, I’d say your best bet is to ask on the repos for those projects, and see whether the owners would consider converting them to use BufferGeometry. If you offer them a small fee they may be receptive, or they may even do it for free.

If that doesn’t work out, I would put the conversion of BufferGeometry in your app on the backburner for a month or so and see if there are any further developments. If not, then you will need to pay someone to convert one of these libraries.

2 Likes

I did another conversion of the madebyevan CSG library that ya’ll may find useful… it works with current three (103) and fixed some issues I had with the older module out there. It allows buffergeometries but only by converting them to geometries internally.

Hope this helps someone and feel free to give feedback/suggestions.

7 Likes

I’ve also added a demo and a screenshot to my library:

feedback welcome

@3DFish

2 Likes

The only thing I could get working was Manthrax’s CSG solution using Three v103.

I kept getting very strange results that appeared to be axis related with other solutions. See the loss of volume on the sides:

With Manthrax’s library it worked fine:

I do not understand why the older solutions produce flat sides.

They were just buggy implementations. I re-ported my version from the original code on madebyevan. Glad you found it useful!

@manthrax Many thanks for doing that! It’s something I had in my to-do list for many years now. It’s that something you would like to contribute to the main repo?

2 Likes

Yeah I’d be happy to. But it will probably take a little work to make it consistent with the rest of THREE, but I have been short on time lately. The interface is a little clunky as it stands.

3 Likes

We can help with the clean up :grinning:

3 Likes

I made a shinier demo for my CSG port and fixed some bugs:

http://vectorslave.com/csg/CSGShinyDemo.html

image

7 Likes

@manthrax good work. I was able to make it work with Simple Box, Sphere and Tube Geometry but unfortunately its not working with extruded mesh geometry. Am I expecting too much?

Do you have a repro of the issue that i could see?

1 Like

@mrdoob was this pulled into main? Is there an example? I am still importing @manthrax lib to complete this operation, which is fine, but I wasn’t sure if this is now redundant.