@tweenjs/tween.js 18.3.2 → 18.6.0

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