Viewer API animation order issue


(Doctypedigital) #1

I have used the Viewer API code example to connect to my SketchFab model:

client.init(urlid, {
  success: function onSuccess(api) {
    api.start();
    api.addEventListener('viewerready', function() {
      api.getAnimations((err, animations) => {
        console.log(animations);
      })
      api.setCycleMode('none');
      api.play();
    });
  },
  error: function onError() {
    console.log('Viewer error');
  },
});

The animations are being logged correctly and match the order in SketchFab:

However, in the viewer itself, the order in the “animation list control” is wrong:

Alt text

Firstly, what is “Static pose” and can I disable it? I’m sure in my earlier animation it just defaulted to the first frame whereas now I have to set this programmatically before .play() will work.

Secondly, why doesn’t the order of the animations match what is in my SketchFab model/what’s being logged to the console? It means that, when I call .play() (or press the play button) the animation plays in a disjointed order as it jumps between the takes in the order listed. Again, this has previously been working so maybe it’s a bug/setting somewhere that I’ve overlooked?

Thanks for any advice.

Update: Just to add, this only seems to occur when I use the setCycleMode method (no matter what value is passed), whereas if I set it using the button in the player it works fine

To test this, I moved the setCycleMode call to a timeout so that only runs after 5 seconds - you’ll see that it’s only when this method is called that the order gets messed up:


Annotation to Animation Binding & A List of API Gripes
#2
  1. The Static Pose is always the rest position of the animation, for example, it might be a T-Pose for a rigged character model. I don’t know exactly how it is determined, it might depend on the software and file format. It cannot be disabled. I’m not sure I understand the problem “now I have to set this programmatically before .play() will work.” Can you elaborate?

  2. The list of animations in the controls and the list that the Viewer API returns should both be the same as the order you set in 3D Settings. The order changing when you use setCycleMode definitely looks like a bug. @paul_sketch can you check?


(Doctypedigital) #3

Hi James,

Thanks for your reply.

I’m not sure I understand the problem “now I have to set this programmatically before .play() will work.” Can you elaborate?

Previously I was able to just call api.play(); and it would start playing the animation through. However, in the more recent version of the model I now have to call api.setCurrentAnimationByUID() and set it to the first animation, otherwise the .play() method doesn’t seem to do anything (it just seems to get stuck on Static Pose) so I was wondering if I’d inadvertently changed something in my model settings.

But this could just be another bug :frowning:

I have a minimal-reproduction JSFiddle set up to reproduce the issue(s) but I can’t share this publicly due to the model content. However, if you would like to PM me then I’ll be happy to share it with you internally.

Thanks again for coming back to me.


(Doctypedigital) #4

@paul_sketch - were you able to find out if this is a bug?

We’ve built an entire front end around the Viewer API but it’s essentially useless until we work out why this has started happening.

Thanks!


(Paul Sketch) #5

Hi, I would be really interested in you jsfiddle sample and model url so that It would be faster to repro and investgate. I you can send them to me by dm it would be great.
Thanks