Skip to content

Animation jump when timeScale changes sign in the first loop when using LoopPingPong mode #19151

@SuperPoneyBoy

Description

@SuperPoneyBoy

Hi I'm testing this lovely library and i've found a bug.

I have an animation in a pingpong way.
When i click on it, the mixer.timeScale is switched between 1 and -1.
In the first loop, at the first click, the animation jumps straight to the end and start going in reverse mode. The others loops are fine.

Looking at the code, it seems to be coming from there :

} else { // repetitive Repeat or PingPong
if ( loopCount === - 1 ) {
// just started
if ( deltaTime >= 0 ) {
loopCount = 0;
this._setEndings( true, this.repetitions === 0, pingPong );
} else {
// when looping in reverse direction, the initial
// transition through zero counts as a repetition,
// so leave loopCount at -1
this._setEndings( this.repetitions === 0, true, pingPong );
}
}

if ( deltaTime >= 0 )
Should be changed because if delta is negative, then it jumps to the end of animation instead of goinf in reverse mode!
if ( deltaTime * timeDirection >= 0 )

Here is the full stack to change the caller :

_update: function ( time, deltaTime, timeDirection, accuIndex ) {

var clipTime = this._updateTime( deltaTime );

Adding timeDirection to

_updateTime: function ( deltaTime ) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions