Skip to content

Instantly share code, notes, and snippets.

@wizard1066
Created October 21, 2022 13:15
Show Gist options
  • Save wizard1066/d2a572d32ac7b2198fbe8acc1b66a52c to your computer and use it in GitHub Desktop.
Save wizard1066/d2a572d32ac7b2198fbe8acc1b66a52c to your computer and use it in GitHub Desktop.
func CGPointToSCNVector3(view: SCNView, depth: Float, point: CGPoint) -> SCNVector3 {
let projectedOrigin = view.projectPoint(SCNVector3Make(0, 0, depth))
let locationWithz = SCNVector3Make(Float(point.x), Float(point.y), projectedOrigin.z)
return view.unprojectPoint(locationWithz)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment