从boundingBoxHelper到BoxHelper

时间:2017-01-04 08:44:08

标签: three.js

在threejs r83中,boundingBoxHelper已被弃用,而不是使用BoxHelper。你如何获得BoxHelper的盒子?

let boundingBox = new THREE.BoxHelper(mesh);
myObj.size = bounding.box.getSize(); // error

谢谢你的帮助!

1 个答案:

答案 0 :(得分:4)

以下是如何使用BoxHelper并获取可渲染对象或网格的大小。

var box3 = new THREE.Box3();
var size = new THREE.Vector3(); // create once and reuse

...

var boxHelper = new THREE.BoxHelper( mesh );
scene.add( boxHelper );

box3.setFromObject( boxHelper ); // or from mesh, same answer
console.log( box3 );

box3.getSize( size ); // pass in size so a new Vector3 is not allocated
console.log( size )

three.js r.83