Skip to content

Commit

Permalink
fix : lower limit of power to 2^-52
Browse files Browse the repository at this point in the history
  • Loading branch information
MasatoMakino committed May 4, 2021
1 parent 2987a00 commit e45bbf8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Easing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 1 addition & 9 deletions src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
},
Expand All @@ -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))
Expand Down

0 comments on commit e45bbf8

Please sign in to comment.