I used automaticImageScaleEstimationEnabled, but ModelEntity is not displayed correctly.
The tested device is iPhone7 plus.
The tested device is iPhone7 plus.
Code Block class ViewController: UIViewController { @IBOutlet var arView: ARView! fileprivate var configuration: ARWorldTrackingConfiguration! fileprivate var rootAnchor: AnchorEntity! // MARK: === viewWillAppear override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) configuration = ARWorldTrackingConfiguration() configuration.automaticImageScaleEstimationEnabled = true configuration.detectionImages = ARReferenceImage.referenceImages(inGroupNamed: "AR Resources", bundle: nil) arView.session.run(configuration) } // MARK: === viewDidLoad override func viewDidLoad() { super.viewDidLoad() arView.session.delegate = self } } // MARK: === ARSessionDelegate extension ViewController: ARSessionDelegate { func session(_ session: ARSession, didAdd anchors: [ARAnchor]) { anchors.compactMap { $0 as? ARImageAnchor }.forEach { rootAnchor = AnchorEntity() rootAnchor.transform.matrix = $0.transform arView.scene.addAnchor(rootAnchor) add() } } func session(_ session: ARSession, didUpdate anchors: [ARAnchor]) { anchors.compactMap { $0 as? ARImageAnchor }.forEach { rootAnchor.transform.matrix = $0.transform } } // MARK: === add fileprivate func add() { let audioPlane = MeshResource.generatePlane(width: 0.2, height: 0.2, cornerRadius: 0) var audioMtl = SimpleMaterial() do { audioMtl.baseColor = try MaterialColorParameter.texture(TextureResource.load(named: "audio_play.png")) } catch { } let audioEy = ModelEntity(mesh: audioPlane, materials: [audioMtl]) audioEy.position = [0, 0.1, 0] rootAnchor.addChild(audioEy) } }
As a general remark, to track an image, make sure that maximumNumberOfTrackedImages is set to a value greater than 0 in your configuration. Otherwise the image will just be detected but its transform won't be updated.
Is that the issue you are referring to or how exactly is your model not displaying correctly?
Is that the issue you are referring to or how exactly is your model not displaying correctly?