Jump to content

Get current frame from animation


babbleon
 Share

Recommended Posts

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,

Link to comment
Share on other sites

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

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