Manthrax CSG library update: now 20% faster, and using BufferGeometry internally

Hi all… I’ve done some spring cleaning on my CSG library located here:

I’ve sped up the algorithm by removing a ton of internal allocation, and also made it work on buffergeometry by default, so no conversion to/from geometry required.

Additionally, I’ve separated the algorithmic core into a separate file with no dependencies that could be easily adapted into a webworker, by serializing/deserializing the vanilla bsp structure.

https://vectorslave.com/csg/demos/CSGShinyDemo.html

21 Likes

Question:
I’m using “clipping planes” for a project in order to interactively show cut-section views of the internals of complex objects.

This method allows me to distinguish the object’s main material from the “cut section” material. Ie: the new internal “side” created by the cut… The faces that are created from the Boolean operation.

Is this an option in your library?

3 Likes

If you only need visualization, there is something called the “goldfeather csg” algorithm that would perform better.
Here’s a sandbox with goldfeather… that I fixed up from this medium article which had the sample but broken:
scs-csg-subtraction-webgl (forked) - CodeSandbox

and the article:

1 Like

@GlifTek btw I just pushed support for color and material id / material groups. Should all work like we were just discussing. You can give each input an id and the result will have separate material groups for each id.

2 Likes

5 Likes

Well that was quick.
Very cool!

ive got objects interacting on the x,y,z axis when they move up and down and vertically.
however i can’t get them to interact if they are rotated at all.
is that a limitation or not implemented yet, or am i missing something?

also polygons moved by morph factor? can that affect the boolean process as well?
i’ve tried but it hasn’t worked.

got diagonals working… wasn’t any problem with the code (obviously works in the demos.) … fault was a silly one on my part…
i had been rotating an empty null which the mesh was attached to.
not the mesh itself.

Thanks a lot! :heart_eyes:

I will try to add it to enable3d :+1:t2:

@manthrax I’ve gone through the CSGStress.html and js files in the most recent version, but I can’t seem to reproduce this example you’ve screenshotted. The CSGStress files generate a slicing torus without multiple materials. I’m trying to get support for material groups in the same way this example demonstrates but can’t seem to get it working. If I use an array of materials as the new mesh’s material, I get an invisible mesh with 0 mats. I’m hoping you can revive the above example in your demos or point me in the right direction.

Thanks!

is what I get when I follow the link.

you can find that example at: https://vectorslave.com/csg/demos/CSGStress.html

1 Like

@manthrax , how well does this CSG library handle pathological intersection cases. Mostly caused by coincident/near-coincident faces between the two intersecting objects?

OLDMAN

I’ll have to let you be the judge of that. I haven’t found many pathological cases that weren’t the result of badly formed input geometry, but the implementation itself is based on a bsp tree. There are no attempts to detect malformed geometry or degenerate cases beforehand.