function getBox(obj: THREE.Object3D): THREE.Box3 { if (obj.hasOwnProperty("geometry")) { let geom = obj["geometry"]; geom.computeBoundingBox(); return geom.boundingBox; } else { if (obj.children.length > 0) { let box; for (var index = 0; index < obj.children.length; index++) { var element = obj.children[index]; let box2 = getBox(element); if (box2) { if (box) { box.union(box2); } else box = box2; } } return box; } return null; } }