Skip to content

Commit

Permalink
animation: update _interpolate implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
noname0310 committed Oct 11, 2023
1 parent 51c7539 commit 864ba45
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Runtime/Animation/bezierAnimation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class BezierAnimation extends Animation {
/**
* @internal Internal use only
*/
public override _interpolate(currentFrame: number, state: _IAnimationState): any {
public override _interpolate(currentFrame: number, state: _IAnimationState, searchClosestKeyOnly = false): any {
if (state.loopMode === Animation.ANIMATIONLOOPMODE_CONSTANT && state.repeatCount > 0) {
return state.highLimitValue.clone ? state.highLimitValue.clone() : state.highLimitValue;
}
Expand All @@ -48,13 +48,18 @@ export class BezierAnimation extends Animation {
state.key = key;

if (key < 0) {
return this._getKeyValue(keys[0].value);
return searchClosestKeyOnly ? undefined : this._getKeyValue(keys[0].value);
} else if (key + 1 > keysLength - 1) {
return this._getKeyValue(keys[keysLength - 1].value);
return searchClosestKeyOnly ? undefined : this._getKeyValue(keys[keysLength - 1].value);
}

const startKey = keys[key];
const endKey = keys[key + 1];

if (searchClosestKeyOnly && (currentFrame === startKey.frame || currentFrame === endKey.frame)) {
return undefined;
}

const startValue = this._getKeyValue(startKey.value);
const endValue = this._getKeyValue(endKey.value);
if (startKey.interpolation === AnimationKeyInterpolation.STEP) {
Expand Down

0 comments on commit 864ba45

Please sign in to comment.