2017-06-03 27 views
0

我已經使用以下來計算導入模型的質心;Three.js - box的質心幫助

geometry.computeBoundingBox(); 
var centroid = new THREE.Vector3(); 
centroid.addVectors(geometry.boundingBox.min, geometry.boundingBox.max); 
centroid.multiplyScalar(- 0.5); 
centroid.applyMatrix4(mesh.matrixWorld); 

https://stackoverflow.com/a/25269787

它運作良好,但我認爲的BoundingBox已被棄用。 我應該使用boxHelper嗎?我如何找到boxHelper的質心?

回答

1

1)BoundingBoxHelper was deprecated,而不是boundingBox財產。

2)不要用BoxHelper找到質心。只需使用boundingBox屬性。

2.5)的boundingBox屬性是Box3對象,其中有一個getCenter方法,它給你,你有什麼計算。

geometry.computeBoundingBox(); 
var centroid = geometry.boundingBox.getCenter(); 
centroid.applyMatrix4(mesh.matrixWorld); 
+0

感謝您的解釋,它完美的作品。 – ShaunaL