2014-09-24 63 views
0

我有這種網格(每個是上面的孩子)獲取父位置網

Scene 
    -scene.add(SpaceMesh) 
      -SpaceMesh.add(ShipMesh) 

SpaceMesh在屏幕上移動。 ShipMesh不動。

,如果我要求ShipMesh.position.x返回0(邏輯)

我怎樣才能在SpaceMeshShipMesh座標?

-

實施例:

SpaceMesh.position.x = 100

ShipMesh.position.x = 0

邏輯結果將必須是ShipMesh。 PositionInSpaceMesh .X = -100

+1

我認爲這是你問 http://stackoverflow.com/questions/15098479/how-to-get-the-global-world-position-of-a-child-object – user54580 2014-09-24 09:19:06

回答

0

我不知道,如果是最好的方式,但是從: how to: get the global/world position of a child object

spaceMesh.updateMatrixWorld(); 
var vector = new THREE.Vector3(); 
vector.setFromMatrixPosition(spaceMesh.matrixWorld); 
vector.multiplyScalar(-1); 
console.log(vector); // my coords in SpaceMesh 

如果有更好的解決方案,或者一些 「最佳實踐」,請糾正我,謝謝。