Jump to content

Animations: goToFrame has no effect: it sets currentFrame and that gets overwritten every animation cycle?


Recommended Posts

Edit (3): After analyzing why it's not working I have created a bug report over at the bug-forum with a playground example. (http://www.html5gamedevs.com/topic/26166-bug-report-gotoframe-has-no-effect-on-running-animation-with-playground-example/)


I am new to babylon.js - so I might be doing something wrong.

Edit (2): I have debugged the code to the best of my knowladge, please see my first reply.

My problem:

When I call goToFrame on the animatable returend by beginAnimation nothing happens.

I try this on already running animations during the runRenderLoop function, and also while setting up the animations.

For example, during the runRenderLoop function, I do the following:

Output the current frame of the first animation inside the animatable, it's for example 109.9123

Now I call: animateable.goToFrame(10);

Now the current frame is actually 10, but during the next call of runRenderLoop the current frame is right back where it was before calling goToFrame.

And the animation just loops on, as if gotoFrame hasn't been called at all.

Setting up the animation:

var anim = scene.skeletons[0].beginAnimation("Idle", true, 1.0);

Code to output the current frame:





Example output on the console:

Set to 10!


Edit: Using Babylon.2.4.js from the dist directory on github.

Link to comment
Share on other sites

This seems to me like an engine bug.

In Animation.prototype.animate (within the engine) a local variable "currentFrame" is calculated without checking the this.currentFrame:

Line 26891 (babylon.2.4.max.js):

var currentFrame = returnValue ? from + ratio % range : to;

"this.currentFrame" goes completely ignored.

And after that in Animation.prototype._interpolate the new calculated value is assigned to this.currentFrame.

This means the "goToFrame"-Function never has any effect.

Link to comment
Share on other sites

6 minutes ago, adam said:

It's working here using BJS 2.4.1:


Hi Adam,

Thank you for the input.

My Version seems to be 2.4.0 (https://raw.githubusercontent.com/BabylonJS/Babylon.js/master/dist/babylon.2.4.max.js) - the only distribution download I could find in the github repository.

In your first jsfiddle the goToFrame call seems to kill the animation? (it's not running for me, removing the line the animation runs)

In the second example the animation runs (while you set the frame to 50 every render call) - this completely matches my code analysis. (that this.currentFrame is set by goToFrame and then ignored and recalculated based on to, from and ratio.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...