Skip to content

Commit

Permalink
Fix LoopMode.Repeat implementation to support domains larger than dou…
Browse files Browse the repository at this point in the history
…ble the original

This matches the original C++ implementation. The situation I was seeing was:

LoopMode: Repeat,
StartFrame: 0,
EndFrame: 2,

`applyLoopMode(22.1)` should return `0.1` but would instead return `20.1`
  • Loading branch information
themikelester committed Dec 11, 2024
1 parent 5efd35e commit f9300c8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Common/JSYSTEM/J3D/J3DGraphAnimator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,14 @@ export class J3DFrameCtrl {
if (timeInFrames >= this.endFrame)
return this.startFrame;
} else if (this.loopMode === LoopMode.Repeat) {
if (timeInFrames >= this.endFrame)
return timeInFrames - (this.endFrame - this.repeatStartFrame);
if (timeInFrames < this.startFrame)
return timeInFrames + (this.repeatStartFrame - this.startFrame);
while (timeInFrames >= this.endFrame) {
if (this.endFrame - this.repeatStartFrame <= 0.0) { break; }
timeInFrames -= (this.endFrame - this.repeatStartFrame);
}
while (timeInFrames < this.startFrame) {
if (this.repeatStartFrame - this.startFrame <= 0.0) { break; }
timeInFrames += (this.repeatStartFrame - this.startFrame);
}
} else if (this.loopMode === LoopMode.MirroredOnce) {
if (timeInFrames >= this.endFrame)
return this.endFrame - (timeInFrames - this.endFrame);
Expand Down

0 comments on commit f9300c8

Please sign in to comment.