@needle-tools/engine 4.4.0-beta → 4.4.0-beta.10

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 (155) hide show
  1. package/CHANGELOG.md +65 -2
  2. package/dist/assets/generateMeshBVH.worker-b7788939.js +25 -0
  3. package/dist/needle-engine.bundle.js +6808 -6645
  4. package/dist/needle-engine.bundle.light.js +7071 -6908
  5. package/dist/needle-engine.bundle.light.min.js +169 -139
  6. package/dist/needle-engine.bundle.light.umd.cjs +173 -143
  7. package/dist/needle-engine.bundle.min.js +169 -139
  8. package/dist/needle-engine.bundle.umd.cjs +172 -142
  9. package/dist/needle-engine.d.ts +0 -9
  10. package/dist/needle-engine.js +468 -467
  11. package/dist/needle-engine.light.d.ts +0 -9
  12. package/dist/needle-engine.light.js +468 -467
  13. package/dist/needle-engine.light.min.js +1 -1
  14. package/dist/needle-engine.light.umd.cjs +1 -1
  15. package/dist/needle-engine.min.js +1 -1
  16. package/dist/needle-engine.umd.cjs +1 -1
  17. package/dist/postprocessing.js +1673 -1527
  18. package/dist/postprocessing.light.js +1673 -1527
  19. package/dist/postprocessing.light.min.js +80 -66
  20. package/dist/postprocessing.light.umd.cjs +83 -69
  21. package/dist/postprocessing.min.js +80 -66
  22. package/dist/postprocessing.umd.cjs +83 -69
  23. package/dist/vendor.js +5109 -5123
  24. package/dist/vendor.light.js +5109 -5123
  25. package/dist/vendor.light.min.js +84 -84
  26. package/dist/vendor.light.umd.cjs +78 -78
  27. package/dist/vendor.min.js +84 -84
  28. package/dist/vendor.umd.cjs +78 -78
  29. package/lib/engine/codegen/register_types.js +2 -0
  30. package/lib/engine/codegen/register_types.js.map +1 -1
  31. package/lib/engine/engine_addressables.js.map +1 -1
  32. package/lib/engine/engine_components.js +3 -1
  33. package/lib/engine/engine_components.js.map +1 -1
  34. package/lib/engine/engine_context.d.ts +10 -1
  35. package/lib/engine/engine_context.js +33 -12
  36. package/lib/engine/engine_context.js.map +1 -1
  37. package/lib/engine/engine_element.js +12 -10
  38. package/lib/engine/engine_element.js.map +1 -1
  39. package/lib/engine/engine_gameobject.js +5 -0
  40. package/lib/engine/engine_gameobject.js.map +1 -1
  41. package/lib/engine/engine_license.d.ts +2 -0
  42. package/lib/engine/engine_license.js +103 -62
  43. package/lib/engine/engine_license.js.map +1 -1
  44. package/lib/engine/engine_networking_blob.js +40 -24
  45. package/lib/engine/engine_networking_blob.js.map +1 -1
  46. package/lib/engine/engine_physics_rapier.js +10 -9
  47. package/lib/engine/engine_physics_rapier.js.map +1 -1
  48. package/lib/engine/engine_serialization_core.js +6 -2
  49. package/lib/engine/engine_serialization_core.js.map +1 -1
  50. package/lib/engine/engine_utils_screenshot.js +1 -1
  51. package/lib/engine/engine_utils_screenshot.js.map +1 -1
  52. package/lib/engine/js-extensions/RGBAColor.d.ts +1 -0
  53. package/lib/engine/js-extensions/RGBAColor.js +48 -0
  54. package/lib/engine/js-extensions/RGBAColor.js.map +1 -1
  55. package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +4 -3
  56. package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js.map +1 -1
  57. package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +6 -6
  58. package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js.map +1 -1
  59. package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +4 -0
  60. package/lib/engine/webcomponents/needle menu/needle-menu.js +13 -2
  61. package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
  62. package/lib/engine/xr/NeedleXRController.js +2 -3
  63. package/lib/engine/xr/NeedleXRController.js.map +1 -1
  64. package/lib/engine/xr/NeedleXRSession.js +12 -12
  65. package/lib/engine/xr/NeedleXRSession.js.map +1 -1
  66. package/lib/engine-components/AudioSource.js +7 -0
  67. package/lib/engine-components/AudioSource.js.map +1 -1
  68. package/lib/engine-components/Camera.js +18 -12
  69. package/lib/engine-components/Camera.js.map +1 -1
  70. package/lib/engine-components/CameraUtils.js +8 -14
  71. package/lib/engine-components/CameraUtils.js.map +1 -1
  72. package/lib/engine-components/GroundProjection.js +1 -1
  73. package/lib/engine-components/GroundProjection.js.map +1 -1
  74. package/lib/engine-components/NeedleMenu.js +1 -1
  75. package/lib/engine-components/NeedleMenu.js.map +1 -1
  76. package/lib/engine-components/OrbitControls.js +3 -1
  77. package/lib/engine-components/OrbitControls.js.map +1 -1
  78. package/lib/engine-components/ReflectionProbe.d.ts +1 -0
  79. package/lib/engine-components/ReflectionProbe.js +16 -9
  80. package/lib/engine-components/ReflectionProbe.js.map +1 -1
  81. package/lib/engine-components/SceneSwitcher.js +28 -7
  82. package/lib/engine-components/SceneSwitcher.js.map +1 -1
  83. package/lib/engine-components/SyncedTransform.d.ts +6 -0
  84. package/lib/engine-components/SyncedTransform.js +10 -5
  85. package/lib/engine-components/SyncedTransform.js.map +1 -1
  86. package/lib/engine-components/codegen/components.d.ts +1 -0
  87. package/lib/engine-components/codegen/components.js +1 -0
  88. package/lib/engine-components/codegen/components.js.map +1 -1
  89. package/lib/engine-components/export/usdz/extensions/USDZUI.js +2 -1
  90. package/lib/engine-components/export/usdz/extensions/USDZUI.js.map +1 -1
  91. package/lib/engine-components/ui/BaseUIComponent.d.ts +0 -1
  92. package/lib/engine-components/ui/BaseUIComponent.js +1 -1
  93. package/lib/engine-components/ui/BaseUIComponent.js.map +1 -1
  94. package/lib/engine-components/ui/EventSystem.js +1 -1
  95. package/lib/engine-components/ui/EventSystem.js.map +1 -1
  96. package/lib/engine-components/ui/Graphic.js +1 -0
  97. package/lib/engine-components/ui/Graphic.js.map +1 -1
  98. package/lib/engine-components/ui/RaycastUtils.js +1 -1
  99. package/lib/engine-components/ui/RaycastUtils.js.map +1 -1
  100. package/lib/engine-components/ui/RectTransform.d.ts +2 -2
  101. package/lib/engine-components/ui/RectTransform.js +9 -6
  102. package/lib/engine-components/ui/RectTransform.js.map +1 -1
  103. package/lib/engine-components/ui/Symbols.d.ts +1 -0
  104. package/lib/engine-components/ui/Symbols.js +2 -0
  105. package/lib/engine-components/ui/Symbols.js.map +1 -0
  106. package/lib/engine-components/ui/Utils.js +1 -1
  107. package/lib/engine-components/ui/Utils.js.map +1 -1
  108. package/lib/engine-components/utils/EnvironmentScene.d.ts +1 -1
  109. package/lib/engine-components/utils/EnvironmentScene.js +1 -1
  110. package/lib/engine-components/utils/EnvironmentScene.js.map +1 -1
  111. package/package.json +3 -3
  112. package/plugins/common/buildinfo.js +1 -0
  113. package/plugins/common/cloud.js +2 -0
  114. package/plugins/common/license.js +174 -33
  115. package/plugins/types/userconfig.d.ts +5 -0
  116. package/plugins/vite/build-pipeline.js +4 -3
  117. package/plugins/vite/dependencies.js +17 -7
  118. package/plugins/vite/facebook-instant-games.js +7 -4
  119. package/plugins/vite/index.js +1 -1
  120. package/src/engine/codegen/register_types.ts +2 -0
  121. package/src/engine/engine_addressables.ts +3 -2
  122. package/src/engine/engine_components.ts +2 -1
  123. package/src/engine/engine_context.ts +36 -12
  124. package/src/engine/engine_element.ts +10 -9
  125. package/src/engine/engine_gameobject.ts +7 -0
  126. package/src/engine/engine_license.ts +116 -67
  127. package/src/engine/engine_networking_blob.ts +47 -26
  128. package/src/engine/engine_physics_rapier.ts +10 -12
  129. package/src/engine/engine_serialization_core.ts +6 -1
  130. package/src/engine/engine_utils_screenshot.ts +1 -1
  131. package/src/engine/js-extensions/RGBAColor.ts +50 -0
  132. package/src/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +6 -6
  133. package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +6 -6
  134. package/src/engine/webcomponents/needle menu/needle-menu.ts +13 -2
  135. package/src/engine/xr/NeedleXRController.ts +2 -3
  136. package/src/engine/xr/NeedleXRSession.ts +12 -12
  137. package/src/engine-components/AudioSource.ts +8 -3
  138. package/src/engine-components/Camera.ts +34 -22
  139. package/src/engine-components/CameraUtils.ts +8 -16
  140. package/src/engine-components/GroundProjection.ts +1 -1
  141. package/src/engine-components/NeedleMenu.ts +1 -1
  142. package/src/engine-components/OrbitControls.ts +2 -1
  143. package/src/engine-components/ReflectionProbe.ts +15 -8
  144. package/src/engine-components/SceneSwitcher.ts +28 -11
  145. package/src/engine-components/SyncedTransform.ts +11 -6
  146. package/src/engine-components/codegen/components.ts +1 -0
  147. package/src/engine-components/export/usdz/extensions/USDZUI.ts +2 -2
  148. package/src/engine-components/ui/BaseUIComponent.ts +1 -1
  149. package/src/engine-components/ui/EventSystem.ts +1 -1
  150. package/src/engine-components/ui/Graphic.ts +1 -1
  151. package/src/engine-components/ui/RaycastUtils.ts +1 -1
  152. package/src/engine-components/ui/RectTransform.ts +10 -7
  153. package/src/engine-components/ui/Symbols.ts +2 -0
  154. package/src/engine-components/ui/Utils.ts +2 -1
  155. package/src/engine-components/utils/EnvironmentScene.ts +1 -1
@@ -107,6 +107,15 @@ export class SyncedTransform extends Behaviour {
107
107
  this._model.requestOwnership();
108
108
  }
109
109
 
110
+ /**
111
+ * Free ownership of this object on the network.
112
+ * You need to be connected to a room for this to work.
113
+ * This will also be called automatically when the component is disabled.
114
+ */
115
+ public freeOwnership() {
116
+ this._model?.freeOwnership();
117
+ }
118
+
110
119
  /**
111
120
  * Checks if this client has ownership of the object
112
121
  * @returns true if this client has ownership, false if not, undefined if ownership state is unknown
@@ -312,8 +321,7 @@ export class SyncedTransform extends Behaviour {
312
321
 
313
322
  if (this._model && !this._model.hasOwnership && this._model.isOwned) {
314
323
  if (this._receivedDataBefore) {
315
- const factor = this._receivedFastUpdate || this.fastMode ? .5 : .3;
316
- const t = factor;//Mathf.clamp01(this.context.time.deltaTime * factor);
324
+ const t = this._receivedFastUpdate || this.fastMode ? .05 : .3;
317
325
  let requireMarkDirty = false;
318
326
  if (this.interpolatePosition && this._targetPosition) {
319
327
  const pos = this.worldPosition;
@@ -366,13 +374,10 @@ export class SyncedTransform extends Behaviour {
366
374
  FAST_ACTIVE_SYNCTRANSFORMS++;
367
375
  if (fastUpdate && FAST_INTERVAL > 0 && this.context.time.frameCount % FAST_INTERVAL !== 0) return;
368
376
 
369
- if (debug)
370
- console.log("send update", this.context.connection.connectionId, this.guid, this.gameObject.name, this.gameObject.guid);
377
+ if (debug) console.debug("[SyncedTransform] Send update", this.context.connection.connectionId, this.guid, this.gameObject.name, this.gameObject.guid);
371
378
 
372
379
  this._needsUpdate = false;
373
380
  const st = createTransformModel(this.guid, this, fastUpdate ? true : false);
374
- // this._state.update(this, this.rb);
375
- // this._state.fast = fastUpdate ? true : false;
376
381
  this.context.connection.sendBinary(st);
377
382
  }
378
383
  }
@@ -194,6 +194,7 @@ export { Rect } from "../ui/RectTransform.js";
194
194
  export { RectTransform } from "../ui/RectTransform.js";
195
195
  export { SpatialHtml } from "../ui/SpatialHtml.js";
196
196
  export { Text } from "../ui/Text.js";
197
+ export { EnvironmentScene } from "../utils/EnvironmentScene.js";
197
198
  export { LookAt } from "../utils/LookAt.js";
198
199
  export { OpenURL } from "../utils/OpenURL.js";
199
200
  export { VideoPlayer } from "../VideoPlayer.js";
@@ -1,12 +1,12 @@
1
1
  import { Color, Mesh, MeshBasicMaterial, Object3D } from "three";
2
2
 
3
3
  import { GameObject } from "../../../Component.js";
4
- import { SpriteRenderer } from "../../../SpriteRenderer.js";
5
- import { $shadowDomOwner, BaseUIComponent } from "../../../ui/BaseUIComponent.js";
4
+ import { BaseUIComponent } from "../../../ui/BaseUIComponent.js";
6
5
  import { Canvas } from "../../../ui/Canvas.js";
7
6
  import { RenderMode } from "../../../ui/Canvas.js";
8
7
  import { CanvasGroup } from "../../../ui/CanvasGroup.js";
9
8
  import { RectTransform } from "../../../ui/RectTransform.js";
9
+ import { $shadowDomOwner } from "../../../ui/Symbols.js";
10
10
  import { Text } from "../../../ui/Text.js";
11
11
  import type { IUSDExporterExtension } from "../Extension.js";
12
12
  import { USDObject, USDZExporterContext } from "../ThreeUSDZExporter.js";
@@ -8,6 +8,7 @@ import { getParam } from '../../engine/engine_utils.js';
8
8
  import { Behaviour, GameObject } from "../Component.js";
9
9
  import { EventSystem } from "./EventSystem.js";
10
10
  import type { ICanvas } from './Interfaces.js';
11
+ import { $shadowDomOwner } from './Symbols.js';
11
12
  export const includesDir = "./include";
12
13
 
13
14
  const debug = getParam("debugshadowcomponents");
@@ -24,7 +25,6 @@ ThreeMeshUI.Block.prototype["interactable"] = {
24
25
  }
25
26
  }
26
27
 
27
- export const $shadowDomOwner = Symbol("shadowDomOwner");
28
28
 
29
29
  /**
30
30
  * Derive from this class if you want to implement your own UI components.
@@ -9,11 +9,11 @@ import { Context } from "../../engine/engine_setup.js";
9
9
  import { HideFlags, type IComponent } from "../../engine/engine_types.js";
10
10
  import { getParam } from "../../engine/engine_utils.js";
11
11
  import { Behaviour, GameObject } from "../Component.js";
12
- import { $shadowDomOwner } from "./BaseUIComponent.js";
13
12
  import type { ICanvasGroup } from "./Interfaces.js";
14
13
  import { hasPointerEventComponent, type IPointerEventHandler, type IPointerUpHandler, PointerEventData } from "./PointerEvents.js";
15
14
  import { ObjectRaycaster, Raycaster } from "./Raycaster.js";
16
15
  import { UIRaycastUtils } from "./RaycastUtils.js";
16
+ import { $shadowDomOwner } from "./Symbols.js";
17
17
  import { isUIObject } from "./Utils.js";
18
18
 
19
19
  const debug = getParam("debugeventsystem");
@@ -98,6 +98,7 @@ export class Graphic extends BaseUIComponent implements IGraphic, IRectTransform
98
98
  super.__internalNewInstanceCreated(init);
99
99
  this._rect = null;
100
100
  this.uiObject = null;
101
+ this._stateManager = null;
101
102
  if (this._color) this._color = this._color.clone();
102
103
  return this;
103
104
  }
@@ -114,7 +115,6 @@ export class Graphic extends BaseUIComponent implements IGraphic, IRectTransform
114
115
  setupState(state: object) {
115
116
  this.makePanel();
116
117
  if (this.uiObject) {
117
-
118
118
  // @marwie : v7.x now have a concurrent state management in core mimicking html/css
119
119
  // ie : (::firstChild::hover::disabled) where firstchild, hover and disabled are all on different channels
120
120
  // In order to keep needle Raycaster and EventSystem intact, I added in v7 a SimpleStateBehavior, which acts as previously
@@ -2,8 +2,8 @@ import { Object3D } from "three";
2
2
 
3
3
  import { foreachComponent } from "../../engine/engine_gameobject.js";
4
4
  import { type IComponent } from "../../engine/engine_types.js";
5
- import { $shadowDomOwner } from "./BaseUIComponent.js";
6
5
  import { type ICanvasGroup, type IGraphic } from "./Interfaces.js";
6
+ import { $shadowDomOwner } from "./Symbols.js";
7
7
 
8
8
 
9
9
  export class UIRaycastUtils {
@@ -106,20 +106,25 @@ export class RectTransform extends BaseUIComponent implements IRectTransform, IR
106
106
  private rectBlock!: Object3D;
107
107
  private _transformNeedsUpdate: boolean = false;
108
108
  private _initialPosition!: Vector3;
109
+ private _parentRectTransform?: RectTransform;
110
+ private _lastUpdateFrame: number = -1;
109
111
 
110
112
  awake() {
111
113
  super.awake();
112
- // this is required if an animator animated the transform anchoring
113
- if (!this._anchoredPosition)
114
- this._anchoredPosition = new Vector2();
114
+ this._lastUpdateFrame = -1;
115
+ this._parentRectTransform = undefined;
115
116
 
116
- this.lastMatrix = new Matrix4();
117
117
  this.rectBlock = new Object3D();
118
118
  this.rectBlock.name = this.name;
119
-
119
+ this.lastMatrix = new Matrix4();
120
+ this._lastAnchoring = null!;
120
121
  // TODO: get rid of the initial position
121
122
  this._initialPosition = this.gameObject.position.clone();
122
123
  this._initialPosition.z = 0;
124
+ // this is required if an animator animated the transform anchoring
125
+ if (!this._anchoredPosition) this._anchoredPosition = new Vector2();
126
+
127
+
123
128
 
124
129
  // TODO: we need to replace this with the watch that e.g. Rigibody is using (or the one in utils?)
125
130
  // perhaps we can also just manually check the few properties in the update loops?
@@ -184,8 +189,6 @@ export class RectTransform extends BaseUIComponent implements IRectTransform, IR
184
189
  }
185
190
  }
186
191
 
187
- private _parentRectTransform?: RectTransform;
188
- private _lastUpdateFrame: number = -1;
189
192
 
190
193
  private canUpdate() {
191
194
  return this._transformNeedsUpdate && this.activeAndEnabled && this._lastUpdateFrame !== this.context.time.frame;
@@ -0,0 +1,2 @@
1
+
2
+ export const $shadowDomOwner = Symbol("shadowDomOwner");
@@ -4,7 +4,8 @@ import ThreeMeshUI from "three-mesh-ui";
4
4
 
5
5
  import { FrameEvent } from "../../engine/engine_setup.js";
6
6
  import { Behaviour } from "../Component.js";
7
- import { $shadowDomOwner, BaseUIComponent } from "./BaseUIComponent.js";
7
+ import { BaseUIComponent } from "./BaseUIComponent.js";
8
+ import { $shadowDomOwner } from "./Symbols.js";
8
9
 
9
10
  export function tryGetUIComponent(obj: Object3D): BaseUIComponent | null {
10
11
  const owner = obj[$shadowDomOwner];
@@ -197,7 +197,7 @@ const neutral = {
197
197
  ]
198
198
  } as Env;
199
199
 
200
- export default class EnvironmentScene extends Scene {
200
+ export class EnvironmentScene extends Scene {
201
201
  constructor(name: 'legacy'|'neutral') {
202
202
  super();
203
203