You don't need to iterate over all children of the object; there's a method in the library to do this: THREE.Box3#setFromObject
: see the docs. For example, you can do:
var bbox = new THREE.Box3().setFromObject(obj);
to get the bounding box of obj
, including all of its children, and accounting for any translations, rotations, etc.
Note that the BoundingBox
helper is intended to draw a bounding box in the scene, not for just calculating the bounding box of some object.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…