Reputation: 3578
If a scene contains multiple cameras, which camera does the projectPoint
method use to project points from 3D to screen-space? If this is defined by the pointOfView
property, then how come when I update the position of the pointOfView
a given 3D point is still projected to the same 2D point?
Upvotes: 1
Views: 621
Reputation: 58553
Since SCNCamera belongs to SCNView, just set the PoV
via the "pointOfView" instance property of a View to a required camera node.
let cameraNode001 = SCNNode()
cameraNode001.camera = SCNCamera()
scene.rootNode.addChildNode(cameraNode001)
cameraNode001.position = SCNVector3(x: 0, y: 0, z: 15)
let cameraNode002 = SCNNode()
cameraNode002.camera = SCNCamera()
scene.rootNode.addChildNode(cameraNode002)
cameraNode002.position = SCNVector3(x: 10, y: 10, z: 30)
let sceneView = self.view as! SCNView
sceneView.scene = scene
sceneView.pointOfView = cameraNode001
then you can change PoV:
sceneView.pointOfView = cameraNode002
Upvotes: 1