我遇到了一個問題,它試圖在加載OBJLoader之後獲取模型幾何體的邊界框。到目前爲止,我有:如何在使用ObjLoader之後計算邊界框three.js
var loader = new THREE.OBJLoader();
loader.load(mURL, function (object) {
for (var i = 0, l = object.children.length; i < l; i ++) {
geometry = object.children[0].geometry;
bBox = geometry.computeBoundingBox();
console.log("have a box of "+bBox);
}
//...rest of function
但是,當我寫入控制檯時,bBox是未定義的。在這種情況下幾何不是正確的屬性?
謝謝mrdoob。這讓我朝着正確的方向前進。我不得不在obj中進行更多的挖掘以達到幾何。看看我的答案新的答案。 – shadyhill 2012-08-03 03:48:37
哎呀!更新了答案。 – mrdoob 2012-08-03 08:55:55
是的,這比我的循環更有效率。再次感謝! – shadyhill 2012-08-03 19:07:53