@xviewer.js/core 1.0.0-alpha.32 → 1.0.0-alpha.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +553 -523
- package/dist/main.js.map +1 -1
- package/dist/module.js +553 -523
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/types/Viewer.d.ts +0 -1
- package/types/cinestation/CinestationBlendDefinition.d.ts +4 -4
- package/types/cinestation/CinestationBrain.d.ts +0 -2
- package/types/cinestation/FreelookVirtualCamera.d.ts +16 -9
- package/types/cinestation/VirtualCamera.d.ts +0 -3
- package/types/math/Interpolation.d.ts +6 -6
- package/types/tween/Easing.d.ts +25 -0
- package/types/tween/Group.d.ts +16 -0
- package/types/tween/Interpolation.d.ts +19 -0
- package/types/tween/Now.d.ts +2 -0
- package/types/tween/Sequence.d.ts +7 -0
- package/types/tween/Tween.d.ts +96 -0
- package/types/tween/TweenChain.d.ts +2 -1
- package/types/tween/TweenManager.d.ts +0 -2
- package/types/tween/Version.d.ts +1 -0
- package/types/tween/index.d.ts +3 -1
- package/types/tween/mainGroup.d.ts +2 -0
- package/types/objects/Reflector.d.ts +0 -18
- package/types/objects/index.d.ts +0 -1
package/dist/main.js
CHANGED
|
@@ -143,87 +143,96 @@ function getClassInstance(constructor, args = []) {
|
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
145
|
* The Ease class provides a collection of easing functions for use with tween.js.
|
|
146
|
-
*/
|
|
147
|
-
Linear: {
|
|
148
|
-
None
|
|
146
|
+
*/ const Easing = Object.freeze({
|
|
147
|
+
Linear: Object.freeze({
|
|
148
|
+
None (amount) {
|
|
149
|
+
return amount;
|
|
150
|
+
},
|
|
151
|
+
In (amount) {
|
|
152
|
+
return amount;
|
|
153
|
+
},
|
|
154
|
+
Out (amount) {
|
|
155
|
+
return amount;
|
|
156
|
+
},
|
|
157
|
+
InOut (amount) {
|
|
149
158
|
return amount;
|
|
150
159
|
}
|
|
151
|
-
},
|
|
152
|
-
Quadratic: {
|
|
153
|
-
In
|
|
160
|
+
}),
|
|
161
|
+
Quadratic: Object.freeze({
|
|
162
|
+
In (amount) {
|
|
154
163
|
return amount * amount;
|
|
155
164
|
},
|
|
156
|
-
Out
|
|
165
|
+
Out (amount) {
|
|
157
166
|
return amount * (2 - amount);
|
|
158
167
|
},
|
|
159
|
-
InOut
|
|
168
|
+
InOut (amount) {
|
|
160
169
|
if ((amount *= 2) < 1) {
|
|
161
170
|
return 0.5 * amount * amount;
|
|
162
171
|
}
|
|
163
172
|
return -0.5 * (--amount * (amount - 2) - 1);
|
|
164
173
|
}
|
|
165
|
-
},
|
|
166
|
-
Cubic: {
|
|
167
|
-
In
|
|
174
|
+
}),
|
|
175
|
+
Cubic: Object.freeze({
|
|
176
|
+
In (amount) {
|
|
168
177
|
return amount * amount * amount;
|
|
169
178
|
},
|
|
170
|
-
Out
|
|
179
|
+
Out (amount) {
|
|
171
180
|
return --amount * amount * amount + 1;
|
|
172
181
|
},
|
|
173
|
-
InOut
|
|
182
|
+
InOut (amount) {
|
|
174
183
|
if ((amount *= 2) < 1) {
|
|
175
184
|
return 0.5 * amount * amount * amount;
|
|
176
185
|
}
|
|
177
186
|
return 0.5 * ((amount -= 2) * amount * amount + 2);
|
|
178
187
|
}
|
|
179
|
-
},
|
|
180
|
-
Quartic: {
|
|
181
|
-
In
|
|
188
|
+
}),
|
|
189
|
+
Quartic: Object.freeze({
|
|
190
|
+
In (amount) {
|
|
182
191
|
return amount * amount * amount * amount;
|
|
183
192
|
},
|
|
184
|
-
Out
|
|
193
|
+
Out (amount) {
|
|
185
194
|
return 1 - --amount * amount * amount * amount;
|
|
186
195
|
},
|
|
187
|
-
InOut
|
|
196
|
+
InOut (amount) {
|
|
188
197
|
if ((amount *= 2) < 1) {
|
|
189
198
|
return 0.5 * amount * amount * amount * amount;
|
|
190
199
|
}
|
|
191
200
|
return -0.5 * ((amount -= 2) * amount * amount * amount - 2);
|
|
192
201
|
}
|
|
193
|
-
},
|
|
194
|
-
Quintic: {
|
|
195
|
-
In
|
|
202
|
+
}),
|
|
203
|
+
Quintic: Object.freeze({
|
|
204
|
+
In (amount) {
|
|
196
205
|
return amount * amount * amount * amount * amount;
|
|
197
206
|
},
|
|
198
|
-
Out
|
|
207
|
+
Out (amount) {
|
|
199
208
|
return --amount * amount * amount * amount * amount + 1;
|
|
200
209
|
},
|
|
201
|
-
InOut
|
|
210
|
+
InOut (amount) {
|
|
202
211
|
if ((amount *= 2) < 1) {
|
|
203
212
|
return 0.5 * amount * amount * amount * amount * amount;
|
|
204
213
|
}
|
|
205
214
|
return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2);
|
|
206
215
|
}
|
|
207
|
-
},
|
|
208
|
-
Sinusoidal: {
|
|
209
|
-
In
|
|
210
|
-
return 1 - Math.
|
|
216
|
+
}),
|
|
217
|
+
Sinusoidal: Object.freeze({
|
|
218
|
+
In (amount) {
|
|
219
|
+
return 1 - Math.sin((1.0 - amount) * Math.PI / 2);
|
|
211
220
|
},
|
|
212
|
-
Out
|
|
221
|
+
Out (amount) {
|
|
213
222
|
return Math.sin(amount * Math.PI / 2);
|
|
214
223
|
},
|
|
215
|
-
InOut
|
|
216
|
-
return 0.5 * (1 - Math.
|
|
224
|
+
InOut (amount) {
|
|
225
|
+
return 0.5 * (1 - Math.sin(Math.PI * (0.5 - amount)));
|
|
217
226
|
}
|
|
218
|
-
},
|
|
219
|
-
Exponential: {
|
|
220
|
-
In
|
|
227
|
+
}),
|
|
228
|
+
Exponential: Object.freeze({
|
|
229
|
+
In (amount) {
|
|
221
230
|
return amount === 0 ? 0 : Math.pow(1024, amount - 1);
|
|
222
231
|
},
|
|
223
|
-
Out
|
|
232
|
+
Out (amount) {
|
|
224
233
|
return amount === 1 ? 1 : 1 - Math.pow(2, -10 * amount);
|
|
225
234
|
},
|
|
226
|
-
InOut
|
|
235
|
+
InOut (amount) {
|
|
227
236
|
if (amount === 0) {
|
|
228
237
|
return 0;
|
|
229
238
|
}
|
|
@@ -235,23 +244,23 @@ function getClassInstance(constructor, args = []) {
|
|
|
235
244
|
}
|
|
236
245
|
return 0.5 * (-Math.pow(2, -10 * (amount - 1)) + 2);
|
|
237
246
|
}
|
|
238
|
-
},
|
|
239
|
-
Circular: {
|
|
240
|
-
In
|
|
247
|
+
}),
|
|
248
|
+
Circular: Object.freeze({
|
|
249
|
+
In (amount) {
|
|
241
250
|
return 1 - Math.sqrt(1 - amount * amount);
|
|
242
251
|
},
|
|
243
|
-
Out
|
|
252
|
+
Out (amount) {
|
|
244
253
|
return Math.sqrt(1 - --amount * amount);
|
|
245
254
|
},
|
|
246
|
-
InOut
|
|
255
|
+
InOut (amount) {
|
|
247
256
|
if ((amount *= 2) < 1) {
|
|
248
257
|
return -0.5 * (Math.sqrt(1 - amount * amount) - 1);
|
|
249
258
|
}
|
|
250
259
|
return 0.5 * (Math.sqrt(1 - (amount -= 2) * amount) + 1);
|
|
251
260
|
}
|
|
252
|
-
},
|
|
253
|
-
Elastic: {
|
|
254
|
-
In
|
|
261
|
+
}),
|
|
262
|
+
Elastic: Object.freeze({
|
|
263
|
+
In (amount) {
|
|
255
264
|
if (amount === 0) {
|
|
256
265
|
return 0;
|
|
257
266
|
}
|
|
@@ -260,7 +269,7 @@ function getClassInstance(constructor, args = []) {
|
|
|
260
269
|
}
|
|
261
270
|
return -Math.pow(2, 10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI);
|
|
262
271
|
},
|
|
263
|
-
Out
|
|
272
|
+
Out (amount) {
|
|
264
273
|
if (amount === 0) {
|
|
265
274
|
return 0;
|
|
266
275
|
}
|
|
@@ -269,7 +278,7 @@ function getClassInstance(constructor, args = []) {
|
|
|
269
278
|
}
|
|
270
279
|
return Math.pow(2, -10 * amount) * Math.sin((amount - 0.1) * 5 * Math.PI) + 1;
|
|
271
280
|
},
|
|
272
|
-
InOut
|
|
281
|
+
InOut (amount) {
|
|
273
282
|
if (amount === 0) {
|
|
274
283
|
return 0;
|
|
275
284
|
}
|
|
@@ -282,29 +291,29 @@ function getClassInstance(constructor, args = []) {
|
|
|
282
291
|
}
|
|
283
292
|
return 0.5 * Math.pow(2, -10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI) + 1;
|
|
284
293
|
}
|
|
285
|
-
},
|
|
286
|
-
Back: {
|
|
287
|
-
In
|
|
288
|
-
|
|
289
|
-
return amount * amount * ((s + 1) * amount - s);
|
|
294
|
+
}),
|
|
295
|
+
Back: Object.freeze({
|
|
296
|
+
In (amount) {
|
|
297
|
+
const s = 1.70158;
|
|
298
|
+
return amount === 1 ? 1 : amount * amount * ((s + 1) * amount - s);
|
|
290
299
|
},
|
|
291
|
-
Out
|
|
292
|
-
|
|
293
|
-
return --amount * amount * ((s + 1) * amount + s) + 1;
|
|
300
|
+
Out (amount) {
|
|
301
|
+
const s = 1.70158;
|
|
302
|
+
return amount === 0 ? 0 : --amount * amount * ((s + 1) * amount + s) + 1;
|
|
294
303
|
},
|
|
295
|
-
InOut
|
|
296
|
-
|
|
304
|
+
InOut (amount) {
|
|
305
|
+
const s = 1.70158 * 1.525;
|
|
297
306
|
if ((amount *= 2) < 1) {
|
|
298
307
|
return 0.5 * (amount * amount * ((s + 1) * amount - s));
|
|
299
308
|
}
|
|
300
309
|
return 0.5 * ((amount -= 2) * amount * ((s + 1) * amount + s) + 2);
|
|
301
310
|
}
|
|
302
|
-
},
|
|
303
|
-
Bounce: {
|
|
304
|
-
In
|
|
311
|
+
}),
|
|
312
|
+
Bounce: Object.freeze({
|
|
313
|
+
In (amount) {
|
|
305
314
|
return 1 - Easing.Bounce.Out(1 - amount);
|
|
306
315
|
},
|
|
307
|
-
Out
|
|
316
|
+
Out (amount) {
|
|
308
317
|
if (amount < 1 / 2.75) {
|
|
309
318
|
return 7.5625 * amount * amount;
|
|
310
319
|
} else if (amount < 2 / 2.75) {
|
|
@@ -315,107 +324,43 @@ function getClassInstance(constructor, args = []) {
|
|
|
315
324
|
return 7.5625 * (amount -= 2.625 / 2.75) * amount + 0.984375;
|
|
316
325
|
}
|
|
317
326
|
},
|
|
318
|
-
InOut
|
|
327
|
+
InOut (amount) {
|
|
319
328
|
if (amount < 0.5) {
|
|
320
329
|
return Easing.Bounce.In(amount * 2) * 0.5;
|
|
321
330
|
}
|
|
322
331
|
return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5;
|
|
323
332
|
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
};
|
|
339
|
-
} else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) {
|
|
340
|
-
// This must be bound, because directly assigning this function
|
|
341
|
-
// leads to an invocation exception in Chrome.
|
|
342
|
-
now = self.performance.now.bind(self.performance);
|
|
343
|
-
} else if (Date.now !== undefined) {
|
|
344
|
-
now = Date.now;
|
|
345
|
-
} else {
|
|
346
|
-
now = function() {
|
|
347
|
-
return new Date().getTime();
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
function now$1() {
|
|
351
|
-
return now() * 0.001;
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Controlling groups of tweens
|
|
355
|
-
*
|
|
356
|
-
* Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.
|
|
357
|
-
* In these cases, you may want to create your own smaller groups of tween
|
|
358
|
-
*/ var Group = /** @class */ function() {
|
|
359
|
-
function Group() {
|
|
360
|
-
this._tweens = {};
|
|
361
|
-
this._tweensAddedDuringUpdate = {};
|
|
362
|
-
}
|
|
363
|
-
Group.prototype.getAll = function() {
|
|
364
|
-
var _this = this;
|
|
365
|
-
return Object.keys(this._tweens).map(function(tweenId) {
|
|
366
|
-
return _this._tweens[tweenId];
|
|
367
|
-
});
|
|
368
|
-
};
|
|
369
|
-
Group.prototype.removeAll = function() {
|
|
370
|
-
this._tweens = {};
|
|
371
|
-
};
|
|
372
|
-
Group.prototype.add = function(tween) {
|
|
373
|
-
this._tweens[tween.getId()] = tween;
|
|
374
|
-
this._tweensAddedDuringUpdate[tween.getId()] = tween;
|
|
375
|
-
};
|
|
376
|
-
Group.prototype.remove = function(tween) {
|
|
377
|
-
delete this._tweens[tween.getId()];
|
|
378
|
-
delete this._tweensAddedDuringUpdate[tween.getId()];
|
|
379
|
-
};
|
|
380
|
-
Group.prototype.update = function(time, preserve) {
|
|
381
|
-
if (time === void 0) {
|
|
382
|
-
time = now$1();
|
|
383
|
-
}
|
|
384
|
-
if (preserve === void 0) {
|
|
385
|
-
preserve = false;
|
|
386
|
-
}
|
|
387
|
-
var tweenIds = Object.keys(this._tweens);
|
|
388
|
-
if (tweenIds.length === 0) {
|
|
389
|
-
return false;
|
|
390
|
-
}
|
|
391
|
-
// Tweens are updated in "batches". If you add a new tween during an
|
|
392
|
-
// update, then the new tween will be updated in the next batch.
|
|
393
|
-
// If you remove a tween during an update, it may or may not be updated.
|
|
394
|
-
// However, if the removed tween was added during the current batch,
|
|
395
|
-
// then it will not be updated.
|
|
396
|
-
while(tweenIds.length > 0){
|
|
397
|
-
this._tweensAddedDuringUpdate = {};
|
|
398
|
-
for(var i = 0; i < tweenIds.length; i++){
|
|
399
|
-
var tween = this._tweens[tweenIds[i]];
|
|
400
|
-
var autoStart = !preserve;
|
|
401
|
-
if (tween && tween.update(time, autoStart) === false && !preserve) {
|
|
402
|
-
delete this._tweens[tweenIds[i]];
|
|
333
|
+
}),
|
|
334
|
+
generatePow (power = 4) {
|
|
335
|
+
power = power < Number.EPSILON ? Number.EPSILON : power;
|
|
336
|
+
power = power > 10000 ? 10000 : power;
|
|
337
|
+
return {
|
|
338
|
+
In (amount) {
|
|
339
|
+
return amount ** power;
|
|
340
|
+
},
|
|
341
|
+
Out (amount) {
|
|
342
|
+
return 1 - (1 - amount) ** power;
|
|
343
|
+
},
|
|
344
|
+
InOut (amount) {
|
|
345
|
+
if (amount < 0.5) {
|
|
346
|
+
return (amount * 2) ** power / 2;
|
|
403
347
|
}
|
|
348
|
+
return (1 - (2 - amount * 2) ** power) / 2 + 0.5;
|
|
404
349
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
return Group;
|
|
410
|
-
}();
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
|
|
411
354
|
/**
|
|
412
355
|
*
|
|
413
|
-
*/
|
|
356
|
+
*/ /**
|
|
357
|
+
*
|
|
358
|
+
*/ const Interpolation = {
|
|
414
359
|
Linear: function(v, k) {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
360
|
+
const m = v.length - 1;
|
|
361
|
+
const f = m * k;
|
|
362
|
+
const i = Math.floor(f);
|
|
363
|
+
const fn = Interpolation.Utils.Linear;
|
|
419
364
|
if (k < 0) {
|
|
420
365
|
return fn(v[0], v[1], f);
|
|
421
366
|
}
|
|
@@ -425,20 +370,20 @@ function now$1() {
|
|
|
425
370
|
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i);
|
|
426
371
|
},
|
|
427
372
|
Bezier: function(v, k) {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
for(
|
|
373
|
+
let b = 0;
|
|
374
|
+
const n = v.length - 1;
|
|
375
|
+
const pw = Math.pow;
|
|
376
|
+
const bn = Interpolation.Utils.Bernstein;
|
|
377
|
+
for(let i = 0; i <= n; i++){
|
|
433
378
|
b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i);
|
|
434
379
|
}
|
|
435
380
|
return b;
|
|
436
381
|
},
|
|
437
382
|
CatmullRom: function(v, k) {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
383
|
+
const m = v.length - 1;
|
|
384
|
+
let f = m * k;
|
|
385
|
+
let i = Math.floor(f);
|
|
386
|
+
const fn = Interpolation.Utils.CatmullRom;
|
|
442
387
|
if (v[0] === v[m]) {
|
|
443
388
|
if (k < 0) {
|
|
444
389
|
i = Math.floor(f = m * (1 + k));
|
|
@@ -459,19 +404,19 @@ function now$1() {
|
|
|
459
404
|
return (p1 - p0) * t + p0;
|
|
460
405
|
},
|
|
461
406
|
Bernstein: function(n, i) {
|
|
462
|
-
|
|
407
|
+
const fc = Interpolation.Utils.Factorial;
|
|
463
408
|
return fc(n) / fc(i) / fc(n - i);
|
|
464
409
|
},
|
|
465
410
|
Factorial: function() {
|
|
466
|
-
|
|
411
|
+
const a = [
|
|
467
412
|
1
|
|
468
413
|
];
|
|
469
414
|
return function(n) {
|
|
470
|
-
|
|
415
|
+
let s = 1;
|
|
471
416
|
if (a[n]) {
|
|
472
417
|
return a[n];
|
|
473
418
|
}
|
|
474
|
-
for(
|
|
419
|
+
for(let i = n; i > 1; i--){
|
|
475
420
|
s *= i;
|
|
476
421
|
}
|
|
477
422
|
a[n] = s;
|
|
@@ -479,77 +424,112 @@ function now$1() {
|
|
|
479
424
|
};
|
|
480
425
|
}(),
|
|
481
426
|
CatmullRom: function(p0, p1, p2, p3, t) {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
427
|
+
const v0 = (p2 - p0) * 0.5;
|
|
428
|
+
const v1 = (p3 - p1) * 0.5;
|
|
429
|
+
const t2 = t * t;
|
|
430
|
+
const t3 = t * t2;
|
|
486
431
|
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
|
|
487
432
|
}
|
|
488
433
|
}
|
|
489
434
|
};
|
|
435
|
+
|
|
436
|
+
const now = ()=>performance.now() * 0.001;
|
|
437
|
+
|
|
490
438
|
/**
|
|
491
|
-
*
|
|
492
|
-
*/ var Sequence = /** @class */ function() {
|
|
493
|
-
function Sequence() {}
|
|
494
|
-
Sequence.nextId = function() {
|
|
495
|
-
return Sequence._nextId++;
|
|
496
|
-
};
|
|
497
|
-
Sequence._nextId = 0;
|
|
498
|
-
return Sequence;
|
|
499
|
-
}();
|
|
500
|
-
var mainGroup = new Group();
|
|
501
|
-
/**
|
|
502
|
-
* Tween.js - Licensed under the MIT license
|
|
503
|
-
* https://github.com/tweenjs/tween.js
|
|
504
|
-
* ----------------------------------------------
|
|
439
|
+
* Controlling groups of tweens
|
|
505
440
|
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
*/
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
441
|
+
* Using the TWEEN singleton to manage your tweens can cause issues in large apps with many components.
|
|
442
|
+
* In these cases, you may want to create your own smaller groups of tween
|
|
443
|
+
*/ class Group {
|
|
444
|
+
getAll() {
|
|
445
|
+
return Object.keys(this._tweens).map((tweenId)=>{
|
|
446
|
+
return this._tweens[tweenId];
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
removeAll() {
|
|
450
|
+
this._tweens = {};
|
|
451
|
+
}
|
|
452
|
+
add(tween) {
|
|
453
|
+
this._tweens[tween.getId()] = tween;
|
|
454
|
+
this._tweensAddedDuringUpdate[tween.getId()] = tween;
|
|
455
|
+
}
|
|
456
|
+
remove(tween) {
|
|
457
|
+
delete this._tweens[tween.getId()];
|
|
458
|
+
delete this._tweensAddedDuringUpdate[tween.getId()];
|
|
459
|
+
}
|
|
460
|
+
update(time = now(), preserve = false) {
|
|
461
|
+
let tweenIds = Object.keys(this._tweens);
|
|
462
|
+
if (tweenIds.length === 0) {
|
|
463
|
+
return false;
|
|
512
464
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
this._chainedTweens = [];
|
|
531
|
-
this._onStartCallbackFired = false;
|
|
532
|
-
this._id = Sequence.nextId();
|
|
533
|
-
this._isChainStopped = false;
|
|
534
|
-
this._goToEnd = false;
|
|
535
|
-
this._headTween = null;
|
|
536
|
-
this._tailTween = null;
|
|
537
|
-
this._headStart = false;
|
|
465
|
+
// Tweens are updated in "batches". If you add a new tween during an
|
|
466
|
+
// update, then the new tween will be updated in the next batch.
|
|
467
|
+
// If you remove a tween during an update, it may or may not be updated.
|
|
468
|
+
// However, if the removed tween was added during the current batch,
|
|
469
|
+
// then it will not be updated.
|
|
470
|
+
while(tweenIds.length > 0){
|
|
471
|
+
this._tweensAddedDuringUpdate = {};
|
|
472
|
+
for(let i = 0; i < tweenIds.length; i++){
|
|
473
|
+
const tween = this._tweens[tweenIds[i]];
|
|
474
|
+
const autoStart = !preserve;
|
|
475
|
+
if (tween && tween.update(time, autoStart) === false && !preserve) {
|
|
476
|
+
delete this._tweens[tweenIds[i]];
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
tweenIds = Object.keys(this._tweensAddedDuringUpdate);
|
|
480
|
+
}
|
|
481
|
+
return true;
|
|
538
482
|
}
|
|
539
|
-
|
|
483
|
+
constructor(){
|
|
484
|
+
this._tweens = {};
|
|
485
|
+
this._tweensAddedDuringUpdate = {};
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
const mainGroup = new Group();
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Utils
|
|
493
|
+
*/ class Sequence {
|
|
494
|
+
static nextId() {
|
|
495
|
+
return Sequence._nextId++;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
Sequence._nextId = 0;
|
|
499
|
+
|
|
500
|
+
class Tween {
|
|
501
|
+
getId() {
|
|
540
502
|
return this._id;
|
|
541
|
-
}
|
|
542
|
-
|
|
503
|
+
}
|
|
504
|
+
isPlaying() {
|
|
543
505
|
return this._isPlaying;
|
|
544
|
-
}
|
|
545
|
-
|
|
506
|
+
}
|
|
507
|
+
isPaused() {
|
|
546
508
|
return this._isPaused;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
this._duration
|
|
509
|
+
}
|
|
510
|
+
getDuration() {
|
|
511
|
+
return this._duration;
|
|
512
|
+
}
|
|
513
|
+
from(properties) {
|
|
514
|
+
this._valuesStart = Object.create(properties);
|
|
550
515
|
return this;
|
|
551
|
-
}
|
|
552
|
-
|
|
516
|
+
}
|
|
517
|
+
to(target, duration = 1) {
|
|
518
|
+
if (this._isPlaying) throw new Error('Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.');
|
|
519
|
+
this._valuesEnd = target;
|
|
520
|
+
this._propertiesAreSetUp = false;
|
|
521
|
+
this._duration = duration < 0 ? 0 : duration;
|
|
522
|
+
return this;
|
|
523
|
+
}
|
|
524
|
+
duration(duration = 1) {
|
|
525
|
+
this._duration = duration < 0 ? 0 : duration;
|
|
526
|
+
return this;
|
|
527
|
+
}
|
|
528
|
+
dynamic(dynamic = false) {
|
|
529
|
+
this._isDynamic = dynamic;
|
|
530
|
+
return this;
|
|
531
|
+
}
|
|
532
|
+
start(time = now(), overrideStartingValues = false) {
|
|
553
533
|
if (this._isPlaying) {
|
|
554
534
|
return this;
|
|
555
535
|
}
|
|
@@ -560,7 +540,7 @@ var mainGroup = new Group();
|
|
|
560
540
|
// If we were reversed (f.e. using the yoyo feature) then we need to
|
|
561
541
|
// flip the tween direction back to forward.
|
|
562
542
|
this._reversed = false;
|
|
563
|
-
for(
|
|
543
|
+
for(const property in this._valuesStartRepeat){
|
|
564
544
|
this._swapEndStartRepeatValues(property);
|
|
565
545
|
this._valuesStart[property] = this._valuesStartRepeat[property];
|
|
566
546
|
}
|
|
@@ -568,18 +548,31 @@ var mainGroup = new Group();
|
|
|
568
548
|
this._isPlaying = true;
|
|
569
549
|
this._isPaused = false;
|
|
570
550
|
this._onStartCallbackFired = false;
|
|
551
|
+
this._onEveryStartCallbackFired = false;
|
|
571
552
|
this._isChainStopped = false;
|
|
572
|
-
this._startTime = time
|
|
553
|
+
this._startTime = time;
|
|
573
554
|
this._startTime += this._delayTime;
|
|
574
|
-
|
|
555
|
+
if (!this._propertiesAreSetUp || overrideStartingValues) {
|
|
556
|
+
this._propertiesAreSetUp = true;
|
|
557
|
+
// If dynamic is not enabled, clone the end values instead of using the passed-in end values.
|
|
558
|
+
if (!this._isDynamic) {
|
|
559
|
+
const tmp = {};
|
|
560
|
+
for(const prop in this._valuesEnd)tmp[prop] = this._valuesEnd[prop];
|
|
561
|
+
this._valuesEnd = tmp;
|
|
562
|
+
}
|
|
563
|
+
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
|
|
564
|
+
}
|
|
575
565
|
return this;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
566
|
+
}
|
|
567
|
+
startFromCurrentValues(time) {
|
|
568
|
+
return this.start(time, true);
|
|
569
|
+
}
|
|
570
|
+
_setupProperties(_object, _valuesStart, _valuesEnd, _valuesStartRepeat, overrideStartingValues) {
|
|
571
|
+
for(const property in _valuesEnd){
|
|
572
|
+
const startValue = _object[property];
|
|
573
|
+
const startValueIsArray = Array.isArray(startValue);
|
|
574
|
+
const propType = startValueIsArray ? 'array' : typeof startValue;
|
|
575
|
+
let isInterpolationList = !startValueIsArray && Array.isArray(_valuesEnd[property]);
|
|
583
576
|
// If `to()` specifies a property that doesn't exist in the source object,
|
|
584
577
|
// we should not set that property in the object
|
|
585
578
|
if (propType === 'undefined' || propType === 'function') {
|
|
@@ -587,39 +580,57 @@ var mainGroup = new Group();
|
|
|
587
580
|
}
|
|
588
581
|
// Check if an Array was provided as property value
|
|
589
582
|
if (isInterpolationList) {
|
|
590
|
-
|
|
583
|
+
const endValues = _valuesEnd[property];
|
|
591
584
|
if (endValues.length === 0) {
|
|
592
585
|
continue;
|
|
593
586
|
}
|
|
594
|
-
//
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
_valuesEnd[property] = [
|
|
587
|
+
// Handle an array of relative values.
|
|
588
|
+
// Creates a local copy of the Array with the start value at the front
|
|
589
|
+
const temp = [
|
|
598
590
|
startValue
|
|
599
|
-
]
|
|
591
|
+
];
|
|
592
|
+
for(let i = 0, l = endValues.length; i < l; i += 1){
|
|
593
|
+
const value = this._handleRelativeValue(startValue, endValues[i]);
|
|
594
|
+
if (isNaN(value)) {
|
|
595
|
+
isInterpolationList = false;
|
|
596
|
+
console.warn('Found invalid interpolation list. Skipping.');
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
temp.push(value);
|
|
600
|
+
}
|
|
601
|
+
if (isInterpolationList) {
|
|
602
|
+
// if (_valuesStart[property] === undefined) { // handle end values only the first time. NOT NEEDED? setupProperties is now guarded by _propertiesAreSetUp.
|
|
603
|
+
_valuesEnd[property] = temp;
|
|
604
|
+
// }
|
|
605
|
+
}
|
|
600
606
|
}
|
|
601
607
|
// handle the deepness of the values
|
|
602
608
|
if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) {
|
|
603
609
|
_valuesStart[property] = startValueIsArray ? [] : {};
|
|
604
|
-
|
|
605
|
-
for(
|
|
606
|
-
|
|
607
|
-
// @ts-ignore FIXME?
|
|
608
|
-
_valuesStart[property][prop] = startValue[prop];
|
|
610
|
+
const nestedObject = startValue;
|
|
611
|
+
for(const prop in nestedObject){
|
|
612
|
+
_valuesStart[property][prop] = nestedObject[prop];
|
|
609
613
|
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
+
// TODO? repeat nested values? And yoyo? And array values?
|
|
615
|
+
_valuesStartRepeat[property] = startValueIsArray ? [] : {};
|
|
616
|
+
let endValues = _valuesEnd[property];
|
|
617
|
+
// If dynamic is not enabled, clone the end values instead of using the passed-in end values.
|
|
618
|
+
if (!this._isDynamic) {
|
|
619
|
+
const tmp = {};
|
|
620
|
+
for(const prop in endValues)tmp[prop] = endValues[prop];
|
|
621
|
+
_valuesEnd[property] = endValues = tmp;
|
|
622
|
+
}
|
|
623
|
+
this._setupProperties(nestedObject, _valuesStart[property], endValues, _valuesStartRepeat[property], overrideStartingValues);
|
|
614
624
|
} else {
|
|
615
|
-
// Save the starting value, but only once.
|
|
616
|
-
if (typeof _valuesStart[property] === 'undefined') {
|
|
625
|
+
// Save the starting value, but only once unless override is requested.
|
|
626
|
+
if (typeof _valuesStart[property] === 'undefined' || overrideStartingValues) {
|
|
617
627
|
_valuesStart[property] = startValue;
|
|
618
628
|
}
|
|
619
629
|
if (!startValueIsArray) {
|
|
620
630
|
// eslint-disable-next-line
|
|
621
631
|
// @ts-ignore FIXME?
|
|
622
|
-
_valuesStart[property] *= 1.0
|
|
632
|
+
_valuesStart[property] *= 1.0 // Ensures we're using numbers, not strings
|
|
633
|
+
;
|
|
623
634
|
}
|
|
624
635
|
if (isInterpolationList) {
|
|
625
636
|
// eslint-disable-next-line
|
|
@@ -630,8 +641,8 @@ var mainGroup = new Group();
|
|
|
630
641
|
}
|
|
631
642
|
}
|
|
632
643
|
}
|
|
633
|
-
}
|
|
634
|
-
|
|
644
|
+
}
|
|
645
|
+
stop() {
|
|
635
646
|
if (!this._isChainStopped) {
|
|
636
647
|
this._isChainStopped = true;
|
|
637
648
|
this.stopChainedTweens();
|
|
@@ -647,16 +658,13 @@ var mainGroup = new Group();
|
|
|
647
658
|
this._onStopCallback(this._object);
|
|
648
659
|
}
|
|
649
660
|
return this;
|
|
650
|
-
}
|
|
651
|
-
|
|
661
|
+
}
|
|
662
|
+
end() {
|
|
652
663
|
this._goToEnd = true;
|
|
653
664
|
this.update(Infinity);
|
|
654
665
|
return this;
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
if (time === void 0) {
|
|
658
|
-
time = now$1();
|
|
659
|
-
}
|
|
666
|
+
}
|
|
667
|
+
pause(time = now()) {
|
|
660
668
|
if (this._isPaused || !this._isPlaying) {
|
|
661
669
|
return this;
|
|
662
670
|
}
|
|
@@ -665,11 +673,8 @@ var mainGroup = new Group();
|
|
|
665
673
|
// eslint-disable-next-line
|
|
666
674
|
this._group && this._group.remove(this);
|
|
667
675
|
return this;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
if (time === void 0) {
|
|
671
|
-
time = now$1();
|
|
672
|
-
}
|
|
676
|
+
}
|
|
677
|
+
resume(time = now()) {
|
|
673
678
|
if (!this._isPaused || !this._isPlaying) {
|
|
674
679
|
return this;
|
|
675
680
|
}
|
|
@@ -679,124 +684,98 @@ var mainGroup = new Group();
|
|
|
679
684
|
// eslint-disable-next-line
|
|
680
685
|
this._group && this._group.add(this);
|
|
681
686
|
return this;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
for(
|
|
687
|
+
}
|
|
688
|
+
stopChainedTweens() {
|
|
689
|
+
for(let i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++){
|
|
685
690
|
this._chainedTweens[i].stop();
|
|
686
691
|
}
|
|
687
|
-
this._chainedTweens = [];
|
|
688
692
|
return this;
|
|
689
|
-
}
|
|
690
|
-
|
|
693
|
+
}
|
|
694
|
+
group(group = mainGroup) {
|
|
691
695
|
this._group = group;
|
|
692
696
|
return this;
|
|
693
|
-
}
|
|
694
|
-
|
|
697
|
+
}
|
|
698
|
+
call(callback) {
|
|
695
699
|
this._onFinishCallback = callback;
|
|
696
700
|
return this;
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
this._valuesStart = Object.create(properties);
|
|
700
|
-
return this;
|
|
701
|
-
};
|
|
702
|
-
Tween.prototype.to = function(properties, duration) {
|
|
703
|
-
// TODO? restore this, then update the 07_dynamic_to example to set fox
|
|
704
|
-
// tween's to on each update. That way the behavior is opt-in (there's
|
|
705
|
-
// currently no opt-out).
|
|
706
|
-
// for (const prop in properties) this._valuesEnd[prop] = properties[prop]
|
|
707
|
-
this._valuesEnd = Object.create(properties);
|
|
708
|
-
if (duration !== undefined) {
|
|
709
|
-
this._duration = duration;
|
|
710
|
-
}
|
|
711
|
-
this._chainedTween = this;
|
|
712
|
-
return this;
|
|
713
|
-
};
|
|
714
|
-
Tween.prototype.delay = function(amount) {
|
|
701
|
+
}
|
|
702
|
+
delay(amount = 0) {
|
|
715
703
|
this._delayTime = amount;
|
|
716
704
|
return this;
|
|
717
|
-
}
|
|
718
|
-
|
|
705
|
+
}
|
|
706
|
+
union(headTween, tailTween) {
|
|
719
707
|
this._headTween = headTween;
|
|
720
708
|
this._tailTween = tailTween.chain(this);
|
|
721
709
|
this._headStart = true;
|
|
722
710
|
return this;
|
|
723
|
-
}
|
|
724
|
-
|
|
711
|
+
}
|
|
712
|
+
repeat(times = 0) {
|
|
725
713
|
this._initialRepeat = times;
|
|
726
714
|
this._repeat = times;
|
|
727
715
|
return this;
|
|
728
|
-
}
|
|
729
|
-
|
|
716
|
+
}
|
|
717
|
+
repeatDelay(amount) {
|
|
730
718
|
this._repeatDelayTime = amount;
|
|
731
719
|
return this;
|
|
732
|
-
}
|
|
733
|
-
|
|
720
|
+
}
|
|
721
|
+
yoyo(yoyo = false) {
|
|
734
722
|
this._yoyo = yoyo;
|
|
735
723
|
return this;
|
|
736
|
-
}
|
|
737
|
-
|
|
724
|
+
}
|
|
725
|
+
easing(easingFunction = Easing.Linear.None) {
|
|
738
726
|
this._easingFunction = easingFunction;
|
|
739
727
|
return this;
|
|
740
|
-
}
|
|
741
|
-
|
|
728
|
+
}
|
|
729
|
+
interpolation(interpolationFunction = Interpolation.Linear) {
|
|
742
730
|
this._interpolationFunction = interpolationFunction;
|
|
743
731
|
return this;
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
for(var _i = 0; _i < arguments.length; _i++){
|
|
748
|
-
tweens[_i] = arguments[_i];
|
|
749
|
-
}
|
|
732
|
+
}
|
|
733
|
+
// eslint-disable-next-line
|
|
734
|
+
chain(...tweens) {
|
|
750
735
|
this._chainedTweens = tweens;
|
|
751
736
|
return this;
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
let index = this._chainedTweens.findIndex((v)=>v
|
|
756
|
-
if (index > -1)
|
|
757
|
-
|
|
758
|
-
}
|
|
759
|
-
}
|
|
737
|
+
}
|
|
738
|
+
unchain(...tweens) {
|
|
739
|
+
tweens.forEach((tween)=>{
|
|
740
|
+
let index = this._chainedTweens.findIndex((v)=>v === tween);
|
|
741
|
+
if (index > -1) this._chainedTweens.splice(index, 1);
|
|
742
|
+
});
|
|
760
743
|
return this;
|
|
761
|
-
}
|
|
762
|
-
|
|
744
|
+
}
|
|
745
|
+
onStart(callback) {
|
|
763
746
|
this._onStartCallback = callback;
|
|
764
747
|
return this;
|
|
765
|
-
}
|
|
766
|
-
|
|
748
|
+
}
|
|
749
|
+
onEveryStart(callback) {
|
|
750
|
+
this._onEveryStartCallback = callback;
|
|
751
|
+
return this;
|
|
752
|
+
}
|
|
753
|
+
onUpdate(callback) {
|
|
767
754
|
this._onUpdateCallback = callback;
|
|
768
755
|
return this;
|
|
769
|
-
}
|
|
770
|
-
|
|
756
|
+
}
|
|
757
|
+
onRepeat(callback) {
|
|
771
758
|
this._onRepeatCallback = callback;
|
|
772
759
|
return this;
|
|
773
|
-
}
|
|
774
|
-
|
|
760
|
+
}
|
|
761
|
+
onComplete(callback) {
|
|
775
762
|
this._onCompleteCallback = callback;
|
|
776
763
|
return this;
|
|
777
|
-
}
|
|
778
|
-
|
|
764
|
+
}
|
|
765
|
+
onStop(callback) {
|
|
779
766
|
this._onStopCallback = callback;
|
|
780
767
|
return this;
|
|
781
|
-
}
|
|
768
|
+
}
|
|
782
769
|
/**
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
if (time === void 0) {
|
|
788
|
-
time = now$1();
|
|
789
|
-
}
|
|
790
|
-
if (autoStart === void 0) {
|
|
791
|
-
autoStart = true;
|
|
792
|
-
}
|
|
770
|
+
* @returns true if the tween is still playing after the update, false
|
|
771
|
+
* otherwise (calling update on a paused tween still returns true because
|
|
772
|
+
* it is still playing, just paused).
|
|
773
|
+
*/ update(time = now(), autoStart = true) {
|
|
793
774
|
if (this._isPaused) return true;
|
|
794
|
-
|
|
795
|
-
var elapsed;
|
|
796
|
-
var endTime = this._startTime + this._duration;
|
|
775
|
+
const endTime = this._startTime + this._duration;
|
|
797
776
|
if (!this._goToEnd && !this._isPlaying) {
|
|
798
777
|
if (time > endTime) return false;
|
|
799
|
-
if (autoStart) this.start(time);
|
|
778
|
+
if (autoStart) this.start(time, true);
|
|
800
779
|
}
|
|
801
780
|
this._goToEnd = false;
|
|
802
781
|
if (time < this._startTime) {
|
|
@@ -808,14 +787,18 @@ var mainGroup = new Group();
|
|
|
808
787
|
}
|
|
809
788
|
this._onStartCallbackFired = true;
|
|
810
789
|
}
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
790
|
+
if (this._onEveryStartCallbackFired === false) {
|
|
791
|
+
if (this._onEveryStartCallback) {
|
|
792
|
+
this._onEveryStartCallback(this._object);
|
|
793
|
+
}
|
|
794
|
+
this._onEveryStartCallbackFired = true;
|
|
795
|
+
}
|
|
796
|
+
const elapsedTime = time - this._startTime;
|
|
797
|
+
var _this__repeatDelayTime;
|
|
798
|
+
const durationAndDelay = this._duration + ((_this__repeatDelayTime = this._repeatDelayTime) != null ? _this__repeatDelayTime : this._delayTime);
|
|
799
|
+
const totalTime = this._duration + this._repeat * durationAndDelay;
|
|
800
|
+
const elapsed = this._calculateElapsedPortion(elapsedTime, durationAndDelay, totalTime);
|
|
801
|
+
const value = this._easingFunction(elapsed);
|
|
819
802
|
if (elapsed === 1) {
|
|
820
803
|
if (this._onFinishCallback) {
|
|
821
804
|
this._onFinishCallback(this._object);
|
|
@@ -826,67 +809,102 @@ var mainGroup = new Group();
|
|
|
826
809
|
this._isPlaying = false;
|
|
827
810
|
return false;
|
|
828
811
|
}
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
this._onCompleteCallback(this._object);
|
|
867
|
-
}
|
|
868
|
-
for(var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++){
|
|
869
|
-
// Make the chained tweens start exactly at the time they should,
|
|
870
|
-
// even if the `update()` method was called way past the duration of the tween
|
|
871
|
-
this._chainedTweens[i].start(this._startTime + this._duration);
|
|
872
|
-
}
|
|
873
|
-
this._isPlaying = false;
|
|
874
|
-
return false;
|
|
812
|
+
}
|
|
813
|
+
const status = this._calculateCompletionStatus(elapsedTime, durationAndDelay);
|
|
814
|
+
if (status === 'repeat') {
|
|
815
|
+
// the current update is happening after the instant the tween repeated
|
|
816
|
+
this._processRepetition(elapsedTime, durationAndDelay);
|
|
817
|
+
}
|
|
818
|
+
this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value);
|
|
819
|
+
if (status === 'about-to-repeat') {
|
|
820
|
+
// the current update is happening at the exact instant the tween is going to repeat
|
|
821
|
+
// the values should match the end of the tween, not the beginning,
|
|
822
|
+
// that's why _processRepetition happens after _updateProperties
|
|
823
|
+
this._processRepetition(elapsedTime, durationAndDelay);
|
|
824
|
+
}
|
|
825
|
+
if (this._onUpdateCallback) {
|
|
826
|
+
this._onUpdateCallback(this._object, elapsed);
|
|
827
|
+
}
|
|
828
|
+
if (status === 'repeat' || status === 'about-to-repeat') {
|
|
829
|
+
if (this._onRepeatCallback) {
|
|
830
|
+
this._onRepeatCallback(this._object);
|
|
831
|
+
}
|
|
832
|
+
if (this._headTween) {
|
|
833
|
+
this._headStart = true;
|
|
834
|
+
this._initialRepeat = this._repeat;
|
|
835
|
+
}
|
|
836
|
+
this._onEveryStartCallbackFired = false;
|
|
837
|
+
} else if (status === 'completed') {
|
|
838
|
+
this._isPlaying = false;
|
|
839
|
+
if (this._tailTween) {
|
|
840
|
+
this._tailTween.unchain(this);
|
|
841
|
+
}
|
|
842
|
+
if (this._onCompleteCallback) {
|
|
843
|
+
this._onCompleteCallback(this._object);
|
|
844
|
+
}
|
|
845
|
+
for(let i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++){
|
|
846
|
+
// Make the chained tweens start exactly at the time they should,
|
|
847
|
+
// even if the `update()` method was called way past the duration of the tween
|
|
848
|
+
this._chainedTweens[i].start(this._startTime + this._duration, false);
|
|
875
849
|
}
|
|
876
850
|
}
|
|
877
|
-
return
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
|
|
851
|
+
return status !== 'completed';
|
|
852
|
+
}
|
|
853
|
+
_calculateElapsedPortion(elapsedTime, durationAndDelay, totalTime) {
|
|
854
|
+
if (this._duration === 0 || elapsedTime > totalTime) {
|
|
855
|
+
return 1;
|
|
856
|
+
}
|
|
857
|
+
const timeIntoCurrentRepeat = elapsedTime % durationAndDelay;
|
|
858
|
+
const portion = Math.min(timeIntoCurrentRepeat / this._duration, 1);
|
|
859
|
+
if (portion === 0 && elapsedTime !== 0 && elapsedTime % this._duration === 0) {
|
|
860
|
+
return 1;
|
|
861
|
+
}
|
|
862
|
+
return portion;
|
|
863
|
+
}
|
|
864
|
+
_calculateCompletionStatus(elapsedTime, durationAndDelay) {
|
|
865
|
+
if (this._duration !== 0 && elapsedTime < this._duration) {
|
|
866
|
+
return 'playing';
|
|
867
|
+
}
|
|
868
|
+
if (this._repeat <= 0) {
|
|
869
|
+
return 'completed';
|
|
870
|
+
}
|
|
871
|
+
if (elapsedTime === this._duration) {
|
|
872
|
+
return 'about-to-repeat';
|
|
873
|
+
}
|
|
874
|
+
return 'repeat';
|
|
875
|
+
}
|
|
876
|
+
_processRepetition(elapsedTime, durationAndDelay) {
|
|
877
|
+
const completeCount = Math.min(durationAndDelay > 0 ? Math.trunc((elapsedTime - this._duration) / durationAndDelay) + 1 : 1, this._repeat);
|
|
878
|
+
if (isFinite(this._repeat)) {
|
|
879
|
+
this._repeat -= completeCount;
|
|
880
|
+
}
|
|
881
|
+
// Reassign starting values, restart by making startTime = now
|
|
882
|
+
for(const property in this._valuesStartRepeat){
|
|
883
|
+
const valueEnd = this._valuesEnd[property];
|
|
884
|
+
if (!this._yoyo && typeof valueEnd === 'string') {
|
|
885
|
+
this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(valueEnd);
|
|
886
|
+
}
|
|
887
|
+
if (this._yoyo) {
|
|
888
|
+
this._swapEndStartRepeatValues(property);
|
|
889
|
+
}
|
|
890
|
+
this._valuesStart[property] = this._valuesStartRepeat[property];
|
|
891
|
+
}
|
|
892
|
+
if (this._yoyo) {
|
|
893
|
+
this._reversed = !this._reversed;
|
|
894
|
+
}
|
|
895
|
+
this._startTime += durationAndDelay * completeCount;
|
|
896
|
+
}
|
|
897
|
+
_updateProperties(_object, _valuesStart, _valuesEnd, value) {
|
|
898
|
+
for(const property in _valuesEnd){
|
|
881
899
|
// Don't update properties that do not exist in the source object
|
|
882
900
|
if (_valuesStart[property] === undefined) {
|
|
883
901
|
continue;
|
|
884
902
|
}
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
903
|
+
const start = _valuesStart[property] || 0;
|
|
904
|
+
let end = _valuesEnd[property];
|
|
905
|
+
const startIsArray = Array.isArray(_object[property]);
|
|
906
|
+
const endIsArray = Array.isArray(end);
|
|
907
|
+
const isInterpolationList = !startIsArray && endIsArray;
|
|
890
908
|
if (isInterpolationList) {
|
|
891
909
|
_object[property] = this._interpolationFunction(end, value);
|
|
892
910
|
} else if (typeof end === 'object' && end) {
|
|
@@ -908,29 +926,57 @@ var mainGroup = new Group();
|
|
|
908
926
|
}
|
|
909
927
|
}
|
|
910
928
|
}
|
|
911
|
-
}
|
|
912
|
-
|
|
929
|
+
}
|
|
930
|
+
_handleRelativeValue(start, end) {
|
|
913
931
|
if (typeof end !== 'string') {
|
|
914
932
|
return end;
|
|
915
933
|
}
|
|
916
934
|
if (end.charAt(0) === '+' || end.charAt(0) === '-') {
|
|
917
935
|
return start + parseFloat(end);
|
|
918
|
-
} else {
|
|
919
|
-
return parseFloat(end);
|
|
920
936
|
}
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
937
|
+
return parseFloat(end);
|
|
938
|
+
}
|
|
939
|
+
_swapEndStartRepeatValues(property) {
|
|
940
|
+
const tmp = this._valuesStartRepeat[property];
|
|
941
|
+
const endValue = this._valuesEnd[property];
|
|
925
942
|
if (typeof endValue === 'string') {
|
|
926
943
|
this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(endValue);
|
|
927
944
|
} else {
|
|
928
945
|
this._valuesStartRepeat[property] = this._valuesEnd[property];
|
|
929
946
|
}
|
|
930
947
|
this._valuesEnd[property] = tmp;
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
|
|
948
|
+
}
|
|
949
|
+
constructor(_object, _group = mainGroup){
|
|
950
|
+
this._object = _object;
|
|
951
|
+
this._group = _group;
|
|
952
|
+
this._isPaused = false;
|
|
953
|
+
this._pauseStart = 0;
|
|
954
|
+
this._valuesStart = {};
|
|
955
|
+
this._valuesEnd = {};
|
|
956
|
+
this._valuesStartRepeat = {};
|
|
957
|
+
this._duration = 0;
|
|
958
|
+
this._isDynamic = false;
|
|
959
|
+
this._initialRepeat = 0;
|
|
960
|
+
this._repeat = 0;
|
|
961
|
+
this._yoyo = false;
|
|
962
|
+
this._isPlaying = false;
|
|
963
|
+
this._reversed = false;
|
|
964
|
+
this._delayTime = 0;
|
|
965
|
+
this._startTime = 0;
|
|
966
|
+
this._easingFunction = Easing.Linear.None;
|
|
967
|
+
this._interpolationFunction = Interpolation.Linear;
|
|
968
|
+
this._chainedTweens = [];
|
|
969
|
+
this._onStartCallbackFired = false;
|
|
970
|
+
this._onEveryStartCallbackFired = false;
|
|
971
|
+
this._id = Sequence.nextId();
|
|
972
|
+
this._isChainStopped = false;
|
|
973
|
+
this._propertiesAreSetUp = false;
|
|
974
|
+
this._headTween = null;
|
|
975
|
+
this._tailTween = null;
|
|
976
|
+
this._headStart = false;
|
|
977
|
+
this._goToEnd = false;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
934
980
|
|
|
935
981
|
class TweenChain {
|
|
936
982
|
start() {
|
|
@@ -946,7 +992,7 @@ class TweenChain {
|
|
|
946
992
|
return this;
|
|
947
993
|
}
|
|
948
994
|
union() {
|
|
949
|
-
this._chainedTween = this._tween = new Tween(this._object).union(this._tween, this._chainedTween);
|
|
995
|
+
this._chainedTween = this._tween = new Tween(this._object, this._group).union(this._tween, this._chainedTween);
|
|
950
996
|
return this;
|
|
951
997
|
}
|
|
952
998
|
call(callback) {
|
|
@@ -993,9 +1039,6 @@ class TweenManager {
|
|
|
993
1039
|
update(time) {
|
|
994
1040
|
this._group.update(time);
|
|
995
1041
|
}
|
|
996
|
-
tween(target) {
|
|
997
|
-
return new Tween(target, this._group);
|
|
998
|
-
}
|
|
999
1042
|
timeline(target) {
|
|
1000
1043
|
return new TweenChain(target, this._group);
|
|
1001
1044
|
}
|
|
@@ -1401,20 +1444,14 @@ class CinestationBrain extends Component {
|
|
|
1401
1444
|
const from = this.node, to = vcam;
|
|
1402
1445
|
const { fov, near, far, finalPosition, finalRotation } = to;
|
|
1403
1446
|
const isLensChanged = from.fov != fov || from.near != near || from.far != far;
|
|
1404
|
-
const isTransformChanged = !from.position.equals(finalPosition) || !from.quaternion.equals(finalRotation);
|
|
1405
|
-
const isChanged = isLensChanged || isTransformChanged;
|
|
1406
1447
|
from.position.lerp(finalPosition, t);
|
|
1407
1448
|
from.quaternion.slerp(finalRotation, t);
|
|
1408
1449
|
from.fov = lerp$1(from.fov, fov, t);
|
|
1409
|
-
from.near =
|
|
1410
|
-
from.far =
|
|
1450
|
+
from.near = near;
|
|
1451
|
+
from.far = far;
|
|
1411
1452
|
if (isLensChanged) {
|
|
1412
1453
|
from.updateProjectionMatrix();
|
|
1413
1454
|
}
|
|
1414
|
-
if (this._isChanged !== isChanged) {
|
|
1415
|
-
this._isChanged = isChanged;
|
|
1416
|
-
this.onChanged && this.onChanged(isChanged);
|
|
1417
|
-
}
|
|
1418
1455
|
}
|
|
1419
1456
|
constructor(...args){
|
|
1420
1457
|
super(...args);
|
|
@@ -1422,9 +1459,7 @@ class CinestationBrain extends Component {
|
|
|
1422
1459
|
this._vcamSolo = null;
|
|
1423
1460
|
this._vcams = [];
|
|
1424
1461
|
this._lerpTime = 0;
|
|
1425
|
-
this._isChanged = false;
|
|
1426
1462
|
this.brainBlend = new CinestationBlendDefinition();
|
|
1427
|
-
this.onChanged = null;
|
|
1428
1463
|
}
|
|
1429
1464
|
}
|
|
1430
1465
|
__decorate([
|
|
@@ -1451,11 +1486,6 @@ class VirtualCamera extends Component {
|
|
|
1451
1486
|
onDestroy() {
|
|
1452
1487
|
this.brain.removeCamera(this);
|
|
1453
1488
|
}
|
|
1454
|
-
update(dt) {
|
|
1455
|
-
if (this.lookAt) {
|
|
1456
|
-
this.node.lookAt(this.lookAt.position);
|
|
1457
|
-
}
|
|
1458
|
-
}
|
|
1459
1489
|
constructor(...args){
|
|
1460
1490
|
super(...args);
|
|
1461
1491
|
this._finalPosition = new three.Vector3();
|
|
@@ -1468,8 +1498,6 @@ class VirtualCamera extends Component {
|
|
|
1468
1498
|
this.far = 1000;
|
|
1469
1499
|
this.correctPosition = new three.Vector3();
|
|
1470
1500
|
this.correctRotation = new three.Quaternion();
|
|
1471
|
-
this.lookaheadPosition = new three.Vector3();
|
|
1472
|
-
this.trackedObjectOffset = new three.Vector3();
|
|
1473
1501
|
}
|
|
1474
1502
|
}
|
|
1475
1503
|
__decorate([
|
|
@@ -2586,7 +2614,13 @@ const { clamp, degToRad } = three.MathUtils;
|
|
|
2586
2614
|
const { abs, tan } = Math;
|
|
2587
2615
|
class FreelookVirtualCamera extends VirtualCamera {
|
|
2588
2616
|
printInfo() {
|
|
2589
|
-
|
|
2617
|
+
const spherical = this._spherical;
|
|
2618
|
+
const lookAt = new three.Vector3().copy(this.lookAt.position).add(this._lookAtOffset);
|
|
2619
|
+
console.log([
|
|
2620
|
+
`springLength: ${spherical.radius.toFixed(2)}`,
|
|
2621
|
+
`rotation: ${spherical.theta.toFixed(2)}, ${spherical.phi.toFixed(2)}`,
|
|
2622
|
+
`lookAt: ${lookAt.x.toFixed(2)},${lookAt.y.toFixed(2)},${lookAt.z.toFixed(2)}`
|
|
2623
|
+
].join("\n"));
|
|
2590
2624
|
}
|
|
2591
2625
|
onEnable() {
|
|
2592
2626
|
this.viewer.on(DeviceInput.POINTER_DOWN, this._onPointerDown, this);
|
|
@@ -2608,9 +2642,16 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2608
2642
|
reset() {
|
|
2609
2643
|
this._button = -1;
|
|
2610
2644
|
this._touchID = -1;
|
|
2611
|
-
this.
|
|
2612
|
-
|
|
2613
|
-
|
|
2645
|
+
this._setSpherical(this.node.position, this.lookAtPosition);
|
|
2646
|
+
}
|
|
2647
|
+
get lookAtPosition() {
|
|
2648
|
+
return this._lookAtPosition.copy(this.lookAt.position).add(this._lookAtOffset);
|
|
2649
|
+
}
|
|
2650
|
+
_setSpherical(position, lookAt) {
|
|
2651
|
+
const { __posDelta } = FreelookVirtualCamera;
|
|
2652
|
+
__posDelta.copy(position).sub(lookAt);
|
|
2653
|
+
this._spherical.setFromVector3(__posDelta);
|
|
2654
|
+
this._targetSpherical.copy(this._spherical);
|
|
2614
2655
|
}
|
|
2615
2656
|
_onPointerDown(e) {
|
|
2616
2657
|
if (SystemInfo.isMobile) return;
|
|
@@ -2623,30 +2664,28 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2623
2664
|
}
|
|
2624
2665
|
_onPointerMove(e) {
|
|
2625
2666
|
if (SystemInfo.isMobile) return;
|
|
2626
|
-
const { __loc0,
|
|
2667
|
+
const { __loc0, __panDelta, __rotateDelta } = FreelookVirtualCamera;
|
|
2627
2668
|
__loc0.set(e.pageX, e.pageY);
|
|
2628
2669
|
switch(this._button){
|
|
2629
2670
|
case 0:
|
|
2630
|
-
this.
|
|
2671
|
+
this._calculateRotatelDelta(__rotateDelta, this._preLoc0, __loc0);
|
|
2672
|
+
this._calculateSpherical(__rotateDelta);
|
|
2631
2673
|
break;
|
|
2632
2674
|
case 1:
|
|
2633
2675
|
case 2:
|
|
2634
|
-
this.
|
|
2676
|
+
this._calculatePanDelta(__panDelta, this._preLoc0, __loc0);
|
|
2677
|
+
this._calculateLookAtOffset(__panDelta);
|
|
2635
2678
|
break;
|
|
2636
2679
|
}
|
|
2637
2680
|
this._preLoc0.copy(__loc0);
|
|
2638
2681
|
}
|
|
2639
2682
|
_onMouseWheel(e) {
|
|
2640
|
-
const { __worldPos } = FreelookVirtualCamera;
|
|
2641
2683
|
if (this.lookAt) {
|
|
2642
|
-
let dist = __worldPos.copy(this.lookAt.position).add(this.trackedObjectOffset).distanceTo(this.node.position);
|
|
2643
|
-
let distNew = dist + this._distanceDelta;
|
|
2644
2684
|
if (e.deltaY > 0) {
|
|
2645
|
-
|
|
2685
|
+
this._targetSpherical.radius *= this._calculateDistanceScale(1 / 0.85);
|
|
2646
2686
|
} else if (e.deltaY < 0) {
|
|
2647
|
-
|
|
2687
|
+
this._targetSpherical.radius *= this._calculateDistanceScale(0.85);
|
|
2648
2688
|
}
|
|
2649
|
-
this._distanceDelta = distNew - dist;
|
|
2650
2689
|
}
|
|
2651
2690
|
}
|
|
2652
2691
|
_onTouchStart(e) {
|
|
@@ -2663,37 +2702,39 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2663
2702
|
}
|
|
2664
2703
|
_onTouchMove(e) {
|
|
2665
2704
|
if (!SystemInfo.isMobile) return;
|
|
2666
|
-
const { __loc0, __loc1,
|
|
2705
|
+
const { __loc0, __loc1, __panDelta, __rotateDelta, __preCenter, __center } = FreelookVirtualCamera;
|
|
2667
2706
|
let touches = e.touches;
|
|
2668
2707
|
let rotateTouchID = this.rotateTouchID;
|
|
2669
2708
|
if (touches.length > rotateTouchID + 1) {
|
|
2670
2709
|
__loc0.set(touches[rotateTouchID].pageX, touches[rotateTouchID].pageY);
|
|
2671
2710
|
__loc1.set(touches[rotateTouchID + 1].pageX, touches[rotateTouchID + 1].pageY);
|
|
2672
2711
|
if (this.lookAt) {
|
|
2673
|
-
|
|
2674
|
-
let distNew = (dist + this._distanceDelta) * this._calculateDistanceScale(this._preLoc0.distanceTo(this._preLoc1) / __loc0.distanceTo(__loc1));
|
|
2675
|
-
this._distanceDelta = distNew - dist;
|
|
2712
|
+
this._targetSpherical.radius *= this._calculateDistanceScale(this._preLoc0.distanceTo(this._preLoc1) / __loc0.distanceTo(__loc1));
|
|
2676
2713
|
}
|
|
2677
2714
|
__preCenter.copy(this._preLoc0).add(this._preLoc1).multiplyScalar(0.5);
|
|
2678
2715
|
__center.copy(__loc0).add(__loc1).multiplyScalar(0.5);
|
|
2679
|
-
this.
|
|
2716
|
+
this._calculatePanDelta(__panDelta, __preCenter, __center);
|
|
2717
|
+
this._calculateLookAtOffset(__panDelta);
|
|
2680
2718
|
this._preLoc0.copy(__loc0);
|
|
2681
2719
|
this._preLoc1.copy(__loc1);
|
|
2682
2720
|
} else if (touches.length > rotateTouchID) {
|
|
2683
2721
|
if (this._touchID === touches[rotateTouchID].identifier) {
|
|
2684
2722
|
__loc0.set(touches[rotateTouchID].pageX, touches[rotateTouchID].pageY);
|
|
2685
|
-
this.
|
|
2723
|
+
this._calculateRotatelDelta(__rotateDelta, this._preLoc0, __loc0);
|
|
2724
|
+
this._calculateSpherical(__rotateDelta);
|
|
2686
2725
|
this._preLoc0.copy(__loc0);
|
|
2687
2726
|
}
|
|
2688
2727
|
}
|
|
2689
2728
|
}
|
|
2690
2729
|
_calculateDistanceScale(scale) {
|
|
2730
|
+
this._tempSmoothing = this.smoothing;
|
|
2691
2731
|
if (this.forbidZ) {
|
|
2692
2732
|
scale = 1;
|
|
2693
2733
|
}
|
|
2694
2734
|
return scale;
|
|
2695
2735
|
}
|
|
2696
|
-
|
|
2736
|
+
_calculateRotatelDelta(out, loc0, loc1) {
|
|
2737
|
+
this._tempSmoothing = this.smoothing;
|
|
2697
2738
|
const domElement = this.viewer.canvas;
|
|
2698
2739
|
out.copy(loc1).sub(loc0).multiplyScalar(this.rotateSpeed * 2 * Math.PI / domElement.height);
|
|
2699
2740
|
out.y = -out.y;
|
|
@@ -2703,10 +2744,10 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2703
2744
|
if (this.forbidY) {
|
|
2704
2745
|
out.y = 0;
|
|
2705
2746
|
}
|
|
2706
|
-
this._tempSmoothing = this.smoothing;
|
|
2707
2747
|
return out;
|
|
2708
2748
|
}
|
|
2709
2749
|
_calculatePanDelta(out, loc0, loc1) {
|
|
2750
|
+
this._tempSmoothing = this.smoothing;
|
|
2710
2751
|
const domElement = this.viewer.canvas;
|
|
2711
2752
|
out.copy(loc1).sub(loc0).multiplyScalar(this.panSpeed / domElement.height);
|
|
2712
2753
|
if (this.forbidPanX) {
|
|
@@ -2715,85 +2756,77 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2715
2756
|
if (this.forbidPanY) {
|
|
2716
2757
|
out.y = 0;
|
|
2717
2758
|
}
|
|
2718
|
-
this._tempSmoothing = this.smoothing;
|
|
2719
2759
|
return out;
|
|
2720
2760
|
}
|
|
2721
|
-
|
|
2722
|
-
const {
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
__posDelta.copy(this.node.position).sub(
|
|
2730
|
-
__posDelta.
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
const
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2761
|
+
_calculateLookAtOffset(panDelta) {
|
|
2762
|
+
const { __xAxis, __yAxis, __posDelta } = FreelookVirtualCamera;
|
|
2763
|
+
__xAxis.setFromMatrixColumn(this.node.matrix, 0);
|
|
2764
|
+
__yAxis.setFromMatrixColumn(this.node.matrix, 1);
|
|
2765
|
+
if (this.forbitPanOffsetY) {
|
|
2766
|
+
__yAxis.y = 0;
|
|
2767
|
+
__yAxis.normalize();
|
|
2768
|
+
}
|
|
2769
|
+
__posDelta.copy(this.node.position).sub(this.lookAtPosition);
|
|
2770
|
+
const length = __posDelta.length() * 2 * tan(degToRad(this.fov * 0.5));
|
|
2771
|
+
return this._targetLookAtOffset.sub(__xAxis.multiplyScalar(panDelta.x * length)).add(__yAxis.multiplyScalar(panDelta.y * length));
|
|
2772
|
+
}
|
|
2773
|
+
_calculateSpherical(rotateDelta, radius) {
|
|
2774
|
+
const spherical = this._targetSpherical;
|
|
2775
|
+
if (rotateDelta) {
|
|
2776
|
+
spherical.theta -= rotateDelta.x;
|
|
2777
|
+
spherical.phi += rotateDelta.y;
|
|
2778
|
+
}
|
|
2779
|
+
if (radius) {
|
|
2780
|
+
spherical.radius = radius;
|
|
2781
|
+
}
|
|
2782
|
+
spherical.theta = clamp(spherical.theta, this.thetaMin, this.thetaMax);
|
|
2783
|
+
spherical.phi = clamp(spherical.phi, this.phiMin, this.phiMax);
|
|
2784
|
+
spherical.radius = clamp(spherical.radius, this.distanceMin, this.distanceMax);
|
|
2785
|
+
return spherical;
|
|
2786
|
+
}
|
|
2787
|
+
gotoPOI(springLength, rotation, lookAt, fov = this.fov, smoothing = this.smoothing) {
|
|
2788
|
+
this._targetFov = fov;
|
|
2738
2789
|
this._tempSmoothing = smoothing;
|
|
2790
|
+
this._targetSpherical.radius = springLength;
|
|
2791
|
+
if (rotation) {
|
|
2792
|
+
this._targetSpherical.theta = rotation.x;
|
|
2793
|
+
this._targetSpherical.phi = rotation.y;
|
|
2794
|
+
}
|
|
2795
|
+
this._calculateSpherical();
|
|
2796
|
+
if (lookAt) {
|
|
2797
|
+
this._targetLookAtOffset.copy(lookAt).sub(this.lookAt.position);
|
|
2798
|
+
}
|
|
2739
2799
|
}
|
|
2740
2800
|
update(dt) {
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
__spherical.setFromVector3(__posDelta);
|
|
2750
|
-
this._rotateDelta.x = __spherical.theta - clamp(__spherical.theta - this._rotateDelta.x, this.thetaMin, this.thetaMax);
|
|
2751
|
-
__spherical.theta = __spherical.theta - this._rotateDelta.x * (1 - dampFactor);
|
|
2752
|
-
this._rotateDelta.y = clamp(__spherical.phi + this._rotateDelta.y, this.phiMin, this.phiMax) - __spherical.phi;
|
|
2753
|
-
__spherical.phi = clamp(__spherical.phi + this._rotateDelta.y * (1 - dampFactor), 0.001, Math.PI - 0.001);
|
|
2754
|
-
this._distanceDelta = clamp(__spherical.radius + this._distanceDelta, this.distanceMin, this.distanceMax) - __spherical.radius;
|
|
2755
|
-
__spherical.radius = __spherical.radius + this._distanceDelta * (1 - dampFactor);
|
|
2756
|
-
this._rotateDelta.multiplyScalar(dampFactor);
|
|
2757
|
-
this._distanceDelta *= dampFactor;
|
|
2758
|
-
__posDelta.setFromSpherical(__spherical);
|
|
2759
|
-
__posDelta.applyQuaternion(__quat.invert());
|
|
2760
|
-
this.node.position.copy(__posDelta.add(__worldPos));
|
|
2761
|
-
}
|
|
2762
|
-
if (this._panDelta.manhattanLength() > 0.001) {
|
|
2763
|
-
__posDelta.copy(this.node.position).sub(__worldPos);
|
|
2764
|
-
__xAxis.setFromMatrixColumn(this.node.matrix, 0);
|
|
2765
|
-
__yAxis.setFromMatrixColumn(this.node.matrix, 1);
|
|
2766
|
-
if (this.forbitPanOffsetY) {
|
|
2767
|
-
__yAxis.y = 0;
|
|
2768
|
-
__yAxis.normalize();
|
|
2769
|
-
}
|
|
2770
|
-
let length = __posDelta.length() * 2 * tan(degToRad(this.fov * 0.5));
|
|
2771
|
-
let trackedObjectOffset = this.trackedObjectOffset;
|
|
2772
|
-
trackedObjectOffset.sub(__xAxis.multiplyScalar(this._panDelta.x * length * (1 - dampFactor)));
|
|
2773
|
-
trackedObjectOffset.add(__yAxis.multiplyScalar(this._panDelta.y * length * (1 - dampFactor)));
|
|
2774
|
-
this._panDelta.multiplyScalar(dampFactor);
|
|
2775
|
-
__worldPos.copy(this.lookAt.position).add(trackedObjectOffset);
|
|
2776
|
-
this.node.position.copy(__posDelta.add(__worldPos));
|
|
2777
|
-
}
|
|
2778
|
-
this.node.lookAt(__worldPos);
|
|
2801
|
+
const smoothing = this._tempSmoothing;
|
|
2802
|
+
this._spherical.theta = FInterpTo(this._spherical.theta, this._targetSpherical.theta, dt, smoothing);
|
|
2803
|
+
this._spherical.phi = FInterpTo(this._spherical.phi, this._targetSpherical.phi, dt, smoothing);
|
|
2804
|
+
this._spherical.radius = FInterpTo(this._spherical.radius, this._targetSpherical.radius, dt, smoothing);
|
|
2805
|
+
this.node.position.setFromSpherical(this._spherical).add(this.lookAtPosition);
|
|
2806
|
+
this.fov = FInterpTo(this.fov, this._targetFov, dt, smoothing);
|
|
2807
|
+
VInterpTo(this._lookAtOffset, this._targetLookAtOffset, dt, smoothing);
|
|
2808
|
+
this.node.lookAt(this.lookAtPosition);
|
|
2779
2809
|
}
|
|
2780
2810
|
constructor(...args){
|
|
2781
2811
|
super(...args);
|
|
2782
2812
|
this._button = -1;
|
|
2783
2813
|
this._touchID = -1;
|
|
2784
|
-
this._distanceDelta = 0;
|
|
2785
2814
|
this._preLoc0 = new three.Vector2();
|
|
2786
2815
|
this._preLoc1 = new three.Vector2();
|
|
2787
|
-
this.
|
|
2788
|
-
this.
|
|
2816
|
+
this._spherical = new three.Spherical();
|
|
2817
|
+
this._lookAtPosition = new three.Vector3();
|
|
2818
|
+
this._lookAtOffset = new three.Vector3();
|
|
2789
2819
|
this._tempSmoothing = 0;
|
|
2820
|
+
this._targetFov = this.fov;
|
|
2821
|
+
this._targetLookAtOffset = new three.Vector3();
|
|
2822
|
+
this._targetSpherical = new three.Spherical();
|
|
2790
2823
|
this.forbidX = false;
|
|
2791
2824
|
this.forbidY = false;
|
|
2792
2825
|
this.forbidZ = false;
|
|
2793
2826
|
this.forbidPanX = false;
|
|
2794
2827
|
this.forbidPanY = false;
|
|
2795
2828
|
this.forbitPanOffsetY = false;
|
|
2796
|
-
this.smoothing =
|
|
2829
|
+
this.smoothing = 5;
|
|
2797
2830
|
this.rotateSpeed = 2;
|
|
2798
2831
|
this.panSpeed = 2;
|
|
2799
2832
|
this.panScale = new three.Vector3(1, 1, 1);
|
|
@@ -2811,13 +2844,13 @@ FreelookVirtualCamera.__loc0 = new three.Vector2();
|
|
|
2811
2844
|
FreelookVirtualCamera.__loc1 = new three.Vector2();
|
|
2812
2845
|
FreelookVirtualCamera.__center = new three.Vector2();
|
|
2813
2846
|
FreelookVirtualCamera.__preCenter = new three.Vector2();
|
|
2814
|
-
FreelookVirtualCamera.
|
|
2815
|
-
FreelookVirtualCamera.
|
|
2847
|
+
FreelookVirtualCamera.__panDelta = new three.Vector2();
|
|
2848
|
+
FreelookVirtualCamera.__panTarget = new three.Vector2();
|
|
2849
|
+
FreelookVirtualCamera.__rotateDelta = new three.Vector2();
|
|
2816
2850
|
FreelookVirtualCamera.__posDelta = new three.Vector3();
|
|
2817
2851
|
FreelookVirtualCamera.__xAxis = new three.Vector3();
|
|
2818
2852
|
FreelookVirtualCamera.__yAxis = new three.Vector3();
|
|
2819
2853
|
FreelookVirtualCamera.__quat = new three.Quaternion();
|
|
2820
|
-
FreelookVirtualCamera.__spherical = new three.Spherical();
|
|
2821
2854
|
__decorate([
|
|
2822
2855
|
property({
|
|
2823
2856
|
dir: "set"
|
|
@@ -4564,9 +4597,6 @@ class Viewer extends EventEmitter {
|
|
|
4564
4597
|
this.addNode(node, props);
|
|
4565
4598
|
return node;
|
|
4566
4599
|
}
|
|
4567
|
-
tween(target) {
|
|
4568
|
-
return this._tweenManager.tween(target);
|
|
4569
|
-
}
|
|
4570
4600
|
timeline(target) {
|
|
4571
4601
|
return this._tweenManager.timeline(target);
|
|
4572
4602
|
}
|