@needle-tools/engine 4.8.2 → 4.8.3-next.106dc4b

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 (33) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/{gltf-progressive-B--ZfCTJ.min.js → gltf-progressive-DLhfUtEV.min.js} +1 -1
  3. package/dist/{gltf-progressive-Do1XJNMG.js → gltf-progressive-DVx_cW0s.js} +1 -5
  4. package/dist/{needle-engine.bundle-C5G_xBUc.umd.cjs → needle-engine.bundle-CS0KpoXy.umd.cjs} +36 -26
  5. package/dist/{needle-engine.bundle-Dujqh1WU.min.js → needle-engine.bundle-D48x8WMx.min.js} +43 -33
  6. package/dist/{needle-engine.bundle-D4YRjNnp.js → needle-engine.bundle-XSFxeb08.js} +224 -212
  7. package/dist/needle-engine.js +3 -3
  8. package/dist/needle-engine.min.js +1 -1
  9. package/dist/needle-engine.umd.cjs +1 -1
  10. package/dist/{vendor-CGONwIc0.js → vendor-B_ytQUuR.js} +6 -6
  11. package/dist/{vendor-BlSxe9JJ.min.js → vendor-C31T0mYm.min.js} +2 -2
  12. package/dist/{vendor-Cty8Dnri.umd.cjs → vendor-D51IT5ns.umd.cjs} +9 -9
  13. package/lib/engine/engine_context.d.ts +2 -2
  14. package/lib/engine/engine_context.js +5 -14
  15. package/lib/engine/engine_context.js.map +1 -1
  16. package/lib/engine/engine_networking_streams.js +13 -2
  17. package/lib/engine/engine_networking_streams.js.map +1 -1
  18. package/lib/engine/webcomponents/buttons.js +6 -2
  19. package/lib/engine/webcomponents/buttons.js.map +1 -1
  20. package/lib/engine/webcomponents/needle menu/needle-menu.js +10 -0
  21. package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
  22. package/lib/engine-components/OrbitControls.d.ts +1 -0
  23. package/lib/engine-components/OrbitControls.js +6 -0
  24. package/lib/engine-components/OrbitControls.js.map +1 -1
  25. package/package.json +2 -2
  26. package/plugins/vite/peer.js +60 -2
  27. package/plugins/vite/poster-client.js +35 -51
  28. package/plugins/vite/poster.js +2 -3
  29. package/src/engine/engine_context.ts +7 -14
  30. package/src/engine/engine_networking_streams.ts +17 -8
  31. package/src/engine/webcomponents/buttons.ts +6 -2
  32. package/src/engine/webcomponents/needle menu/needle-menu.ts +10 -0
  33. package/src/engine-components/OrbitControls.ts +5 -0
@@ -8,7 +8,7 @@ import { showBalloonMessage } from "./debug/index.js";
8
8
  import { Application } from "./engine_application.js";
9
9
  import { Context } from "./engine_context.js";
10
10
  import type { IModel } from "./engine_networking_types.js";
11
- import { type IComponent,isComponent } from "./engine_types.js";
11
+ import { type IComponent, isComponent } from "./engine_types.js";
12
12
  import { getParam } from "./engine_utils.js";
13
13
 
14
14
 
@@ -113,8 +113,8 @@ class CallHandle extends EventDispatcher<any> {
113
113
  }
114
114
  }
115
115
 
116
- function applySdpTransform(sdp){
117
- sdp = sdp.replace("a=fmtp:111 minptime=10;useinbandfec=1","a=fmtp:111 ptime=5;useinbandfec=1;stereo=1;maxplaybackrate=48000;maxaveragebitrat=128000;sprop-stereo=1");
116
+ function applySdpTransform(sdp) {
117
+ sdp = sdp.replace("a=fmtp:111 minptime=10;useinbandfec=1", "a=fmtp:111 ptime=5;useinbandfec=1;stereo=1;maxplaybackrate=48000;maxaveragebitrat=128000;sprop-stereo=1");
118
118
  return sdp;
119
119
  }
120
120
 
@@ -237,10 +237,19 @@ export class PeerHandle extends EventDispatcher<any> {
237
237
  this.context = context;
238
238
  this.id = id;
239
239
  this.setupPeer();
240
- navigator["getUserMedia"] = (
241
- navigator["getUserMedia"] || navigator["webkitGetUserMedia"] ||
242
- navigator["mozGetUserMedia"] || navigator["msGetUserMedia"]
243
- );
240
+ const isGetUserMediaWriteable = Object.getOwnPropertyDescriptor(navigator, "getUserMedia")?.writable;
241
+ try {
242
+ if (isGetUserMediaWriteable) {
243
+ navigator["getUserMedia"] = (
244
+ navigator["getUserMedia"] || navigator["webkitGetUserMedia"] ||
245
+ navigator["mozGetUserMedia"] || navigator["msGetUserMedia"]
246
+ );
247
+ }
248
+ else if (debug) console.warn("[PeerJs] getUserMedia is not writable");
249
+ }
250
+ catch (err) {
251
+ if (debug) console.error("[PeerJs] Error setting getUserMedia", err);
252
+ }
244
253
  }
245
254
 
246
255
  private _enabled: boolean = false;
@@ -479,7 +488,7 @@ export class NetworkedStreams extends EventDispatcher<any> {
479
488
  }
480
489
 
481
490
  if (!context) throw new Error("Failed to create NetworkedStreams because context is undefined");
482
- else if(!(context instanceof Context)) throw new Error("Failed to create NetworkedStreams because context is not an instance of Context");
491
+ else if (!(context instanceof Context)) throw new Error("Failed to create NetworkedStreams because context is not an instance of Context");
483
492
  if (!peer) throw new Error("Failed to create NetworkedStreams because peer is undefined");
484
493
 
485
494
  this.context = context;
@@ -218,7 +218,11 @@ export class ButtonsFactory {
218
218
  await generateAndInsertQRCode();
219
219
  // TODO: make sure it doesnt overflow the screen
220
220
  // we need to add the qrCodeContainer to the body to get the correct size
221
- document.body.appendChild(qrCodeContainer);
221
+ // TODO: we would need to search for the right engine element to insert this into if there are more
222
+ // Insert the QR code overlay inside the needle-engine element
223
+ const engine_element = document.body.querySelector("needle-engine");
224
+ const parent = engine_element || document.body;
225
+ parent.appendChild(qrCodeContainer);
222
226
  const containerRect = qrCodeElement.getBoundingClientRect();
223
227
  const buttonRect = qrCodeButton.getBoundingClientRect();
224
228
  qrCodeContainer.style.left = (buttonRect.left + buttonRect.width * .5 - containerRect.width * .5) + "px";
@@ -245,7 +249,7 @@ export class ButtonsFactory {
245
249
  document.fullscreenElement.appendChild(qrCodeContainer);
246
250
  }
247
251
  else
248
- document.body.appendChild(qrCodeContainer);
252
+ parent.appendChild(qrCodeContainer);
249
253
  }
250
254
 
251
255
  /** hides to QRCode overlay and unsubscribes from events */
@@ -287,6 +287,16 @@ export class NeedleMenuElement extends HTMLElement {
287
287
  // TODO: make host full size again and move the buttons to a wrapper so that we can later easily open e.g. foldouts/dropdowns / use the whole canvas space
288
288
  template.innerHTML = `<style>
289
289
 
290
+ /** Styling attributes that ensure the nested menu z-index does not cause it to overlay elements outside of <needle-engine> */
291
+ :host {
292
+ position: absolute;
293
+ width: 100%;
294
+ height: 100%;
295
+ z-index: 0;
296
+ top: 0;
297
+ pointer-events: none;
298
+ }
299
+
290
300
  #root {
291
301
  position: absolute;
292
302
  width: auto;
@@ -565,6 +565,11 @@ export class OrbitControls extends Behaviour implements ICameraController {
565
565
  }
566
566
  }
567
567
 
568
+ onPausedChanged(isPaused: boolean): void {
569
+ if (!this._controls) return;
570
+ if (isPaused) this._controls.enabled = false;
571
+ }
572
+
568
573
 
569
574
  /** @internal */
570
575
  onBeforeRender() {