JohnM

Play animations on a html5 button

Recommended Posts

Hello all,

 

I am making a project and i need to play animations on a button click. but for some reason after the animation is played the first time it will never play again. I have been able to replicate the basics in a PG - https://playground.babylonjs.com/indexStable.html#V19ZT2

if you open console and enter 

window.startAnim.restart()

then watch the animation play. then enter

 window.startAnim.reset();

it will reset, if you then do the restart command again. nothing will happen. why is this? 

also the version of babylon i am using (i cant find a version number?) has scene.Animatables where it seems all of the animatables (which to my understanding control the animations) are stored. and once the animation is played, it seems the animabable in scene.Animatables is deleted. however in the PG i cant find this variable so i assume its been changed since? however the outcome is the same still.

hope this makes sense!! 

 

many thanks

Share this post


Link to post
Share on other sites

ok that makes sense. so if i need to replay it but i dont want it to instantly loop, how do i go about that? i also preferably dont want to create a new animatable each time either.

i wondered about having an onanimationend function but i guess it wouldnt end in loop mode untill i tell it to stop / pause? 

Share this post


Link to post
Share on other sites

ok so my next question would be, i was using beginDirectAnimation because it creates a new Animatable for each animation as i need to control each animation separately. 

it seems beginDirectAnimation doesnt have onAnimationEnd (from what i  can see) so what would be the next best thing to do to accomplish both needs? 

 

many thanks. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.