简体   繁体   中英

Glitch in ARView

I have an iOS application in which you can open an AR view by tapping on a button. However, after popping the view from my navigation controller and tapping on the AR button again something unusual happens in the camera feed. I see a sudden appearance of the last frame of my previous ar session that comes and goes during the whole session. I'm using RealityKit. Any ideas?

  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)
  }

So it seems that there was a problem with the FocusSquare. It is fixed now that I have removed it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM