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