@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.
Files changed (35) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/needle-engine.js +258 -186
  3. package/dist/needle-engine.light.js +258 -186
  4. package/dist/needle-engine.light.min.js +25 -25
  5. package/dist/needle-engine.light.umd.cjs +156 -156
  6. package/dist/needle-engine.min.js +25 -25
  7. package/dist/needle-engine.umd.cjs +49 -49
  8. package/lib/engine/extensions/NEEDLE_progressive.d.ts +1 -0
  9. package/lib/engine/extensions/NEEDLE_progressive.js +7 -1
  10. package/lib/engine/extensions/NEEDLE_progressive.js.map +1 -1
  11. package/lib/engine-components/DropListener.d.ts +31 -3
  12. package/lib/engine-components/DropListener.js +30 -2
  13. package/lib/engine-components/DropListener.js.map +1 -1
  14. package/lib/engine-components/OrbitControls.d.ts +16 -3
  15. package/lib/engine-components/OrbitControls.js +25 -9
  16. package/lib/engine-components/OrbitControls.js.map +1 -1
  17. package/lib/engine-components/ParticleSystem.d.ts +31 -1
  18. package/lib/engine-components/ParticleSystem.js +42 -1
  19. package/lib/engine-components/ParticleSystem.js.map +1 -1
  20. package/lib/engine-components/SceneSwitcher.d.ts +22 -2
  21. package/lib/engine-components/SceneSwitcher.js +29 -3
  22. package/lib/engine-components/SceneSwitcher.js.map +1 -1
  23. package/lib/engine-components/VideoPlayer.d.ts +5 -3
  24. package/lib/engine-components/VideoPlayer.js +26 -14
  25. package/lib/engine-components/VideoPlayer.js.map +1 -1
  26. package/lib/engine-components/webxr/WebARCameraBackground.js +8 -0
  27. package/lib/engine-components/webxr/WebARCameraBackground.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/engine/extensions/NEEDLE_progressive.ts +9 -1
  30. package/src/engine-components/DropListener.ts +30 -2
  31. package/src/engine-components/OrbitControls.ts +29 -11
  32. package/src/engine-components/ParticleSystem.ts +44 -4
  33. package/src/engine-components/SceneSwitcher.ts +45 -5
  34. package/src/engine-components/VideoPlayer.ts +25 -13
  35. 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
- private url?: string | null = null;
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.url === url) return;
213
- this.url = url;
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.ensureM3U8CanBePlayed();
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.shouldUseM3U8){
312
- this.ensureM3U8CanBePlayed();
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.shouldUseM3U8) {
491
- this.ensureM3U8CanBePlayed();
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 shouldUseM3U8(): boolean { return this.url != undefined && this.url.endsWith(".m3u8") && this.source === VideoSource.Url; }
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 ensureM3U8CanBePlayed() {
582
- if (!this.shouldUseM3U8) return;
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.shouldUseM3U8 || !this.url) return;
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) {