ramshreyas Posted June 6, 2015 Share Posted June 6, 2015 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 cube2.) 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! Quote Link to comment Share on other sites More sharing options...
Temechon Posted June 6, 2015 Share Posted June 6, 2015 You have to remove the first animation in your callback function: http://www.babylonjs-playground.com/#1PVZKQ#1 Cheers! DiV 1 Quote Link to comment Share on other sites More sharing options...
gryff Posted June 6, 2015 Share Posted June 6, 2015 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 Quote Link to comment Share on other sites More sharing options...
Temechon Posted June 7, 2015 Share Posted June 7, 2015 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). gryff 1 Quote Link to comment Share on other sites More sharing options...
gryff Posted June 7, 2015 Share Posted June 7, 2015 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 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.