Jump to content

Chaining animations? (or animations in sequence)


ramshreyas
 Share

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!

Link to comment
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 :)

Link to comment
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).

Link to comment
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 :)

 

 

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