From e45bbf83af86bba3da59f6c656d09269c978cd2e Mon Sep 17 00:00:00 2001 From: MasatoMakino Date: Tue, 4 May 2021 16:13:04 +0900 Subject: [PATCH] fix : lower limit of power to 2^-52 --- src/Easing.ts | 2 +- src/tests.ts | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Easing.ts b/src/Easing.ts index b502034..9639783 100644 --- a/src/Easing.ts +++ b/src/Easing.ts @@ -202,7 +202,7 @@ const Easing = { Out(amount: number): number InOut(amount: number): number } { - power = power < 1.0 ? 1.0 : power + power = power < Number.EPSILON ? Number.EPSILON : power power = power > 10000 ? 10000 : power return { In: function (amount: number): number { diff --git a/src/tests.ts b/src/tests.ts index e736023..74258b0 100644 --- a/src/tests.ts +++ b/src/tests.ts @@ -2021,7 +2021,6 @@ export const tests = { 'Test TWEEN.Easing.generatePow(1) equals Linear'(test: Test): void { const ease1 = TWEEN.Easing.generatePow(1) - const easeMinus = TWEEN.Easing.generatePow(-1) const compareWithLinear = (ease: EasingFunctionGroup, amount: number) => { const linearResult = TWEEN.Easing.Linear.None(amount) @@ -2030,20 +2029,12 @@ export const tests = { test.equal(linearResult, ease.InOut(amount)) } compareWithLinear(ease1, 0) - compareWithLinear(easeMinus, 0) compareWithLinear(ease1, 0.25) - compareWithLinear(easeMinus, 0.25) compareWithLinear(ease1, 0.5) - compareWithLinear(easeMinus, 0.5) compareWithLinear(ease1, 0.75) - compareWithLinear(easeMinus, 0.75) compareWithLinear(ease1, 1) - compareWithLinear(easeMinus, 1) - compareWithLinear(ease1, -1) - compareWithLinear(easeMinus, -1) compareWithLinear(ease1, Infinity) - compareWithLinear(easeMinus, Infinity) test.done() }, @@ -2061,6 +2052,7 @@ export const tests = { test.equal(ease.Out(1.0), 1.0) } checkEdgeValue(TWEEN.Easing.generatePow(Number.NEGATIVE_INFINITY)) + checkEdgeValue(TWEEN.Easing.generatePow(-1.0)) checkEdgeValue(TWEEN.Easing.generatePow(1)) checkEdgeValue(TWEEN.Easing.generatePow(Math.LOG2E)) checkEdgeValue(TWEEN.Easing.generatePow(Math.PI))