@tweenjs/tween.js
Advanced tools
Comparing version 18.5.0 to 18.6.0
define(function () { 'use strict'; | ||
var version = '18.5.0'; | ||
var NOW; | ||
// Include a performance.now polyfill. | ||
// In node.js, use process.hrtime. | ||
// eslint-disable-next-line | ||
// @ts-ignore | ||
if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) { | ||
NOW = function () { | ||
// eslint-disable-next-line | ||
// @ts-ignore | ||
var time = process.hrtime(); | ||
// Convert [seconds, nanoseconds] to milliseconds. | ||
return time[0] * 1000 + time[1] / 1000000; | ||
}; | ||
} | ||
// In a browser, use self.performance.now if it is available. | ||
else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) { | ||
// This must be bound, because directly assigning this function | ||
// leads to an invocation exception in Chrome. | ||
NOW = self.performance.now.bind(self.performance); | ||
} | ||
// Use Date.now if it is available. | ||
else if (Date.now !== undefined) { | ||
NOW = Date.now; | ||
} | ||
// Otherwise, use 'new Date().getTime()'. | ||
else { | ||
NOW = function () { | ||
return new Date().getTime(); | ||
}; | ||
} | ||
var NOW$1 = NOW; | ||
/** | ||
* Tween.js - Licensed under the MIT license | ||
* https://github.com/tweenjs/tween.js | ||
* ---------------------------------------------- | ||
* | ||
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. | ||
* Thank you all, you're awesome! | ||
*/ | ||
/** | ||
* Controlling groups of tweens | ||
* | ||
* Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components. | ||
* In these cases, you may want to create your own smaller groups of tween | ||
*/ | ||
var Group = /** @class */ (function () { | ||
function Group() { | ||
this._tweens = {}; | ||
this._tweensAddedDuringUpdate = {}; | ||
} | ||
Group.prototype.getAll = function () { | ||
var _this = this; | ||
return Object.keys(this._tweens).map(function (tweenId) { | ||
return _this._tweens[tweenId]; | ||
}); | ||
}; | ||
Group.prototype.removeAll = function () { | ||
this._tweens = {}; | ||
}; | ||
Group.prototype.add = function (tween) { | ||
this._tweens[tween.getId()] = tween; | ||
this._tweensAddedDuringUpdate[tween.getId()] = tween; | ||
}; | ||
Group.prototype.remove = function (tween) { | ||
delete this._tweens[tween.getId()]; | ||
delete this._tweensAddedDuringUpdate[tween.getId()]; | ||
}; | ||
Group.prototype.update = function (time, preserve) { | ||
var tweenIds = Object.keys(this._tweens); | ||
if (tweenIds.length === 0) { | ||
return false; | ||
} | ||
time = time !== undefined ? time : NOW$1(); | ||
// Tweens are updated in "batches". If you add a new tween during an | ||
// update, then the new tween will be updated in the next batch. | ||
// If you remove a tween during an update, it may or may not be updated. | ||
// However, if the removed tween was added during the current batch, | ||
// then it will not be updated. | ||
while (tweenIds.length > 0) { | ||
this._tweensAddedDuringUpdate = {}; | ||
for (var i = 0; i < tweenIds.length; i++) { | ||
var tween = this._tweens[tweenIds[i]]; | ||
if (tween && tween.update(time) === false && !preserve) { | ||
delete this._tweens[tweenIds[i]]; | ||
} | ||
} | ||
tweenIds = Object.keys(this._tweensAddedDuringUpdate); | ||
} | ||
return true; | ||
}; | ||
return Group; | ||
}()); | ||
/** | ||
* The Ease class provides a collection of easing functions for use with tween.js. | ||
*/ | ||
var Easing = { | ||
Linear: { | ||
None: function (amount) { | ||
return amount; | ||
}, | ||
}, | ||
Quadratic: { | ||
In: function (amount) { | ||
return amount * amount; | ||
}, | ||
Out: function (amount) { | ||
return amount * (2 - amount); | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * amount * amount; | ||
} | ||
return -0.5 * (--amount * (amount - 2) - 1); | ||
}, | ||
}, | ||
Cubic: { | ||
In: function (amount) { | ||
return amount * amount * amount; | ||
}, | ||
Out: function (amount) { | ||
return --amount * amount * amount + 1; | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * amount * amount * amount; | ||
} | ||
return 0.5 * ((amount -= 2) * amount * amount + 2); | ||
}, | ||
}, | ||
Quartic: { | ||
In: function (amount) { | ||
return amount * amount * amount * amount; | ||
}, | ||
Out: function (amount) { | ||
return 1 - --amount * amount * amount * amount; | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * amount * amount * amount * amount; | ||
} | ||
return -0.5 * ((amount -= 2) * amount * amount * amount - 2); | ||
}, | ||
}, | ||
Quintic: { | ||
In: function (amount) { | ||
return amount * amount * amount * amount * amount; | ||
}, | ||
Out: function (amount) { | ||
return --amount * amount * amount * amount * amount + 1; | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * amount * amount * amount * amount * amount; | ||
} | ||
return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2); | ||
}, | ||
}, | ||
Sinusoidal: { | ||
In: function (amount) { | ||
return 1 - Math.cos((amount * Math.PI) / 2); | ||
}, | ||
Out: function (amount) { | ||
return Math.sin((amount * Math.PI) / 2); | ||
}, | ||
InOut: function (amount) { | ||
return 0.5 * (1 - Math.cos(Math.PI * amount)); | ||
}, | ||
}, | ||
Exponential: { | ||
In: function (amount) { | ||
return amount === 0 ? 0 : Math.pow(1024, amount - 1); | ||
}, | ||
Out: function (amount) { | ||
return amount === 1 ? 1 : 1 - Math.pow(2, -10 * amount); | ||
}, | ||
InOut: function (amount) { | ||
if (amount === 0) { | ||
return 0; | ||
} | ||
if (amount === 1) { | ||
return 1; | ||
} | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * Math.pow(1024, amount - 1); | ||
} | ||
return 0.5 * (-Math.pow(2, -10 * (amount - 1)) + 2); | ||
}, | ||
}, | ||
Circular: { | ||
In: function (amount) { | ||
return 1 - Math.sqrt(1 - amount * amount); | ||
}, | ||
Out: function (amount) { | ||
return Math.sqrt(1 - --amount * amount); | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return -0.5 * (Math.sqrt(1 - amount * amount) - 1); | ||
} | ||
return 0.5 * (Math.sqrt(1 - (amount -= 2) * amount) + 1); | ||
}, | ||
}, | ||
Elastic: { | ||
In: function (amount) { | ||
if (amount === 0) { | ||
return 0; | ||
} | ||
if (amount === 1) { | ||
return 1; | ||
} | ||
return -Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI); | ||
}, | ||
Out: function (amount) { | ||
if (amount === 0) { | ||
return 0; | ||
} | ||
if (amount === 1) { | ||
return 1; | ||
} | ||
return Math.pow(2, -10 * amount) * Math.sin((amount - 0.1) * 5 * Math.PI) + 1; | ||
}, | ||
InOut: function (amount) { | ||
if (amount === 0) { | ||
return 0; | ||
} | ||
if (amount === 1) { | ||
return 1; | ||
} | ||
amount *= 2; | ||
if (amount < 1) { | ||
return -0.5 * Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI); | ||
} | ||
return 0.5 * Math.pow(2, -10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI) + 1; | ||
}, | ||
}, | ||
Back: { | ||
In: function (amount) { | ||
var s = 1.70158; | ||
return amount * amount * ((s + 1) * amount - s); | ||
}, | ||
Out: function (amount) { | ||
var s = 1.70158; | ||
return --amount * amount * ((s + 1) * amount + s) + 1; | ||
}, | ||
InOut: function (amount) { | ||
var s = 1.70158 * 1.525; | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * (amount * amount * ((s + 1) * amount - s)); | ||
} | ||
return 0.5 * ((amount -= 2) * amount * ((s + 1) * amount + s) + 2); | ||
}, | ||
}, | ||
Bounce: { | ||
In: function (amount) { | ||
return 1 - Easing.Bounce.Out(1 - amount); | ||
}, | ||
Out: function (amount) { | ||
if (amount < 1 / 2.75) { | ||
return 7.5625 * amount * amount; | ||
} | ||
else if (amount < 2 / 2.75) { | ||
return 7.5625 * (amount -= 1.5 / 2.75) * amount + 0.75; | ||
} | ||
else if (amount < 2.5 / 2.75) { | ||
return 7.5625 * (amount -= 2.25 / 2.75) * amount + 0.9375; | ||
} | ||
else { | ||
return 7.5625 * (amount -= 2.625 / 2.75) * amount + 0.984375; | ||
} | ||
}, | ||
InOut: function (amount) { | ||
if (amount < 0.5) { | ||
return Easing.Bounce.In(amount * 2) * 0.5; | ||
} | ||
return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5; | ||
}, | ||
}, | ||
}; | ||
var _Group = function () { | ||
this._tweens = {}; | ||
this._tweensAddedDuringUpdate = {}; | ||
}; | ||
/** | ||
* | ||
*/ | ||
var Interpolation = { | ||
Linear: function (v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = Interpolation.Utils.Linear; | ||
if (k < 0) { | ||
return fn(v[0], v[1], f); | ||
} | ||
if (k > 1) { | ||
return fn(v[m], v[m - 1], m - f); | ||
} | ||
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i); | ||
}, | ||
Bezier: function (v, k) { | ||
var b = 0; | ||
var n = v.length - 1; | ||
var pw = Math.pow; | ||
var bn = Interpolation.Utils.Bernstein; | ||
for (var i = 0; i <= n; i++) { | ||
b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i); | ||
} | ||
return b; | ||
}, | ||
CatmullRom: function (v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = Interpolation.Utils.CatmullRom; | ||
if (v[0] === v[m]) { | ||
if (k < 0) { | ||
i = Math.floor((f = m * (1 + k))); | ||
} | ||
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i); | ||
} | ||
else { | ||
if (k < 0) { | ||
return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]); | ||
} | ||
if (k > 1) { | ||
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]); | ||
} | ||
return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i); | ||
} | ||
}, | ||
Utils: { | ||
Linear: function (p0, p1, t) { | ||
return (p1 - p0) * t + p0; | ||
}, | ||
Bernstein: function (n, i) { | ||
var fc = Interpolation.Utils.Factorial; | ||
return fc(n) / fc(i) / fc(n - i); | ||
}, | ||
Factorial: (function () { | ||
var a = [1]; | ||
return function (n) { | ||
var s = 1; | ||
if (a[n]) { | ||
return a[n]; | ||
} | ||
for (var i = n; i > 1; i--) { | ||
s *= i; | ||
} | ||
a[n] = s; | ||
return s; | ||
}; | ||
})(), | ||
CatmullRom: function (p0, p1, p2, p3, t) { | ||
var v0 = (p2 - p0) * 0.5; | ||
var v1 = (p3 - p1) * 0.5; | ||
var t2 = t * t; | ||
var t3 = t * t2; | ||
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; | ||
}, | ||
}, | ||
}; | ||
_Group.prototype = { | ||
getAll: function () { | ||
/** | ||
* Utils | ||
*/ | ||
var Sequence = /** @class */ (function () { | ||
function Sequence() { | ||
} | ||
Sequence.nextId = function () { | ||
return Sequence._nextId++; | ||
}; | ||
Sequence._nextId = 0; | ||
return Sequence; | ||
}()); | ||
return Object.keys(this._tweens).map(function (tweenId) { | ||
return this._tweens[tweenId]; | ||
}.bind(this)); | ||
/** | ||
* Tween.js - Licensed under the MIT license | ||
* https://github.com/tweenjs/tween.js | ||
* ---------------------------------------------- | ||
* | ||
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. | ||
* Thank you all, you're awesome! | ||
*/ | ||
var Tween = /** @class */ (function () { | ||
function Tween(_object, _group) { | ||
if (_group === void 0) { _group = TWEEN; } | ||
this._object = _object; | ||
this._group = _group; | ||
this._isPaused = false; | ||
this._pauseStart = 0; | ||
this._valuesStart = {}; | ||
this._valuesEnd = {}; | ||
this._valuesStartRepeat = {}; | ||
this._duration = 1000; | ||
this._initialRepeat = 0; | ||
this._repeat = 0; | ||
this._yoyo = false; | ||
this._isPlaying = false; | ||
this._reversed = false; | ||
this._delayTime = 0; | ||
this._startTime = 0; | ||
this._easingFunction = TWEEN.Easing.Linear.None; | ||
this._interpolationFunction = TWEEN.Interpolation.Linear; | ||
this._chainedTweens = []; | ||
this._onStartCallbackFired = false; | ||
this._id = TWEEN.nextId(); | ||
this._isChainStopped = false; | ||
} | ||
Tween.prototype.getId = function () { | ||
return this._id; | ||
}; | ||
Tween.prototype.isPlaying = function () { | ||
return this._isPlaying; | ||
}; | ||
Tween.prototype.isPaused = function () { | ||
return this._isPaused; | ||
}; | ||
Tween.prototype.to = function (properties, duration) { | ||
for (var prop in properties) { | ||
this._valuesEnd[prop] = properties[prop]; | ||
} | ||
if (duration !== undefined) { | ||
this._duration = duration; | ||
} | ||
return this; | ||
}; | ||
Tween.prototype.duration = function (d) { | ||
this._duration = d; | ||
return this; | ||
}; | ||
Tween.prototype.start = function (time) { | ||
if (this._isPlaying) { | ||
return this; | ||
} | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._group.add(this); | ||
this._repeat = this._initialRepeat; | ||
if (this._reversed) { | ||
// If we were reversed (f.e. using the yoyo feature) then we need to | ||
// flip the tween direction back to forward. | ||
this._reversed = false; | ||
for (var property in this._valuesStartRepeat) { | ||
this._swapEndStartRepeatValues(property); | ||
this._valuesStart[property] = this._valuesStartRepeat[property]; | ||
} | ||
} | ||
this._isPlaying = true; | ||
this._isPaused = false; | ||
this._onStartCallbackFired = false; | ||
this._isChainStopped = false; | ||
this._startTime = | ||
time !== undefined ? (typeof time === 'string' ? TWEEN.now() + parseFloat(time) : time) : TWEEN.now(); | ||
this._startTime += this._delayTime; | ||
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat); | ||
return this; | ||
}; | ||
Tween.prototype._setupProperties = function (_object, _valuesStart, _valuesEnd, _valuesStartRepeat) { | ||
for (var property in _valuesEnd) { | ||
var startValue = _object[property]; | ||
var startValueIsArray = Array.isArray(startValue); | ||
var propType = startValueIsArray ? 'array' : typeof startValue; | ||
var isInterpolationList = !startValueIsArray && Array.isArray(_valuesEnd[property]); | ||
// If `to()` specifies a property that doesn't exist in the source object, | ||
// we should not set that property in the object | ||
if (propType === 'undefined' || propType === 'function') { | ||
continue; | ||
} | ||
// Check if an Array was provided as property value | ||
if (isInterpolationList) { | ||
var endValues = _valuesEnd[property]; | ||
if (endValues.length === 0) { | ||
continue; | ||
} | ||
// handle an array of relative values | ||
endValues = endValues.map(this._handleRelativeValue.bind(this, startValue)); | ||
// Create a local copy of the Array with the start value at the front | ||
_valuesEnd[property] = [startValue].concat(endValues); | ||
} | ||
// handle the deepness of the values | ||
if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) { | ||
_valuesStart[property] = startValueIsArray ? [] : {}; | ||
// eslint-disable-next-line | ||
for (var prop in startValue) { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
_valuesStart[property][prop] = startValue[prop]; | ||
} | ||
_valuesStartRepeat[property] = startValueIsArray ? [] : {}; // TODO? repeat nested values? And yoyo? And array values? | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._setupProperties(startValue, _valuesStart[property], _valuesEnd[property], _valuesStartRepeat[property]); | ||
} | ||
else { | ||
// Save the starting value, but only once. | ||
if (typeof _valuesStart[property] === 'undefined') { | ||
_valuesStart[property] = startValue; | ||
} | ||
if (!startValueIsArray) { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
_valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings | ||
} | ||
if (isInterpolationList) { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
_valuesStartRepeat[property] = _valuesEnd[property].slice().reverse(); | ||
} | ||
else { | ||
_valuesStartRepeat[property] = _valuesStart[property] || 0; | ||
} | ||
} | ||
} | ||
}; | ||
Tween.prototype.stop = function () { | ||
if (!this._isChainStopped) { | ||
this._isChainStopped = true; | ||
this.stopChainedTweens(); | ||
} | ||
if (!this._isPlaying) { | ||
return this; | ||
} | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._group.remove(this); | ||
this._isPlaying = false; | ||
this._isPaused = false; | ||
if (this._onStopCallback) { | ||
this._onStopCallback(this._object); | ||
} | ||
return this; | ||
}; | ||
Tween.prototype.end = function () { | ||
this.update(Infinity); | ||
return this; | ||
}; | ||
Tween.prototype.pause = function (time) { | ||
if (this._isPaused || !this._isPlaying) { | ||
return this; | ||
} | ||
this._isPaused = true; | ||
this._pauseStart = time === undefined ? TWEEN.now() : time; | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._group.remove(this); | ||
return this; | ||
}; | ||
Tween.prototype.resume = function (time) { | ||
if (!this._isPaused || !this._isPlaying) { | ||
return this; | ||
} | ||
this._isPaused = false; | ||
this._startTime += (time === undefined ? TWEEN.now() : time) - this._pauseStart; | ||
this._pauseStart = 0; | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._group.add(this); | ||
return this; | ||
}; | ||
Tween.prototype.stopChainedTweens = function () { | ||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { | ||
this._chainedTweens[i].stop(); | ||
} | ||
return this; | ||
}; | ||
Tween.prototype.group = function (group) { | ||
this._group = group; | ||
return this; | ||
}; | ||
Tween.prototype.delay = function (amount) { | ||
this._delayTime = amount; | ||
return this; | ||
}; | ||
Tween.prototype.repeat = function (times) { | ||
this._initialRepeat = times; | ||
this._repeat = times; | ||
return this; | ||
}; | ||
Tween.prototype.repeatDelay = function (amount) { | ||
this._repeatDelayTime = amount; | ||
return this; | ||
}; | ||
Tween.prototype.yoyo = function (yoyo) { | ||
this._yoyo = yoyo; | ||
return this; | ||
}; | ||
Tween.prototype.easing = function (easingFunction) { | ||
this._easingFunction = easingFunction; | ||
return this; | ||
}; | ||
Tween.prototype.interpolation = function (interpolationFunction) { | ||
this._interpolationFunction = interpolationFunction; | ||
return this; | ||
}; | ||
Tween.prototype.chain = function () { | ||
var tweens = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
tweens[_i] = arguments[_i]; | ||
} | ||
this._chainedTweens = tweens; | ||
return this; | ||
}; | ||
Tween.prototype.onStart = function (callback) { | ||
this._onStartCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.onUpdate = function (callback) { | ||
this._onUpdateCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.onRepeat = function (callback) { | ||
this._onRepeatCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.onComplete = function (callback) { | ||
this._onCompleteCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.onStop = function (callback) { | ||
this._onStopCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.update = function (time) { | ||
var property; | ||
var elapsed; | ||
var endTime = this._startTime + this._duration; | ||
if (time > endTime && !this._isPlaying) { | ||
return false; | ||
} | ||
// If the tween was already finished, | ||
if (!this.isPlaying) { | ||
this.start(time); | ||
} | ||
if (time < this._startTime) { | ||
return true; | ||
} | ||
if (this._onStartCallbackFired === false) { | ||
if (this._onStartCallback) { | ||
this._onStartCallback(this._object); | ||
} | ||
this._onStartCallbackFired = true; | ||
} | ||
elapsed = (time - this._startTime) / this._duration; | ||
elapsed = this._duration === 0 || elapsed > 1 ? 1 : elapsed; | ||
var value = this._easingFunction(elapsed); | ||
// properties transformations | ||
this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value); | ||
if (this._onUpdateCallback) { | ||
this._onUpdateCallback(this._object, elapsed); | ||
} | ||
if (elapsed === 1) { | ||
if (this._repeat > 0) { | ||
if (isFinite(this._repeat)) { | ||
this._repeat--; | ||
} | ||
// Reassign starting values, restart by making startTime = now | ||
for (property in this._valuesStartRepeat) { | ||
if (!this._yoyo && typeof this._valuesEnd[property] === 'string') { | ||
this._valuesStartRepeat[property] = | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]); | ||
} | ||
if (this._yoyo) { | ||
this._swapEndStartRepeatValues(property); | ||
} | ||
this._valuesStart[property] = this._valuesStartRepeat[property]; | ||
} | ||
if (this._yoyo) { | ||
this._reversed = !this._reversed; | ||
} | ||
if (this._repeatDelayTime !== undefined) { | ||
this._startTime = time + this._repeatDelayTime; | ||
} | ||
else { | ||
this._startTime = time + this._delayTime; | ||
} | ||
if (this._onRepeatCallback) { | ||
this._onRepeatCallback(this._object); | ||
} | ||
return true; | ||
} | ||
else { | ||
if (this._onCompleteCallback) { | ||
this._onCompleteCallback(this._object); | ||
} | ||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { | ||
// Make the chained tweens start exactly at the time they should, | ||
// even if the `update()` method was called way past the duration of the tween | ||
this._chainedTweens[i].start(this._startTime + this._duration); | ||
} | ||
this._isPlaying = false; | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
Tween.prototype._updateProperties = function (_object, _valuesStart, _valuesEnd, value) { | ||
for (var property in _valuesEnd) { | ||
// Don't update properties that do not exist in the source object | ||
if (_valuesStart[property] === undefined) { | ||
continue; | ||
} | ||
var start = _valuesStart[property] || 0; | ||
var end = _valuesEnd[property]; | ||
var startIsArray = Array.isArray(_object[property]); | ||
var endIsArray = Array.isArray(end); | ||
var isInterpolationList = !startIsArray && endIsArray; | ||
if (isInterpolationList) { | ||
_object[property] = this._interpolationFunction(end, value); | ||
} | ||
else if (typeof end === 'object' && end) { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._updateProperties(_object[property], start, end, value); | ||
} | ||
else { | ||
// Parses relative end values with start as base (e.g.: +10, -3) | ||
end = this._handleRelativeValue(start, end); | ||
// Protect against non numeric properties. | ||
if (typeof end === 'number') { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
_object[property] = start + (end - start) * value; | ||
} | ||
} | ||
} | ||
}; | ||
Tween.prototype._handleRelativeValue = function (start, end) { | ||
if (typeof end !== 'string') { | ||
return end; | ||
} | ||
if (end.charAt(0) === '+' || end.charAt(0) === '-') { | ||
return start + parseFloat(end); | ||
} | ||
else { | ||
return parseFloat(end); | ||
} | ||
}; | ||
Tween.prototype._swapEndStartRepeatValues = function (property) { | ||
var tmp = this._valuesStartRepeat[property]; | ||
if (typeof this._valuesEnd[property] === 'string') { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]); | ||
} | ||
else { | ||
this._valuesStartRepeat[property] = this._valuesEnd[property]; | ||
} | ||
this._valuesEnd[property] = tmp; | ||
}; | ||
return Tween; | ||
}()); | ||
}, | ||
var VERSION = '18.6.0'; | ||
removeAll: function () { | ||
/** | ||
* Tween.js - Licensed under the MIT license | ||
* https://github.com/tweenjs/tween.js | ||
* ---------------------------------------------- | ||
* | ||
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. | ||
* Thank you all, you're awesome! | ||
*/ | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
/** | ||
* Controlling groups of tweens | ||
* | ||
* Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components. | ||
* In these cases, you may want to create your own smaller groups of tween | ||
*/ | ||
var Main = /** @class */ (function (_super) { | ||
__extends(Main, _super); | ||
function Main() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.version = VERSION; | ||
_this.now = NOW$1; | ||
_this.Group = Group; | ||
_this.Easing = Easing; | ||
_this.Interpolation = Interpolation; | ||
_this.nextId = Sequence.nextId; | ||
_this.Tween = Tween; | ||
return _this; | ||
} | ||
return Main; | ||
}(Group)); | ||
var TWEEN = new Main(); | ||
this._tweens = {}; | ||
return TWEEN; | ||
}, | ||
add: function (tween) { | ||
this._tweens[tween.getId()] = tween; | ||
this._tweensAddedDuringUpdate[tween.getId()] = tween; | ||
}, | ||
remove: function (tween) { | ||
delete this._tweens[tween.getId()]; | ||
delete this._tweensAddedDuringUpdate[tween.getId()]; | ||
}, | ||
update: function (time, preserve) { | ||
var tweenIds = Object.keys(this._tweens); | ||
if (tweenIds.length === 0) { | ||
return false; | ||
} | ||
time = time !== undefined ? time : TWEEN.now(); | ||
// Tweens are updated in "batches". If you add a new tween during an | ||
// update, then the new tween will be updated in the next batch. | ||
// If you remove a tween during an update, it may or may not be updated. | ||
// However, if the removed tween was added during the current batch, | ||
// then it will not be updated. | ||
while (tweenIds.length > 0) { | ||
this._tweensAddedDuringUpdate = {}; | ||
for (var i = 0; i < tweenIds.length; i++) { | ||
var tween = this._tweens[tweenIds[i]]; | ||
if (tween && tween.update(time) === false) { | ||
tween._isPlaying = false; | ||
if (!preserve) { | ||
delete this._tweens[tweenIds[i]]; | ||
} | ||
} | ||
} | ||
tweenIds = Object.keys(this._tweensAddedDuringUpdate); | ||
} | ||
return true; | ||
} | ||
}; | ||
var TWEEN = new _Group(); | ||
TWEEN.Group = _Group; | ||
TWEEN._nextId = 0; | ||
TWEEN.nextId = function () { | ||
return TWEEN._nextId++; | ||
}; | ||
// Include a performance.now polyfill. | ||
// In node.js, use process.hrtime. | ||
if (typeof (self) === 'undefined' && typeof (process) !== 'undefined' && process.hrtime) { | ||
TWEEN.now = function () { | ||
var time = process.hrtime(); | ||
// Convert [seconds, nanoseconds] to milliseconds. | ||
return time[0] * 1000 + time[1] / 1000000; | ||
}; | ||
} | ||
// In a browser, use self.performance.now if it is available. | ||
else if (typeof (self) !== 'undefined' && | ||
self.performance !== undefined && | ||
self.performance.now !== undefined) { | ||
// This must be bound, because directly assigning this function | ||
// leads to an invocation exception in Chrome. | ||
TWEEN.now = self.performance.now.bind(self.performance); | ||
} | ||
// Use Date.now if it is available. | ||
else if (Date.now !== undefined) { | ||
TWEEN.now = Date.now; | ||
} | ||
// Otherwise, use 'new Date().getTime()'. | ||
else { | ||
TWEEN.now = function () { | ||
return new Date().getTime(); | ||
}; | ||
} | ||
TWEEN.Tween = function (object, group) { | ||
this._isPaused = false; | ||
this._pauseStart = null; | ||
this._object = object; | ||
this._valuesStart = {}; | ||
this._valuesEnd = {}; | ||
this._valuesStartRepeat = {}; | ||
this._duration = 1000; | ||
this._repeat = 0; | ||
this._repeatDelayTime = undefined; | ||
this._yoyo = false; | ||
this._isPlaying = false; | ||
this._reversed = false; | ||
this._delayTime = 0; | ||
this._startTime = null; | ||
this._easingFunction = TWEEN.Easing.Linear.None; | ||
this._interpolationFunction = TWEEN.Interpolation.Linear; | ||
this._chainedTweens = []; | ||
this._onStartCallback = null; | ||
this._onStartCallbackFired = false; | ||
this._onUpdateCallback = null; | ||
this._onRepeatCallback = null; | ||
this._onCompleteCallback = null; | ||
this._onStopCallback = null; | ||
this._group = group || TWEEN; | ||
this._id = TWEEN.nextId(); | ||
}; | ||
TWEEN.Tween.prototype = { | ||
getId: function () { | ||
return this._id; | ||
}, | ||
isPlaying: function () { | ||
return this._isPlaying; | ||
}, | ||
isPaused: function () { | ||
return this._isPaused; | ||
}, | ||
to: function (properties, duration) { | ||
this._valuesEnd = Object.create(properties); | ||
if (duration !== undefined) { | ||
this._duration = duration; | ||
} | ||
return this; | ||
}, | ||
duration: function duration(d) { | ||
this._duration = d; | ||
return this; | ||
}, | ||
start: function (time) { | ||
this._group.add(this); | ||
this._isPlaying = true; | ||
this._isPaused = false; | ||
this._onStartCallbackFired = false; | ||
this._startTime = time !== undefined ? typeof time === 'string' ? TWEEN.now() + parseFloat(time) : time : TWEEN.now(); | ||
this._startTime += this._delayTime; | ||
for (var property in this._valuesEnd) { | ||
// Check if an Array was provided as property value | ||
if (this._valuesEnd[property] instanceof Array) { | ||
if (this._valuesEnd[property].length === 0) { | ||
continue; | ||
} | ||
// Create a local copy of the Array with the start value at the front | ||
this._valuesEnd[property] = [this._object[property]].concat(this._valuesEnd[property]); | ||
} | ||
// If `to()` specifies a property that doesn't exist in the source object, | ||
// we should not set that property in the object | ||
if (this._object[property] === undefined) { | ||
continue; | ||
} | ||
// Save the starting value, but only once. | ||
if (typeof(this._valuesStart[property]) === 'undefined') { | ||
this._valuesStart[property] = this._object[property]; | ||
} | ||
if ((this._valuesStart[property] instanceof Array) === false) { | ||
this._valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings | ||
} | ||
this._valuesStartRepeat[property] = this._valuesStart[property] || 0; | ||
} | ||
return this; | ||
}, | ||
stop: function () { | ||
if (!this._isPlaying) { | ||
return this; | ||
} | ||
this._group.remove(this); | ||
this._isPlaying = false; | ||
this._isPaused = false; | ||
if (this._onStopCallback !== null) { | ||
this._onStopCallback(this._object); | ||
} | ||
this.stopChainedTweens(); | ||
return this; | ||
}, | ||
end: function () { | ||
this.update(Infinity); | ||
return this; | ||
}, | ||
pause: function(time) { | ||
if (this._isPaused || !this._isPlaying) { | ||
return this; | ||
} | ||
this._isPaused = true; | ||
this._pauseStart = time === undefined ? TWEEN.now() : time; | ||
this._group.remove(this); | ||
return this; | ||
}, | ||
resume: function(time) { | ||
if (!this._isPaused || !this._isPlaying) { | ||
return this; | ||
} | ||
this._isPaused = false; | ||
this._startTime += (time === undefined ? TWEEN.now() : time) | ||
- this._pauseStart; | ||
this._pauseStart = 0; | ||
this._group.add(this); | ||
return this; | ||
}, | ||
stopChainedTweens: function () { | ||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { | ||
this._chainedTweens[i].stop(); | ||
} | ||
}, | ||
group: function (group) { | ||
this._group = group; | ||
return this; | ||
}, | ||
delay: function (amount) { | ||
this._delayTime = amount; | ||
return this; | ||
}, | ||
repeat: function (times) { | ||
this._repeat = times; | ||
return this; | ||
}, | ||
repeatDelay: function (amount) { | ||
this._repeatDelayTime = amount; | ||
return this; | ||
}, | ||
yoyo: function (yoyo) { | ||
this._yoyo = yoyo; | ||
return this; | ||
}, | ||
easing: function (easingFunction) { | ||
this._easingFunction = easingFunction; | ||
return this; | ||
}, | ||
interpolation: function (interpolationFunction) { | ||
this._interpolationFunction = interpolationFunction; | ||
return this; | ||
}, | ||
chain: function () { | ||
this._chainedTweens = arguments; | ||
return this; | ||
}, | ||
onStart: function (callback) { | ||
this._onStartCallback = callback; | ||
return this; | ||
}, | ||
onUpdate: function (callback) { | ||
this._onUpdateCallback = callback; | ||
return this; | ||
}, | ||
onRepeat: function onRepeat(callback) { | ||
this._onRepeatCallback = callback; | ||
return this; | ||
}, | ||
onComplete: function (callback) { | ||
this._onCompleteCallback = callback; | ||
return this; | ||
}, | ||
onStop: function (callback) { | ||
this._onStopCallback = callback; | ||
return this; | ||
}, | ||
update: function (time) { | ||
var property; | ||
var elapsed; | ||
var value; | ||
if (time < this._startTime) { | ||
return true; | ||
} | ||
if (this._onStartCallbackFired === false) { | ||
if (this._onStartCallback !== null) { | ||
this._onStartCallback(this._object); | ||
} | ||
this._onStartCallbackFired = true; | ||
} | ||
elapsed = (time - this._startTime) / this._duration; | ||
elapsed = (this._duration === 0 || elapsed > 1) ? 1 : elapsed; | ||
value = this._easingFunction(elapsed); | ||
for (property in this._valuesEnd) { | ||
// Don't update properties that do not exist in the source object | ||
if (this._valuesStart[property] === undefined) { | ||
continue; | ||
} | ||
var start = this._valuesStart[property] || 0; | ||
var end = this._valuesEnd[property]; | ||
if (end instanceof Array) { | ||
this._object[property] = this._interpolationFunction(end, value); | ||
} else { | ||
// Parses relative end values with start as base (e.g.: +10, -3) | ||
if (typeof (end) === 'string') { | ||
if (end.charAt(0) === '+' || end.charAt(0) === '-') { | ||
end = start + parseFloat(end); | ||
} else { | ||
end = parseFloat(end); | ||
} | ||
} | ||
// Protect against non numeric properties. | ||
if (typeof (end) === 'number') { | ||
this._object[property] = start + (end - start) * value; | ||
} | ||
} | ||
} | ||
if (this._onUpdateCallback !== null) { | ||
this._onUpdateCallback(this._object, elapsed); | ||
} | ||
if (elapsed === 1) { | ||
if (this._repeat > 0) { | ||
if (isFinite(this._repeat)) { | ||
this._repeat--; | ||
} | ||
// Reassign starting values, restart by making startTime = now | ||
for (property in this._valuesStartRepeat) { | ||
if (typeof (this._valuesEnd[property]) === 'string') { | ||
this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]); | ||
} | ||
if (this._yoyo) { | ||
var tmp = this._valuesStartRepeat[property]; | ||
this._valuesStartRepeat[property] = this._valuesEnd[property]; | ||
this._valuesEnd[property] = tmp; | ||
} | ||
this._valuesStart[property] = this._valuesStartRepeat[property]; | ||
} | ||
if (this._yoyo) { | ||
this._reversed = !this._reversed; | ||
} | ||
if (this._repeatDelayTime !== undefined) { | ||
this._startTime = time + this._repeatDelayTime; | ||
} else { | ||
this._startTime = time + this._delayTime; | ||
} | ||
if (this._onRepeatCallback !== null) { | ||
this._onRepeatCallback(this._object); | ||
} | ||
return true; | ||
} else { | ||
if (this._onCompleteCallback !== null) { | ||
this._onCompleteCallback(this._object); | ||
} | ||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { | ||
// Make the chained tweens start exactly at the time they should, | ||
// even if the `update()` method was called way past the duration of the tween | ||
this._chainedTweens[i].start(this._startTime + this._duration); | ||
} | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
}; | ||
TWEEN.Easing = { | ||
Linear: { | ||
None: function (k) { | ||
return k; | ||
} | ||
}, | ||
Quadratic: { | ||
In: function (k) { | ||
return k * k; | ||
}, | ||
Out: function (k) { | ||
return k * (2 - k); | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k; | ||
} | ||
return - 0.5 * (--k * (k - 2) - 1); | ||
} | ||
}, | ||
Cubic: { | ||
In: function (k) { | ||
return k * k * k; | ||
}, | ||
Out: function (k) { | ||
return --k * k * k + 1; | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k; | ||
} | ||
return 0.5 * ((k -= 2) * k * k + 2); | ||
} | ||
}, | ||
Quartic: { | ||
In: function (k) { | ||
return k * k * k * k; | ||
}, | ||
Out: function (k) { | ||
return 1 - (--k * k * k * k); | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k; | ||
} | ||
return - 0.5 * ((k -= 2) * k * k * k - 2); | ||
} | ||
}, | ||
Quintic: { | ||
In: function (k) { | ||
return k * k * k * k * k; | ||
}, | ||
Out: function (k) { | ||
return --k * k * k * k * k + 1; | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k * k; | ||
} | ||
return 0.5 * ((k -= 2) * k * k * k * k + 2); | ||
} | ||
}, | ||
Sinusoidal: { | ||
In: function (k) { | ||
return 1 - Math.cos(k * Math.PI / 2); | ||
}, | ||
Out: function (k) { | ||
return Math.sin(k * Math.PI / 2); | ||
}, | ||
InOut: function (k) { | ||
return 0.5 * (1 - Math.cos(Math.PI * k)); | ||
} | ||
}, | ||
Exponential: { | ||
In: function (k) { | ||
return k === 0 ? 0 : Math.pow(1024, k - 1); | ||
}, | ||
Out: function (k) { | ||
return k === 1 ? 1 : 1 - Math.pow(2, - 10 * k); | ||
}, | ||
InOut: function (k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
if ((k *= 2) < 1) { | ||
return 0.5 * Math.pow(1024, k - 1); | ||
} | ||
return 0.5 * (- Math.pow(2, - 10 * (k - 1)) + 2); | ||
} | ||
}, | ||
Circular: { | ||
In: function (k) { | ||
return 1 - Math.sqrt(1 - k * k); | ||
}, | ||
Out: function (k) { | ||
return Math.sqrt(1 - (--k * k)); | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return - 0.5 * (Math.sqrt(1 - k * k) - 1); | ||
} | ||
return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1); | ||
} | ||
}, | ||
Elastic: { | ||
In: function (k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
return -Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI); | ||
}, | ||
Out: function (k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
return Math.pow(2, -10 * k) * Math.sin((k - 0.1) * 5 * Math.PI) + 1; | ||
}, | ||
InOut: function (k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
k *= 2; | ||
if (k < 1) { | ||
return -0.5 * Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI); | ||
} | ||
return 0.5 * Math.pow(2, -10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI) + 1; | ||
} | ||
}, | ||
Back: { | ||
In: function (k) { | ||
var s = 1.70158; | ||
return k * k * ((s + 1) * k - s); | ||
}, | ||
Out: function (k) { | ||
var s = 1.70158; | ||
return --k * k * ((s + 1) * k + s) + 1; | ||
}, | ||
InOut: function (k) { | ||
var s = 1.70158 * 1.525; | ||
if ((k *= 2) < 1) { | ||
return 0.5 * (k * k * ((s + 1) * k - s)); | ||
} | ||
return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); | ||
} | ||
}, | ||
Bounce: { | ||
In: function (k) { | ||
return 1 - TWEEN.Easing.Bounce.Out(1 - k); | ||
}, | ||
Out: function (k) { | ||
if (k < (1 / 2.75)) { | ||
return 7.5625 * k * k; | ||
} else if (k < (2 / 2.75)) { | ||
return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75; | ||
} else if (k < (2.5 / 2.75)) { | ||
return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375; | ||
} else { | ||
return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375; | ||
} | ||
}, | ||
InOut: function (k) { | ||
if (k < 0.5) { | ||
return TWEEN.Easing.Bounce.In(k * 2) * 0.5; | ||
} | ||
return TWEEN.Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5; | ||
} | ||
} | ||
}; | ||
TWEEN.Interpolation = { | ||
Linear: function (v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = TWEEN.Interpolation.Utils.Linear; | ||
if (k < 0) { | ||
return fn(v[0], v[1], f); | ||
} | ||
if (k > 1) { | ||
return fn(v[m], v[m - 1], m - f); | ||
} | ||
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i); | ||
}, | ||
Bezier: function (v, k) { | ||
var b = 0; | ||
var n = v.length - 1; | ||
var pw = Math.pow; | ||
var bn = TWEEN.Interpolation.Utils.Bernstein; | ||
for (var i = 0; i <= n; i++) { | ||
b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i); | ||
} | ||
return b; | ||
}, | ||
CatmullRom: function (v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = TWEEN.Interpolation.Utils.CatmullRom; | ||
if (v[0] === v[m]) { | ||
if (k < 0) { | ||
i = Math.floor(f = m * (1 + k)); | ||
} | ||
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i); | ||
} else { | ||
if (k < 0) { | ||
return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]); | ||
} | ||
if (k > 1) { | ||
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]); | ||
} | ||
return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i); | ||
} | ||
}, | ||
Utils: { | ||
Linear: function (p0, p1, t) { | ||
return (p1 - p0) * t + p0; | ||
}, | ||
Bernstein: function (n, i) { | ||
var fc = TWEEN.Interpolation.Utils.Factorial; | ||
return fc(n) / fc(i) / fc(n - i); | ||
}, | ||
Factorial: (function () { | ||
var a = [1]; | ||
return function (n) { | ||
var s = 1; | ||
if (a[n]) { | ||
return a[n]; | ||
} | ||
for (var i = n; i > 1; i--) { | ||
s *= i; | ||
} | ||
a[n] = s; | ||
return s; | ||
}; | ||
})(), | ||
CatmullRom: function (p0, p1, p2, p3, t) { | ||
var v0 = (p2 - p0) * 0.5; | ||
var v1 = (p3 - p1) * 0.5; | ||
var t2 = t * t; | ||
var t3 = t * t2; | ||
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (- 3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; | ||
} | ||
} | ||
}; | ||
TWEEN.version = version; | ||
return TWEEN; | ||
}); |
'use strict'; | ||
var version = '18.5.0'; | ||
/** | ||
* Tween.js - Licensed under the MIT license | ||
* https://github.com/tweenjs/tween.js | ||
* ---------------------------------------------- | ||
* | ||
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. | ||
* Thank you all, you're awesome! | ||
*/ | ||
var _Group = function () { | ||
this._tweens = {}; | ||
this._tweensAddedDuringUpdate = {}; | ||
}; | ||
_Group.prototype = { | ||
getAll: function () { | ||
return Object.keys(this._tweens).map(function (tweenId) { | ||
return this._tweens[tweenId]; | ||
}.bind(this)); | ||
}, | ||
removeAll: function () { | ||
this._tweens = {}; | ||
}, | ||
add: function (tween) { | ||
this._tweens[tween.getId()] = tween; | ||
this._tweensAddedDuringUpdate[tween.getId()] = tween; | ||
}, | ||
remove: function (tween) { | ||
delete this._tweens[tween.getId()]; | ||
delete this._tweensAddedDuringUpdate[tween.getId()]; | ||
}, | ||
update: function (time, preserve) { | ||
var tweenIds = Object.keys(this._tweens); | ||
if (tweenIds.length === 0) { | ||
return false; | ||
} | ||
time = time !== undefined ? time : TWEEN.now(); | ||
// Tweens are updated in "batches". If you add a new tween during an | ||
// update, then the new tween will be updated in the next batch. | ||
// If you remove a tween during an update, it may or may not be updated. | ||
// However, if the removed tween was added during the current batch, | ||
// then it will not be updated. | ||
while (tweenIds.length > 0) { | ||
this._tweensAddedDuringUpdate = {}; | ||
for (var i = 0; i < tweenIds.length; i++) { | ||
var tween = this._tweens[tweenIds[i]]; | ||
if (tween && tween.update(time) === false) { | ||
tween._isPlaying = false; | ||
if (!preserve) { | ||
delete this._tweens[tweenIds[i]]; | ||
} | ||
} | ||
} | ||
tweenIds = Object.keys(this._tweensAddedDuringUpdate); | ||
} | ||
return true; | ||
} | ||
}; | ||
var TWEEN = new _Group(); | ||
TWEEN.Group = _Group; | ||
TWEEN._nextId = 0; | ||
TWEEN.nextId = function () { | ||
return TWEEN._nextId++; | ||
}; | ||
var NOW; | ||
// Include a performance.now polyfill. | ||
// In node.js, use process.hrtime. | ||
if (typeof (self) === 'undefined' && typeof (process) !== 'undefined' && process.hrtime) { | ||
TWEEN.now = function () { | ||
var time = process.hrtime(); | ||
// Convert [seconds, nanoseconds] to milliseconds. | ||
return time[0] * 1000 + time[1] / 1000000; | ||
}; | ||
// eslint-disable-next-line | ||
// @ts-ignore | ||
if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) { | ||
NOW = function () { | ||
// eslint-disable-next-line | ||
// @ts-ignore | ||
var time = process.hrtime(); | ||
// Convert [seconds, nanoseconds] to milliseconds. | ||
return time[0] * 1000 + time[1] / 1000000; | ||
}; | ||
} | ||
// In a browser, use self.performance.now if it is available. | ||
else if (typeof (self) !== 'undefined' && | ||
self.performance !== undefined && | ||
self.performance.now !== undefined) { | ||
// This must be bound, because directly assigning this function | ||
// leads to an invocation exception in Chrome. | ||
TWEEN.now = self.performance.now.bind(self.performance); | ||
else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) { | ||
// This must be bound, because directly assigning this function | ||
// leads to an invocation exception in Chrome. | ||
NOW = self.performance.now.bind(self.performance); | ||
} | ||
// Use Date.now if it is available. | ||
else if (Date.now !== undefined) { | ||
TWEEN.now = Date.now; | ||
NOW = Date.now; | ||
} | ||
// Otherwise, use 'new Date().getTime()'. | ||
else { | ||
TWEEN.now = function () { | ||
return new Date().getTime(); | ||
}; | ||
NOW = function () { | ||
return new Date().getTime(); | ||
}; | ||
} | ||
var NOW$1 = NOW; | ||
/** | ||
* Controlling groups of tweens | ||
* | ||
* Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components. | ||
* In these cases, you may want to create your own smaller groups of tween | ||
*/ | ||
var Group = /** @class */ (function () { | ||
function Group() { | ||
this._tweens = {}; | ||
this._tweensAddedDuringUpdate = {}; | ||
} | ||
Group.prototype.getAll = function () { | ||
var _this = this; | ||
return Object.keys(this._tweens).map(function (tweenId) { | ||
return _this._tweens[tweenId]; | ||
}); | ||
}; | ||
Group.prototype.removeAll = function () { | ||
this._tweens = {}; | ||
}; | ||
Group.prototype.add = function (tween) { | ||
this._tweens[tween.getId()] = tween; | ||
this._tweensAddedDuringUpdate[tween.getId()] = tween; | ||
}; | ||
Group.prototype.remove = function (tween) { | ||
delete this._tweens[tween.getId()]; | ||
delete this._tweensAddedDuringUpdate[tween.getId()]; | ||
}; | ||
Group.prototype.update = function (time, preserve) { | ||
var tweenIds = Object.keys(this._tweens); | ||
if (tweenIds.length === 0) { | ||
return false; | ||
} | ||
time = time !== undefined ? time : NOW$1(); | ||
// Tweens are updated in "batches". If you add a new tween during an | ||
// update, then the new tween will be updated in the next batch. | ||
// If you remove a tween during an update, it may or may not be updated. | ||
// However, if the removed tween was added during the current batch, | ||
// then it will not be updated. | ||
while (tweenIds.length > 0) { | ||
this._tweensAddedDuringUpdate = {}; | ||
for (var i = 0; i < tweenIds.length; i++) { | ||
var tween = this._tweens[tweenIds[i]]; | ||
if (tween && tween.update(time) === false && !preserve) { | ||
delete this._tweens[tweenIds[i]]; | ||
} | ||
} | ||
tweenIds = Object.keys(this._tweensAddedDuringUpdate); | ||
} | ||
return true; | ||
}; | ||
return Group; | ||
}()); | ||
TWEEN.Tween = function (object, group) { | ||
this._isPaused = false; | ||
this._pauseStart = null; | ||
this._object = object; | ||
this._valuesStart = {}; | ||
this._valuesEnd = {}; | ||
this._valuesStartRepeat = {}; | ||
this._duration = 1000; | ||
this._repeat = 0; | ||
this._repeatDelayTime = undefined; | ||
this._yoyo = false; | ||
this._isPlaying = false; | ||
this._reversed = false; | ||
this._delayTime = 0; | ||
this._startTime = null; | ||
this._easingFunction = TWEEN.Easing.Linear.None; | ||
this._interpolationFunction = TWEEN.Interpolation.Linear; | ||
this._chainedTweens = []; | ||
this._onStartCallback = null; | ||
this._onStartCallbackFired = false; | ||
this._onUpdateCallback = null; | ||
this._onRepeatCallback = null; | ||
this._onCompleteCallback = null; | ||
this._onStopCallback = null; | ||
this._group = group || TWEEN; | ||
this._id = TWEEN.nextId(); | ||
/** | ||
* The Ease class provides a collection of easing functions for use with tween.js. | ||
*/ | ||
var Easing = { | ||
Linear: { | ||
None: function (amount) { | ||
return amount; | ||
}, | ||
}, | ||
Quadratic: { | ||
In: function (amount) { | ||
return amount * amount; | ||
}, | ||
Out: function (amount) { | ||
return amount * (2 - amount); | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * amount * amount; | ||
} | ||
return -0.5 * (--amount * (amount - 2) - 1); | ||
}, | ||
}, | ||
Cubic: { | ||
In: function (amount) { | ||
return amount * amount * amount; | ||
}, | ||
Out: function (amount) { | ||
return --amount * amount * amount + 1; | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * amount * amount * amount; | ||
} | ||
return 0.5 * ((amount -= 2) * amount * amount + 2); | ||
}, | ||
}, | ||
Quartic: { | ||
In: function (amount) { | ||
return amount * amount * amount * amount; | ||
}, | ||
Out: function (amount) { | ||
return 1 - --amount * amount * amount * amount; | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * amount * amount * amount * amount; | ||
} | ||
return -0.5 * ((amount -= 2) * amount * amount * amount - 2); | ||
}, | ||
}, | ||
Quintic: { | ||
In: function (amount) { | ||
return amount * amount * amount * amount * amount; | ||
}, | ||
Out: function (amount) { | ||
return --amount * amount * amount * amount * amount + 1; | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * amount * amount * amount * amount * amount; | ||
} | ||
return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2); | ||
}, | ||
}, | ||
Sinusoidal: { | ||
In: function (amount) { | ||
return 1 - Math.cos((amount * Math.PI) / 2); | ||
}, | ||
Out: function (amount) { | ||
return Math.sin((amount * Math.PI) / 2); | ||
}, | ||
InOut: function (amount) { | ||
return 0.5 * (1 - Math.cos(Math.PI * amount)); | ||
}, | ||
}, | ||
Exponential: { | ||
In: function (amount) { | ||
return amount === 0 ? 0 : Math.pow(1024, amount - 1); | ||
}, | ||
Out: function (amount) { | ||
return amount === 1 ? 1 : 1 - Math.pow(2, -10 * amount); | ||
}, | ||
InOut: function (amount) { | ||
if (amount === 0) { | ||
return 0; | ||
} | ||
if (amount === 1) { | ||
return 1; | ||
} | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * Math.pow(1024, amount - 1); | ||
} | ||
return 0.5 * (-Math.pow(2, -10 * (amount - 1)) + 2); | ||
}, | ||
}, | ||
Circular: { | ||
In: function (amount) { | ||
return 1 - Math.sqrt(1 - amount * amount); | ||
}, | ||
Out: function (amount) { | ||
return Math.sqrt(1 - --amount * amount); | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return -0.5 * (Math.sqrt(1 - amount * amount) - 1); | ||
} | ||
return 0.5 * (Math.sqrt(1 - (amount -= 2) * amount) + 1); | ||
}, | ||
}, | ||
Elastic: { | ||
In: function (amount) { | ||
if (amount === 0) { | ||
return 0; | ||
} | ||
if (amount === 1) { | ||
return 1; | ||
} | ||
return -Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI); | ||
}, | ||
Out: function (amount) { | ||
if (amount === 0) { | ||
return 0; | ||
} | ||
if (amount === 1) { | ||
return 1; | ||
} | ||
return Math.pow(2, -10 * amount) * Math.sin((amount - 0.1) * 5 * Math.PI) + 1; | ||
}, | ||
InOut: function (amount) { | ||
if (amount === 0) { | ||
return 0; | ||
} | ||
if (amount === 1) { | ||
return 1; | ||
} | ||
amount *= 2; | ||
if (amount < 1) { | ||
return -0.5 * Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI); | ||
} | ||
return 0.5 * Math.pow(2, -10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI) + 1; | ||
}, | ||
}, | ||
Back: { | ||
In: function (amount) { | ||
var s = 1.70158; | ||
return amount * amount * ((s + 1) * amount - s); | ||
}, | ||
Out: function (amount) { | ||
var s = 1.70158; | ||
return --amount * amount * ((s + 1) * amount + s) + 1; | ||
}, | ||
InOut: function (amount) { | ||
var s = 1.70158 * 1.525; | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * (amount * amount * ((s + 1) * amount - s)); | ||
} | ||
return 0.5 * ((amount -= 2) * amount * ((s + 1) * amount + s) + 2); | ||
}, | ||
}, | ||
Bounce: { | ||
In: function (amount) { | ||
return 1 - Easing.Bounce.Out(1 - amount); | ||
}, | ||
Out: function (amount) { | ||
if (amount < 1 / 2.75) { | ||
return 7.5625 * amount * amount; | ||
} | ||
else if (amount < 2 / 2.75) { | ||
return 7.5625 * (amount -= 1.5 / 2.75) * amount + 0.75; | ||
} | ||
else if (amount < 2.5 / 2.75) { | ||
return 7.5625 * (amount -= 2.25 / 2.75) * amount + 0.9375; | ||
} | ||
else { | ||
return 7.5625 * (amount -= 2.625 / 2.75) * amount + 0.984375; | ||
} | ||
}, | ||
InOut: function (amount) { | ||
if (amount < 0.5) { | ||
return Easing.Bounce.In(amount * 2) * 0.5; | ||
} | ||
return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5; | ||
}, | ||
}, | ||
}; | ||
TWEEN.Tween.prototype = { | ||
getId: function () { | ||
return this._id; | ||
}, | ||
isPlaying: function () { | ||
return this._isPlaying; | ||
}, | ||
isPaused: function () { | ||
return this._isPaused; | ||
}, | ||
to: function (properties, duration) { | ||
this._valuesEnd = Object.create(properties); | ||
if (duration !== undefined) { | ||
this._duration = duration; | ||
} | ||
return this; | ||
}, | ||
duration: function duration(d) { | ||
this._duration = d; | ||
return this; | ||
}, | ||
start: function (time) { | ||
this._group.add(this); | ||
this._isPlaying = true; | ||
this._isPaused = false; | ||
this._onStartCallbackFired = false; | ||
this._startTime = time !== undefined ? typeof time === 'string' ? TWEEN.now() + parseFloat(time) : time : TWEEN.now(); | ||
this._startTime += this._delayTime; | ||
for (var property in this._valuesEnd) { | ||
// Check if an Array was provided as property value | ||
if (this._valuesEnd[property] instanceof Array) { | ||
if (this._valuesEnd[property].length === 0) { | ||
continue; | ||
} | ||
// Create a local copy of the Array with the start value at the front | ||
this._valuesEnd[property] = [this._object[property]].concat(this._valuesEnd[property]); | ||
} | ||
// If `to()` specifies a property that doesn't exist in the source object, | ||
// we should not set that property in the object | ||
if (this._object[property] === undefined) { | ||
continue; | ||
} | ||
// Save the starting value, but only once. | ||
if (typeof(this._valuesStart[property]) === 'undefined') { | ||
this._valuesStart[property] = this._object[property]; | ||
} | ||
if ((this._valuesStart[property] instanceof Array) === false) { | ||
this._valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings | ||
} | ||
this._valuesStartRepeat[property] = this._valuesStart[property] || 0; | ||
} | ||
return this; | ||
}, | ||
stop: function () { | ||
if (!this._isPlaying) { | ||
return this; | ||
} | ||
this._group.remove(this); | ||
this._isPlaying = false; | ||
this._isPaused = false; | ||
if (this._onStopCallback !== null) { | ||
this._onStopCallback(this._object); | ||
} | ||
this.stopChainedTweens(); | ||
return this; | ||
}, | ||
end: function () { | ||
this.update(Infinity); | ||
return this; | ||
}, | ||
pause: function(time) { | ||
if (this._isPaused || !this._isPlaying) { | ||
return this; | ||
} | ||
this._isPaused = true; | ||
this._pauseStart = time === undefined ? TWEEN.now() : time; | ||
this._group.remove(this); | ||
return this; | ||
}, | ||
resume: function(time) { | ||
if (!this._isPaused || !this._isPlaying) { | ||
return this; | ||
} | ||
this._isPaused = false; | ||
this._startTime += (time === undefined ? TWEEN.now() : time) | ||
- this._pauseStart; | ||
this._pauseStart = 0; | ||
this._group.add(this); | ||
return this; | ||
}, | ||
stopChainedTweens: function () { | ||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { | ||
this._chainedTweens[i].stop(); | ||
} | ||
}, | ||
group: function (group) { | ||
this._group = group; | ||
return this; | ||
}, | ||
delay: function (amount) { | ||
this._delayTime = amount; | ||
return this; | ||
}, | ||
repeat: function (times) { | ||
this._repeat = times; | ||
return this; | ||
}, | ||
repeatDelay: function (amount) { | ||
this._repeatDelayTime = amount; | ||
return this; | ||
}, | ||
yoyo: function (yoyo) { | ||
this._yoyo = yoyo; | ||
return this; | ||
}, | ||
easing: function (easingFunction) { | ||
this._easingFunction = easingFunction; | ||
return this; | ||
}, | ||
interpolation: function (interpolationFunction) { | ||
this._interpolationFunction = interpolationFunction; | ||
return this; | ||
}, | ||
chain: function () { | ||
this._chainedTweens = arguments; | ||
return this; | ||
}, | ||
onStart: function (callback) { | ||
this._onStartCallback = callback; | ||
return this; | ||
}, | ||
onUpdate: function (callback) { | ||
this._onUpdateCallback = callback; | ||
return this; | ||
}, | ||
onRepeat: function onRepeat(callback) { | ||
this._onRepeatCallback = callback; | ||
return this; | ||
}, | ||
onComplete: function (callback) { | ||
this._onCompleteCallback = callback; | ||
return this; | ||
}, | ||
onStop: function (callback) { | ||
this._onStopCallback = callback; | ||
return this; | ||
}, | ||
update: function (time) { | ||
var property; | ||
var elapsed; | ||
var value; | ||
if (time < this._startTime) { | ||
return true; | ||
} | ||
if (this._onStartCallbackFired === false) { | ||
if (this._onStartCallback !== null) { | ||
this._onStartCallback(this._object); | ||
} | ||
this._onStartCallbackFired = true; | ||
} | ||
elapsed = (time - this._startTime) / this._duration; | ||
elapsed = (this._duration === 0 || elapsed > 1) ? 1 : elapsed; | ||
value = this._easingFunction(elapsed); | ||
for (property in this._valuesEnd) { | ||
// Don't update properties that do not exist in the source object | ||
if (this._valuesStart[property] === undefined) { | ||
continue; | ||
} | ||
var start = this._valuesStart[property] || 0; | ||
var end = this._valuesEnd[property]; | ||
if (end instanceof Array) { | ||
this._object[property] = this._interpolationFunction(end, value); | ||
} else { | ||
// Parses relative end values with start as base (e.g.: +10, -3) | ||
if (typeof (end) === 'string') { | ||
if (end.charAt(0) === '+' || end.charAt(0) === '-') { | ||
end = start + parseFloat(end); | ||
} else { | ||
end = parseFloat(end); | ||
} | ||
} | ||
// Protect against non numeric properties. | ||
if (typeof (end) === 'number') { | ||
this._object[property] = start + (end - start) * value; | ||
} | ||
} | ||
} | ||
if (this._onUpdateCallback !== null) { | ||
this._onUpdateCallback(this._object, elapsed); | ||
} | ||
if (elapsed === 1) { | ||
if (this._repeat > 0) { | ||
if (isFinite(this._repeat)) { | ||
this._repeat--; | ||
} | ||
// Reassign starting values, restart by making startTime = now | ||
for (property in this._valuesStartRepeat) { | ||
if (typeof (this._valuesEnd[property]) === 'string') { | ||
this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]); | ||
} | ||
if (this._yoyo) { | ||
var tmp = this._valuesStartRepeat[property]; | ||
this._valuesStartRepeat[property] = this._valuesEnd[property]; | ||
this._valuesEnd[property] = tmp; | ||
} | ||
this._valuesStart[property] = this._valuesStartRepeat[property]; | ||
} | ||
if (this._yoyo) { | ||
this._reversed = !this._reversed; | ||
} | ||
if (this._repeatDelayTime !== undefined) { | ||
this._startTime = time + this._repeatDelayTime; | ||
} else { | ||
this._startTime = time + this._delayTime; | ||
} | ||
if (this._onRepeatCallback !== null) { | ||
this._onRepeatCallback(this._object); | ||
} | ||
return true; | ||
} else { | ||
if (this._onCompleteCallback !== null) { | ||
this._onCompleteCallback(this._object); | ||
} | ||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { | ||
// Make the chained tweens start exactly at the time they should, | ||
// even if the `update()` method was called way past the duration of the tween | ||
this._chainedTweens[i].start(this._startTime + this._duration); | ||
} | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
/** | ||
* | ||
*/ | ||
var Interpolation = { | ||
Linear: function (v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = Interpolation.Utils.Linear; | ||
if (k < 0) { | ||
return fn(v[0], v[1], f); | ||
} | ||
if (k > 1) { | ||
return fn(v[m], v[m - 1], m - f); | ||
} | ||
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i); | ||
}, | ||
Bezier: function (v, k) { | ||
var b = 0; | ||
var n = v.length - 1; | ||
var pw = Math.pow; | ||
var bn = Interpolation.Utils.Bernstein; | ||
for (var i = 0; i <= n; i++) { | ||
b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i); | ||
} | ||
return b; | ||
}, | ||
CatmullRom: function (v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = Interpolation.Utils.CatmullRom; | ||
if (v[0] === v[m]) { | ||
if (k < 0) { | ||
i = Math.floor((f = m * (1 + k))); | ||
} | ||
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i); | ||
} | ||
else { | ||
if (k < 0) { | ||
return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]); | ||
} | ||
if (k > 1) { | ||
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]); | ||
} | ||
return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i); | ||
} | ||
}, | ||
Utils: { | ||
Linear: function (p0, p1, t) { | ||
return (p1 - p0) * t + p0; | ||
}, | ||
Bernstein: function (n, i) { | ||
var fc = Interpolation.Utils.Factorial; | ||
return fc(n) / fc(i) / fc(n - i); | ||
}, | ||
Factorial: (function () { | ||
var a = [1]; | ||
return function (n) { | ||
var s = 1; | ||
if (a[n]) { | ||
return a[n]; | ||
} | ||
for (var i = n; i > 1; i--) { | ||
s *= i; | ||
} | ||
a[n] = s; | ||
return s; | ||
}; | ||
})(), | ||
CatmullRom: function (p0, p1, p2, p3, t) { | ||
var v0 = (p2 - p0) * 0.5; | ||
var v1 = (p3 - p1) * 0.5; | ||
var t2 = t * t; | ||
var t3 = t * t2; | ||
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; | ||
}, | ||
}, | ||
}; | ||
/** | ||
* Utils | ||
*/ | ||
var Sequence = /** @class */ (function () { | ||
function Sequence() { | ||
} | ||
Sequence.nextId = function () { | ||
return Sequence._nextId++; | ||
}; | ||
Sequence._nextId = 0; | ||
return Sequence; | ||
}()); | ||
TWEEN.Easing = { | ||
/** | ||
* Tween.js - Licensed under the MIT license | ||
* https://github.com/tweenjs/tween.js | ||
* ---------------------------------------------- | ||
* | ||
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. | ||
* Thank you all, you're awesome! | ||
*/ | ||
var Tween = /** @class */ (function () { | ||
function Tween(_object, _group) { | ||
if (_group === void 0) { _group = TWEEN; } | ||
this._object = _object; | ||
this._group = _group; | ||
this._isPaused = false; | ||
this._pauseStart = 0; | ||
this._valuesStart = {}; | ||
this._valuesEnd = {}; | ||
this._valuesStartRepeat = {}; | ||
this._duration = 1000; | ||
this._initialRepeat = 0; | ||
this._repeat = 0; | ||
this._yoyo = false; | ||
this._isPlaying = false; | ||
this._reversed = false; | ||
this._delayTime = 0; | ||
this._startTime = 0; | ||
this._easingFunction = TWEEN.Easing.Linear.None; | ||
this._interpolationFunction = TWEEN.Interpolation.Linear; | ||
this._chainedTweens = []; | ||
this._onStartCallbackFired = false; | ||
this._id = TWEEN.nextId(); | ||
this._isChainStopped = false; | ||
} | ||
Tween.prototype.getId = function () { | ||
return this._id; | ||
}; | ||
Tween.prototype.isPlaying = function () { | ||
return this._isPlaying; | ||
}; | ||
Tween.prototype.isPaused = function () { | ||
return this._isPaused; | ||
}; | ||
Tween.prototype.to = function (properties, duration) { | ||
for (var prop in properties) { | ||
this._valuesEnd[prop] = properties[prop]; | ||
} | ||
if (duration !== undefined) { | ||
this._duration = duration; | ||
} | ||
return this; | ||
}; | ||
Tween.prototype.duration = function (d) { | ||
this._duration = d; | ||
return this; | ||
}; | ||
Tween.prototype.start = function (time) { | ||
if (this._isPlaying) { | ||
return this; | ||
} | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._group.add(this); | ||
this._repeat = this._initialRepeat; | ||
if (this._reversed) { | ||
// If we were reversed (f.e. using the yoyo feature) then we need to | ||
// flip the tween direction back to forward. | ||
this._reversed = false; | ||
for (var property in this._valuesStartRepeat) { | ||
this._swapEndStartRepeatValues(property); | ||
this._valuesStart[property] = this._valuesStartRepeat[property]; | ||
} | ||
} | ||
this._isPlaying = true; | ||
this._isPaused = false; | ||
this._onStartCallbackFired = false; | ||
this._isChainStopped = false; | ||
this._startTime = | ||
time !== undefined ? (typeof time === 'string' ? TWEEN.now() + parseFloat(time) : time) : TWEEN.now(); | ||
this._startTime += this._delayTime; | ||
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat); | ||
return this; | ||
}; | ||
Tween.prototype._setupProperties = function (_object, _valuesStart, _valuesEnd, _valuesStartRepeat) { | ||
for (var property in _valuesEnd) { | ||
var startValue = _object[property]; | ||
var startValueIsArray = Array.isArray(startValue); | ||
var propType = startValueIsArray ? 'array' : typeof startValue; | ||
var isInterpolationList = !startValueIsArray && Array.isArray(_valuesEnd[property]); | ||
// If `to()` specifies a property that doesn't exist in the source object, | ||
// we should not set that property in the object | ||
if (propType === 'undefined' || propType === 'function') { | ||
continue; | ||
} | ||
// Check if an Array was provided as property value | ||
if (isInterpolationList) { | ||
var endValues = _valuesEnd[property]; | ||
if (endValues.length === 0) { | ||
continue; | ||
} | ||
// handle an array of relative values | ||
endValues = endValues.map(this._handleRelativeValue.bind(this, startValue)); | ||
// Create a local copy of the Array with the start value at the front | ||
_valuesEnd[property] = [startValue].concat(endValues); | ||
} | ||
// handle the deepness of the values | ||
if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) { | ||
_valuesStart[property] = startValueIsArray ? [] : {}; | ||
// eslint-disable-next-line | ||
for (var prop in startValue) { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
_valuesStart[property][prop] = startValue[prop]; | ||
} | ||
_valuesStartRepeat[property] = startValueIsArray ? [] : {}; // TODO? repeat nested values? And yoyo? And array values? | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._setupProperties(startValue, _valuesStart[property], _valuesEnd[property], _valuesStartRepeat[property]); | ||
} | ||
else { | ||
// Save the starting value, but only once. | ||
if (typeof _valuesStart[property] === 'undefined') { | ||
_valuesStart[property] = startValue; | ||
} | ||
if (!startValueIsArray) { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
_valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings | ||
} | ||
if (isInterpolationList) { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
_valuesStartRepeat[property] = _valuesEnd[property].slice().reverse(); | ||
} | ||
else { | ||
_valuesStartRepeat[property] = _valuesStart[property] || 0; | ||
} | ||
} | ||
} | ||
}; | ||
Tween.prototype.stop = function () { | ||
if (!this._isChainStopped) { | ||
this._isChainStopped = true; | ||
this.stopChainedTweens(); | ||
} | ||
if (!this._isPlaying) { | ||
return this; | ||
} | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._group.remove(this); | ||
this._isPlaying = false; | ||
this._isPaused = false; | ||
if (this._onStopCallback) { | ||
this._onStopCallback(this._object); | ||
} | ||
return this; | ||
}; | ||
Tween.prototype.end = function () { | ||
this.update(Infinity); | ||
return this; | ||
}; | ||
Tween.prototype.pause = function (time) { | ||
if (this._isPaused || !this._isPlaying) { | ||
return this; | ||
} | ||
this._isPaused = true; | ||
this._pauseStart = time === undefined ? TWEEN.now() : time; | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._group.remove(this); | ||
return this; | ||
}; | ||
Tween.prototype.resume = function (time) { | ||
if (!this._isPaused || !this._isPlaying) { | ||
return this; | ||
} | ||
this._isPaused = false; | ||
this._startTime += (time === undefined ? TWEEN.now() : time) - this._pauseStart; | ||
this._pauseStart = 0; | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._group.add(this); | ||
return this; | ||
}; | ||
Tween.prototype.stopChainedTweens = function () { | ||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { | ||
this._chainedTweens[i].stop(); | ||
} | ||
return this; | ||
}; | ||
Tween.prototype.group = function (group) { | ||
this._group = group; | ||
return this; | ||
}; | ||
Tween.prototype.delay = function (amount) { | ||
this._delayTime = amount; | ||
return this; | ||
}; | ||
Tween.prototype.repeat = function (times) { | ||
this._initialRepeat = times; | ||
this._repeat = times; | ||
return this; | ||
}; | ||
Tween.prototype.repeatDelay = function (amount) { | ||
this._repeatDelayTime = amount; | ||
return this; | ||
}; | ||
Tween.prototype.yoyo = function (yoyo) { | ||
this._yoyo = yoyo; | ||
return this; | ||
}; | ||
Tween.prototype.easing = function (easingFunction) { | ||
this._easingFunction = easingFunction; | ||
return this; | ||
}; | ||
Tween.prototype.interpolation = function (interpolationFunction) { | ||
this._interpolationFunction = interpolationFunction; | ||
return this; | ||
}; | ||
Tween.prototype.chain = function () { | ||
var tweens = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
tweens[_i] = arguments[_i]; | ||
} | ||
this._chainedTweens = tweens; | ||
return this; | ||
}; | ||
Tween.prototype.onStart = function (callback) { | ||
this._onStartCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.onUpdate = function (callback) { | ||
this._onUpdateCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.onRepeat = function (callback) { | ||
this._onRepeatCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.onComplete = function (callback) { | ||
this._onCompleteCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.onStop = function (callback) { | ||
this._onStopCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.update = function (time) { | ||
var property; | ||
var elapsed; | ||
var endTime = this._startTime + this._duration; | ||
if (time > endTime && !this._isPlaying) { | ||
return false; | ||
} | ||
// If the tween was already finished, | ||
if (!this.isPlaying) { | ||
this.start(time); | ||
} | ||
if (time < this._startTime) { | ||
return true; | ||
} | ||
if (this._onStartCallbackFired === false) { | ||
if (this._onStartCallback) { | ||
this._onStartCallback(this._object); | ||
} | ||
this._onStartCallbackFired = true; | ||
} | ||
elapsed = (time - this._startTime) / this._duration; | ||
elapsed = this._duration === 0 || elapsed > 1 ? 1 : elapsed; | ||
var value = this._easingFunction(elapsed); | ||
// properties transformations | ||
this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value); | ||
if (this._onUpdateCallback) { | ||
this._onUpdateCallback(this._object, elapsed); | ||
} | ||
if (elapsed === 1) { | ||
if (this._repeat > 0) { | ||
if (isFinite(this._repeat)) { | ||
this._repeat--; | ||
} | ||
// Reassign starting values, restart by making startTime = now | ||
for (property in this._valuesStartRepeat) { | ||
if (!this._yoyo && typeof this._valuesEnd[property] === 'string') { | ||
this._valuesStartRepeat[property] = | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]); | ||
} | ||
if (this._yoyo) { | ||
this._swapEndStartRepeatValues(property); | ||
} | ||
this._valuesStart[property] = this._valuesStartRepeat[property]; | ||
} | ||
if (this._yoyo) { | ||
this._reversed = !this._reversed; | ||
} | ||
if (this._repeatDelayTime !== undefined) { | ||
this._startTime = time + this._repeatDelayTime; | ||
} | ||
else { | ||
this._startTime = time + this._delayTime; | ||
} | ||
if (this._onRepeatCallback) { | ||
this._onRepeatCallback(this._object); | ||
} | ||
return true; | ||
} | ||
else { | ||
if (this._onCompleteCallback) { | ||
this._onCompleteCallback(this._object); | ||
} | ||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { | ||
// Make the chained tweens start exactly at the time they should, | ||
// even if the `update()` method was called way past the duration of the tween | ||
this._chainedTweens[i].start(this._startTime + this._duration); | ||
} | ||
this._isPlaying = false; | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
Tween.prototype._updateProperties = function (_object, _valuesStart, _valuesEnd, value) { | ||
for (var property in _valuesEnd) { | ||
// Don't update properties that do not exist in the source object | ||
if (_valuesStart[property] === undefined) { | ||
continue; | ||
} | ||
var start = _valuesStart[property] || 0; | ||
var end = _valuesEnd[property]; | ||
var startIsArray = Array.isArray(_object[property]); | ||
var endIsArray = Array.isArray(end); | ||
var isInterpolationList = !startIsArray && endIsArray; | ||
if (isInterpolationList) { | ||
_object[property] = this._interpolationFunction(end, value); | ||
} | ||
else if (typeof end === 'object' && end) { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._updateProperties(_object[property], start, end, value); | ||
} | ||
else { | ||
// Parses relative end values with start as base (e.g.: +10, -3) | ||
end = this._handleRelativeValue(start, end); | ||
// Protect against non numeric properties. | ||
if (typeof end === 'number') { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
_object[property] = start + (end - start) * value; | ||
} | ||
} | ||
} | ||
}; | ||
Tween.prototype._handleRelativeValue = function (start, end) { | ||
if (typeof end !== 'string') { | ||
return end; | ||
} | ||
if (end.charAt(0) === '+' || end.charAt(0) === '-') { | ||
return start + parseFloat(end); | ||
} | ||
else { | ||
return parseFloat(end); | ||
} | ||
}; | ||
Tween.prototype._swapEndStartRepeatValues = function (property) { | ||
var tmp = this._valuesStartRepeat[property]; | ||
if (typeof this._valuesEnd[property] === 'string') { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]); | ||
} | ||
else { | ||
this._valuesStartRepeat[property] = this._valuesEnd[property]; | ||
} | ||
this._valuesEnd[property] = tmp; | ||
}; | ||
return Tween; | ||
}()); | ||
Linear: { | ||
var VERSION = '18.6.0'; | ||
None: function (k) { | ||
/** | ||
* Tween.js - Licensed under the MIT license | ||
* https://github.com/tweenjs/tween.js | ||
* ---------------------------------------------- | ||
* | ||
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. | ||
* Thank you all, you're awesome! | ||
*/ | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
/** | ||
* Controlling groups of tweens | ||
* | ||
* Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components. | ||
* In these cases, you may want to create your own smaller groups of tween | ||
*/ | ||
var Main = /** @class */ (function (_super) { | ||
__extends(Main, _super); | ||
function Main() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.version = VERSION; | ||
_this.now = NOW$1; | ||
_this.Group = Group; | ||
_this.Easing = Easing; | ||
_this.Interpolation = Interpolation; | ||
_this.nextId = Sequence.nextId; | ||
_this.Tween = Tween; | ||
return _this; | ||
} | ||
return Main; | ||
}(Group)); | ||
var TWEEN = new Main(); | ||
return k; | ||
} | ||
}, | ||
Quadratic: { | ||
In: function (k) { | ||
return k * k; | ||
}, | ||
Out: function (k) { | ||
return k * (2 - k); | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k; | ||
} | ||
return - 0.5 * (--k * (k - 2) - 1); | ||
} | ||
}, | ||
Cubic: { | ||
In: function (k) { | ||
return k * k * k; | ||
}, | ||
Out: function (k) { | ||
return --k * k * k + 1; | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k; | ||
} | ||
return 0.5 * ((k -= 2) * k * k + 2); | ||
} | ||
}, | ||
Quartic: { | ||
In: function (k) { | ||
return k * k * k * k; | ||
}, | ||
Out: function (k) { | ||
return 1 - (--k * k * k * k); | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k; | ||
} | ||
return - 0.5 * ((k -= 2) * k * k * k - 2); | ||
} | ||
}, | ||
Quintic: { | ||
In: function (k) { | ||
return k * k * k * k * k; | ||
}, | ||
Out: function (k) { | ||
return --k * k * k * k * k + 1; | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k * k; | ||
} | ||
return 0.5 * ((k -= 2) * k * k * k * k + 2); | ||
} | ||
}, | ||
Sinusoidal: { | ||
In: function (k) { | ||
return 1 - Math.cos(k * Math.PI / 2); | ||
}, | ||
Out: function (k) { | ||
return Math.sin(k * Math.PI / 2); | ||
}, | ||
InOut: function (k) { | ||
return 0.5 * (1 - Math.cos(Math.PI * k)); | ||
} | ||
}, | ||
Exponential: { | ||
In: function (k) { | ||
return k === 0 ? 0 : Math.pow(1024, k - 1); | ||
}, | ||
Out: function (k) { | ||
return k === 1 ? 1 : 1 - Math.pow(2, - 10 * k); | ||
}, | ||
InOut: function (k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
if ((k *= 2) < 1) { | ||
return 0.5 * Math.pow(1024, k - 1); | ||
} | ||
return 0.5 * (- Math.pow(2, - 10 * (k - 1)) + 2); | ||
} | ||
}, | ||
Circular: { | ||
In: function (k) { | ||
return 1 - Math.sqrt(1 - k * k); | ||
}, | ||
Out: function (k) { | ||
return Math.sqrt(1 - (--k * k)); | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return - 0.5 * (Math.sqrt(1 - k * k) - 1); | ||
} | ||
return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1); | ||
} | ||
}, | ||
Elastic: { | ||
In: function (k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
return -Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI); | ||
}, | ||
Out: function (k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
return Math.pow(2, -10 * k) * Math.sin((k - 0.1) * 5 * Math.PI) + 1; | ||
}, | ||
InOut: function (k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
k *= 2; | ||
if (k < 1) { | ||
return -0.5 * Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI); | ||
} | ||
return 0.5 * Math.pow(2, -10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI) + 1; | ||
} | ||
}, | ||
Back: { | ||
In: function (k) { | ||
var s = 1.70158; | ||
return k * k * ((s + 1) * k - s); | ||
}, | ||
Out: function (k) { | ||
var s = 1.70158; | ||
return --k * k * ((s + 1) * k + s) + 1; | ||
}, | ||
InOut: function (k) { | ||
var s = 1.70158 * 1.525; | ||
if ((k *= 2) < 1) { | ||
return 0.5 * (k * k * ((s + 1) * k - s)); | ||
} | ||
return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); | ||
} | ||
}, | ||
Bounce: { | ||
In: function (k) { | ||
return 1 - TWEEN.Easing.Bounce.Out(1 - k); | ||
}, | ||
Out: function (k) { | ||
if (k < (1 / 2.75)) { | ||
return 7.5625 * k * k; | ||
} else if (k < (2 / 2.75)) { | ||
return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75; | ||
} else if (k < (2.5 / 2.75)) { | ||
return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375; | ||
} else { | ||
return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375; | ||
} | ||
}, | ||
InOut: function (k) { | ||
if (k < 0.5) { | ||
return TWEEN.Easing.Bounce.In(k * 2) * 0.5; | ||
} | ||
return TWEEN.Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5; | ||
} | ||
} | ||
}; | ||
TWEEN.Interpolation = { | ||
Linear: function (v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = TWEEN.Interpolation.Utils.Linear; | ||
if (k < 0) { | ||
return fn(v[0], v[1], f); | ||
} | ||
if (k > 1) { | ||
return fn(v[m], v[m - 1], m - f); | ||
} | ||
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i); | ||
}, | ||
Bezier: function (v, k) { | ||
var b = 0; | ||
var n = v.length - 1; | ||
var pw = Math.pow; | ||
var bn = TWEEN.Interpolation.Utils.Bernstein; | ||
for (var i = 0; i <= n; i++) { | ||
b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i); | ||
} | ||
return b; | ||
}, | ||
CatmullRom: function (v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = TWEEN.Interpolation.Utils.CatmullRom; | ||
if (v[0] === v[m]) { | ||
if (k < 0) { | ||
i = Math.floor(f = m * (1 + k)); | ||
} | ||
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i); | ||
} else { | ||
if (k < 0) { | ||
return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]); | ||
} | ||
if (k > 1) { | ||
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]); | ||
} | ||
return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i); | ||
} | ||
}, | ||
Utils: { | ||
Linear: function (p0, p1, t) { | ||
return (p1 - p0) * t + p0; | ||
}, | ||
Bernstein: function (n, i) { | ||
var fc = TWEEN.Interpolation.Utils.Factorial; | ||
return fc(n) / fc(i) / fc(n - i); | ||
}, | ||
Factorial: (function () { | ||
var a = [1]; | ||
return function (n) { | ||
var s = 1; | ||
if (a[n]) { | ||
return a[n]; | ||
} | ||
for (var i = n; i > 1; i--) { | ||
s *= i; | ||
} | ||
a[n] = s; | ||
return s; | ||
}; | ||
})(), | ||
CatmullRom: function (p0, p1, p2, p3, t) { | ||
var v0 = (p2 - p0) * 0.5; | ||
var v1 = (p3 - p1) * 0.5; | ||
var t2 = t * t; | ||
var t3 = t * t2; | ||
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (- 3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; | ||
} | ||
} | ||
}; | ||
TWEEN.version = version; | ||
module.exports = TWEEN; |
@@ -1,964 +0,792 @@ | ||
var version = '18.5.0'; | ||
/** | ||
* Tween.js - Licensed under the MIT license | ||
* https://github.com/tweenjs/tween.js | ||
* ---------------------------------------------- | ||
* | ||
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. | ||
* Thank you all, you're awesome! | ||
*/ | ||
var _Group = function () { | ||
this._tweens = {}; | ||
this._tweensAddedDuringUpdate = {}; | ||
}; | ||
_Group.prototype = { | ||
getAll: function () { | ||
return Object.keys(this._tweens).map(function (tweenId) { | ||
return this._tweens[tweenId]; | ||
}.bind(this)); | ||
}, | ||
removeAll: function () { | ||
this._tweens = {}; | ||
}, | ||
add: function (tween) { | ||
this._tweens[tween.getId()] = tween; | ||
this._tweensAddedDuringUpdate[tween.getId()] = tween; | ||
}, | ||
remove: function (tween) { | ||
delete this._tweens[tween.getId()]; | ||
delete this._tweensAddedDuringUpdate[tween.getId()]; | ||
}, | ||
update: function (time, preserve) { | ||
var tweenIds = Object.keys(this._tweens); | ||
if (tweenIds.length === 0) { | ||
return false; | ||
} | ||
time = time !== undefined ? time : TWEEN.now(); | ||
// Tweens are updated in "batches". If you add a new tween during an | ||
// update, then the new tween will be updated in the next batch. | ||
// If you remove a tween during an update, it may or may not be updated. | ||
// However, if the removed tween was added during the current batch, | ||
// then it will not be updated. | ||
while (tweenIds.length > 0) { | ||
this._tweensAddedDuringUpdate = {}; | ||
for (var i = 0; i < tweenIds.length; i++) { | ||
var tween = this._tweens[tweenIds[i]]; | ||
if (tween && tween.update(time) === false) { | ||
tween._isPlaying = false; | ||
if (!preserve) { | ||
delete this._tweens[tweenIds[i]]; | ||
} | ||
} | ||
} | ||
tweenIds = Object.keys(this._tweensAddedDuringUpdate); | ||
} | ||
return true; | ||
} | ||
}; | ||
var TWEEN = new _Group(); | ||
TWEEN.Group = _Group; | ||
TWEEN._nextId = 0; | ||
TWEEN.nextId = function () { | ||
return TWEEN._nextId++; | ||
}; | ||
var NOW; | ||
// Include a performance.now polyfill. | ||
// In node.js, use process.hrtime. | ||
if (typeof (self) === 'undefined' && typeof (process) !== 'undefined' && process.hrtime) { | ||
TWEEN.now = function () { | ||
var time = process.hrtime(); | ||
// Convert [seconds, nanoseconds] to milliseconds. | ||
return time[0] * 1000 + time[1] / 1000000; | ||
}; | ||
// eslint-disable-next-line | ||
// @ts-ignore | ||
if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) { | ||
NOW = function () { | ||
// eslint-disable-next-line | ||
// @ts-ignore | ||
var time = process.hrtime(); | ||
// Convert [seconds, nanoseconds] to milliseconds. | ||
return time[0] * 1000 + time[1] / 1000000; | ||
}; | ||
} | ||
// In a browser, use self.performance.now if it is available. | ||
else if (typeof (self) !== 'undefined' && | ||
self.performance !== undefined && | ||
self.performance.now !== undefined) { | ||
// This must be bound, because directly assigning this function | ||
// leads to an invocation exception in Chrome. | ||
TWEEN.now = self.performance.now.bind(self.performance); | ||
else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) { | ||
// This must be bound, because directly assigning this function | ||
// leads to an invocation exception in Chrome. | ||
NOW = self.performance.now.bind(self.performance); | ||
} | ||
// Use Date.now if it is available. | ||
else if (Date.now !== undefined) { | ||
TWEEN.now = Date.now; | ||
NOW = Date.now; | ||
} | ||
// Otherwise, use 'new Date().getTime()'. | ||
else { | ||
TWEEN.now = function () { | ||
return new Date().getTime(); | ||
}; | ||
NOW = function () { | ||
return new Date().getTime(); | ||
}; | ||
} | ||
var NOW$1 = NOW; | ||
/** | ||
* Controlling groups of tweens | ||
* | ||
* Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components. | ||
* In these cases, you may want to create your own smaller groups of tween | ||
*/ | ||
var Group = /** @class */ (function () { | ||
function Group() { | ||
this._tweens = {}; | ||
this._tweensAddedDuringUpdate = {}; | ||
} | ||
Group.prototype.getAll = function () { | ||
var _this = this; | ||
return Object.keys(this._tweens).map(function (tweenId) { | ||
return _this._tweens[tweenId]; | ||
}); | ||
}; | ||
Group.prototype.removeAll = function () { | ||
this._tweens = {}; | ||
}; | ||
Group.prototype.add = function (tween) { | ||
this._tweens[tween.getId()] = tween; | ||
this._tweensAddedDuringUpdate[tween.getId()] = tween; | ||
}; | ||
Group.prototype.remove = function (tween) { | ||
delete this._tweens[tween.getId()]; | ||
delete this._tweensAddedDuringUpdate[tween.getId()]; | ||
}; | ||
Group.prototype.update = function (time, preserve) { | ||
var tweenIds = Object.keys(this._tweens); | ||
if (tweenIds.length === 0) { | ||
return false; | ||
} | ||
time = time !== undefined ? time : NOW$1(); | ||
// Tweens are updated in "batches". If you add a new tween during an | ||
// update, then the new tween will be updated in the next batch. | ||
// If you remove a tween during an update, it may or may not be updated. | ||
// However, if the removed tween was added during the current batch, | ||
// then it will not be updated. | ||
while (tweenIds.length > 0) { | ||
this._tweensAddedDuringUpdate = {}; | ||
for (var i = 0; i < tweenIds.length; i++) { | ||
var tween = this._tweens[tweenIds[i]]; | ||
if (tween && tween.update(time) === false && !preserve) { | ||
delete this._tweens[tweenIds[i]]; | ||
} | ||
} | ||
tweenIds = Object.keys(this._tweensAddedDuringUpdate); | ||
} | ||
return true; | ||
}; | ||
return Group; | ||
}()); | ||
TWEEN.Tween = function (object, group) { | ||
this._isPaused = false; | ||
this._pauseStart = null; | ||
this._object = object; | ||
this._valuesStart = {}; | ||
this._valuesEnd = {}; | ||
this._valuesStartRepeat = {}; | ||
this._duration = 1000; | ||
this._repeat = 0; | ||
this._repeatDelayTime = undefined; | ||
this._yoyo = false; | ||
this._isPlaying = false; | ||
this._reversed = false; | ||
this._delayTime = 0; | ||
this._startTime = null; | ||
this._easingFunction = TWEEN.Easing.Linear.None; | ||
this._interpolationFunction = TWEEN.Interpolation.Linear; | ||
this._chainedTweens = []; | ||
this._onStartCallback = null; | ||
this._onStartCallbackFired = false; | ||
this._onUpdateCallback = null; | ||
this._onRepeatCallback = null; | ||
this._onCompleteCallback = null; | ||
this._onStopCallback = null; | ||
this._group = group || TWEEN; | ||
this._id = TWEEN.nextId(); | ||
/** | ||
* The Ease class provides a collection of easing functions for use with tween.js. | ||
*/ | ||
var Easing = { | ||
Linear: { | ||
None: function (amount) { | ||
return amount; | ||
}, | ||
}, | ||
Quadratic: { | ||
In: function (amount) { | ||
return amount * amount; | ||
}, | ||
Out: function (amount) { | ||
return amount * (2 - amount); | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * amount * amount; | ||
} | ||
return -0.5 * (--amount * (amount - 2) - 1); | ||
}, | ||
}, | ||
Cubic: { | ||
In: function (amount) { | ||
return amount * amount * amount; | ||
}, | ||
Out: function (amount) { | ||
return --amount * amount * amount + 1; | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * amount * amount * amount; | ||
} | ||
return 0.5 * ((amount -= 2) * amount * amount + 2); | ||
}, | ||
}, | ||
Quartic: { | ||
In: function (amount) { | ||
return amount * amount * amount * amount; | ||
}, | ||
Out: function (amount) { | ||
return 1 - --amount * amount * amount * amount; | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * amount * amount * amount * amount; | ||
} | ||
return -0.5 * ((amount -= 2) * amount * amount * amount - 2); | ||
}, | ||
}, | ||
Quintic: { | ||
In: function (amount) { | ||
return amount * amount * amount * amount * amount; | ||
}, | ||
Out: function (amount) { | ||
return --amount * amount * amount * amount * amount + 1; | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * amount * amount * amount * amount * amount; | ||
} | ||
return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2); | ||
}, | ||
}, | ||
Sinusoidal: { | ||
In: function (amount) { | ||
return 1 - Math.cos((amount * Math.PI) / 2); | ||
}, | ||
Out: function (amount) { | ||
return Math.sin((amount * Math.PI) / 2); | ||
}, | ||
InOut: function (amount) { | ||
return 0.5 * (1 - Math.cos(Math.PI * amount)); | ||
}, | ||
}, | ||
Exponential: { | ||
In: function (amount) { | ||
return amount === 0 ? 0 : Math.pow(1024, amount - 1); | ||
}, | ||
Out: function (amount) { | ||
return amount === 1 ? 1 : 1 - Math.pow(2, -10 * amount); | ||
}, | ||
InOut: function (amount) { | ||
if (amount === 0) { | ||
return 0; | ||
} | ||
if (amount === 1) { | ||
return 1; | ||
} | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * Math.pow(1024, amount - 1); | ||
} | ||
return 0.5 * (-Math.pow(2, -10 * (amount - 1)) + 2); | ||
}, | ||
}, | ||
Circular: { | ||
In: function (amount) { | ||
return 1 - Math.sqrt(1 - amount * amount); | ||
}, | ||
Out: function (amount) { | ||
return Math.sqrt(1 - --amount * amount); | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return -0.5 * (Math.sqrt(1 - amount * amount) - 1); | ||
} | ||
return 0.5 * (Math.sqrt(1 - (amount -= 2) * amount) + 1); | ||
}, | ||
}, | ||
Elastic: { | ||
In: function (amount) { | ||
if (amount === 0) { | ||
return 0; | ||
} | ||
if (amount === 1) { | ||
return 1; | ||
} | ||
return -Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI); | ||
}, | ||
Out: function (amount) { | ||
if (amount === 0) { | ||
return 0; | ||
} | ||
if (amount === 1) { | ||
return 1; | ||
} | ||
return Math.pow(2, -10 * amount) * Math.sin((amount - 0.1) * 5 * Math.PI) + 1; | ||
}, | ||
InOut: function (amount) { | ||
if (amount === 0) { | ||
return 0; | ||
} | ||
if (amount === 1) { | ||
return 1; | ||
} | ||
amount *= 2; | ||
if (amount < 1) { | ||
return -0.5 * Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI); | ||
} | ||
return 0.5 * Math.pow(2, -10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI) + 1; | ||
}, | ||
}, | ||
Back: { | ||
In: function (amount) { | ||
var s = 1.70158; | ||
return amount * amount * ((s + 1) * amount - s); | ||
}, | ||
Out: function (amount) { | ||
var s = 1.70158; | ||
return --amount * amount * ((s + 1) * amount + s) + 1; | ||
}, | ||
InOut: function (amount) { | ||
var s = 1.70158 * 1.525; | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * (amount * amount * ((s + 1) * amount - s)); | ||
} | ||
return 0.5 * ((amount -= 2) * amount * ((s + 1) * amount + s) + 2); | ||
}, | ||
}, | ||
Bounce: { | ||
In: function (amount) { | ||
return 1 - Easing.Bounce.Out(1 - amount); | ||
}, | ||
Out: function (amount) { | ||
if (amount < 1 / 2.75) { | ||
return 7.5625 * amount * amount; | ||
} | ||
else if (amount < 2 / 2.75) { | ||
return 7.5625 * (amount -= 1.5 / 2.75) * amount + 0.75; | ||
} | ||
else if (amount < 2.5 / 2.75) { | ||
return 7.5625 * (amount -= 2.25 / 2.75) * amount + 0.9375; | ||
} | ||
else { | ||
return 7.5625 * (amount -= 2.625 / 2.75) * amount + 0.984375; | ||
} | ||
}, | ||
InOut: function (amount) { | ||
if (amount < 0.5) { | ||
return Easing.Bounce.In(amount * 2) * 0.5; | ||
} | ||
return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5; | ||
}, | ||
}, | ||
}; | ||
TWEEN.Tween.prototype = { | ||
getId: function () { | ||
return this._id; | ||
}, | ||
isPlaying: function () { | ||
return this._isPlaying; | ||
}, | ||
isPaused: function () { | ||
return this._isPaused; | ||
}, | ||
to: function (properties, duration) { | ||
this._valuesEnd = Object.create(properties); | ||
if (duration !== undefined) { | ||
this._duration = duration; | ||
} | ||
return this; | ||
}, | ||
duration: function duration(d) { | ||
this._duration = d; | ||
return this; | ||
}, | ||
start: function (time) { | ||
this._group.add(this); | ||
this._isPlaying = true; | ||
this._isPaused = false; | ||
this._onStartCallbackFired = false; | ||
this._startTime = time !== undefined ? typeof time === 'string' ? TWEEN.now() + parseFloat(time) : time : TWEEN.now(); | ||
this._startTime += this._delayTime; | ||
for (var property in this._valuesEnd) { | ||
// Check if an Array was provided as property value | ||
if (this._valuesEnd[property] instanceof Array) { | ||
if (this._valuesEnd[property].length === 0) { | ||
continue; | ||
} | ||
// Create a local copy of the Array with the start value at the front | ||
this._valuesEnd[property] = [this._object[property]].concat(this._valuesEnd[property]); | ||
} | ||
// If `to()` specifies a property that doesn't exist in the source object, | ||
// we should not set that property in the object | ||
if (this._object[property] === undefined) { | ||
continue; | ||
} | ||
// Save the starting value, but only once. | ||
if (typeof(this._valuesStart[property]) === 'undefined') { | ||
this._valuesStart[property] = this._object[property]; | ||
} | ||
if ((this._valuesStart[property] instanceof Array) === false) { | ||
this._valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings | ||
} | ||
this._valuesStartRepeat[property] = this._valuesStart[property] || 0; | ||
} | ||
return this; | ||
}, | ||
stop: function () { | ||
if (!this._isPlaying) { | ||
return this; | ||
} | ||
this._group.remove(this); | ||
this._isPlaying = false; | ||
this._isPaused = false; | ||
if (this._onStopCallback !== null) { | ||
this._onStopCallback(this._object); | ||
} | ||
this.stopChainedTweens(); | ||
return this; | ||
}, | ||
end: function () { | ||
this.update(Infinity); | ||
return this; | ||
}, | ||
pause: function(time) { | ||
if (this._isPaused || !this._isPlaying) { | ||
return this; | ||
} | ||
this._isPaused = true; | ||
this._pauseStart = time === undefined ? TWEEN.now() : time; | ||
this._group.remove(this); | ||
return this; | ||
}, | ||
resume: function(time) { | ||
if (!this._isPaused || !this._isPlaying) { | ||
return this; | ||
} | ||
this._isPaused = false; | ||
this._startTime += (time === undefined ? TWEEN.now() : time) | ||
- this._pauseStart; | ||
this._pauseStart = 0; | ||
this._group.add(this); | ||
return this; | ||
}, | ||
stopChainedTweens: function () { | ||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { | ||
this._chainedTweens[i].stop(); | ||
} | ||
}, | ||
group: function (group) { | ||
this._group = group; | ||
return this; | ||
}, | ||
delay: function (amount) { | ||
this._delayTime = amount; | ||
return this; | ||
}, | ||
repeat: function (times) { | ||
this._repeat = times; | ||
return this; | ||
}, | ||
repeatDelay: function (amount) { | ||
this._repeatDelayTime = amount; | ||
return this; | ||
}, | ||
yoyo: function (yoyo) { | ||
this._yoyo = yoyo; | ||
return this; | ||
}, | ||
easing: function (easingFunction) { | ||
this._easingFunction = easingFunction; | ||
return this; | ||
}, | ||
interpolation: function (interpolationFunction) { | ||
this._interpolationFunction = interpolationFunction; | ||
return this; | ||
}, | ||
chain: function () { | ||
this._chainedTweens = arguments; | ||
return this; | ||
}, | ||
onStart: function (callback) { | ||
this._onStartCallback = callback; | ||
return this; | ||
}, | ||
onUpdate: function (callback) { | ||
this._onUpdateCallback = callback; | ||
return this; | ||
}, | ||
onRepeat: function onRepeat(callback) { | ||
this._onRepeatCallback = callback; | ||
return this; | ||
}, | ||
onComplete: function (callback) { | ||
this._onCompleteCallback = callback; | ||
return this; | ||
}, | ||
onStop: function (callback) { | ||
this._onStopCallback = callback; | ||
return this; | ||
}, | ||
update: function (time) { | ||
var property; | ||
var elapsed; | ||
var value; | ||
if (time < this._startTime) { | ||
return true; | ||
} | ||
if (this._onStartCallbackFired === false) { | ||
if (this._onStartCallback !== null) { | ||
this._onStartCallback(this._object); | ||
} | ||
this._onStartCallbackFired = true; | ||
} | ||
elapsed = (time - this._startTime) / this._duration; | ||
elapsed = (this._duration === 0 || elapsed > 1) ? 1 : elapsed; | ||
value = this._easingFunction(elapsed); | ||
for (property in this._valuesEnd) { | ||
// Don't update properties that do not exist in the source object | ||
if (this._valuesStart[property] === undefined) { | ||
continue; | ||
} | ||
var start = this._valuesStart[property] || 0; | ||
var end = this._valuesEnd[property]; | ||
if (end instanceof Array) { | ||
this._object[property] = this._interpolationFunction(end, value); | ||
} else { | ||
// Parses relative end values with start as base (e.g.: +10, -3) | ||
if (typeof (end) === 'string') { | ||
if (end.charAt(0) === '+' || end.charAt(0) === '-') { | ||
end = start + parseFloat(end); | ||
} else { | ||
end = parseFloat(end); | ||
} | ||
} | ||
// Protect against non numeric properties. | ||
if (typeof (end) === 'number') { | ||
this._object[property] = start + (end - start) * value; | ||
} | ||
} | ||
} | ||
if (this._onUpdateCallback !== null) { | ||
this._onUpdateCallback(this._object, elapsed); | ||
} | ||
if (elapsed === 1) { | ||
if (this._repeat > 0) { | ||
if (isFinite(this._repeat)) { | ||
this._repeat--; | ||
} | ||
// Reassign starting values, restart by making startTime = now | ||
for (property in this._valuesStartRepeat) { | ||
if (typeof (this._valuesEnd[property]) === 'string') { | ||
this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]); | ||
} | ||
if (this._yoyo) { | ||
var tmp = this._valuesStartRepeat[property]; | ||
this._valuesStartRepeat[property] = this._valuesEnd[property]; | ||
this._valuesEnd[property] = tmp; | ||
} | ||
this._valuesStart[property] = this._valuesStartRepeat[property]; | ||
} | ||
if (this._yoyo) { | ||
this._reversed = !this._reversed; | ||
} | ||
if (this._repeatDelayTime !== undefined) { | ||
this._startTime = time + this._repeatDelayTime; | ||
} else { | ||
this._startTime = time + this._delayTime; | ||
} | ||
if (this._onRepeatCallback !== null) { | ||
this._onRepeatCallback(this._object); | ||
} | ||
return true; | ||
} else { | ||
if (this._onCompleteCallback !== null) { | ||
this._onCompleteCallback(this._object); | ||
} | ||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { | ||
// Make the chained tweens start exactly at the time they should, | ||
// even if the `update()` method was called way past the duration of the tween | ||
this._chainedTweens[i].start(this._startTime + this._duration); | ||
} | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
/** | ||
* | ||
*/ | ||
var Interpolation = { | ||
Linear: function (v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = Interpolation.Utils.Linear; | ||
if (k < 0) { | ||
return fn(v[0], v[1], f); | ||
} | ||
if (k > 1) { | ||
return fn(v[m], v[m - 1], m - f); | ||
} | ||
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i); | ||
}, | ||
Bezier: function (v, k) { | ||
var b = 0; | ||
var n = v.length - 1; | ||
var pw = Math.pow; | ||
var bn = Interpolation.Utils.Bernstein; | ||
for (var i = 0; i <= n; i++) { | ||
b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i); | ||
} | ||
return b; | ||
}, | ||
CatmullRom: function (v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = Interpolation.Utils.CatmullRom; | ||
if (v[0] === v[m]) { | ||
if (k < 0) { | ||
i = Math.floor((f = m * (1 + k))); | ||
} | ||
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i); | ||
} | ||
else { | ||
if (k < 0) { | ||
return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]); | ||
} | ||
if (k > 1) { | ||
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]); | ||
} | ||
return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i); | ||
} | ||
}, | ||
Utils: { | ||
Linear: function (p0, p1, t) { | ||
return (p1 - p0) * t + p0; | ||
}, | ||
Bernstein: function (n, i) { | ||
var fc = Interpolation.Utils.Factorial; | ||
return fc(n) / fc(i) / fc(n - i); | ||
}, | ||
Factorial: (function () { | ||
var a = [1]; | ||
return function (n) { | ||
var s = 1; | ||
if (a[n]) { | ||
return a[n]; | ||
} | ||
for (var i = n; i > 1; i--) { | ||
s *= i; | ||
} | ||
a[n] = s; | ||
return s; | ||
}; | ||
})(), | ||
CatmullRom: function (p0, p1, p2, p3, t) { | ||
var v0 = (p2 - p0) * 0.5; | ||
var v1 = (p3 - p1) * 0.5; | ||
var t2 = t * t; | ||
var t3 = t * t2; | ||
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; | ||
}, | ||
}, | ||
}; | ||
/** | ||
* Utils | ||
*/ | ||
var Sequence = /** @class */ (function () { | ||
function Sequence() { | ||
} | ||
Sequence.nextId = function () { | ||
return Sequence._nextId++; | ||
}; | ||
Sequence._nextId = 0; | ||
return Sequence; | ||
}()); | ||
TWEEN.Easing = { | ||
/** | ||
* Tween.js - Licensed under the MIT license | ||
* https://github.com/tweenjs/tween.js | ||
* ---------------------------------------------- | ||
* | ||
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. | ||
* Thank you all, you're awesome! | ||
*/ | ||
var Tween = /** @class */ (function () { | ||
function Tween(_object, _group) { | ||
if (_group === void 0) { _group = TWEEN; } | ||
this._object = _object; | ||
this._group = _group; | ||
this._isPaused = false; | ||
this._pauseStart = 0; | ||
this._valuesStart = {}; | ||
this._valuesEnd = {}; | ||
this._valuesStartRepeat = {}; | ||
this._duration = 1000; | ||
this._initialRepeat = 0; | ||
this._repeat = 0; | ||
this._yoyo = false; | ||
this._isPlaying = false; | ||
this._reversed = false; | ||
this._delayTime = 0; | ||
this._startTime = 0; | ||
this._easingFunction = TWEEN.Easing.Linear.None; | ||
this._interpolationFunction = TWEEN.Interpolation.Linear; | ||
this._chainedTweens = []; | ||
this._onStartCallbackFired = false; | ||
this._id = TWEEN.nextId(); | ||
this._isChainStopped = false; | ||
} | ||
Tween.prototype.getId = function () { | ||
return this._id; | ||
}; | ||
Tween.prototype.isPlaying = function () { | ||
return this._isPlaying; | ||
}; | ||
Tween.prototype.isPaused = function () { | ||
return this._isPaused; | ||
}; | ||
Tween.prototype.to = function (properties, duration) { | ||
for (var prop in properties) { | ||
this._valuesEnd[prop] = properties[prop]; | ||
} | ||
if (duration !== undefined) { | ||
this._duration = duration; | ||
} | ||
return this; | ||
}; | ||
Tween.prototype.duration = function (d) { | ||
this._duration = d; | ||
return this; | ||
}; | ||
Tween.prototype.start = function (time) { | ||
if (this._isPlaying) { | ||
return this; | ||
} | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._group.add(this); | ||
this._repeat = this._initialRepeat; | ||
if (this._reversed) { | ||
// If we were reversed (f.e. using the yoyo feature) then we need to | ||
// flip the tween direction back to forward. | ||
this._reversed = false; | ||
for (var property in this._valuesStartRepeat) { | ||
this._swapEndStartRepeatValues(property); | ||
this._valuesStart[property] = this._valuesStartRepeat[property]; | ||
} | ||
} | ||
this._isPlaying = true; | ||
this._isPaused = false; | ||
this._onStartCallbackFired = false; | ||
this._isChainStopped = false; | ||
this._startTime = | ||
time !== undefined ? (typeof time === 'string' ? TWEEN.now() + parseFloat(time) : time) : TWEEN.now(); | ||
this._startTime += this._delayTime; | ||
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat); | ||
return this; | ||
}; | ||
Tween.prototype._setupProperties = function (_object, _valuesStart, _valuesEnd, _valuesStartRepeat) { | ||
for (var property in _valuesEnd) { | ||
var startValue = _object[property]; | ||
var startValueIsArray = Array.isArray(startValue); | ||
var propType = startValueIsArray ? 'array' : typeof startValue; | ||
var isInterpolationList = !startValueIsArray && Array.isArray(_valuesEnd[property]); | ||
// If `to()` specifies a property that doesn't exist in the source object, | ||
// we should not set that property in the object | ||
if (propType === 'undefined' || propType === 'function') { | ||
continue; | ||
} | ||
// Check if an Array was provided as property value | ||
if (isInterpolationList) { | ||
var endValues = _valuesEnd[property]; | ||
if (endValues.length === 0) { | ||
continue; | ||
} | ||
// handle an array of relative values | ||
endValues = endValues.map(this._handleRelativeValue.bind(this, startValue)); | ||
// Create a local copy of the Array with the start value at the front | ||
_valuesEnd[property] = [startValue].concat(endValues); | ||
} | ||
// handle the deepness of the values | ||
if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) { | ||
_valuesStart[property] = startValueIsArray ? [] : {}; | ||
// eslint-disable-next-line | ||
for (var prop in startValue) { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
_valuesStart[property][prop] = startValue[prop]; | ||
} | ||
_valuesStartRepeat[property] = startValueIsArray ? [] : {}; // TODO? repeat nested values? And yoyo? And array values? | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._setupProperties(startValue, _valuesStart[property], _valuesEnd[property], _valuesStartRepeat[property]); | ||
} | ||
else { | ||
// Save the starting value, but only once. | ||
if (typeof _valuesStart[property] === 'undefined') { | ||
_valuesStart[property] = startValue; | ||
} | ||
if (!startValueIsArray) { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
_valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings | ||
} | ||
if (isInterpolationList) { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
_valuesStartRepeat[property] = _valuesEnd[property].slice().reverse(); | ||
} | ||
else { | ||
_valuesStartRepeat[property] = _valuesStart[property] || 0; | ||
} | ||
} | ||
} | ||
}; | ||
Tween.prototype.stop = function () { | ||
if (!this._isChainStopped) { | ||
this._isChainStopped = true; | ||
this.stopChainedTweens(); | ||
} | ||
if (!this._isPlaying) { | ||
return this; | ||
} | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._group.remove(this); | ||
this._isPlaying = false; | ||
this._isPaused = false; | ||
if (this._onStopCallback) { | ||
this._onStopCallback(this._object); | ||
} | ||
return this; | ||
}; | ||
Tween.prototype.end = function () { | ||
this.update(Infinity); | ||
return this; | ||
}; | ||
Tween.prototype.pause = function (time) { | ||
if (this._isPaused || !this._isPlaying) { | ||
return this; | ||
} | ||
this._isPaused = true; | ||
this._pauseStart = time === undefined ? TWEEN.now() : time; | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._group.remove(this); | ||
return this; | ||
}; | ||
Tween.prototype.resume = function (time) { | ||
if (!this._isPaused || !this._isPlaying) { | ||
return this; | ||
} | ||
this._isPaused = false; | ||
this._startTime += (time === undefined ? TWEEN.now() : time) - this._pauseStart; | ||
this._pauseStart = 0; | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._group.add(this); | ||
return this; | ||
}; | ||
Tween.prototype.stopChainedTweens = function () { | ||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { | ||
this._chainedTweens[i].stop(); | ||
} | ||
return this; | ||
}; | ||
Tween.prototype.group = function (group) { | ||
this._group = group; | ||
return this; | ||
}; | ||
Tween.prototype.delay = function (amount) { | ||
this._delayTime = amount; | ||
return this; | ||
}; | ||
Tween.prototype.repeat = function (times) { | ||
this._initialRepeat = times; | ||
this._repeat = times; | ||
return this; | ||
}; | ||
Tween.prototype.repeatDelay = function (amount) { | ||
this._repeatDelayTime = amount; | ||
return this; | ||
}; | ||
Tween.prototype.yoyo = function (yoyo) { | ||
this._yoyo = yoyo; | ||
return this; | ||
}; | ||
Tween.prototype.easing = function (easingFunction) { | ||
this._easingFunction = easingFunction; | ||
return this; | ||
}; | ||
Tween.prototype.interpolation = function (interpolationFunction) { | ||
this._interpolationFunction = interpolationFunction; | ||
return this; | ||
}; | ||
Tween.prototype.chain = function () { | ||
var tweens = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
tweens[_i] = arguments[_i]; | ||
} | ||
this._chainedTweens = tweens; | ||
return this; | ||
}; | ||
Tween.prototype.onStart = function (callback) { | ||
this._onStartCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.onUpdate = function (callback) { | ||
this._onUpdateCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.onRepeat = function (callback) { | ||
this._onRepeatCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.onComplete = function (callback) { | ||
this._onCompleteCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.onStop = function (callback) { | ||
this._onStopCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.update = function (time) { | ||
var property; | ||
var elapsed; | ||
var endTime = this._startTime + this._duration; | ||
if (time > endTime && !this._isPlaying) { | ||
return false; | ||
} | ||
// If the tween was already finished, | ||
if (!this.isPlaying) { | ||
this.start(time); | ||
} | ||
if (time < this._startTime) { | ||
return true; | ||
} | ||
if (this._onStartCallbackFired === false) { | ||
if (this._onStartCallback) { | ||
this._onStartCallback(this._object); | ||
} | ||
this._onStartCallbackFired = true; | ||
} | ||
elapsed = (time - this._startTime) / this._duration; | ||
elapsed = this._duration === 0 || elapsed > 1 ? 1 : elapsed; | ||
var value = this._easingFunction(elapsed); | ||
// properties transformations | ||
this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value); | ||
if (this._onUpdateCallback) { | ||
this._onUpdateCallback(this._object, elapsed); | ||
} | ||
if (elapsed === 1) { | ||
if (this._repeat > 0) { | ||
if (isFinite(this._repeat)) { | ||
this._repeat--; | ||
} | ||
// Reassign starting values, restart by making startTime = now | ||
for (property in this._valuesStartRepeat) { | ||
if (!this._yoyo && typeof this._valuesEnd[property] === 'string') { | ||
this._valuesStartRepeat[property] = | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]); | ||
} | ||
if (this._yoyo) { | ||
this._swapEndStartRepeatValues(property); | ||
} | ||
this._valuesStart[property] = this._valuesStartRepeat[property]; | ||
} | ||
if (this._yoyo) { | ||
this._reversed = !this._reversed; | ||
} | ||
if (this._repeatDelayTime !== undefined) { | ||
this._startTime = time + this._repeatDelayTime; | ||
} | ||
else { | ||
this._startTime = time + this._delayTime; | ||
} | ||
if (this._onRepeatCallback) { | ||
this._onRepeatCallback(this._object); | ||
} | ||
return true; | ||
} | ||
else { | ||
if (this._onCompleteCallback) { | ||
this._onCompleteCallback(this._object); | ||
} | ||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { | ||
// Make the chained tweens start exactly at the time they should, | ||
// even if the `update()` method was called way past the duration of the tween | ||
this._chainedTweens[i].start(this._startTime + this._duration); | ||
} | ||
this._isPlaying = false; | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
Tween.prototype._updateProperties = function (_object, _valuesStart, _valuesEnd, value) { | ||
for (var property in _valuesEnd) { | ||
// Don't update properties that do not exist in the source object | ||
if (_valuesStart[property] === undefined) { | ||
continue; | ||
} | ||
var start = _valuesStart[property] || 0; | ||
var end = _valuesEnd[property]; | ||
var startIsArray = Array.isArray(_object[property]); | ||
var endIsArray = Array.isArray(end); | ||
var isInterpolationList = !startIsArray && endIsArray; | ||
if (isInterpolationList) { | ||
_object[property] = this._interpolationFunction(end, value); | ||
} | ||
else if (typeof end === 'object' && end) { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._updateProperties(_object[property], start, end, value); | ||
} | ||
else { | ||
// Parses relative end values with start as base (e.g.: +10, -3) | ||
end = this._handleRelativeValue(start, end); | ||
// Protect against non numeric properties. | ||
if (typeof end === 'number') { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
_object[property] = start + (end - start) * value; | ||
} | ||
} | ||
} | ||
}; | ||
Tween.prototype._handleRelativeValue = function (start, end) { | ||
if (typeof end !== 'string') { | ||
return end; | ||
} | ||
if (end.charAt(0) === '+' || end.charAt(0) === '-') { | ||
return start + parseFloat(end); | ||
} | ||
else { | ||
return parseFloat(end); | ||
} | ||
}; | ||
Tween.prototype._swapEndStartRepeatValues = function (property) { | ||
var tmp = this._valuesStartRepeat[property]; | ||
if (typeof this._valuesEnd[property] === 'string') { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]); | ||
} | ||
else { | ||
this._valuesStartRepeat[property] = this._valuesEnd[property]; | ||
} | ||
this._valuesEnd[property] = tmp; | ||
}; | ||
return Tween; | ||
}()); | ||
Linear: { | ||
var VERSION = '18.6.0'; | ||
None: function (k) { | ||
/** | ||
* Tween.js - Licensed under the MIT license | ||
* https://github.com/tweenjs/tween.js | ||
* ---------------------------------------------- | ||
* | ||
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. | ||
* Thank you all, you're awesome! | ||
*/ | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
/** | ||
* Controlling groups of tweens | ||
* | ||
* Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components. | ||
* In these cases, you may want to create your own smaller groups of tween | ||
*/ | ||
var Main = /** @class */ (function (_super) { | ||
__extends(Main, _super); | ||
function Main() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.version = VERSION; | ||
_this.now = NOW$1; | ||
_this.Group = Group; | ||
_this.Easing = Easing; | ||
_this.Interpolation = Interpolation; | ||
_this.nextId = Sequence.nextId; | ||
_this.Tween = Tween; | ||
return _this; | ||
} | ||
return Main; | ||
}(Group)); | ||
var TWEEN = new Main(); | ||
return k; | ||
} | ||
}, | ||
Quadratic: { | ||
In: function (k) { | ||
return k * k; | ||
}, | ||
Out: function (k) { | ||
return k * (2 - k); | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k; | ||
} | ||
return - 0.5 * (--k * (k - 2) - 1); | ||
} | ||
}, | ||
Cubic: { | ||
In: function (k) { | ||
return k * k * k; | ||
}, | ||
Out: function (k) { | ||
return --k * k * k + 1; | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k; | ||
} | ||
return 0.5 * ((k -= 2) * k * k + 2); | ||
} | ||
}, | ||
Quartic: { | ||
In: function (k) { | ||
return k * k * k * k; | ||
}, | ||
Out: function (k) { | ||
return 1 - (--k * k * k * k); | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k; | ||
} | ||
return - 0.5 * ((k -= 2) * k * k * k - 2); | ||
} | ||
}, | ||
Quintic: { | ||
In: function (k) { | ||
return k * k * k * k * k; | ||
}, | ||
Out: function (k) { | ||
return --k * k * k * k * k + 1; | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k * k; | ||
} | ||
return 0.5 * ((k -= 2) * k * k * k * k + 2); | ||
} | ||
}, | ||
Sinusoidal: { | ||
In: function (k) { | ||
return 1 - Math.cos(k * Math.PI / 2); | ||
}, | ||
Out: function (k) { | ||
return Math.sin(k * Math.PI / 2); | ||
}, | ||
InOut: function (k) { | ||
return 0.5 * (1 - Math.cos(Math.PI * k)); | ||
} | ||
}, | ||
Exponential: { | ||
In: function (k) { | ||
return k === 0 ? 0 : Math.pow(1024, k - 1); | ||
}, | ||
Out: function (k) { | ||
return k === 1 ? 1 : 1 - Math.pow(2, - 10 * k); | ||
}, | ||
InOut: function (k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
if ((k *= 2) < 1) { | ||
return 0.5 * Math.pow(1024, k - 1); | ||
} | ||
return 0.5 * (- Math.pow(2, - 10 * (k - 1)) + 2); | ||
} | ||
}, | ||
Circular: { | ||
In: function (k) { | ||
return 1 - Math.sqrt(1 - k * k); | ||
}, | ||
Out: function (k) { | ||
return Math.sqrt(1 - (--k * k)); | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return - 0.5 * (Math.sqrt(1 - k * k) - 1); | ||
} | ||
return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1); | ||
} | ||
}, | ||
Elastic: { | ||
In: function (k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
return -Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI); | ||
}, | ||
Out: function (k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
return Math.pow(2, -10 * k) * Math.sin((k - 0.1) * 5 * Math.PI) + 1; | ||
}, | ||
InOut: function (k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
k *= 2; | ||
if (k < 1) { | ||
return -0.5 * Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI); | ||
} | ||
return 0.5 * Math.pow(2, -10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI) + 1; | ||
} | ||
}, | ||
Back: { | ||
In: function (k) { | ||
var s = 1.70158; | ||
return k * k * ((s + 1) * k - s); | ||
}, | ||
Out: function (k) { | ||
var s = 1.70158; | ||
return --k * k * ((s + 1) * k + s) + 1; | ||
}, | ||
InOut: function (k) { | ||
var s = 1.70158 * 1.525; | ||
if ((k *= 2) < 1) { | ||
return 0.5 * (k * k * ((s + 1) * k - s)); | ||
} | ||
return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); | ||
} | ||
}, | ||
Bounce: { | ||
In: function (k) { | ||
return 1 - TWEEN.Easing.Bounce.Out(1 - k); | ||
}, | ||
Out: function (k) { | ||
if (k < (1 / 2.75)) { | ||
return 7.5625 * k * k; | ||
} else if (k < (2 / 2.75)) { | ||
return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75; | ||
} else if (k < (2.5 / 2.75)) { | ||
return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375; | ||
} else { | ||
return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375; | ||
} | ||
}, | ||
InOut: function (k) { | ||
if (k < 0.5) { | ||
return TWEEN.Easing.Bounce.In(k * 2) * 0.5; | ||
} | ||
return TWEEN.Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5; | ||
} | ||
} | ||
}; | ||
TWEEN.Interpolation = { | ||
Linear: function (v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = TWEEN.Interpolation.Utils.Linear; | ||
if (k < 0) { | ||
return fn(v[0], v[1], f); | ||
} | ||
if (k > 1) { | ||
return fn(v[m], v[m - 1], m - f); | ||
} | ||
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i); | ||
}, | ||
Bezier: function (v, k) { | ||
var b = 0; | ||
var n = v.length - 1; | ||
var pw = Math.pow; | ||
var bn = TWEEN.Interpolation.Utils.Bernstein; | ||
for (var i = 0; i <= n; i++) { | ||
b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i); | ||
} | ||
return b; | ||
}, | ||
CatmullRom: function (v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = TWEEN.Interpolation.Utils.CatmullRom; | ||
if (v[0] === v[m]) { | ||
if (k < 0) { | ||
i = Math.floor(f = m * (1 + k)); | ||
} | ||
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i); | ||
} else { | ||
if (k < 0) { | ||
return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]); | ||
} | ||
if (k > 1) { | ||
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]); | ||
} | ||
return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i); | ||
} | ||
}, | ||
Utils: { | ||
Linear: function (p0, p1, t) { | ||
return (p1 - p0) * t + p0; | ||
}, | ||
Bernstein: function (n, i) { | ||
var fc = TWEEN.Interpolation.Utils.Factorial; | ||
return fc(n) / fc(i) / fc(n - i); | ||
}, | ||
Factorial: (function () { | ||
var a = [1]; | ||
return function (n) { | ||
var s = 1; | ||
if (a[n]) { | ||
return a[n]; | ||
} | ||
for (var i = n; i > 1; i--) { | ||
s *= i; | ||
} | ||
a[n] = s; | ||
return s; | ||
}; | ||
})(), | ||
CatmullRom: function (p0, p1, p2, p3, t) { | ||
var v0 = (p2 - p0) * 0.5; | ||
var v1 = (p3 - p1) * 0.5; | ||
var t2 = t * t; | ||
var t3 = t * t2; | ||
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (- 3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; | ||
} | ||
} | ||
}; | ||
TWEEN.version = version; | ||
export default TWEEN; |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global.TWEEN = factory()); | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global.TWEEN = factory()); | ||
}(this, (function () { 'use strict'; | ||
var version = '18.5.0'; | ||
var NOW; | ||
// Include a performance.now polyfill. | ||
// In node.js, use process.hrtime. | ||
// eslint-disable-next-line | ||
// @ts-ignore | ||
if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) { | ||
NOW = function () { | ||
// eslint-disable-next-line | ||
// @ts-ignore | ||
var time = process.hrtime(); | ||
// Convert [seconds, nanoseconds] to milliseconds. | ||
return time[0] * 1000 + time[1] / 1000000; | ||
}; | ||
} | ||
// In a browser, use self.performance.now if it is available. | ||
else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) { | ||
// This must be bound, because directly assigning this function | ||
// leads to an invocation exception in Chrome. | ||
NOW = self.performance.now.bind(self.performance); | ||
} | ||
// Use Date.now if it is available. | ||
else if (Date.now !== undefined) { | ||
NOW = Date.now; | ||
} | ||
// Otherwise, use 'new Date().getTime()'. | ||
else { | ||
NOW = function () { | ||
return new Date().getTime(); | ||
}; | ||
} | ||
var NOW$1 = NOW; | ||
/** | ||
* Tween.js - Licensed under the MIT license | ||
* https://github.com/tweenjs/tween.js | ||
* ---------------------------------------------- | ||
* | ||
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. | ||
* Thank you all, you're awesome! | ||
*/ | ||
/** | ||
* Controlling groups of tweens | ||
* | ||
* Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components. | ||
* In these cases, you may want to create your own smaller groups of tween | ||
*/ | ||
var Group = /** @class */ (function () { | ||
function Group() { | ||
this._tweens = {}; | ||
this._tweensAddedDuringUpdate = {}; | ||
} | ||
Group.prototype.getAll = function () { | ||
var _this = this; | ||
return Object.keys(this._tweens).map(function (tweenId) { | ||
return _this._tweens[tweenId]; | ||
}); | ||
}; | ||
Group.prototype.removeAll = function () { | ||
this._tweens = {}; | ||
}; | ||
Group.prototype.add = function (tween) { | ||
this._tweens[tween.getId()] = tween; | ||
this._tweensAddedDuringUpdate[tween.getId()] = tween; | ||
}; | ||
Group.prototype.remove = function (tween) { | ||
delete this._tweens[tween.getId()]; | ||
delete this._tweensAddedDuringUpdate[tween.getId()]; | ||
}; | ||
Group.prototype.update = function (time, preserve) { | ||
var tweenIds = Object.keys(this._tweens); | ||
if (tweenIds.length === 0) { | ||
return false; | ||
} | ||
time = time !== undefined ? time : NOW$1(); | ||
// Tweens are updated in "batches". If you add a new tween during an | ||
// update, then the new tween will be updated in the next batch. | ||
// If you remove a tween during an update, it may or may not be updated. | ||
// However, if the removed tween was added during the current batch, | ||
// then it will not be updated. | ||
while (tweenIds.length > 0) { | ||
this._tweensAddedDuringUpdate = {}; | ||
for (var i = 0; i < tweenIds.length; i++) { | ||
var tween = this._tweens[tweenIds[i]]; | ||
if (tween && tween.update(time) === false && !preserve) { | ||
delete this._tweens[tweenIds[i]]; | ||
} | ||
} | ||
tweenIds = Object.keys(this._tweensAddedDuringUpdate); | ||
} | ||
return true; | ||
}; | ||
return Group; | ||
}()); | ||
/** | ||
* The Ease class provides a collection of easing functions for use with tween.js. | ||
*/ | ||
var Easing = { | ||
Linear: { | ||
None: function (amount) { | ||
return amount; | ||
}, | ||
}, | ||
Quadratic: { | ||
In: function (amount) { | ||
return amount * amount; | ||
}, | ||
Out: function (amount) { | ||
return amount * (2 - amount); | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * amount * amount; | ||
} | ||
return -0.5 * (--amount * (amount - 2) - 1); | ||
}, | ||
}, | ||
Cubic: { | ||
In: function (amount) { | ||
return amount * amount * amount; | ||
}, | ||
Out: function (amount) { | ||
return --amount * amount * amount + 1; | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * amount * amount * amount; | ||
} | ||
return 0.5 * ((amount -= 2) * amount * amount + 2); | ||
}, | ||
}, | ||
Quartic: { | ||
In: function (amount) { | ||
return amount * amount * amount * amount; | ||
}, | ||
Out: function (amount) { | ||
return 1 - --amount * amount * amount * amount; | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * amount * amount * amount * amount; | ||
} | ||
return -0.5 * ((amount -= 2) * amount * amount * amount - 2); | ||
}, | ||
}, | ||
Quintic: { | ||
In: function (amount) { | ||
return amount * amount * amount * amount * amount; | ||
}, | ||
Out: function (amount) { | ||
return --amount * amount * amount * amount * amount + 1; | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * amount * amount * amount * amount * amount; | ||
} | ||
return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2); | ||
}, | ||
}, | ||
Sinusoidal: { | ||
In: function (amount) { | ||
return 1 - Math.cos((amount * Math.PI) / 2); | ||
}, | ||
Out: function (amount) { | ||
return Math.sin((amount * Math.PI) / 2); | ||
}, | ||
InOut: function (amount) { | ||
return 0.5 * (1 - Math.cos(Math.PI * amount)); | ||
}, | ||
}, | ||
Exponential: { | ||
In: function (amount) { | ||
return amount === 0 ? 0 : Math.pow(1024, amount - 1); | ||
}, | ||
Out: function (amount) { | ||
return amount === 1 ? 1 : 1 - Math.pow(2, -10 * amount); | ||
}, | ||
InOut: function (amount) { | ||
if (amount === 0) { | ||
return 0; | ||
} | ||
if (amount === 1) { | ||
return 1; | ||
} | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * Math.pow(1024, amount - 1); | ||
} | ||
return 0.5 * (-Math.pow(2, -10 * (amount - 1)) + 2); | ||
}, | ||
}, | ||
Circular: { | ||
In: function (amount) { | ||
return 1 - Math.sqrt(1 - amount * amount); | ||
}, | ||
Out: function (amount) { | ||
return Math.sqrt(1 - --amount * amount); | ||
}, | ||
InOut: function (amount) { | ||
if ((amount *= 2) < 1) { | ||
return -0.5 * (Math.sqrt(1 - amount * amount) - 1); | ||
} | ||
return 0.5 * (Math.sqrt(1 - (amount -= 2) * amount) + 1); | ||
}, | ||
}, | ||
Elastic: { | ||
In: function (amount) { | ||
if (amount === 0) { | ||
return 0; | ||
} | ||
if (amount === 1) { | ||
return 1; | ||
} | ||
return -Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI); | ||
}, | ||
Out: function (amount) { | ||
if (amount === 0) { | ||
return 0; | ||
} | ||
if (amount === 1) { | ||
return 1; | ||
} | ||
return Math.pow(2, -10 * amount) * Math.sin((amount - 0.1) * 5 * Math.PI) + 1; | ||
}, | ||
InOut: function (amount) { | ||
if (amount === 0) { | ||
return 0; | ||
} | ||
if (amount === 1) { | ||
return 1; | ||
} | ||
amount *= 2; | ||
if (amount < 1) { | ||
return -0.5 * Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI); | ||
} | ||
return 0.5 * Math.pow(2, -10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI) + 1; | ||
}, | ||
}, | ||
Back: { | ||
In: function (amount) { | ||
var s = 1.70158; | ||
return amount * amount * ((s + 1) * amount - s); | ||
}, | ||
Out: function (amount) { | ||
var s = 1.70158; | ||
return --amount * amount * ((s + 1) * amount + s) + 1; | ||
}, | ||
InOut: function (amount) { | ||
var s = 1.70158 * 1.525; | ||
if ((amount *= 2) < 1) { | ||
return 0.5 * (amount * amount * ((s + 1) * amount - s)); | ||
} | ||
return 0.5 * ((amount -= 2) * amount * ((s + 1) * amount + s) + 2); | ||
}, | ||
}, | ||
Bounce: { | ||
In: function (amount) { | ||
return 1 - Easing.Bounce.Out(1 - amount); | ||
}, | ||
Out: function (amount) { | ||
if (amount < 1 / 2.75) { | ||
return 7.5625 * amount * amount; | ||
} | ||
else if (amount < 2 / 2.75) { | ||
return 7.5625 * (amount -= 1.5 / 2.75) * amount + 0.75; | ||
} | ||
else if (amount < 2.5 / 2.75) { | ||
return 7.5625 * (amount -= 2.25 / 2.75) * amount + 0.9375; | ||
} | ||
else { | ||
return 7.5625 * (amount -= 2.625 / 2.75) * amount + 0.984375; | ||
} | ||
}, | ||
InOut: function (amount) { | ||
if (amount < 0.5) { | ||
return Easing.Bounce.In(amount * 2) * 0.5; | ||
} | ||
return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5; | ||
}, | ||
}, | ||
}; | ||
var _Group = function () { | ||
this._tweens = {}; | ||
this._tweensAddedDuringUpdate = {}; | ||
}; | ||
/** | ||
* | ||
*/ | ||
var Interpolation = { | ||
Linear: function (v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = Interpolation.Utils.Linear; | ||
if (k < 0) { | ||
return fn(v[0], v[1], f); | ||
} | ||
if (k > 1) { | ||
return fn(v[m], v[m - 1], m - f); | ||
} | ||
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i); | ||
}, | ||
Bezier: function (v, k) { | ||
var b = 0; | ||
var n = v.length - 1; | ||
var pw = Math.pow; | ||
var bn = Interpolation.Utils.Bernstein; | ||
for (var i = 0; i <= n; i++) { | ||
b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i); | ||
} | ||
return b; | ||
}, | ||
CatmullRom: function (v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = Interpolation.Utils.CatmullRom; | ||
if (v[0] === v[m]) { | ||
if (k < 0) { | ||
i = Math.floor((f = m * (1 + k))); | ||
} | ||
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i); | ||
} | ||
else { | ||
if (k < 0) { | ||
return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]); | ||
} | ||
if (k > 1) { | ||
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]); | ||
} | ||
return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i); | ||
} | ||
}, | ||
Utils: { | ||
Linear: function (p0, p1, t) { | ||
return (p1 - p0) * t + p0; | ||
}, | ||
Bernstein: function (n, i) { | ||
var fc = Interpolation.Utils.Factorial; | ||
return fc(n) / fc(i) / fc(n - i); | ||
}, | ||
Factorial: (function () { | ||
var a = [1]; | ||
return function (n) { | ||
var s = 1; | ||
if (a[n]) { | ||
return a[n]; | ||
} | ||
for (var i = n; i > 1; i--) { | ||
s *= i; | ||
} | ||
a[n] = s; | ||
return s; | ||
}; | ||
})(), | ||
CatmullRom: function (p0, p1, p2, p3, t) { | ||
var v0 = (p2 - p0) * 0.5; | ||
var v1 = (p3 - p1) * 0.5; | ||
var t2 = t * t; | ||
var t3 = t * t2; | ||
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; | ||
}, | ||
}, | ||
}; | ||
_Group.prototype = { | ||
getAll: function () { | ||
/** | ||
* Utils | ||
*/ | ||
var Sequence = /** @class */ (function () { | ||
function Sequence() { | ||
} | ||
Sequence.nextId = function () { | ||
return Sequence._nextId++; | ||
}; | ||
Sequence._nextId = 0; | ||
return Sequence; | ||
}()); | ||
return Object.keys(this._tweens).map(function (tweenId) { | ||
return this._tweens[tweenId]; | ||
}.bind(this)); | ||
/** | ||
* Tween.js - Licensed under the MIT license | ||
* https://github.com/tweenjs/tween.js | ||
* ---------------------------------------------- | ||
* | ||
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. | ||
* Thank you all, you're awesome! | ||
*/ | ||
var Tween = /** @class */ (function () { | ||
function Tween(_object, _group) { | ||
if (_group === void 0) { _group = TWEEN; } | ||
this._object = _object; | ||
this._group = _group; | ||
this._isPaused = false; | ||
this._pauseStart = 0; | ||
this._valuesStart = {}; | ||
this._valuesEnd = {}; | ||
this._valuesStartRepeat = {}; | ||
this._duration = 1000; | ||
this._initialRepeat = 0; | ||
this._repeat = 0; | ||
this._yoyo = false; | ||
this._isPlaying = false; | ||
this._reversed = false; | ||
this._delayTime = 0; | ||
this._startTime = 0; | ||
this._easingFunction = TWEEN.Easing.Linear.None; | ||
this._interpolationFunction = TWEEN.Interpolation.Linear; | ||
this._chainedTweens = []; | ||
this._onStartCallbackFired = false; | ||
this._id = TWEEN.nextId(); | ||
this._isChainStopped = false; | ||
} | ||
Tween.prototype.getId = function () { | ||
return this._id; | ||
}; | ||
Tween.prototype.isPlaying = function () { | ||
return this._isPlaying; | ||
}; | ||
Tween.prototype.isPaused = function () { | ||
return this._isPaused; | ||
}; | ||
Tween.prototype.to = function (properties, duration) { | ||
for (var prop in properties) { | ||
this._valuesEnd[prop] = properties[prop]; | ||
} | ||
if (duration !== undefined) { | ||
this._duration = duration; | ||
} | ||
return this; | ||
}; | ||
Tween.prototype.duration = function (d) { | ||
this._duration = d; | ||
return this; | ||
}; | ||
Tween.prototype.start = function (time) { | ||
if (this._isPlaying) { | ||
return this; | ||
} | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._group.add(this); | ||
this._repeat = this._initialRepeat; | ||
if (this._reversed) { | ||
// If we were reversed (f.e. using the yoyo feature) then we need to | ||
// flip the tween direction back to forward. | ||
this._reversed = false; | ||
for (var property in this._valuesStartRepeat) { | ||
this._swapEndStartRepeatValues(property); | ||
this._valuesStart[property] = this._valuesStartRepeat[property]; | ||
} | ||
} | ||
this._isPlaying = true; | ||
this._isPaused = false; | ||
this._onStartCallbackFired = false; | ||
this._isChainStopped = false; | ||
this._startTime = | ||
time !== undefined ? (typeof time === 'string' ? TWEEN.now() + parseFloat(time) : time) : TWEEN.now(); | ||
this._startTime += this._delayTime; | ||
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat); | ||
return this; | ||
}; | ||
Tween.prototype._setupProperties = function (_object, _valuesStart, _valuesEnd, _valuesStartRepeat) { | ||
for (var property in _valuesEnd) { | ||
var startValue = _object[property]; | ||
var startValueIsArray = Array.isArray(startValue); | ||
var propType = startValueIsArray ? 'array' : typeof startValue; | ||
var isInterpolationList = !startValueIsArray && Array.isArray(_valuesEnd[property]); | ||
// If `to()` specifies a property that doesn't exist in the source object, | ||
// we should not set that property in the object | ||
if (propType === 'undefined' || propType === 'function') { | ||
continue; | ||
} | ||
// Check if an Array was provided as property value | ||
if (isInterpolationList) { | ||
var endValues = _valuesEnd[property]; | ||
if (endValues.length === 0) { | ||
continue; | ||
} | ||
// handle an array of relative values | ||
endValues = endValues.map(this._handleRelativeValue.bind(this, startValue)); | ||
// Create a local copy of the Array with the start value at the front | ||
_valuesEnd[property] = [startValue].concat(endValues); | ||
} | ||
// handle the deepness of the values | ||
if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) { | ||
_valuesStart[property] = startValueIsArray ? [] : {}; | ||
// eslint-disable-next-line | ||
for (var prop in startValue) { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
_valuesStart[property][prop] = startValue[prop]; | ||
} | ||
_valuesStartRepeat[property] = startValueIsArray ? [] : {}; // TODO? repeat nested values? And yoyo? And array values? | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._setupProperties(startValue, _valuesStart[property], _valuesEnd[property], _valuesStartRepeat[property]); | ||
} | ||
else { | ||
// Save the starting value, but only once. | ||
if (typeof _valuesStart[property] === 'undefined') { | ||
_valuesStart[property] = startValue; | ||
} | ||
if (!startValueIsArray) { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
_valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings | ||
} | ||
if (isInterpolationList) { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
_valuesStartRepeat[property] = _valuesEnd[property].slice().reverse(); | ||
} | ||
else { | ||
_valuesStartRepeat[property] = _valuesStart[property] || 0; | ||
} | ||
} | ||
} | ||
}; | ||
Tween.prototype.stop = function () { | ||
if (!this._isChainStopped) { | ||
this._isChainStopped = true; | ||
this.stopChainedTweens(); | ||
} | ||
if (!this._isPlaying) { | ||
return this; | ||
} | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._group.remove(this); | ||
this._isPlaying = false; | ||
this._isPaused = false; | ||
if (this._onStopCallback) { | ||
this._onStopCallback(this._object); | ||
} | ||
return this; | ||
}; | ||
Tween.prototype.end = function () { | ||
this.update(Infinity); | ||
return this; | ||
}; | ||
Tween.prototype.pause = function (time) { | ||
if (this._isPaused || !this._isPlaying) { | ||
return this; | ||
} | ||
this._isPaused = true; | ||
this._pauseStart = time === undefined ? TWEEN.now() : time; | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._group.remove(this); | ||
return this; | ||
}; | ||
Tween.prototype.resume = function (time) { | ||
if (!this._isPaused || !this._isPlaying) { | ||
return this; | ||
} | ||
this._isPaused = false; | ||
this._startTime += (time === undefined ? TWEEN.now() : time) - this._pauseStart; | ||
this._pauseStart = 0; | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._group.add(this); | ||
return this; | ||
}; | ||
Tween.prototype.stopChainedTweens = function () { | ||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { | ||
this._chainedTweens[i].stop(); | ||
} | ||
return this; | ||
}; | ||
Tween.prototype.group = function (group) { | ||
this._group = group; | ||
return this; | ||
}; | ||
Tween.prototype.delay = function (amount) { | ||
this._delayTime = amount; | ||
return this; | ||
}; | ||
Tween.prototype.repeat = function (times) { | ||
this._initialRepeat = times; | ||
this._repeat = times; | ||
return this; | ||
}; | ||
Tween.prototype.repeatDelay = function (amount) { | ||
this._repeatDelayTime = amount; | ||
return this; | ||
}; | ||
Tween.prototype.yoyo = function (yoyo) { | ||
this._yoyo = yoyo; | ||
return this; | ||
}; | ||
Tween.prototype.easing = function (easingFunction) { | ||
this._easingFunction = easingFunction; | ||
return this; | ||
}; | ||
Tween.prototype.interpolation = function (interpolationFunction) { | ||
this._interpolationFunction = interpolationFunction; | ||
return this; | ||
}; | ||
Tween.prototype.chain = function () { | ||
var tweens = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
tweens[_i] = arguments[_i]; | ||
} | ||
this._chainedTweens = tweens; | ||
return this; | ||
}; | ||
Tween.prototype.onStart = function (callback) { | ||
this._onStartCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.onUpdate = function (callback) { | ||
this._onUpdateCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.onRepeat = function (callback) { | ||
this._onRepeatCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.onComplete = function (callback) { | ||
this._onCompleteCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.onStop = function (callback) { | ||
this._onStopCallback = callback; | ||
return this; | ||
}; | ||
Tween.prototype.update = function (time) { | ||
var property; | ||
var elapsed; | ||
var endTime = this._startTime + this._duration; | ||
if (time > endTime && !this._isPlaying) { | ||
return false; | ||
} | ||
// If the tween was already finished, | ||
if (!this.isPlaying) { | ||
this.start(time); | ||
} | ||
if (time < this._startTime) { | ||
return true; | ||
} | ||
if (this._onStartCallbackFired === false) { | ||
if (this._onStartCallback) { | ||
this._onStartCallback(this._object); | ||
} | ||
this._onStartCallbackFired = true; | ||
} | ||
elapsed = (time - this._startTime) / this._duration; | ||
elapsed = this._duration === 0 || elapsed > 1 ? 1 : elapsed; | ||
var value = this._easingFunction(elapsed); | ||
// properties transformations | ||
this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value); | ||
if (this._onUpdateCallback) { | ||
this._onUpdateCallback(this._object, elapsed); | ||
} | ||
if (elapsed === 1) { | ||
if (this._repeat > 0) { | ||
if (isFinite(this._repeat)) { | ||
this._repeat--; | ||
} | ||
// Reassign starting values, restart by making startTime = now | ||
for (property in this._valuesStartRepeat) { | ||
if (!this._yoyo && typeof this._valuesEnd[property] === 'string') { | ||
this._valuesStartRepeat[property] = | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]); | ||
} | ||
if (this._yoyo) { | ||
this._swapEndStartRepeatValues(property); | ||
} | ||
this._valuesStart[property] = this._valuesStartRepeat[property]; | ||
} | ||
if (this._yoyo) { | ||
this._reversed = !this._reversed; | ||
} | ||
if (this._repeatDelayTime !== undefined) { | ||
this._startTime = time + this._repeatDelayTime; | ||
} | ||
else { | ||
this._startTime = time + this._delayTime; | ||
} | ||
if (this._onRepeatCallback) { | ||
this._onRepeatCallback(this._object); | ||
} | ||
return true; | ||
} | ||
else { | ||
if (this._onCompleteCallback) { | ||
this._onCompleteCallback(this._object); | ||
} | ||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { | ||
// Make the chained tweens start exactly at the time they should, | ||
// even if the `update()` method was called way past the duration of the tween | ||
this._chainedTweens[i].start(this._startTime + this._duration); | ||
} | ||
this._isPlaying = false; | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
Tween.prototype._updateProperties = function (_object, _valuesStart, _valuesEnd, value) { | ||
for (var property in _valuesEnd) { | ||
// Don't update properties that do not exist in the source object | ||
if (_valuesStart[property] === undefined) { | ||
continue; | ||
} | ||
var start = _valuesStart[property] || 0; | ||
var end = _valuesEnd[property]; | ||
var startIsArray = Array.isArray(_object[property]); | ||
var endIsArray = Array.isArray(end); | ||
var isInterpolationList = !startIsArray && endIsArray; | ||
if (isInterpolationList) { | ||
_object[property] = this._interpolationFunction(end, value); | ||
} | ||
else if (typeof end === 'object' && end) { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._updateProperties(_object[property], start, end, value); | ||
} | ||
else { | ||
// Parses relative end values with start as base (e.g.: +10, -3) | ||
end = this._handleRelativeValue(start, end); | ||
// Protect against non numeric properties. | ||
if (typeof end === 'number') { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
_object[property] = start + (end - start) * value; | ||
} | ||
} | ||
} | ||
}; | ||
Tween.prototype._handleRelativeValue = function (start, end) { | ||
if (typeof end !== 'string') { | ||
return end; | ||
} | ||
if (end.charAt(0) === '+' || end.charAt(0) === '-') { | ||
return start + parseFloat(end); | ||
} | ||
else { | ||
return parseFloat(end); | ||
} | ||
}; | ||
Tween.prototype._swapEndStartRepeatValues = function (property) { | ||
var tmp = this._valuesStartRepeat[property]; | ||
if (typeof this._valuesEnd[property] === 'string') { | ||
// eslint-disable-next-line | ||
// @ts-ignore FIXME? | ||
this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]); | ||
} | ||
else { | ||
this._valuesStartRepeat[property] = this._valuesEnd[property]; | ||
} | ||
this._valuesEnd[property] = tmp; | ||
}; | ||
return Tween; | ||
}()); | ||
}, | ||
var VERSION = '18.6.0'; | ||
removeAll: function () { | ||
/** | ||
* Tween.js - Licensed under the MIT license | ||
* https://github.com/tweenjs/tween.js | ||
* ---------------------------------------------- | ||
* | ||
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors. | ||
* Thank you all, you're awesome! | ||
*/ | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
/** | ||
* Controlling groups of tweens | ||
* | ||
* Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components. | ||
* In these cases, you may want to create your own smaller groups of tween | ||
*/ | ||
var Main = /** @class */ (function (_super) { | ||
__extends(Main, _super); | ||
function Main() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.version = VERSION; | ||
_this.now = NOW$1; | ||
_this.Group = Group; | ||
_this.Easing = Easing; | ||
_this.Interpolation = Interpolation; | ||
_this.nextId = Sequence.nextId; | ||
_this.Tween = Tween; | ||
return _this; | ||
} | ||
return Main; | ||
}(Group)); | ||
var TWEEN = new Main(); | ||
this._tweens = {}; | ||
return TWEEN; | ||
}, | ||
add: function (tween) { | ||
this._tweens[tween.getId()] = tween; | ||
this._tweensAddedDuringUpdate[tween.getId()] = tween; | ||
}, | ||
remove: function (tween) { | ||
delete this._tweens[tween.getId()]; | ||
delete this._tweensAddedDuringUpdate[tween.getId()]; | ||
}, | ||
update: function (time, preserve) { | ||
var tweenIds = Object.keys(this._tweens); | ||
if (tweenIds.length === 0) { | ||
return false; | ||
} | ||
time = time !== undefined ? time : TWEEN.now(); | ||
// Tweens are updated in "batches". If you add a new tween during an | ||
// update, then the new tween will be updated in the next batch. | ||
// If you remove a tween during an update, it may or may not be updated. | ||
// However, if the removed tween was added during the current batch, | ||
// then it will not be updated. | ||
while (tweenIds.length > 0) { | ||
this._tweensAddedDuringUpdate = {}; | ||
for (var i = 0; i < tweenIds.length; i++) { | ||
var tween = this._tweens[tweenIds[i]]; | ||
if (tween && tween.update(time) === false) { | ||
tween._isPlaying = false; | ||
if (!preserve) { | ||
delete this._tweens[tweenIds[i]]; | ||
} | ||
} | ||
} | ||
tweenIds = Object.keys(this._tweensAddedDuringUpdate); | ||
} | ||
return true; | ||
} | ||
}; | ||
var TWEEN = new _Group(); | ||
TWEEN.Group = _Group; | ||
TWEEN._nextId = 0; | ||
TWEEN.nextId = function () { | ||
return TWEEN._nextId++; | ||
}; | ||
// Include a performance.now polyfill. | ||
// In node.js, use process.hrtime. | ||
if (typeof (self) === 'undefined' && typeof (process) !== 'undefined' && process.hrtime) { | ||
TWEEN.now = function () { | ||
var time = process.hrtime(); | ||
// Convert [seconds, nanoseconds] to milliseconds. | ||
return time[0] * 1000 + time[1] / 1000000; | ||
}; | ||
} | ||
// In a browser, use self.performance.now if it is available. | ||
else if (typeof (self) !== 'undefined' && | ||
self.performance !== undefined && | ||
self.performance.now !== undefined) { | ||
// This must be bound, because directly assigning this function | ||
// leads to an invocation exception in Chrome. | ||
TWEEN.now = self.performance.now.bind(self.performance); | ||
} | ||
// Use Date.now if it is available. | ||
else if (Date.now !== undefined) { | ||
TWEEN.now = Date.now; | ||
} | ||
// Otherwise, use 'new Date().getTime()'. | ||
else { | ||
TWEEN.now = function () { | ||
return new Date().getTime(); | ||
}; | ||
} | ||
TWEEN.Tween = function (object, group) { | ||
this._isPaused = false; | ||
this._pauseStart = null; | ||
this._object = object; | ||
this._valuesStart = {}; | ||
this._valuesEnd = {}; | ||
this._valuesStartRepeat = {}; | ||
this._duration = 1000; | ||
this._repeat = 0; | ||
this._repeatDelayTime = undefined; | ||
this._yoyo = false; | ||
this._isPlaying = false; | ||
this._reversed = false; | ||
this._delayTime = 0; | ||
this._startTime = null; | ||
this._easingFunction = TWEEN.Easing.Linear.None; | ||
this._interpolationFunction = TWEEN.Interpolation.Linear; | ||
this._chainedTweens = []; | ||
this._onStartCallback = null; | ||
this._onStartCallbackFired = false; | ||
this._onUpdateCallback = null; | ||
this._onRepeatCallback = null; | ||
this._onCompleteCallback = null; | ||
this._onStopCallback = null; | ||
this._group = group || TWEEN; | ||
this._id = TWEEN.nextId(); | ||
}; | ||
TWEEN.Tween.prototype = { | ||
getId: function () { | ||
return this._id; | ||
}, | ||
isPlaying: function () { | ||
return this._isPlaying; | ||
}, | ||
isPaused: function () { | ||
return this._isPaused; | ||
}, | ||
to: function (properties, duration) { | ||
this._valuesEnd = Object.create(properties); | ||
if (duration !== undefined) { | ||
this._duration = duration; | ||
} | ||
return this; | ||
}, | ||
duration: function duration(d) { | ||
this._duration = d; | ||
return this; | ||
}, | ||
start: function (time) { | ||
this._group.add(this); | ||
this._isPlaying = true; | ||
this._isPaused = false; | ||
this._onStartCallbackFired = false; | ||
this._startTime = time !== undefined ? typeof time === 'string' ? TWEEN.now() + parseFloat(time) : time : TWEEN.now(); | ||
this._startTime += this._delayTime; | ||
for (var property in this._valuesEnd) { | ||
// Check if an Array was provided as property value | ||
if (this._valuesEnd[property] instanceof Array) { | ||
if (this._valuesEnd[property].length === 0) { | ||
continue; | ||
} | ||
// Create a local copy of the Array with the start value at the front | ||
this._valuesEnd[property] = [this._object[property]].concat(this._valuesEnd[property]); | ||
} | ||
// If `to()` specifies a property that doesn't exist in the source object, | ||
// we should not set that property in the object | ||
if (this._object[property] === undefined) { | ||
continue; | ||
} | ||
// Save the starting value, but only once. | ||
if (typeof(this._valuesStart[property]) === 'undefined') { | ||
this._valuesStart[property] = this._object[property]; | ||
} | ||
if ((this._valuesStart[property] instanceof Array) === false) { | ||
this._valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings | ||
} | ||
this._valuesStartRepeat[property] = this._valuesStart[property] || 0; | ||
} | ||
return this; | ||
}, | ||
stop: function () { | ||
if (!this._isPlaying) { | ||
return this; | ||
} | ||
this._group.remove(this); | ||
this._isPlaying = false; | ||
this._isPaused = false; | ||
if (this._onStopCallback !== null) { | ||
this._onStopCallback(this._object); | ||
} | ||
this.stopChainedTweens(); | ||
return this; | ||
}, | ||
end: function () { | ||
this.update(Infinity); | ||
return this; | ||
}, | ||
pause: function(time) { | ||
if (this._isPaused || !this._isPlaying) { | ||
return this; | ||
} | ||
this._isPaused = true; | ||
this._pauseStart = time === undefined ? TWEEN.now() : time; | ||
this._group.remove(this); | ||
return this; | ||
}, | ||
resume: function(time) { | ||
if (!this._isPaused || !this._isPlaying) { | ||
return this; | ||
} | ||
this._isPaused = false; | ||
this._startTime += (time === undefined ? TWEEN.now() : time) | ||
- this._pauseStart; | ||
this._pauseStart = 0; | ||
this._group.add(this); | ||
return this; | ||
}, | ||
stopChainedTweens: function () { | ||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { | ||
this._chainedTweens[i].stop(); | ||
} | ||
}, | ||
group: function (group) { | ||
this._group = group; | ||
return this; | ||
}, | ||
delay: function (amount) { | ||
this._delayTime = amount; | ||
return this; | ||
}, | ||
repeat: function (times) { | ||
this._repeat = times; | ||
return this; | ||
}, | ||
repeatDelay: function (amount) { | ||
this._repeatDelayTime = amount; | ||
return this; | ||
}, | ||
yoyo: function (yoyo) { | ||
this._yoyo = yoyo; | ||
return this; | ||
}, | ||
easing: function (easingFunction) { | ||
this._easingFunction = easingFunction; | ||
return this; | ||
}, | ||
interpolation: function (interpolationFunction) { | ||
this._interpolationFunction = interpolationFunction; | ||
return this; | ||
}, | ||
chain: function () { | ||
this._chainedTweens = arguments; | ||
return this; | ||
}, | ||
onStart: function (callback) { | ||
this._onStartCallback = callback; | ||
return this; | ||
}, | ||
onUpdate: function (callback) { | ||
this._onUpdateCallback = callback; | ||
return this; | ||
}, | ||
onRepeat: function onRepeat(callback) { | ||
this._onRepeatCallback = callback; | ||
return this; | ||
}, | ||
onComplete: function (callback) { | ||
this._onCompleteCallback = callback; | ||
return this; | ||
}, | ||
onStop: function (callback) { | ||
this._onStopCallback = callback; | ||
return this; | ||
}, | ||
update: function (time) { | ||
var property; | ||
var elapsed; | ||
var value; | ||
if (time < this._startTime) { | ||
return true; | ||
} | ||
if (this._onStartCallbackFired === false) { | ||
if (this._onStartCallback !== null) { | ||
this._onStartCallback(this._object); | ||
} | ||
this._onStartCallbackFired = true; | ||
} | ||
elapsed = (time - this._startTime) / this._duration; | ||
elapsed = (this._duration === 0 || elapsed > 1) ? 1 : elapsed; | ||
value = this._easingFunction(elapsed); | ||
for (property in this._valuesEnd) { | ||
// Don't update properties that do not exist in the source object | ||
if (this._valuesStart[property] === undefined) { | ||
continue; | ||
} | ||
var start = this._valuesStart[property] || 0; | ||
var end = this._valuesEnd[property]; | ||
if (end instanceof Array) { | ||
this._object[property] = this._interpolationFunction(end, value); | ||
} else { | ||
// Parses relative end values with start as base (e.g.: +10, -3) | ||
if (typeof (end) === 'string') { | ||
if (end.charAt(0) === '+' || end.charAt(0) === '-') { | ||
end = start + parseFloat(end); | ||
} else { | ||
end = parseFloat(end); | ||
} | ||
} | ||
// Protect against non numeric properties. | ||
if (typeof (end) === 'number') { | ||
this._object[property] = start + (end - start) * value; | ||
} | ||
} | ||
} | ||
if (this._onUpdateCallback !== null) { | ||
this._onUpdateCallback(this._object, elapsed); | ||
} | ||
if (elapsed === 1) { | ||
if (this._repeat > 0) { | ||
if (isFinite(this._repeat)) { | ||
this._repeat--; | ||
} | ||
// Reassign starting values, restart by making startTime = now | ||
for (property in this._valuesStartRepeat) { | ||
if (typeof (this._valuesEnd[property]) === 'string') { | ||
this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]); | ||
} | ||
if (this._yoyo) { | ||
var tmp = this._valuesStartRepeat[property]; | ||
this._valuesStartRepeat[property] = this._valuesEnd[property]; | ||
this._valuesEnd[property] = tmp; | ||
} | ||
this._valuesStart[property] = this._valuesStartRepeat[property]; | ||
} | ||
if (this._yoyo) { | ||
this._reversed = !this._reversed; | ||
} | ||
if (this._repeatDelayTime !== undefined) { | ||
this._startTime = time + this._repeatDelayTime; | ||
} else { | ||
this._startTime = time + this._delayTime; | ||
} | ||
if (this._onRepeatCallback !== null) { | ||
this._onRepeatCallback(this._object); | ||
} | ||
return true; | ||
} else { | ||
if (this._onCompleteCallback !== null) { | ||
this._onCompleteCallback(this._object); | ||
} | ||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) { | ||
// Make the chained tweens start exactly at the time they should, | ||
// even if the `update()` method was called way past the duration of the tween | ||
this._chainedTweens[i].start(this._startTime + this._duration); | ||
} | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
}; | ||
TWEEN.Easing = { | ||
Linear: { | ||
None: function (k) { | ||
return k; | ||
} | ||
}, | ||
Quadratic: { | ||
In: function (k) { | ||
return k * k; | ||
}, | ||
Out: function (k) { | ||
return k * (2 - k); | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k; | ||
} | ||
return - 0.5 * (--k * (k - 2) - 1); | ||
} | ||
}, | ||
Cubic: { | ||
In: function (k) { | ||
return k * k * k; | ||
}, | ||
Out: function (k) { | ||
return --k * k * k + 1; | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k; | ||
} | ||
return 0.5 * ((k -= 2) * k * k + 2); | ||
} | ||
}, | ||
Quartic: { | ||
In: function (k) { | ||
return k * k * k * k; | ||
}, | ||
Out: function (k) { | ||
return 1 - (--k * k * k * k); | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k; | ||
} | ||
return - 0.5 * ((k -= 2) * k * k * k - 2); | ||
} | ||
}, | ||
Quintic: { | ||
In: function (k) { | ||
return k * k * k * k * k; | ||
}, | ||
Out: function (k) { | ||
return --k * k * k * k * k + 1; | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return 0.5 * k * k * k * k * k; | ||
} | ||
return 0.5 * ((k -= 2) * k * k * k * k + 2); | ||
} | ||
}, | ||
Sinusoidal: { | ||
In: function (k) { | ||
return 1 - Math.cos(k * Math.PI / 2); | ||
}, | ||
Out: function (k) { | ||
return Math.sin(k * Math.PI / 2); | ||
}, | ||
InOut: function (k) { | ||
return 0.5 * (1 - Math.cos(Math.PI * k)); | ||
} | ||
}, | ||
Exponential: { | ||
In: function (k) { | ||
return k === 0 ? 0 : Math.pow(1024, k - 1); | ||
}, | ||
Out: function (k) { | ||
return k === 1 ? 1 : 1 - Math.pow(2, - 10 * k); | ||
}, | ||
InOut: function (k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
if ((k *= 2) < 1) { | ||
return 0.5 * Math.pow(1024, k - 1); | ||
} | ||
return 0.5 * (- Math.pow(2, - 10 * (k - 1)) + 2); | ||
} | ||
}, | ||
Circular: { | ||
In: function (k) { | ||
return 1 - Math.sqrt(1 - k * k); | ||
}, | ||
Out: function (k) { | ||
return Math.sqrt(1 - (--k * k)); | ||
}, | ||
InOut: function (k) { | ||
if ((k *= 2) < 1) { | ||
return - 0.5 * (Math.sqrt(1 - k * k) - 1); | ||
} | ||
return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1); | ||
} | ||
}, | ||
Elastic: { | ||
In: function (k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
return -Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI); | ||
}, | ||
Out: function (k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
return Math.pow(2, -10 * k) * Math.sin((k - 0.1) * 5 * Math.PI) + 1; | ||
}, | ||
InOut: function (k) { | ||
if (k === 0) { | ||
return 0; | ||
} | ||
if (k === 1) { | ||
return 1; | ||
} | ||
k *= 2; | ||
if (k < 1) { | ||
return -0.5 * Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI); | ||
} | ||
return 0.5 * Math.pow(2, -10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI) + 1; | ||
} | ||
}, | ||
Back: { | ||
In: function (k) { | ||
var s = 1.70158; | ||
return k * k * ((s + 1) * k - s); | ||
}, | ||
Out: function (k) { | ||
var s = 1.70158; | ||
return --k * k * ((s + 1) * k + s) + 1; | ||
}, | ||
InOut: function (k) { | ||
var s = 1.70158 * 1.525; | ||
if ((k *= 2) < 1) { | ||
return 0.5 * (k * k * ((s + 1) * k - s)); | ||
} | ||
return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); | ||
} | ||
}, | ||
Bounce: { | ||
In: function (k) { | ||
return 1 - TWEEN.Easing.Bounce.Out(1 - k); | ||
}, | ||
Out: function (k) { | ||
if (k < (1 / 2.75)) { | ||
return 7.5625 * k * k; | ||
} else if (k < (2 / 2.75)) { | ||
return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75; | ||
} else if (k < (2.5 / 2.75)) { | ||
return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375; | ||
} else { | ||
return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375; | ||
} | ||
}, | ||
InOut: function (k) { | ||
if (k < 0.5) { | ||
return TWEEN.Easing.Bounce.In(k * 2) * 0.5; | ||
} | ||
return TWEEN.Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5; | ||
} | ||
} | ||
}; | ||
TWEEN.Interpolation = { | ||
Linear: function (v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = TWEEN.Interpolation.Utils.Linear; | ||
if (k < 0) { | ||
return fn(v[0], v[1], f); | ||
} | ||
if (k > 1) { | ||
return fn(v[m], v[m - 1], m - f); | ||
} | ||
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i); | ||
}, | ||
Bezier: function (v, k) { | ||
var b = 0; | ||
var n = v.length - 1; | ||
var pw = Math.pow; | ||
var bn = TWEEN.Interpolation.Utils.Bernstein; | ||
for (var i = 0; i <= n; i++) { | ||
b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i); | ||
} | ||
return b; | ||
}, | ||
CatmullRom: function (v, k) { | ||
var m = v.length - 1; | ||
var f = m * k; | ||
var i = Math.floor(f); | ||
var fn = TWEEN.Interpolation.Utils.CatmullRom; | ||
if (v[0] === v[m]) { | ||
if (k < 0) { | ||
i = Math.floor(f = m * (1 + k)); | ||
} | ||
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i); | ||
} else { | ||
if (k < 0) { | ||
return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]); | ||
} | ||
if (k > 1) { | ||
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]); | ||
} | ||
return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i); | ||
} | ||
}, | ||
Utils: { | ||
Linear: function (p0, p1, t) { | ||
return (p1 - p0) * t + p0; | ||
}, | ||
Bernstein: function (n, i) { | ||
var fc = TWEEN.Interpolation.Utils.Factorial; | ||
return fc(n) / fc(i) / fc(n - i); | ||
}, | ||
Factorial: (function () { | ||
var a = [1]; | ||
return function (n) { | ||
var s = 1; | ||
if (a[n]) { | ||
return a[n]; | ||
} | ||
for (var i = n; i > 1; i--) { | ||
s *= i; | ||
} | ||
a[n] = s; | ||
return s; | ||
}; | ||
})(), | ||
CatmullRom: function (p0, p1, p2, p3, t) { | ||
var v0 = (p2 - p0) * 0.5; | ||
var v1 = (p3 - p1) * 0.5; | ||
var t2 = t * t; | ||
var t3 = t * t2; | ||
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (- 3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; | ||
} | ||
} | ||
}; | ||
TWEEN.version = version; | ||
return TWEEN; | ||
}))); |
{ | ||
"name": "@tweenjs/tween.js", | ||
"description": "Super simple, fast and easy to use tweening engine which incorporates optimised Robert Penner's equations.", | ||
"version": "18.5.0", | ||
"main": "dist/tween.cjs.js", | ||
"module": "dist/tween.esm.js", | ||
"homepage": "https://github.com/tweenjs/tween.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/tweenjs/tween.js.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/tweenjs/tween.js/issues" | ||
}, | ||
"license": "MIT", | ||
"keywords": [ | ||
"tween", | ||
"interpolation" | ||
], | ||
"dependencies": {}, | ||
"scripts": { | ||
"build": "node scripts/write-version.js && npm run rollup-build && node scripts/remove-version.js", | ||
"rollup-build": "rollup -c ./rollup.config.js", | ||
"test": "npm run build && npm run test-unit && npm run test-lint", | ||
"test-unit": "nodeunit test/unit/nodeunitheadless.js", | ||
"test-lint": "eslint src/Tween.js" | ||
}, | ||
"author": "tween.js contributors (https://github.com/tweenjs/tween.js/graphs/contributors)", | ||
"devDependencies": { | ||
"eslint": "^6.3.0", | ||
"nodeunit": "^0.9.5", | ||
"rollup": "^0.57.1" | ||
} | ||
"name": "@tweenjs/tween.js", | ||
"description": "Super simple, fast and easy to use tweening engine which incorporates optimised Robert Penner's equations.", | ||
"version": "18.6.0", | ||
"main": "dist/tween.cjs.js", | ||
"types": "dist/index.d.ts", | ||
"module": "dist/tween.esm.js", | ||
"files": [ | ||
"dist", | ||
"README.md", | ||
"LICENSE" | ||
], | ||
"homepage": "https://github.com/tweenjs/tween.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/tweenjs/tween.js.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/tweenjs/tween.js/issues" | ||
}, | ||
"license": "MIT", | ||
"keywords": [ | ||
"tween", | ||
"interpolation" | ||
], | ||
"dependencies": {}, | ||
"scripts": { | ||
"build": "rimraf dist && node scripts/write-version.js && npm run tsc && npm run rollup-build && npm run tsc-d.ts && npm run adjust-d.ts", | ||
"rollup-build": "rollup -c ./rollup.config.js", | ||
"tsc": "tsc", | ||
"tsc-watch": "tsc --watch", | ||
"tsc-d.ts": "tsc --declaration --emitDeclarationOnly --esModuleInterop --outFile dist/index.d.ts", | ||
"adjust-d.ts": "node scripts/adjust-d.ts.js", | ||
"test": "npm run build && npm run test-unit && npm run test-lint", | ||
"test-unit": "nodeunit test/unit/nodeunitheadless.js", | ||
"test-lint": "npm run prettier -- --check && eslint 'src/**/*.ts'", | ||
"lint": "npm run prettier -- --write && eslint 'src/**/*.ts' --fix", | ||
"prettier": "prettier './**/*.{js,ts,md,json,html,css}'", | ||
"prepare": "npm run build" | ||
}, | ||
"author": "tween.js contributors (https://github.com/tweenjs/tween.js/graphs/contributors)", | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^3.1.0", | ||
"@typescript-eslint/parser": "^3.1.0", | ||
"eslint": "^7.1.0", | ||
"eslint-config-prettier": "^6.7.0", | ||
"eslint-plugin-prettier": "^3.1.1", | ||
"nodeunit": "^0.11.3", | ||
"prettier": "^2.0.0", | ||
"rimraf": "^3.0.0", | ||
"rollup": "^0.57.1", | ||
"rollup-plugin-typescript": "^1.0.1", | ||
"tslib": "^1.10.0", | ||
"typescript": "^3.9.0" | ||
} | ||
} |
@@ -18,24 +18,25 @@ # tween.js | ||
```javascript | ||
const box = document.createElement('div'); | ||
box.style.setProperty('background-color', '#008800'); | ||
box.style.setProperty('width', '100px'); | ||
box.style.setProperty('height', '100px'); | ||
document.body.appendChild(box); | ||
const box = document.createElement('div') | ||
box.style.setProperty('background-color', '#008800') | ||
box.style.setProperty('width', '100px') | ||
box.style.setProperty('height', '100px') | ||
document.body.appendChild(box) | ||
// Setup the animation loop. | ||
function animate(time) { | ||
requestAnimationFrame(animate); | ||
TWEEN.update(time); | ||
requestAnimationFrame(animate) | ||
TWEEN.update(time) | ||
} | ||
requestAnimationFrame(animate); | ||
requestAnimationFrame(animate) | ||
const coords = { x: 0, y: 0 }; // Start at (0, 0) | ||
const coords = {x: 0, y: 0} // Start at (0, 0) | ||
const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'. | ||
.to({ x: 300, y: 200 }, 1000) // Move to (300, 200) in 1 second. | ||
.easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth. | ||
.onUpdate(() => { // Called after tween.js updates 'coords'. | ||
// Move 'box' to the position described by 'coords' with a CSS translation. | ||
box.style.setProperty('transform', `translate(${coords.x}px, ${coords.y}px)`); | ||
}) | ||
.start(); // Start the tween immediately. | ||
.to({x: 300, y: 200}, 1000) // Move to (300, 200) in 1 second. | ||
.easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth. | ||
.onUpdate(() => { | ||
// Called after tween.js updates 'coords'. | ||
// Move 'box' to the position described by 'coords' with a CSS translation. | ||
box.style.setProperty('transform', `translate(${coords.x}px, ${coords.y}px)`) | ||
}) | ||
.start() // Start the tween immediately. | ||
``` | ||
@@ -58,6 +59,6 @@ | ||
- UMD : tween.umd.js | ||
- AMD : tween.amd.js | ||
- CommonJS : tween.cjs.js | ||
- ES6 Module : tween.es.js | ||
- UMD : tween.umd.js | ||
- AMD : tween.amd.js | ||
- CommonJS : tween.cjs.js | ||
- ES6 Module : tween.es.js | ||
@@ -82,3 +83,3 @@ You are now able to copy tween.umd.js into your project, then include it with | ||
```javascript | ||
const TWEEN = require('@tweenjs/tween.js'); | ||
const TWEEN = require('@tweenjs/tween.js') | ||
``` | ||
@@ -88,16 +89,16 @@ | ||
* Does one thing and one thing only: tween properties | ||
* Doesn't take care of CSS units (e.g. appending `px`) | ||
* Doesn't interpolate colours | ||
* Easing functions are reusable outside of Tween | ||
* Can also use custom easing functions | ||
- Does one thing and one thing only: tween properties | ||
- Doesn't take care of CSS units (e.g. appending `px`) | ||
- Doesn't interpolate colours | ||
- Easing functions are reusable outside of Tween | ||
- Can also use custom easing functions | ||
## Documentation | ||
* [User guide](./docs/user_guide.md) | ||
* [Contributor guide](./docs/contributor_guide.md) | ||
* [Tutorial](http://learningthreejs.com/blog/2011/08/17/tweenjs-for-smooth-animation/) using tween.js with three.js | ||
* Also: [libtween](https://github.com/jsm174/libtween), a port of tween.js to C by [jsm174](https://github.com/jsm174) | ||
* Also: [es6-tween](https://github.com/tweenjs/es6-tween), a port of tween.js to ES6/Harmony by [dalisoft](https://github.com/dalisoft) | ||
* [Understanding tween.js](https://mikebolt.me/article/understanding-tweenjs.html) | ||
- [User guide](./docs/user_guide.md) | ||
- [Contributor guide](./docs/contributor_guide.md) | ||
- [Tutorial](http://learningthreejs.com/blog/2011/08/17/tweenjs-for-smooth-animation/) using tween.js with three.js | ||
- Also: [libtween](https://github.com/jsm174/libtween), a port of tween.js to C by [jsm174](https://github.com/jsm174) | ||
- Also: [es6-tween](https://github.com/tweenjs/es6-tween), a port of tween.js to ES6/Harmony by [dalisoft](https://github.com/dalisoft) | ||
- [Understanding tween.js](https://mikebolt.me/article/understanding-tweenjs.html) | ||
@@ -256,3 +257,3 @@ ## Examples | ||
If you want to add any feature or change existing features, you *must* run the tests to make sure you didn't break anything else. If you send a pull request (PR) to add something new and it doesn't have tests, or the tests don't pass, the PR won't be accepted. See [contributing](CONTRIBUTING.md) for more information. | ||
If you want to add any feature or change existing features, you _must_ run the tests to make sure you didn't break anything else. If you send a pull request (PR) to add something new and it doesn't have tests, or the tests don't pass, the PR won't be accepted. See [contributing](CONTRIBUTING.md) for more information. | ||
@@ -288,2 +289,1 @@ ## People | ||
[cdnjs-url]: https://cdnjs.com/libraries/tween.js | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
142874
3401
0
12
8
1