SceneKit:具有多个摄像头的sceneView projectPoint

时间:2019-04-23 14:53:54

标签: scenekit

如果一个场景包含多个摄像机,projectPoint方法使用哪个摄像机将点从3D投影到屏幕空间?如果这是由pointOfView属性定义的,那么当我更新pointOfView的位置时,给定的3D点仍被投影到相同的2D点怎么办?

1 个答案:

答案 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