Recently, I studied about ARWorldTrackingConfiguration. But it is very difficult. First I want to use this function:
func session(_ session: ARSession, didRemove anchors: [ARAnchor]) { }
I already tried these one but it's not working:
arView.session.remove(anchor: frame.anchors[0])
arView.session.currentFrame?.anchors.removeAll() // 'anchors' is a get-only property
Anyone know about 'didRemove' of session function by using something?
Plz help me master of ARkit.
To remove ARAnchor from ARSession you need to use remove(anchor:) instance method:
let specialAnchor = ARAnchor(name: "special", transform: simd_float4x4())
arView.session.remove(anchor: specialAnchor)
The method you've mentioned is called when anchors are removed from the session:
func session(_ session: ARSession, didRemove anchors: [ARAnchor]) {
self.anchorsData(anchors: anchors)
}
func anchorsData(anchors: [ARAnchor]) -> [Any] {
var data = [Any]()
// some code...
return data
}