CSG Subtract disconnect vertices when geometry or mesh scale is applied before

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.

  1. with group scale (clean):

  2. with mesh or geometry scale (broken):
    image

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 mesh-bvh works but that’s my first guess.
I don’t see how the mesh-bvh 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