Serialization of Animation doesn't seem to work?

Hello everyone,

I am currently working on a WebXR project in which I am dynamically creating animations at runtime. Short summary, I do this by creating BABYLON.Animation instances, creating a number of keyframes which I then set as the keys, then I push the animations onto the meshes I want to animate.
This works, but I also want to persist these animations beyond the current session so I can reuse them in later sessions. I tried serializing the animations and saving them as json strings in the “localStorage” of the browser, but when I parse them back, it throws a type error I don’t really understand. I created a Playground to summarize what I am trying to do.

Parsing the JSON will not be enough. You need to use the Parse method of animation and push an instance of the animation class. If you do that, it works as expected:

Babylon.js Playground (


That did the trick, thanks!