[英]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.