@needle-tools/engine 5.1.15 → 5.1.16

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 (66) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/{needle-engine.bundle-BivRq9Io.umd.cjs → needle-engine.bundle-CFnhozXr.umd.cjs} +133 -133
  3. package/dist/{needle-engine.bundle-ByEd2JMt.js → needle-engine.bundle-Ccvgzl3v.js} +4122 -4117
  4. package/dist/{needle-engine.bundle-DiobwRVT.min.js → needle-engine.bundle-DBXustN8.min.js} +136 -136
  5. package/dist/needle-engine.d.ts +7 -7
  6. package/dist/needle-engine.js +233 -233
  7. package/dist/needle-engine.min.js +1 -1
  8. package/dist/needle-engine.umd.cjs +1 -1
  9. package/lib/engine/api.d.ts +1 -1
  10. package/lib/engine/api.js +1 -1
  11. package/lib/engine/api.js.map +1 -1
  12. package/lib/engine/debug/debug_overlay.js +5 -8
  13. package/lib/engine/debug/debug_overlay.js.map +1 -1
  14. package/lib/engine/engine_context_registry.js +3 -1
  15. package/lib/engine/engine_context_registry.js.map +1 -1
  16. package/lib/engine/engine_init.js +2 -2
  17. package/lib/engine/engine_init.js.map +1 -1
  18. package/lib/engine/engine_license.d.ts +7 -7
  19. package/lib/engine/engine_license.js +87 -77
  20. package/lib/engine/engine_license.js.map +1 -1
  21. package/lib/engine/engine_networking_blob.js +3 -3
  22. package/lib/engine/engine_networking_blob.js.map +1 -1
  23. package/lib/engine/engine_utils.js +2 -0
  24. package/lib/engine/engine_utils.js.map +1 -1
  25. package/lib/engine/engine_utils_qrcode.js +2 -2
  26. package/lib/engine/engine_utils_qrcode.js.map +1 -1
  27. package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +2 -2
  28. package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js.map +1 -1
  29. package/lib/engine/webcomponents/needle menu/needle-menu.js +5 -5
  30. package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
  31. package/lib/engine/webcomponents/needle-engine.js +2 -2
  32. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  33. package/lib/engine/webcomponents/needle-engine.loading.js +2 -2
  34. package/lib/engine/webcomponents/needle-engine.loading.js.map +1 -1
  35. package/lib/engine/xr/TempXRContext.js +2 -2
  36. package/lib/engine/xr/TempXRContext.js.map +1 -1
  37. package/lib/engine-components/Skybox.js +11 -7
  38. package/lib/engine-components/Skybox.js.map +1 -1
  39. package/lib/engine-components/export/usdz/USDZExporter.js +4 -4
  40. package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
  41. package/lib/engine-components/web/Clickthrough.d.ts +1 -0
  42. package/lib/engine-components/web/Clickthrough.js +7 -2
  43. package/lib/engine-components/web/Clickthrough.js.map +1 -1
  44. package/lib/engine-components-experimental/networking/PlayerSync.d.ts +1 -2
  45. package/lib/engine-components-experimental/networking/PlayerSync.js +10 -13
  46. package/lib/engine-components-experimental/networking/PlayerSync.js.map +1 -1
  47. package/package.json +1 -1
  48. package/plugins/common/license.js +4 -4
  49. package/plugins/vite/license.js +4 -4
  50. package/src/engine/api.ts +1 -1
  51. package/src/engine/debug/debug_overlay.ts +6 -9
  52. package/src/engine/engine_context_registry.ts +4 -2
  53. package/src/engine/engine_init.ts +2 -2
  54. package/src/engine/engine_license.ts +83 -74
  55. package/src/engine/engine_networking_blob.ts +3 -3
  56. package/src/engine/engine_utils.ts +2 -0
  57. package/src/engine/engine_utils_qrcode.ts +2 -2
  58. package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +2 -2
  59. package/src/engine/webcomponents/needle menu/needle-menu.ts +5 -5
  60. package/src/engine/webcomponents/needle-engine.loading.ts +6 -6
  61. package/src/engine/webcomponents/needle-engine.ts +2 -2
  62. package/src/engine/xr/TempXRContext.ts +2 -2
  63. package/src/engine-components/Skybox.ts +12 -9
  64. package/src/engine-components/export/usdz/USDZExporter.ts +4 -4
  65. package/src/engine-components/web/Clickthrough.ts +8 -2
  66. package/src/engine-components-experimental/networking/PlayerSync.ts +11 -15
@@ -3,7 +3,7 @@ import { Euler, Material, Matrix4, Mesh, Object3D, Quaternion, Vector3 } from "t
3
3
 
4
4
  import { isDevEnvironment, showBalloonMessage, showBalloonWarning } from "../../../engine/debug/index.js";
5
5
  import { findObjectOfType } from "../../../engine/engine_components.js";
6
- import { __iOMsPxgl } from "../../../engine/engine_license.js";
6
+ import { _$RTXoT } from "../../../engine/engine_license.js";
7
7
  import { serializable } from "../../../engine/engine_serialization.js";
8
8
  import { getFormattedDate, Progress } from "../../../engine/engine_time_utils.js";
9
9
  import { DeviceUtilities, getParam } from "../../../engine/engine_utils.js";
@@ -277,7 +277,7 @@ export class USDZExporter extends Behaviour {
277
277
  let name = this.exportFileName ?? this.objectToExport?.name ?? this.name;
278
278
  name += "-" + getFormattedDate(); // seems iOS caches the file in some cases, this ensures we always have a fresh file
279
279
 
280
- if (!__iOMsPxgl()) {
280
+ if (!_$RTXoT()) {
281
281
  if (name !== "") name += "-";
282
282
  name += "MadeWithNeedle";
283
283
  }
@@ -682,7 +682,7 @@ export class USDZExporter extends Behaviour {
682
682
  if (debug)
683
683
  showBalloonMessage("Quicklook url: " + callToActionURL);
684
684
  if (callToActionURL) {
685
- if (!__iOMsPxgl()) {
685
+ if (!_$RTXoT()) {
686
686
  console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing", callToActionURL)
687
687
  }
688
688
  else {
@@ -697,7 +697,7 @@ export class USDZExporter extends Behaviour {
697
697
  private buildQuicklookOverlay(): CustomBranding {
698
698
  const obj: CustomBranding = {};
699
699
  if (this.customBranding) Object.assign(obj, this.customBranding);
700
- if (!__iOMsPxgl()) {
700
+ if (!_$RTXoT()) {
701
701
  console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing");
702
702
  obj.callToAction = "Close";
703
703
  obj.checkoutTitle = "🌵 Made with Needle";
@@ -5,15 +5,17 @@ import { onStart } from "../../engine/engine_lifecycle_api.js";
5
5
  import { addAttributeChangeCallback } from "../../engine/engine_utils.js";
6
6
  import { Behaviour } from "../Component.js";
7
7
 
8
+ const attributeUnsubscribers = new WeakMap<ClickThrough, () => void>();
9
+
8
10
  // Automatically add ClickThrough component if "clickthrough" attribute is present on the needle-engine element
9
11
  onStart(ctx => {
10
12
  const attribute = ctx.domElement.getAttribute("clickthrough");
11
13
  if (clickthroughEnabled(attribute)) {
12
14
  const comp = ctx.scene.addComponent(ClickThrough);
13
- addAttributeChangeCallback(ctx.domElement, "clickthrough", () => {
15
+ attributeUnsubscribers.set(comp, addAttributeChangeCallback(ctx.domElement, "clickthrough", () => {
14
16
  const attribute = ctx.domElement.getAttribute("clickthrough");
15
17
  comp.enabled = clickthroughEnabled(attribute);
16
- });
18
+ }));
17
19
  }
18
20
 
19
21
  function clickthroughEnabled(val: string | null) {
@@ -167,6 +169,10 @@ export class ClickThrough extends Behaviour {
167
169
  window.removeEventListener("touchend", this.onTouchEnd);
168
170
  this.context.domElement.style.pointerEvents = this._previousPointerEvents;
169
171
  }
172
+ onDestroy() {
173
+ attributeUnsubscribers.get(this)?.();
174
+ attributeUnsubscribers.delete(this);
175
+ }
170
176
  onPointerEnter() {
171
177
  /** do nothing, necessary to raycast children */
172
178
  }
@@ -114,11 +114,8 @@ export class PlayerSync extends Behaviour {
114
114
  this.onPlayerSpawned = new EventList();
115
115
  }
116
116
 
117
- awake(): void {
118
- this.watchTabVisible();
119
- }
120
-
121
117
  onEnable(): void {
118
+ document.addEventListener("visibilitychange", this.onVisibilityChange);
122
119
  this.context.connection.beginListen(RoomEvents.RoomStateSent, this.onJoinedRoom);
123
120
  this.context.connection.beginListen(RoomEvents.JoinedRoom, this.onJoinedRoom);
124
121
  this.context.connection.beginListen(RoomEvents.LeftRoom, this.destroyInstance);
@@ -141,6 +138,7 @@ export class PlayerSync extends Behaviour {
141
138
  }
142
139
  }
143
140
  onDisable(): void {
141
+ document.removeEventListener("visibilitychange", this.onVisibilityChange);
144
142
  this.context.connection.stopListen(RoomEvents.RoomStateSent, this.onJoinedRoom);
145
143
  this.context.connection.stopListen(RoomEvents.JoinedRoom, this.onJoinedRoom);
146
144
  this.context.connection.stopListen(RoomEvents.LeftRoom, this.destroyInstance);
@@ -207,18 +205,16 @@ export class PlayerSync extends Behaviour {
207
205
  /**
208
206
  * Sets up visibility change listeners to handle player cleanup when browser tab visibility changes
209
207
  */
210
- private watchTabVisible() {
211
- window.addEventListener("visibilitychange", _ => {
212
- if (document.visibilityState === "visible") {
213
- for (let i = PlayerState.all.length - 1; i >= 0; i--) {
214
- const pl = PlayerState.all[i];
215
- if (!pl.owner || !this.context.connection.userIsInRoom(pl.owner)) {
216
- pl.doDestroy();
217
- }
208
+ private onVisibilityChange = () => {
209
+ if (document.visibilityState === "visible") {
210
+ for (let i = PlayerState.all.length - 1; i >= 0; i--) {
211
+ const pl = PlayerState.all[i];
212
+ if (!pl.owner || !this.context.connection.userIsInRoom(pl.owner)) {
213
+ pl.doDestroy();
218
214
  }
219
215
  }
220
- });
221
- }
216
+ }
217
+ };
222
218
  }
223
219
 
224
220
  /**
@@ -454,4 +450,4 @@ export class PlayerState extends Behaviour {
454
450
  return;
455
451
  }
456
452
  }
457
- }
453
+ }