How to get the global/world position of a child object?

后端 未结 2 1998
误落风尘
误落风尘 2020-11-29 23:10

How do I get the global position of an Object3D inside another Object3D?

setup:

var parent = new THREE.Object3D();
parent.position.s         


        
相关标签:
2条回答
  • 2020-11-29 23:25

    In threejs r89 you can just get the world position by Object3D.getWorldPosition. I don't know when it was added.

    0 讨论(0)
  • 2020-11-29 23:40

    You can extract the world position like so:

    var target = new THREE.Vector3(); // create once an reuse it
    
    child.getWorldPosition( target );
    

    target will contain the result.

    EDIT: updated to three.js r.120

    0 讨论(0)
提交回复
热议问题