Computing the hitbox of a mesh with two (or more) materials

Beginner question again:
I have a glb file with two cubes. One of them has two materials (one side with texture a, the other sides with texture b).
When I import the file, the cube with one material is of type “mesh”. The other cube is of type “group” with two children of type “mesh” as children.
This is all correct and fine because you need to split the mesh into two meshes in order to have two draw calls, I guess.

Is there a way to compute the hitbox (bounding box) of the whole group? If I call .geometry on the group, I get “undefined”. Do I need to write my own algorithm for finding all vertices of each sub-mesh and then calculate hitbox from the outermost vertices? Or does THREE provide some method for this?

Kind regards!

Don’t do this to yourself :slight_smile: Try Box3.setFromObject on the entire group instead. It calculates a bounding box of an object taking into account submeshes.

Ah, exactly what I was looking for! Thanks a lot!!