Post

Replies

Boosts

Views

Activity

Model won't appear at location with ARGeoAnchor
Hi all, I'm trying to display a 3d model from a usdz file at a particular location. Here's the code I came up with: class ViewController: UIViewController, ARSessionDelegate { @IBOutlet var arView: ARView! var geoAnchor: ARGeoAnchor? = nil override func viewDidLoad() { super.viewDidLoad() arView.session.delegate = self let config = ARGeoTrackingConfiguration() arView.session.run(config) let coordinate = CLLocationCoordinate2DMake(0.0, -100.0) // coordinates omitted let geoAnchor = ARGeoAnchor(coordinate: coordinate) self.geoAnchor = geoAnchor arView.session.add(anchor: geoAnchor) } func session(_ session: ARSession, didAdd anchors: [ARAnchor]) { guard let geoAnchor = geoAnchor else { return } guard let usdzPath = Bundle.main.url(forResource: "myModelFile", withExtension: "usdz") else { return } let modelEntity = try! Entity.loadModel(contentsOf: usdzPath) let anchorEntity = AnchorEntity(anchor: geoAnchor) anchorEntity.addChild(modelEntity) arView.scene.addAnchor(anchorEntity) } } When I go out on the street, I'm asked for location/camera permissions and approve. After that, I get nothing as I face my camera towards the location. Note: I'm in one of the supported cities for ARGeoTrackingConfiguration to work—I've also logged statements confirming its availability both on my device and in my city. Does anyone have any idea what might be the issue?
4
0
592
Sep ’21