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