@tweenjs/tween.js 18.6.0 → 18.6.4

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