Post

Replies

Boosts

Views

Activity

Reply to GeoAnchor saving multiple anchors after removeall anchors method
The example code from Apple uses a computed var to store the array of placed Geoanchors in the scene but since the computed variable is read-only, the values in the array cannot be removed when the scene is reset so it was keeping a long list every time a model was added to the scene with no way to delete them (that I know of.) Fixed the issue by not using a computed variable and modifying the code accordingly: var currentAnchors: [ARAnchor] = [] // from var currentAnchors: [ARAnchor] { return arView.session.currentFrame?.anchors ?? []} append the geo anchor to the array when the anchor is placed in the scene add currentAnchors.removeAll() in the reset AR session function Not sure if this is helpful at all to anyone out there but I'm glad I figured it out! ** Anyone know why they used computed variable for storing AR Anchors?
Jul ’21
Reply to GeoAnchor saving multiple anchors after removeall anchors method
I found the logic problem, when a session is reset, arView.scene.anchors.removeAll() statement is executed but does not clear a global variable : var currentAnchors: [ARAnchor] { return arView.session.currentFrame?.anchors ?? [] }. I'm not 100% positive but it looks like this statement adds an element in the array every time an anchor is added to a scene but does not get cleared when the anchors in the scene are removed. Anyone recommend the best way to clear the array when its a computed variable? It wont allow me to use removeall()
Jul ’21