I made a simple cube model
with animation in Blender.
Exported it as a .fbx
file with the option bake animation
turned on.
With Reality Converter
I converted the .fbx
file to .usdz
which I imported into my Xcode project. But I am not getting the animation back in my project (see below for the code).
import SwiftUI
import RealityKit
struct ContentView : View {
var body: some View {
ARViewContainer().edgesIgnoringSafeArea(.all)
}
}
struct ARViewContainer: UIViewRepresentable {
let arView = ARView(frame: .zero)
func makeUIView(context: Context) -> ARView {
let anchorEntity = AnchorEntity()
//get local usdz file which is in xcode project
do {
let cubeModel = try ModelEntity.load(named: "cube")
print(cubeModel)
print(cubeModel.availableAnimations) // here i get an empty array
anchorEntity.addChild(cubeModel)
arView.scene.addAnchor(anchorEntity)
}
catch {
print(error)
}
return arView // the cube is visible on my ipad
}
func updateUIView(_ uiView: ARView, context: Context) { }
}
For what i understand is has to be possible to import with animations. Am i missing something ?