ARKit会话已暂停且未恢复

ARKit会话已暂停且未恢复

本文介绍了ARKit会话已暂停且未恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的ARKit应用程序中,我提出了一个模态窗口。当我关闭模态并返回到ARSCNView时,我发现由于此代码会话暂停:

In my ARKit app I am presenting a modal window. When I close the modal and go back to the ARSCNView then I find out that the session is paused due to this code:

 override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)

        // Pause the view's session
        sceneView.session.pause()
    }

当我关闭模态并返回到ARKit相机视图屏幕时,此代码被触发:

When I close the modal and go back to the ARKit camera view screen this code gets fired:

override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

        // Create a session configuration
        let configuration = ARWorldTrackingSessionConfiguration()

        // Run the view's session
        sceneView.session.run(configuration)
    }

但此代码永远不会恢复会话。屏幕在其读取的最后一张图像上完全冻结。有什么想法吗?

But this code never resumes the session. The screen is completely frozen on the last image it read. Any ideas?

我将viewDidAppear代码更新为以下代码。它仍然卡在相机屏幕上,图像被冻结。

I update the viewDidAppear code to be the following. It is still stuck on the camera screen with image frozen.

  override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

        // Create a session configuration
        let configuration = ARWorldTrackingSessionConfiguration()

        sceneView.session.delegate = self

        if self.isPaused {
            sceneView.session.run(sceneView.session.configuration!)
        } else {
            // Run the view's session
            sceneView.session.run(configuration)
        }


    }


推荐答案

不确定为什么你的会话没有恢复,但是...这通常不是你想要的情况。

Not sure why your session isn't resuming, but... this generally isn't a situation you want to be in anyway.

请注意Apple的附带自述文件ARKit示例代码(附于):

Notice in the readme that ships with Apple's ARKit sample code (attached to the WWDC17 session on ARKit):

使用弹出式演示文稿(甚至在iPhone上)用于辅助视图控制器,以在调整设置或进行模态选择时使用户保持AR体验。在此示例中, SettingsViewController VirtualObjectSelectionViewController 类使用popover演示文稿。

Use the popover presentation (even on iPhone) for auxiliary view controllers to keep the user in the AR experience while adjusting settings or making a modal selection. In this example, the SettingsViewController and VirtualObjectSelectionViewController classes use popover presentation.

进一步详细说明:如果您暂停会话,当您的用户离开不同的全屏视图控制器时,它将无法跟踪世界。这意味着当您恢复时,场景中放置的任何虚拟内容都不会位于您离开的位置(相对于相机)。

To go into a bit more detail: if you pause the session, it won't be tracking the world while your user is away in a different fullscreen view controller. That means that when you resume, any virtual content placed in the scene won't be in the positions (relative to the camera) where you left it.

这篇关于ARKit会话已暂停且未恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 13:03