Sign in to follow this  
dingoogle

How to reset/restart multiple animations in one animationGroup

Recommended Posts

Hi Guys,

I got a problem when trying to reset/restart an animationGroup with multiple animations in it. Looks the animations can't reset together by animationGroup.

I've tried several ways as below but none of them worked well.  Your kind help will be highly appreciated.

1. create AnimationEvent at the end frame, PB https://www.babylonjs-playground.com/index.html#9DDUHI

2. add callback to onAnimationEndObservable.add() function, PB https://www.babylonjs-playground.com/index.html#9DDUHI#2

3. add callback to onAnimationEndObservable.addOnce() function, PB https://www.babylonjs-playground.com/index.html#9DDUHI#3

 

 

Share this post


Link to post
Share on other sites
1 hour ago, SinhNQ said:

Hi,

I think this is bug (not sure) but you can use tricks by set _isStarted = false 😅

Fixed: https://www.babylonjs-playground.com/index.html#9DDUHI#4

Hi SinhNQ, thank you for your reply. "_isStarted" works well in JS. But unfortunately my project is coded in strict TypeScript , "_isStarted" is private and "isStarted" is readonly. :( I can't make it pass verification when compiling. Hope the "bug" could be  fixed soon ;).

BTW, is there any suggestion to create a "timeline" like Adobe Flash CC or 3DSMax? My thought is creating a global animation with default length, let's say 500 frames, adding key frames and expanding length dynamically. This animation should be assigned to a "pseudo" mesh to provide current and total frames when animating. Can set playback head, be sought, paused, restarted etc.

If there's any better practice please let me know. thanks!

Share this post


Link to post
Share on other sites
47 minutes ago, RaananW said:

I agree that this is a bug.

The onAnimationEnd should only be triggered once (i would assume) and isStarted should be set to false when all animations ended.

This would be my solution - (very similar to yours, just using public methods😞

https://www.babylonjs-playground.com/index.html#9DDUHI#5

Hi RaananW, just saw your reply, thanks, It should work in TypeScript. Agree that onAnimationEnd should only be triggered once. Hope the observable in babylon.js could be something like rxjs.

Share this post


Link to post
Share on other sites
34 minutes ago, dingoogle said:

BTW, is there any suggestion to create a "timeline" like Adobe Flash CC or 3DSMax? My thought is creating a global animation with default length, let's say 500 frames, adding key frames and expanding length dynamically. This animation should be assigned to a "pseudo" mesh to provide current and total frames when animating. Can set playback head, be sought, paused, restarted etc.

I recommend you use GreenSock API - the best framework for HTML5 Animation. I been used more than 3 year for 2D and 3D projects. 😁

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.