Skip to content

Commit 33363e3

Browse files
authored
Animation: Fix wrong value at end of animation (#17412)
See https://forum.babylonjs.com/t/animations-with-animationloopmode-constant-behave-weird/61320 It looks like a bug to me, what do you think?
1 parent a1f1433 commit 33363e3

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

packages/dev/core/src/Animations/runtimeAnimation.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ export class RuntimeAnimation {
123123
private _keys: IAnimationKey[];
124124
private _minFrame: number;
125125
private _maxFrame: number;
126-
private _minValue: any;
127-
private _maxValue: any;
128126
private _targetIsArray = false;
129127

130128
/** @internal */
@@ -206,12 +204,10 @@ export class RuntimeAnimation {
206204
this._keys = this._animation.getKeys();
207205
this._minFrame = this._keys[0].frame;
208206
this._maxFrame = this._keys[this._keys.length - 1].frame;
209-
this._minValue = this._keys[0].value;
210-
this._maxValue = this._keys[this._keys.length - 1].value;
211207

212208
// Add a start key at frame 0 if missing
213209
if (this._minFrame !== 0) {
214-
const newKey = { frame: 0, value: this._minValue };
210+
const newKey = { frame: 0, value: this._keys[0].value };
215211
this._keys.splice(0, 0, newKey);
216212
}
217213

@@ -575,10 +571,10 @@ export class RuntimeAnimation {
575571
if (!loop && to >= from && ((absoluteFrame >= frameRange && speedRatio > 0) || (absoluteFrame <= 0 && speedRatio < 0))) {
576572
// If we are out of range and not looping get back to caller
577573
returnValue = false;
578-
highLimitValue = animation._getKeyValue(this._maxValue);
574+
highLimitValue = animation.evaluate(to);
579575
} else if (!loop && from >= to && ((absoluteFrame <= frameRange && speedRatio < 0) || (absoluteFrame >= 0 && speedRatio > 0))) {
580576
returnValue = false;
581-
highLimitValue = animation._getKeyValue(this._minValue);
577+
highLimitValue = animation.evaluate(from);
582578
} else if (this._animationState.loopMode !== Animation.ANIMATIONLOOPMODE_CYCLE) {
583579
const keyOffset = to.toString() + from.toString();
584580
if (!this._offsetsCache[keyOffset]) {

0 commit comments

Comments
 (0)