So I am trying to use three-bvh-csg
I have used it before already, but for somethin simple.
What I am trying to do sounds complex to me,
So lets say I have an array of meshes lets call it GroupA.
And I have another array of meshes called GroupB.
I want to Subtract GroupB from GroupA where ever it intersects.
I was thinking of doing like a nested for loop but that would not be a good idea. Does anyone know how to do it?
It’s difficult to predict what will yield the best topology for this operation. Sometimes you’re better off ‘union’ combining multiple objects before then subtracting the combined object from the second combined group, but it’s not always obvious what the ideal configuration is. Have you tried the straightforward for loop, and had issues with it?
1 Like
not yet, do you know if there is a way to prevent a result from forming if two meshes are not intersecting with each other?
Lets say for example i try to subtract Cube 2 from Cube1
const cube = new Operation(geometry, material);
const cube2 = new Operation(geometry2, material2);
cube2.operation = SUBTRACTION;
cube.add(cube2);
const evaluator = new Evaluator();
const result = evaluator.evaluateHierarchy(cube);
const mesh = new THREE.Mesh(
result.geometry,
new THREE.MeshBasicMaterial({ color: Math.random() * 0xffffff })
);
But if they dont intersect is it possible to just remove the mesh?
I don’t think there is a generic mesh->intersects mesh function in mesh-bvh. I think you would have to just try the operation and examine the result, but I could be wrong.
In general, you’ll probably have to do a lot of trial and error, and fiddling to get reliable results with multi mesh operations, since sometimes operations can yield better/worse results depending on order, and sometimes even generate bad meshes or fail in mysterious ways.
Oh i guess i can do an operation of intersection, and see if the result geometry is empty of not
1 Like