Sign in to follow this  
ramshreyas

Chaining animations? (or animations in sequence)

Recommended Posts

I want to be able to start animation "B" immediately after "A" is finished.

I can't make them all one big animation because it's dynamic.

 

Here's my example:

 

http://www.babylonjs-playground.com/#1PVZKQ

 

I'm trying to:

 

1.) Move the cube

2.) When it's finished, fade it out

 

What's the best way to do it? Using the onAnimationEnd callback isn't working, it's looping the first animation.

 

Any help appreciated, thanks!

Share this post


Link to post
Share on other sites

Interesting code Temechon - but I have a question about the clearing of the animation array. You use this code:

// Remove the first animation        var index = box.animations.indexOf(anim);        box.animations.splice(index, 1);

Could you just not use this code:

// Remove the first animation        box.animations = [];

It seems to work
  

Is there a reason you do it using the splice function ?

 

cheers, gryff :)

Share this post


Link to post
Share on other sites

Gryff, 

 

There is no specific reason in this case to use the splice function over creating a new array. In both cases, the garbage collector will do its work.

However, if the box has other animations (like a rotation on itself), creating a new array will delete it as well (as it will delete all animations linked to the box).

Share this post


Link to post
Share on other sites

TY for your reply Temechon. :)

 

I have said before, I'm just a javascript "duffer" but as I said above, I find this an interesting piece of code - something that I will probably play around with.

 

Funny how just two lines of code can stimulate some thoughts.

 

cheers, gryff :)

 

 

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.