Skip to content

Instantly share code, notes, and snippets.

@fisherds
Last active May 7, 2018 02:18
Show Gist options
  • Save fisherds/a2a75c914c293213f594daf5fd940d3d to your computer and use it in GitHub Desktop.
Save fisherds/a2a75c914c293213f594daf5fd940d3d to your computer and use it in GitHub Desktop.
snippet of code for getting the position of the camera that I don't want you to bother type
@IBAction func pressedAddEarth(_ sender: Any) {
guard let pointOfView = sceneView.pointOfView else {return}
let transform = pointOfView.transform
let orientation = SCNVector3(-transform.m31, -transform.m32, -transform.m33)
let location = SCNVector3(transform.m41, transform.m42, transform.m43)
let currentPositionOfCamera = orientation + location
// other stuff
}
func +(left: SCNVector3, right: SCNVector3) -> SCNVector3 {
return SCNVector3Make(left.x + right.x, left.y + right.y, left.z + right.z)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment