I use ARImageTrackingConfiguration to load the entity. In the scene the entity keeps shaking. Tracking images have been correcting the rootAnchor transform,which should be the cause of this problem. Is there any optimization plan?
override func viewDidLoad() {
super.viewDidLoad()
arView.session.delegate = self
guard let anchorCGImage = UIImage(named: "anchor.png")?.cgImage else { return }
let arReferenceImage = ARReferenceImage(anchorCGImage, orientation: .up, physicalWidth: CGFloat(0.1))
let arImages: Set<ARReferenceImage> = [arReferenceImage]
imageConfiguration.trackingImages = arImages
imageConfiguration.maximumNumberOfTrackedImages = 1
arView.session.run(imageConfiguration)
}
func session(_ session: ARSession, didAdd anchors: [ARAnchor])
{
anchors.compactMap { $0 as? ARImageAnchor }.forEach {
do {
let ey = try Entity.load(named: "c5nj3ibu_l1a", in: .main)
ey.scale = [0.4, 0.4, 0.4]
rootAnchor = AnchorEntity(anchor: $0)
rootAnchor.addChild(ey)
arView.scene.addAnchor(rootAnchor)
} catch {
}
}
}