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

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 (178) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/SKILL.md +4 -1
  3. package/components.needle.json +1 -1
  4. package/dist/needle-engine.bundle-AjVIot3d.min.js +1733 -0
  5. package/dist/{needle-engine.bundle-DF01sSGQ.js → needle-engine.bundle-B7cqsI4c.js} +9149 -8867
  6. package/dist/{needle-engine.bundle-C-ixARur.umd.cjs → needle-engine.bundle-DQCuBTVp.umd.cjs} +154 -154
  7. package/dist/needle-engine.d.ts +754 -199
  8. package/dist/needle-engine.js +583 -584
  9. package/dist/needle-engine.min.js +1 -1
  10. package/dist/needle-engine.umd.cjs +1 -1
  11. package/lib/engine/api.d.ts +3 -0
  12. package/lib/engine/api.js +2 -0
  13. package/lib/engine/api.js.map +1 -1
  14. package/lib/engine/codegen/register_types.js +2 -10
  15. package/lib/engine/codegen/register_types.js.map +1 -1
  16. package/lib/engine/engine_context.js +2 -1
  17. package/lib/engine/engine_context.js.map +1 -1
  18. package/lib/engine/engine_disposable.d.ts +172 -0
  19. package/lib/engine/engine_disposable.js +136 -0
  20. package/lib/engine/engine_disposable.js.map +1 -0
  21. package/lib/engine/engine_gameobject.d.ts +1 -10
  22. package/lib/engine/engine_gameobject.js +20 -118
  23. package/lib/engine/engine_gameobject.js.map +1 -1
  24. package/lib/engine/engine_gltf_builtin_components.js +7 -69
  25. package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
  26. package/lib/engine/engine_instantiate_resolve.d.ts +42 -0
  27. package/lib/engine/engine_instantiate_resolve.js +372 -0
  28. package/lib/engine/engine_instantiate_resolve.js.map +1 -0
  29. package/lib/engine/engine_mainloop_utils.js +2 -2
  30. package/lib/engine/engine_mainloop_utils.js.map +1 -1
  31. package/lib/engine/engine_networking.d.ts +51 -37
  32. package/lib/engine/engine_networking.js +132 -82
  33. package/lib/engine/engine_networking.js.map +1 -1
  34. package/lib/engine/engine_networking.transport.websocket.d.ts +15 -0
  35. package/lib/engine/engine_networking.transport.websocket.js +38 -0
  36. package/lib/engine/engine_networking.transport.websocket.js.map +1 -0
  37. package/lib/engine/engine_networking_instantiate.js +2 -2
  38. package/lib/engine/engine_networking_instantiate.js.map +1 -1
  39. package/lib/engine/engine_networking_types.d.ts +39 -1
  40. package/lib/engine/engine_networking_types.js +7 -0
  41. package/lib/engine/engine_networking_types.js.map +1 -1
  42. package/lib/engine/engine_physics_rapier.d.ts +11 -3
  43. package/lib/engine/engine_physics_rapier.js +88 -25
  44. package/lib/engine/engine_physics_rapier.js.map +1 -1
  45. package/lib/engine/engine_serialization_builtin_serializer.js +1 -5
  46. package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
  47. package/lib/engine/engine_serialization_core.d.ts +1 -0
  48. package/lib/engine/engine_serialization_core.js +7 -0
  49. package/lib/engine/engine_serialization_core.js.map +1 -1
  50. package/lib/engine/engine_types.d.ts +19 -11
  51. package/lib/engine/engine_types.js +1 -1
  52. package/lib/engine/engine_types.js.map +1 -1
  53. package/lib/engine/engine_util_decorator.js +7 -2
  54. package/lib/engine/engine_util_decorator.js.map +1 -1
  55. package/lib/engine/engine_utils.d.ts +1 -1
  56. package/lib/engine/engine_utils.js +19 -5
  57. package/lib/engine/engine_utils.js.map +1 -1
  58. package/lib/engine-components/Animator.d.ts +6 -0
  59. package/lib/engine-components/Animator.js +17 -12
  60. package/lib/engine-components/Animator.js.map +1 -1
  61. package/lib/engine-components/AnimatorController.builder.d.ts +113 -0
  62. package/lib/engine-components/AnimatorController.builder.js +195 -0
  63. package/lib/engine-components/AnimatorController.builder.js.map +1 -0
  64. package/lib/engine-components/AnimatorController.d.ts +2 -119
  65. package/lib/engine-components/AnimatorController.js +31 -232
  66. package/lib/engine-components/AnimatorController.js.map +1 -1
  67. package/lib/engine-components/Collider.d.ts +18 -9
  68. package/lib/engine-components/Collider.js +61 -14
  69. package/lib/engine-components/Collider.js.map +1 -1
  70. package/lib/engine-components/Component.d.ts +72 -9
  71. package/lib/engine-components/Component.js +114 -10
  72. package/lib/engine-components/Component.js.map +1 -1
  73. package/lib/engine-components/DragControls.js +0 -7
  74. package/lib/engine-components/DragControls.js.map +1 -1
  75. package/lib/engine-components/EventList.d.ts +31 -9
  76. package/lib/engine-components/EventList.js +37 -76
  77. package/lib/engine-components/EventList.js.map +1 -1
  78. package/lib/engine-components/Joints.d.ts +4 -2
  79. package/lib/engine-components/Joints.js +19 -3
  80. package/lib/engine-components/Joints.js.map +1 -1
  81. package/lib/engine-components/Light.js +9 -1
  82. package/lib/engine-components/Light.js.map +1 -1
  83. package/lib/engine-components/RigidBody.d.ts +12 -4
  84. package/lib/engine-components/RigidBody.js +18 -4
  85. package/lib/engine-components/RigidBody.js.map +1 -1
  86. package/lib/engine-components/api.d.ts +1 -1
  87. package/lib/engine-components/api.js +1 -1
  88. package/lib/engine-components/api.js.map +1 -1
  89. package/lib/engine-components/codegen/components.d.ts +3 -9
  90. package/lib/engine-components/codegen/components.js +3 -9
  91. package/lib/engine-components/codegen/components.js.map +1 -1
  92. package/lib/engine-components/timeline/PlayableDirector.d.ts +16 -6
  93. package/lib/engine-components/timeline/PlayableDirector.js +70 -62
  94. package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
  95. package/lib/engine-components/timeline/SignalAsset.d.ts +3 -1
  96. package/lib/engine-components/timeline/SignalAsset.js +1 -0
  97. package/lib/engine-components/timeline/SignalAsset.js.map +1 -1
  98. package/lib/engine-components/timeline/TimelineBuilder.d.ts +247 -0
  99. package/lib/engine-components/timeline/TimelineBuilder.js +400 -0
  100. package/lib/engine-components/timeline/TimelineBuilder.js.map +1 -0
  101. package/lib/engine-components/timeline/TimelineModels.d.ts +2 -1
  102. package/lib/engine-components/timeline/TimelineModels.js +3 -0
  103. package/lib/engine-components/timeline/TimelineModels.js.map +1 -1
  104. package/lib/engine-components/timeline/TimelineTracks.d.ts +23 -0
  105. package/lib/engine-components/timeline/TimelineTracks.js +71 -13
  106. package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
  107. package/lib/engine-components/timeline/index.d.ts +2 -1
  108. package/lib/engine-components/timeline/index.js +2 -0
  109. package/lib/engine-components/timeline/index.js.map +1 -1
  110. package/package.json +2 -83
  111. package/plugins/common/license.js +5 -2
  112. package/plugins/common/worker.js +9 -4
  113. package/plugins/vite/dependencies.js +1 -11
  114. package/plugins/vite/dependency-watcher.js +2 -2
  115. package/plugins/vite/editor-connection.js +3 -3
  116. package/plugins/vite/reload.js +1 -1
  117. package/plugins/vite/server.js +2 -1
  118. package/src/engine/api.ts +4 -0
  119. package/src/engine/codegen/register_types.ts +2 -10
  120. package/src/engine/engine_context.ts +2 -1
  121. package/src/engine/engine_disposable.ts +214 -0
  122. package/src/engine/engine_gameobject.ts +52 -157
  123. package/src/engine/engine_gltf_builtin_components.ts +7 -76
  124. package/src/engine/engine_instantiate_resolve.ts +407 -0
  125. package/src/engine/engine_mainloop_utils.ts +2 -2
  126. package/src/engine/engine_networking.transport.websocket.ts +45 -0
  127. package/src/engine/engine_networking.ts +161 -137
  128. package/src/engine/engine_networking_instantiate.ts +2 -2
  129. package/src/engine/engine_networking_types.ts +41 -1
  130. package/src/engine/engine_physics_rapier.ts +82 -27
  131. package/src/engine/engine_serialization_builtin_serializer.ts +1 -6
  132. package/src/engine/engine_serialization_core.ts +9 -0
  133. package/src/engine/engine_types.ts +24 -15
  134. package/src/engine/engine_util_decorator.ts +7 -2
  135. package/src/engine/engine_utils.ts +16 -5
  136. package/src/engine-components/Animator.ts +18 -11
  137. package/src/engine-components/AnimatorController.builder.ts +261 -0
  138. package/src/engine-components/AnimatorController.ts +19 -291
  139. package/src/engine-components/Collider.ts +66 -18
  140. package/src/engine-components/Component.ts +118 -20
  141. package/src/engine-components/DragControls.ts +0 -9
  142. package/src/engine-components/EventList.ts +45 -83
  143. package/src/engine-components/Joints.ts +20 -4
  144. package/src/engine-components/Light.ts +10 -2
  145. package/src/engine-components/RigidBody.ts +18 -4
  146. package/src/engine-components/api.ts +1 -1
  147. package/src/engine-components/codegen/components.ts +3 -9
  148. package/src/engine-components/timeline/PlayableDirector.ts +67 -65
  149. package/src/engine-components/timeline/SignalAsset.ts +4 -1
  150. package/src/engine-components/timeline/TimelineBuilder.ts +564 -0
  151. package/src/engine-components/timeline/TimelineModels.ts +5 -1
  152. package/src/engine-components/timeline/TimelineTracks.ts +74 -13
  153. package/src/engine-components/timeline/index.ts +2 -1
  154. package/dist/needle-engine.bundle-CHmXdnE1.min.js +0 -1733
  155. package/lib/engine-components/AvatarLoader.d.ts +0 -80
  156. package/lib/engine-components/AvatarLoader.js +0 -232
  157. package/lib/engine-components/AvatarLoader.js.map +0 -1
  158. package/lib/engine-components/avatar/AvatarBlink_Simple.d.ts +0 -11
  159. package/lib/engine-components/avatar/AvatarBlink_Simple.js +0 -77
  160. package/lib/engine-components/avatar/AvatarBlink_Simple.js.map +0 -1
  161. package/lib/engine-components/avatar/AvatarEyeLook_Rotation.d.ts +0 -14
  162. package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js +0 -69
  163. package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js.map +0 -1
  164. package/lib/engine-components/avatar/Avatar_Brain_LookAt.d.ts +0 -29
  165. package/lib/engine-components/avatar/Avatar_Brain_LookAt.js +0 -122
  166. package/lib/engine-components/avatar/Avatar_Brain_LookAt.js.map +0 -1
  167. package/lib/engine-components/avatar/Avatar_MouthShapes.d.ts +0 -15
  168. package/lib/engine-components/avatar/Avatar_MouthShapes.js +0 -80
  169. package/lib/engine-components/avatar/Avatar_MouthShapes.js.map +0 -1
  170. package/lib/engine-components/avatar/Avatar_MustacheShake.d.ts +0 -9
  171. package/lib/engine-components/avatar/Avatar_MustacheShake.js +0 -30
  172. package/lib/engine-components/avatar/Avatar_MustacheShake.js.map +0 -1
  173. package/src/engine-components/AvatarLoader.ts +0 -264
  174. package/src/engine-components/avatar/AvatarBlink_Simple.ts +0 -70
  175. package/src/engine-components/avatar/AvatarEyeLook_Rotation.ts +0 -64
  176. package/src/engine-components/avatar/Avatar_Brain_LookAt.ts +0 -140
  177. package/src/engine-components/avatar/Avatar_MouthShapes.ts +0 -84
  178. 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.
@@ -1555,6 +1601,26 @@ declare type AudioClipModel_2 = Models.ClipModel & {
1555
1601
  _didTriggerPlay: boolean;
1556
1602
  };
1557
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
+
1558
1624
  export declare class AudioExtension implements IUSDExporterExtension {
1559
1625
  static getName(clip: string): string;
1560
1626
  get extensionName(): string;
@@ -1840,6 +1906,20 @@ export declare class AudioSource extends Component {
1840
1906
  /* Excluded from this release type: update */
1841
1907
  }
1842
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
+ */
1843
1923
  export declare class AudioTrackHandler extends TrackHandler {
1844
1924
  models: Array<AudioClipModel_2>;
1845
1925
  listener: AudioListener_3;
@@ -1847,6 +1927,9 @@ export declare class AudioTrackHandler extends TrackHandler {
1847
1927
  audioContextTimeOffset: Array<number>;
1848
1928
  lastTime: number;
1849
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);
1850
1933
  private _audioLoader;
1851
1934
  private getAudioFilePath;
1852
1935
  onAllowAudioChanged(allow: boolean): void;
@@ -1896,69 +1979,6 @@ export declare class Avatar extends Component {
1896
1979
  private loadAvatarObjects;
1897
1980
  }
1898
1981
 
1899
- /* Excluded from this release type: Avatar_Brain_LookAt */
1900
-
1901
- /* Excluded from this release type: Avatar_MouthShapes */
1902
-
1903
- /* Excluded from this release type: Avatar_MustacheShake */
1904
-
1905
- /* Excluded from this release type: Avatar_POI */
1906
-
1907
- /* Excluded from this release type: AvatarBlink_Simple */
1908
-
1909
- /* Excluded from this release type: AvatarEyeLook_Rotation */
1910
-
1911
- /**
1912
- * Handles loading and instantiating avatar models from various sources.
1913
- * Provides functionality to find and extract important parts of an avatar (head, hands).
1914
- *
1915
- * Debug mode can be enabled with the URL parameter `?debugavatar`,
1916
- * which will log detailed information about avatar loading and configuration.
1917
- */
1918
- export declare class AvatarLoader {
1919
- private readonly avatarRegistryUrl;
1920
- /**
1921
- * Retrieves or creates a new avatar instance from an ID or existing Object3D.
1922
- * @param context The application context
1923
- * @param avatarId Either a string ID to load an avatar or an existing Object3D to use as avatar
1924
- * @returns Promise resolving to an AvatarModel if successful, or null if failed
1925
- */
1926
- getOrCreateNewAvatarInstance(context: Context, avatarId: string | Object3D): Promise<AvatarModel | null>;
1927
- /**
1928
- * Loads an avatar model from a file or registry using the provided ID.
1929
- * @param context The engine context
1930
- * @param avatarId The ID of the avatar to load
1931
- * @returns Promise resolving to the loaded avatar's Object3D, or null if failed
1932
- */
1933
- private loadAvatar;
1934
- /**
1935
- * Caches an avatar model for reuse.
1936
- * @param _id The ID to associate with the model
1937
- * @param _model The avatar model to cache
1938
- */
1939
- private cacheModel;
1940
- /**
1941
- * Analyzes an Object3D to find avatar parts (head, hands) based on naming conventions.
1942
- * @param obj The Object3D to search for avatar parts
1943
- * @returns A structured AvatarModel with references to found parts
1944
- */
1945
- private findAvatar;
1946
- /**
1947
- * Recursively searches for an avatar part by name within an Object3D hierarchy.
1948
- * @param obj The Object3D to search within
1949
- * @param searchString Array of strings that should all be present in the object name
1950
- * @returns The found Object3D part or null if not found
1951
- */
1952
- private findAvatarPart;
1953
- /**
1954
- * Handles HTTP response errors from avatar loading operations.
1955
- * @param response The fetch API response to check
1956
- * @returns The response if it was ok
1957
- * @throws Error with status text if response was not ok
1958
- */
1959
- private handleCustomAvatarErrors;
1960
- }
1961
-
1962
1982
  /**
1963
1983
  * Marks a GameObject as being controlled or owned by a player in networked XR sessions.
1964
1984
  * This is used internally by the networking system to identify player-controlled objects.
@@ -2019,35 +2039,6 @@ declare type AvatarMarkerEventArgs = {
2019
2039
  gameObject: Object3D;
2020
2040
  };
2021
2041
 
2022
- /**
2023
- * Represents an avatar model with head and hands references.
2024
- * Used for representing characters in 3D space.
2025
- */
2026
- export declare class AvatarModel {
2027
- /** The root object of the avatar model */
2028
- root: Object3D;
2029
- /** The head object of the avatar model */
2030
- head: Object3D;
2031
- /** The left hand object of the avatar model, if available */
2032
- leftHand: Object3D | null;
2033
- /** The right hand object of the avatar model, if available */
2034
- rigthHand: Object3D | null;
2035
- /**
2036
- * Checks if the avatar model has a valid configuration.
2037
- * An avatar is considered valid if it has a head.
2038
- * @returns Whether the avatar has a valid setup
2039
- */
2040
- get isValid(): boolean;
2041
- /**
2042
- * Creates a new avatar model.
2043
- * @param root The root object of the avatar
2044
- * @param head The head object of the avatar
2045
- * @param leftHand The left hand object of the avatar
2046
- * @param rigthHand The right hand object of the avatar
2047
- */
2048
- constructor(root: Object3D, head: Object3D, leftHand: Object3D | null, rigthHand: Object3D | null);
2049
- }
2050
-
2051
2042
  export declare enum Axes {
2052
2043
  None = 0,
2053
2044
  X = 2,
@@ -2411,7 +2402,6 @@ export declare class BoxCollider extends Collider implements IBoxCollider {
2411
2402
  center: Vector3;
2412
2403
  /* Excluded from this release type: onEnable */
2413
2404
  /* Excluded from this release type: onDisable */
2414
- /* Excluded from this release type: onValidate */
2415
2405
  /**
2416
2406
  * Automatically fits the collider to the geometry of the object.
2417
2407
  * Sets the size and center based on the object's bounding box.
@@ -2685,6 +2675,7 @@ declare class CallHandle extends EventDispatcher<any> {
2685
2675
  * CallInfo represents a single callback method that can be invoked by the {@link EventList}.
2686
2676
  */
2687
2677
  export declare class CallInfo {
2678
+ $serializedTypes: Record<string, any>;
2688
2679
  /**
2689
2680
  * When the CallInfo is enabled it will be invoked when the EventList is invoked
2690
2681
  */
@@ -3607,6 +3598,22 @@ export declare abstract class Collider extends Component implements ICollider {
3607
3598
  * The layers that this collider will interact with. Used for filtering collision detection.
3608
3599
  */
3609
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 */
3610
3617
  /* Excluded from this release type: awake */
3611
3618
  /* Excluded from this release type: start */
3612
3619
  /* Excluded from this release type: onEnable */
@@ -3729,7 +3736,7 @@ export declare function compareAssociation<T extends Material>(obj1: T, obj2: T)
3729
3736
  * **Input event methods:**
3730
3737
  * {@link onPointerDown}, {@link onPointerUp}, {@link onPointerEnter}, {@link onPointerExit} and {@link onPointerMove}.
3731
3738
  *
3732
- * @example
3739
+ * @example Basic component
3733
3740
  * ```typescript
3734
3741
  * import { Behaviour } from "@needle-tools/engine";
3735
3742
  * export class MyComponent extends Behaviour {
@@ -3742,6 +3749,25 @@ export declare function compareAssociation<T extends Material>(obj1: T, obj2: T)
3742
3749
  * }
3743
3750
  * ```
3744
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
+ *
3745
3771
  * @group Components
3746
3772
  */
3747
3773
  declare abstract class Component implements IComponent, EventTarget, Partial<INeedleXRSessionEventReceiver>, Partial<IPointerEventHandler> {
@@ -3792,6 +3818,50 @@ declare abstract class Component implements IComponent, EventTarget, Partial<INe
3792
3818
  * @returns True if the component is enabled and all parent GameObjects are active
3793
3819
  */
3794
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;
3795
3865
  private get __isActive();
3796
3866
  private get __isActiveInHierarchy();
3797
3867
  private set __isActiveInHierarchy(value);
@@ -3810,11 +3880,6 @@ declare abstract class Component implements IComponent, EventTarget, Partial<INe
3810
3880
  * For example, URL to the glTF file this component was loaded from
3811
3881
  */
3812
3882
  sourceId?: SourceIdentifier;
3813
- /**
3814
- * Called when this component needs to remap guids after an instantiate operation.
3815
- * @param guidsMap Mapping from old guids to newly generated guids
3816
- */
3817
- resolveGuids?(guidsMap: GuidsMap): void;
3818
3883
  /**
3819
3884
  * Called once when the component becomes active for the first time.
3820
3885
  * This is the first lifecycle callback to be invoked
@@ -4027,6 +4092,10 @@ declare abstract class Component implements IComponent, EventTarget, Partial<INe
4027
4092
  destroy(): void;
4028
4093
  /* Excluded from this release type: __didAwake */
4029
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;
4030
4099
  /* Excluded from this release type: __didEnable */
4031
4100
  /* Excluded from this release type: __isEnabled */
4032
4101
  /* Excluded from this release type: __destroyed */
@@ -4891,6 +4960,20 @@ export declare type ControlClipModel = {
4891
4960
  updateDirector: boolean;
4892
4961
  };
4893
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
+
4894
4977
  /** true when selectstart was ever received.
4895
4978
  * On VisionOS 1.1 we always have select events (as per the spec), so this is always true
4896
4979
  */
@@ -5221,7 +5304,7 @@ export declare function decompressGpuTexture(texture: any, maxTextureSize?: numb
5221
5304
  * return true;
5222
5305
  * });
5223
5306
  * */
5224
- export declare function deepClone(obj: any, predicate?: deepClonePredicate): any;
5307
+ export declare function deepClone(obj: any, predicate?: deepClonePredicate, _visited?: WeakSet<object>): any;
5225
5308
 
5226
5309
  declare type deepClonePredicate = (owner: any, propertyName: string, current: any) => boolean;
5227
5310
 
@@ -5449,7 +5532,7 @@ export declare namespace DeviceUtilities {
5449
5532
  * Controls how the {@link PlayableDirector} behaves when playback reaches the end.
5450
5533
  * @see {@link PlayableDirector.extrapolationMode}
5451
5534
  */
5452
- declare enum DirectorWrapMode {
5535
+ export declare enum DirectorWrapMode {
5453
5536
  /** Hold the last frame when playback reaches the end of the timeline. */
5454
5537
  Hold = 0,
5455
5538
  /** Loop back to the start and continue playing indefinitely. */
@@ -5458,6 +5541,101 @@ declare enum DirectorWrapMode {
5458
5541
  None = 2
5459
5542
  }
5460
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
+
5461
5639
  /** Recursive disposes all referenced resources by this object. Does not traverse children */
5462
5640
  export declare function disposeObjectResources(obj: object | null | undefined): void;
5463
5641
 
@@ -6057,13 +6235,9 @@ export declare class EnvironmentScene extends Scene {
6057
6235
  * @see {@link Button} for UI button events
6058
6236
  */
6059
6237
  export declare class EventList<TArgs extends any = any> implements IEventList {
6238
+ $serializedTypes: Record<string, any>;
6060
6239
  /** checked during instantiate to create a new instance */
6061
6240
  readonly isEventList = true;
6062
- /* Excluded from this release type: __internalOnInstantiate */
6063
- private target?;
6064
- private key?;
6065
- /** set an event target to try invoke the EventTarget dispatchEvent when this EventList is invoked */
6066
- setEventTarget(key: string, target: object): void;
6067
6241
  /** How many callback methods are subscribed to this event */
6068
6242
  get listenerCount(): number;
6069
6243
  /** If the event is currently being invoked */
@@ -6096,13 +6270,41 @@ export declare class EventList<TArgs extends any = any> implements IEventList {
6096
6270
  invoke(...args: Array<TArgs>): boolean;
6097
6271
  /** Add a new event listener to this event
6098
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
+ * ```
6099
6281
  */
6100
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;
6101
6292
  /**
6102
6293
  * Remove an event listener from this event.
6103
6294
  * @returns true if the event listener was found and removed, false otherwise
6104
6295
  */
6105
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;
6106
6308
  /**
6107
6309
  * Remove all event listeners from this event. Use with caution! This will remove all listeners!
6108
6310
  */
@@ -6133,6 +6335,7 @@ declare type EventListenerOptions_2 = {
6133
6335
  signal?: AbortSignal;
6134
6336
  };
6135
6337
 
6338
+ /** @deprecated No longer automatically dispatched. Use `eventList.on()` directly instead. */
6136
6339
  export declare class EventListEvent<TArgs extends any> extends Event {
6137
6340
  args?: TArgs;
6138
6341
  }
@@ -6586,7 +6789,7 @@ declare type FitParameters = {
6586
6789
  * @see {@link HingeJoint} for rotating connections
6587
6790
  */
6588
6791
  export declare class FixedJoint extends Joint {
6589
- protected createJoint(self: Rigidbody, other: Rigidbody): void;
6792
+ protected createJoint(self: Rigidbody, other: Rigidbody): any;
6590
6793
  }
6591
6794
 
6592
6795
  declare type FocusRect = DOMRect | Element | {
@@ -7837,7 +8040,7 @@ export declare class HingeJoint extends Joint {
7837
8040
  anchor?: Vector3;
7838
8041
  /** Axis of rotation for the hinge (e.g., Vector3(0,1,0) for vertical axis) */
7839
8042
  axis?: Vector3;
7840
- protected createJoint(self: Rigidbody, other: Rigidbody): void;
8043
+ protected createJoint(self: Rigidbody, other: Rigidbody): any;
7841
8044
  }
7842
8045
 
7843
8046
  declare type HitPointObject = Object3D & {
@@ -8060,7 +8263,7 @@ declare const HTMLElementBase: typeof HTMLElement;
8060
8263
 
8061
8264
  export declare type IAnimationComponent = Pick<IComponent, "gameObject"> & {
8062
8265
  isAnimationComponent: boolean;
8063
- addClip?(clip: AnimationClip): any;
8266
+ addClip?(clip: AnimationClip): void;
8064
8267
  };
8065
8268
 
8066
8269
  /* Excluded from this release type: IApplyPrototypeExtension */
@@ -8134,6 +8337,12 @@ export declare interface ICollider extends IComponent {
8134
8337
  * Default: undefined
8135
8338
  */
8136
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;
8137
8346
  }
8138
8347
 
8139
8348
  export declare type ICollisionContext = {
@@ -8160,7 +8369,6 @@ export declare interface IComponent extends IHasGuid {
8160
8369
  /* Excluded from this release type: __internalEnable */
8161
8370
  /* Excluded from this release type: __internalDisable */
8162
8371
  /* Excluded from this release type: __internalDestroy */
8163
- /* Excluded from this release type: resolveGuids */
8164
8372
  /** experimental, called when the script is registered for the first time, this is called even if the component is not enabled. */
8165
8373
  registering?(): any;
8166
8374
  awake(): any;
@@ -8197,6 +8405,24 @@ export declare interface IConnectionData {
8197
8405
 
8198
8406
  export declare type IContext = Context;
8199
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
+
8200
8426
  /** Implement to receive callbacks from {@type @needle-tools/editor-sync} package */
8201
8427
  declare interface IEditorModification {
8202
8428
  /**
@@ -8216,7 +8442,6 @@ export declare interface IEffectProvider {
8216
8442
 
8217
8443
  export declare interface IEventList {
8218
8444
  readonly isEventList: true;
8219
- __internalOnInstantiate(map: InstantiateContext): IEventList;
8220
8445
  }
8221
8446
 
8222
8447
  export declare interface IGameObject extends Object3D {
@@ -8509,13 +8734,45 @@ export declare interface INeedleXRSessionEventReceiver extends Pick<IComponent,
8509
8734
  export declare interface INetworkConnection {
8510
8735
  get isConnected(): boolean;
8511
8736
  get isInRoom(): boolean;
8512
- 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;
8513
8738
  }
8514
8739
 
8515
8740
  export declare interface INetworkingWebsocketUrlProvider {
8516
8741
  getWebsocketUrl(): string | null;
8517
8742
  }
8518
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
+
8519
8776
  export declare class InheritVelocityModule {
8520
8777
  enabled: boolean;
8521
8778
  curve: MinMaxCurve;
@@ -9072,7 +9329,7 @@ export declare function instantiate(instance: AssetReference, opts?: IInstantiat
9072
9329
  export declare function instantiate(instance: IGameObject | Object3D, opts?: IInstantiateOptions | null): IGameObject;
9073
9330
 
9074
9331
  /**
9075
- * Provides access to the instantiated object and its clone
9332
+ * Provides access to the instantiated object map (used by EventList etc.)
9076
9333
  */
9077
9334
  export declare type InstantiateContext = Readonly<InstantiateReferenceMap>;
9078
9335
 
@@ -9112,7 +9369,8 @@ export declare class InstantiateOptions implements IInstantiateOptions {
9112
9369
  cloneAssign(other: InstantiateOptions | IInstantiateOptions): void;
9113
9370
  }
9114
9371
 
9115
- 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>;
9116
9374
 
9117
9375
  /**
9118
9376
  * An empty component that can be used to mark an object as interactable.
@@ -9183,8 +9441,10 @@ export declare interface IPhysicsEngine {
9183
9441
  postStep(): any;
9184
9442
  /** Indicates whether the physics engine is currently updating */
9185
9443
  get isUpdating(): boolean;
9186
- /** Clears all cached data (e.g., mesh data when creating scaled mesh colliders) */
9187
- 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;
9188
9448
  /** Enables or disables the physics engine */
9189
9449
  enabled: boolean;
9190
9450
  /** Returns the underlying physics world object */
@@ -9414,8 +9674,9 @@ export declare interface IPhysicsEngine {
9414
9674
  * @returns The underlying physics body or null if not found
9415
9675
  */
9416
9676
  getBody(obj: ICollider | IRigidbody): null | any;
9417
- addFixedJoint(body1: IRigidbody, body2: IRigidbody): any;
9418
- 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;
9419
9680
  /** Enable to render collider shapes */
9420
9681
  debugRenderColliders: boolean;
9421
9682
  /** Enable to visualize raycasts in the scene with gizmos */
@@ -9636,6 +9897,18 @@ export declare function isDestroyed(go: Object3D): boolean;
9636
9897
  /** True when the application runs on a local url */
9637
9898
  export declare function isDevEnvironment(): boolean;
9638
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
+
9639
9912
  export declare function isDisposed(obj: object): boolean;
9640
9913
 
9641
9914
  export declare interface ISerializable {
@@ -9670,6 +9943,10 @@ export declare function isHotReloadEnabled(): boolean;
9670
9943
  /**@returns true if the element is an needle engine icon element */
9671
9944
  export declare function isIconElement(element: Node): boolean;
9672
9945
 
9946
+ export declare interface ISignalReceiver {
9947
+ readonly isSignalReceiver: true;
9948
+ }
9949
+
9673
9950
  /** @deprecated use {@link DeviceUtilities.isiOS} instead */
9674
9951
  export declare function isiOS(): boolean;
9675
9952
 
@@ -9704,6 +9981,8 @@ export declare function isResourceTrackingEnabled(): boolean;
9704
9981
  /** @deprecated use {@link DeviceUtilities.isSafari} instead */
9705
9982
  export declare function isSafari(): boolean;
9706
9983
 
9984
+ export declare function isTrackModel(obj: unknown): obj is TrackModel;
9985
+
9707
9986
  export declare function isUsingInstancing(instance: Object3D): boolean;
9708
9987
 
9709
9988
  export declare interface ITime {
@@ -9828,7 +10107,9 @@ declare abstract class Joint extends Component {
9828
10107
  connectedBody?: Rigidbody;
9829
10108
  get rigidBody(): Rigidbody | null;
9830
10109
  private _rigidBody;
10110
+ private _jointHandle;
9831
10111
  onEnable(): void;
10112
+ onDisable(): void;
9832
10113
  private create;
9833
10114
  protected abstract createJoint(self: Rigidbody, other: Rigidbody): any;
9834
10115
  }
@@ -11090,6 +11371,7 @@ export declare type Model = (GLTF | FBX | OBJ | CustomModel);
11090
11371
 
11091
11372
  declare namespace Models {
11092
11373
  export {
11374
+ isTrackModel,
11093
11375
  TimelineAssetModel,
11094
11376
  TrackType,
11095
11377
  ClipExtrapolation,
@@ -12696,7 +12978,7 @@ export declare class NetworkConnection implements INetworkConnection {
12696
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) */
12697
12979
  leaveRoom(room?: string | null): boolean;
12698
12980
  /** Send a message to the networking backend - it will be broadcasted to all connected users (except yourself) in the same room by default */
12699
- 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;
12700
12982
  /**
12701
12983
  * Deletes the network state for a specific object on the server.
12702
12984
  * This removes the object's state from the room, preventing it from being sent to newly joining users.
@@ -12718,61 +13000,69 @@ export declare class NetworkConnection implements INetworkConnection {
12718
13000
  private _defaultMessagesBufferArray;
12719
13001
  sendBufferedMessagesNow(): void;
12720
13002
  /** Use to start listening to networking events.
12721
- * 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.
12722
13005
  *
12723
- * @example Custom event example
13006
+ * @example With autoCleanup (recommended)
12724
13007
  * ```ts
12725
- * // Listen to a custom event sent by the server
12726
- * this.context.connection.beginListen<MyDataType>("my-custom-event", (data) => {
12727
- * console.log("Received custom event:", data);
12728
- * });
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
+ * }
13016
+ * ```
13017
+ *
13018
+ * @example Manual unsubscribe
13019
+ * ```ts
13020
+ * const unsub = this.context.connection.beginListen("joined-room", () => { });
13021
+ * // Later:
13022
+ * unsub(); // removes the listener
12729
13023
  * ```
12730
13024
  *
12731
- * @example Listening to room events
13025
+ * @example With stopListen (legacy pattern, still supported)
12732
13026
  * ```ts
12733
- * // Make sure to unsubscribe from events when the component is disabled
12734
13027
  * export class MyComponent extends Behaviour {
12735
13028
  * onEnable() {
12736
- * this.connection.beginListen("joined-room", this.onJoinedRoom)
13029
+ * this.context.connection.beginListen("joined-room", this.onJoinedRoom);
12737
13030
  * }
12738
13031
  * onDisable() {
12739
- * this.connection.stopListen("joined-room", this.onJoinedRoom)
13032
+ * this.context.connection.stopListen("joined-room", this.onJoinedRoom);
12740
13033
  * }
12741
13034
  * onJoinedRoom = () => {
12742
- * console.log("I joined a networked room")
13035
+ * console.log("I joined a networked room");
12743
13036
  * }
12744
13037
  * }
12745
13038
  * ```
12746
13039
  * @link https://engine.needle.tools/docs/networking.html
12747
13040
  *
12748
13041
  */
12749
- 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;
12750
13043
  /**@deprecated please use stopListen instead (2.65.2-pre) */
12751
13044
  stopListening<K extends NetworkEventKey>(key: K, callback: (K extends keyof NetworkEventMap ? NetworkEventMap[K] : (...args: any[]) => void) | null): void;
12752
- /** 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}.
12753
13047
  * To subscribe to events use the `{@link beginListen}` method.
12754
- * See the example below for typical usage:
12755
13048
  *
12756
- * ### Component Example
13049
+ * @example
12757
13050
  * ```ts
12758
- * // Make sure to unsubscribe from events when the component is disabled
12759
- * export class MyComponent extends Behaviour {
12760
- * onEnable() {
12761
- * this.connection.beginListen("joined-room", this.onJoinedRoom)
12762
- * }
12763
- * onDisable() {
12764
- * this.connection.stopListen("joined-room", this.onJoinedRoom)
12765
- * }
12766
- * onJoinedRoom = () => {
12767
- * console.log("I joined a networked room")
12768
- * }
12769
- * }
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
12770
13054
  * ```
12771
13055
  */
12772
- stopListen<K extends NetworkEventKey>(key: K, callback: (K extends keyof NetworkEventMap ? NetworkEventMap[K] : (...args: any[]) => void) | null): void;
12773
- /** Use to start listening to networking binary events */
12774
- beginListenBinary(identifier: string, callback: BinaryCallback): BinaryCallback;
12775
- /** 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
+ */
12776
13066
  stopListenBinary(identifier: string, callback: any): void;
12777
13067
  private netWebSocketUrlProvider?;
12778
13068
  /** Use to override the networking server backend url.
@@ -12781,16 +13071,19 @@ export declare class NetworkConnection implements INetworkConnection {
12781
13071
  registerProvider(prov: INetworkingWebsocketUrlProvider): void;
12782
13072
  /** Used to connect to the networking server
12783
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.
12784
13075
  */
12785
- connect(url?: string): Promise<boolean>;
13076
+ connect(url?: string, transport?: INetworkTransport): Promise<boolean>;
12786
13077
  /** Disconnect from the networking backend + reset internal state */
12787
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;
12788
13082
  private _listeners;
12789
13083
  private _listenersBinary;
12790
13084
  private connected;
12791
- private channelId;
12792
13085
  private _connectionId;
12793
- private _ws;
13086
+ private _transport;
12794
13087
  private _waitingForSocket;
12795
13088
  private _isInRoom;
12796
13089
  private _currentRoomName;
@@ -12800,6 +13093,8 @@ export declare class NetworkConnection implements INetworkConnection {
12800
13093
  private _state;
12801
13094
  private _currentDelay;
12802
13095
  private _connectingToWebsocketPromise;
13096
+ /** Wire up a transport's event callbacks and start it */
13097
+ private connectTransport;
12803
13098
  private connectWebsocket;
12804
13099
  private onMessage;
12805
13100
  private handleIncomingBinaryMessage;
@@ -13065,7 +13360,7 @@ export declare type OBJ = {
13065
13360
  scenes: Object3D[];
13066
13361
  };
13067
13362
 
13068
- declare type ObjectCloneReference = {
13363
+ export declare type ObjectCloneReference = {
13069
13364
  readonly original: object;
13070
13365
  readonly clone: object;
13071
13366
  };
@@ -13272,6 +13567,61 @@ export declare function offXRSessionEnd(fn: (evt: XRSessionEventArgs) => void):
13272
13567
  */
13273
13568
  export declare function offXRSessionStart(fn: (evt: XRSessionEventArgs) => void): void;
13274
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
+
13275
13625
  /**
13276
13626
  * Register a callback in the engine onAfterRender event
13277
13627
  * This is called every frame after the main camera has rendered
@@ -14745,13 +15095,15 @@ export declare class OrbitControls extends Component implements ICameraControlle
14745
15095
  * The timeline asset containing tracks, clips, and markers that this director will play.
14746
15096
  * Assign a timeline asset exported from Unity or Blender to enable playback.
14747
15097
  */
14748
- playableAsset?: Models.TimelineAssetModel;
15098
+ get playableAsset(): Models.TimelineAssetModel | undefined;
15099
+ set playableAsset(value: Models.TimelineAssetModel | undefined);
15100
+ private _playableAsset?;
14749
15101
  /**
14750
15102
  * When true, the timeline starts playing automatically when the component awakens.
14751
15103
  * Set to false to control playback manually via `play()`.
14752
15104
  * @default false
14753
15105
  */
14754
- playOnAwake?: boolean;
15106
+ playOnAwake: boolean;
14755
15107
  /**
14756
15108
  * Determines how the timeline behaves when it reaches the end of its duration.
14757
15109
  * @default DirectorWrapMode.Loop
@@ -14846,6 +15198,14 @@ export declare class OrbitControls extends Component implements ICameraControlle
14846
15198
  * @returns all marker tracks of the timeline
14847
15199
  */
14848
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>;
14849
15209
  /**
14850
15210
  * Iterates over all markers of the timeline, optionally filtering by type
14851
15211
  *
@@ -14859,13 +15219,13 @@ export declare class OrbitControls extends Component implements ICameraControlle
14859
15219
  *
14860
15220
  */
14861
15221
  foreachMarker<T extends Record<string, any>>(type?: string | null): Generator<(T & Models.MarkerModel)>;
14862
- private _guidsMap?;
14863
- /* Excluded from this release type: resolveGuids */
15222
+ private _needsGraphRebuild;
14864
15223
  private _isPlaying;
14865
15224
  private _internalUpdateRoutine;
14866
15225
  private _isPaused;
14867
15226
  /** internal, true during the time stop() is being processed */
14868
15227
  private _isStopping;
15228
+ /* Excluded from this release type: _isUserEvaluation */
14869
15229
  private _time;
14870
15230
  private _duration;
14871
15231
  private _weight;
@@ -14874,6 +15234,7 @@ export declare class OrbitControls extends Component implements ICameraControlle
14874
15234
  private readonly _signalTracks;
14875
15235
  private readonly _markerTracks;
14876
15236
  private readonly _controlTracks;
15237
+ private readonly _activationTracks;
14877
15238
  private readonly _customTracks;
14878
15239
  private readonly _tracksArray;
14879
15240
  private get _allTracks();
@@ -16052,6 +16413,10 @@ export declare class OrbitControls extends Component implements ICameraControlle
16052
16413
  private _gravity;
16053
16414
  get gravity(): Vec3;
16054
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. */
16055
16420
  clearCaches(): void;
16056
16421
  addBoxCollider(collider: ICollider, size: Vector3): Promise<void>;
16057
16422
  addSphereCollider(collider: ICollider): Promise<void>;
@@ -16098,7 +16463,8 @@ export declare class OrbitControls extends Component implements ICameraControlle
16098
16463
  private getRigidbodyRelativeMatrix;
16099
16464
  private static centerConnectionPos;
16100
16465
  private static centerConnectionRot;
16101
- addFixedJoint(body1: IRigidbody, body2: IRigidbody): void;
16466
+ private _jointTempMatrix;
16467
+ addFixedJoint(body1: IRigidbody, body2: IRigidbody): Promise<ImpulseJoint | null>;
16102
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. */
16103
16469
  addHingeJoint(body1: IRigidbody, body2: IRigidbody, anchor: {
16104
16470
  x: number;
@@ -16108,8 +16474,11 @@ export declare class OrbitControls extends Component implements ICameraControlle
16108
16474
  x: number;
16109
16475
  y: number;
16110
16476
  z: number;
16111
- }): 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. */
16112
16480
  private calculateJointRelativeMatrices;
16481
+ private normalizeMatrixColumns;
16113
16482
  }
16114
16483
 
16115
16484
  /**
@@ -16912,10 +17281,17 @@ export declare class OrbitControls extends Component implements ICameraControlle
16912
17281
  */
16913
17282
  export declare class Rigidbody extends Component implements IRigidbody {
16914
17283
  get isRigidbody(): boolean;
16915
- /** 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
+ */
16916
17288
  autoMass: boolean;
16917
- /** By default the mass will be automatically calculated (see `autoMass`) by the physics engine using the collider sizes
16918
- * 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.
16919
17295
  */
16920
17296
  set mass(value: number);
16921
17297
  get mass(): number;
@@ -16998,7 +17374,8 @@ export declare class OrbitControls extends Component implements ICameraControlle
16998
17374
  onEnable(): void;
16999
17375
  onDisable(): void;
17000
17376
  onDestroy(): void;
17001
- onValidate(): void;
17377
+ onValidate(property?: string): void;
17378
+ private static _didWarnAutoMass;
17002
17379
  beforePhysics(): Generator<undefined, void, unknown>;
17003
17380
  /** Teleport the rigidbody to a new position in the world.
17004
17381
  * Will reset forces before setting the object world position
@@ -18218,10 +18595,17 @@ export declare class OrbitControls extends Component implements ICameraControlle
18218
18595
 
18219
18596
  export declare function sendDestroyed(guid: string, con: INetworkConnection, opts?: SyncDestroyOptions): void;
18220
18597
 
18598
+ /** Controls when a network message is actually sent to the server.
18599
+ * @see {@link NetworkConnection.send}
18600
+ */
18221
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). */
18222
18603
  OnConnection = 0,
18604
+ /** Hold the message until the client has joined a room, then send it. Use for messages that require room context. */
18223
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()`. */
18224
18607
  Queued = 2,
18608
+ /** Send the message to the server immediately without buffering. */
18225
18609
  Immediate = 3
18226
18610
  }
18227
18611
 
@@ -18654,6 +19038,16 @@ export declare class OrbitControls extends Component implements ICameraControlle
18654
19038
  asset: string;
18655
19039
  }
18656
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
+
18657
19051
  /** SignalReceiver is a component that listens for signals and invokes a reaction when a signal is received.
18658
19052
  * Signals can be added to a signal track on a {@link PlayableDirector}
18659
19053
  *
@@ -18661,7 +19055,8 @@ export declare class OrbitControls extends Component implements ICameraControlle
18661
19055
  * @category Animation and Sequencing
18662
19056
  * @group Components
18663
19057
  */
18664
- export declare class SignalReceiver extends Component {
19058
+ export declare class SignalReceiver extends Component implements ISignalReceiver {
19059
+ readonly isSignalReceiver = true;
18665
19060
  private static receivers;
18666
19061
  static invoke(guid: string): void;
18667
19062
  events?: SignalReceiverEvent[];
@@ -18684,6 +19079,9 @@ export declare class OrbitControls extends Component implements ICameraControlle
18684
19079
  models: Models.SignalMarkerModel[];
18685
19080
  didTrigger: boolean[];
18686
19081
  receivers: Array<SignalReceiver | null>;
19082
+ private _lastTime;
19083
+ onEnable(): void;
19084
+ onMuteChanged(): void;
18687
19085
  evaluate(time: number): void;
18688
19086
  }
18689
19087
 
@@ -19183,10 +19581,6 @@ export declare class OrbitControls extends Component implements ICameraControlle
19183
19581
  * Removes scale change monitoring when the collider is disabled.
19184
19582
  */
19185
19583
  onDisable(): void;
19186
- /**
19187
- * Updates collider properties when validated in the editor or inspector.
19188
- */
19189
- onValidate(): void;
19190
19584
  }
19191
19585
 
19192
19586
  export declare class SphereIntersection implements Intersection {
@@ -20771,6 +21165,166 @@ export declare class OrbitControls extends Component implements ICameraControlle
20771
21165
  tracks: TrackModel[];
20772
21166
  };
20773
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
+
20774
21328
  declare type TonemappingAttributeOptions = "none" | "linear" | "neutral" | "agx";
20775
21329
 
20776
21330
  /**
@@ -20852,6 +21406,7 @@ export declare class OrbitControls extends Component implements ICameraControlle
20852
21406
  AudioTrackHandler,
20853
21407
  MarkerTrackHandler,
20854
21408
  SignalTrackHandler,
21409
+ ActivationTrackHandler,
20855
21410
  ControlTrackHandler
20856
21411
  }
20857
21412
  }
@@ -22575,7 +23130,7 @@ export declare class OrbitControls extends Component implements ICameraControlle
22575
23130
  private onApplyPose;
22576
23131
  }
22577
23132
 
22578
- declare type WebsocketSendType = IModel | object | boolean | null | string | number;
23133
+ declare type WebsocketSendType = IModel | object | boolean | string | number;
22579
23134
 
22580
23135
  /**
22581
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.
@@ -23618,6 +24173,28 @@ export declare class OrbitControls extends Component implements ICameraControlle
23618
24173
  export { }
23619
24174
 
23620
24175
 
24176
+ declare module 'three' {
24177
+ interface SkinnedMesh {
24178
+ staticGenerator?: StaticGeometryGenerator;
24179
+ staticGeometry?: BufferGeometry;
24180
+ staticGeometryLastUpdate?: number;
24181
+ }
24182
+ interface Mesh {
24183
+ acceleratedRaycast?: any;
24184
+ }
24185
+ interface SkinnedMesh {
24186
+ /** @deprecated use autoUpdateMeshBvhInterval */
24187
+ autoUpdateMeshBVH?: boolean;
24188
+ /**
24189
+ * Interval in milliseconds to automatically update the mesh BVH. When set to >= 0 the BVH will be updated every x milliseconds.
24190
+ * @default undefined (disabled)
24191
+ */
24192
+ autoUpdateMeshBvhInterval?: number;
24193
+ bvhNeedsUpdate?: boolean;
24194
+ }
24195
+ }
24196
+
24197
+
23621
24198
  declare module 'three' {
23622
24199
  interface Object3D {
23623
24200
  get guid(): string | undefined;
@@ -23763,25 +24340,3 @@ declare module 'three' {
23763
24340
  slerp(end: Vector3, t: number): Vector3;
23764
24341
  }
23765
24342
  }
23766
-
23767
-
23768
- declare module 'three' {
23769
- interface SkinnedMesh {
23770
- staticGenerator?: StaticGeometryGenerator;
23771
- staticGeometry?: BufferGeometry;
23772
- staticGeometryLastUpdate?: number;
23773
- }
23774
- interface Mesh {
23775
- acceleratedRaycast?: any;
23776
- }
23777
- interface SkinnedMesh {
23778
- /** @deprecated use autoUpdateMeshBvhInterval */
23779
- autoUpdateMeshBVH?: boolean;
23780
- /**
23781
- * Interval in milliseconds to automatically update the mesh BVH. When set to >= 0 the BVH will be updated every x milliseconds.
23782
- * @default undefined (disabled)
23783
- */
23784
- autoUpdateMeshBvhInterval?: number;
23785
- bvhNeedsUpdate?: boolean;
23786
- }
23787
- }