Merge two or three 3d shapes

Hello Folks,
Hope you all are doing great.

I am trying to make something like this.
Want to create a 3D shapes (Cube, Cuboid, Cylinder, Cone, Sphere, Hemisphere) with scaling property via scroller and then want to merge two or three shapes and get new form of shape.

Ref. screenshots

  1. For Scaling
    image
    image

  2. For Merging
    image
    image
    image
    image

summary (I want to do Union, Intersection and merging of 2 or 3 different shapes. Also I can scale the dimensions of those shapes according to my requirement.)

Thankyou in advance for any help.

It’s a little hard to tell from your picture… is the idea that the small cylinder is being subtracted from the big cylinder?
Or just that you want it all in one geometry? If you just want it in one geometry, there is BufferGeometryUtils.mergeGeometries()

https://threejs.org/docs/#examples/en/utils/BufferGeometryUtils.mergeGeometries

If you want to actually do subtractions and such, that’s a technique called “CSG” or constructive solid geometry, also known as “boolean modelling”.

There are a few libraries for that, each with different attributes.
The fastest one is mesh-bvh-csg: GitHub - gkjohnson/three-bvh-csg: A flexible, memory compact, fast and dynamic CSG implementation on top of three-mesh-bvh

I also maintain a smaller library that implements similar functionality but without an acceleration structure, so it’s slower for large models, but works pretty well for smaller models:

would also suggest bvh csg GitHub - gkjohnson/three-bvh-csg: A flexible, memory compact, fast and dynamic CSG implementation on top of three-mesh-bvh

it’s fairly fast, too, try this example to get a feel for how it behaves

ps, it also support material groups, if you merge or subtract models with varying materials you can retain them. in vanilla bvh-csg it’s the “useGroups” flag.

Thank you soo much for your time and support.
I want to do Union, Intersection and merging of 2 or 3 different shapes. Also I can scale the dimensions of those shapes according to my requirement.

1 Like