How can I make an image anchor only place an object?

Context, I want to make a very basic ar app using an image anchor, I have achieved this using Reality Composer and it works great.


The issue is if I tried to zoom into an object in a way where the image anchor isn't clearly visible it disappears, which I understand is expected.

My question is is there a way to have my objects stay in place so I can walk around and zoom in and out.


So the ar object will appear when the image anchor is placed and if the image anchor is visible stay on it (allowing me to move and rotate the image anchor) but if not visible stay in the place it was last in.


I don't know how to program but I'm learning as I follow tutorials and bits and pieces. I have linked the code that I have slightly modified in the view controller

import UIKit 
import RealityKit

class ViewController: UIViewController {

@IBOutlet var arView: ARView!
var mapAnchor: Experience.Map! 

override funcviewDidLoad() { 
     super.viewDidLoad()

     mapAnchor = try! Experience.loadMap()
     arView.scene.anchors.append(mapAnchor)
     }
}

I'm also looking for an answer to this, the default behaviour of the ar quick view does exactly what I need. I'm just needing to know how to do that in xcode.


As said above, when the image is no longer visible it should keep the last known location in the scene and remain visible.\

Thanks

I have exactly the same problem.

Same issue but for AR Quick Look. Reality Composer plays scene correctly but usdz / . Reality files show this behavior

+1 how to retain it after losing it.. :- )

You can achieve this using ARKit API in two ways:

  1. In your ARWorldTrackingConfiguration, set maximumNumberOfTrackedImages to 0. This will disable image tracking, i.e., your ARImageAnchors won't receive any updates once they have been added to the session. Hence, your model won't be removed even if you lose sight of the anchor.

  2. Alternatively, you can monitor the session:didUpdateAnchors: callback and decide on your own how to react when the image anchor is updated. For example, you could only update your content based on the anchor's position component and keep the rotation constant, or apply any other custom logic how to use the anchor's transform.

How can I make an image anchor only place an object?
 
 
Q