I try to subtract a mesh from another mesh and before CSG subtract I need to scale the mesh before.
When I did it via group scale, no problem. CSG subtract works perfect.
Then I try to scale at the geometry level or mesh level, CSG subtract will break vertices there.

with group scale (clean):

with mesh or geometry scale (broken):
Code mesh scale:
svgGroup.children.forEach(item => {
item.scale.set(scale, scale, ratioY)
});
svgGroup.scale.set(1, 1, inverse * 1)
Code group scale:
svgGroup.scale.set(scale, scale, ratioY * inverse * 1)
This lib is used: three.js geometry  csg (threejs.org)
Any idea how this issue could be solved ?
If you scale the geometrie(s), you probably need to regenerate the BVHâ€™s as well?
Iâ€™m not super versed in how meshbvh works but thatâ€™s my first guess.
I donâ€™t see how the meshbvh could notice that you modified verticesâ€¦ so it makes sense to me that youâ€™d have to manually regenerate them.
Alsoâ€¦ csg can be sensitive to the mathematical ranges of the inputsâ€¦
Alsoâ€¦ itâ€™s Really hard if not impossible to remove all mathematical edge cases where CSG can simply fail under certain circumstancesâ€¦ so sometimes it takes some hacky constraints to come up with a reliable application of csg.
All CSG operations come after scaling.
I found a workaround by resizing the svg that is used to generate all of my geometries. In this way my all of my meshes built with potentially different svg size will be the same and all subtract applied on this geometry will be similar.
1 Like
If you have an issue you should provide a live example so people can inspect and see whatâ€™s happening. Otherwise everyone is just left guessing at what might be going on.
1 Like