I use Entity.loadAsync to load the USDZ. The camera is stuck for a moment when loading the model.
var cancellable: AnyCancellable? = nil
cancellable = Entity.loadAsync(contentsOf: Bundle.main.url(forResource: "vyygabbj_afr", withExtension: "usdz")!)
.sink(receiveCompletion: { error in
DispatchQueue.main.async {
cancellable?.cancel()
cancellable = nil
}
}, receiveValue: { [weak self] ey in
guard let self = self else { return }
self.modelEy = ModelEntity()
self.modelEy.addChild(ey)
self.rootAnchor.addChild(self.modelEy)
ey.availableAnimations.forEach {
ey.playAnimation($0.repeat())
}
DispatchQueue.main.async {
cancellable?.cancel()
cancellable = nil
}
})