如何获得Three.js组的尺寸?

时间:2019-12-26 20:36:38

标签: javascript three.js

我可以得到mesh(三层网格)的尺寸:

mymesh.geometry.computeBoundingBox()
var bbox = mymesh.geometry.boundingBox;
var bboxWidth = bbox.max.x - bbox.min.x;
var bboxHeight = bbox.max.y - bbox.min.y;
var bboxDepth = bbox.max.z - bbox.min.z;

但是其中有多个网格的group

var mygroup = new THREE.Group();

没有computeBoundingBox()/ boundingBox吗?

1 个答案:

答案 0 :(得分:0)

感谢其中一位评论者,这是一个简单的解决方案:

var box = new THREE.Box3().setFromObject(theGroup);
var sizeX = box.getSize().x;
var sizeY = box.getSize().y;
var sizeZ = box.getSize().z;