@Usnul what do you mean by this? To my knowledge there has never been CSG code in the repo.
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
But to be honest, I see CSG everywhere, when I walk outside in the morning and see a tree - I immediately start thinking about how many smaller cubes needed to be subtracted from a very large cube to result in this marvel of nature, and then I go back home in the evening, since I tend to get pretty hungry at that point.
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.
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.
I’ve also added a demo and a screenshot to my library:
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?
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.
We can help with the clean up
I made a shinier demo for my CSG port and fixed some bugs:
@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?
No, it’s no part of the main repository.
Hi there, I am not quite sure if this is the right place, but I am referring to @manthrax ‘s version of the CSG library.
So far, mesh subtraction works great, but it does not seem to take the meshes’ positions into account. Can anybody verify this?
I have an example here: https://jsfiddle.net/zyj1oucx/
The actual code starts on line 2352. (The threejs and csg libraries are included inline above).
The code should subtract the simple box “clampingMesh” from the complex mesh “component” at position (-15, -50, 0).
Instead, it’s subtracted at (0, 0, 0,).
The sample shows the mesh to subtract at the right position, but the subtraction is on top of the cylinder.
Does the following update fiddle look better? https://jsfiddle.net/zhys4b8w/
The idea is to update
clampingMesh before performing the subtraction.
Thank you very, very much. This is almost what I tried to achieve: https://jsfiddle.net/3snmhuvb/
I must have overseen the part with updating the matrix in the Github documentation. Shame on me.
Now I have to find out, how to “close” the subtracted shape. It is not desired to see through.
Edit: Experimenting with double sided materials does not help. Am I missing something, again?