ios - ARKit 2 中的场景切换

标签 ios swift scenekit arkit

我有一个在检测到图像时显示的场景。理想情况下,我希望在检测到图像时加载两个场景,但一次只显示一个场景,并允许用户通过按钮操作进行切换。我怎样才能实现这个目标?谢谢。

case "qr-code":
                print("trackingWatch")
                activeScene = SCNScene(named: "art.scnassets/Apple_Watch/apple_watch.scn")!
                activeNode = activeScene?.rootNode.childNodes.first!
                activeNode?.position = SCNVector3Zero
                activeNode?.position.z = -0.15 
                planeNode.addChildNode(activeNode!)
                node.addChildNode(planeNode)

案例是加载事件场景的图像。我想要一个更活跃的场景,可以在两者之间旋转。

最佳答案

你只需要一个场景,你可以做的就是将scene2的rootNode附加到第一个场景。我们的想法是将整个场景放入 1 个可以一键隐藏的节点中。

let scene2root = scene2.rootnode
sceneView.scene.rootNode.addChildNode(scene2Root)

然后,当点击按钮时,隐藏 scene2root。您甚至可以运行一个操作来实现平滑过渡。

关于ios - ARKit 2 中的场景切换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51581417/

相关文章:

iphone - TableView didSelectRowAtIndexPath : Activity indicator not showing properly

android - 是否可以将从移动设备拾取的音频实时流式传输到Web服务器?

arrays - 获取数组的总和,保存到核心数据,并在应用程序重新打开后从总和开始?

ios - 为什么我必须在发送对等连接提议之前打开数据通道?

ios - Xcode 7 beta - 构建错误(xcassets)

ios - Xcode Profile和物理设备离线问题

c# - iOS 中的游戏中心 : GKScore vs. GKachievement?

ios - SceneKit 纹理

ios - Swift/IOS : SCNNode appeared to return to its original position after SCNAction is finished, 但它的实际位置被 SCNAction 改变了

ios - 场景套件: Use multiple SCNView instances side by side