title: Convert 3d point on sphere to UV coordinate
body: <p>I have a 3d point on a sphere and want to convert from that, to a UV point on the sphere's texture.</p>
  
  <p>Could someone point in the right direction for the please? I can take a pure math solution.</p>
  
  <p>Edit:</p>
  
  <p>I currently have this, which does not return the correct UV coordinate.
  p is the 3d point on the sphere
  mesh.position is the position of the sphere</p>
  
  <pre><code>var x = (p.x-mesh.position.x)/500;
  var y = (p.y-mesh.position.y)/500;
  var z = (p.z-mesh.position.z)/500;                  
  
  var u = Math.atan2(x, z) / (2 * Math.PI) + 0.5;
  var v = Math.asin(y) / Math.PI + .5;
  </code></pre>