简体   繁体   English

我怎样才能得到一个three.js组的尺寸?

[英]How can I get the dimensions of a three.js group?

I can get the dimensions of a mesh (Three.Mesh):我可以获得网格的尺寸(Three.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;

But a group that has multiple meshes within it:但是一个包含多个网格的

var mygroup = new THREE.Group();

doesn't have a computeBoundingBox()/boundingBox?没有computeBoundingBox()/boundingBox?

Thanks to one of the commentors, it was an easy solution:感谢其中一位评论者,这是一个简单的解决方案:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM