threejs Box3().getSize() 方法的正确用法是什么?

What is the proper use of threejs Box3().getSize() method?

Whosebug 等人的处处似乎都同意 Box3() getSize() 方法的正确使用如下:

const geometry = new THREE.BoxGeometry( 10, 10, 10 );
const material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
const cube = new THREE.Mesh( geometry, material );
scene.add( cube );

let cubeBoundingBox = new THREE.Box3().setFromObject( cube );
let boxSize = cubeBoundingBox.getSize();
console.log("BoxSize: " + boxSize);

然而,情况似乎并非如此。请参阅此示例中的错误:https://jsfiddle.net/8L5dczmf/3/

我可以在 three.js documentation 中看到 getSize() 实际上应该这样使用...除非我正在阅读 .getSize ( target : Vector3 ) : Vector3 错误。那么上面fiddle中的代码有什么问题呢?

您需要传入一个向量,结果将写入该向量:

// ...

let boxSize = new THREE.Vector3();
cubeBoundingBox.getSize(boxSize);

console.log("BoxSize: " + boxSize);