Parsing Animation

We don’t currently let you upload json formats for models and animation (because we’d be required to validate the formats to ensure bad uploads didn’t break anything).

You should be able to manually load the data as a json asset and then run it through the engine to create animation assets. If you checkout the animation resource handler on github you should be able to do something like:

var asset = this.app.assets.find("jsonAssetName", "json");
var handler = this.app.loader.getHandler("animation");
var animation = handler.open(asset.getFileUrl(), asset.resource);


// fudge an animation asset
var animAsset = new pc.Asset("My Animation Asset", "animation", {
    file: asset.file
});
animAsset.resource = animation;
animAsset.loaded = true;

It’s a bit of a hack around, and you may not even need to create the actual animation asset if you just need the animation object itself.

1 Like