@needle-tools/engine 5.1.0-alpha.1 → 5.1.0-alpha.3

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 (250) hide show
  1. package/.needle/generated/needle-bindings.gen.d.ts +5 -0
  2. package/CHANGELOG.md +52 -0
  3. package/components.needle.json +1 -1
  4. package/dist/{gltf-progressive-DJBMx-zB.umd.cjs → gltf-progressive-BmblPzFj.umd.cjs} +4 -4
  5. package/dist/{gltf-progressive-BryRjllq.min.js → gltf-progressive-CN_mbb66.min.js} +2 -2
  6. package/dist/{gltf-progressive-Cl167Vjx.js → gltf-progressive-DUlhxdv4.js} +5 -2
  7. package/dist/needle-engine.bundle-C-ixARur.umd.cjs +1733 -0
  8. package/dist/needle-engine.bundle-CHmXdnE1.min.js +1733 -0
  9. package/dist/{needle-engine.bundle-BGyKqxBH.js → needle-engine.bundle-DF01sSGQ.js} +10841 -10434
  10. package/dist/needle-engine.d.ts +244 -54
  11. package/dist/needle-engine.js +541 -536
  12. package/dist/needle-engine.min.js +1 -1
  13. package/dist/needle-engine.umd.cjs +1 -1
  14. package/dist/{postprocessing-B_9sKVU7.min.js → postprocessing-B571qGWR.min.js} +34 -34
  15. package/dist/{postprocessing-WDc9WwI3.js → postprocessing-CfrLAbLX.js} +0 -1
  16. package/dist/{postprocessing-B2wb6pzI.umd.cjs → postprocessing-CiGkAeM9.umd.cjs} +17 -17
  17. package/dist/{vendor-CAcsI0eU.js → vendor-BFrMaK9q.js} +8983 -9136
  18. package/dist/vendor-CJmyOrCq.min.js +1116 -0
  19. package/dist/vendor-DkMW3WY4.umd.cjs +1116 -0
  20. package/lib/engine/api.d.ts +14 -0
  21. package/lib/engine/api.js +4 -0
  22. package/lib/engine/api.js.map +1 -1
  23. package/lib/engine/debug/debug_environment.js +1 -1
  24. package/lib/engine/debug/debug_environment.js.map +1 -1
  25. package/lib/engine/debug/debug_spatial_console.d.ts +2 -0
  26. package/lib/engine/debug/debug_spatial_console.js +10 -7
  27. package/lib/engine/debug/debug_spatial_console.js.map +1 -1
  28. package/lib/engine/engine_addressables.d.ts +2 -0
  29. package/lib/engine/engine_addressables.js +6 -3
  30. package/lib/engine/engine_addressables.js.map +1 -1
  31. package/lib/engine/engine_application.js +8 -6
  32. package/lib/engine/engine_application.js.map +1 -1
  33. package/lib/engine/engine_audio.d.ts +68 -0
  34. package/lib/engine/engine_audio.js +172 -0
  35. package/lib/engine/engine_audio.js.map +1 -1
  36. package/lib/engine/engine_components.js +1 -1
  37. package/lib/engine/engine_components.js.map +1 -1
  38. package/lib/engine/engine_constants.js +6 -0
  39. package/lib/engine/engine_constants.js.map +1 -1
  40. package/lib/engine/engine_context.d.ts +33 -7
  41. package/lib/engine/engine_context.js +40 -2
  42. package/lib/engine/engine_context.js.map +1 -1
  43. package/lib/engine/engine_context_registry.js +1 -1
  44. package/lib/engine/engine_context_registry.js.map +1 -1
  45. package/lib/engine/engine_gameobject.js +2 -2
  46. package/lib/engine/engine_gameobject.js.map +1 -1
  47. package/lib/engine/engine_init.js +16 -1
  48. package/lib/engine/engine_init.js.map +1 -1
  49. package/lib/engine/engine_input.d.ts +3 -2
  50. package/lib/engine/engine_input.js +3 -2
  51. package/lib/engine/engine_input.js.map +1 -1
  52. package/lib/engine/engine_license.d.ts +2 -0
  53. package/lib/engine/engine_license.js +25 -15
  54. package/lib/engine/engine_license.js.map +1 -1
  55. package/lib/engine/engine_lifecycle_functions_internal.js +5 -0
  56. package/lib/engine/engine_lifecycle_functions_internal.js.map +1 -1
  57. package/lib/engine/engine_mainloop_utils.js +5 -2
  58. package/lib/engine/engine_mainloop_utils.js.map +1 -1
  59. package/lib/engine/engine_networking_blob.d.ts +1 -1
  60. package/lib/engine/engine_networking_blob.js +5 -11
  61. package/lib/engine/engine_networking_blob.js.map +1 -1
  62. package/lib/engine/engine_physics_rapier.js +0 -1
  63. package/lib/engine/engine_physics_rapier.js.map +1 -1
  64. package/lib/engine/engine_pmrem.js +2 -2
  65. package/lib/engine/engine_pmrem.js.map +1 -1
  66. package/lib/engine/engine_scenedata.d.ts +32 -0
  67. package/lib/engine/engine_scenedata.js +138 -0
  68. package/lib/engine/engine_scenedata.js.map +1 -0
  69. package/lib/engine/engine_serialization_builtin_serializer.d.ts +10 -16
  70. package/lib/engine/engine_serialization_builtin_serializer.js +55 -41
  71. package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
  72. package/lib/engine/engine_ssr.d.ts +18 -0
  73. package/lib/engine/engine_ssr.js +40 -0
  74. package/lib/engine/engine_ssr.js.map +1 -0
  75. package/lib/engine/engine_three_utils.d.ts +14 -7
  76. package/lib/engine/engine_three_utils.js +14 -7
  77. package/lib/engine/engine_three_utils.js.map +1 -1
  78. package/lib/engine/engine_types.d.ts +2 -0
  79. package/lib/engine/engine_types.js.map +1 -1
  80. package/lib/engine/engine_utils.js +2 -0
  81. package/lib/engine/engine_utils.js.map +1 -1
  82. package/lib/engine/engine_utils_hash.d.ts +9 -0
  83. package/lib/engine/engine_utils_hash.js +112 -0
  84. package/lib/engine/engine_utils_hash.js.map +1 -0
  85. package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +1 -1
  86. package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js.map +1 -1
  87. package/lib/engine/webcomponents/jsx.d.ts +51 -0
  88. package/lib/engine/webcomponents/logo-element.d.ts +2 -1
  89. package/lib/engine/webcomponents/logo-element.js +2 -1
  90. package/lib/engine/webcomponents/logo-element.js.map +1 -1
  91. package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +4 -4
  92. package/lib/engine/webcomponents/needle menu/needle-menu.js +2 -1
  93. package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
  94. package/lib/engine/webcomponents/needle-button.d.ts +2 -1
  95. package/lib/engine/webcomponents/needle-button.js +2 -1
  96. package/lib/engine/webcomponents/needle-button.js.map +1 -1
  97. package/lib/engine/webcomponents/needle-engine.d.ts +11 -4
  98. package/lib/engine/webcomponents/needle-engine.js +2 -1
  99. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  100. package/lib/engine/xr/NeedleXRSession.d.ts +3 -2
  101. package/lib/engine/xr/NeedleXRSession.js +51 -15
  102. package/lib/engine/xr/NeedleXRSession.js.map +1 -1
  103. package/lib/engine/xr/events.d.ts +1 -1
  104. package/lib/engine/xr/events.js.map +1 -1
  105. package/lib/engine-components/Animation.js +17 -16
  106. package/lib/engine-components/Animation.js.map +1 -1
  107. package/lib/engine-components/AnimatorController.d.ts +2 -0
  108. package/lib/engine-components/AnimatorController.js +4 -1
  109. package/lib/engine-components/AnimatorController.js.map +1 -1
  110. package/lib/engine-components/AudioSource.d.ts +19 -3
  111. package/lib/engine-components/AudioSource.js +121 -68
  112. package/lib/engine-components/AudioSource.js.map +1 -1
  113. package/lib/engine-components/DragControls.d.ts +7 -0
  114. package/lib/engine-components/DragControls.js +19 -0
  115. package/lib/engine-components/DragControls.js.map +1 -1
  116. package/lib/engine-components/Light.d.ts +6 -8
  117. package/lib/engine-components/Light.js +40 -27
  118. package/lib/engine-components/Light.js.map +1 -1
  119. package/lib/engine-components/Networking.d.ts +1 -1
  120. package/lib/engine-components/Networking.js +1 -1
  121. package/lib/engine-components/OrbitControls.js +16 -11
  122. package/lib/engine-components/OrbitControls.js.map +1 -1
  123. package/lib/engine-components/ReflectionProbe.js +2 -0
  124. package/lib/engine-components/ReflectionProbe.js.map +1 -1
  125. package/lib/engine-components/RigidBody.js +3 -3
  126. package/lib/engine-components/RigidBody.js.map +1 -1
  127. package/lib/engine-components/SceneSwitcher.js +2 -0
  128. package/lib/engine-components/SceneSwitcher.js.map +1 -1
  129. package/lib/engine-components/SeeThrough.js +2 -2
  130. package/lib/engine-components/SeeThrough.js.map +1 -1
  131. package/lib/engine-components/api.d.ts +1 -1
  132. package/lib/engine-components/api.js +1 -1
  133. package/lib/engine-components/api.js.map +1 -1
  134. package/lib/engine-components/postprocessing/Effects/BloomEffect.d.ts +1 -1
  135. package/lib/engine-components/postprocessing/Effects/Sharpening.js +1 -2
  136. package/lib/engine-components/postprocessing/Effects/Sharpening.js.map +1 -1
  137. package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +1 -1
  138. package/lib/engine-components/postprocessing/PostProcessingHandler.js +5 -6
  139. package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
  140. package/lib/engine-components/postprocessing/VolumeParameter.d.ts +2 -0
  141. package/lib/engine-components/postprocessing/VolumeParameter.js +4 -1
  142. package/lib/engine-components/postprocessing/VolumeParameter.js.map +1 -1
  143. package/lib/engine-components/ui/Canvas.d.ts +1 -1
  144. package/lib/engine-components/ui/Canvas.js +2 -8
  145. package/lib/engine-components/ui/Canvas.js.map +1 -1
  146. package/lib/engine-components/ui/Text.d.ts +1 -0
  147. package/lib/engine-components/ui/Text.js +10 -7
  148. package/lib/engine-components/ui/Text.js.map +1 -1
  149. package/lib/engine-components/web/CursorFollow.js +21 -12
  150. package/lib/engine-components/web/CursorFollow.js.map +1 -1
  151. package/lib/engine-components/web/ScrollFollow.d.ts +0 -1
  152. package/lib/engine-components/web/ScrollFollow.js +3 -2
  153. package/lib/engine-components/web/ScrollFollow.js.map +1 -1
  154. package/lib/engine-components/webxr/WebXRImageTracking.js +4 -0
  155. package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
  156. package/lib/needle-engine.d.ts +2 -0
  157. package/lib/needle-engine.js +2 -0
  158. package/lib/needle-engine.js.map +1 -1
  159. package/package.json +6 -4
  160. package/plugins/dts-generator/dts.codegen.js +334 -0
  161. package/plugins/dts-generator/dts.scan.js +99 -0
  162. package/plugins/dts-generator/dts.writer.js +59 -0
  163. package/plugins/dts-generator/glb.discovery.js +279 -0
  164. package/plugins/dts-generator/glb.extractor.js +215 -0
  165. package/plugins/dts-generator/glb.reader.js +167 -0
  166. package/plugins/dts-generator/index.js +36 -0
  167. package/plugins/dts-generator/manifest.types.js +174 -0
  168. package/plugins/types/index.d.ts +2 -1
  169. package/plugins/types/needle-bindings.d.ts +30 -0
  170. package/plugins/types/userconfig.d.ts +21 -2
  171. package/plugins/vite/asap.js +18 -9
  172. package/plugins/vite/dependencies.js +29 -0
  173. package/plugins/vite/dependency-watcher.d.ts +2 -2
  174. package/plugins/vite/dependency-watcher.js +3 -4
  175. package/plugins/vite/drop.d.ts +2 -2
  176. package/plugins/vite/drop.js +3 -4
  177. package/plugins/vite/dts-generator.d.ts +7 -0
  178. package/plugins/vite/dts-generator.js +191 -0
  179. package/plugins/vite/index.d.ts +10 -3
  180. package/plugins/vite/index.js +27 -10
  181. package/plugins/vite/local-files-core.js +3 -3
  182. package/plugins/vite/local-files-utils.d.ts +3 -1
  183. package/plugins/vite/local-files-utils.js +29 -5
  184. package/plugins/vite/logging.js +2 -2
  185. package/plugins/vite/meta.js +4 -2
  186. package/plugins/vite/poster.d.ts +2 -2
  187. package/plugins/vite/poster.js +3 -5
  188. package/plugins/vite/reload.d.ts +2 -2
  189. package/plugins/vite/reload.js +23 -22
  190. package/src/engine/api.ts +18 -1
  191. package/src/engine/debug/debug_environment.ts +1 -1
  192. package/src/engine/debug/debug_spatial_console.ts +10 -7
  193. package/src/engine/engine_addressables.ts +6 -3
  194. package/src/engine/engine_application.ts +8 -6
  195. package/src/engine/engine_audio.ts +184 -0
  196. package/src/engine/engine_components.ts +1 -1
  197. package/src/engine/engine_constants.ts +11 -6
  198. package/src/engine/engine_context.ts +50 -7
  199. package/src/engine/engine_context_registry.ts +1 -1
  200. package/src/engine/engine_gameobject.ts +2 -2
  201. package/src/engine/engine_init.ts +15 -1
  202. package/src/engine/engine_input.ts +3 -2
  203. package/src/engine/engine_license.ts +23 -19
  204. package/src/engine/engine_lifecycle_functions_internal.ts +7 -0
  205. package/src/engine/engine_mainloop_utils.ts +5 -2
  206. package/src/engine/engine_networking_blob.ts +5 -11
  207. package/src/engine/engine_physics_rapier.ts +0 -3
  208. package/src/engine/engine_pmrem.ts +3 -3
  209. package/src/engine/engine_scenedata.ts +136 -0
  210. package/src/engine/engine_serialization_builtin_serializer.ts +63 -46
  211. package/src/engine/engine_ssr.ts +48 -0
  212. package/src/engine/engine_three_utils.ts +15 -7
  213. package/src/engine/engine_types.ts +2 -0
  214. package/src/engine/engine_utils.ts +1 -0
  215. package/src/engine/engine_utils_hash.ts +65 -0
  216. package/src/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +1 -1
  217. package/src/engine/webcomponents/jsx.d.ts +51 -0
  218. package/src/engine/webcomponents/logo-element.ts +3 -1
  219. package/src/engine/webcomponents/needle menu/needle-menu.ts +4 -2
  220. package/src/engine/webcomponents/needle-button.ts +3 -1
  221. package/src/engine/webcomponents/needle-engine.ts +12 -4
  222. package/src/engine/xr/NeedleXRSession.ts +49 -14
  223. package/src/engine/xr/events.ts +1 -1
  224. package/src/engine-components/Animation.ts +19 -16
  225. package/src/engine-components/AnimatorController.ts +4 -1
  226. package/src/engine-components/AudioSource.ts +130 -79
  227. package/src/engine-components/DragControls.ts +18 -2
  228. package/src/engine-components/Light.ts +40 -26
  229. package/src/engine-components/Networking.ts +1 -1
  230. package/src/engine-components/OrbitControls.ts +18 -9
  231. package/src/engine-components/ReflectionProbe.ts +2 -0
  232. package/src/engine-components/RigidBody.ts +3 -3
  233. package/src/engine-components/SceneSwitcher.ts +1 -0
  234. package/src/engine-components/SeeThrough.ts +2 -2
  235. package/src/engine-components/api.ts +1 -1
  236. package/src/engine-components/postprocessing/Effects/BloomEffect.ts +1 -1
  237. package/src/engine-components/postprocessing/Effects/Sharpening.ts +1 -2
  238. package/src/engine-components/postprocessing/PostProcessingHandler.ts +4 -8
  239. package/src/engine-components/postprocessing/VolumeParameter.ts +4 -1
  240. package/src/engine-components/ui/Canvas.ts +2 -8
  241. package/src/engine-components/ui/Text.ts +12 -8
  242. package/src/engine-components/web/CursorFollow.ts +21 -13
  243. package/src/engine-components/web/ScrollFollow.ts +2 -2
  244. package/src/engine-components/webxr/WebXRImageTracking.ts +2 -0
  245. package/src/needle-engine.ts +3 -0
  246. package/src/vite-env.d.ts +16 -0
  247. package/dist/needle-engine.bundle-CiYtOO2O.min.js +0 -1732
  248. package/dist/needle-engine.bundle-DzVx9Z8D.umd.cjs +0 -1732
  249. package/dist/vendor-CEM38hLE.umd.cjs +0 -1116
  250. package/dist/vendor-HRlxIBga.min.js +0 -1116
@@ -84,6 +84,7 @@ import { RawShaderMaterial } from 'three';
84
84
  import { Ray } from 'three';
85
85
  import { Raycaster } from 'three';
86
86
  import { Scene } from 'three';
87
+ import { SceneData } from '../../plugins/types/needle-bindings.d.ts';
87
88
  import { ShaderMaterial } from 'three';
88
89
  import { ShapeJSON } from 'three.quarks';
89
90
  import { SkinnedMesh } from 'three';
@@ -1471,6 +1472,75 @@ export declare class Attractor extends Component {
1471
1472
 
1472
1473
  declare type AttributeChangeCallback = (value: string | null) => void;
1473
1474
 
1475
+ /**
1476
+ * Represents an audio clip that can be loaded and played independently.
1477
+ * The AudioClip class encapsulates the URL of the audio resource and provides
1478
+ * methods for playback control (play, pause, stop) and querying duration.
1479
+ */
1480
+ export declare class AudioClip {
1481
+ readonly url: string;
1482
+ /**
1483
+ * Creates a new AudioClip instance with the specified URL.
1484
+ * @param url The URL of the audio resource to load. This can be a path to an audio file or a MediaStream URL.
1485
+ */
1486
+ constructor(url: string);
1487
+ /** Whether the clip is currently playing.
1488
+ * @returns `true` if the clip is actively playing audio.
1489
+ */
1490
+ get isPlaying(): boolean;
1491
+ /**
1492
+ * The total duration of the audio clip in seconds.
1493
+ * Loads the audio metadata if not already available.
1494
+ * @returns A promise that resolves with the duration in seconds.
1495
+ */
1496
+ getDuration(): Promise<number>;
1497
+ /**
1498
+ * Plays the audio clip from the current position.
1499
+ * @returns A promise that resolves when playback finishes, or rejects on error.
1500
+ * If the clip is looping, the promise will never resolve on its own – call {@link stop} or {@link pause} to end playback.
1501
+ */
1502
+ play(): Promise<void>;
1503
+ /**
1504
+ * Pauses playback at the current position.
1505
+ * Call {@link play} to resume.
1506
+ */
1507
+ pause(): void;
1508
+ /**
1509
+ * Stops playback and resets the position to the beginning.
1510
+ */
1511
+ stop(): void;
1512
+ /** Whether the clip should loop when reaching the end. */
1513
+ get loop(): boolean;
1514
+ set loop(value: boolean);
1515
+ /** Playback volume from 0 (silent) to 1 (full). */
1516
+ get volume(): number;
1517
+ set volume(value: number);
1518
+ /** Current playback position in seconds. */
1519
+ get currentTime(): number;
1520
+ set currentTime(value: number);
1521
+ /** Normalized playback progress from 0 to 1.
1522
+ * @returns The current playback position as a value between 0 and 1, or 0 if the duration is unknown.
1523
+ */
1524
+ get progress(): number;
1525
+ /**
1526
+ * Seeks to a normalized position (0–1) in the clip.
1527
+ * @param position A value between 0 (start) and 1 (end).
1528
+ */
1529
+ seek(position: number): void;
1530
+ /** The underlying HTMLAudioElement, or `undefined` if not yet created.
1531
+ * Use this to connect the element to the Web Audio API via `createMediaElementSource()`.
1532
+ * @returns The HTMLAudioElement if the clip has been loaded or played, otherwise `undefined`.
1533
+ */
1534
+ get audioElement(): HTMLAudioElement | undefined;
1535
+ private _audioElement?;
1536
+ private _duration?;
1537
+ private _loadPromise?;
1538
+ private _loop;
1539
+ private _volume;
1540
+ /** Lazily creates and loads the shared HTMLAudioElement. */
1541
+ private ensureAudioElement;
1542
+ }
1543
+
1474
1544
  /**
1475
1545
  * @category Animation and Sequencing
1476
1546
  * @see {@link PlayableDirector} for the main component to control timelines in Needle Engine.
@@ -1626,9 +1696,10 @@ export declare class AudioSource extends Component {
1626
1696
  */
1627
1697
  get isPlaying(): boolean;
1628
1698
  /**
1629
- * The total duration of the current audio clip in seconds.
1699
+ * The total duration of the currently loaded audio clip in seconds.
1630
1700
  *
1631
1701
  * @returns Duration in seconds or undefined if no clip is loaded
1702
+ * @remarks For MediaStream clips, duration is not directly available and will return undefined. If the audio clip has not started loading or is still loading, duration may also be undefined until the audio buffer is ready.
1632
1703
  */
1633
1704
  get duration(): number | undefined;
1634
1705
  /**
@@ -1653,7 +1724,8 @@ export declare class AudioSource extends Component {
1653
1724
  /**
1654
1725
  * Controls how the audio is positioned in space.
1655
1726
  * Values range from 0 (2D, non-positional) to 1 (fully 3D positioned).
1656
- * Note: 2D playback is not fully supported in the current implementation.
1727
+ * Internally uses a dual-path audio graph to crossfade between a spatialized (PannerNode)
1728
+ * and a non-spatialized (direct) signal path.
1657
1729
  */
1658
1730
  get spatialBlend(): number;
1659
1731
  set spatialBlend(val: number);
@@ -1701,7 +1773,11 @@ export declare class AudioSource extends Component {
1701
1773
  private audioLoader;
1702
1774
  private shouldPlay;
1703
1775
  private _lastClipStartedLoading;
1776
+ private _loadedClip;
1704
1777
  private _audioElement;
1778
+ private _entryNode;
1779
+ private _spatialGain;
1780
+ private _bypassGain;
1705
1781
  /**
1706
1782
  * Returns the underlying {@link PositionalAudio} object, creating it if necessary.
1707
1783
  * The audio source needs a user interaction to be initialized due to browser autoplay policies.
@@ -1729,6 +1805,15 @@ export declare class AudioSource extends Component {
1729
1805
  private onApplicationMuteChanged;
1730
1806
  private createAudio;
1731
1807
  private __onAllowAudioCallback;
1808
+ /**
1809
+ * Sets up the dual-path audio graph for spatial blend crossfading.
1810
+ * Creates two parallel signal paths from source to output:
1811
+ * - 3D path: entry → panner → spatialGain → gain (spatialized)
1812
+ * - 2D path: entry → bypassGain → gain (non-spatialized)
1813
+ */
1814
+ private setupSpatialBlendNodes;
1815
+ /** Updates the spatial/bypass gain values based on the current spatialBlend. */
1816
+ private updateSpatialBlendGains;
1732
1817
  private applySpatialDistanceSettings;
1733
1818
  private onNewClip;
1734
1819
  /**
@@ -1736,8 +1821,9 @@ export declare class AudioSource extends Component {
1736
1821
  * If no argument is provided, plays the currently assigned clip.
1737
1822
  *
1738
1823
  * @param clip - Optional audio clip or {@link MediaStream} to play
1824
+ * @returns A promise that resolves when playback starts successfully, or rejects on error
1739
1825
  */
1740
- play(clip?: string | MediaStream | undefined): void;
1826
+ play(clip?: string | MediaStream | undefined): Promise<boolean>;
1741
1827
  /**
1742
1828
  * Pauses audio playback while maintaining the current position.
1743
1829
  * Use play() to resume from the paused position.
@@ -2192,7 +2278,7 @@ export declare namespace BlobStorage {
2192
2278
  /**
2193
2279
  * Generates an md5 hash from a given buffer
2194
2280
  * @param buffer The buffer to hash
2195
- * @returns The md5 hash
2281
+ * @returns The md5 hash as a hex string
2196
2282
  */
2197
2283
  export function hashMD5(buffer: ArrayBuffer): string;
2198
2284
  export function hashMD5_Base64(buffer: ArrayBuffer): string;
@@ -2945,7 +3031,7 @@ export declare class Canvas extends UIRootComponent implements ICanvas {
2945
3031
  private _receivers;
2946
3032
  registerEventReceiver(receiver: ICanvasEventReceiver): void;
2947
3033
  unregisterEventReceiver(receiver: ICanvasEventReceiver): void;
2948
- onEnterXR(args: NeedleXREventArgs): Promise<void>;
3034
+ onEnterXR(args: NeedleXREventArgs): void;
2949
3035
  onLeaveXR(args: NeedleXREventArgs): void;
2950
3036
  onBeforeRenderRoutine: () => void;
2951
3037
  onAfterRenderRoutine: () => void;
@@ -3622,7 +3708,7 @@ declare class ColorSerializer extends TypeSerializer {
3622
3708
  onSerialize(data: any): any | void;
3623
3709
  }
3624
3710
 
3625
- export declare const colorSerializer: ColorSerializer;
3711
+ export declare let colorSerializer: ColorSerializer;
3626
3712
 
3627
3713
  /**
3628
3714
  * Utility method to check if two materials were created from the same glTF material
@@ -4096,7 +4182,7 @@ declare class ComponentSerializer extends TypeSerializer {
4096
4182
  findObjectForGuid(guid: string, root: Object3D): any;
4097
4183
  }
4098
4184
 
4099
- export declare const componentSerializer: ComponentSerializer;
4185
+ export declare let componentSerializer: ComponentSerializer;
4100
4186
 
4101
4187
  declare type ComponentType = "button" | "thumbstick" | "squeeze" | "touchpad";
4102
4188
 
@@ -4458,6 +4544,25 @@ export declare class Context implements IContext {
4458
4544
  * The main camera of the scene - this camera is used for rendering
4459
4545
  * Use `setCurrentCamera` for updating the main camera.
4460
4546
  */
4547
+ /**
4548
+ * Access your scene's full hierarchy, objects, and components directly by name — with full autocomplete.
4549
+ * Types are generated automatically from your GLB files when the dev server starts.
4550
+ *
4551
+ * You can store references to objects or components for later use.
4552
+ * Note that the scene hierarchy can change at runtime (e.g. when objects are added, removed, or re-parented),
4553
+ * in which case stored references may become stale.
4554
+ *
4555
+ * @experimental This API may change in future versions.
4556
+ *
4557
+ * @example
4558
+ * // Toggle auto-rotate on the orbit camera
4559
+ * ctx.sceneData.Camera.OrbitControls.autoRotate = true;
4560
+ *
4561
+ * @example
4562
+ * // Change the background color
4563
+ * ctx.sceneData.Camera.Camera.backgroundColor = new RGBAColor(1, 0, 0, 1);
4564
+ */
4565
+ get sceneData(): SceneData;
4461
4566
  get mainCamera(): Camera_2;
4462
4567
  /** Set the main camera of the scene. If set to null the camera of the {@link mainCameraComponent} will be used - this camera is used for rendering */
4463
4568
  set mainCamera(cam: Camera_2 | null);
@@ -4479,15 +4584,21 @@ export declare class Context implements IContext {
4479
4584
  connection: NetworkConnection;
4480
4585
  /** @deprecated AssetDatabase is deprecated */
4481
4586
  assets: AssetDatabase;
4482
- /** The main light in the scene */
4483
- mainLight: ILight | null;
4587
+ /** All registered lights in the scene, maintained by the Light component.
4588
+ * @see mainLight for accessing the main directional light in the scene
4589
+ */
4590
+ readonly lights: ILight[];
4591
+ /** The brightest registered directional light, or null if none are registered
4592
+ * @see lights
4593
+ */
4594
+ get mainLight(): ILight | null;
4484
4595
  /** @deprecated Use sceneLighting */
4485
- get rendererData(): RendererData;
4596
+ private get rendererData();
4486
4597
  /** Access the scene lighting manager to control lighting settings in the context */
4487
- sceneLighting: RendererData;
4488
- addressables: Addressables;
4489
- lightmaps: ILightDataRegistry;
4490
- players: PlayerViewManager;
4598
+ readonly sceneLighting: RendererData;
4599
+ readonly addressables: Addressables;
4600
+ readonly lightmaps: ILightDataRegistry;
4601
+ readonly players: PlayerViewManager;
4491
4602
  /** Access the LODs manager to control LOD behavior in the context */
4492
4603
  readonly lodsManager: LODsManager;
4493
4604
  /** Access the needle menu to add or remove buttons to the menu element */
@@ -5454,6 +5565,12 @@ export declare class DragControls extends Component implements IPointerEventHand
5454
5565
  * providing visual feedback about the object's position relative to surfaces below it.
5455
5566
  */
5456
5567
  showGizmo: boolean;
5568
+ /** Invoked once when a drag begins (after the minimum drag distance threshold is met). */
5569
+ dragStarted: EventList;
5570
+ /** Invoked every frame while the object is being dragged. */
5571
+ dragUpdated: EventList;
5572
+ /** Invoked once when the last pointer is released and the drag ends. */
5573
+ dragEnded: EventList;
5457
5574
  /**
5458
5575
  * Returns the object currently being dragged by this DragControls component, if any.
5459
5576
  * @returns The object being dragged or null if no object is currently dragged
@@ -5894,19 +6011,6 @@ export declare class EnvironmentScene extends Scene {
5894
6011
  createAreaLightMaterial(intensity: number): MeshBasicMaterial;
5895
6012
  }
5896
6013
 
5897
- export declare const euler: EulerSerializer;
5898
-
5899
- declare class EulerSerializer extends TypeSerializer {
5900
- constructor();
5901
- onDeserialize(data: any, _context: SerializationContext): Euler | undefined;
5902
- onSerialize(data: any, _context: SerializationContext): {
5903
- x: any;
5904
- y: any;
5905
- z: any;
5906
- order: any;
5907
- };
5908
- }
5909
-
5910
6014
  /**
5911
6015
  * EventList manages a list of callbacks that can be invoked together.
5912
6016
  * Used for Unity-style events that can be configured in the editor (Unity or Blender).
@@ -6039,7 +6143,7 @@ declare class EventListSerializer extends TypeSerializer {
6039
6143
  onDeserialize(data: EventListData, context: SerializationContext): EventList<any> | undefined | null;
6040
6144
  }
6041
6145
 
6042
- export declare const eventListSerializer: EventListSerializer;
6146
+ export declare let eventListSerializer: EventListSerializer;
6043
6147
 
6044
6148
  /**
6045
6149
  * [EventSystem](https://engine.needle.tools/docs/api/EventSystem) is responsible for managing and dispatching input events to UI components within the scene.
@@ -7130,6 +7234,20 @@ export declare function getPeerOptions(): PeerJSOption | undefined;
7130
7234
 
7131
7235
  export declare function getResourceUserCount(object: object): number | undefined;
7132
7236
 
7237
+ /**
7238
+ * Returns a lazily-resolved proxy typed as {@link SceneData}.
7239
+ * The proxy is cached per context — each context gets exactly one instance.
7240
+ *
7241
+ * Shape mirrors the generated `needle-bindings.gen.d.ts`:
7242
+ * ctx.sceneData.MyGlb.Camera.$components.OrbitControls.autoRotate = true;
7243
+ * ctx.sceneData.MyGlb.Camera.$object // → THREE.Camera
7244
+ * ctx.sceneData.MyGlb.UI.Button.$components.Button // → Needle Button component
7245
+ *
7246
+ * GLB name is ignored at runtime (scene is already loaded).
7247
+ * Node lookup starts at the scene root.
7248
+ */
7249
+ export declare function getSceneData(ctx: IContext): SceneData;
7250
+
7133
7251
  export declare function getTempColor(color?: Color): Color;
7134
7252
 
7135
7253
  /**
@@ -7460,13 +7578,20 @@ export declare class GraphicRaycaster extends ObjectRaycaster {
7460
7578
  * Utility class to perform various graphics operations like copying textures to canvas
7461
7579
  */
7462
7580
  export declare class Graphics {
7463
- private static readonly planeGeometry;
7464
- private static readonly renderer;
7465
- private static readonly perspectiveCam;
7466
- private static readonly orthographicCam;
7467
- private static readonly scene;
7468
- private static readonly blitMaterial;
7469
- private static readonly mesh;
7581
+ private static _planeGeometry;
7582
+ private static _renderer;
7583
+ private static _perspectiveCam;
7584
+ private static _orthographicCam;
7585
+ private static _scene;
7586
+ private static _blitMaterial;
7587
+ private static _mesh;
7588
+ private static get planeGeometry();
7589
+ private static get renderer();
7590
+ private static get perspectiveCam();
7591
+ private static get orthographicCam();
7592
+ private static get scene();
7593
+ private static get blitMaterial();
7594
+ private static get mesh();
7470
7595
  /**
7471
7596
  * Copy a texture to a new texture
7472
7597
  * @param texture the texture to copy
@@ -7930,6 +8055,9 @@ export declare class HoverAnimation extends Component {
7930
8055
  private playHover;
7931
8056
  }
7932
8057
 
8058
+ /** SSR-safe base class for web components. */
8059
+ declare const HTMLElementBase: typeof HTMLElement;
8060
+
7933
8061
  export declare type IAnimationComponent = Pick<IComponent, "gameObject"> & {
7934
8062
  isAnimationComponent: boolean;
7935
8063
  addClip?(clip: AnimationClip): any;
@@ -8189,6 +8317,8 @@ declare interface ILayoutGroup extends IComponent {
8189
8317
  export declare interface ILight extends IComponent {
8190
8318
  intensity: number;
8191
8319
  color: Color;
8320
+ /** The type of light as a lowercase string: `"directional"`, `"point"`, `"spot"` */
8321
+ readonly type: "directional" | "point" | "spot";
8192
8322
  }
8193
8323
 
8194
8324
  declare interface ILightDataRegistry {
@@ -8405,10 +8535,20 @@ export declare class InheritVelocityModule {
8405
8535
  applyCurrent(vel: Vector3 | Vector3_2, t01: number, lerpFactor: number): void;
8406
8536
  }
8407
8537
 
8538
+ /* Excluded from this release type: initAddressableSerializers */
8539
+
8540
+ /** Register all builtin serializers and prototype patches.
8541
+ * Must be called from {@link initEngine} so the registrations survive tree-shaking
8542
+ * when the package declares `sideEffects: false`.
8543
+ */
8544
+ export declare function initBuiltinSerializers(): void;
8545
+
8408
8546
  /** Register the Rapier physics backend. Called from {@link initEngine}
8409
8547
  * to ensure it runs regardless of tree-shaking. */
8410
8548
  export declare function initPhysics(): void;
8411
8549
 
8550
+ /* Excluded from this release type: initVolumeParameterSerializer */
8551
+
8412
8552
  /**
8413
8553
  * Handles all input events including mouse, touch, keyboard, and XR controllers.
8414
8554
  * Access via `this.context.input` from any component.
@@ -9699,6 +9839,9 @@ declare const enum KeyboardEnumType {
9699
9839
  KeyPressed = "keypress"
9700
9840
  }
9701
9841
 
9842
+ /** SSR-safe base class for keyboard events. */
9843
+ declare const KeyboardEventBase: typeof KeyboardEvent;
9844
+
9702
9845
  declare type KeyboardEventListener = (evt: NEKeyboardEvent) => void;
9703
9846
 
9704
9847
  declare type KeyboardEventNames = EnumToPrimitiveUnion<KeyboardEnumType>;
@@ -9823,10 +9966,13 @@ declare type LifecycleMethodOptions = {
9823
9966
  */
9824
9967
  export declare class Light extends Component implements ILight {
9825
9968
  /**
9826
- * The type of light (spot, directional, point, etc.)
9827
- * Can not be changed at runtime.
9969
+ * The type of light as a lowercase string: `"directional"`, `"point"`, `"spot"`.
9970
+ * Implements {@link ILight.type}. Can not be changed at runtime.
9828
9971
  */
9829
- private type;
9972
+ get type(): ILight["type"];
9973
+ /** Numeric LightType serialized from Unity/Blender — converts to string on write */
9974
+ set type(value: LightType | ILight["type"]);
9975
+ private _type;
9830
9976
  /**
9831
9977
  * The maximum distance the light affects.
9832
9978
  * Only applicable for spot and point lights.
@@ -9932,11 +10078,6 @@ export declare class Light extends Component implements ILight {
9932
10078
  * and applies all settings like shadows, intensity, and color.
9933
10079
  */
9934
10080
  createLight(): void;
9935
- /**
9936
- * Coroutine that updates the main light reference in the context
9937
- * if this directional light should be the main light
9938
- */
9939
- updateMainLightRoutine(): Generator<undefined, void, unknown>;
9940
10081
  /**
9941
10082
  * Controls whether the renderer's shadow map type can be changed when soft shadows are used
9942
10083
  */
@@ -9985,6 +10126,25 @@ declare enum LightShadows {
9985
10126
  Soft = 2
9986
10127
  }
9987
10128
 
10129
+ /**
10130
+ * Defines the type of light in a scene.
10131
+ * @see {@link Light} for configuring light properties and behavior
10132
+ */
10133
+ declare enum LightType {
10134
+ /** Spot light that emits light in a cone shape */
10135
+ Spot = 0,
10136
+ /** Directional light that emits parallel light rays in a specific direction */
10137
+ Directional = 1,
10138
+ /** Point light that emits light in all directions from a single point */
10139
+ Point = 2,
10140
+ /** Area light */
10141
+ Area = 3,
10142
+ /** Rectangle shaped area light that only affects baked lightmaps and light probes */
10143
+ Rectangle = 3,
10144
+ /** Disc shaped area light that only affects baked lightmaps and light probes */
10145
+ Disc = 4
10146
+ }
10147
+
9988
10148
  export declare class LimitVelocityOverLifetimeModule {
9989
10149
  enabled: boolean;
9990
10150
  dampen: number;
@@ -10972,6 +11132,23 @@ export declare type MouseButtonName = "left" | "right" | "middle";
10972
11132
 
10973
11133
  /* Excluded from this release type: nameofFactory */
10974
11134
 
11135
+ /**
11136
+ * Quick access to the current Needle Engine context from anywhere — no need to pass `ctx` around.
11137
+ * Use it in React/Svelte/Vue components, button handlers, or plain JavaScript.
11138
+ *
11139
+ * Safe to import at module level, including in SSR environments.
11140
+ * For pages with multiple `<needle-engine>` elements, use `ctx` directly instead.
11141
+ *
11142
+ * @experimental This API may change in future releases.
11143
+ *
11144
+ * @example
11145
+ * import { needle } from "@needle-tools/engine";
11146
+ * button.onclick = () => {
11147
+ * needle.sceneData.Camera.OrbitControls.autoRotate = true;
11148
+ * };
11149
+ */
11150
+ export declare const needle: IContext;
11151
+
10975
11152
  declare class NEEDLE_components implements GLTFLoaderPlugin {
10976
11153
  get name(): string;
10977
11154
  exportContext: {
@@ -11105,7 +11282,7 @@ export { NEEDLE_progressive }
11105
11282
  * @see {@link NeedleEngineWebComponent} for the main &lt;needle-engine&gt; element
11106
11283
  * @see {@link NeedleMenu} for the built-in menu component that can display similar buttons
11107
11284
  */
11108
- export declare class NeedleButtonElement extends HTMLElement {
11285
+ export declare class NeedleButtonElement extends HTMLElementBase {
11109
11286
  #private;
11110
11287
  static observedAttributes: string[];
11111
11288
  constructor();
@@ -11120,11 +11297,17 @@ export declare interface NeedleEngineAttributes {
11120
11297
  'hash': string;
11121
11298
  /** Set to automatically add OrbitControls to the loaded scene. */
11122
11299
  'camera-controls': string;
11123
- /** Override the default draco decoder path location. */
11300
+ /** Override the default Draco decoder/decompressor path. Can be a URL or a local path to a directory containing the Draco decoder files.
11301
+ * @default "https://www.gstatic.com/draco/versioned/decoders/1.5.7/"
11302
+ * @example <needle-engine dracoDecoderPath="./decoders/draco/"></needle-engine>
11303
+ */
11124
11304
  'dracoDecoderPath': string;
11125
- /** Override the default draco library type. */
11305
+ /** Override the default Draco decoder type. */
11126
11306
  'dracoDecoderType': 'wasm' | 'js';
11127
- /** Override the default KTX2 transcoder/decoder path. */
11307
+ /** Override the default KTX2 transcoder/decoder path. Can be a URL or a local path to a directory containing the KTX2 transcoder files.
11308
+ * @default "https://cdn.needle.tools/static/three/0.179.1/basis2/"
11309
+ * @example <needle-engine ktx2DecoderPath="./decoders/ktx2/"></needle-engine>
11310
+ */
11128
11311
  'ktx2DecoderPath': string;
11129
11312
  /** Prevent context from being disposed when element is removed from DOM. */
11130
11313
  'keep-alive': 'true' | 'false';
@@ -11245,7 +11428,7 @@ export declare namespace NeedleEngineModelLoader {
11245
11428
  * @see {@link NeedleButtonElement} for adding AR/VR/Quicklook buttons via &lt;needle-button&gt;
11246
11429
  * @see {@link NeedleMenu} for the built-in menu configuration component
11247
11430
  */
11248
- export declare class NeedleEngineWebComponent extends HTMLElement implements INeedleEngineComponent {
11431
+ export declare class NeedleEngineWebComponent extends HTMLElementBase implements INeedleEngineComponent {
11249
11432
  static get observedAttributes(): string[];
11250
11433
  get loadingProgress01(): number;
11251
11434
  get loadingFinished(): boolean;
@@ -12078,8 +12261,7 @@ export declare class NeedleXRSession implements INeedleXRSession {
12078
12261
  get referenceSpace(): XRSpace | null;
12079
12262
  /** @returns the XRFrame `viewerpose` using the xr `referenceSpace` */
12080
12263
  get viewerPose(): XRViewerPose | undefined;
12081
- /** @returns `true` if any image is currently being tracked */
12082
- /** returns true if images are currently being tracked */
12264
+ /** @returns `true` if any image is currently being tracked or emulated */
12083
12265
  get isTrackingImages(): boolean;
12084
12266
  /** The currently active XR rig */
12085
12267
  get rig(): IXRRig | null;
@@ -12125,6 +12307,8 @@ export declare class NeedleXRSession implements INeedleXRSession {
12125
12307
  private readonly _xr_update_scripts;
12126
12308
  /** scripts that are in the scene but inactive (e.g. disabled parent gameObject) */
12127
12309
  private readonly _inactive_scripts;
12310
+ /** tracks scripts that have received onEnterXR — prevents spurious onLeaveXR calls */
12311
+ private readonly _scripts_in_xr;
12128
12312
  private readonly _controllerAdded;
12129
12313
  private readonly _controllerRemoved;
12130
12314
  private readonly _originalCameraWorldPosition?;
@@ -12218,7 +12402,7 @@ export declare class NeedleXRUtils {
12218
12402
  }): void;
12219
12403
  }
12220
12404
 
12221
- export declare class NEKeyboardEvent extends KeyboardEvent {
12405
+ export declare class NEKeyboardEvent extends KeyboardEventBase {
12222
12406
  source?: Event;
12223
12407
  constructor(type: InputEvents, source: Event, init: KeyboardEventInit);
12224
12408
  stopImmediatePropagation(): void;
@@ -12242,7 +12426,7 @@ export declare class NEKeyboardEvent extends KeyboardEvent {
12242
12426
  * @see {@link Input} for the input management system
12243
12427
  * @see {@link PointerType} for available pointer types
12244
12428
  */
12245
- export declare class NEPointerEvent extends PointerEvent {
12429
+ export declare class NEPointerEvent extends PointerEventBase {
12246
12430
  /**
12247
12431
  * Spatial input data
12248
12432
  */
@@ -12744,7 +12928,7 @@ export declare interface NetworkEventMap {
12744
12928
  * @see {@link RoomEvents} for room lifecycle events
12745
12929
  * @see {@link isLocalNetwork} for local network detection
12746
12930
  * @link https://engine.needle.tools/docs/how-to-guides/networking/
12747
- * @summary Networking configuration
12931
+ * @summary Configures the websocket server URL for multiplayer networking
12748
12932
  * @category Networking
12749
12933
  * @group Components
12750
12934
  */
@@ -12965,7 +13149,7 @@ declare class ObjectSerializer extends TypeSerializer {
12965
13149
  onDeserialize(data: ObjectData | string | null, context: SerializationContext): Object3D<Object3DEventMap> | Component | null | undefined;
12966
13150
  }
12967
13151
 
12968
- export declare const objectSerializer: ObjectSerializer;
13152
+ export declare let objectSerializer: ObjectSerializer;
12969
13153
 
12970
13154
  declare type ObjectToNodeMap = {
12971
13155
  [uuid: string]: number;
@@ -15074,6 +15258,9 @@ export declare class OrbitControls extends Component implements ICameraControlle
15074
15258
  PointerMove = "pointermove"
15075
15259
  }
15076
15260
 
15261
+ /** SSR-safe base class for pointer events. */
15262
+ declare const PointerEventBase: typeof PointerEvent;
15263
+
15077
15264
  /** [PointerEventData](https://engine.needle.tools/docs/api/PointerEventData) This pointer event data object is passed to all event receivers that are currently active
15078
15265
  * It contains hit information if an object was hovered or clicked
15079
15266
  * If the event is received in onPointerDown or onPointerMove, you can call `setPointerCapture` to receive onPointerMove events even when the pointer has left the object until you call `releasePointerCapture` or when the pointerUp event happens
@@ -16961,6 +17148,8 @@ export declare class OrbitControls extends Component implements ICameraControlle
16961
17148
  */
16962
17149
  declare type ScaleClipType = "linear" | "spring";
16963
17150
 
17151
+ export { SceneData }
17152
+
16964
17153
  export declare class SceneLightSettings extends Component {
16965
17154
  ambientMode: AmbientMode;
16966
17155
  ambientLight?: Color;
@@ -20317,6 +20506,7 @@ export declare class OrbitControls extends Component implements ICameraControlle
20317
20506
  set font(val: string | null);
20318
20507
  get font(): string | null;
20319
20508
  private _font;
20509
+ private _assignedAtRuntime;
20320
20510
  /**
20321
20511
  * Whether to support basic rich text tags in the `text` property. Supported tags include `<b>`, `<i>`, and `<color=hex>`. For example: `Hello <b>World</b>` or `Score: <color=#ff0000>100</color>`
20322
20512
  * @default false