0

I have this sort of meshes (each is the child of above)

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

SpaceMesh is moving in scene. ShipMesh is not moving.

if i request ShipMesh.position.x it returns 0 (logically)

How can i get coordinates of my ShipMesh in SpaceMesh?

--

Example:

SpaceMesh.position.x = 100

ShipMesh.position.x = 0

Logical result will have to be ShipMesh.PositionInSpaceMesh.x = -100

Martin112345
  • 47
  • 1
  • 5
  • 1
    I think this is what you're asking http://stackoverflow.com/questions/15098479/how-to-get-the-global-world-position-of-a-child-object – user54580 Sep 24 '14 at 09:19

1 Answers1

0

I don't know if is the best way, but from: 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

If is there better solution, or some "best practices", please correct me, thank you.

Community
  • 1
  • 1
Martin112345
  • 47
  • 1
  • 5