You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WebCAD/sample/Getbox.ts

35 lines
785 B

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;
}
}