BoundingBox of a compounded Object3D object?

Hello Guys,

i hava a Object3D instance, which includes a CubeGeometry and a TextGeometry. My Question: It is possible to get the
bounding box of this compounded geometries? i ask this, because i saw that the Object3D class doesn’t have a boundingBox-Method
and i have no approach to calculate it for all objects include in the Object3D container.

My idea was it to center the camera depending on the Object3D- containers centeroid and therefore i have to know the boundingBox.

Greetings roundrobin

Author: Fantashit

2 thoughts on “BoundingBox of a compounded Object3D object?

  1. I came across this looking for the same thing and ended up settling on this:

    function getCompoundBoundingBox(object3D) {
        var box = null;
        object3D.traverse(function (obj3D) {
            var geometry = obj3D.geometry;
            if (geometry === undefined) return;
            geometry.computeBoundingBox();
            if (box === null) {
                box = geometry.boundingBox;
            } else {
                box.union(geometry.boundingBox);
            }
        });
        return box;
    }
    
  2. This is a really old thread. Nowadays you can just new new THREE.Box3().setFromObject(object3d)

Comments are closed.