@needle-tools/engine 3.19.3 → 3.19.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/CHANGELOG.md +6 -1
- package/dist/needle-engine.js +3106 -3102
- package/dist/needle-engine.light.js +2906 -2902
- package/dist/needle-engine.light.min.js +140 -140
- package/dist/needle-engine.light.umd.cjs +96 -96
- package/dist/needle-engine.min.js +141 -141
- package/dist/needle-engine.umd.cjs +97 -97
- package/lib/engine-components/Animation.js +6 -6
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/OrbitControls.js +2 -1
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/VideoPlayer.d.ts +1 -2
- package/lib/engine-components/VideoPlayer.js +9 -7
- package/lib/engine-components/VideoPlayer.js.map +1 -1
- package/lib/engine-components/timeline/PlayableDirector.js +50 -36
- package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
- package/lib/engine-components/timeline/TimelineModels.d.ts +2 -2
- package/package.json +1 -1
- package/src/engine-components/Animation.ts +5 -4
- package/src/engine-components/OrbitControls.ts +2 -1
- package/src/engine-components/VideoPlayer.ts +7 -5
- package/src/engine-components/timeline/PlayableDirector.ts +48 -34
- package/src/engine-components/timeline/TimelineModels.ts +2 -2
|
@@ -41,12 +41,12 @@ export class Animation extends Behaviour {
|
|
|
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 @@ export class Animation extends Behaviour {
|
|
|
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 @@ export class Animation extends Behaviour {
|
|
|
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 @@ export class OrbitControls extends Behaviour implements ICameraController {
|
|
|
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;
|
|
@@ -45,8 +45,6 @@ export enum VideoRenderMode {
|
|
|
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 @@ export class VideoPlayer extends Behaviour {
|
|
|
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 @@ export class VideoPlayer extends Behaviour {
|
|
|
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 @@ export class VideoPlayer extends Behaviour {
|
|
|
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) {
|
|
@@ -325,9 +325,11 @@ export class PlayableDirector extends Behaviour {
|
|
|
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,20 +413,22 @@ export class PlayableDirector extends Behaviour {
|
|
|
411
413
|
}
|
|
412
414
|
}
|
|
413
415
|
if (track.type === Models.TrackType.Control) {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
if (
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
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
|
+
}
|
|
428
432
|
}
|
|
429
433
|
}
|
|
430
434
|
}
|
|
@@ -443,11 +447,15 @@ export class PlayableDirector extends Behaviour {
|
|
|
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 @@ export class PlayableDirector extends Behaviour {
|
|
|
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 @@ export class PlayableDirector extends Behaviour {
|
|
|
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 @@ export class PlayableDirector extends Behaviour {
|
|
|
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 @@ export class PlayableDirector extends Behaviour {
|
|
|
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 @@ export class PlayableDirector extends Behaviour {
|
|
|
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 @@ export declare type TrackModel = {
|
|
|
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
|
|