流星

流星消逝的时候,光明已在望。黑暗无论多么长,光明迟早总是会来的。

插值运动种类详记 有更新!

    各种插值,达到不同的运动感受
    Linear = 0, //线性,运动最硬,没有曲线滑动效果,一次函数 y = ax + b;
    InSine = 1,
    OutSine = 2,
    InOutSine = 3,
    InQuad = 4,
    OutQuad = 5,
    InOutQuad = 6,
    InCubic = 7,
    OutCubic = 8,
    InOutCubic = 9,
    InQuart = 10,
    OutQuart = 11,
    InOutQuart = 12,
    InQuint = 13,
    OutQuint = 14,
    InOutQuint = 15,
    InExpo = 16,
    OutExpo = 17,
    InOutExpo = 18,
    InCirc = 19,
    OutCirc = 20,
    InOutCirc = 21,
    InElastic = 22,
    OutElastic = 23,
    InOutElastic = 24,
    InBack = 25,
    OutBack = 26,
    InOutBack = 27,
    InBounce = 28,
    OutBounce = 29,
    InOutBounce = 30,
    Hard = 31,
    2次加速,类似y = a x^2,

    骨骼位置插值,我原本用的是普通的插值,后面看laya用的是埃尔米特插值,不知道和普通插值的区别是什么
    _hermiteInterpolate(frame, nextFrame, t, dur) {
    var t0 = frame.outTangent, t1 = nextFrame.inTangent;
    if (Number.isFinite(t0) && Number.isFinite(t1)) {
    var t2 = t * t;
    var t3 = t2 * t;
    var a = 2.0 * t3 - 3.0 * t2 + 1.0;
    var b = t3 - 2.0 * t2 + t;
    var c = t3 - t2;
    var d = -2.0 * t3 + 3.0 * t2;
    return a * frame.value + b * t0 * dur + c * t1 * dur + d * nextFrame.value;
    }
    else
    return frame.value;
    }
    _hermiteInterpolateVector3(frame, nextFrame, t, dur, out) {
    var p0 = frame.value;
    var tan0 = frame.outTangent;
    var p1 = nextFrame.value;
    var tan1 = nextFrame.inTangent;
    var t2 = t * t;
    var t3 = t2 * t;
    var a = 2.0 * t3 - 3.0 * t2 + 1.0;
    var b = t3 - 2.0 * t2 + t;
    var c = t3 - t2;
    var d = -2.0 * t3 + 3.0 * t2;
    var t0 = tan0.x, t1 = tan1.x;
    if (Number.isFinite(t0) && Number.isFinite(t1))
    out.x = a * p0.x + b * t0 * dur + c * t1 * dur + d * p1.x;
    else
    out.x = p0.x;
    t0 = tan0.y, t1 = tan1.y;
    if (Number.isFinite(t0) && Number.isFinite(t1))
    out.y = a * p0.y + b * t0 * dur + c * t1 * dur + d * p1.y;
    else
    out.y = p0.y;
    t0 = tan0.z, t1 = tan1.z;
    if (Number.isFinite(t0) && Number.isFinite(t1))
    out.z = a * p0.z + b * t0 * dur + c * t1 * dur + d * p1.z;
    else
    out.z = p0.z;
    }
    _hermiteInterpolateQuaternion(frame, nextFrame, t, dur, out) {
    var p0 = frame.value;
    var tan0 = frame.outTangent;
    var p1 = nextFrame.value;
    var tan1 = nextFrame.inTangent;
    var t2 = t * t;
    var t3 = t2 * t;
    var a = 2.0 * t3 - 3.0 * t2 + 1.0;
    var b = t3 - 2.0 * t2 + t;
    var c = t3 - t2;
    var d = -2.0 * t3 + 3.0 * t2;
    var t0 = tan0.x, t1 = tan1.x;
    if (Number.isFinite(t0) && Number.isFinite(t1))
    out.x = a * p0.x + b * t0 * dur + c * t1 * dur + d * p1.x;
    else
    out.x = p0.x;
    t0 = tan0.y, t1 = tan1.y;
    if (Number.isFinite(t0) && Number.isFinite(t1))
    out.y = a * p0.y + b * t0 * dur + c * t1 * dur + d * p1.y;
    else
    out.y = p0.y;
    t0 = tan0.z, t1 = tan1.z;
    if (Number.isFinite(t0) && Number.isFinite(t1))
    out.z = a * p0.z + b * t0 * dur + c * t1 * dur + d * p1.z;
    else
    out.z = p0.z;
    t0 = tan0.w, t1 = tan1.w;
    if (Number.isFinite(t0) && Number.isFinite(t1))
    out.w = a * p0.w + b * t0 * dur + c * t1 * dur + d * p1.w;
    else
    out.w = p0.w;
    }

    validate