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