Help with Convex Hull/Geometry

Hello ThreeJS Community! I have a problem I’m hoping someone can help me with. I am trying to traverse a loaded .gltf and use the ConvexHull’s setFromObject function to create a hull from that object, then pass the hull to a modified ConvexGeometry constructor (modified to accept a hull instead of a set of points, since I noticed that ConvexGeometry relies on ConvexHull anyway).

My ultimate goal with this is to create a convex geometry that maps exactly to given mesh, then make the geometry invisible and use it to create a physics mesh. Here is my code to create the ConvexGeometry:

However, the created geometries do not conform to the geometry of the mesh. Here is an image of this logic applied to only one of the .gltlf’s child meshes:

Does anyone have an idea why this might be happening? Let me know if you need any more information about the code or what I’m doing. Just in case, here is the modified ConvexGeometry constructor I am using:

Thanks in advance for your time and assistance!

Are the columns in your scene all separate objects? You could check this by opening the glTF file in Blender or the three.js editor, for example.

It sort of looks like the convex hull is wrapping multiple columns, as if they’re not each a separate child mesh.

I feel pretty dumb now! Just checked and of course you are right and this is the reason my approach isn’t working. Haven’t messed too much with Blender yet, someone else on my team for this project has done most of that. Do you know of any way to programmatically make them all seperate objects or so I just need to edit the gltf in Blender to do this?

Thanks again for your help.

I’m sure there’s a couple hotkeys in Blender that would make quick work of it… something like:

  • Tab Switch to edit mode.
  • 3 Switch to face selection mode, then select a face on any column.
  • Ctrl + L Select linked faces.
  • P + Selection. Split selection into a separate mesh.

Not aware of any easy way to do the modeling changes in the threejs engine though, no.