title: Three.js - How to get camera position with respect to origin
body: <p>The title of this question might a bit ambiguous, but I don't know how to phrase it in a line.</p>
  
  <p>Basically I've got this situation: there is a perspective camera in the scene and a mesh. The mesh is NOT centered at the origin of the axis.</p>
  
  <p>The camera points directly to the center of this object, and it's position (I mean literally the "position" property of the Three.js camera object) is the position with respect to the center of the object, not the origin; so it works in another coordinate system.</p>
  
  <p>My question is: how can I get the position of the camera not with respect of the object center but with respect of the origin of the "global" coordinate system?</p>
  
  <p>To clarify, the situation is <a href="http://it.tinypic.com/r/rvvndu/9" rel="noreferrer">this</a>. In this image you can see a hand mesh that has a position far away from the origin of the coordinate system. The camera points directly to the center of the hand (so the origin from the point of view of the camera is the center of the hand), and if I print it's position it gives me these values:
  x: -53.46980763626004; y: -2.7201492246619283; z: -9.814480359970839
  while actually I want the position with respect to the origin of the coordinate stystem (so in this case the values would be different; for example, the y value would be positive).</p>
  
  <p><strong>UPDATE:</strong>
  I tried @leota's suggestion, so I used the localToWorld method in this way:</p>
  
  <pre><code>var camera = scene.getCamera();
  var viewPos = camera.position;
  var newView = new THREE.Vector3();
  newView.copy(viewPos);
  camera.localToWorld(newView);
  </code></pre>
  
  <p>I did an experiment with <a href="http://it.tinypic.com/r/2s0crxg/9" rel="noreferrer">this</a> mesh. As you can see this mesh is also not centered on the origin (you can see the axes on the bottom-left corner).
  If I print the normal value of the camera's position (so, with respect to the center of the mesh) it gives me these results:
  x: 0; y: 0; z: 15</p>
  
  <p>If now I print the resulting values after the code above, the result is:
  x: 0; y: 0; z: 30</p>
  
  <p>which is wrong, because as you can see the camera position in the image has x and y values clearly different than 0 (while z = 30 could be true, as far as I can see).</p>
  
  <p>If for example I rotate the camera so that it's very close to the origin, like <a href="http://it.tinypic.com/r/16ll7qr/9" rel="noreferrer">this</a> (in the image the camera is just behind the origin, so its position in world coordinates should have negative values for x, y, z), the coordinates with respect of the center of the object are:</p>
  
  <p>x: -4.674180744175711; y: -4.8370441591630255; z: -4.877951155147168</p>
  
  <p>while after the code above they become:</p>
  
  <p>x: 3.6176076166961373; y: -4.98753160894295; z: -4.365141278155379</p>
  
  <p>The y and z values might even be accurate at a glance, but the positive value of x tells me that it's totally wrong, and I don't know why.</p>
  
  <p>I'm going to continue looking for a solution, but this might be a step in the right direction. Still, any more suggestions are appreciated!</p>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>Found the solution. What @leota said is correct, that is indeed how you would get absolute coordinates for the camera. In my case though, I finally found a single line of code hidden in the project's code that was scaling everything according to some rule (project related). So the solution for me was to take the camera position as it is and then scale it back according to that rule.</p>
  
  <p>Since @leota's answer was indeed the solution to the original question, I'm accepting it as the correct anwser</p>