@@ -41,12 +41,12 @@
|
|
41
41
|
}
|
42
42
|
set clip(val: AnimationClip | null) {
|
43
43
|
if (!this.__didAwake) {
|
44
|
-
if (debug) console.
|
44
|
+
if (debug) console.warn("Assign clip during serialization", val);
|
45
45
|
this._tempAnimationClipBeforeGameObjectExisted = val;
|
46
46
|
return;
|
47
47
|
}
|
48
48
|
if (!val) return;
|
49
|
-
if (debug) console.log("Assign clip", val, Boolean(this.gameObject));
|
49
|
+
// if (debug) console.log("Assign clip", val, Boolean(this.gameObject));
|
50
50
|
if (!this.gameObject.animations) this.gameObject.animations = [];
|
51
51
|
if (this.animations.includes(val)) return;
|
52
52
|
if (this.animations.length > 0) {
|
@@ -62,7 +62,8 @@
|
|
62
62
|
}
|
63
63
|
|
64
64
|
set animations(animations: AnimationClip[]) {
|
65
|
-
if
|
65
|
+
if(animations === null || animations === undefined || !Array.isArray(animations)) return;
|
66
|
+
// if (debug) console.warn("assign animations", this.name, animations, this.gameObject);
|
66
67
|
this.gameObject.animations = animations;
|
67
68
|
}
|
68
69
|
|
@@ -98,7 +99,7 @@
|
|
98
99
|
private _handles: AnimationHandle[] = [];
|
99
100
|
|
100
101
|
awake() {
|
101
|
-
if (debug) console.log(this);
|
102
|
+
if (debug) console.log("Animation Awake", this.name, this);
|
102
103
|
if (this._tempAnimationClipBeforeGameObjectExisted) {
|
103
104
|
this.clip = this._tempAnimationClipBeforeGameObjectExisted;
|
104
105
|
this._tempAnimationClipBeforeGameObjectExisted = null;
|
@@ -440,7 +440,8 @@
|
|
440
440
|
// If we encountered some geometry that should be ignored
|
441
441
|
// Then we don't want to use that for expanding the view
|
442
442
|
if (allowExpanding) {
|
443
|
-
|
443
|
+
if (debugCameraFit)
|
444
|
+
console.log(obj.name, obj.type, obj);
|
444
445
|
// Temporary override children
|
445
446
|
const children_length = obj.children;
|
446
447
|
obj.children = emptyChildren;
|
@@ -325,9 +325,11 @@
|
|
325
325
|
const binding = track.outputs[i];
|
326
326
|
if (typeof binding === "object") {
|
327
327
|
let isActive: boolean = false;
|
328
|
-
|
329
|
-
|
330
|
-
|
328
|
+
if (track.clips) {
|
329
|
+
for (const clip of track.clips) {
|
330
|
+
if (clip.start <= time && time <= clip.end) {
|
331
|
+
isActive = true;
|
332
|
+
}
|
331
333
|
}
|
332
334
|
}
|
333
335
|
const obj = binding as THREE.Object3D;
|
@@ -411,21 +413,23 @@
|
|
411
413
|
}
|
412
414
|
}
|
413
415
|
if (track.type === Models.TrackType.Control) {
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
if (
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
416
|
+
if (track.clips) {
|
417
|
+
for (let i = 0; i < track.clips.length; i++) {
|
418
|
+
const clip = track.clips[i];
|
419
|
+
let binding = clip.asset.sourceObject;
|
420
|
+
if (typeof binding === "string") {
|
421
|
+
if (this._guidsMap && this._guidsMap[binding])
|
422
|
+
binding = this._guidsMap[binding];
|
423
|
+
const obj = GameObject.findByGuid(binding, root);
|
424
|
+
if (obj === null || typeof obj !== "object") {
|
425
|
+
console.warn("Failed to resolve sourceObject binding", binding, track.name, clip);
|
426
|
+
}
|
427
|
+
else {
|
428
|
+
if (debug)
|
429
|
+
console.log("Resolved binding", binding, "to", obj);
|
430
|
+
clip.asset.sourceObject = obj;
|
431
|
+
}
|
423
432
|
}
|
424
|
-
else {
|
425
|
-
if (debug)
|
426
|
-
console.log("Resolved binding", binding, "to", obj);
|
427
|
-
clip.asset.sourceObject = obj;
|
428
|
-
}
|
429
433
|
}
|
430
434
|
}
|
431
435
|
}
|
@@ -443,11 +447,15 @@
|
|
443
447
|
if (!this.playableAsset || !this.playableAsset.tracks) return;
|
444
448
|
for (const track of this.playableAsset.tracks) {
|
445
449
|
if (track.muted === true) continue;
|
446
|
-
|
447
|
-
|
450
|
+
if (track.clips) {
|
451
|
+
for (const clip of track.clips) {
|
452
|
+
if (clip.end > this._duration) this._duration = clip.end;
|
453
|
+
}
|
448
454
|
}
|
449
|
-
|
450
|
-
|
455
|
+
if (track.markers) {
|
456
|
+
for (const marker of track.markers) {
|
457
|
+
if (marker.time > this._duration) this._duration = marker.time + .001;
|
458
|
+
}
|
451
459
|
}
|
452
460
|
}
|
453
461
|
// console.log("timeline duration", this._duration, this.playableAsset);
|
@@ -474,7 +482,7 @@
|
|
474
482
|
}
|
475
483
|
// only handle animation tracks
|
476
484
|
if (track.type === Models.TrackType.Animation) {
|
477
|
-
if (track.clips.length <= 0) {
|
485
|
+
if (!track.clips || track.clips.length <= 0) {
|
478
486
|
if (debug) console.warn("Animation track has no clips", track);
|
479
487
|
continue;
|
480
488
|
}
|
@@ -533,7 +541,7 @@
|
|
533
541
|
}
|
534
542
|
}
|
535
543
|
else if (track.type === Models.TrackType.Audio) {
|
536
|
-
if (track.clips.length <= 0) continue;
|
544
|
+
if (!track.clips || track.clips.length <= 0) continue;
|
537
545
|
const audio = new Tracks.AudioTrackHandler();
|
538
546
|
audio.director = this;
|
539
547
|
audio.track = track;
|
@@ -549,12 +557,14 @@
|
|
549
557
|
const signalHandler: Tracks.SignalTrackHandler = new Tracks.SignalTrackHandler();
|
550
558
|
signalHandler.director = this;
|
551
559
|
signalHandler.track = track;
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
560
|
+
if (track.markers) {
|
561
|
+
for (const marker of track.markers) {
|
562
|
+
switch (marker.type) {
|
563
|
+
case Models.MarkerType.Signal:
|
564
|
+
signalHandler.models.push(marker as Models.SignalMarkerModel);
|
565
|
+
signalHandler.didTrigger.push(false);
|
566
|
+
break;
|
567
|
+
}
|
558
568
|
}
|
559
569
|
}
|
560
570
|
if (signalHandler !== null && signalHandler.models.length > 0) {
|
@@ -569,9 +579,11 @@
|
|
569
579
|
const handler = new Tracks.SignalTrackHandler();
|
570
580
|
handler.director = this;
|
571
581
|
handler.track = track;
|
572
|
-
|
573
|
-
|
574
|
-
|
582
|
+
if (track.markers) {
|
583
|
+
for (const marker of track.markers) {
|
584
|
+
handler.models.push(marker as Models.SignalMarkerModel);
|
585
|
+
handler.didTrigger.push(false);
|
586
|
+
}
|
575
587
|
}
|
576
588
|
for (const bound of track.outputs) {
|
577
589
|
handler.receivers.push(bound as SignalReceiver);
|
@@ -582,8 +594,10 @@
|
|
582
594
|
const handler = new Tracks.ControlTrackHandler();
|
583
595
|
handler.director = this;
|
584
596
|
handler.track = track;
|
585
|
-
|
586
|
-
|
597
|
+
if (track.clips) {
|
598
|
+
for (const clip of track.clips) {
|
599
|
+
handler.models.push(clip);
|
600
|
+
}
|
587
601
|
}
|
588
602
|
handler.resolveSourceObjects(this.context);
|
589
603
|
this._controlTracks.push(handler);
|
@@ -28,8 +28,8 @@
|
|
28
28
|
type: TrackType;
|
29
29
|
muted: boolean;
|
30
30
|
outputs: Array<null | string | object>;
|
31
|
-
clips
|
32
|
-
markers
|
31
|
+
clips?: Array<ClipModel>;
|
32
|
+
markers?: Array<MarkerModel>;
|
33
33
|
trackOffset?: TrackOffset;
|
34
34
|
}
|
35
35
|
|
@@ -45,8 +45,6 @@
|
|
45
45
|
|
46
46
|
export class VideoPlayer extends Behaviour {
|
47
47
|
|
48
|
-
@serializable(Object3D)
|
49
|
-
renderer: Object3D | null = null;
|
50
48
|
@serializable()
|
51
49
|
playOnAwake: boolean = true;
|
52
50
|
|
@@ -166,8 +164,8 @@
|
|
166
164
|
|
167
165
|
private _crossOrigin: string | null = "anonymous";
|
168
166
|
|
169
|
-
|
170
|
-
private source
|
167
|
+
// set a default src, this should not be undefined
|
168
|
+
private source: VideoSource = VideoSource.Url;
|
171
169
|
private url?: string | null = null;
|
172
170
|
|
173
171
|
private _videoElement: HTMLVideoElement | null = null;
|
@@ -207,6 +205,7 @@
|
|
207
205
|
}
|
208
206
|
|
209
207
|
onEnable(): void {
|
208
|
+
if(debug) console.log("VideoPlayer.onEnable", this)
|
210
209
|
window.addEventListener('visibilitychange', this.visibilityChanged);
|
211
210
|
|
212
211
|
if (this.playOnAwake === true) {
|
@@ -316,7 +315,10 @@
|
|
316
315
|
break;
|
317
316
|
}
|
318
317
|
|
319
|
-
if (!src)
|
318
|
+
if (!src) {
|
319
|
+
if(debug) console.warn("No video source set", this);
|
320
|
+
return;
|
321
|
+
}
|
320
322
|
|
321
323
|
|
322
324
|
if (!this._videoElement) {
|