I am wondering if anyone can help me with this. What I would like to do is stringify individual animations, and save them to the server in mysql or as files, that can be called up dynamically.
What I have is code like this… it loads the model… it works… the animation plays fine.
loader.load( ‘models/new/myAvatar.glb’, function ( gltf ) {
loader.load( ‘models/new/default_anis.glb’, function ( defanis ) {
var avatar=gltf.scene;
animations = defanis.animations;
/// ^^ This is an avatar that loads, works, animations are working…
What I want to do…
var theSavedAnimation = JSON.stringify( animations[0] );
//… does stuff to store the string and calls it back later…
animations[0]=JSON.parse( theSavedAnimation );
If I do this … just stringify… then immediately parse the same string. The animation is not usable. If I console.log and compare… all the data is there. But I am thinking it is coming back as a structure that the mixer does not like?
Here is the error:
TypeError: a[e].createInterpolant is not a function at new Kf (three.min.js:297) at be.clipAction (three.min.js:863)
The way I am doing animations now. I have several avatar characters with the same skeleton. And I export them as GLTF, with one small animation. Then I have another master avatar, that has the entire collection of animations.
So I copy…
animations[0] = masterAvatar.animations[2];
and that system works fine… but I will potentially have hundreds, and I need to load them dynamically from a URL later. I can’t load them all at startup, the way I am doing it now.
Any insights would be appreciated.