Jump to content

Animation loopMode


Blax
 Share

Recommended Posts

Hi.  Please, escape me - animation does not allow me to sleep on nights :)  And have all chances will be my personal nightmare )))

I just do not understand how it works.

 

http://www.babylonjs-playground.com/#1UGLI9#3

if we change loopMode in animation process - we have the same result - animation play to end and stop.

Next, if we swap modes:

http://www.babylonjs-playground.com/#1UGLI9#4

we also can not change animation loopMode. Why?

 

Perhaps loopMode cant be changed, while animation played?  Try:

http://www.babylonjs-playground.com/#1UGLI9#5

click just stopped animation.

 

And:

http://www.babylonjs-playground.com/#1UGLI9#6

Oh, no... restart() do nothing again :((((

 

More:

http://www.babylonjs-playground.com/#1UGLI9#8, http://www.babylonjs-playground.com/#1UGLI9#9

If we click - sphere not return in original state.

 

Please, open the animation logic for new bee - it really unclear and seems unlogic (( 

 

 

Link to comment
Share on other sites

Hello,

let me help me kill your nightmares :)

 

the loopMode defines how the animation behaves when it needs to loop.

 

For instance, using relative means that computed value will be relative to first key (meaning that if loop == 1 then animation = key0 + current value). For your example because key0 = 0 this has no impact.

When using cycle, the value just cycle infinitely: http://www.babylonjs-playground.com/#1UGLI9#11

 

For your key/antikey question, animations on the same property are not additive. only the last is used

Link to comment
Share on other sites

Big thank to you, Deltakosh!

One half nightmare's is killed, but i still can't sleep ))

 

Remains three important question:

 

1. What is doung restart() for Animatable?

2. Why we can't return in initial state, if delete animation? (in my try's mesh still changed (scaled) if i runtime delete animation).  I must just save key0 state and restore it for animated property, yes?

3. Can i change loopMode on runtime? In my case i can see anything changing :(

Link to comment
Share on other sites

Let keep fighting then :)

 

1. it stop the pause. So if you pause() the animatable, you can restart(continue) the animation with restart()

2. correct. For performance reasons, animations change the current state of objects so you need to save initial state if you want to restore it

3. Nope (unless changing it on every animatable involved in the animation)

Link to comment
Share on other sites

Hi guys!

 

I did a source search and I cannot find anywhere that Animatable.animationStarted is ever set true.  I suspect that animationStarted should be set in the Lines 84-100 area.

 

Good find, Blax! 

 

Do you know what Coffee Royale is, Blax?  It's coffee with booze in it.  Deltakosh's daughter is probably quite annoying at her current age (1), and Deltakosh likely starts drinking Coffee Royale daily at about 4:30 AM Seattle time.   So, he's pretty well schnockered-up by 9 AM every day.  :D

 

Just kidding, of course.  Deltakosh is RARELY wrong about ANYTHING in BJS, so when he IS wrong about something, we all throw a giant party to celebrate that he is human just like us.  ;)  Maybe we will have another party SOON!  heh

Link to comment
Share on other sites

Hi, Wingnut!

 

>> Do you know what Coffee Royale is, Blax?

 

I rarely drink coffe and rarely booze drink: In the morning, and then..... only-only in the evening :D

 

First, I think set animationStarted manualy, but afraid it broke something inside animation logic.

We need expert opinion, just still wait Deltakosh :)

 

Link to comment
Share on other sites

Ahhh... interesting!  A Blender support device... possibly.  Thanks VP. 

 

See the looper in line 85?  yuh yuh yuh.  Multiple Animations on a single Animatable.  With my kludge... if ANY of them is running... .animationStarted = true (I think) hmm.  Maybe that's not good/right.

Link to comment
Share on other sites

BTW, Animatable still contain mysterious stuff to my ears :P , because it leads to a specific problem I encountered few month ago.

 

If I remember well, when creating many animations with Animation.CreateAndStartAnimation (for instance we use this function to create a new anim while others still running), they all register in the same single Animatable (sounds good), but to do that, the following happens : first, Animatable is created for the first animation, then, this Animatable is stopped at the second Animation creation and a new Animatable is created with both Animations, etc...

That's not totally ok because when setting a onAnimationEnd callback, it is called when the first Animatable stops, not at the real first Animation end (even if the duration time wasn't reached). Also, the "final" Animatable produced contains only the latest onAnimationEnd callback, and not all onAnimationEnd callbacks created for each Animation.

 

Many solutions possible. Maybe we can discuss them to choose the best one :

1. call scene.beginDirectAnimation in Animation.CreateAndStartAnimation instead of calling scene.beginAnimation : I think (not totally sure) that would create as many Animatables as Animations, each one corresponding to one single Animation, with its own onAnimationEnd callback. Drawbacks : we loose the interest of having only one Animatable for all those "quick" anims (CreateAndSartAnimation is meant to be a quick animation constructor)

2. put an onAnimationEnd callback in Animation also, and call those callbacks on real animation end, and not on complete Animatable end/stop. This version is elegant and logical. Interest : that would be more usefull and obvious to allow distinct end callbacks for each animation created. But, first, in this case should we keep Animatable's onAnimationEnd callback and second I remember there was another problem or strange fact, but I don't remember what :lol: :lol:

Link to comment
Share on other sites

does speed ratio = -1 work?

 

I've just tried, unfortunatly it works only if loop is set to true.

 

Loop false :

scene.beginAnimation(mesh, 0, 100, false, -1);  doesn't work (jump to frame 0)

scene.beginAnimation(mesh, 100, 0, false, -1);  doesn't work (jump to frame 0)

 

Loop true :

scene.beginAnimation(mesh, 0, 100, true, -1);  doesn't work (jump to frame 0 and stay on it)

scene.beginAnimation(mesh, 100, 0, true, -1);  works (anim from 100 to 0, but anim is looping - of course -)

Link to comment
Share on other sites

Hmm, another question, how can we go to a specific frame ?

 

I can do scene.beginAnimation(mesh, 6, 7); to go frame 7 but that's not really efficient (and it introduces a slight movement not desired).

scene.beginAnimation(mesh, 7, 7); doesn't work (and maybe it's a bit heavy to start an anim to go at one single frame.

I presume difficulty for reaching a single frame is that correct value need to be interpolated taking all easings specified on the anim in consideration.

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