@needle-tools/engine 5.1.0-canary.c111c4f → 5.1.0-canary.cce79c8

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 (294) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/components.needle.json +1 -1
  3. package/dist/needle-engine.bundle-B1w7P037.min.js +1733 -0
  4. package/dist/needle-engine.bundle-C4w-9vec.umd.cjs +1733 -0
  5. package/dist/{needle-engine.bundle-BuaGvme0.js → needle-engine.bundle-CPbnC8NP.js} +15153 -14701
  6. package/dist/needle-engine.d.ts +898 -271
  7. package/dist/needle-engine.js +584 -582
  8. package/dist/needle-engine.min.js +1 -1
  9. package/dist/needle-engine.umd.cjs +1 -1
  10. package/dist/three-examples.js +3778 -4289
  11. package/dist/three-examples.min.js +14 -301
  12. package/dist/three-examples.umd.cjs +14 -301
  13. package/lib/engine/api.d.ts +5 -0
  14. package/lib/engine/api.js +4 -0
  15. package/lib/engine/api.js.map +1 -1
  16. package/lib/engine/codegen/register_types.js +2 -10
  17. package/lib/engine/codegen/register_types.js.map +1 -1
  18. package/lib/engine/debug/debug_spatial_console.d.ts +2 -0
  19. package/lib/engine/debug/debug_spatial_console.js +10 -7
  20. package/lib/engine/debug/debug_spatial_console.js.map +1 -1
  21. package/lib/engine/engine_addressables.d.ts +2 -0
  22. package/lib/engine/engine_addressables.js +6 -3
  23. package/lib/engine/engine_addressables.js.map +1 -1
  24. package/lib/engine/engine_audio.d.ts +68 -0
  25. package/lib/engine/engine_audio.js +172 -0
  26. package/lib/engine/engine_audio.js.map +1 -1
  27. package/lib/engine/engine_components.js +1 -1
  28. package/lib/engine/engine_components.js.map +1 -1
  29. package/lib/engine/engine_context.d.ts +17 -20
  30. package/lib/engine/engine_context.js +15 -17
  31. package/lib/engine/engine_context.js.map +1 -1
  32. package/lib/engine/engine_disposable.d.ts +172 -0
  33. package/lib/engine/engine_disposable.js +136 -0
  34. package/lib/engine/engine_disposable.js.map +1 -0
  35. package/lib/engine/engine_gameobject.d.ts +1 -10
  36. package/lib/engine/engine_gameobject.js +22 -120
  37. package/lib/engine/engine_gameobject.js.map +1 -1
  38. package/lib/engine/engine_gltf_builtin_components.js +7 -69
  39. package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
  40. package/lib/engine/engine_init.js +13 -3
  41. package/lib/engine/engine_init.js.map +1 -1
  42. package/lib/engine/engine_input.d.ts +1 -1
  43. package/lib/engine/engine_input.js +1 -1
  44. package/lib/engine/engine_input.js.map +1 -1
  45. package/lib/engine/engine_instantiate_resolve.d.ts +42 -0
  46. package/lib/engine/engine_instantiate_resolve.js +372 -0
  47. package/lib/engine/engine_instantiate_resolve.js.map +1 -0
  48. package/lib/engine/engine_license.js +1 -1
  49. package/lib/engine/engine_license.js.map +1 -1
  50. package/lib/engine/engine_mainloop_utils.js +7 -4
  51. package/lib/engine/engine_mainloop_utils.js.map +1 -1
  52. package/lib/engine/engine_networking.d.ts +51 -37
  53. package/lib/engine/engine_networking.js +132 -82
  54. package/lib/engine/engine_networking.js.map +1 -1
  55. package/lib/engine/engine_networking.transport.websocket.d.ts +15 -0
  56. package/lib/engine/engine_networking.transport.websocket.js +38 -0
  57. package/lib/engine/engine_networking.transport.websocket.js.map +1 -0
  58. package/lib/engine/engine_networking_blob.js +1 -1
  59. package/lib/engine/engine_networking_blob.js.map +1 -1
  60. package/lib/engine/engine_networking_instantiate.js +2 -2
  61. package/lib/engine/engine_networking_instantiate.js.map +1 -1
  62. package/lib/engine/engine_networking_types.d.ts +39 -1
  63. package/lib/engine/engine_networking_types.js +7 -0
  64. package/lib/engine/engine_networking_types.js.map +1 -1
  65. package/lib/engine/engine_physics_rapier.d.ts +11 -3
  66. package/lib/engine/engine_physics_rapier.js +88 -25
  67. package/lib/engine/engine_physics_rapier.js.map +1 -1
  68. package/lib/engine/engine_scenedata.d.ts +5 -7
  69. package/lib/engine/engine_scenedata.js +16 -13
  70. package/lib/engine/engine_scenedata.js.map +1 -1
  71. package/lib/engine/engine_serialization_builtin_serializer.d.ts +10 -16
  72. package/lib/engine/engine_serialization_builtin_serializer.js +56 -46
  73. package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
  74. package/lib/engine/engine_serialization_core.d.ts +1 -0
  75. package/lib/engine/engine_serialization_core.js +7 -0
  76. package/lib/engine/engine_serialization_core.js.map +1 -1
  77. package/lib/engine/engine_types.d.ts +19 -11
  78. package/lib/engine/engine_types.js +1 -1
  79. package/lib/engine/engine_types.js.map +1 -1
  80. package/lib/engine/engine_util_decorator.js +7 -2
  81. package/lib/engine/engine_util_decorator.js.map +1 -1
  82. package/lib/engine/engine_utils.d.ts +1 -1
  83. package/lib/engine/engine_utils.js +19 -5
  84. package/lib/engine/engine_utils.js.map +1 -1
  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.js.map +1 -1
  89. package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +3 -4
  90. package/lib/engine/webcomponents/needle menu/needle-menu.js +1 -1
  91. package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
  92. package/lib/engine/webcomponents/needle-button.js.map +1 -1
  93. package/lib/engine/webcomponents/needle-engine.d.ts +10 -4
  94. package/lib/engine/webcomponents/needle-engine.js +1 -1
  95. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  96. package/lib/engine/xr/NeedleXRSession.d.ts +3 -2
  97. package/lib/engine/xr/NeedleXRSession.js +50 -14
  98. package/lib/engine/xr/NeedleXRSession.js.map +1 -1
  99. package/lib/engine/xr/events.d.ts +1 -1
  100. package/lib/engine/xr/events.js.map +1 -1
  101. package/lib/engine-components/Animation.js +17 -16
  102. package/lib/engine-components/Animation.js.map +1 -1
  103. package/lib/engine-components/Animator.d.ts +6 -0
  104. package/lib/engine-components/Animator.js +17 -12
  105. package/lib/engine-components/Animator.js.map +1 -1
  106. package/lib/engine-components/AnimatorController.builder.d.ts +113 -0
  107. package/lib/engine-components/AnimatorController.builder.js +195 -0
  108. package/lib/engine-components/AnimatorController.builder.js.map +1 -0
  109. package/lib/engine-components/AnimatorController.d.ts +4 -119
  110. package/lib/engine-components/AnimatorController.js +35 -233
  111. package/lib/engine-components/AnimatorController.js.map +1 -1
  112. package/lib/engine-components/AudioSource.d.ts +19 -3
  113. package/lib/engine-components/AudioSource.js +121 -68
  114. package/lib/engine-components/AudioSource.js.map +1 -1
  115. package/lib/engine-components/Collider.d.ts +18 -9
  116. package/lib/engine-components/Collider.js +61 -14
  117. package/lib/engine-components/Collider.js.map +1 -1
  118. package/lib/engine-components/Component.d.ts +72 -9
  119. package/lib/engine-components/Component.js +114 -10
  120. package/lib/engine-components/Component.js.map +1 -1
  121. package/lib/engine-components/DragControls.d.ts +7 -0
  122. package/lib/engine-components/DragControls.js +19 -7
  123. package/lib/engine-components/DragControls.js.map +1 -1
  124. package/lib/engine-components/EventList.d.ts +31 -9
  125. package/lib/engine-components/EventList.js +37 -76
  126. package/lib/engine-components/EventList.js.map +1 -1
  127. package/lib/engine-components/Joints.d.ts +4 -2
  128. package/lib/engine-components/Joints.js +19 -3
  129. package/lib/engine-components/Joints.js.map +1 -1
  130. package/lib/engine-components/Light.d.ts +0 -19
  131. package/lib/engine-components/Light.js +13 -97
  132. package/lib/engine-components/Light.js.map +1 -1
  133. package/lib/engine-components/Networking.d.ts +1 -1
  134. package/lib/engine-components/Networking.js +1 -1
  135. package/lib/engine-components/OrbitControls.js +16 -11
  136. package/lib/engine-components/OrbitControls.js.map +1 -1
  137. package/lib/engine-components/ReflectionProbe.js +2 -0
  138. package/lib/engine-components/ReflectionProbe.js.map +1 -1
  139. package/lib/engine-components/RigidBody.d.ts +12 -4
  140. package/lib/engine-components/RigidBody.js +18 -4
  141. package/lib/engine-components/RigidBody.js.map +1 -1
  142. package/lib/engine-components/SeeThrough.js +2 -2
  143. package/lib/engine-components/SeeThrough.js.map +1 -1
  144. package/lib/engine-components/api.d.ts +1 -1
  145. package/lib/engine-components/api.js +1 -1
  146. package/lib/engine-components/api.js.map +1 -1
  147. package/lib/engine-components/codegen/components.d.ts +3 -9
  148. package/lib/engine-components/codegen/components.js +3 -9
  149. package/lib/engine-components/codegen/components.js.map +1 -1
  150. package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +1 -1
  151. package/lib/engine-components/postprocessing/VolumeParameter.d.ts +2 -0
  152. package/lib/engine-components/postprocessing/VolumeParameter.js +4 -1
  153. package/lib/engine-components/postprocessing/VolumeParameter.js.map +1 -1
  154. package/lib/engine-components/timeline/PlayableDirector.d.ts +16 -6
  155. package/lib/engine-components/timeline/PlayableDirector.js +63 -61
  156. package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
  157. package/lib/engine-components/timeline/SignalAsset.d.ts +3 -1
  158. package/lib/engine-components/timeline/SignalAsset.js +1 -0
  159. package/lib/engine-components/timeline/SignalAsset.js.map +1 -1
  160. package/lib/engine-components/timeline/TimelineBuilder.d.ts +247 -0
  161. package/lib/engine-components/timeline/TimelineBuilder.js +400 -0
  162. package/lib/engine-components/timeline/TimelineBuilder.js.map +1 -0
  163. package/lib/engine-components/timeline/TimelineModels.d.ts +2 -1
  164. package/lib/engine-components/timeline/TimelineModels.js +3 -0
  165. package/lib/engine-components/timeline/TimelineModels.js.map +1 -1
  166. package/lib/engine-components/timeline/TimelineTracks.d.ts +23 -0
  167. package/lib/engine-components/timeline/TimelineTracks.js +71 -13
  168. package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
  169. package/lib/engine-components/timeline/index.d.ts +2 -1
  170. package/lib/engine-components/timeline/index.js +2 -0
  171. package/lib/engine-components/timeline/index.js.map +1 -1
  172. package/lib/engine-components/ui/Canvas.d.ts +1 -1
  173. package/lib/engine-components/ui/Canvas.js +2 -8
  174. package/lib/engine-components/ui/Canvas.js.map +1 -1
  175. package/lib/engine-components/ui/Text.d.ts +1 -0
  176. package/lib/engine-components/ui/Text.js +10 -7
  177. package/lib/engine-components/ui/Text.js.map +1 -1
  178. package/lib/engine-components/web/CursorFollow.js +21 -12
  179. package/lib/engine-components/web/CursorFollow.js.map +1 -1
  180. package/lib/engine-components/webxr/WebXRImageTracking.js +4 -0
  181. package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
  182. package/lib/needle-engine.d.ts +2 -0
  183. package/lib/needle-engine.js +1 -0
  184. package/lib/needle-engine.js.map +1 -1
  185. package/package.json +2 -83
  186. package/plugins/common/license.js +5 -2
  187. package/plugins/common/worker.js +9 -4
  188. package/plugins/dts-generator/dts.codegen.js +12 -6
  189. package/plugins/dts-generator/dts.writer.js +1 -1
  190. package/plugins/dts-generator/glb.extractor.js +12 -1
  191. package/plugins/dts-generator/glb.reader.js +42 -33
  192. package/plugins/types/userconfig.d.ts +12 -0
  193. package/plugins/vite/asap.js +17 -8
  194. package/plugins/vite/dependencies.js +29 -10
  195. package/plugins/vite/dependency-watcher.js +2 -2
  196. package/plugins/vite/dts-generator.d.ts +2 -2
  197. package/plugins/vite/dts-generator.js +6 -1
  198. package/plugins/vite/editor-connection.js +3 -3
  199. package/plugins/vite/local-files-core.js +3 -3
  200. package/plugins/vite/local-files-utils.d.ts +3 -1
  201. package/plugins/vite/local-files-utils.js +29 -5
  202. package/plugins/vite/reload.js +19 -18
  203. package/plugins/vite/server.js +2 -1
  204. package/src/engine/api.ts +7 -0
  205. package/src/engine/codegen/register_types.ts +2 -10
  206. package/src/engine/debug/debug_spatial_console.ts +10 -7
  207. package/src/engine/engine_addressables.ts +6 -3
  208. package/src/engine/engine_audio.ts +184 -0
  209. package/src/engine/engine_components.ts +1 -1
  210. package/src/engine/engine_context.ts +22 -23
  211. package/src/engine/engine_disposable.ts +214 -0
  212. package/src/engine/engine_gameobject.ts +54 -159
  213. package/src/engine/engine_gltf_builtin_components.ts +7 -76
  214. package/src/engine/engine_init.ts +13 -3
  215. package/src/engine/engine_input.ts +1 -1
  216. package/src/engine/engine_instantiate_resolve.ts +407 -0
  217. package/src/engine/engine_license.ts +1 -1
  218. package/src/engine/engine_mainloop_utils.ts +7 -4
  219. package/src/engine/engine_networking.transport.websocket.ts +45 -0
  220. package/src/engine/engine_networking.ts +161 -137
  221. package/src/engine/engine_networking_blob.ts +1 -1
  222. package/src/engine/engine_networking_instantiate.ts +2 -2
  223. package/src/engine/engine_networking_types.ts +41 -1
  224. package/src/engine/engine_physics_rapier.ts +82 -27
  225. package/src/engine/engine_scenedata.ts +16 -13
  226. package/src/engine/engine_serialization_builtin_serializer.ts +64 -52
  227. package/src/engine/engine_serialization_core.ts +9 -0
  228. package/src/engine/engine_types.ts +24 -15
  229. package/src/engine/engine_util_decorator.ts +7 -2
  230. package/src/engine/engine_utils.ts +16 -5
  231. package/src/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +1 -1
  232. package/src/engine/webcomponents/jsx.d.ts +51 -0
  233. package/src/engine/webcomponents/logo-element.ts +1 -0
  234. package/src/engine/webcomponents/needle menu/needle-menu.ts +3 -2
  235. package/src/engine/webcomponents/needle-button.ts +1 -0
  236. package/src/engine/webcomponents/needle-engine.ts +11 -4
  237. package/src/engine/xr/NeedleXRSession.ts +48 -13
  238. package/src/engine/xr/events.ts +1 -1
  239. package/src/engine-components/Animation.ts +19 -16
  240. package/src/engine-components/Animator.ts +18 -11
  241. package/src/engine-components/AnimatorController.builder.ts +261 -0
  242. package/src/engine-components/AnimatorController.ts +23 -292
  243. package/src/engine-components/AudioSource.ts +130 -79
  244. package/src/engine-components/Collider.ts +66 -18
  245. package/src/engine-components/Component.ts +118 -20
  246. package/src/engine-components/DragControls.ts +18 -11
  247. package/src/engine-components/EventList.ts +45 -83
  248. package/src/engine-components/Joints.ts +20 -4
  249. package/src/engine-components/Light.ts +13 -96
  250. package/src/engine-components/Networking.ts +1 -1
  251. package/src/engine-components/OrbitControls.ts +18 -9
  252. package/src/engine-components/ReflectionProbe.ts +2 -0
  253. package/src/engine-components/RigidBody.ts +18 -4
  254. package/src/engine-components/SeeThrough.ts +2 -2
  255. package/src/engine-components/api.ts +1 -1
  256. package/src/engine-components/codegen/components.ts +3 -9
  257. package/src/engine-components/postprocessing/VolumeParameter.ts +4 -1
  258. package/src/engine-components/timeline/PlayableDirector.ts +61 -64
  259. package/src/engine-components/timeline/SignalAsset.ts +4 -1
  260. package/src/engine-components/timeline/TimelineBuilder.ts +565 -0
  261. package/src/engine-components/timeline/TimelineModels.ts +5 -1
  262. package/src/engine-components/timeline/TimelineTracks.ts +74 -13
  263. package/src/engine-components/timeline/index.ts +2 -1
  264. package/src/engine-components/ui/Canvas.ts +2 -8
  265. package/src/engine-components/ui/Text.ts +12 -8
  266. package/src/engine-components/web/CursorFollow.ts +21 -13
  267. package/src/engine-components/webxr/WebXRImageTracking.ts +2 -0
  268. package/src/needle-engine.ts +1 -0
  269. package/dist/needle-engine.bundle-CayCdkzK.min.js +0 -1732
  270. package/dist/needle-engine.bundle-DVhVGqQR.umd.cjs +0 -1732
  271. package/lib/engine-components/AvatarLoader.d.ts +0 -80
  272. package/lib/engine-components/AvatarLoader.js +0 -232
  273. package/lib/engine-components/AvatarLoader.js.map +0 -1
  274. package/lib/engine-components/avatar/AvatarBlink_Simple.d.ts +0 -11
  275. package/lib/engine-components/avatar/AvatarBlink_Simple.js +0 -77
  276. package/lib/engine-components/avatar/AvatarBlink_Simple.js.map +0 -1
  277. package/lib/engine-components/avatar/AvatarEyeLook_Rotation.d.ts +0 -14
  278. package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js +0 -69
  279. package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js.map +0 -1
  280. package/lib/engine-components/avatar/Avatar_Brain_LookAt.d.ts +0 -29
  281. package/lib/engine-components/avatar/Avatar_Brain_LookAt.js +0 -122
  282. package/lib/engine-components/avatar/Avatar_Brain_LookAt.js.map +0 -1
  283. package/lib/engine-components/avatar/Avatar_MouthShapes.d.ts +0 -15
  284. package/lib/engine-components/avatar/Avatar_MouthShapes.js +0 -80
  285. package/lib/engine-components/avatar/Avatar_MouthShapes.js.map +0 -1
  286. package/lib/engine-components/avatar/Avatar_MustacheShake.d.ts +0 -9
  287. package/lib/engine-components/avatar/Avatar_MustacheShake.js +0 -30
  288. package/lib/engine-components/avatar/Avatar_MustacheShake.js.map +0 -1
  289. package/src/engine-components/AvatarLoader.ts +0 -264
  290. package/src/engine-components/avatar/AvatarBlink_Simple.ts +0 -70
  291. package/src/engine-components/avatar/AvatarEyeLook_Rotation.ts +0 -64
  292. package/src/engine-components/avatar/Avatar_Brain_LookAt.ts +0 -140
  293. package/src/engine-components/avatar/Avatar_MouthShapes.ts +0 -84
  294. package/src/engine-components/avatar/Avatar_MustacheShake.ts +0 -32
@@ -40,6 +40,7 @@ import { GLTFLoader } from '../../../node_modules/@types/three/examples/jsm/load
40
40
  import { GLTFLoaderPlugin } from '../../../node_modules/@types/three/examples/jsm/loaders/GLTFLoader.js';
41
41
  import { GLTFParser } from '../../../node_modules/@types/three/examples/jsm/loaders/GLTFLoader.js';
42
42
  import { Group } from 'three';
43
+ import { ImpulseJoint } from '@dimforge/rapier3d-compat';
43
44
  import { InstancedMesh } from 'three';
44
45
  import { Intersection } from 'three';
45
46
  import { IParticleSystem as IParticleSystem_2 } from 'three.quarks';
@@ -254,6 +255,24 @@ export declare class ActionModel implements IBehaviorElement {
254
255
  writeTo(document: USDDocument, writer: USDWriter): void;
255
256
  }
256
257
 
258
+ /**
259
+ * Options for an activation clip in the timeline builder
260
+ */
261
+ export declare type ActivationClipOptions = {
262
+ /** Start time of the clip in seconds. If omitted, placed after the previous clip on this track. */
263
+ start?: number;
264
+ /** Duration of the clip in seconds (required) */
265
+ duration: number;
266
+ /** Ease-in duration in seconds (default: 0) */
267
+ easeIn?: number;
268
+ /** Ease-out duration in seconds (default: 0) */
269
+ easeOut?: number;
270
+ };
271
+
272
+ export declare class ActivationTrackHandler extends TrackHandler {
273
+ evaluate(time: number): void;
274
+ }
275
+
257
276
  export declare const activeInHierarchyFieldName = "needle_isActiveInHierarchy";
258
277
 
259
278
  /**
@@ -500,6 +519,34 @@ export declare type AnimationClipModel = {
500
519
  rotation?: Quat | Quaternion;
501
520
  };
502
521
 
522
+ /**
523
+ * Options for an animation clip in the timeline builder
524
+ */
525
+ export declare type AnimationClipOptions = {
526
+ /** Start time of the clip in seconds. If omitted, placed after the previous clip on this track. */
527
+ start?: number;
528
+ /** Duration of the clip in seconds. Defaults to the animation clip duration. */
529
+ duration?: number;
530
+ /** Playback speed multiplier (default: 1) */
531
+ speed?: number;
532
+ /** Whether the animation should loop within the clip (default: false) */
533
+ loop?: boolean;
534
+ /** Ease-in duration in seconds (default: 0) */
535
+ easeIn?: number;
536
+ /** Ease-out duration in seconds (default: 0) */
537
+ easeOut?: number;
538
+ /** Offset into the source animation clip in seconds (default: 0) */
539
+ clipIn?: number;
540
+ /** Whether to remove the start offset of the animation (default: false) */
541
+ removeStartOffset?: boolean;
542
+ /** Pre-extrapolation mode (default: None) */
543
+ preExtrapolation?: ClipExtrapolation;
544
+ /** Post-extrapolation mode (default: None) */
545
+ postExtrapolation?: ClipExtrapolation;
546
+ /** Play the clip in reverse */
547
+ reversed?: boolean;
548
+ };
549
+
503
550
  /**
504
551
  * AnimationCurve is a representation of a curve that can be used to animate values over time.
505
552
  *
@@ -726,6 +773,12 @@ export declare class Animator extends Component implements IAnimationComponent {
726
773
  * Identifies this component as an animation component in the engine
727
774
  */
728
775
  get isAnimationComponent(): boolean;
776
+ /**
777
+ * The current animator mixer, used for low-level control of animations. Owned by the AnimatorController
778
+ * @returns The current AnimationMixer, or null if no controller is assigned
779
+ * @see AnimatorController.mixer
780
+ */
781
+ get mixer(): AnimationMixer | null;
729
782
  /**
730
783
  * When enabled, animation will affect the root transform position and rotation
731
784
  */
@@ -1102,13 +1155,6 @@ export declare class AnimatorController {
1102
1155
  * @param animator - The animator to bind this controller to
1103
1156
  */
1104
1157
  bind(animator: Animator): void;
1105
- /**
1106
- * Creates a deep copy of this controller.
1107
- * Clones the model data but does not copy runtime state.
1108
- *
1109
- * @returns A new AnimatorController instance with the same configuration
1110
- */
1111
- clone(): AnimatorController | null;
1112
1158
  /**
1113
1159
  * Updates the controller's state machine and animations.
1114
1160
  * Called each frame by the animator component.
@@ -1472,6 +1518,75 @@ export declare class Attractor extends Component {
1472
1518
 
1473
1519
  declare type AttributeChangeCallback = (value: string | null) => void;
1474
1520
 
1521
+ /**
1522
+ * Represents an audio clip that can be loaded and played independently.
1523
+ * The AudioClip class encapsulates the URL of the audio resource and provides
1524
+ * methods for playback control (play, pause, stop) and querying duration.
1525
+ */
1526
+ export declare class AudioClip {
1527
+ readonly url: string;
1528
+ /**
1529
+ * Creates a new AudioClip instance with the specified URL.
1530
+ * @param url The URL of the audio resource to load. This can be a path to an audio file or a MediaStream URL.
1531
+ */
1532
+ constructor(url: string);
1533
+ /** Whether the clip is currently playing.
1534
+ * @returns `true` if the clip is actively playing audio.
1535
+ */
1536
+ get isPlaying(): boolean;
1537
+ /**
1538
+ * The total duration of the audio clip in seconds.
1539
+ * Loads the audio metadata if not already available.
1540
+ * @returns A promise that resolves with the duration in seconds.
1541
+ */
1542
+ getDuration(): Promise<number>;
1543
+ /**
1544
+ * Plays the audio clip from the current position.
1545
+ * @returns A promise that resolves when playback finishes, or rejects on error.
1546
+ * If the clip is looping, the promise will never resolve on its own – call {@link stop} or {@link pause} to end playback.
1547
+ */
1548
+ play(): Promise<void>;
1549
+ /**
1550
+ * Pauses playback at the current position.
1551
+ * Call {@link play} to resume.
1552
+ */
1553
+ pause(): void;
1554
+ /**
1555
+ * Stops playback and resets the position to the beginning.
1556
+ */
1557
+ stop(): void;
1558
+ /** Whether the clip should loop when reaching the end. */
1559
+ get loop(): boolean;
1560
+ set loop(value: boolean);
1561
+ /** Playback volume from 0 (silent) to 1 (full). */
1562
+ get volume(): number;
1563
+ set volume(value: number);
1564
+ /** Current playback position in seconds. */
1565
+ get currentTime(): number;
1566
+ set currentTime(value: number);
1567
+ /** Normalized playback progress from 0 to 1.
1568
+ * @returns The current playback position as a value between 0 and 1, or 0 if the duration is unknown.
1569
+ */
1570
+ get progress(): number;
1571
+ /**
1572
+ * Seeks to a normalized position (0–1) in the clip.
1573
+ * @param position A value between 0 (start) and 1 (end).
1574
+ */
1575
+ seek(position: number): void;
1576
+ /** The underlying HTMLAudioElement, or `undefined` if not yet created.
1577
+ * Use this to connect the element to the Web Audio API via `createMediaElementSource()`.
1578
+ * @returns The HTMLAudioElement if the clip has been loaded or played, otherwise `undefined`.
1579
+ */
1580
+ get audioElement(): HTMLAudioElement | undefined;
1581
+ private _audioElement?;
1582
+ private _duration?;
1583
+ private _loadPromise?;
1584
+ private _loop;
1585
+ private _volume;
1586
+ /** Lazily creates and loads the shared HTMLAudioElement. */
1587
+ private ensureAudioElement;
1588
+ }
1589
+
1475
1590
  /**
1476
1591
  * @category Animation and Sequencing
1477
1592
  * @see {@link PlayableDirector} for the main component to control timelines in Needle Engine.
@@ -1486,6 +1601,26 @@ declare type AudioClipModel_2 = Models.ClipModel & {
1486
1601
  _didTriggerPlay: boolean;
1487
1602
  };
1488
1603
 
1604
+ /**
1605
+ * Options for an audio clip in the timeline builder
1606
+ */
1607
+ export declare type AudioClipOptions = {
1608
+ /** Start time of the clip in seconds. If omitted, placed after the previous clip on this track. */
1609
+ start?: number;
1610
+ /** Duration of the clip in seconds (required for audio since we can't infer it) */
1611
+ duration: number;
1612
+ /** Playback speed multiplier (default: 1) */
1613
+ speed?: number;
1614
+ /** Volume multiplier for this clip (default: 1) */
1615
+ volume?: number;
1616
+ /** Whether the audio should loop within the clip (default: false) */
1617
+ loop?: boolean;
1618
+ /** Ease-in duration in seconds (default: 0) */
1619
+ easeIn?: number;
1620
+ /** Ease-out duration in seconds (default: 0) */
1621
+ easeOut?: number;
1622
+ };
1623
+
1489
1624
  export declare class AudioExtension implements IUSDExporterExtension {
1490
1625
  static getName(clip: string): string;
1491
1626
  get extensionName(): string;
@@ -1627,9 +1762,10 @@ export declare class AudioSource extends Component {
1627
1762
  */
1628
1763
  get isPlaying(): boolean;
1629
1764
  /**
1630
- * The total duration of the current audio clip in seconds.
1765
+ * The total duration of the currently loaded audio clip in seconds.
1631
1766
  *
1632
1767
  * @returns Duration in seconds or undefined if no clip is loaded
1768
+ * @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.
1633
1769
  */
1634
1770
  get duration(): number | undefined;
1635
1771
  /**
@@ -1654,7 +1790,8 @@ export declare class AudioSource extends Component {
1654
1790
  /**
1655
1791
  * Controls how the audio is positioned in space.
1656
1792
  * Values range from 0 (2D, non-positional) to 1 (fully 3D positioned).
1657
- * Note: 2D playback is not fully supported in the current implementation.
1793
+ * Internally uses a dual-path audio graph to crossfade between a spatialized (PannerNode)
1794
+ * and a non-spatialized (direct) signal path.
1658
1795
  */
1659
1796
  get spatialBlend(): number;
1660
1797
  set spatialBlend(val: number);
@@ -1702,7 +1839,11 @@ export declare class AudioSource extends Component {
1702
1839
  private audioLoader;
1703
1840
  private shouldPlay;
1704
1841
  private _lastClipStartedLoading;
1842
+ private _loadedClip;
1705
1843
  private _audioElement;
1844
+ private _entryNode;
1845
+ private _spatialGain;
1846
+ private _bypassGain;
1706
1847
  /**
1707
1848
  * Returns the underlying {@link PositionalAudio} object, creating it if necessary.
1708
1849
  * The audio source needs a user interaction to be initialized due to browser autoplay policies.
@@ -1730,6 +1871,15 @@ export declare class AudioSource extends Component {
1730
1871
  private onApplicationMuteChanged;
1731
1872
  private createAudio;
1732
1873
  private __onAllowAudioCallback;
1874
+ /**
1875
+ * Sets up the dual-path audio graph for spatial blend crossfading.
1876
+ * Creates two parallel signal paths from source to output:
1877
+ * - 3D path: entry → panner → spatialGain → gain (spatialized)
1878
+ * - 2D path: entry → bypassGain → gain (non-spatialized)
1879
+ */
1880
+ private setupSpatialBlendNodes;
1881
+ /** Updates the spatial/bypass gain values based on the current spatialBlend. */
1882
+ private updateSpatialBlendGains;
1733
1883
  private applySpatialDistanceSettings;
1734
1884
  private onNewClip;
1735
1885
  /**
@@ -1737,8 +1887,9 @@ export declare class AudioSource extends Component {
1737
1887
  * If no argument is provided, plays the currently assigned clip.
1738
1888
  *
1739
1889
  * @param clip - Optional audio clip or {@link MediaStream} to play
1890
+ * @returns A promise that resolves when playback starts successfully, or rejects on error
1740
1891
  */
1741
- play(clip?: string | MediaStream | undefined): void;
1892
+ play(clip?: string | MediaStream | undefined): Promise<boolean>;
1742
1893
  /**
1743
1894
  * Pauses audio playback while maintaining the current position.
1744
1895
  * Use play() to resume from the paused position.
@@ -1755,6 +1906,20 @@ export declare class AudioSource extends Component {
1755
1906
  /* Excluded from this release type: update */
1756
1907
  }
1757
1908
 
1909
+ /**
1910
+ * Handles audio playback for a timeline audio track.
1911
+ *
1912
+ * **Runtime mutation:** The track model is read fresh every frame during `evaluate()`.
1913
+ * You can mutate `track.volume`, `clip.start`, `clip.end`, `clip.asset.volume` etc.
1914
+ * at any time — changes take effect on the next frame without rebuilding the timeline.
1915
+ *
1916
+ * **Audio stopping:** Audio clips are automatically stopped when:
1917
+ * - Timeline time moves outside a clip's `[start, end]` range (e.g. jumping or normal playback advancing past a clip)
1918
+ * - The track is muted (via `muted = true`)
1919
+ * - The director is stopped (`director.stop()`)
1920
+ * - The director is paused (`director.pause()`)
1921
+ * - The director is disabled or destroyed
1922
+ */
1758
1923
  export declare class AudioTrackHandler extends TrackHandler {
1759
1924
  models: Array<AudioClipModel_2>;
1760
1925
  listener: AudioListener_3;
@@ -1762,6 +1927,9 @@ export declare class AudioTrackHandler extends TrackHandler {
1762
1927
  audioContextTimeOffset: Array<number>;
1763
1928
  lastTime: number;
1764
1929
  audioSource?: AudioSource;
1930
+ /** Track-level volume multiplier (0–1). Applied on top of per-clip volume each frame. */
1931
+ get volume(): number;
1932
+ set volume(val: number);
1765
1933
  private _audioLoader;
1766
1934
  private getAudioFilePath;
1767
1935
  onAllowAudioChanged(allow: boolean): void;
@@ -1811,69 +1979,6 @@ export declare class Avatar extends Component {
1811
1979
  private loadAvatarObjects;
1812
1980
  }
1813
1981
 
1814
- /* Excluded from this release type: Avatar_Brain_LookAt */
1815
-
1816
- /* Excluded from this release type: Avatar_MouthShapes */
1817
-
1818
- /* Excluded from this release type: Avatar_MustacheShake */
1819
-
1820
- /* Excluded from this release type: Avatar_POI */
1821
-
1822
- /* Excluded from this release type: AvatarBlink_Simple */
1823
-
1824
- /* Excluded from this release type: AvatarEyeLook_Rotation */
1825
-
1826
- /**
1827
- * Handles loading and instantiating avatar models from various sources.
1828
- * Provides functionality to find and extract important parts of an avatar (head, hands).
1829
- *
1830
- * Debug mode can be enabled with the URL parameter `?debugavatar`,
1831
- * which will log detailed information about avatar loading and configuration.
1832
- */
1833
- export declare class AvatarLoader {
1834
- private readonly avatarRegistryUrl;
1835
- /**
1836
- * Retrieves or creates a new avatar instance from an ID or existing Object3D.
1837
- * @param context The application context
1838
- * @param avatarId Either a string ID to load an avatar or an existing Object3D to use as avatar
1839
- * @returns Promise resolving to an AvatarModel if successful, or null if failed
1840
- */
1841
- getOrCreateNewAvatarInstance(context: Context, avatarId: string | Object3D): Promise<AvatarModel | null>;
1842
- /**
1843
- * Loads an avatar model from a file or registry using the provided ID.
1844
- * @param context The engine context
1845
- * @param avatarId The ID of the avatar to load
1846
- * @returns Promise resolving to the loaded avatar's Object3D, or null if failed
1847
- */
1848
- private loadAvatar;
1849
- /**
1850
- * Caches an avatar model for reuse.
1851
- * @param _id The ID to associate with the model
1852
- * @param _model The avatar model to cache
1853
- */
1854
- private cacheModel;
1855
- /**
1856
- * Analyzes an Object3D to find avatar parts (head, hands) based on naming conventions.
1857
- * @param obj The Object3D to search for avatar parts
1858
- * @returns A structured AvatarModel with references to found parts
1859
- */
1860
- private findAvatar;
1861
- /**
1862
- * Recursively searches for an avatar part by name within an Object3D hierarchy.
1863
- * @param obj The Object3D to search within
1864
- * @param searchString Array of strings that should all be present in the object name
1865
- * @returns The found Object3D part or null if not found
1866
- */
1867
- private findAvatarPart;
1868
- /**
1869
- * Handles HTTP response errors from avatar loading operations.
1870
- * @param response The fetch API response to check
1871
- * @returns The response if it was ok
1872
- * @throws Error with status text if response was not ok
1873
- */
1874
- private handleCustomAvatarErrors;
1875
- }
1876
-
1877
1982
  /**
1878
1983
  * Marks a GameObject as being controlled or owned by a player in networked XR sessions.
1879
1984
  * This is used internally by the networking system to identify player-controlled objects.
@@ -1934,35 +2039,6 @@ declare type AvatarMarkerEventArgs = {
1934
2039
  gameObject: Object3D;
1935
2040
  };
1936
2041
 
1937
- /**
1938
- * Represents an avatar model with head and hands references.
1939
- * Used for representing characters in 3D space.
1940
- */
1941
- export declare class AvatarModel {
1942
- /** The root object of the avatar model */
1943
- root: Object3D;
1944
- /** The head object of the avatar model */
1945
- head: Object3D;
1946
- /** The left hand object of the avatar model, if available */
1947
- leftHand: Object3D | null;
1948
- /** The right hand object of the avatar model, if available */
1949
- rigthHand: Object3D | null;
1950
- /**
1951
- * Checks if the avatar model has a valid configuration.
1952
- * An avatar is considered valid if it has a head.
1953
- * @returns Whether the avatar has a valid setup
1954
- */
1955
- get isValid(): boolean;
1956
- /**
1957
- * Creates a new avatar model.
1958
- * @param root The root object of the avatar
1959
- * @param head The head object of the avatar
1960
- * @param leftHand The left hand object of the avatar
1961
- * @param rigthHand The right hand object of the avatar
1962
- */
1963
- constructor(root: Object3D, head: Object3D, leftHand: Object3D | null, rigthHand: Object3D | null);
1964
- }
1965
-
1966
2042
  export declare enum Axes {
1967
2043
  None = 0,
1968
2044
  X = 2,
@@ -2326,7 +2402,6 @@ export declare class BoxCollider extends Collider implements IBoxCollider {
2326
2402
  center: Vector3;
2327
2403
  /* Excluded from this release type: onEnable */
2328
2404
  /* Excluded from this release type: onDisable */
2329
- /* Excluded from this release type: onValidate */
2330
2405
  /**
2331
2406
  * Automatically fits the collider to the geometry of the object.
2332
2407
  * Sets the size and center based on the object's bounding box.
@@ -2600,6 +2675,7 @@ declare class CallHandle extends EventDispatcher<any> {
2600
2675
  * CallInfo represents a single callback method that can be invoked by the {@link EventList}.
2601
2676
  */
2602
2677
  export declare class CallInfo {
2678
+ $serializedTypes: Record<string, any>;
2603
2679
  /**
2604
2680
  * When the CallInfo is enabled it will be invoked when the EventList is invoked
2605
2681
  */
@@ -2946,7 +3022,7 @@ export declare class Canvas extends UIRootComponent implements ICanvas {
2946
3022
  private _receivers;
2947
3023
  registerEventReceiver(receiver: ICanvasEventReceiver): void;
2948
3024
  unregisterEventReceiver(receiver: ICanvasEventReceiver): void;
2949
- onEnterXR(args: NeedleXREventArgs): Promise<void>;
3025
+ onEnterXR(args: NeedleXREventArgs): void;
2950
3026
  onLeaveXR(args: NeedleXREventArgs): void;
2951
3027
  onBeforeRenderRoutine: () => void;
2952
3028
  onAfterRenderRoutine: () => void;
@@ -3522,6 +3598,22 @@ export declare abstract class Collider extends Component implements ICollider {
3522
3598
  * The layers that this collider will interact with. Used for filtering collision detection.
3523
3599
  */
3524
3600
  filter?: number[];
3601
+ /**
3602
+ * The density of the collider, used for automatic mass calculation when the attached {@link Rigidbody} has `autoMass` enabled.
3603
+ * Rapier computes mass from density using the real-world formula: `mass = density × volume`.
3604
+ * The volume is derived from the collider shape (sphere, box, capsule, or convex hull).
3605
+ *
3606
+ * Reference values (relative to water = 1.0):
3607
+ * - Wood: 0.5–0.9
3608
+ * - Water: 1.0 (engine default)
3609
+ * - Rubber: 1.2
3610
+ * - Steel: 7.8
3611
+ *
3612
+ * @default undefined — uses the physics engine default of 1.0
3613
+ */
3614
+ density?: number;
3615
+ /* Excluded from this release type: _propertiesDirty */
3616
+ /* Excluded from this release type: onValidate */
3525
3617
  /* Excluded from this release type: awake */
3526
3618
  /* Excluded from this release type: start */
3527
3619
  /* Excluded from this release type: onEnable */
@@ -3623,7 +3715,7 @@ declare class ColorSerializer extends TypeSerializer {
3623
3715
  onSerialize(data: any): any | void;
3624
3716
  }
3625
3717
 
3626
- export declare const colorSerializer: ColorSerializer;
3718
+ export declare let colorSerializer: ColorSerializer;
3627
3719
 
3628
3720
  /**
3629
3721
  * Utility method to check if two materials were created from the same glTF material
@@ -3644,7 +3736,7 @@ export declare function compareAssociation<T extends Material>(obj1: T, obj2: T)
3644
3736
  * **Input event methods:**
3645
3737
  * {@link onPointerDown}, {@link onPointerUp}, {@link onPointerEnter}, {@link onPointerExit} and {@link onPointerMove}.
3646
3738
  *
3647
- * @example
3739
+ * @example Basic component
3648
3740
  * ```typescript
3649
3741
  * import { Behaviour } from "@needle-tools/engine";
3650
3742
  * export class MyComponent extends Behaviour {
@@ -3657,6 +3749,25 @@ export declare function compareAssociation<T extends Material>(obj1: T, obj2: T)
3657
3749
  * }
3658
3750
  * ```
3659
3751
  *
3752
+ * @example Automatic cleanup with autoCleanup
3753
+ * ```typescript
3754
+ * import { Behaviour, serializable, EventList } from "@needle-tools/engine";
3755
+ * export class ScoreTracker extends Behaviour {
3756
+ * @serializable(EventList)
3757
+ * onScoreChanged?: EventList<number>;
3758
+ *
3759
+ * start() {
3760
+ * // Registered during start → survives enable/disable, cleaned up on destroy
3761
+ * this.autoCleanup(this.onScoreChanged?.on(score => console.log("Score:", score)));
3762
+ * }
3763
+ *
3764
+ * onEnable() {
3765
+ * // Registered during onEnable → cleaned up on disable
3766
+ * this.autoCleanup(() => this.cleanupResources());
3767
+ * }
3768
+ * }
3769
+ * ```
3770
+ *
3660
3771
  * @group Components
3661
3772
  */
3662
3773
  declare abstract class Component implements IComponent, EventTarget, Partial<INeedleXRSessionEventReceiver>, Partial<IPointerEventHandler> {
@@ -3707,6 +3818,50 @@ declare abstract class Component implements IComponent, EventTarget, Partial<INe
3707
3818
  * @returns True if the component is enabled and all parent GameObjects are active
3708
3819
  */
3709
3820
  get activeAndEnabled(): boolean;
3821
+ private __disableCleanups?;
3822
+ private __destroyCleanups?;
3823
+ /**
3824
+ * @experimental
3825
+ * Register a resource for automatic cleanup tied to this component's lifecycle.
3826
+ * Accepts {@link IDisposable} objects, cleanup functions, or event unsubscribe functions.
3827
+ * `null` and `undefined` are safe no-ops (convenient for conditional subscriptions).
3828
+ *
3829
+ * **Lifecycle-aware:** The cleanup store is chosen automatically based on when `autoCleanup` is called:
3830
+ * - Called during {@link onEnable} → cleaned up on {@link onDisable} (and re-registered on re-enable)
3831
+ * - Called during {@link awake} or {@link start} → cleaned up on {@link onDestroy} (survives enable/disable cycles)
3832
+ * - Called at any other time (e.g. from update) → cleaned up on {@link onDisable}
3833
+ *
3834
+ * @param disposable An {@link IDisposable}, a cleanup/unsubscribe function, or `null`/`undefined`
3835
+ *
3836
+ * @example EventList subscriptions
3837
+ * ```ts
3838
+ * import { Behaviour, serializable, EventList } from "@needle-tools/engine";
3839
+ *
3840
+ * export class MyComponent extends Behaviour {
3841
+ * @serializable(EventList)
3842
+ * onScoreChanged?: EventList<number>;
3843
+ *
3844
+ * onEnable() {
3845
+ * this.autoCleanup(this.onScoreChanged?.on(score => {
3846
+ * console.log("Score:", score);
3847
+ * }));
3848
+ * }
3849
+ * }
3850
+ * ```
3851
+ *
3852
+ * @example Lifetime subscriptions in awake
3853
+ * ```ts
3854
+ * import { Behaviour } from "@needle-tools/engine";
3855
+ *
3856
+ * export class Persistent extends Behaviour {
3857
+ * awake() {
3858
+ * // Registered during awake → survives enable/disable, cleaned up on destroy
3859
+ * this.autoCleanup(() => this.save());
3860
+ * }
3861
+ * }
3862
+ * ```
3863
+ */
3864
+ protected autoCleanup(disposable: IDisposable | DisposeFn | Function | null | undefined): void;
3710
3865
  private get __isActive();
3711
3866
  private get __isActiveInHierarchy();
3712
3867
  private set __isActiveInHierarchy(value);
@@ -3725,11 +3880,6 @@ declare abstract class Component implements IComponent, EventTarget, Partial<INe
3725
3880
  * For example, URL to the glTF file this component was loaded from
3726
3881
  */
3727
3882
  sourceId?: SourceIdentifier;
3728
- /**
3729
- * Called when this component needs to remap guids after an instantiate operation.
3730
- * @param guidsMap Mapping from old guids to newly generated guids
3731
- */
3732
- resolveGuids?(guidsMap: GuidsMap): void;
3733
3883
  /**
3734
3884
  * Called once when the component becomes active for the first time.
3735
3885
  * This is the first lifecycle callback to be invoked
@@ -3942,6 +4092,10 @@ declare abstract class Component implements IComponent, EventTarget, Partial<INe
3942
4092
  destroy(): void;
3943
4093
  /* Excluded from this release type: __didAwake */
3944
4094
  /* Excluded from this release type: __didStart */
4095
+ /** True while start() has finished executing (used by autoCleanup to distinguish start from update) */
4096
+ private __didCompleteStart;
4097
+ /** True while onEnable() is executing (used by autoCleanup to route to disable store) */
4098
+ private __inEnableOrDisableCallback;
3945
4099
  /* Excluded from this release type: __didEnable */
3946
4100
  /* Excluded from this release type: __isEnabled */
3947
4101
  /* Excluded from this release type: __destroyed */
@@ -4097,7 +4251,7 @@ declare class ComponentSerializer extends TypeSerializer {
4097
4251
  findObjectForGuid(guid: string, root: Object3D): any;
4098
4252
  }
4099
4253
 
4100
- export declare const componentSerializer: ComponentSerializer;
4254
+ export declare let componentSerializer: ComponentSerializer;
4101
4255
 
4102
4256
  declare type ComponentType = "button" | "thumbstick" | "squeeze" | "touchpad";
4103
4257
 
@@ -4460,13 +4614,14 @@ export declare class Context implements IContext {
4460
4614
  * Use `setCurrentCamera` for updating the main camera.
4461
4615
  */
4462
4616
  /**
4463
- * Typed proxy providing direct access to scene components by node and component name.
4464
- * Types are auto-generated from your GLB assets by the `needle:dts-generator` Vite plugin
4465
- * and written to `src/generated/needle-bindings.d.ts` on every dev-server start and GLB change.
4617
+ * Access your scene's full hierarchy, objects, and components directly by name with full autocomplete.
4618
+ * Types are generated automatically from your GLB files when the dev server starts.
4619
+ *
4620
+ * You can store references to objects or components for later use.
4621
+ * Note that the scene hierarchy can change at runtime (e.g. when objects are added, removed, or re-parented),
4622
+ * in which case stored references may become stale.
4466
4623
  *
4467
- * Each property access traverses the live scene graph on demand — no caching, always fresh.
4468
- * This is a convenience shorthand for `getComponent` lookups; the same result can be
4469
- * achieved manually via `scene.getObjectByName(name)` + `getComponent(node, Type)`.
4624
+ * @experimental This API may change in future versions.
4470
4625
  *
4471
4626
  * @example
4472
4627
  * // Toggle auto-rotate on the orbit camera
@@ -4475,12 +4630,6 @@ export declare class Context implements IContext {
4475
4630
  * @example
4476
4631
  * // Change the background color
4477
4632
  * ctx.sceneData.Camera.Camera.backgroundColor = new RGBAColor(1, 0, 0, 1);
4478
- *
4479
- * @example
4480
- * // Equivalent manual approach (without sceneData)
4481
- * const node = ctx.scene.getObjectByName("Camera");
4482
- * const orbit = getComponent(node, OrbitControls);
4483
- * if (orbit) orbit.autoRotate = true;
4484
4633
  */
4485
4634
  get sceneData(): SceneData;
4486
4635
  get mainCamera(): Camera_2;
@@ -4504,19 +4653,21 @@ export declare class Context implements IContext {
4504
4653
  connection: NetworkConnection;
4505
4654
  /** @deprecated AssetDatabase is deprecated */
4506
4655
  assets: AssetDatabase;
4507
- /** All registered lights in the scene, maintained by the Light component */
4508
- readonly lights: Set<ILight>;
4656
+ /** All registered lights in the scene, maintained by the Light component.
4657
+ * @see mainLight for accessing the main directional light in the scene
4658
+ */
4659
+ readonly lights: ILight[];
4509
4660
  /** The brightest registered directional light, or null if none are registered
4510
4661
  * @see lights
4511
4662
  */
4512
4663
  get mainLight(): ILight | null;
4513
4664
  /** @deprecated Use sceneLighting */
4514
- get rendererData(): RendererData;
4665
+ private get rendererData();
4515
4666
  /** Access the scene lighting manager to control lighting settings in the context */
4516
- sceneLighting: RendererData;
4517
- addressables: Addressables;
4518
- lightmaps: ILightDataRegistry;
4519
- players: PlayerViewManager;
4667
+ readonly sceneLighting: RendererData;
4668
+ readonly addressables: Addressables;
4669
+ readonly lightmaps: ILightDataRegistry;
4670
+ readonly players: PlayerViewManager;
4520
4671
  /** Access the LODs manager to control LOD behavior in the context */
4521
4672
  readonly lodsManager: LODsManager;
4522
4673
  /** Access the needle menu to add or remove buttons to the menu element */
@@ -4809,6 +4960,20 @@ export declare type ControlClipModel = {
4809
4960
  updateDirector: boolean;
4810
4961
  };
4811
4962
 
4963
+ /**
4964
+ * Options for a control clip in the timeline builder
4965
+ */
4966
+ export declare type ControlClipOptions = {
4967
+ /** Start time of the clip in seconds. If omitted, placed after the previous clip on this track. */
4968
+ start?: number;
4969
+ /** Duration of the clip in seconds (required) */
4970
+ duration: number;
4971
+ /** Whether to control the activation of the source object (default: true) */
4972
+ controlActivation?: boolean;
4973
+ /** Whether to update a nested PlayableDirector on the source object (default: true) */
4974
+ updateDirector?: boolean;
4975
+ };
4976
+
4812
4977
  /** true when selectstart was ever received.
4813
4978
  * On VisionOS 1.1 we always have select events (as per the spec), so this is always true
4814
4979
  */
@@ -5139,7 +5304,7 @@ export declare function decompressGpuTexture(texture: any, maxTextureSize?: numb
5139
5304
  * return true;
5140
5305
  * });
5141
5306
  * */
5142
- export declare function deepClone(obj: any, predicate?: deepClonePredicate): any;
5307
+ export declare function deepClone(obj: any, predicate?: deepClonePredicate, _visited?: WeakSet<object>): any;
5143
5308
 
5144
5309
  declare type deepClonePredicate = (owner: any, propertyName: string, current: any) => boolean;
5145
5310
 
@@ -5367,7 +5532,7 @@ export declare namespace DeviceUtilities {
5367
5532
  * Controls how the {@link PlayableDirector} behaves when playback reaches the end.
5368
5533
  * @see {@link PlayableDirector.extrapolationMode}
5369
5534
  */
5370
- declare enum DirectorWrapMode {
5535
+ export declare enum DirectorWrapMode {
5371
5536
  /** Hold the last frame when playback reaches the end of the timeline. */
5372
5537
  Hold = 0,
5373
5538
  /** Loop back to the start and continue playing indefinitely. */
@@ -5376,6 +5541,101 @@ declare enum DirectorWrapMode {
5376
5541
  None = 2
5377
5542
  }
5378
5543
 
5544
+ /**
5545
+ * A store for managing disposable resources (event subscriptions, listeners, callbacks)
5546
+ * that should be cleaned up together.
5547
+ *
5548
+ * DisposableStore collects disposables and disposes them all at once when
5549
+ * {@link dispose} is called. After disposal, the store can be reused — new items
5550
+ * can be added and a subsequent {@link dispose} call will clean those up.
5551
+ *
5552
+ * This is the same pattern used internally by VSCode for lifecycle-bound resource management.
5553
+ *
5554
+ * @example Basic usage
5555
+ * ```ts
5556
+ * import { DisposableStore, on } from "@needle-tools/engine";
5557
+ *
5558
+ * const store = new DisposableStore();
5559
+ *
5560
+ * // Register a DOM event listener (typed!)
5561
+ * store.add(on(window, "resize", (ev) => console.log(ev)));
5562
+ *
5563
+ * // Register the return value of EventList.on()
5564
+ * store.add(myEventList.on(data => console.log(data)));
5565
+ *
5566
+ * // Register a raw cleanup function
5567
+ * store.add(() => someSDK.off("event", handler));
5568
+ *
5569
+ * // Later: dispose everything at once
5570
+ * store.dispose();
5571
+ * ```
5572
+ *
5573
+ * @example Use with Needle Engine components
5574
+ * ```ts
5575
+ * import { Behaviour, serializable, EventList, on } from "@needle-tools/engine";
5576
+ *
5577
+ * export class MyComponent extends Behaviour {
5578
+ * @serializable(EventList)
5579
+ * onClick?: EventList;
5580
+ *
5581
+ * onEnable() {
5582
+ * // DOM events — fully typed
5583
+ * this.autoCleanup(on(window, "resize", (ev) => this.onResize(ev)));
5584
+ *
5585
+ * // EventList — .on() returns a function, autoCleanup accepts it
5586
+ * this.autoCleanup(this.onClick?.on(() => console.log("clicked!")));
5587
+ * }
5588
+ * // No onDisable needed — cleaned up automatically!
5589
+ * }
5590
+ * ```
5591
+ *
5592
+ * @category Utilities
5593
+ * @group Lifecycle
5594
+ */
5595
+ export declare class DisposableStore implements IDisposable {
5596
+ private _disposables;
5597
+ /** The number of registered disposables */
5598
+ get size(): number;
5599
+ /**
5600
+ * Register a disposable resource. Accepts:
5601
+ * - An {@link IDisposable} object (has a `dispose()` method) — e.g. from {@link on}
5602
+ * - A cleanup function (e.g. return value of `EventList.on()`)
5603
+ * - `null` or `undefined` (safe no-op for conditional subscriptions)
5604
+ *
5605
+ * When {@link dispose} is called, all registered resources are cleaned up.
5606
+ *
5607
+ * @param disposable The resource to register for disposal
5608
+ *
5609
+ * @example
5610
+ * ```ts
5611
+ * const store = new DisposableStore();
5612
+ *
5613
+ * // IDisposable object from on()
5614
+ * store.add(on(window, "resize", handler));
5615
+ *
5616
+ * // Function returned by EventList.on()
5617
+ * store.add(myEvent.on(handler));
5618
+ *
5619
+ * // Raw cleanup function
5620
+ * store.add(() => connection.close());
5621
+ *
5622
+ * // Conditional — safe with undefined
5623
+ * store.add(this.maybeEvent?.on(handler));
5624
+ * ```
5625
+ */
5626
+ add(disposable: IDisposable | DisposeFn | Function | null | undefined): void;
5627
+ /**
5628
+ * Dispose all registered resources. Each registered disposable is cleaned up,
5629
+ * then the internal list is cleared. The store can be reused after disposal.
5630
+ *
5631
+ * Called automatically by the engine when a component's `onDisable` lifecycle fires.
5632
+ */
5633
+ dispose(): void;
5634
+ }
5635
+
5636
+ /** A function that performs cleanup when called */
5637
+ export declare type DisposeFn = () => void;
5638
+
5379
5639
  /** Recursive disposes all referenced resources by this object. Does not traverse children */
5380
5640
  export declare function disposeObjectResources(obj: object | null | undefined): void;
5381
5641
 
@@ -5483,6 +5743,12 @@ export declare class DragControls extends Component implements IPointerEventHand
5483
5743
  * providing visual feedback about the object's position relative to surfaces below it.
5484
5744
  */
5485
5745
  showGizmo: boolean;
5746
+ /** Invoked once when a drag begins (after the minimum drag distance threshold is met). */
5747
+ dragStarted: EventList;
5748
+ /** Invoked every frame while the object is being dragged. */
5749
+ dragUpdated: EventList;
5750
+ /** Invoked once when the last pointer is released and the drag ends. */
5751
+ dragEnded: EventList;
5486
5752
  /**
5487
5753
  * Returns the object currently being dragged by this DragControls component, if any.
5488
5754
  * @returns The object being dragged or null if no object is currently dragged
@@ -5923,19 +6189,6 @@ export declare class EnvironmentScene extends Scene {
5923
6189
  createAreaLightMaterial(intensity: number): MeshBasicMaterial;
5924
6190
  }
5925
6191
 
5926
- export declare const euler: EulerSerializer;
5927
-
5928
- declare class EulerSerializer extends TypeSerializer {
5929
- constructor();
5930
- onDeserialize(data: any, _context: SerializationContext): Euler | undefined;
5931
- onSerialize(data: any, _context: SerializationContext): {
5932
- x: any;
5933
- y: any;
5934
- z: any;
5935
- order: any;
5936
- };
5937
- }
5938
-
5939
6192
  /**
5940
6193
  * EventList manages a list of callbacks that can be invoked together.
5941
6194
  * Used for Unity-style events that can be configured in the editor (Unity or Blender).
@@ -5982,13 +6235,9 @@ declare class EulerSerializer extends TypeSerializer {
5982
6235
  * @see {@link Button} for UI button events
5983
6236
  */
5984
6237
  export declare class EventList<TArgs extends any = any> implements IEventList {
6238
+ $serializedTypes: Record<string, any>;
5985
6239
  /** checked during instantiate to create a new instance */
5986
6240
  readonly isEventList = true;
5987
- /* Excluded from this release type: __internalOnInstantiate */
5988
- private target?;
5989
- private key?;
5990
- /** set an event target to try invoke the EventTarget dispatchEvent when this EventList is invoked */
5991
- setEventTarget(key: string, target: object): void;
5992
6241
  /** How many callback methods are subscribed to this event */
5993
6242
  get listenerCount(): number;
5994
6243
  /** If the event is currently being invoked */
@@ -6021,13 +6270,41 @@ export declare class EventList<TArgs extends any = any> implements IEventList {
6021
6270
  invoke(...args: Array<TArgs>): boolean;
6022
6271
  /** Add a new event listener to this event
6023
6272
  * @returns a function to remove the event listener
6273
+ * @see {@link removeEventListener} for more details and return value information
6274
+ * @see {@link off} for an alias with better readability when unsubscribing from events
6275
+ * @example
6276
+ * ```ts
6277
+ * const off = myEvent.addEventListener(args => console.log("Clicked!", args));
6278
+ * // later
6279
+ * off();
6280
+ * ```
6024
6281
  */
6025
6282
  addEventListener(callback: (args: TArgs) => void): Function;
6283
+ /**
6284
+ * Alias for addEventListener for better readability when subscribing to events. You can use it like this:
6285
+ * ```ts
6286
+ * myEvent.on(args => console.log("Clicked!", args));
6287
+ * ```
6288
+ * @returns a function to remove the event listener
6289
+ * @see {@link addEventListener} for more details and return value information
6290
+ */
6291
+ on(callback: (args: TArgs) => void): Function;
6026
6292
  /**
6027
6293
  * Remove an event listener from this event.
6028
6294
  * @returns true if the event listener was found and removed, false otherwise
6029
6295
  */
6030
6296
  removeEventListener(fn: Function | null | undefined): boolean;
6297
+ /**
6298
+ * Alias for removeEventListener for better readability when unsubscribing from events. You can use it like this:
6299
+ * ```ts
6300
+ * const off = myEvent.on(args => console.log("Clicked!", args));
6301
+ * // later
6302
+ * off();
6303
+ * ```
6304
+ *
6305
+ * @see {@link removeEventListener} for more details and return value information
6306
+ */
6307
+ off(callback: Function | null | undefined): boolean;
6031
6308
  /**
6032
6309
  * Remove all event listeners from this event. Use with caution! This will remove all listeners!
6033
6310
  */
@@ -6058,6 +6335,7 @@ declare type EventListenerOptions_2 = {
6058
6335
  signal?: AbortSignal;
6059
6336
  };
6060
6337
 
6338
+ /** @deprecated No longer automatically dispatched. Use `eventList.on()` directly instead. */
6061
6339
  export declare class EventListEvent<TArgs extends any> extends Event {
6062
6340
  args?: TArgs;
6063
6341
  }
@@ -6068,7 +6346,7 @@ declare class EventListSerializer extends TypeSerializer {
6068
6346
  onDeserialize(data: EventListData, context: SerializationContext): EventList<any> | undefined | null;
6069
6347
  }
6070
6348
 
6071
- export declare const eventListSerializer: EventListSerializer;
6349
+ export declare let eventListSerializer: EventListSerializer;
6072
6350
 
6073
6351
  /**
6074
6352
  * [EventSystem](https://engine.needle.tools/docs/api/EventSystem) is responsible for managing and dispatching input events to UI components within the scene.
@@ -6511,7 +6789,7 @@ declare type FitParameters = {
6511
6789
  * @see {@link HingeJoint} for rotating connections
6512
6790
  */
6513
6791
  export declare class FixedJoint extends Joint {
6514
- protected createJoint(self: Rigidbody, other: Rigidbody): void;
6792
+ protected createJoint(self: Rigidbody, other: Rigidbody): any;
6515
6793
  }
6516
6794
 
6517
6795
  declare type FocusRect = DOMRect | Element | {
@@ -7762,7 +8040,7 @@ export declare class HingeJoint extends Joint {
7762
8040
  anchor?: Vector3;
7763
8041
  /** Axis of rotation for the hinge (e.g., Vector3(0,1,0) for vertical axis) */
7764
8042
  axis?: Vector3;
7765
- protected createJoint(self: Rigidbody, other: Rigidbody): void;
8043
+ protected createJoint(self: Rigidbody, other: Rigidbody): any;
7766
8044
  }
7767
8045
 
7768
8046
  declare type HitPointObject = Object3D & {
@@ -7985,7 +8263,7 @@ declare const HTMLElementBase: typeof HTMLElement;
7985
8263
 
7986
8264
  export declare type IAnimationComponent = Pick<IComponent, "gameObject"> & {
7987
8265
  isAnimationComponent: boolean;
7988
- addClip?(clip: AnimationClip): any;
8266
+ addClip?(clip: AnimationClip): void;
7989
8267
  };
7990
8268
 
7991
8269
  /* Excluded from this release type: IApplyPrototypeExtension */
@@ -8059,6 +8337,12 @@ export declare interface ICollider extends IComponent {
8059
8337
  * Default: undefined
8060
8338
  */
8061
8339
  filter?: number[];
8340
+ /** The density of the collider used for automatic mass calculation.
8341
+ * When the attached Rigidbody has `autoMass` enabled, the mass is computed as `density × volume`.
8342
+ * Note: Make sure to call updateProperties after having changed this property
8343
+ * Default: undefined (uses physics engine default of 1.0)
8344
+ */
8345
+ density?: number;
8062
8346
  }
8063
8347
 
8064
8348
  export declare type ICollisionContext = {
@@ -8085,7 +8369,6 @@ export declare interface IComponent extends IHasGuid {
8085
8369
  /* Excluded from this release type: __internalEnable */
8086
8370
  /* Excluded from this release type: __internalDisable */
8087
8371
  /* Excluded from this release type: __internalDestroy */
8088
- /* Excluded from this release type: resolveGuids */
8089
8372
  /** experimental, called when the script is registered for the first time, this is called even if the component is not enabled. */
8090
8373
  registering?(): any;
8091
8374
  awake(): any;
@@ -8122,6 +8405,24 @@ export declare interface IConnectionData {
8122
8405
 
8123
8406
  export declare type IContext = Context;
8124
8407
 
8408
+ /**
8409
+ * Interface for objects that hold resources and can be disposed.
8410
+ * Implement this interface on any object that needs deterministic cleanup.
8411
+ *
8412
+ * @example
8413
+ * ```ts
8414
+ * class MyResource implements IDisposable {
8415
+ * dispose() { /* release resources *\/ }
8416
+ * }
8417
+ * ```
8418
+ *
8419
+ * @category Utilities
8420
+ * @group Lifecycle
8421
+ */
8422
+ export declare interface IDisposable {
8423
+ dispose(): void;
8424
+ }
8425
+
8125
8426
  /** Implement to receive callbacks from {@type @needle-tools/editor-sync} package */
8126
8427
  declare interface IEditorModification {
8127
8428
  /**
@@ -8141,7 +8442,6 @@ export declare interface IEffectProvider {
8141
8442
 
8142
8443
  export declare interface IEventList {
8143
8444
  readonly isEventList: true;
8144
- __internalOnInstantiate(map: InstantiateContext): IEventList;
8145
8445
  }
8146
8446
 
8147
8447
  export declare interface IGameObject extends Object3D {
@@ -8434,13 +8734,45 @@ export declare interface INeedleXRSessionEventReceiver extends Pick<IComponent,
8434
8734
  export declare interface INetworkConnection {
8435
8735
  get isConnected(): boolean;
8436
8736
  get isInRoom(): boolean;
8437
- send(key: string, data: IModel | object | boolean | null | string | number, queue: SendQueue): unknown;
8737
+ send(key: string, data?: IModel | object | boolean | string | number, queue?: SendQueue): unknown;
8438
8738
  }
8439
8739
 
8440
8740
  export declare interface INetworkingWebsocketUrlProvider {
8441
8741
  getWebsocketUrl(): string | null;
8442
8742
  }
8443
8743
 
8744
+ /**
8745
+ * @experimental
8746
+ * Interface for a network transport layer used by {@link NetworkConnection}.
8747
+ * The default implementation wraps a websocket via `websocket-ts`.
8748
+ * Custom implementations can be injected into {@link NetworkConnection.connect}
8749
+ * for testing or alternative transports.
8750
+ *
8751
+ * **Lifecycle:** After creating a transport and passing it to `connect()`,
8752
+ * `NetworkConnection` sets the four event callbacks (`onOpen`, `onClose`,
8753
+ * `onError`, `onMessage`) and then calls {@link start}. The transport
8754
+ * should call `onOpen` when the connection is ready.
8755
+ */
8756
+ export declare interface INetworkTransport {
8757
+ /** Start the connection. Called by NetworkConnection after event callbacks are set.
8758
+ * May return a promise if setup is async (e.g. dynamic imports). */
8759
+ start(): void | Promise<void>;
8760
+ /** Send data (string for JSON messages, Uint8Array for binary) */
8761
+ send(data: string | Uint8Array): void;
8762
+ /** Close the transport */
8763
+ close(): void | Promise<void>;
8764
+ /** The URL this transport is connected to, if applicable */
8765
+ readonly url: string | undefined;
8766
+ /** Called when the transport connection opens */
8767
+ onOpen: (() => void) | null;
8768
+ /** Called when the transport connection closes */
8769
+ onClose: (() => void) | null;
8770
+ /** Called when an error occurs */
8771
+ onError: ((err: any) => void) | null;
8772
+ /** Called when a message is received. Data is either a string (JSON) or Blob (binary). */
8773
+ onMessage: ((data: string | Blob) => void) | null;
8774
+ }
8775
+
8444
8776
  export declare class InheritVelocityModule {
8445
8777
  enabled: boolean;
8446
8778
  curve: MinMaxCurve;
@@ -8460,10 +8792,20 @@ export declare class InheritVelocityModule {
8460
8792
  applyCurrent(vel: Vector3 | Vector3_2, t01: number, lerpFactor: number): void;
8461
8793
  }
8462
8794
 
8795
+ /* Excluded from this release type: initAddressableSerializers */
8796
+
8797
+ /** Register all builtin serializers and prototype patches.
8798
+ * Must be called from {@link initEngine} so the registrations survive tree-shaking
8799
+ * when the package declares `sideEffects: false`.
8800
+ */
8801
+ export declare function initBuiltinSerializers(): void;
8802
+
8463
8803
  /** Register the Rapier physics backend. Called from {@link initEngine}
8464
8804
  * to ensure it runs regardless of tree-shaking. */
8465
8805
  export declare function initPhysics(): void;
8466
8806
 
8807
+ /* Excluded from this release type: initVolumeParameterSerializer */
8808
+
8467
8809
  /**
8468
8810
  * Handles all input events including mouse, touch, keyboard, and XR controllers.
8469
8811
  * Access via `this.context.input` from any component.
@@ -8987,7 +9329,7 @@ export declare function instantiate(instance: AssetReference, opts?: IInstantiat
8987
9329
  export declare function instantiate(instance: IGameObject | Object3D, opts?: IInstantiateOptions | null): IGameObject;
8988
9330
 
8989
9331
  /**
8990
- * Provides access to the instantiated object and its clone
9332
+ * Provides access to the instantiated object map (used by EventList etc.)
8991
9333
  */
8992
9334
  export declare type InstantiateContext = Readonly<InstantiateReferenceMap>;
8993
9335
 
@@ -9027,7 +9369,8 @@ export declare class InstantiateOptions implements IInstantiateOptions {
9027
9369
  cloneAssign(other: InstantiateOptions | IInstantiateOptions): void;
9028
9370
  }
9029
9371
 
9030
- declare type InstantiateReferenceMap = Record<string, ObjectCloneReference>;
9372
+ /** Maps uuid/guid { original, clone } for Object3D and Component instances */
9373
+ export declare type InstantiateReferenceMap = Record<string, ObjectCloneReference>;
9031
9374
 
9032
9375
  /**
9033
9376
  * An empty component that can be used to mark an object as interactable.
@@ -9098,8 +9441,10 @@ export declare interface IPhysicsEngine {
9098
9441
  postStep(): any;
9099
9442
  /** Indicates whether the physics engine is currently updating */
9100
9443
  get isUpdating(): boolean;
9101
- /** Clears all cached data (e.g., mesh data when creating scaled mesh colliders) */
9102
- clearCaches(): any;
9444
+ /** Tears down the physics world and frees all resources. The world will be re-created on next use. */
9445
+ dispose(): void;
9446
+ /** @deprecated Use {@link dispose} instead. */
9447
+ clearCaches(): void;
9103
9448
  /** Enables or disables the physics engine */
9104
9449
  enabled: boolean;
9105
9450
  /** Returns the underlying physics world object */
@@ -9329,8 +9674,9 @@ export declare interface IPhysicsEngine {
9329
9674
  * @returns The underlying physics body or null if not found
9330
9675
  */
9331
9676
  getBody(obj: ICollider | IRigidbody): null | any;
9332
- addFixedJoint(body1: IRigidbody, body2: IRigidbody): any;
9333
- addHingeJoint(body1: IRigidbody, body2: IRigidbody, anchor: Vec3, axis: Vec3): any;
9677
+ addFixedJoint(body1: IRigidbody, body2: IRigidbody): Promise<any> | any;
9678
+ addHingeJoint(body1: IRigidbody, body2: IRigidbody, anchor: Vec3, axis: Vec3): Promise<any> | any;
9679
+ removeJoint(joint: any): void;
9334
9680
  /** Enable to render collider shapes */
9335
9681
  debugRenderColliders: boolean;
9336
9682
  /** Enable to visualize raycasts in the scene with gizmos */
@@ -9551,6 +9897,18 @@ export declare function isDestroyed(go: Object3D): boolean;
9551
9897
  /** True when the application runs on a local url */
9552
9898
  export declare function isDevEnvironment(): boolean;
9553
9899
 
9900
+ /**
9901
+ * Type guard to check if an object implements {@link IDisposable}.
9902
+ *
9903
+ * @example
9904
+ * ```ts
9905
+ * if (isDisposable(obj)) {
9906
+ * obj.dispose(); // safe to call
9907
+ * }
9908
+ * ```
9909
+ */
9910
+ export declare function isDisposable(value: unknown): value is IDisposable;
9911
+
9554
9912
  export declare function isDisposed(obj: object): boolean;
9555
9913
 
9556
9914
  export declare interface ISerializable {
@@ -9585,6 +9943,10 @@ export declare function isHotReloadEnabled(): boolean;
9585
9943
  /**@returns true if the element is an needle engine icon element */
9586
9944
  export declare function isIconElement(element: Node): boolean;
9587
9945
 
9946
+ export declare interface ISignalReceiver {
9947
+ readonly isSignalReceiver: true;
9948
+ }
9949
+
9588
9950
  /** @deprecated use {@link DeviceUtilities.isiOS} instead */
9589
9951
  export declare function isiOS(): boolean;
9590
9952
 
@@ -9619,6 +9981,8 @@ export declare function isResourceTrackingEnabled(): boolean;
9619
9981
  /** @deprecated use {@link DeviceUtilities.isSafari} instead */
9620
9982
  export declare function isSafari(): boolean;
9621
9983
 
9984
+ export declare function isTrackModel(obj: unknown): obj is TrackModel;
9985
+
9622
9986
  export declare function isUsingInstancing(instance: Object3D): boolean;
9623
9987
 
9624
9988
  export declare interface ITime {
@@ -9743,7 +10107,9 @@ declare abstract class Joint extends Component {
9743
10107
  connectedBody?: Rigidbody;
9744
10108
  get rigidBody(): Rigidbody | null;
9745
10109
  private _rigidBody;
10110
+ private _jointHandle;
9746
10111
  onEnable(): void;
10112
+ onDisable(): void;
9747
10113
  private create;
9748
10114
  protected abstract createJoint(self: Rigidbody, other: Rigidbody): any;
9749
10115
  }
@@ -9967,19 +10333,6 @@ export declare class Light extends Component implements ILight {
9967
10333
  get shadowResolution(): number;
9968
10334
  set shadowResolution(val: number);
9969
10335
  private _shadowResolution?;
9970
- /**
9971
- * Number of shadow cascade levels (only used when `useCascades` is true)
9972
- */
9973
- cascades: number;
9974
- /**
9975
- * Cascade split mode (only used when `useCascades` is true):
9976
- * - `practical` — balanced (default, recommended)
9977
- * - `logarithmic` — more resolution close up
9978
- * - `uniform` — equal splits
9979
- */
9980
- cascadeMode: "practical" | "logarithmic" | "uniform";
9981
- private _csm?;
9982
- private _csmHelper?;
9983
10336
  /**
9984
10337
  * Whether this light's illumination is entirely baked into lightmaps
9985
10338
  */
@@ -10001,7 +10354,6 @@ export declare class Light extends Component implements ILight {
10001
10354
  awake(): void;
10002
10355
  onEnable(): void;
10003
10356
  onDisable(): void;
10004
- onBeforeRender(): void;
10005
10357
  /**
10006
10358
  * Creates the appropriate three.js light based on the configured light type
10007
10359
  * and applies all settings like shadows, intensity, and color.
@@ -10022,11 +10374,6 @@ export declare class Light extends Component implements ILight {
10022
10374
  * When the rig is scaled, world-space distances change proportionally
10023
10375
  * causing lights to appear brighter or dimmer due to distance falloff. */
10024
10376
  private applyXRScale;
10025
- /**
10026
- * Creates and initializes a CSM instance for this directional light.
10027
- * CSM manages its own cascade DirectionalLights internally.
10028
- */
10029
- private createCSM;
10030
10377
  /**
10031
10378
  * Configures a directional light by adding and positioning its target
10032
10379
  * @param dirLight The directional light to set up
@@ -11024,6 +11371,7 @@ export declare type Model = (GLTF | FBX | OBJ | CustomModel);
11024
11371
 
11025
11372
  declare namespace Models {
11026
11373
  export {
11374
+ isTrackModel,
11027
11375
  TimelineAssetModel,
11028
11376
  TrackType,
11029
11377
  ClipExtrapolation,
@@ -11067,15 +11415,13 @@ export declare type MouseButtonName = "left" | "right" | "middle";
11067
11415
  /* Excluded from this release type: nameofFactory */
11068
11416
 
11069
11417
  /**
11070
- * Global proxy for the primary Needle Engine context.
11071
- * Resolves lazily on property access via `ContextRegistry.Current` —
11072
- * safe to import at module level, including in SSR environments
11073
- * (returns a silent error proxy when no context is active).
11418
+ * Quick access to the current Needle Engine context from anywhere — no need to pass `ctx` around.
11419
+ * Use it in React/Svelte/Vue components, button handlers, or plain JavaScript.
11074
11420
  *
11075
- * Use this outside of Needle component lifecycle (e.g. in Svelte/React/Vue
11076
- * components, button handlers, or vanilla JS) instead of threading `ctx` around.
11421
+ * Safe to import at module level, including in SSR environments.
11422
+ * For pages with multiple `<needle-engine>` elements, use `ctx` directly instead.
11077
11423
  *
11078
- * For multiple `<needle-engine>` elements on the same page, use `ctx` directly.
11424
+ * @experimental This API may change in future releases.
11079
11425
  *
11080
11426
  * @example
11081
11427
  * import { needle } from "@needle-tools/engine";
@@ -11233,11 +11579,17 @@ export declare interface NeedleEngineAttributes {
11233
11579
  'hash': string;
11234
11580
  /** Set to automatically add OrbitControls to the loaded scene. */
11235
11581
  'camera-controls': string;
11236
- /** Override the default draco decoder path location. */
11582
+ /** Override the default Draco decoder/decompressor path. Can be a URL or a local path to a directory containing the Draco decoder files.
11583
+ * @default "https://www.gstatic.com/draco/versioned/decoders/1.5.7/"
11584
+ * @example <needle-engine dracoDecoderPath="./decoders/draco/"></needle-engine>
11585
+ */
11237
11586
  'dracoDecoderPath': string;
11238
- /** Override the default draco library type. */
11587
+ /** Override the default Draco decoder type. */
11239
11588
  'dracoDecoderType': 'wasm' | 'js';
11240
- /** Override the default KTX2 transcoder/decoder path. */
11589
+ /** Override the default KTX2 transcoder/decoder path. Can be a URL or a local path to a directory containing the KTX2 transcoder files.
11590
+ * @default "https://cdn.needle.tools/static/three/0.179.1/basis2/"
11591
+ * @example <needle-engine ktx2DecoderPath="./decoders/ktx2/"></needle-engine>
11592
+ */
11241
11593
  'ktx2DecoderPath': string;
11242
11594
  /** Prevent context from being disposed when element is removed from DOM. */
11243
11595
  'keep-alive': 'true' | 'false';
@@ -12191,8 +12543,7 @@ export declare class NeedleXRSession implements INeedleXRSession {
12191
12543
  get referenceSpace(): XRSpace | null;
12192
12544
  /** @returns the XRFrame `viewerpose` using the xr `referenceSpace` */
12193
12545
  get viewerPose(): XRViewerPose | undefined;
12194
- /** @returns `true` if any image is currently being tracked */
12195
- /** returns true if images are currently being tracked */
12546
+ /** @returns `true` if any image is currently being tracked or emulated */
12196
12547
  get isTrackingImages(): boolean;
12197
12548
  /** The currently active XR rig */
12198
12549
  get rig(): IXRRig | null;
@@ -12238,6 +12589,8 @@ export declare class NeedleXRSession implements INeedleXRSession {
12238
12589
  private readonly _xr_update_scripts;
12239
12590
  /** scripts that are in the scene but inactive (e.g. disabled parent gameObject) */
12240
12591
  private readonly _inactive_scripts;
12592
+ /** tracks scripts that have received onEnterXR — prevents spurious onLeaveXR calls */
12593
+ private readonly _scripts_in_xr;
12241
12594
  private readonly _controllerAdded;
12242
12595
  private readonly _controllerRemoved;
12243
12596
  private readonly _originalCameraWorldPosition?;
@@ -12625,7 +12978,7 @@ export declare class NetworkConnection implements INetworkConnection {
12625
12978
  /** Use to leave a room that you are currently connected to (use `leaveRoom()` to disconnect from the currently active room but you can also specify a room name) */
12626
12979
  leaveRoom(room?: string | null): boolean;
12627
12980
  /** Send a message to the networking backend - it will be broadcasted to all connected users (except yourself) in the same room by default */
12628
- send<K extends NetworkEventKey>(key: K, data?: (K extends keyof NetworkEventMap ? NetworkEventData<K> : WebsocketSendType) | null, queue?: SendQueue): void;
12981
+ send<K extends NetworkEventKey>(key: K, data?: (K extends keyof NetworkEventMap ? NetworkEventData<K> : WebsocketSendType), queue?: SendQueue): void;
12629
12982
  /**
12630
12983
  * Deletes the network state for a specific object on the server.
12631
12984
  * This removes the object's state from the room, preventing it from being sent to newly joining users.
@@ -12647,61 +13000,69 @@ export declare class NetworkConnection implements INetworkConnection {
12647
13000
  private _defaultMessagesBufferArray;
12648
13001
  sendBufferedMessagesNow(): void;
12649
13002
  /** Use to start listening to networking events.
12650
- * To unsubscribe from events use the `{@link stopListen}` method.
13003
+ * Returns an unsubscribe function that removes the listener when called.
13004
+ * The returned function can also be passed to {@link stopListen} or {@link Component.autoCleanup} for automatic lifecycle management.
12651
13005
  *
12652
- * @example Custom event example
13006
+ * @example With autoCleanup (recommended)
12653
13007
  * ```ts
12654
- * // Listen to a custom event sent by the server
12655
- * this.context.connection.beginListen<MyDataType>("my-custom-event", (data) => {
12656
- * console.log("Received custom event:", data);
12657
- * });
13008
+ * export class MyComponent extends Behaviour {
13009
+ * onEnable() {
13010
+ * this.autoCleanup(this.context.connection.beginListen("joined-room", () => {
13011
+ * console.log("I joined a networked room");
13012
+ * }));
13013
+ * }
13014
+ * // Automatically unsubscribed on disable — no manual cleanup needed!
13015
+ * }
12658
13016
  * ```
12659
13017
  *
12660
- * @example Listening to room events
13018
+ * @example Manual unsubscribe
13019
+ * ```ts
13020
+ * const unsub = this.context.connection.beginListen("joined-room", () => { });
13021
+ * // Later:
13022
+ * unsub(); // removes the listener
13023
+ * ```
13024
+ *
13025
+ * @example With stopListen (legacy pattern, still supported)
12661
13026
  * ```ts
12662
- * // Make sure to unsubscribe from events when the component is disabled
12663
13027
  * export class MyComponent extends Behaviour {
12664
13028
  * onEnable() {
12665
- * this.connection.beginListen("joined-room", this.onJoinedRoom)
13029
+ * this.context.connection.beginListen("joined-room", this.onJoinedRoom);
12666
13030
  * }
12667
13031
  * onDisable() {
12668
- * this.connection.stopListen("joined-room", this.onJoinedRoom)
13032
+ * this.context.connection.stopListen("joined-room", this.onJoinedRoom);
12669
13033
  * }
12670
13034
  * onJoinedRoom = () => {
12671
- * console.log("I joined a networked room")
13035
+ * console.log("I joined a networked room");
12672
13036
  * }
12673
13037
  * }
12674
13038
  * ```
12675
13039
  * @link https://engine.needle.tools/docs/networking.html
12676
13040
  *
12677
13041
  */
12678
- beginListen<K extends NetworkEventKey>(key: K, callback: K extends keyof NetworkEventMap ? NetworkEventMap[K] : (...args: any[]) => void): K extends keyof NetworkEventMap ? NetworkEventMap[K] : (...args: any[]) => void;
13042
+ beginListen<K extends NetworkEventKey>(key: K, callback: K extends keyof NetworkEventMap ? NetworkEventMap[K] : (...args: any[]) => void): DisposeFn;
12679
13043
  /**@deprecated please use stopListen instead (2.65.2-pre) */
12680
13044
  stopListening<K extends NetworkEventKey>(key: K, callback: (K extends keyof NetworkEventMap ? NetworkEventMap[K] : (...args: any[]) => void) | null): void;
12681
- /** Use to stop listening to networking events
13045
+ /** Use to stop listening to networking events.
13046
+ * Accepts either the original callback or the unsubscribe function returned by {@link beginListen}.
12682
13047
  * To subscribe to events use the `{@link beginListen}` method.
12683
- * See the example below for typical usage:
12684
13048
  *
12685
- * ### Component Example
13049
+ * @example
12686
13050
  * ```ts
12687
- * // Make sure to unsubscribe from events when the component is disabled
12688
- * export class MyComponent extends Behaviour {
12689
- * onEnable() {
12690
- * this.connection.beginListen("joined-room", this.onJoinedRoom)
12691
- * }
12692
- * onDisable() {
12693
- * this.connection.stopListen("joined-room", this.onJoinedRoom)
12694
- * }
12695
- * onJoinedRoom = () => {
12696
- * console.log("I joined a networked room")
12697
- * }
12698
- * }
13051
+ * // Both patterns work:
13052
+ * this.context.connection.stopListen("joined-room", this.onJoinedRoom); // original callback
13053
+ * this.context.connection.stopListen("joined-room", unsub); // unsubscribe fn from beginListen
12699
13054
  * ```
12700
13055
  */
12701
- stopListen<K extends NetworkEventKey>(key: K, callback: (K extends keyof NetworkEventMap ? NetworkEventMap[K] : (...args: any[]) => void) | null): void;
12702
- /** Use to start listening to networking binary events */
12703
- beginListenBinary(identifier: string, callback: BinaryCallback): BinaryCallback;
12704
- /** Use to stop listening to networking binary events */
13056
+ private static _didLogStopListenHint;
13057
+ stopListen<K extends NetworkEventKey>(key: K, callback: (K extends keyof NetworkEventMap ? NetworkEventMap[K] : (...args: any[]) => void) | Function | null): void;
13058
+ /** Use to start listening to networking binary events.
13059
+ * Returns an unsubscribe function that removes the listener when called.
13060
+ * The returned function can also be passed to {@link stopListenBinary} or {@link Component.autoCleanup}.
13061
+ */
13062
+ beginListenBinary(identifier: string, callback: BinaryCallback): DisposeFn;
13063
+ /** Use to stop listening to networking binary events.
13064
+ * Accepts either the original callback or the unsubscribe function returned by {@link beginListenBinary}.
13065
+ */
12705
13066
  stopListenBinary(identifier: string, callback: any): void;
12706
13067
  private netWebSocketUrlProvider?;
12707
13068
  /** Use to override the networking server backend url.
@@ -12710,16 +13071,19 @@ export declare class NetworkConnection implements INetworkConnection {
12710
13071
  registerProvider(prov: INetworkingWebsocketUrlProvider): void;
12711
13072
  /** Used to connect to the networking server
12712
13073
  * @param url Optional url to connect to. If not provided, it will use the url from the registered `INetworkingWebsocketUrlProvider` or the default backend networking url. If you want to change the url after connecting, you need to disconnect first and then connect again with the new url.
13074
+ * @param transport Optional custom transport to use instead of the default websocket. Useful for testing or alternative transports.
12713
13075
  */
12714
- connect(url?: string): Promise<boolean>;
13076
+ connect(url?: string, transport?: INetworkTransport): Promise<boolean>;
12715
13077
  /** Disconnect from the networking backend + reset internal state */
12716
13078
  disconnect(): void;
13079
+ /** Full teardown: disconnect, clear all listeners, and release all resources.
13080
+ * Called when the owning Context is destroyed. After dispose(), this instance should not be reused. */
13081
+ dispose(): void;
12717
13082
  private _listeners;
12718
13083
  private _listenersBinary;
12719
13084
  private connected;
12720
- private channelId;
12721
13085
  private _connectionId;
12722
- private _ws;
13086
+ private _transport;
12723
13087
  private _waitingForSocket;
12724
13088
  private _isInRoom;
12725
13089
  private _currentRoomName;
@@ -12729,6 +13093,8 @@ export declare class NetworkConnection implements INetworkConnection {
12729
13093
  private _state;
12730
13094
  private _currentDelay;
12731
13095
  private _connectingToWebsocketPromise;
13096
+ /** Wire up a transport's event callbacks and start it */
13097
+ private connectTransport;
12732
13098
  private connectWebsocket;
12733
13099
  private onMessage;
12734
13100
  private handleIncomingBinaryMessage;
@@ -12857,7 +13223,7 @@ export declare interface NetworkEventMap {
12857
13223
  * @see {@link RoomEvents} for room lifecycle events
12858
13224
  * @see {@link isLocalNetwork} for local network detection
12859
13225
  * @link https://engine.needle.tools/docs/how-to-guides/networking/
12860
- * @summary Networking configuration
13226
+ * @summary Configures the websocket server URL for multiplayer networking
12861
13227
  * @category Networking
12862
13228
  * @group Components
12863
13229
  */
@@ -12994,7 +13360,7 @@ export declare type OBJ = {
12994
13360
  scenes: Object3D[];
12995
13361
  };
12996
13362
 
12997
- declare type ObjectCloneReference = {
13363
+ export declare type ObjectCloneReference = {
12998
13364
  readonly original: object;
12999
13365
  readonly clone: object;
13000
13366
  };
@@ -13078,7 +13444,7 @@ declare class ObjectSerializer extends TypeSerializer {
13078
13444
  onDeserialize(data: ObjectData | string | null, context: SerializationContext): Object3D<Object3DEventMap> | Component | null | undefined;
13079
13445
  }
13080
13446
 
13081
- export declare const objectSerializer: ObjectSerializer;
13447
+ export declare let objectSerializer: ObjectSerializer;
13082
13448
 
13083
13449
  declare type ObjectToNodeMap = {
13084
13450
  [uuid: string]: number;
@@ -13201,6 +13567,61 @@ export declare function offXRSessionEnd(fn: (evt: XRSessionEventArgs) => void):
13201
13567
  */
13202
13568
  export declare function offXRSessionStart(fn: (evt: XRSessionEventArgs) => void): void;
13203
13569
 
13570
+ /**
13571
+ * @experimental
13572
+ * Subscribe to a DOM event on any {@link EventTarget} (window, document, HTML elements, etc.)
13573
+ * and return an {@link IDisposable} that removes the listener when disposed.
13574
+ *
13575
+ * Provides full TypeScript event type inference — the callback parameter
13576
+ * is automatically typed based on the event name (e.g. `"resize"` → `UIEvent`,
13577
+ * `"click"` → `MouseEvent`).
13578
+ *
13579
+ * Use with {@link DisposableStore.add} for automatic lifecycle cleanup in components.
13580
+ *
13581
+ * @param target The EventTarget to listen on (window, document, an element, etc.)
13582
+ * @param type The event name (e.g. `"resize"`, `"click"`, `"keydown"`)
13583
+ * @param listener The event handler callback
13584
+ * @param options Optional addEventListener options (passive, capture, once, signal)
13585
+ * @returns An {@link IDisposable} that removes the event listener when disposed
13586
+ *
13587
+ * @example Standalone usage
13588
+ * ```ts
13589
+ * import { on } from "@needle-tools/engine";
13590
+ *
13591
+ * const sub = on(window, "resize", (ev) => {
13592
+ * // ev is typed as UIEvent
13593
+ * console.log("resized", ev.target);
13594
+ * });
13595
+ *
13596
+ * // Later: clean up
13597
+ * sub.dispose();
13598
+ * ```
13599
+ *
13600
+ * @example With autoCleanup in a component
13601
+ * ```ts
13602
+ * import { Behaviour, on } from "@needle-tools/engine";
13603
+ *
13604
+ * export class MyComponent extends Behaviour {
13605
+ * onEnable() {
13606
+ * this.autoCleanup(on(window, "resize", (ev) => { /* UIEvent *\/ }));
13607
+ * this.autoCleanup(on(document, "keydown", (ev) => { /* KeyboardEvent *\/ }));
13608
+ * this.autoCleanup(on(this.context.domElement, "click", (ev) => { /* MouseEvent *\/ }));
13609
+ * }
13610
+ * // All listeners removed automatically on disable!
13611
+ * }
13612
+ * ```
13613
+ *
13614
+ * @category Utilities
13615
+ * @group Lifecycle
13616
+ */
13617
+ export declare function on<K extends keyof WindowEventMap>(target: Window, type: K, listener: (ev: WindowEventMap[K]) => void, options?: boolean | AddEventListenerOptions): IDisposable;
13618
+
13619
+ export declare function on<K extends keyof DocumentEventMap>(target: Document, type: K, listener: (ev: DocumentEventMap[K]) => void, options?: boolean | AddEventListenerOptions): IDisposable;
13620
+
13621
+ export declare function on<K extends keyof HTMLElementEventMap>(target: HTMLElement, type: K, listener: (ev: HTMLElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): IDisposable;
13622
+
13623
+ export declare function on(target: EventTarget, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): IDisposable;
13624
+
13204
13625
  /**
13205
13626
  * Register a callback in the engine onAfterRender event
13206
13627
  * This is called every frame after the main camera has rendered
@@ -14674,13 +15095,15 @@ export declare class OrbitControls extends Component implements ICameraControlle
14674
15095
  * The timeline asset containing tracks, clips, and markers that this director will play.
14675
15096
  * Assign a timeline asset exported from Unity or Blender to enable playback.
14676
15097
  */
14677
- playableAsset?: Models.TimelineAssetModel;
15098
+ get playableAsset(): Models.TimelineAssetModel | undefined;
15099
+ set playableAsset(value: Models.TimelineAssetModel | undefined);
15100
+ private _playableAsset?;
14678
15101
  /**
14679
15102
  * When true, the timeline starts playing automatically when the component awakens.
14680
15103
  * Set to false to control playback manually via `play()`.
14681
15104
  * @default false
14682
15105
  */
14683
- playOnAwake?: boolean;
15106
+ playOnAwake: boolean;
14684
15107
  /**
14685
15108
  * Determines how the timeline behaves when it reaches the end of its duration.
14686
15109
  * @default DirectorWrapMode.Loop
@@ -14775,6 +15198,14 @@ export declare class OrbitControls extends Component implements ICameraControlle
14775
15198
  * @returns all marker tracks of the timeline
14776
15199
  */
14777
15200
  get markerTracks(): Tracks.MarkerTrackHandler[];
15201
+ /**
15202
+ * @returns all activation tracks of the timeline
15203
+ */
15204
+ get activationTracks(): Tracks.ActivationTrackHandler[];
15205
+ /**
15206
+ * @returns all tracks of the timeline
15207
+ */
15208
+ get tracks(): ReadonlyArray<Tracks.TrackHandler>;
14778
15209
  /**
14779
15210
  * Iterates over all markers of the timeline, optionally filtering by type
14780
15211
  *
@@ -14788,13 +15219,13 @@ export declare class OrbitControls extends Component implements ICameraControlle
14788
15219
  *
14789
15220
  */
14790
15221
  foreachMarker<T extends Record<string, any>>(type?: string | null): Generator<(T & Models.MarkerModel)>;
14791
- private _guidsMap?;
14792
- /* Excluded from this release type: resolveGuids */
15222
+ private _needsGraphRebuild;
14793
15223
  private _isPlaying;
14794
15224
  private _internalUpdateRoutine;
14795
15225
  private _isPaused;
14796
15226
  /** internal, true during the time stop() is being processed */
14797
15227
  private _isStopping;
15228
+ /* Excluded from this release type: _isUserEvaluation */
14798
15229
  private _time;
14799
15230
  private _duration;
14800
15231
  private _weight;
@@ -14803,6 +15234,7 @@ export declare class OrbitControls extends Component implements ICameraControlle
14803
15234
  private readonly _signalTracks;
14804
15235
  private readonly _markerTracks;
14805
15236
  private readonly _controlTracks;
15237
+ private readonly _activationTracks;
14806
15238
  private readonly _customTracks;
14807
15239
  private readonly _tracksArray;
14808
15240
  private get _allTracks();
@@ -15981,6 +16413,10 @@ export declare class OrbitControls extends Component implements ICameraControlle
15981
16413
  private _gravity;
15982
16414
  get gravity(): Vec3;
15983
16415
  set gravity(value: Vec3);
16416
+ /** Tears down the physics world and frees all WASM resources.
16417
+ * After calling this, the world will be re-created on next use. */
16418
+ dispose(): void;
16419
+ /** @deprecated Use {@link dispose} instead. */
15984
16420
  clearCaches(): void;
15985
16421
  addBoxCollider(collider: ICollider, size: Vector3): Promise<void>;
15986
16422
  addSphereCollider(collider: ICollider): Promise<void>;
@@ -16027,7 +16463,8 @@ export declare class OrbitControls extends Component implements ICameraControlle
16027
16463
  private getRigidbodyRelativeMatrix;
16028
16464
  private static centerConnectionPos;
16029
16465
  private static centerConnectionRot;
16030
- addFixedJoint(body1: IRigidbody, body2: IRigidbody): void;
16466
+ private _jointTempMatrix;
16467
+ addFixedJoint(body1: IRigidbody, body2: IRigidbody): Promise<ImpulseJoint | null>;
16031
16468
  /** The joint prevents any relative movement between two rigid-bodies, except for relative rotations along one axis. This is typically used to simulate wheels, fans, etc. They are characterized by one local anchor as well as one local axis on each rigid-body. */
16032
16469
  addHingeJoint(body1: IRigidbody, body2: IRigidbody, anchor: {
16033
16470
  x: number;
@@ -16037,8 +16474,11 @@ export declare class OrbitControls extends Component implements ICameraControlle
16037
16474
  x: number;
16038
16475
  y: number;
16039
16476
  z: number;
16040
- }): void;
16477
+ }): Promise<ImpulseJoint | null>;
16478
+ removeJoint(joint: ImpulseJoint): void;
16479
+ /** Compute the relative transform from body1's local space to body2's local space (W2⁻¹ * W1), ignoring scale. */
16041
16480
  private calculateJointRelativeMatrices;
16481
+ private normalizeMatrixColumns;
16042
16482
  }
16043
16483
 
16044
16484
  /**
@@ -16841,10 +17281,17 @@ export declare class OrbitControls extends Component implements ICameraControlle
16841
17281
  */
16842
17282
  export declare class Rigidbody extends Component implements IRigidbody {
16843
17283
  get isRigidbody(): boolean;
16844
- /** When true the mass will be automatically calculated by the attached colliders */
17284
+ /** When true the mass is automatically computed from the attached colliders using `mass = density × volume`.
17285
+ * Each collider's {@link Collider.density} determines how heavy it contributes to the total mass.
17286
+ * Disable to set mass explicitly via the `mass` property.
17287
+ */
16845
17288
  autoMass: boolean;
16846
- /** By default the mass will be automatically calculated (see `autoMass`) by the physics engine using the collider sizes
16847
- * To set the mass manually you can either set the `mass` value or set `autoMass` to `false`
17289
+ /** The mass of the rigidbody in kg (when `autoMass` is disabled).
17290
+ * When `autoMass` is enabled, reading this returns the computed mass from `density × volume` of all attached colliders.
17291
+ * Setting this property automatically disables `autoMass`.
17292
+ *
17293
+ * **Prefer using {@link Collider.density}** with `autoMass` enabled instead — density scales
17294
+ * naturally with collider size, while explicit mass stays fixed regardless of shape changes.
16848
17295
  */
16849
17296
  set mass(value: number);
16850
17297
  get mass(): number;
@@ -16927,7 +17374,8 @@ export declare class OrbitControls extends Component implements ICameraControlle
16927
17374
  onEnable(): void;
16928
17375
  onDisable(): void;
16929
17376
  onDestroy(): void;
16930
- onValidate(): void;
17377
+ onValidate(property?: string): void;
17378
+ private static _didWarnAutoMass;
16931
17379
  beforePhysics(): Generator<undefined, void, unknown>;
16932
17380
  /** Teleport the rigidbody to a new position in the world.
16933
17381
  * Will reset forces before setting the object world position
@@ -18147,10 +18595,17 @@ export declare class OrbitControls extends Component implements ICameraControlle
18147
18595
 
18148
18596
  export declare function sendDestroyed(guid: string, con: INetworkConnection, opts?: SyncDestroyOptions): void;
18149
18597
 
18598
+ /** Controls when a network message is actually sent to the server.
18599
+ * @see {@link NetworkConnection.send}
18600
+ */
18150
18601
  export declare enum SendQueue {
18602
+ /** Hold the message until the transport connection opens, then send it. Use for messages that must arrive as soon as the socket is ready (e.g. join-room). */
18151
18603
  OnConnection = 0,
18604
+ /** Hold the message until the client has joined a room, then send it. Use for messages that require room context. */
18152
18605
  OnRoomJoin = 1,
18606
+ /** Buffer the message and send it on the next `sendBufferedMessagesNow()` call (typically once per frame). This is the default for `send()`. */
18153
18607
  Queued = 2,
18608
+ /** Send the message to the server immediately without buffering. */
18154
18609
  Immediate = 3
18155
18610
  }
18156
18611
 
@@ -18583,6 +19038,16 @@ export declare class OrbitControls extends Component implements ICameraControlle
18583
19038
  asset: string;
18584
19039
  }
18585
19040
 
19041
+ /**
19042
+ * Options for a signal marker in the timeline builder
19043
+ */
19044
+ export declare type SignalMarkerOptions = {
19045
+ /** Whether the signal should fire if the playback starts past its time (default: false) */
19046
+ retroActive?: boolean;
19047
+ /** Whether the signal should only fire once (default: false) */
19048
+ emitOnce?: boolean;
19049
+ };
19050
+
18586
19051
  /** SignalReceiver is a component that listens for signals and invokes a reaction when a signal is received.
18587
19052
  * Signals can be added to a signal track on a {@link PlayableDirector}
18588
19053
  *
@@ -18590,7 +19055,8 @@ export declare class OrbitControls extends Component implements ICameraControlle
18590
19055
  * @category Animation and Sequencing
18591
19056
  * @group Components
18592
19057
  */
18593
- export declare class SignalReceiver extends Component {
19058
+ export declare class SignalReceiver extends Component implements ISignalReceiver {
19059
+ readonly isSignalReceiver = true;
18594
19060
  private static receivers;
18595
19061
  static invoke(guid: string): void;
18596
19062
  events?: SignalReceiverEvent[];
@@ -18613,6 +19079,9 @@ export declare class OrbitControls extends Component implements ICameraControlle
18613
19079
  models: Models.SignalMarkerModel[];
18614
19080
  didTrigger: boolean[];
18615
19081
  receivers: Array<SignalReceiver | null>;
19082
+ private _lastTime;
19083
+ onEnable(): void;
19084
+ onMuteChanged(): void;
18616
19085
  evaluate(time: number): void;
18617
19086
  }
18618
19087
 
@@ -19112,10 +19581,6 @@ export declare class OrbitControls extends Component implements ICameraControlle
19112
19581
  * Removes scale change monitoring when the collider is disabled.
19113
19582
  */
19114
19583
  onDisable(): void;
19115
- /**
19116
- * Updates collider properties when validated in the editor or inspector.
19117
- */
19118
- onValidate(): void;
19119
19584
  }
19120
19585
 
19121
19586
  export declare class SphereIntersection implements Intersection {
@@ -20435,6 +20900,7 @@ export declare class OrbitControls extends Component implements ICameraControlle
20435
20900
  set font(val: string | null);
20436
20901
  get font(): string | null;
20437
20902
  private _font;
20903
+ private _assignedAtRuntime;
20438
20904
  /**
20439
20905
  * 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>`
20440
20906
  * @default false
@@ -20699,6 +21165,166 @@ export declare class OrbitControls extends Component implements ICameraControlle
20699
21165
  tracks: TrackModel[];
20700
21166
  };
20701
21167
 
21168
+ /**
21169
+ * A fluent builder for creating timeline assets ({@link TimelineAssetModel}) from code.
21170
+ *
21171
+ * Use {@link TimelineBuilder.create} to start building a timeline.
21172
+ *
21173
+ * @example Using build() for timelines without signal callbacks
21174
+ * ```ts
21175
+ * const timeline = TimelineBuilder.create("MySequence")
21176
+ * .animationTrack("Character", animator)
21177
+ * .clip(walkClip, { duration: 2, easeIn: 0.3 })
21178
+ * .clip(runClip, { duration: 3, easeIn: 0.5, easeOut: 0.5 })
21179
+ * .activationTrack("FX", particleObject)
21180
+ * .clip({ start: 1, duration: 2 })
21181
+ * .audioTrack("Music", audioSource)
21182
+ * .clip("music.mp3", { start: 0, duration: 5, volume: 0.8 })
21183
+ * .build();
21184
+ *
21185
+ * director.playableAsset = timeline;
21186
+ * director.play();
21187
+ * ```
21188
+ *
21189
+ * @example Using install() with signal callbacks
21190
+ * ```ts
21191
+ * TimelineBuilder.create("WithSignals")
21192
+ * .animationTrack("Character", animator)
21193
+ * .clip(walkClip, { duration: 2 })
21194
+ * .signalTrack("Events")
21195
+ * .signal(1.0, () => console.log("1 second!"))
21196
+ * .signal(2.0, () => spawnParticles())
21197
+ * .install(director);
21198
+ *
21199
+ * director.play();
21200
+ * ```
21201
+ *
21202
+ * @category Animation and Sequencing
21203
+ * @group Utilities
21204
+ */
21205
+ export declare class TimelineBuilder {
21206
+ private _name;
21207
+ private _tracks;
21208
+ private _currentTrack;
21209
+ private _pendingSignals;
21210
+ private _idProvider;
21211
+ private constructor();
21212
+ /**
21213
+ * Creates a new TimelineBuilder instance.
21214
+ * @param name - Name for the timeline asset
21215
+ * @param seed - Optional numeric seed for deterministic guid generation. Defaults to `Date.now()`.
21216
+ */
21217
+ static create(name?: string, seed?: number): TimelineBuilder;
21218
+ /**
21219
+ * Adds an animation track. Subsequent `.clip()` calls add animation clips to this track.
21220
+ * @param name - Display name for the track
21221
+ * @param binding - The Animator or Object3D to animate
21222
+ */
21223
+ animationTrack(name: string, binding?: Animator | Object3D | null): this;
21224
+ /**
21225
+ * Adds an audio track. Subsequent `.clip()` calls add audio clips to this track.
21226
+ * @param name - Display name for the track
21227
+ * @param binding - The AudioSource to play audio on (optional)
21228
+ * @param volume - Track volume multiplier (default: 1)
21229
+ */
21230
+ audioTrack(name: string, binding?: AudioSource | Object3D | null, volume?: number): this;
21231
+ /**
21232
+ * Adds an activation track. Subsequent `.clip()` calls define when the bound object is active.
21233
+ * @param name - Display name for the track
21234
+ * @param binding - The Object3D to show/hide
21235
+ */
21236
+ activationTrack(name: string, binding?: Object3D | null): this;
21237
+ /**
21238
+ * Adds a control track. Subsequent `.clip()` calls control nested timelines or objects.
21239
+ * @param name - Display name for the track
21240
+ */
21241
+ controlTrack(name: string): this;
21242
+ /**
21243
+ * Adds a signal track. Use `.signal()` or `.marker()` to add signal markers.
21244
+ * @param name - Display name for the track
21245
+ * @param binding - The SignalReceiver component (optional — if using `.signal()` with callbacks, one is created automatically by {@link install})
21246
+ */
21247
+ signalTrack(name: string, binding?: SignalReceiver | Object3D | null): this;
21248
+ /**
21249
+ * Adds a marker track. Use `.marker()` to add markers.
21250
+ * @param name - Display name for the track
21251
+ */
21252
+ markerTrack(name: string): this;
21253
+ /**
21254
+ * Adds a clip to the current track. The clip type must match the track type.
21255
+ *
21256
+ * - On an **animation track**: pass an `AnimationClip` and optional {@link AnimationClipOptions}
21257
+ * - On an **audio track**: pass a clip URL (string) and {@link AudioClipOptions}
21258
+ * - On an **activation track**: pass {@link ActivationClipOptions}
21259
+ * - On a **control track**: pass an Object3D and {@link ControlClipOptions}
21260
+ */
21261
+ clip(asset: AnimationClip, options?: AnimationClipOptions): this;
21262
+ clip(url: string, options: AudioClipOptions): this;
21263
+ clip(options: ActivationClipOptions): this;
21264
+ clip(sourceObject: Object3D, options: ControlClipOptions): this;
21265
+ /**
21266
+ * Adds a signal marker to the current signal or marker track.
21267
+ * @param time - Time in seconds when the signal fires
21268
+ * @param asset - The signal asset identifier (guid string)
21269
+ * @param options - Optional marker configuration
21270
+ */
21271
+ marker(time: number, asset: string, options?: SignalMarkerOptions): this;
21272
+ /**
21273
+ * Adds a signal with a callback to the current signal track.
21274
+ * This is a convenience method that automatically generates a signal asset guid,
21275
+ * adds the marker, and registers the callback so that {@link install} can wire up
21276
+ * the `SignalReceiver` on the director's GameObject.
21277
+ *
21278
+ * @param time - Time in seconds when the signal fires
21279
+ * @param callback - The function to invoke when the signal fires
21280
+ * @param options - Optional marker configuration
21281
+ *
21282
+ * @example
21283
+ * ```ts
21284
+ * const timeline = TimelineBuilder.create("Sequence")
21285
+ * .signalTrack("Events")
21286
+ * .signal(1.0, () => console.log("1 second reached!"))
21287
+ * .signal(3.5, () => console.log("halfway!"), { emitOnce: true })
21288
+ * .install(director);
21289
+ * ```
21290
+ */
21291
+ signal(time: number, callback: Function, options?: SignalMarkerOptions): this;
21292
+ /**
21293
+ * Mutes the current track so it is skipped during playback.
21294
+ */
21295
+ muted(muted?: boolean): this;
21296
+ /**
21297
+ * Builds and returns the {@link TimelineAssetModel}.
21298
+ * Assign the result to `PlayableDirector.playableAsset` to play it.
21299
+ *
21300
+ * If you used `.signal()` with callbacks, use {@link install} instead — it calls `build()`
21301
+ * internally and also wires up the SignalReceiver on the director's GameObject.
21302
+ */
21303
+ build(): TimelineAssetModel;
21304
+ /**
21305
+ * Builds the timeline asset, assigns it to the director, and wires up any
21306
+ * `.signal()` callbacks by creating/configuring a {@link SignalReceiver} on the
21307
+ * director's GameObject.
21308
+ *
21309
+ * @param director - The PlayableDirector to install the timeline on
21310
+ * @returns The built TimelineAssetModel (also assigned to `director.playableAsset`)
21311
+ *
21312
+ * @example
21313
+ * ```ts
21314
+ * TimelineBuilder.create("MyTimeline")
21315
+ * .animationTrack("Anim", animator)
21316
+ * .clip(walkClip, { duration: 2 })
21317
+ * .signalTrack("Events")
21318
+ * .signal(1.0, () => console.log("signal fired!"))
21319
+ * .install(director);
21320
+ *
21321
+ * director.play();
21322
+ * ```
21323
+ */
21324
+ install(director: PlayableDirector): TimelineAssetModel;
21325
+ private pushTrack;
21326
+ }
21327
+
20702
21328
  declare type TonemappingAttributeOptions = "none" | "linear" | "neutral" | "agx";
20703
21329
 
20704
21330
  /**
@@ -20780,6 +21406,7 @@ export declare class OrbitControls extends Component implements ICameraControlle
20780
21406
  AudioTrackHandler,
20781
21407
  MarkerTrackHandler,
20782
21408
  SignalTrackHandler,
21409
+ ActivationTrackHandler,
20783
21410
  ControlTrackHandler
20784
21411
  }
20785
21412
  }
@@ -22503,7 +23130,7 @@ export declare class OrbitControls extends Component implements ICameraControlle
22503
23130
  private onApplyPose;
22504
23131
  }
22505
23132
 
22506
- declare type WebsocketSendType = IModel | object | boolean | null | string | number;
23133
+ declare type WebsocketSendType = IModel | object | boolean | string | number;
22507
23134
 
22508
23135
  /**
22509
23136
  * Use the [WebXR](https://engine.needle.tools/docs/api/WebXR) component to enable VR and AR on **iOS and Android** in your scene. VisionOS support is also provided via QuickLook USDZ export.
@@ -23546,28 +24173,6 @@ export declare class OrbitControls extends Component implements ICameraControlle
23546
24173
  export { }
23547
24174
 
23548
24175
 
23549
- declare module 'three' {
23550
- interface SkinnedMesh {
23551
- staticGenerator?: StaticGeometryGenerator;
23552
- staticGeometry?: BufferGeometry;
23553
- staticGeometryLastUpdate?: number;
23554
- }
23555
- interface Mesh {
23556
- acceleratedRaycast?: any;
23557
- }
23558
- interface SkinnedMesh {
23559
- /** @deprecated use autoUpdateMeshBvhInterval */
23560
- autoUpdateMeshBVH?: boolean;
23561
- /**
23562
- * Interval in milliseconds to automatically update the mesh BVH. When set to >= 0 the BVH will be updated every x milliseconds.
23563
- * @default undefined (disabled)
23564
- */
23565
- autoUpdateMeshBvhInterval?: number;
23566
- bvhNeedsUpdate?: boolean;
23567
- }
23568
- }
23569
-
23570
-
23571
24176
  declare module 'three' {
23572
24177
  interface Object3D {
23573
24178
  get guid(): string | undefined;
@@ -23713,3 +24318,25 @@ declare module 'three' {
23713
24318
  slerp(end: Vector3, t: number): Vector3;
23714
24319
  }
23715
24320
  }
24321
+
24322
+
24323
+ declare module 'three' {
24324
+ interface SkinnedMesh {
24325
+ staticGenerator?: StaticGeometryGenerator;
24326
+ staticGeometry?: BufferGeometry;
24327
+ staticGeometryLastUpdate?: number;
24328
+ }
24329
+ interface Mesh {
24330
+ acceleratedRaycast?: any;
24331
+ }
24332
+ interface SkinnedMesh {
24333
+ /** @deprecated use autoUpdateMeshBvhInterval */
24334
+ autoUpdateMeshBVH?: boolean;
24335
+ /**
24336
+ * Interval in milliseconds to automatically update the mesh BVH. When set to >= 0 the BVH will be updated every x milliseconds.
24337
+ * @default undefined (disabled)
24338
+ */
24339
+ autoUpdateMeshBvhInterval?: number;
24340
+ bvhNeedsUpdate?: boolean;
24341
+ }
24342
+ }