Have a usdz file with the typical one character and one animation.
let p = Bundle.main.url(forResource: "Sitting Laughing", withExtension: "usdz")!
let amyAsset = MDLAsset(url: p)
amyAsset.loadTextures()
let amy = SCNNode(mdlObject: amyAsset.object(at: 0))
.. your node .. .addChildNode(amy)
You can now see "amy" perfectly in your scene.
If you try this, notice there are NO keys:
for k in amy.animationKeys { print("keys? \(k)") }
however try this with the asset,
for ob in amyAsset.animations.objects { print("ob \(ob)") }
And you'll see the MDLPackedJointAnimation
for example
<<MDLPackedJointAnimation: 0x7ff7b0e18830>, Name: /High_Jump/mixamorig_Hips/Skeleton/Animation, Children: 0>
Alternately, say,
let pjs = amyAsset.animations.objects.compactMap { $0 as? MDLPackedJointAnimation }
for pj in pjs {
print("... \(pj.name)")
}
for the same info.
The "name" will look like /High_Jump/mixamorig_Hips/Skeleton/Animation
From there how the heck do you play that MDLPackedJointAnimation
???
I've tried everything and cannot :/
It seems to be the case that the MDLPackedJointAnimation
is a low-level representation of the animation(s) of the joints.
It's only possible to "play" a packed joint animation in the sense of completely manually animating it yourself using a display link and so on.
Article which touches on that:
https://medium.com/@warrenm/thirty-days-of-metal-day-28-skinning-690fe46785c9
It seems that MDLPackedJointAnimation
is completely unrelated to the CAAnimation
concepts in iOS, that is to say, there is no "command" or way whatsoever to "just play" a MDLPackedJointAnimation
set of information.