@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/README.md +34 -34
- package/dist/index.d.ts +273 -0
- package/dist/tween.amd.js +792 -961
- package/dist/tween.cjs.js +786 -955
- package/dist/tween.esm.js +786 -955
- package/dist/tween.umd.js +795 -964
- package/package.json +54 -31
- package/.eslintrc.json +0 -100
- package/.travis.yml +0 -26
- package/CODE_OF_CONDUCT.md +0 -75
- package/README_zh-CN.md +0 -297
- package/rollup.config.js +0 -24
- package/src/Tween.js +0 -961
package/dist/tween.umd.js
CHANGED
@@ -1,969 +1,800 @@
|
|
1
1
|
(function (global, factory) {
|
2
|
-
|
3
|
-
|
4
|
-
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
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
|
})));
|