如果一个场景包含多个摄像机,projectPoint
方法使用哪个摄像机将点从3D投影到屏幕空间?如果这是由pointOfView
属性定义的,那么当我更新pointOfView
的位置时,给定的3D点仍被投影到相同的2D点怎么办?
答案 0 :(得分:1)
由于SCNCamera属于SCNView,因此只需通过视图的“ pointOfView”实例属性将PoV
设置为所需的摄像机节点即可。
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
然后您可以更改PoV:
sceneView.pointOfView = cameraNode002