Skip to content

AnimationAction: Fix timeScale reversal jump.#33035

Merged
Mugen87 merged 1 commit intomrdoob:devfrom
Mugen87:dev5
Feb 21, 2026
Merged

AnimationAction: Fix timeScale reversal jump.#33035
Mugen87 merged 1 commit intomrdoob:devfrom
Mugen87:dev5

Conversation

@Mugen87
Copy link
Copy Markdown
Collaborator

@Mugen87 Mugen87 commented Feb 20, 2026

Fixed #19151.

Description

The PR fixes a long-standing bug in AnimationAction that happens when the time scale of the animation mixer is reversed during the first run of looped animations.

I've tried to fix this multiple times in the past but wasn't sure about the real root cause. With the help of Claude 4.6, this should be resolved. Claude required multiple attempts but eventually found the root cause in an else branch where a member wasn't correctly updated.

In _updateTime() , the "just started" block (line 781) sets the local variable loopCount from -1 to 0, but this._loopCount is only persisted inside the wrap-around branch (line 847). The non-wrapping else branch (line 857) never writes it back. This means this._loopCount stays at -1 indefinitely until a wrap-around occurs. On subsequent frames, the "just started" block re-executes, and for PingPong mode, the check (loopCount & 1) === 1 evaluates to true because -1 & 1 === 1, causing unwanted time inversion and a visual jump.

The test code from #19151 now behaves correctly and the animation examples should also work as before (tested locally). I think it's worth giving this fix a try!

@github-actions
Copy link
Copy Markdown

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 359.15
85.24
359.15
85.24
+0 B
+0 B
WebGPU 623.55
173.47
623.55
173.47
+0 B
+0 B
WebGPU Nodes 622.13
173.21
622.13
173.21
+0 B
+0 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 490.87
119.65
490.87
119.65
+0 B
+0 B
WebGPU 697.03
188.44
697.03
188.44
+0 B
+0 B
WebGPU Nodes 646.24
175.82
646.24
175.82
+0 B
+0 B

@Mugen87 Mugen87 added this to the r184 milestone Feb 20, 2026
@Mugen87 Mugen87 merged commit 5f6753b into mrdoob:dev Feb 21, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant