I have a problem, I want to load a usdz file, place it and animate it in RealityKit. It should also be possible to apply standard gestures as done in
arView.installGestures(for: entity)
From what I know I have two choices to load an Entity, for example Apples "toy_biplane.usdz" (It also contains an skeletal animation).
I have
let entity = try! Entity.load(named: "toy_biplane")
or
let entity = try! Entity.loadModel(named: "toy_biplane")
when I use the first one, the usdz is loaded as an Entity, not ModelEntity. I can execute
entity.playAnimation(entity.repeat())
But I can't use
arView.installGestures(for: entity)
because it does not conform to HasCollision. I tried subclassing Entity and conforming to HasCollision and HasModel. It compiles but even if I call the generateCollisionShape(recursive: true) the gestures are not working.
So I tried the loadModel approach which returns an ModelEntity. There the arView.installGestures are working fine exactly as tried out. But when I want to play the animation, the airplane just rotates around my camer very weird.
I also tried loading them asynchronously, no success.
After many time of debugging I found out, that the Entity from the first approach contained many children from the usdz. Each of them is a part of the skeleton and has its own animation. Not so in the ModelEntity. The children property is an empty set and therefore the animation (e.g rotation of the propeller) is not applied to the skeletal element it belongs to but rather to the combined overall skeleton. Causing a rotation of the whole plane which is not what I want.
What am I doing wrong or is something of this unintended behaviour from RealityKit?
Thanks.