@tweenjs/tween.js 18.6.0 → 18.6.4

Sign up to get free protection for your applications and to get access to all the features.
package/dist/tween.cjs.js CHANGED
@@ -1,794 +1,819 @@
1
1
  'use strict';
2
2
 
3
- var NOW;
4
- // Include a performance.now polyfill.
5
- // In node.js, use process.hrtime.
6
- // eslint-disable-next-line
7
- // @ts-ignore
8
- if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) {
9
- NOW = function () {
10
- // eslint-disable-next-line
11
- // @ts-ignore
12
- var time = process.hrtime();
13
- // Convert [seconds, nanoseconds] to milliseconds.
14
- return time[0] * 1000 + time[1] / 1000000;
15
- };
16
- }
17
- // In a browser, use self.performance.now if it is available.
18
- else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) {
19
- // This must be bound, because directly assigning this function
20
- // leads to an invocation exception in Chrome.
21
- NOW = self.performance.now.bind(self.performance);
22
- }
23
- // Use Date.now if it is available.
24
- else if (Date.now !== undefined) {
25
- NOW = Date.now;
26
- }
27
- // Otherwise, use 'new Date().getTime()'.
28
- else {
29
- NOW = function () {
30
- return new Date().getTime();
31
- };
32
- }
33
- var NOW$1 = NOW;
3
+ Object.defineProperty(exports, '__esModule', { value: true });
34
4
 
35
- /**
36
- * Controlling groups of tweens
37
- *
38
- * Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.
39
- * In these cases, you may want to create your own smaller groups of tween
40
- */
41
- var Group = /** @class */ (function () {
42
- function Group() {
43
- this._tweens = {};
44
- this._tweensAddedDuringUpdate = {};
45
- }
46
- Group.prototype.getAll = function () {
47
- var _this = this;
48
- return Object.keys(this._tweens).map(function (tweenId) {
49
- return _this._tweens[tweenId];
50
- });
51
- };
52
- Group.prototype.removeAll = function () {
53
- this._tweens = {};
54
- };
55
- Group.prototype.add = function (tween) {
56
- this._tweens[tween.getId()] = tween;
57
- this._tweensAddedDuringUpdate[tween.getId()] = tween;
58
- };
59
- Group.prototype.remove = function (tween) {
60
- delete this._tweens[tween.getId()];
61
- delete this._tweensAddedDuringUpdate[tween.getId()];
62
- };
63
- Group.prototype.update = function (time, preserve) {
64
- var tweenIds = Object.keys(this._tweens);
65
- if (tweenIds.length === 0) {
66
- return false;
67
- }
68
- time = time !== undefined ? time : NOW$1();
69
- // Tweens are updated in "batches". If you add a new tween during an
70
- // update, then the new tween will be updated in the next batch.
71
- // If you remove a tween during an update, it may or may not be updated.
72
- // However, if the removed tween was added during the current batch,
73
- // then it will not be updated.
74
- while (tweenIds.length > 0) {
75
- this._tweensAddedDuringUpdate = {};
76
- for (var i = 0; i < tweenIds.length; i++) {
77
- var tween = this._tweens[tweenIds[i]];
78
- if (tween && tween.update(time) === false && !preserve) {
79
- delete this._tweens[tweenIds[i]];
80
- }
81
- }
82
- tweenIds = Object.keys(this._tweensAddedDuringUpdate);
83
- }
84
- return true;
85
- };
86
- return Group;
87
- }());
88
-
89
- /**
90
- * The Ease class provides a collection of easing functions for use with tween.js.
91
- */
92
- var Easing = {
93
- Linear: {
94
- None: function (amount) {
95
- return amount;
96
- },
97
- },
98
- Quadratic: {
99
- In: function (amount) {
100
- return amount * amount;
101
- },
102
- Out: function (amount) {
103
- return amount * (2 - amount);
104
- },
105
- InOut: function (amount) {
106
- if ((amount *= 2) < 1) {
107
- return 0.5 * amount * amount;
108
- }
109
- return -0.5 * (--amount * (amount - 2) - 1);
110
- },
111
- },
112
- Cubic: {
113
- In: function (amount) {
114
- return amount * amount * amount;
115
- },
116
- Out: function (amount) {
117
- return --amount * amount * amount + 1;
118
- },
119
- InOut: function (amount) {
120
- if ((amount *= 2) < 1) {
121
- return 0.5 * amount * amount * amount;
122
- }
123
- return 0.5 * ((amount -= 2) * amount * amount + 2);
124
- },
125
- },
126
- Quartic: {
127
- In: function (amount) {
128
- return amount * amount * amount * amount;
129
- },
130
- Out: function (amount) {
131
- return 1 - --amount * amount * amount * amount;
132
- },
133
- InOut: function (amount) {
134
- if ((amount *= 2) < 1) {
135
- return 0.5 * amount * amount * amount * amount;
136
- }
137
- return -0.5 * ((amount -= 2) * amount * amount * amount - 2);
138
- },
139
- },
140
- Quintic: {
141
- In: function (amount) {
142
- return amount * amount * amount * amount * amount;
143
- },
144
- Out: function (amount) {
145
- return --amount * amount * amount * amount * amount + 1;
146
- },
147
- InOut: function (amount) {
148
- if ((amount *= 2) < 1) {
149
- return 0.5 * amount * amount * amount * amount * amount;
150
- }
151
- return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2);
152
- },
153
- },
154
- Sinusoidal: {
155
- In: function (amount) {
156
- return 1 - Math.cos((amount * Math.PI) / 2);
157
- },
158
- Out: function (amount) {
159
- return Math.sin((amount * Math.PI) / 2);
160
- },
161
- InOut: function (amount) {
162
- return 0.5 * (1 - Math.cos(Math.PI * amount));
163
- },
164
- },
165
- Exponential: {
166
- In: function (amount) {
167
- return amount === 0 ? 0 : Math.pow(1024, amount - 1);
168
- },
169
- Out: function (amount) {
170
- return amount === 1 ? 1 : 1 - Math.pow(2, -10 * amount);
171
- },
172
- InOut: function (amount) {
173
- if (amount === 0) {
174
- return 0;
175
- }
176
- if (amount === 1) {
177
- return 1;
178
- }
179
- if ((amount *= 2) < 1) {
180
- return 0.5 * Math.pow(1024, amount - 1);
181
- }
182
- return 0.5 * (-Math.pow(2, -10 * (amount - 1)) + 2);
183
- },
184
- },
185
- Circular: {
186
- In: function (amount) {
187
- return 1 - Math.sqrt(1 - amount * amount);
188
- },
189
- Out: function (amount) {
190
- return Math.sqrt(1 - --amount * amount);
191
- },
192
- InOut: function (amount) {
193
- if ((amount *= 2) < 1) {
194
- return -0.5 * (Math.sqrt(1 - amount * amount) - 1);
195
- }
196
- return 0.5 * (Math.sqrt(1 - (amount -= 2) * amount) + 1);
197
- },
198
- },
199
- Elastic: {
200
- In: function (amount) {
201
- if (amount === 0) {
202
- return 0;
203
- }
204
- if (amount === 1) {
205
- return 1;
206
- }
207
- return -Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);
208
- },
209
- Out: function (amount) {
210
- if (amount === 0) {
211
- return 0;
212
- }
213
- if (amount === 1) {
214
- return 1;
215
- }
216
- return Math.pow(2, -10 * amount) * Math.sin((amount - 0.1) * 5 * Math.PI) + 1;
217
- },
218
- InOut: function (amount) {
219
- if (amount === 0) {
220
- return 0;
221
- }
222
- if (amount === 1) {
223
- return 1;
224
- }
225
- amount *= 2;
226
- if (amount < 1) {
227
- return -0.5 * Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);
228
- }
229
- return 0.5 * Math.pow(2, -10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI) + 1;
230
- },
231
- },
232
- Back: {
233
- In: function (amount) {
234
- var s = 1.70158;
235
- return amount * amount * ((s + 1) * amount - s);
236
- },
237
- Out: function (amount) {
238
- var s = 1.70158;
239
- return --amount * amount * ((s + 1) * amount + s) + 1;
240
- },
241
- InOut: function (amount) {
242
- var s = 1.70158 * 1.525;
243
- if ((amount *= 2) < 1) {
244
- return 0.5 * (amount * amount * ((s + 1) * amount - s));
245
- }
246
- return 0.5 * ((amount -= 2) * amount * ((s + 1) * amount + s) + 2);
247
- },
248
- },
249
- Bounce: {
250
- In: function (amount) {
251
- return 1 - Easing.Bounce.Out(1 - amount);
252
- },
253
- Out: function (amount) {
254
- if (amount < 1 / 2.75) {
255
- return 7.5625 * amount * amount;
256
- }
257
- else if (amount < 2 / 2.75) {
258
- return 7.5625 * (amount -= 1.5 / 2.75) * amount + 0.75;
259
- }
260
- else if (amount < 2.5 / 2.75) {
261
- return 7.5625 * (amount -= 2.25 / 2.75) * amount + 0.9375;
262
- }
263
- else {
264
- return 7.5625 * (amount -= 2.625 / 2.75) * amount + 0.984375;
265
- }
266
- },
267
- InOut: function (amount) {
268
- if (amount < 0.5) {
269
- return Easing.Bounce.In(amount * 2) * 0.5;
270
- }
271
- return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5;
272
- },
273
- },
5
+ /**
6
+ * The Ease class provides a collection of easing functions for use with tween.js.
7
+ */
8
+ var Easing = {
9
+ Linear: {
10
+ None: function (amount) {
11
+ return amount;
12
+ },
13
+ },
14
+ Quadratic: {
15
+ In: function (amount) {
16
+ return amount * amount;
17
+ },
18
+ Out: function (amount) {
19
+ return amount * (2 - amount);
20
+ },
21
+ InOut: function (amount) {
22
+ if ((amount *= 2) < 1) {
23
+ return 0.5 * amount * amount;
24
+ }
25
+ return -0.5 * (--amount * (amount - 2) - 1);
26
+ },
27
+ },
28
+ Cubic: {
29
+ In: function (amount) {
30
+ return amount * amount * amount;
31
+ },
32
+ Out: function (amount) {
33
+ return --amount * amount * amount + 1;
34
+ },
35
+ InOut: function (amount) {
36
+ if ((amount *= 2) < 1) {
37
+ return 0.5 * amount * amount * amount;
38
+ }
39
+ return 0.5 * ((amount -= 2) * amount * amount + 2);
40
+ },
41
+ },
42
+ Quartic: {
43
+ In: function (amount) {
44
+ return amount * amount * amount * amount;
45
+ },
46
+ Out: function (amount) {
47
+ return 1 - --amount * amount * amount * amount;
48
+ },
49
+ InOut: function (amount) {
50
+ if ((amount *= 2) < 1) {
51
+ return 0.5 * amount * amount * amount * amount;
52
+ }
53
+ return -0.5 * ((amount -= 2) * amount * amount * amount - 2);
54
+ },
55
+ },
56
+ Quintic: {
57
+ In: function (amount) {
58
+ return amount * amount * amount * amount * amount;
59
+ },
60
+ Out: function (amount) {
61
+ return --amount * amount * amount * amount * amount + 1;
62
+ },
63
+ InOut: function (amount) {
64
+ if ((amount *= 2) < 1) {
65
+ return 0.5 * amount * amount * amount * amount * amount;
66
+ }
67
+ return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2);
68
+ },
69
+ },
70
+ Sinusoidal: {
71
+ In: function (amount) {
72
+ return 1 - Math.cos((amount * Math.PI) / 2);
73
+ },
74
+ Out: function (amount) {
75
+ return Math.sin((amount * Math.PI) / 2);
76
+ },
77
+ InOut: function (amount) {
78
+ return 0.5 * (1 - Math.cos(Math.PI * amount));
79
+ },
80
+ },
81
+ Exponential: {
82
+ In: function (amount) {
83
+ return amount === 0 ? 0 : Math.pow(1024, amount - 1);
84
+ },
85
+ Out: function (amount) {
86
+ return amount === 1 ? 1 : 1 - Math.pow(2, -10 * amount);
87
+ },
88
+ InOut: function (amount) {
89
+ if (amount === 0) {
90
+ return 0;
91
+ }
92
+ if (amount === 1) {
93
+ return 1;
94
+ }
95
+ if ((amount *= 2) < 1) {
96
+ return 0.5 * Math.pow(1024, amount - 1);
97
+ }
98
+ return 0.5 * (-Math.pow(2, -10 * (amount - 1)) + 2);
99
+ },
100
+ },
101
+ Circular: {
102
+ In: function (amount) {
103
+ return 1 - Math.sqrt(1 - amount * amount);
104
+ },
105
+ Out: function (amount) {
106
+ return Math.sqrt(1 - --amount * amount);
107
+ },
108
+ InOut: function (amount) {
109
+ if ((amount *= 2) < 1) {
110
+ return -0.5 * (Math.sqrt(1 - amount * amount) - 1);
111
+ }
112
+ return 0.5 * (Math.sqrt(1 - (amount -= 2) * amount) + 1);
113
+ },
114
+ },
115
+ Elastic: {
116
+ In: function (amount) {
117
+ if (amount === 0) {
118
+ return 0;
119
+ }
120
+ if (amount === 1) {
121
+ return 1;
122
+ }
123
+ return -Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);
124
+ },
125
+ Out: function (amount) {
126
+ if (amount === 0) {
127
+ return 0;
128
+ }
129
+ if (amount === 1) {
130
+ return 1;
131
+ }
132
+ return Math.pow(2, -10 * amount) * Math.sin((amount - 0.1) * 5 * Math.PI) + 1;
133
+ },
134
+ InOut: function (amount) {
135
+ if (amount === 0) {
136
+ return 0;
137
+ }
138
+ if (amount === 1) {
139
+ return 1;
140
+ }
141
+ amount *= 2;
142
+ if (amount < 1) {
143
+ return -0.5 * Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);
144
+ }
145
+ return 0.5 * Math.pow(2, -10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI) + 1;
146
+ },
147
+ },
148
+ Back: {
149
+ In: function (amount) {
150
+ var s = 1.70158;
151
+ return amount * amount * ((s + 1) * amount - s);
152
+ },
153
+ Out: function (amount) {
154
+ var s = 1.70158;
155
+ return --amount * amount * ((s + 1) * amount + s) + 1;
156
+ },
157
+ InOut: function (amount) {
158
+ var s = 1.70158 * 1.525;
159
+ if ((amount *= 2) < 1) {
160
+ return 0.5 * (amount * amount * ((s + 1) * amount - s));
161
+ }
162
+ return 0.5 * ((amount -= 2) * amount * ((s + 1) * amount + s) + 2);
163
+ },
164
+ },
165
+ Bounce: {
166
+ In: function (amount) {
167
+ return 1 - Easing.Bounce.Out(1 - amount);
168
+ },
169
+ Out: function (amount) {
170
+ if (amount < 1 / 2.75) {
171
+ return 7.5625 * amount * amount;
172
+ }
173
+ else if (amount < 2 / 2.75) {
174
+ return 7.5625 * (amount -= 1.5 / 2.75) * amount + 0.75;
175
+ }
176
+ else if (amount < 2.5 / 2.75) {
177
+ return 7.5625 * (amount -= 2.25 / 2.75) * amount + 0.9375;
178
+ }
179
+ else {
180
+ return 7.5625 * (amount -= 2.625 / 2.75) * amount + 0.984375;
181
+ }
182
+ },
183
+ InOut: function (amount) {
184
+ if (amount < 0.5) {
185
+ return Easing.Bounce.In(amount * 2) * 0.5;
186
+ }
187
+ return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5;
188
+ },
189
+ },
274
190
  };
275
191
 
276
- /**
277
- *
278
- */
279
- var Interpolation = {
280
- Linear: function (v, k) {
281
- var m = v.length - 1;
282
- var f = m * k;
283
- var i = Math.floor(f);
284
- var fn = Interpolation.Utils.Linear;
285
- if (k < 0) {
286
- return fn(v[0], v[1], f);
287
- }
288
- if (k > 1) {
289
- return fn(v[m], v[m - 1], m - f);
290
- }
291
- return fn(v[i], v[i + 1 > m ? m : i + 1], f - i);
292
- },
293
- Bezier: function (v, k) {
294
- var b = 0;
295
- var n = v.length - 1;
296
- var pw = Math.pow;
297
- var bn = Interpolation.Utils.Bernstein;
298
- for (var i = 0; i <= n; i++) {
299
- b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i);
300
- }
301
- return b;
302
- },
303
- CatmullRom: function (v, k) {
304
- var m = v.length - 1;
305
- var f = m * k;
306
- var i = Math.floor(f);
307
- var fn = Interpolation.Utils.CatmullRom;
308
- if (v[0] === v[m]) {
309
- if (k < 0) {
310
- i = Math.floor((f = m * (1 + k)));
311
- }
312
- return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i);
313
- }
314
- else {
315
- if (k < 0) {
316
- return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]);
317
- }
318
- if (k > 1) {
319
- return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]);
320
- }
321
- 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);
322
- }
323
- },
324
- Utils: {
325
- Linear: function (p0, p1, t) {
326
- return (p1 - p0) * t + p0;
327
- },
328
- Bernstein: function (n, i) {
329
- var fc = Interpolation.Utils.Factorial;
330
- return fc(n) / fc(i) / fc(n - i);
331
- },
332
- Factorial: (function () {
333
- var a = [1];
334
- return function (n) {
335
- var s = 1;
336
- if (a[n]) {
337
- return a[n];
338
- }
339
- for (var i = n; i > 1; i--) {
340
- s *= i;
341
- }
342
- a[n] = s;
343
- return s;
344
- };
345
- })(),
346
- CatmullRom: function (p0, p1, p2, p3, t) {
347
- var v0 = (p2 - p0) * 0.5;
348
- var v1 = (p3 - p1) * 0.5;
349
- var t2 = t * t;
350
- var t3 = t * t2;
351
- return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
352
- },
353
- },
192
+ var now;
193
+ // Include a performance.now polyfill.
194
+ // In node.js, use process.hrtime.
195
+ // eslint-disable-next-line
196
+ // @ts-ignore
197
+ if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) {
198
+ now = function () {
199
+ // eslint-disable-next-line
200
+ // @ts-ignore
201
+ var time = process.hrtime();
202
+ // Convert [seconds, nanoseconds] to milliseconds.
203
+ return time[0] * 1000 + time[1] / 1000000;
204
+ };
205
+ }
206
+ // In a browser, use self.performance.now if it is available.
207
+ else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) {
208
+ // This must be bound, because directly assigning this function
209
+ // leads to an invocation exception in Chrome.
210
+ now = self.performance.now.bind(self.performance);
211
+ }
212
+ // Use Date.now if it is available.
213
+ else if (Date.now !== undefined) {
214
+ now = Date.now;
215
+ }
216
+ // Otherwise, use 'new Date().getTime()'.
217
+ else {
218
+ now = function () {
219
+ return new Date().getTime();
220
+ };
221
+ }
222
+ var now$1 = now;
223
+
224
+ /**
225
+ * Controlling groups of tweens
226
+ *
227
+ * Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.
228
+ * In these cases, you may want to create your own smaller groups of tween
229
+ */
230
+ var Group = /** @class */ (function () {
231
+ function Group() {
232
+ this._tweens = {};
233
+ this._tweensAddedDuringUpdate = {};
234
+ }
235
+ Group.prototype.getAll = function () {
236
+ var _this = this;
237
+ return Object.keys(this._tweens).map(function (tweenId) {
238
+ return _this._tweens[tweenId];
239
+ });
240
+ };
241
+ Group.prototype.removeAll = function () {
242
+ this._tweens = {};
243
+ };
244
+ Group.prototype.add = function (tween) {
245
+ this._tweens[tween.getId()] = tween;
246
+ this._tweensAddedDuringUpdate[tween.getId()] = tween;
247
+ };
248
+ Group.prototype.remove = function (tween) {
249
+ delete this._tweens[tween.getId()];
250
+ delete this._tweensAddedDuringUpdate[tween.getId()];
251
+ };
252
+ Group.prototype.update = function (time, preserve) {
253
+ if (time === void 0) { time = now$1(); }
254
+ if (preserve === void 0) { preserve = false; }
255
+ var tweenIds = Object.keys(this._tweens);
256
+ if (tweenIds.length === 0) {
257
+ return false;
258
+ }
259
+ // Tweens are updated in "batches". If you add a new tween during an
260
+ // update, then the new tween will be updated in the next batch.
261
+ // If you remove a tween during an update, it may or may not be updated.
262
+ // However, if the removed tween was added during the current batch,
263
+ // then it will not be updated.
264
+ while (tweenIds.length > 0) {
265
+ this._tweensAddedDuringUpdate = {};
266
+ for (var i = 0; i < tweenIds.length; i++) {
267
+ var tween = this._tweens[tweenIds[i]];
268
+ var autoStart = !preserve;
269
+ if (tween && tween.update(time, autoStart) === false && !preserve) {
270
+ delete this._tweens[tweenIds[i]];
271
+ }
272
+ }
273
+ tweenIds = Object.keys(this._tweensAddedDuringUpdate);
274
+ }
275
+ return true;
276
+ };
277
+ return Group;
278
+ }());
279
+
280
+ /**
281
+ *
282
+ */
283
+ var Interpolation = {
284
+ Linear: function (v, k) {
285
+ var m = v.length - 1;
286
+ var f = m * k;
287
+ var i = Math.floor(f);
288
+ var fn = Interpolation.Utils.Linear;
289
+ if (k < 0) {
290
+ return fn(v[0], v[1], f);
291
+ }
292
+ if (k > 1) {
293
+ return fn(v[m], v[m - 1], m - f);
294
+ }
295
+ return fn(v[i], v[i + 1 > m ? m : i + 1], f - i);
296
+ },
297
+ Bezier: function (v, k) {
298
+ var b = 0;
299
+ var n = v.length - 1;
300
+ var pw = Math.pow;
301
+ var bn = Interpolation.Utils.Bernstein;
302
+ for (var i = 0; i <= n; i++) {
303
+ b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i);
304
+ }
305
+ return b;
306
+ },
307
+ CatmullRom: function (v, k) {
308
+ var m = v.length - 1;
309
+ var f = m * k;
310
+ var i = Math.floor(f);
311
+ var fn = Interpolation.Utils.CatmullRom;
312
+ if (v[0] === v[m]) {
313
+ if (k < 0) {
314
+ i = Math.floor((f = m * (1 + k)));
315
+ }
316
+ return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i);
317
+ }
318
+ else {
319
+ if (k < 0) {
320
+ return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]);
321
+ }
322
+ if (k > 1) {
323
+ return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]);
324
+ }
325
+ 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);
326
+ }
327
+ },
328
+ Utils: {
329
+ Linear: function (p0, p1, t) {
330
+ return (p1 - p0) * t + p0;
331
+ },
332
+ Bernstein: function (n, i) {
333
+ var fc = Interpolation.Utils.Factorial;
334
+ return fc(n) / fc(i) / fc(n - i);
335
+ },
336
+ Factorial: (function () {
337
+ var a = [1];
338
+ return function (n) {
339
+ var s = 1;
340
+ if (a[n]) {
341
+ return a[n];
342
+ }
343
+ for (var i = n; i > 1; i--) {
344
+ s *= i;
345
+ }
346
+ a[n] = s;
347
+ return s;
348
+ };
349
+ })(),
350
+ CatmullRom: function (p0, p1, p2, p3, t) {
351
+ var v0 = (p2 - p0) * 0.5;
352
+ var v1 = (p3 - p1) * 0.5;
353
+ var t2 = t * t;
354
+ var t3 = t * t2;
355
+ return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
356
+ },
357
+ },
354
358
  };
355
359
 
356
- /**
357
- * Utils
358
- */
359
- var Sequence = /** @class */ (function () {
360
- function Sequence() {
361
- }
362
- Sequence.nextId = function () {
363
- return Sequence._nextId++;
364
- };
365
- Sequence._nextId = 0;
366
- return Sequence;
360
+ /**
361
+ * Utils
362
+ */
363
+ var Sequence = /** @class */ (function () {
364
+ function Sequence() {
365
+ }
366
+ Sequence.nextId = function () {
367
+ return Sequence._nextId++;
368
+ };
369
+ Sequence._nextId = 0;
370
+ return Sequence;
367
371
  }());
368
372
 
369
- /**
370
- * Tween.js - Licensed under the MIT license
371
- * https://github.com/tweenjs/tween.js
372
- * ----------------------------------------------
373
- *
374
- * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
375
- * Thank you all, you're awesome!
376
- */
377
- var Tween = /** @class */ (function () {
378
- function Tween(_object, _group) {
379
- if (_group === void 0) { _group = TWEEN; }
380
- this._object = _object;
381
- this._group = _group;
382
- this._isPaused = false;
383
- this._pauseStart = 0;
384
- this._valuesStart = {};
385
- this._valuesEnd = {};
386
- this._valuesStartRepeat = {};
387
- this._duration = 1000;
388
- this._initialRepeat = 0;
389
- this._repeat = 0;
390
- this._yoyo = false;
391
- this._isPlaying = false;
392
- this._reversed = false;
393
- this._delayTime = 0;
394
- this._startTime = 0;
395
- this._easingFunction = TWEEN.Easing.Linear.None;
396
- this._interpolationFunction = TWEEN.Interpolation.Linear;
397
- this._chainedTweens = [];
398
- this._onStartCallbackFired = false;
399
- this._id = TWEEN.nextId();
400
- this._isChainStopped = false;
401
- }
402
- Tween.prototype.getId = function () {
403
- return this._id;
404
- };
405
- Tween.prototype.isPlaying = function () {
406
- return this._isPlaying;
407
- };
408
- Tween.prototype.isPaused = function () {
409
- return this._isPaused;
410
- };
411
- Tween.prototype.to = function (properties, duration) {
412
- for (var prop in properties) {
413
- this._valuesEnd[prop] = properties[prop];
414
- }
415
- if (duration !== undefined) {
416
- this._duration = duration;
417
- }
418
- return this;
419
- };
420
- Tween.prototype.duration = function (d) {
421
- this._duration = d;
422
- return this;
423
- };
424
- Tween.prototype.start = function (time) {
425
- if (this._isPlaying) {
426
- return this;
427
- }
428
- // eslint-disable-next-line
429
- // @ts-ignore FIXME?
430
- this._group.add(this);
431
- this._repeat = this._initialRepeat;
432
- if (this._reversed) {
433
- // If we were reversed (f.e. using the yoyo feature) then we need to
434
- // flip the tween direction back to forward.
435
- this._reversed = false;
436
- for (var property in this._valuesStartRepeat) {
437
- this._swapEndStartRepeatValues(property);
438
- this._valuesStart[property] = this._valuesStartRepeat[property];
439
- }
440
- }
441
- this._isPlaying = true;
442
- this._isPaused = false;
443
- this._onStartCallbackFired = false;
444
- this._isChainStopped = false;
445
- this._startTime =
446
- time !== undefined ? (typeof time === 'string' ? TWEEN.now() + parseFloat(time) : time) : TWEEN.now();
447
- this._startTime += this._delayTime;
448
- this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat);
449
- return this;
450
- };
451
- Tween.prototype._setupProperties = function (_object, _valuesStart, _valuesEnd, _valuesStartRepeat) {
452
- for (var property in _valuesEnd) {
453
- var startValue = _object[property];
454
- var startValueIsArray = Array.isArray(startValue);
455
- var propType = startValueIsArray ? 'array' : typeof startValue;
456
- var isInterpolationList = !startValueIsArray && Array.isArray(_valuesEnd[property]);
457
- // If `to()` specifies a property that doesn't exist in the source object,
458
- // we should not set that property in the object
459
- if (propType === 'undefined' || propType === 'function') {
460
- continue;
461
- }
462
- // Check if an Array was provided as property value
463
- if (isInterpolationList) {
464
- var endValues = _valuesEnd[property];
465
- if (endValues.length === 0) {
466
- continue;
467
- }
468
- // handle an array of relative values
469
- endValues = endValues.map(this._handleRelativeValue.bind(this, startValue));
470
- // Create a local copy of the Array with the start value at the front
471
- _valuesEnd[property] = [startValue].concat(endValues);
472
- }
473
- // handle the deepness of the values
474
- if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) {
475
- _valuesStart[property] = startValueIsArray ? [] : {};
476
- // eslint-disable-next-line
477
- for (var prop in startValue) {
478
- // eslint-disable-next-line
479
- // @ts-ignore FIXME?
480
- _valuesStart[property][prop] = startValue[prop];
481
- }
482
- _valuesStartRepeat[property] = startValueIsArray ? [] : {}; // TODO? repeat nested values? And yoyo? And array values?
483
- // eslint-disable-next-line
484
- // @ts-ignore FIXME?
485
- this._setupProperties(startValue, _valuesStart[property], _valuesEnd[property], _valuesStartRepeat[property]);
486
- }
487
- else {
488
- // Save the starting value, but only once.
489
- if (typeof _valuesStart[property] === 'undefined') {
490
- _valuesStart[property] = startValue;
491
- }
492
- if (!startValueIsArray) {
493
- // eslint-disable-next-line
494
- // @ts-ignore FIXME?
495
- _valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings
496
- }
497
- if (isInterpolationList) {
498
- // eslint-disable-next-line
499
- // @ts-ignore FIXME?
500
- _valuesStartRepeat[property] = _valuesEnd[property].slice().reverse();
501
- }
502
- else {
503
- _valuesStartRepeat[property] = _valuesStart[property] || 0;
504
- }
505
- }
506
- }
507
- };
508
- Tween.prototype.stop = function () {
509
- if (!this._isChainStopped) {
510
- this._isChainStopped = true;
511
- this.stopChainedTweens();
512
- }
513
- if (!this._isPlaying) {
514
- return this;
515
- }
516
- // eslint-disable-next-line
517
- // @ts-ignore FIXME?
518
- this._group.remove(this);
519
- this._isPlaying = false;
520
- this._isPaused = false;
521
- if (this._onStopCallback) {
522
- this._onStopCallback(this._object);
523
- }
524
- return this;
525
- };
526
- Tween.prototype.end = function () {
527
- this.update(Infinity);
528
- return this;
529
- };
530
- Tween.prototype.pause = function (time) {
531
- if (this._isPaused || !this._isPlaying) {
532
- return this;
533
- }
534
- this._isPaused = true;
535
- this._pauseStart = time === undefined ? TWEEN.now() : time;
536
- // eslint-disable-next-line
537
- // @ts-ignore FIXME?
538
- this._group.remove(this);
539
- return this;
540
- };
541
- Tween.prototype.resume = function (time) {
542
- if (!this._isPaused || !this._isPlaying) {
543
- return this;
544
- }
545
- this._isPaused = false;
546
- this._startTime += (time === undefined ? TWEEN.now() : time) - this._pauseStart;
547
- this._pauseStart = 0;
548
- // eslint-disable-next-line
549
- // @ts-ignore FIXME?
550
- this._group.add(this);
551
- return this;
552
- };
553
- Tween.prototype.stopChainedTweens = function () {
554
- for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
555
- this._chainedTweens[i].stop();
556
- }
557
- return this;
558
- };
559
- Tween.prototype.group = function (group) {
560
- this._group = group;
561
- return this;
562
- };
563
- Tween.prototype.delay = function (amount) {
564
- this._delayTime = amount;
565
- return this;
566
- };
567
- Tween.prototype.repeat = function (times) {
568
- this._initialRepeat = times;
569
- this._repeat = times;
570
- return this;
571
- };
572
- Tween.prototype.repeatDelay = function (amount) {
573
- this._repeatDelayTime = amount;
574
- return this;
575
- };
576
- Tween.prototype.yoyo = function (yoyo) {
577
- this._yoyo = yoyo;
578
- return this;
579
- };
580
- Tween.prototype.easing = function (easingFunction) {
581
- this._easingFunction = easingFunction;
582
- return this;
583
- };
584
- Tween.prototype.interpolation = function (interpolationFunction) {
585
- this._interpolationFunction = interpolationFunction;
586
- return this;
587
- };
588
- Tween.prototype.chain = function () {
589
- var tweens = [];
590
- for (var _i = 0; _i < arguments.length; _i++) {
591
- tweens[_i] = arguments[_i];
592
- }
593
- this._chainedTweens = tweens;
594
- return this;
595
- };
596
- Tween.prototype.onStart = function (callback) {
597
- this._onStartCallback = callback;
598
- return this;
599
- };
600
- Tween.prototype.onUpdate = function (callback) {
601
- this._onUpdateCallback = callback;
602
- return this;
603
- };
604
- Tween.prototype.onRepeat = function (callback) {
605
- this._onRepeatCallback = callback;
606
- return this;
607
- };
608
- Tween.prototype.onComplete = function (callback) {
609
- this._onCompleteCallback = callback;
610
- return this;
611
- };
612
- Tween.prototype.onStop = function (callback) {
613
- this._onStopCallback = callback;
614
- return this;
615
- };
616
- Tween.prototype.update = function (time) {
617
- var property;
618
- var elapsed;
619
- var endTime = this._startTime + this._duration;
620
- if (time > endTime && !this._isPlaying) {
621
- return false;
622
- }
623
- // If the tween was already finished,
624
- if (!this.isPlaying) {
625
- this.start(time);
626
- }
627
- if (time < this._startTime) {
628
- return true;
629
- }
630
- if (this._onStartCallbackFired === false) {
631
- if (this._onStartCallback) {
632
- this._onStartCallback(this._object);
633
- }
634
- this._onStartCallbackFired = true;
635
- }
636
- elapsed = (time - this._startTime) / this._duration;
637
- elapsed = this._duration === 0 || elapsed > 1 ? 1 : elapsed;
638
- var value = this._easingFunction(elapsed);
639
- // properties transformations
640
- this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value);
641
- if (this._onUpdateCallback) {
642
- this._onUpdateCallback(this._object, elapsed);
643
- }
644
- if (elapsed === 1) {
645
- if (this._repeat > 0) {
646
- if (isFinite(this._repeat)) {
647
- this._repeat--;
648
- }
649
- // Reassign starting values, restart by making startTime = now
650
- for (property in this._valuesStartRepeat) {
651
- if (!this._yoyo && typeof this._valuesEnd[property] === 'string') {
652
- this._valuesStartRepeat[property] =
653
- // eslint-disable-next-line
654
- // @ts-ignore FIXME?
655
- this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]);
656
- }
657
- if (this._yoyo) {
658
- this._swapEndStartRepeatValues(property);
659
- }
660
- this._valuesStart[property] = this._valuesStartRepeat[property];
661
- }
662
- if (this._yoyo) {
663
- this._reversed = !this._reversed;
664
- }
665
- if (this._repeatDelayTime !== undefined) {
666
- this._startTime = time + this._repeatDelayTime;
667
- }
668
- else {
669
- this._startTime = time + this._delayTime;
670
- }
671
- if (this._onRepeatCallback) {
672
- this._onRepeatCallback(this._object);
673
- }
674
- return true;
675
- }
676
- else {
677
- if (this._onCompleteCallback) {
678
- this._onCompleteCallback(this._object);
679
- }
680
- for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
681
- // Make the chained tweens start exactly at the time they should,
682
- // even if the `update()` method was called way past the duration of the tween
683
- this._chainedTweens[i].start(this._startTime + this._duration);
684
- }
685
- this._isPlaying = false;
686
- return false;
687
- }
688
- }
689
- return true;
690
- };
691
- Tween.prototype._updateProperties = function (_object, _valuesStart, _valuesEnd, value) {
692
- for (var property in _valuesEnd) {
693
- // Don't update properties that do not exist in the source object
694
- if (_valuesStart[property] === undefined) {
695
- continue;
696
- }
697
- var start = _valuesStart[property] || 0;
698
- var end = _valuesEnd[property];
699
- var startIsArray = Array.isArray(_object[property]);
700
- var endIsArray = Array.isArray(end);
701
- var isInterpolationList = !startIsArray && endIsArray;
702
- if (isInterpolationList) {
703
- _object[property] = this._interpolationFunction(end, value);
704
- }
705
- else if (typeof end === 'object' && end) {
706
- // eslint-disable-next-line
707
- // @ts-ignore FIXME?
708
- this._updateProperties(_object[property], start, end, value);
709
- }
710
- else {
711
- // Parses relative end values with start as base (e.g.: +10, -3)
712
- end = this._handleRelativeValue(start, end);
713
- // Protect against non numeric properties.
714
- if (typeof end === 'number') {
715
- // eslint-disable-next-line
716
- // @ts-ignore FIXME?
717
- _object[property] = start + (end - start) * value;
718
- }
719
- }
720
- }
721
- };
722
- Tween.prototype._handleRelativeValue = function (start, end) {
723
- if (typeof end !== 'string') {
724
- return end;
725
- }
726
- if (end.charAt(0) === '+' || end.charAt(0) === '-') {
727
- return start + parseFloat(end);
728
- }
729
- else {
730
- return parseFloat(end);
731
- }
732
- };
733
- Tween.prototype._swapEndStartRepeatValues = function (property) {
734
- var tmp = this._valuesStartRepeat[property];
735
- if (typeof this._valuesEnd[property] === 'string') {
736
- // eslint-disable-next-line
737
- // @ts-ignore FIXME?
738
- this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]);
739
- }
740
- else {
741
- this._valuesStartRepeat[property] = this._valuesEnd[property];
742
- }
743
- this._valuesEnd[property] = tmp;
744
- };
745
- return Tween;
373
+ var mainGroup = new Group();
374
+
375
+ /**
376
+ * Tween.js - Licensed under the MIT license
377
+ * https://github.com/tweenjs/tween.js
378
+ * ----------------------------------------------
379
+ *
380
+ * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
381
+ * Thank you all, you're awesome!
382
+ */
383
+ var Tween = /** @class */ (function () {
384
+ function Tween(_object, _group) {
385
+ if (_group === void 0) { _group = mainGroup; }
386
+ this._object = _object;
387
+ this._group = _group;
388
+ this._isPaused = false;
389
+ this._pauseStart = 0;
390
+ this._valuesStart = {};
391
+ this._valuesEnd = {};
392
+ this._valuesStartRepeat = {};
393
+ this._duration = 1000;
394
+ this._initialRepeat = 0;
395
+ this._repeat = 0;
396
+ this._yoyo = false;
397
+ this._isPlaying = false;
398
+ this._reversed = false;
399
+ this._delayTime = 0;
400
+ this._startTime = 0;
401
+ this._easingFunction = Easing.Linear.None;
402
+ this._interpolationFunction = Interpolation.Linear;
403
+ this._chainedTweens = [];
404
+ this._onStartCallbackFired = false;
405
+ this._id = Sequence.nextId();
406
+ this._isChainStopped = false;
407
+ this._goToEnd = false;
408
+ }
409
+ Tween.prototype.getId = function () {
410
+ return this._id;
411
+ };
412
+ Tween.prototype.isPlaying = function () {
413
+ return this._isPlaying;
414
+ };
415
+ Tween.prototype.isPaused = function () {
416
+ return this._isPaused;
417
+ };
418
+ Tween.prototype.to = function (properties, duration) {
419
+ // TODO? restore this, then update the 07_dynamic_to example to set fox
420
+ // tween's to on each update. That way the behavior is opt-in (there's
421
+ // currently no opt-out).
422
+ // for (const prop in properties) this._valuesEnd[prop] = properties[prop]
423
+ this._valuesEnd = Object.create(properties);
424
+ if (duration !== undefined) {
425
+ this._duration = duration;
426
+ }
427
+ return this;
428
+ };
429
+ Tween.prototype.duration = function (d) {
430
+ this._duration = d;
431
+ return this;
432
+ };
433
+ Tween.prototype.start = function (time) {
434
+ if (this._isPlaying) {
435
+ return this;
436
+ }
437
+ // eslint-disable-next-line
438
+ this._group && this._group.add(this);
439
+ this._repeat = this._initialRepeat;
440
+ if (this._reversed) {
441
+ // If we were reversed (f.e. using the yoyo feature) then we need to
442
+ // flip the tween direction back to forward.
443
+ this._reversed = false;
444
+ for (var property in this._valuesStartRepeat) {
445
+ this._swapEndStartRepeatValues(property);
446
+ this._valuesStart[property] = this._valuesStartRepeat[property];
447
+ }
448
+ }
449
+ this._isPlaying = true;
450
+ this._isPaused = false;
451
+ this._onStartCallbackFired = false;
452
+ this._isChainStopped = false;
453
+ this._startTime = time !== undefined ? (typeof time === 'string' ? now$1() + parseFloat(time) : time) : now$1();
454
+ this._startTime += this._delayTime;
455
+ this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat);
456
+ return this;
457
+ };
458
+ Tween.prototype._setupProperties = function (_object, _valuesStart, _valuesEnd, _valuesStartRepeat) {
459
+ for (var property in _valuesEnd) {
460
+ var startValue = _object[property];
461
+ var startValueIsArray = Array.isArray(startValue);
462
+ var propType = startValueIsArray ? 'array' : typeof startValue;
463
+ var isInterpolationList = !startValueIsArray && Array.isArray(_valuesEnd[property]);
464
+ // If `to()` specifies a property that doesn't exist in the source object,
465
+ // we should not set that property in the object
466
+ if (propType === 'undefined' || propType === 'function') {
467
+ continue;
468
+ }
469
+ // Check if an Array was provided as property value
470
+ if (isInterpolationList) {
471
+ var endValues = _valuesEnd[property];
472
+ if (endValues.length === 0) {
473
+ continue;
474
+ }
475
+ // handle an array of relative values
476
+ endValues = endValues.map(this._handleRelativeValue.bind(this, startValue));
477
+ // Create a local copy of the Array with the start value at the front
478
+ _valuesEnd[property] = [startValue].concat(endValues);
479
+ }
480
+ // handle the deepness of the values
481
+ if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) {
482
+ _valuesStart[property] = startValueIsArray ? [] : {};
483
+ // eslint-disable-next-line
484
+ for (var prop in startValue) {
485
+ // eslint-disable-next-line
486
+ // @ts-ignore FIXME?
487
+ _valuesStart[property][prop] = startValue[prop];
488
+ }
489
+ _valuesStartRepeat[property] = startValueIsArray ? [] : {}; // TODO? repeat nested values? And yoyo? And array values?
490
+ // eslint-disable-next-line
491
+ // @ts-ignore FIXME?
492
+ this._setupProperties(startValue, _valuesStart[property], _valuesEnd[property], _valuesStartRepeat[property]);
493
+ }
494
+ else {
495
+ // Save the starting value, but only once.
496
+ if (typeof _valuesStart[property] === 'undefined') {
497
+ _valuesStart[property] = startValue;
498
+ }
499
+ if (!startValueIsArray) {
500
+ // eslint-disable-next-line
501
+ // @ts-ignore FIXME?
502
+ _valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings
503
+ }
504
+ if (isInterpolationList) {
505
+ // eslint-disable-next-line
506
+ // @ts-ignore FIXME?
507
+ _valuesStartRepeat[property] = _valuesEnd[property].slice().reverse();
508
+ }
509
+ else {
510
+ _valuesStartRepeat[property] = _valuesStart[property] || 0;
511
+ }
512
+ }
513
+ }
514
+ };
515
+ Tween.prototype.stop = function () {
516
+ if (!this._isChainStopped) {
517
+ this._isChainStopped = true;
518
+ this.stopChainedTweens();
519
+ }
520
+ if (!this._isPlaying) {
521
+ return this;
522
+ }
523
+ // eslint-disable-next-line
524
+ this._group && this._group.remove(this);
525
+ this._isPlaying = false;
526
+ this._isPaused = false;
527
+ if (this._onStopCallback) {
528
+ this._onStopCallback(this._object);
529
+ }
530
+ return this;
531
+ };
532
+ Tween.prototype.end = function () {
533
+ this._goToEnd = true;
534
+ this.update(Infinity);
535
+ return this;
536
+ };
537
+ Tween.prototype.pause = function (time) {
538
+ if (time === void 0) { time = now$1(); }
539
+ if (this._isPaused || !this._isPlaying) {
540
+ return this;
541
+ }
542
+ this._isPaused = true;
543
+ this._pauseStart = time;
544
+ // eslint-disable-next-line
545
+ this._group && this._group.remove(this);
546
+ return this;
547
+ };
548
+ Tween.prototype.resume = function (time) {
549
+ if (time === void 0) { time = now$1(); }
550
+ if (!this._isPaused || !this._isPlaying) {
551
+ return this;
552
+ }
553
+ this._isPaused = false;
554
+ this._startTime += time - this._pauseStart;
555
+ this._pauseStart = 0;
556
+ // eslint-disable-next-line
557
+ this._group && this._group.add(this);
558
+ return this;
559
+ };
560
+ Tween.prototype.stopChainedTweens = function () {
561
+ for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
562
+ this._chainedTweens[i].stop();
563
+ }
564
+ return this;
565
+ };
566
+ Tween.prototype.group = function (group) {
567
+ this._group = group;
568
+ return this;
569
+ };
570
+ Tween.prototype.delay = function (amount) {
571
+ this._delayTime = amount;
572
+ return this;
573
+ };
574
+ Tween.prototype.repeat = function (times) {
575
+ this._initialRepeat = times;
576
+ this._repeat = times;
577
+ return this;
578
+ };
579
+ Tween.prototype.repeatDelay = function (amount) {
580
+ this._repeatDelayTime = amount;
581
+ return this;
582
+ };
583
+ Tween.prototype.yoyo = function (yoyo) {
584
+ this._yoyo = yoyo;
585
+ return this;
586
+ };
587
+ Tween.prototype.easing = function (easingFunction) {
588
+ this._easingFunction = easingFunction;
589
+ return this;
590
+ };
591
+ Tween.prototype.interpolation = function (interpolationFunction) {
592
+ this._interpolationFunction = interpolationFunction;
593
+ return this;
594
+ };
595
+ Tween.prototype.chain = function () {
596
+ var tweens = [];
597
+ for (var _i = 0; _i < arguments.length; _i++) {
598
+ tweens[_i] = arguments[_i];
599
+ }
600
+ this._chainedTweens = tweens;
601
+ return this;
602
+ };
603
+ Tween.prototype.onStart = function (callback) {
604
+ this._onStartCallback = callback;
605
+ return this;
606
+ };
607
+ Tween.prototype.onUpdate = function (callback) {
608
+ this._onUpdateCallback = callback;
609
+ return this;
610
+ };
611
+ Tween.prototype.onRepeat = function (callback) {
612
+ this._onRepeatCallback = callback;
613
+ return this;
614
+ };
615
+ Tween.prototype.onComplete = function (callback) {
616
+ this._onCompleteCallback = callback;
617
+ return this;
618
+ };
619
+ Tween.prototype.onStop = function (callback) {
620
+ this._onStopCallback = callback;
621
+ return this;
622
+ };
623
+ /**
624
+ * @returns true if the tween is still playing after the update, false
625
+ * otherwise (calling update on a paused tween still returns true because
626
+ * it is still playing, just paused).
627
+ */
628
+ Tween.prototype.update = function (time, autoStart) {
629
+ if (time === void 0) { time = now$1(); }
630
+ if (autoStart === void 0) { autoStart = true; }
631
+ if (this._isPaused)
632
+ return true;
633
+ var property;
634
+ var elapsed;
635
+ var endTime = this._startTime + this._duration;
636
+ if (!this._goToEnd && !this._isPlaying) {
637
+ if (time > endTime)
638
+ return false;
639
+ if (autoStart)
640
+ this.start(time);
641
+ }
642
+ this._goToEnd = false;
643
+ if (time < this._startTime) {
644
+ return true;
645
+ }
646
+ if (this._onStartCallbackFired === false) {
647
+ if (this._onStartCallback) {
648
+ this._onStartCallback(this._object);
649
+ }
650
+ this._onStartCallbackFired = true;
651
+ }
652
+ elapsed = (time - this._startTime) / this._duration;
653
+ elapsed = this._duration === 0 || elapsed > 1 ? 1 : elapsed;
654
+ var value = this._easingFunction(elapsed);
655
+ // properties transformations
656
+ this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value);
657
+ if (this._onUpdateCallback) {
658
+ this._onUpdateCallback(this._object, elapsed);
659
+ }
660
+ if (elapsed === 1) {
661
+ if (this._repeat > 0) {
662
+ if (isFinite(this._repeat)) {
663
+ this._repeat--;
664
+ }
665
+ // Reassign starting values, restart by making startTime = now
666
+ for (property in this._valuesStartRepeat) {
667
+ if (!this._yoyo && typeof this._valuesEnd[property] === 'string') {
668
+ this._valuesStartRepeat[property] =
669
+ // eslint-disable-next-line
670
+ // @ts-ignore FIXME?
671
+ this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]);
672
+ }
673
+ if (this._yoyo) {
674
+ this._swapEndStartRepeatValues(property);
675
+ }
676
+ this._valuesStart[property] = this._valuesStartRepeat[property];
677
+ }
678
+ if (this._yoyo) {
679
+ this._reversed = !this._reversed;
680
+ }
681
+ if (this._repeatDelayTime !== undefined) {
682
+ this._startTime = time + this._repeatDelayTime;
683
+ }
684
+ else {
685
+ this._startTime = time + this._delayTime;
686
+ }
687
+ if (this._onRepeatCallback) {
688
+ this._onRepeatCallback(this._object);
689
+ }
690
+ return true;
691
+ }
692
+ else {
693
+ if (this._onCompleteCallback) {
694
+ this._onCompleteCallback(this._object);
695
+ }
696
+ for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
697
+ // Make the chained tweens start exactly at the time they should,
698
+ // even if the `update()` method was called way past the duration of the tween
699
+ this._chainedTweens[i].start(this._startTime + this._duration);
700
+ }
701
+ this._isPlaying = false;
702
+ return false;
703
+ }
704
+ }
705
+ return true;
706
+ };
707
+ Tween.prototype._updateProperties = function (_object, _valuesStart, _valuesEnd, value) {
708
+ for (var property in _valuesEnd) {
709
+ // Don't update properties that do not exist in the source object
710
+ if (_valuesStart[property] === undefined) {
711
+ continue;
712
+ }
713
+ var start = _valuesStart[property] || 0;
714
+ var end = _valuesEnd[property];
715
+ var startIsArray = Array.isArray(_object[property]);
716
+ var endIsArray = Array.isArray(end);
717
+ var isInterpolationList = !startIsArray && endIsArray;
718
+ if (isInterpolationList) {
719
+ _object[property] = this._interpolationFunction(end, value);
720
+ }
721
+ else if (typeof end === 'object' && end) {
722
+ // eslint-disable-next-line
723
+ // @ts-ignore FIXME?
724
+ this._updateProperties(_object[property], start, end, value);
725
+ }
726
+ else {
727
+ // Parses relative end values with start as base (e.g.: +10, -3)
728
+ end = this._handleRelativeValue(start, end);
729
+ // Protect against non numeric properties.
730
+ if (typeof end === 'number') {
731
+ // eslint-disable-next-line
732
+ // @ts-ignore FIXME?
733
+ _object[property] = start + (end - start) * value;
734
+ }
735
+ }
736
+ }
737
+ };
738
+ Tween.prototype._handleRelativeValue = function (start, end) {
739
+ if (typeof end !== 'string') {
740
+ return end;
741
+ }
742
+ if (end.charAt(0) === '+' || end.charAt(0) === '-') {
743
+ return start + parseFloat(end);
744
+ }
745
+ else {
746
+ return parseFloat(end);
747
+ }
748
+ };
749
+ Tween.prototype._swapEndStartRepeatValues = function (property) {
750
+ var tmp = this._valuesStartRepeat[property];
751
+ var endValue = this._valuesEnd[property];
752
+ if (typeof endValue === 'string') {
753
+ this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(endValue);
754
+ }
755
+ else {
756
+ this._valuesStartRepeat[property] = this._valuesEnd[property];
757
+ }
758
+ this._valuesEnd[property] = tmp;
759
+ };
760
+ return Tween;
746
761
  }());
747
762
 
748
- var VERSION = '18.6.0';
763
+ var VERSION = '18.6.4';
749
764
 
750
- /**
751
- * Tween.js - Licensed under the MIT license
752
- * https://github.com/tweenjs/tween.js
753
- * ----------------------------------------------
754
- *
755
- * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
756
- * Thank you all, you're awesome!
757
- */
758
- var __extends = (this && this.__extends) || (function () {
759
- var extendStatics = function (d, b) {
760
- extendStatics = Object.setPrototypeOf ||
761
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
762
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
763
- return extendStatics(d, b);
764
- };
765
- return function (d, b) {
766
- extendStatics(d, b);
767
- function __() { this.constructor = d; }
768
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
769
- };
770
- })();
771
- /**
772
- * Controlling groups of tweens
773
- *
774
- * Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.
775
- * In these cases, you may want to create your own smaller groups of tween
776
- */
777
- var Main = /** @class */ (function (_super) {
778
- __extends(Main, _super);
779
- function Main() {
780
- var _this = _super !== null && _super.apply(this, arguments) || this;
781
- _this.version = VERSION;
782
- _this.now = NOW$1;
783
- _this.Group = Group;
784
- _this.Easing = Easing;
785
- _this.Interpolation = Interpolation;
786
- _this.nextId = Sequence.nextId;
787
- _this.Tween = Tween;
788
- return _this;
789
- }
790
- return Main;
791
- }(Group));
792
- var TWEEN = new Main();
765
+ /**
766
+ * Tween.js - Licensed under the MIT license
767
+ * https://github.com/tweenjs/tween.js
768
+ * ----------------------------------------------
769
+ *
770
+ * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
771
+ * Thank you all, you're awesome!
772
+ */
773
+ var nextId = Sequence.nextId;
774
+ /**
775
+ * Controlling groups of tweens
776
+ *
777
+ * Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.
778
+ * In these cases, you may want to create your own smaller groups of tweens.
779
+ */
780
+ var TWEEN = mainGroup;
781
+ // This is the best way to export things in a way that's compatible with both ES
782
+ // Modules and CommonJS, without build hacks, and so as not to break the
783
+ // existing API.
784
+ // https://github.com/rollup/rollup/issues/1961#issuecomment-423037881
785
+ var getAll = TWEEN.getAll.bind(TWEEN);
786
+ var removeAll = TWEEN.removeAll.bind(TWEEN);
787
+ var add = TWEEN.add.bind(TWEEN);
788
+ var remove = TWEEN.remove.bind(TWEEN);
789
+ var update = TWEEN.update.bind(TWEEN);
790
+ var exports$1 = {
791
+ Easing: Easing,
792
+ Group: Group,
793
+ Interpolation: Interpolation,
794
+ now: now$1,
795
+ Sequence: Sequence,
796
+ nextId: nextId,
797
+ Tween: Tween,
798
+ VERSION: VERSION,
799
+ getAll: getAll,
800
+ removeAll: removeAll,
801
+ add: add,
802
+ remove: remove,
803
+ update: update,
804
+ };
793
805
 
794
- module.exports = TWEEN;
806
+ exports.Easing = Easing;
807
+ exports.Group = Group;
808
+ exports.Interpolation = Interpolation;
809
+ exports.Sequence = Sequence;
810
+ exports.Tween = Tween;
811
+ exports.VERSION = VERSION;
812
+ exports.add = add;
813
+ exports.default = exports$1;
814
+ exports.getAll = getAll;
815
+ exports.nextId = nextId;
816
+ exports.now = now$1;
817
+ exports.remove = remove;
818
+ exports.removeAll = removeAll;
819
+ exports.update = update;