Jump to content

How to reset/restart multiple animations in one animationGroup


dingoogle
 Share

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

 

 

Link to comment
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!

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

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

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