Animate MDLObject and export to collada .dae

Hey everyone, I want to animate an MDLObject and then export it to a .dae file. Currently, only the objects mesh is exported, but without animation. I could not find any articles online how to animate objects correctly, so I came here to ask for help.

Here is the code I have:

First, I set up a camera transform:

var cameraTransform = MDLTransform()

Then I write to the transform:

let transform = frame.camera.transform
let rotation = frame.camera.eulerAngles
let position = transform.columns.3
let elapsedTime = frame.timestamp - firstUpdateTime!

cameraTransform.setTranslation(position[SIMD3(0,1,2)], forTime: elapsedTime)
cameraTransform.setRotation(rotation, forTime: elapsedTime)

And assign the transform to a mesh and a scene:

let object = MDLMesh(boxWithExtent: .init(0.1, 0.1, 0.1), segments: .init(10, 10, 10), inwardNormals: false, geometryType: .triangles, allocator: nil)
object.name = "Camera Transform"
object.transform = ARSessionManager().cameraTransform
let asset = MDLAsset()
asset.add(object)

And lastly, I export the file:

try! asset.export(to: colladaFileURL)

This spits out a file that contains a cube, but no animation. The cameraTransform is in the frame update function of my ARSessionDelegate and when I add a print in there I also see values being spit out. (e.g. SIMD3<Float>(-0.522029, -0.40510324, -1.5561341)).

Any help would be greatly appreciated!

Animate MDLObject and export to collada .dae
 
 
Q