'Available animations collection is empty, while using .loadModelAsync()

I am successfully loading USDZ file in my RealityKit scene asynchronously by using LoadModelAsync. I am using toy_biplane USDZ file provided by apple which has default animations. If I load model asynchronousely availableAnimations array is always empty!

My codes:

func loadASingleModel(name: String, 
                completion: @escaping (_ model: ModelEntity?) -> Void) {
        
    var cancellable: AnyCancellable?
    cancellable = Entity.loadModelAsync(named: name)
        .sink(receiveCompletion: { handler in
            if case let .failure(error) = handler {
                print("Unable to load a model due to error \(error)")
            }
            cancellable?.cancel()
            completion(nil)

        }, receiveValue: { [self] (model: ModelEntity?) in
            if let model = model  {
                cancellable?.cancel()
                print("Congrats! Model is successfully loaded!")
                print(model.availableAnimations, 
                      //Here availableAnimations is empty
                      "Debug: Any Animation?")
                            completion(model)
            }
        })
    }
}

How to load USDZ file asynchronously with animations?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source