ARKit 会话已暂停且未恢复 [英] ARKit Session Paused and Not Resuming

查看:21
本文介绍了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 示例代码随附的自述文件中的通知(附在 WWDC17 session在 ARKit 上):

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

避免中断 AR 体验.如果用户转换到您应用中的另一个全屏 UI,则 AR 视图在返回时可能不是预期的状态.

Avoid interrupting the AR experience. If the user transitions to another fullscreen UI in your app, the AR view might not be an expected state when coming back.

为辅助视图控制器使用 popover 演示(甚至在 iPhone 上),让用户在调整设置或进行模式选择时保持 AR 体验.在此示例中,SettingsViewControllerVirtualObjectSelectionViewController 类使用弹出式显示.

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 会话已暂停且未恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆