title: How to accurately get 3D point from 2D point in scenekit?
body: <p>I need to be able to tap on the view, get the X, Y tap position, and then for a scenekit node to appear in that position, including depth. So if I tap at top of screen, it appears far away, and if lower, then closer. It needs to take into account camera view rotation, lateral position, and should appear exactly where touched on screen. Snapchat do this very well with their newest augmented reality objects, as seen here. </p>
  
  <p><a href="https://cnet3.cbsistatic.com/img/zjwcEw0O0BQ7smi3X1KrksTliu4=/fit-in/270x0/2017/04/17/0fae55ef-4d61-4b0f-80ec-de943ae1dc7b/snapchat-world-lenses.gif" rel="nofollow noreferrer">https://cnet3.cbsistatic.com/img/zjwcEw0O0BQ7smi3X1KrksTliu4=/fit-in/270x0/2017/04/17/0fae55ef-4d61-4b0f-80ec-de943ae1dc7b/snapchat-world-lenses.gif</a></p>
  
  <p>I have heard about scenekits projected/unprojected points, and tried the answer to this
  <a href="https://stackoverflow.com/questions/25150737/how-to-use-ios-swift-scenekit-scnscenerenderer-unprojectpoint-properly">How to use iOS (Swift) SceneKit SCNSceneRenderer unprojectPoint properly</a></p>
  
  <pre><code>let projectedOrigin = scnView.projectPoint(SCNVector3Zero)  
  
  let vpWithZ = SCNVector3(x: tapX, y: tapY, z: projectedOrigin.z)
  let worldPoint = scnView.unprojectPoint(vpWithZ)
  </code></pre>
  
  <p>However the node that moves to worldPoint shows appears much to close anywhere I tap (how do I scale it?), and even though it shows signs of working laterally,  it is very inaccurate. I want it to just move along the xz plane like in snapchat. How exactly does the projection system work to implement it (it is not well explained elsewhere), and is there a better alternative?</p>
  
  <p>Thank you.</p>