diff --git a/src/Tween.ts b/src/Tween.ts index 7ad8ab9d..d167b2bf 100644 --- a/src/Tween.ts +++ b/src/Tween.ts @@ -149,7 +149,9 @@ export class Tween { endValues = endValues.map(this._handleRelativeValue.bind(this, startValue as number)) // Create a local copy of the Array with the start value at the front - _valuesEnd[property] = [startValue].concat(endValues) + if (_valuesStart[property] === undefined) { + _valuesEnd[property] = [startValue].concat(endValues) + } } // handle the deepness of the values diff --git a/src/tests.ts b/src/tests.ts index e87c0702..6a3b8a6d 100644 --- a/src/tests.ts +++ b/src/tests.ts @@ -2146,6 +2146,20 @@ export const tests = { test.done() }, + "Test TWEEN.to(ends) shouldn't grow endless on ends value"(test: Test): void { + const target = {y: 0} + const ends = {y: [100, 200]} + const tween = new TWEEN.Tween(target).to(ends, 1000) + + tween.stop().start(0) + tween.stop().start(0) + + TWEEN.update(250) + test.equal(target.y, 50) + + test.done() + }, + 'Test TWEEN.Tween.update() with no arguments'(test: Test): void { const clock = FakeTimers.install() const targetNow = {x: 0.0}