I been researching various places about trying to get the width and height of a mesh but I have been able to find anything that works. I have a collada model that I imported and all I want to do is get the dimension of it in Webgl/Three.js Units so that I can calculate collision in my simple game. So how would I go about getting the width and height of a mesh in THREE.js?
我一直在研究各种各样的地方,试图获得网格的宽度和高度,但我已经能够找到任何有用的东西。我有一个我导入的collada模型,我想做的就是在Webgl / Three.js单位中获取它的尺寸,以便我可以在简单的游戏中计算碰撞。那么如何在THREE.js中获取网格的宽度和高度呢?
1 个解决方案
#1
46
If you're ok with a basic bounding box, you can use a THREE.Box3
如果您对基本边界框没问题,可以使用THREE.Box3
var box = new THREE.Box3().setFromObject( colladaModel );
console.log( box.min, box.max, box.getSize() );
#1
46
If you're ok with a basic bounding box, you can use a THREE.Box3
如果您对基本边界框没问题,可以使用THREE.Box3
var box = new THREE.Box3().setFromObject( colladaModel );
console.log( box.min, box.max, box.getSize() );