Jump to content

AnimationEvent being triggered when skipping over frame


FunFetched
 Share

Recommended Posts

Found an issue with Animation/AnimationEvent where an event set for an earlier frame is immediately triggered when playing the animation starting at a later frame. Here's a playground example of the problem (you'll need to open your JS console):

https://www.babylonjs-playground.com/#E54IFV#4

Edit: Taking a look at the code, I can already see the problem. I'll see if I can't whip this one myself.

Link to comment
Share on other sites

Oof. This is also affecting animations that are played backwards. On line 656 in babylon.animation.ts we have this line:

if (currentFrame >= this._events[index].frame) {

Obviously, currentFrame is floating point, so we can't just do a simple == in this situation. Unfortunately, since it's looping through all of the events from start to finish every time, all previous events in the timeline get triggered right off the bat, even if we started the animation at a later point. In the case of backwards animations, the problem is exacerbated for the same reason. If we only supported forward animation, the solution would be a simple matter of changing the line above to:

if (currentFrame >= this._events[index].frame && this._events[index].frame >= from) {

... but I guess it's not that simple any more. :)  I'll keep digging.

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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