【发布时间】:2021-05-06 04:01:37
【问题描述】:
我有一个 iOS 应用程序,您可以在其中通过点击按钮打开 AR 视图。然而,在从我的导航控制器弹出视图并再次点击 AR 按钮后,摄像头馈送中发生了一些不寻常的事情。我看到我之前的 ar 会话的最后一帧突然出现,在整个会话期间来来去去。我正在使用 RealityKit。有什么想法吗?
override func viewDidLoad() {
super.viewDidLoad()
focusSquare = FocusEntity(on: arview, style: .classic(color: .yellow))
setupCoachingOverlay()
}
override func viewWillAppear(_ animated: Bool) {
self.navigationController?.isNavigationBarHidden = true
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
UIApplication.shared.isIdleTimerDisabled = true
resetTracking()
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
arview.session.pause()
}
deinit{
arview.session.delegate = nil
arview.scene.anchors.removeAll()
arview.removeFromSuperview()
arview = nil
}
func resetTracking() {
arview.automaticallyConfigureSession = false
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = [.horizontal, .vertical]
arview.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])
arview.scene.addAnchor(anchor)
}
【问题讨论】:
标签: ios swift realitykit