48

別の 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));

...しかし、 (200, 200, 200)ではなく( 100, 100, 100)が得られます。

4

2 に答える 2

65

次のようにワールド位置を抽出できます。

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

child.getWorldPosition( target );

target結果が含まれます。

編集: three.js r.120 に更新

于 2013-02-26T20:43:01.137 に答える