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)