jpdev Posted October 31, 2016 Share Posted October 31, 2016 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/) Hi, 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: console.log(anim.getAnimations()[0].currentFrame); gotoCode: anim.goToFrame(10); Example output on the console: 77.15608 77.56336 Set to 10! 10 77.96092 77.96092 Edit: Using Babylon.2.4.js from the dist directory on github. Quote Link to comment Share on other sites More sharing options...
jpdev Posted October 31, 2016 Author Share Posted October 31, 2016 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. Quote Link to comment Share on other sites More sharing options...
adam Posted October 31, 2016 Share Posted October 31, 2016 It's working here using BJS 2.4.1: https://jsfiddle.net/usxek13s/1/ Quote Link to comment Share on other sites More sharing options...
adam Posted October 31, 2016 Share Posted October 31, 2016 This doesn't seem to do much though: https://jsfiddle.net/usxek13s/2/ Quote Link to comment Share on other sites More sharing options...
jpdev Posted October 31, 2016 Author Share Posted October 31, 2016 6 minutes ago, adam said: It's working here using BJS 2.4.1: https://jsfiddle.net/usxek13s/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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.