如何在Scene Kit中为同一场景使用多个摄像头 [英] How to use multiple cameras for the same scene in Scene Kit
问题描述
我有2个SCNViews彼此相邻,两个都应该显示相同的场景,但通过不同的相机。
在我看来,Scene Kit使用的节点与节点层次结构中最高的相机一样,所以我尝试了类似的东西
I have 2 SCNViews next to each other and both should show the same scene but through different cameras. It seems to me that Scene Kit uses that node with a camera that is highest in the node hierarchy so I tried something like that
leftSceneView.scene?.rootNode.addChildNode(scene.rootNode)
rightSceneView.scene?.rootNode.addChildNode(scene.rootNode)
leftSceneView.scene?.rootNode.addChildNode(cameraNodeLeft)
rightSceneView.scene?.rootNode.addChildNode(cameraNodeRight)
但是我得到了错误消息 [SCNKit ERROR]不允许从场景中删除场景的根节点
,它根本不起作用。
but I got the error message [SCNKit ERROR] removing the root node of a scene from its scene is not allowed
and it did not work at all.
有人建议如何实现这一目标吗?
Has anybody a suggestion how I can achieve that?
Toby
推荐答案
设置视图以使用SCNView的pointOfView属性渲染场景。
Set the point of view to render the scene with the "pointOfView" property of the SCNView.
scnView.pointOfView = cameraNodeLeft;
scnView.pointOfView = cameraNodeLeft;
这篇关于如何在Scene Kit中为同一场景使用多个摄像头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!