0
votes

I'm developing ARKit 2.0 app currently which the user need to find the virtual objects around the mapped space, I had making use the AR Persistence and i realise after the relocalization of initial ARWorldMap, all object appears instantly even the object which far away from me and had walls between me and the virtual object. Is it possible to only add in the anchor when the current camera detected a plane which is similar to initial World Map session's plane instead of once mapped with initial world map, all anchor has been mapped ?

1

1 Answers

4
votes

When you successfully localize to an ARWorldMap, your ARSession immediately contains all the anchors that were saved in that world map. But that doesn't mean your app has to immediately show whatever virtual content you associate with those anchors.

If you're using ARSCNView, your renderer(_:didAdd:for:) callback fires for each of the anchors being restored from the world map, just like it does for anchors you add to the session yourself and for anchors that ARKit adds automatically (plane detection, image detection, etc). And of course, if you're not using ARSCNView, there are similar callbacks for other renderers (and in ARSessionDelegate if you build your own renderer.)

Your logic in that callback method determines what virtual content gets shown. If you don't want content associated with an anchor to appear, don't add it to the scene in that method. Or add it to the scene but set isHidden on it, and use some other logic to un-hide it later.