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