@needle-tools/engine 3.37.4-alpha → 3.37.6-alpha
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 +12 -0
- package/dist/needle-engine.js +258 -186
- package/dist/needle-engine.light.js +258 -186
- package/dist/needle-engine.light.min.js +25 -25
- package/dist/needle-engine.light.umd.cjs +156 -156
- package/dist/needle-engine.min.js +25 -25
- package/dist/needle-engine.umd.cjs +49 -49
- package/lib/engine/extensions/NEEDLE_progressive.d.ts +1 -0
- package/lib/engine/extensions/NEEDLE_progressive.js +7 -1
- package/lib/engine/extensions/NEEDLE_progressive.js.map +1 -1
- package/lib/engine-components/DropListener.d.ts +31 -3
- package/lib/engine-components/DropListener.js +30 -2
- package/lib/engine-components/DropListener.js.map +1 -1
- package/lib/engine-components/OrbitControls.d.ts +16 -3
- package/lib/engine-components/OrbitControls.js +25 -9
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/ParticleSystem.d.ts +31 -1
- package/lib/engine-components/ParticleSystem.js +42 -1
- package/lib/engine-components/ParticleSystem.js.map +1 -1
- package/lib/engine-components/SceneSwitcher.d.ts +22 -2
- package/lib/engine-components/SceneSwitcher.js +29 -3
- package/lib/engine-components/SceneSwitcher.js.map +1 -1
- package/lib/engine-components/VideoPlayer.d.ts +5 -3
- package/lib/engine-components/VideoPlayer.js +26 -14
- package/lib/engine-components/VideoPlayer.js.map +1 -1
- package/lib/engine-components/webxr/WebARCameraBackground.js +8 -0
- package/lib/engine-components/webxr/WebARCameraBackground.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/extensions/NEEDLE_progressive.ts +9 -1
- package/src/engine-components/DropListener.ts +30 -2
- package/src/engine-components/OrbitControls.ts +29 -11
- package/src/engine-components/ParticleSystem.ts +44 -4
- package/src/engine-components/SceneSwitcher.ts +45 -5
- package/src/engine-components/VideoPlayer.ts +25 -13
- package/src/engine-components/webxr/WebARCameraBackground.ts +9 -0
|
@@ -59,7 +59,19 @@ export class VideoPlayer extends Behaviour {
|
|
|
59
59
|
@serializable()
|
|
60
60
|
private source: VideoSource = VideoSource.Url;
|
|
61
61
|
@serializable(URL)
|
|
62
|
-
|
|
62
|
+
get url() { return this._url }
|
|
63
|
+
set url(val: string | null) {
|
|
64
|
+
const prev = this._url;
|
|
65
|
+
const changed = prev !== val;
|
|
66
|
+
if (this.__didAwake) {
|
|
67
|
+
if (changed) {
|
|
68
|
+
this.setClipURL(val ?? "");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else this._url = val;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private _url: string | null = null;
|
|
63
75
|
|
|
64
76
|
@serializable()
|
|
65
77
|
private renderMode?: VideoRenderMode;
|
|
@@ -209,15 +221,15 @@ export class VideoPlayer extends Behaviour {
|
|
|
209
221
|
}
|
|
210
222
|
|
|
211
223
|
setClipURL(url: string) {
|
|
212
|
-
if (this.
|
|
213
|
-
this.
|
|
224
|
+
if (this._url === url) return;
|
|
225
|
+
this._url = url;
|
|
214
226
|
this.source = VideoSource.Url;
|
|
215
227
|
|
|
216
228
|
if (debug) console.log("set url", url);
|
|
217
229
|
if (!this._videoElement) this.create(this.playOnAwake);
|
|
218
230
|
else {
|
|
219
|
-
if (url.endsWith(".m3u8")) {
|
|
220
|
-
this.
|
|
231
|
+
if (url.endsWith(".m3u8") || url.includes(".m3u")) {
|
|
232
|
+
this.ensureM3UCanBePlayed();
|
|
221
233
|
}
|
|
222
234
|
else {
|
|
223
235
|
this._videoElement.src = url;
|
|
@@ -308,8 +320,8 @@ export class VideoPlayer extends Behaviour {
|
|
|
308
320
|
if (!this._receivedInput) this._videoElement.muted = true;
|
|
309
321
|
this.handleBeginPlaying(false);
|
|
310
322
|
|
|
311
|
-
if(this.
|
|
312
|
-
this.
|
|
323
|
+
if (this.shouldUseM3U) {
|
|
324
|
+
this.ensureM3UCanBePlayed();
|
|
313
325
|
return;
|
|
314
326
|
}
|
|
315
327
|
|
|
@@ -487,8 +499,8 @@ export class VideoPlayer extends Behaviour {
|
|
|
487
499
|
this.updateVideoElementSettings();
|
|
488
500
|
this.updateVideoElementStyles();
|
|
489
501
|
if (playAutomatically) {
|
|
490
|
-
if (this.
|
|
491
|
-
this.
|
|
502
|
+
if (this.shouldUseM3U) {
|
|
503
|
+
this.ensureM3UCanBePlayed();
|
|
492
504
|
}
|
|
493
505
|
this.play();
|
|
494
506
|
}
|
|
@@ -576,10 +588,10 @@ export class VideoPlayer extends Behaviour {
|
|
|
576
588
|
|
|
577
589
|
|
|
578
590
|
|
|
579
|
-
private get
|
|
591
|
+
private get shouldUseM3U(): boolean { return this.url != undefined && (this.url.endsWith(".m3u8") || this.url.endsWith(".m3u")) && this.source === VideoSource.Url; }
|
|
580
592
|
|
|
581
|
-
private
|
|
582
|
-
if (!this.
|
|
593
|
+
private ensureM3UCanBePlayed() {
|
|
594
|
+
if (!this.shouldUseM3U) return;
|
|
583
595
|
let hls_script = document.head.querySelector("script[data-hls_library]") as HTMLScriptElement;
|
|
584
596
|
if (!hls_script) {
|
|
585
597
|
if (debug) console.log("HLS: load script");
|
|
@@ -599,7 +611,7 @@ export class VideoPlayer extends Behaviour {
|
|
|
599
611
|
private _hls?: Hls;
|
|
600
612
|
private onHlsAvailable = () => {
|
|
601
613
|
if (debug) console.log("HLS: available", this.clip);
|
|
602
|
-
if (!this.
|
|
614
|
+
if (!this.shouldUseM3U || !this.url) return;
|
|
603
615
|
if (!this._hls)
|
|
604
616
|
this._hls = new Hls();
|
|
605
617
|
this.videoElement!.autoplay = true;
|
|
@@ -116,6 +116,15 @@ export class WebARCameraBackground extends Behaviour {
|
|
|
116
116
|
updateFromFrame(frame: XRFrame | null) {
|
|
117
117
|
if (!frame) return;
|
|
118
118
|
|
|
119
|
+
// If camera feed is not present, then abort and hiden background
|
|
120
|
+
const enabledFeatures = frame.session.enabledFeatures;
|
|
121
|
+
if (enabledFeatures && !enabledFeatures.some(x => x === 'camera-access')) {
|
|
122
|
+
if (this.background) {
|
|
123
|
+
this.background.visible = false;
|
|
124
|
+
}
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
119
128
|
// https://chromium.googlesource.com/chromium/src/+/7c5ac3c0f95b97cf12be95a5c1c0a8ff163246d8/third_party/webxr_test_pages/webxr-samples/proposals/camera-access-barebones.html
|
|
120
129
|
const pose = frame.getViewerPose(this.context.renderer.xr.getReferenceSpace()!);
|
|
121
130
|
if (pose) {
|