From 51ce17b9879daec7ffb011e27cbe29d70fca052f Mon Sep 17 00:00:00 2001 From: Leslie Leigh Date: Fri, 14 Jun 2019 14:45:07 +0800 Subject: [PATCH] update api document for ILerpable (#4621) --- cocos/animation/animation-clip.ts | 2 +- cocos/animation/animation-curve.ts | 7 +++++-- cocos/animation/types.ts | 12 ++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/cocos/animation/animation-clip.ts b/cocos/animation/animation-clip.ts index 4d821a09f3..493b189462 100644 --- a/cocos/animation/animation-clip.ts +++ b/cocos/animation/animation-clip.ts @@ -307,7 +307,7 @@ export class AnimationClip extends Asset { if (propertyCurveData.keys >= 0) { ratioSampler = this._ratioSamplers[propertyCurveData.keys]; } - return new AnimCurve(propertyCurveData, propertyName, isNode, ratioSampler); + return new AnimCurve(propertyCurveData, propertyName, this._duration, isNode, ratioSampler); } private _createRuntimeEvents () { diff --git a/cocos/animation/animation-curve.ts b/cocos/animation/animation-curve.ts index 6761641c02..0591e9f363 100644 --- a/cocos/animation/animation-curve.ts +++ b/cocos/animation/animation-curve.ts @@ -152,7 +152,10 @@ export class AnimCurve { private _stepfiedValues?: any[]; - constructor (propertyCurveData: IPropertyCurveData, propertyName: string, isNode: boolean, ratioSampler: RatioSampler | null) { + private _duration: number; + + constructor (propertyCurveData: IPropertyCurveData, propertyName: string, duration: number, isNode: boolean, ratioSampler: RatioSampler | null) { + this._duration = duration; this._ratioSampler = ratioSampler; // Install values. @@ -276,7 +279,7 @@ export class AnimCurve { } // calculate value const toVal = values[index]; - value = this._lerp(fromVal, toVal, ratioBetweenFrames, dRatio); + value = this._lerp(fromVal, toVal, ratioBetweenFrames, dRatio * this._duration); isLerped = true; } } diff --git a/cocos/animation/types.ts b/cocos/animation/types.ts index ea89f031b9..c5be961082 100644 --- a/cocos/animation/types.ts +++ b/cocos/animation/types.ts @@ -79,7 +79,19 @@ export class WrappedInfo { } export interface ILerpable { + /** + * 在当前曲线值与目标曲线值之间插值。 + * @param to 目标曲线值。 + * @param t 插值比率。 + * @param dt 当前曲线值与目标曲线值的时间间隔,单位为秒。 + * @returns 插值结果。 + */ lerp (to: any, t: number, dt: number): any; + + /** + * 当直接使用曲线值作为采样结果时的结果值,它应该等同于插值比率为 0 时的插值结果。 + * @returns 插值比率为 0 时的插值结果。 + */ getNoLerp? (): any; }