@tweenjs/tween.js 18.3.2 → 18.6.0

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