[英]How to get the global/world position of a child object?
如何在另一個 Object3D 中獲取 Object3D 的全局位置?
設置:
var parent = new THREE.Object3D();
parent.position.set(100, 100, 100);
var child = new THREE.Object3D();
child.position.set(100, 100, 100);
parent.add(child);
scene.add(parent);
筆記:
我認為這將是這樣做的方式:
console.log(child.localToWorld(parent.position));
...但它給了我(100, 100, 100) ,而不是(200, 200, 200) 。
您可以像這樣提取世界位置:
var target = new THREE.Vector3(); // create once an reuse it
child.getWorldPosition( target );
target
將包含結果。
編輯:更新為three.js r.120
在 Threejs r89 中,您可以通過Object3D.getWorldPosition
獲取世界位置。 不知道什么時候加的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.