From aabc59f62807b911d872b1d3a436ee2485006872 Mon Sep 17 00:00:00 2001 From: suoluo Date: Tue, 4 Sep 2018 14:47:50 +0800 Subject: [PATCH 1/2] add: onRepeat+add update rate --- src/Tween.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Tween.js b/src/Tween.js index 57a1be34..31bb47d2 100644 --- a/src/Tween.js +++ b/src/Tween.js @@ -138,6 +138,7 @@ TWEEN.Tween = function (object, group) { this._onStartCallback = null; this._onStartCallbackFired = false; this._onUpdateCallback = null; + this._onRepeatCallback = null; this._onCompleteCallback = null; this._onStopCallback = null; this._group = group || TWEEN; @@ -313,6 +314,13 @@ TWEEN.Tween.prototype = { }, + onRepeat: function onRepeat(callback) { + + this._onRepeatCallback = callback; + return this; + + }, + onComplete: function onComplete(callback) { this._onCompleteCallback = callback; @@ -387,7 +395,7 @@ TWEEN.Tween.prototype = { } if (this._onUpdateCallback !== null) { - this._onUpdateCallback(this._object); + this._onUpdateCallback(this._object,elapsed); } if (elapsed === 1) { @@ -426,6 +434,10 @@ TWEEN.Tween.prototype = { this._startTime = time + this._delayTime; } + if (this._onRepeatCallback!=null) { + this._onRepeatCallback(); + } + return true; } else { From cc4bdf89a40c045d8e20fc3dbc301746038c0ab9 Mon Sep 17 00:00:00 2001 From: suoluo Date: Tue, 4 Sep 2018 15:08:52 +0800 Subject: [PATCH 2/2] add: onRepeat+add update rate --- src/Tween.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Tween.js b/src/Tween.js index 31bb47d2..07913833 100644 --- a/src/Tween.js +++ b/src/Tween.js @@ -395,7 +395,7 @@ TWEEN.Tween.prototype = { } if (this._onUpdateCallback !== null) { - this._onUpdateCallback(this._object,elapsed); + this._onUpdateCallback(this._object, elapsed); } if (elapsed === 1) { @@ -434,7 +434,7 @@ TWEEN.Tween.prototype = { this._startTime = time + this._delayTime; } - if (this._onRepeatCallback!=null) { + if (this._onRepeatCallback !== null) { this._onRepeatCallback(); }