babbleon Posted January 10, 2018 Share Posted January 10, 2018 Hello, I have an animation which I start with a function containing this: scene.beginAnimation(scene.getMeshByName("Cube"), 0, 60, false, 1.0); How do I get the current frame number, assuming I stop or pause it at some arbitrary point whilst the animation is running. Thank you, Quote Link to comment Share on other sites More sharing options...
RaananW Posted January 10, 2018 Share Posted January 10, 2018 The RuntimeAnimation class has a currentFrame variable. you can get the RuntimeAnimations from the animatable, rturned by beginAnimation. so, a quick (untested) code, assuming there is one animation registered: let animatable = scene.beginAnimation(scene.getMeshByName("Cube"), 0, 60, false, 1.0); let currentFrame = animatable.getAnimations()[0].currentFrame This code can (and SHOULD) be improved - especially the direct access to the array without checking if anything's there, but this would be the way to start Quote Link to comment Share on other sites More sharing options...
babbleon Posted January 10, 2018 Author Share Posted January 10, 2018 Many thanks RaananW, This works with https://preview.babylonjs.com/babylon.js but not with https://cdn.babylonjs.com/babylon.js (I am unsure of versions). Much appreciated. Quote Link to comment Share on other sites More sharing options...
RaananW Posted January 10, 2018 Share Posted January 10, 2018 the CDN has 3.1.1 , i should be working (the class is there). What error do you get? Quote Link to comment Share on other sites More sharing options...
babbleon Posted January 10, 2018 Author Share Posted January 10, 2018 I don't get an error in the console, it simply states frame 0 regardless of what frame the animation is at. Can I find the Babylon version from the console? Quote Link to comment Share on other sites More sharing options...
RaananW Posted January 10, 2018 Share Posted January 10, 2018 yep, it is always the first line in the console (automatically added). Open the F12 tools before everything loads and you will see the version used. Quote Link to comment Share on other sites More sharing options...
babbleon Posted January 10, 2018 Author Share Posted January 10, 2018 Yes, I see it clearly - sorry, I should have looked at my screen! So, to confirm... .currentFrame v3.2.0-alpha2 correctly shows current frame 3.1.1 shows 0 for current frame Quote Link to comment Share on other sites More sharing options...
RaananW Posted January 10, 2018 Share Posted January 10, 2018 Might have been a bug that was fixed (and I am happy it was! 3.2.0 is fully compatible with 3.1.1, I would recommend using it instead, if you need the current frame. 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.