1

I'm experiencing a bug where it seems like the target from an AnchorEntity is never found.

For example: I set horizonal plane as the trigger in Reality Composer. Once I run the project, sometimes (not always) it will never detect a plane. It's like plane detection is not running.

My solution was to run the session with configurations based on the target in the AnchorEntity. The problem is that I'm not able to run a session with detection images because all I receive from the targets .image case is a name and a group. I'm not able to initilize ARReferenceImages with that data.

let loadRequest = Entity.loadAnchorAsync(contentsOf: url)
loadRequest.sink(receiveCompletion: { result in
    print("handle completion and error") }, 
    receiveValue: { anchorEntity in
        switch anchorEntity.anchoring.target {
        case .plane(let alignment, classification: let classification, minimumBounds: let bounds):
            let config = ARWorldTrackingConfiguration()
            config.planeDetection = alignment == .horizontal ? .horizontal : .vertical
            self.arView.session.run(config, options: .resetTracking)
        case .image(group: let group, name: let name): break
            // ISSUE: run session with detected images from anchorEntity
        default: break
        }
        self.arView.scene.addAnchor(anchorEntity)
    }).store(in: &self.subscribers)
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
Magnus T
  • 220
  • 1
  • 9
  • Does `f.eks` mean `for eksempel` in Danish or in Norwegian ? )) – Andy Jazz Jul 28 '20 at 04:44
  • 1
    yeah haha! my bad @AndyFedoroff – Magnus T Jul 28 '20 at 10:05
  • If instead `break` you'll write `let config = ARImageTrackingConfiguration()` in `case .image(...)`, does it help? And Set must be in Xcode's asset catalog. – Andy Jazz Jul 28 '20 at 10:19
  • Thats what i want to do yes. But im not going to use the asset catalog Basically my project should only contain a reality composer project file. Is it possible to use the trigger image that was uploaded in reality composer? @AndyFedoroff – Magnus T Jul 28 '20 at 15:27

0 Answers0