@needle-tools/engine 5.1.0-alpha → 5.1.0-canary.30cc545

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 (166) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/SKILL.md +39 -21
  3. package/components.needle.json +1 -1
  4. package/dist/{gltf-progressive-DJBMx-zB.umd.cjs → gltf-progressive-BmblPzFj.umd.cjs} +4 -4
  5. package/dist/{gltf-progressive-BryRjllq.min.js → gltf-progressive-CN_mbb66.min.js} +2 -2
  6. package/dist/{gltf-progressive-Cl167Vjx.js → gltf-progressive-DUlhxdv4.js} +5 -2
  7. package/dist/{needle-engine.bundle-wM-BWPX9.umd.cjs → needle-engine.bundle-BMlLSACE.umd.cjs} +250 -174
  8. package/dist/{needle-engine.bundle-qDahLTqW.min.js → needle-engine.bundle-BXPPQRer.min.js} +242 -166
  9. package/dist/{needle-engine.bundle-CwhCzjep.js → needle-engine.bundle-d_9mSxN4.js} +12930 -12465
  10. package/dist/needle-engine.d.ts +267 -16
  11. package/dist/needle-engine.js +569 -563
  12. package/dist/needle-engine.min.js +1 -1
  13. package/dist/needle-engine.umd.cjs +1 -1
  14. package/dist/{postprocessing-B_9sKVU7.min.js → postprocessing-B571qGWR.min.js} +34 -34
  15. package/dist/{postprocessing-WDc9WwI3.js → postprocessing-CfrLAbLX.js} +0 -1
  16. package/dist/{postprocessing-B2wb6pzI.umd.cjs → postprocessing-CiGkAeM9.umd.cjs} +17 -17
  17. package/dist/{vendor-CAcsI0eU.js → vendor-BFrMaK9q.js} +8983 -9136
  18. package/dist/vendor-CJmyOrCq.min.js +1116 -0
  19. package/dist/vendor-DkMW3WY4.umd.cjs +1116 -0
  20. package/lib/engine/api.d.ts +12 -0
  21. package/lib/engine/api.js +2 -0
  22. package/lib/engine/api.js.map +1 -1
  23. package/lib/engine/debug/debug_environment.js +1 -1
  24. package/lib/engine/debug/debug_environment.js.map +1 -1
  25. package/lib/engine/engine_application.js +8 -6
  26. package/lib/engine/engine_application.js.map +1 -1
  27. package/lib/engine/engine_components.js +5 -1
  28. package/lib/engine/engine_components.js.map +1 -1
  29. package/lib/engine/engine_constants.js +6 -0
  30. package/lib/engine/engine_constants.js.map +1 -1
  31. package/lib/engine/engine_context.d.ts +25 -0
  32. package/lib/engine/engine_context.js +27 -0
  33. package/lib/engine/engine_context.js.map +1 -1
  34. package/lib/engine/engine_context_registry.js +1 -1
  35. package/lib/engine/engine_context_registry.js.map +1 -1
  36. package/lib/engine/engine_init.js +2 -0
  37. package/lib/engine/engine_init.js.map +1 -1
  38. package/lib/engine/engine_input.d.ts +3 -2
  39. package/lib/engine/engine_input.js +3 -2
  40. package/lib/engine/engine_input.js.map +1 -1
  41. package/lib/engine/engine_license.js +11 -9
  42. package/lib/engine/engine_license.js.map +1 -1
  43. package/lib/engine/engine_networking_blob.d.ts +1 -1
  44. package/lib/engine/engine_networking_blob.js +5 -11
  45. package/lib/engine/engine_networking_blob.js.map +1 -1
  46. package/lib/engine/engine_physics_rapier.d.ts +3 -0
  47. package/lib/engine/engine_physics_rapier.js +13 -10
  48. package/lib/engine/engine_physics_rapier.js.map +1 -1
  49. package/lib/engine/engine_pmrem.js +2 -2
  50. package/lib/engine/engine_pmrem.js.map +1 -1
  51. package/lib/engine/engine_scenedata.d.ts +36 -0
  52. package/lib/engine/engine_scenedata.js +111 -0
  53. package/lib/engine/engine_scenedata.js.map +1 -0
  54. package/lib/engine/engine_ssr.d.ts +16 -0
  55. package/lib/engine/engine_ssr.js +38 -0
  56. package/lib/engine/engine_ssr.js.map +1 -0
  57. package/lib/engine/engine_three_utils.d.ts +14 -7
  58. package/lib/engine/engine_three_utils.js +14 -7
  59. package/lib/engine/engine_three_utils.js.map +1 -1
  60. package/lib/engine/engine_utils.js +4 -2
  61. package/lib/engine/engine_utils.js.map +1 -1
  62. package/lib/engine/engine_utils_hash.d.ts +9 -0
  63. package/lib/engine/engine_utils_hash.js +112 -0
  64. package/lib/engine/engine_utils_hash.js.map +1 -0
  65. package/lib/engine/webcomponents/logo-element.d.ts +2 -1
  66. package/lib/engine/webcomponents/logo-element.js +2 -1
  67. package/lib/engine/webcomponents/logo-element.js.map +1 -1
  68. package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +2 -1
  69. package/lib/engine/webcomponents/needle menu/needle-menu.js +2 -1
  70. package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
  71. package/lib/engine/webcomponents/needle-button.d.ts +2 -1
  72. package/lib/engine/webcomponents/needle-button.js +2 -1
  73. package/lib/engine/webcomponents/needle-button.js.map +1 -1
  74. package/lib/engine/webcomponents/needle-engine.d.ts +2 -1
  75. package/lib/engine/webcomponents/needle-engine.js +2 -1
  76. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  77. package/lib/engine/xr/NeedleXRSession.d.ts +1 -0
  78. package/lib/engine/xr/NeedleXRSession.js +5 -5
  79. package/lib/engine/xr/NeedleXRSession.js.map +1 -1
  80. package/lib/engine/xr/events.d.ts +30 -3
  81. package/lib/engine/xr/events.js +38 -0
  82. package/lib/engine/xr/events.js.map +1 -1
  83. package/lib/engine/xr/init.js +1 -7
  84. package/lib/engine/xr/init.js.map +1 -1
  85. package/lib/engine-components/AnimatorController.d.ts +135 -2
  86. package/lib/engine-components/AnimatorController.js +218 -2
  87. package/lib/engine-components/AnimatorController.js.map +1 -1
  88. package/lib/engine-components/GroundProjection.d.ts +1 -0
  89. package/lib/engine-components/GroundProjection.js +184 -48
  90. package/lib/engine-components/GroundProjection.js.map +1 -1
  91. package/lib/engine-components/RigidBody.js +3 -3
  92. package/lib/engine-components/RigidBody.js.map +1 -1
  93. package/lib/engine-components/SceneSwitcher.js +2 -0
  94. package/lib/engine-components/SceneSwitcher.js.map +1 -1
  95. package/lib/engine-components/api.d.ts +1 -0
  96. package/lib/engine-components/api.js +1 -0
  97. package/lib/engine-components/api.js.map +1 -1
  98. package/lib/engine-components/codegen/components.d.ts +1 -0
  99. package/lib/engine-components/codegen/components.js +1 -0
  100. package/lib/engine-components/codegen/components.js.map +1 -1
  101. package/lib/engine-components/postprocessing/Effects/BloomEffect.d.ts +1 -1
  102. package/lib/engine-components/postprocessing/Effects/Sharpening.js +1 -2
  103. package/lib/engine-components/postprocessing/Effects/Sharpening.js.map +1 -1
  104. package/lib/engine-components/postprocessing/PostProcessingHandler.js +5 -6
  105. package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
  106. package/lib/engine-components/web/ScrollFollow.d.ts +0 -1
  107. package/lib/engine-components/web/ScrollFollow.js +3 -2
  108. package/lib/engine-components/web/ScrollFollow.js.map +1 -1
  109. package/package.json +6 -5
  110. package/plugins/common/logger.js +42 -19
  111. package/plugins/dts-generator/dts.codegen.js +129 -0
  112. package/plugins/dts-generator/dts.scan.js +71 -0
  113. package/plugins/dts-generator/dts.writer.js +59 -0
  114. package/plugins/dts-generator/glb.discovery.js +162 -0
  115. package/plugins/dts-generator/glb.extractor.js +175 -0
  116. package/plugins/dts-generator/glb.reader.js +114 -0
  117. package/plugins/dts-generator/index.js +36 -0
  118. package/plugins/dts-generator/manifest.types.js +174 -0
  119. package/plugins/types/index.d.ts +2 -1
  120. package/plugins/types/needle-bindings.d.ts +19 -0
  121. package/plugins/types/userconfig.d.ts +9 -2
  122. package/plugins/vite/dts-generator.d.ts +7 -0
  123. package/plugins/vite/dts-generator.js +157 -0
  124. package/plugins/vite/index.d.ts +1 -0
  125. package/plugins/vite/index.js +4 -0
  126. package/plugins/vite/logger.client.js +4 -3
  127. package/plugins/vite/logging.js +2 -2
  128. package/plugins/vite/reload.js +2 -1
  129. package/src/engine/api.ts +15 -1
  130. package/src/engine/debug/debug_environment.ts +1 -1
  131. package/src/engine/engine_application.ts +8 -6
  132. package/src/engine/engine_components.ts +7 -4
  133. package/src/engine/engine_constants.ts +11 -6
  134. package/src/engine/engine_context.ts +29 -0
  135. package/src/engine/engine_context_registry.ts +1 -1
  136. package/src/engine/engine_init.ts +2 -0
  137. package/src/engine/engine_input.ts +3 -2
  138. package/src/engine/engine_license.ts +11 -9
  139. package/src/engine/engine_networking_blob.ts +5 -11
  140. package/src/engine/engine_physics_rapier.ts +14 -12
  141. package/src/engine/engine_pmrem.ts +3 -3
  142. package/src/engine/engine_scenedata.ts +110 -0
  143. package/src/engine/engine_ssr.ts +45 -0
  144. package/src/engine/engine_three_utils.ts +15 -7
  145. package/src/engine/engine_utils.ts +3 -2
  146. package/src/engine/engine_utils_hash.ts +65 -0
  147. package/src/engine/webcomponents/logo-element.ts +2 -1
  148. package/src/engine/webcomponents/needle menu/needle-menu.ts +2 -1
  149. package/src/engine/webcomponents/needle-button.ts +2 -1
  150. package/src/engine/webcomponents/needle-engine.ts +2 -1
  151. package/src/engine/xr/NeedleXRSession.ts +6 -6
  152. package/src/engine/xr/events.ts +44 -1
  153. package/src/engine/xr/init.ts +0 -7
  154. package/src/engine-components/AnimatorController.ts +286 -4
  155. package/src/engine-components/GroundProjection.ts +226 -52
  156. package/src/engine-components/RigidBody.ts +3 -3
  157. package/src/engine-components/SceneSwitcher.ts +1 -0
  158. package/src/engine-components/api.ts +1 -0
  159. package/src/engine-components/codegen/components.ts +1 -0
  160. package/src/engine-components/postprocessing/Effects/BloomEffect.ts +1 -1
  161. package/src/engine-components/postprocessing/Effects/Sharpening.ts +1 -2
  162. package/src/engine-components/postprocessing/PostProcessingHandler.ts +4 -8
  163. package/src/engine-components/web/ScrollFollow.ts +2 -2
  164. package/src/vite-env.d.ts +16 -0
  165. package/dist/vendor-CEM38hLE.umd.cjs +0 -1116
  166. package/dist/vendor-HRlxIBga.min.js +0 -1116
@@ -84,6 +84,7 @@ import { RawShaderMaterial } from 'three';
84
84
  import { Ray } from 'three';
85
85
  import { Raycaster } from 'three';
86
86
  import { Scene } from 'three';
87
+ import { SceneData } from '../../plugins/types/needle-bindings.d.ts';
87
88
  import { ShaderMaterial } from 'three';
88
89
  import { ShapeJSON } from 'three.quarks';
89
90
  import { SkinnedMesh } from 'three';
@@ -918,8 +919,9 @@ export declare enum AnimatorConditionMode {
918
919
  * and parameters that affect those transitions. It is used by the {@link Animator}
919
920
  * component to control animation behavior on 3D models.
920
921
  *
921
- * Use the static method {@link AnimatorController.createFromClips} to create
922
- * an animator controller from a set of animation clips.
922
+ * Use {@link AnimatorController.build} to fluently create a controller with parameters,
923
+ * states, transitions, and conditions. For simple sequential playback,
924
+ * use {@link AnimatorController.createFromClips}.
923
925
  *
924
926
  * @category Animation and Sequencing
925
927
  * @group Utilities
@@ -934,6 +936,27 @@ export declare class AnimatorController {
934
936
  * @returns A new AnimatorController instance
935
937
  */
936
938
  static createFromClips(clips: AnimationClip[], options?: CreateAnimatorControllerOptions): AnimatorController;
939
+ /**
940
+ * Creates a new {@link AnimatorControllerBuilder} for fluently constructing a controller with
941
+ * parameters, states, transitions, and conditions.
942
+ *
943
+ * @param name - Optional name for the controller
944
+ * @returns A new builder instance
945
+ *
946
+ * @example
947
+ * ```ts
948
+ * const ctrl = AnimatorController.build("MyController")
949
+ * .floatParameter("Speed")
950
+ * .state("Idle", { clip: idleClip, loop: true })
951
+ * .state("Walk", { clip: walkClip, loop: true })
952
+ * .transition("Idle", "Walk", { duration: 0.25 })
953
+ * .condition("Speed", "greater", 0.1)
954
+ * .transition("Walk", "Idle", { duration: 0.25 })
955
+ * .condition("Speed", "less", 0.1)
956
+ * .build();
957
+ * ```
958
+ */
959
+ static build(name?: string): AnimatorControllerBuilder;
937
960
  /**
938
961
  * Plays an animation state by name or hash.
939
962
  *
@@ -1125,6 +1148,84 @@ export declare class AnimatorController {
1125
1148
  private rootMotionHandler?;
1126
1149
  }
1127
1150
 
1151
+ /**
1152
+ * A fluent builder for creating {@link AnimatorController} instances from code.
1153
+ *
1154
+ * Use {@link AnimatorController.build} to create a new builder.
1155
+ *
1156
+ * @example
1157
+ * ```ts
1158
+ * const controller = AnimatorController.build("CharacterController")
1159
+ * .floatParameter("Speed", 0)
1160
+ * .triggerParameter("Jump")
1161
+ * .state("Idle", { clip: idleClip, loop: true })
1162
+ * .state("Walk", { clip: walkClip, loop: true })
1163
+ * .state("Jump", { clip: jumpClip })
1164
+ * .transition("Idle", "Walk", { duration: 0.25 })
1165
+ * .condition("Speed", "greater", 0.1)
1166
+ * .transition("Walk", "Idle", { duration: 0.25 })
1167
+ * .condition("Speed", "less", 0.1)
1168
+ * .transition("*", "Jump", { duration: 0.1 })
1169
+ * .condition("Jump", "if")
1170
+ * .transition("Jump", "Idle", { hasExitTime: true, exitTime: 0.9, duration: 0.25 })
1171
+ * .build();
1172
+ * ```
1173
+ *
1174
+ * @category Animation and Sequencing
1175
+ * @group Utilities
1176
+ */
1177
+ export declare class AnimatorControllerBuilder {
1178
+ private _name;
1179
+ private _parameters;
1180
+ private _states;
1181
+ private _anyStateTransitions;
1182
+ private _defaultStateName;
1183
+ private _lastTransition;
1184
+ constructor(name?: string);
1185
+ /** Adds a float parameter */
1186
+ floatParameter(name: string, defaultValue?: number): this;
1187
+ /** Adds an integer parameter */
1188
+ intParameter(name: string, defaultValue?: number): this;
1189
+ /** Adds a boolean parameter */
1190
+ boolParameter(name: string, defaultValue?: boolean): this;
1191
+ /** Adds a trigger parameter */
1192
+ triggerParameter(name: string): this;
1193
+ /**
1194
+ * Adds a state to the controller. The first state added becomes the default state.
1195
+ * @param name - Unique name for the state
1196
+ * @param options - State configuration including clip, loop, speed
1197
+ */
1198
+ state(name: string, options: StateOptions): this;
1199
+ /**
1200
+ * Adds a transition between two states.
1201
+ * Use `"*"` as the source to create a transition from any state.
1202
+ * Chain `.condition()` calls after this to add conditions.
1203
+ * @param from - Source state name, or `"*"` for any-state transition
1204
+ * @param to - Destination state name
1205
+ * @param options - Transition configuration
1206
+ */
1207
+ transition(from: string, to: string, options?: TransitionOptions): this;
1208
+ /**
1209
+ * Adds a condition to the most recently added transition.
1210
+ * Multiple conditions on the same transition are AND-ed together.
1211
+ * @param parameter - Name of the parameter to evaluate
1212
+ * @param mode - Condition mode: `"if"`, `"ifNot"`, `"greater"`, `"less"`, `"equals"`, `"notEqual"`
1213
+ * @param threshold - Comparison threshold for numeric conditions (default: 0)
1214
+ */
1215
+ condition(parameter: string, mode: ConditionMode, threshold?: number): this;
1216
+ /**
1217
+ * Sets which state is the default/entry state.
1218
+ * If not called, the first added state is used.
1219
+ * @param name - Name of the state
1220
+ */
1221
+ defaultState(name: string): this;
1222
+ /**
1223
+ * Builds and returns the {@link AnimatorController}.
1224
+ * Resolves all state name references to indices.
1225
+ */
1226
+ build(): AnimatorController;
1227
+ }
1228
+
1128
1229
  export declare type AnimatorControllerModel = {
1129
1230
  name: string;
1130
1231
  guid: string;
@@ -2092,7 +2193,7 @@ export declare namespace BlobStorage {
2092
2193
  /**
2093
2194
  * Generates an md5 hash from a given buffer
2094
2195
  * @param buffer The buffer to hash
2095
- * @returns The md5 hash
2196
+ * @returns The md5 hash as a hex string
2096
2197
  */
2097
2198
  export function hashMD5(buffer: ArrayBuffer): string;
2098
2199
  export function hashMD5_Base64(buffer: ArrayBuffer): string;
@@ -4006,6 +4107,9 @@ export declare type Condition = {
4006
4107
  threshold: number;
4007
4108
  };
4008
4109
 
4110
+ /** String condition modes for the builder, mapped to {@link AnimatorConditionMode} */
4111
+ export declare type ConditionMode = "if" | "ifNot" | "greater" | "less" | "equals" | "notEqual";
4112
+
4009
4113
  /** Events regarding the websocket connection (e.g. when the connection opens) */
4010
4114
  export declare enum ConnectionEvents {
4011
4115
  ConnectionInfo = "connection-start-info"
@@ -4355,6 +4459,30 @@ export declare class Context implements IContext {
4355
4459
  * The main camera of the scene - this camera is used for rendering
4356
4460
  * Use `setCurrentCamera` for updating the main camera.
4357
4461
  */
4462
+ /**
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.
4466
+ *
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)`.
4470
+ *
4471
+ * @example
4472
+ * // Toggle auto-rotate on the orbit camera
4473
+ * ctx.sceneData.Camera.OrbitControls.autoRotate = true;
4474
+ *
4475
+ * @example
4476
+ * // Change the background color
4477
+ * 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
+ */
4485
+ get sceneData(): SceneData;
4358
4486
  get mainCamera(): Camera_2;
4359
4487
  /** Set the main camera of the scene. If set to null the camera of the {@link mainCameraComponent} will be used - this camera is used for rendering */
4360
4488
  set mainCamera(cam: Camera_2 | null);
@@ -7027,6 +7155,23 @@ export declare function getPeerOptions(): PeerJSOption | undefined;
7027
7155
 
7028
7156
  export declare function getResourceUserCount(object: object): number | undefined;
7029
7157
 
7158
+ /**
7159
+ * Returns a lazily-resolved proxy typed as {@link SceneData}.
7160
+ * The proxy is cached per context — each context gets exactly one instance.
7161
+ *
7162
+ * Accessing a property traverses the scene graph on demand:
7163
+ * - First level → find Object3D by node name
7164
+ * - Second level → getComponent by component name (via TypeStore)
7165
+ * - Third level → read/write a field on the real component instance
7166
+ *
7167
+ * If a node or component is not found, property accesses log a warning
7168
+ * instead of throwing, so chained access never crashes.
7169
+ *
7170
+ * @example
7171
+ * ctx.sceneData.Camera.OrbitControls.autoRotate = true;
7172
+ */
7173
+ export declare function getSceneData(ctx: IContext): SceneData;
7174
+
7030
7175
  export declare function getTempColor(color?: Color): Color;
7031
7176
 
7032
7177
  /**
@@ -7357,13 +7502,20 @@ export declare class GraphicRaycaster extends ObjectRaycaster {
7357
7502
  * Utility class to perform various graphics operations like copying textures to canvas
7358
7503
  */
7359
7504
  export declare class Graphics {
7360
- private static readonly planeGeometry;
7361
- private static readonly renderer;
7362
- private static readonly perspectiveCam;
7363
- private static readonly orthographicCam;
7364
- private static readonly scene;
7365
- private static readonly blitMaterial;
7366
- private static readonly mesh;
7505
+ private static _planeGeometry;
7506
+ private static _renderer;
7507
+ private static _perspectiveCam;
7508
+ private static _orthographicCam;
7509
+ private static _scene;
7510
+ private static _blitMaterial;
7511
+ private static _mesh;
7512
+ private static get planeGeometry();
7513
+ private static get renderer();
7514
+ private static get perspectiveCam();
7515
+ private static get orthographicCam();
7516
+ private static get scene();
7517
+ private static get blitMaterial();
7518
+ private static get mesh();
7367
7519
  /**
7368
7520
  * Copy a texture to a new texture
7369
7521
  * @param texture the texture to copy
@@ -7516,6 +7668,7 @@ export declare class GroundProjectedEnv extends Component {
7516
7668
  updateProjection(): void;
7517
7669
  private _blurrynessShader;
7518
7670
  private _lastBlurriness;
7671
+ private updateProjectionMaterial;
7519
7672
  private updateBlurriness;
7520
7673
  }
7521
7674
 
@@ -7826,6 +7979,9 @@ export declare class HoverAnimation extends Component {
7826
7979
  private playHover;
7827
7980
  }
7828
7981
 
7982
+ /** SSR-safe base class for web components. */
7983
+ declare const HTMLElementBase: typeof HTMLElement;
7984
+
7829
7985
  export declare type IAnimationComponent = Pick<IComponent, "gameObject"> & {
7830
7986
  isAnimationComponent: boolean;
7831
7987
  addClip?(clip: AnimationClip): any;
@@ -8301,6 +8457,10 @@ export declare class InheritVelocityModule {
8301
8457
  applyCurrent(vel: Vector3 | Vector3_2, t01: number, lerpFactor: number): void;
8302
8458
  }
8303
8459
 
8460
+ /** Register the Rapier physics backend. Called from {@link initEngine}
8461
+ * to ensure it runs regardless of tree-shaking. */
8462
+ export declare function initPhysics(): void;
8463
+
8304
8464
  /**
8305
8465
  * Handles all input events including mouse, touch, keyboard, and XR controllers.
8306
8466
  * Access via `this.context.input` from any component.
@@ -9591,6 +9751,9 @@ declare const enum KeyboardEnumType {
9591
9751
  KeyPressed = "keypress"
9592
9752
  }
9593
9753
 
9754
+ /** SSR-safe base class for keyboard events. */
9755
+ declare const KeyboardEventBase: typeof KeyboardEvent;
9756
+
9594
9757
  declare type KeyboardEventListener = (evt: NEKeyboardEvent) => void;
9595
9758
 
9596
9759
  declare type KeyboardEventNames = EnumToPrimitiveUnion<KeyboardEnumType>;
@@ -10864,6 +11027,25 @@ export declare type MouseButtonName = "left" | "right" | "middle";
10864
11027
 
10865
11028
  /* Excluded from this release type: nameofFactory */
10866
11029
 
11030
+ /**
11031
+ * Global proxy for the primary Needle Engine context.
11032
+ * Resolves lazily on property access via `ContextRegistry.Current` —
11033
+ * safe to import at module level, including in SSR environments
11034
+ * (returns a silent error proxy when no context is active).
11035
+ *
11036
+ * Use this outside of Needle component lifecycle (e.g. in Svelte/React/Vue
11037
+ * components, button handlers, or vanilla JS) instead of threading `ctx` around.
11038
+ *
11039
+ * For multiple `<needle-engine>` elements on the same page, use `ctx` directly.
11040
+ *
11041
+ * @example
11042
+ * import { needle } from "@needle-tools/engine";
11043
+ * button.onclick = () => {
11044
+ * needle.sceneData.Camera.OrbitControls.autoRotate = true;
11045
+ * };
11046
+ */
11047
+ export declare const needle: IContext;
11048
+
10867
11049
  declare class NEEDLE_components implements GLTFLoaderPlugin {
10868
11050
  get name(): string;
10869
11051
  exportContext: {
@@ -10997,7 +11179,7 @@ export { NEEDLE_progressive }
10997
11179
  * @see {@link NeedleEngineWebComponent} for the main &lt;needle-engine&gt; element
10998
11180
  * @see {@link NeedleMenu} for the built-in menu component that can display similar buttons
10999
11181
  */
11000
- export declare class NeedleButtonElement extends HTMLElement {
11182
+ export declare class NeedleButtonElement extends HTMLElementBase {
11001
11183
  #private;
11002
11184
  static observedAttributes: string[];
11003
11185
  constructor();
@@ -11137,7 +11319,7 @@ export declare namespace NeedleEngineModelLoader {
11137
11319
  * @see {@link NeedleButtonElement} for adding AR/VR/Quicklook buttons via &lt;needle-button&gt;
11138
11320
  * @see {@link NeedleMenu} for the built-in menu configuration component
11139
11321
  */
11140
- export declare class NeedleEngineWebComponent extends HTMLElement implements INeedleEngineComponent {
11322
+ export declare class NeedleEngineWebComponent extends HTMLElementBase implements INeedleEngineComponent {
11141
11323
  static get observedAttributes(): string[];
11142
11324
  get loadingProgress01(): number;
11143
11325
  get loadingFinished(): boolean;
@@ -12110,7 +12292,7 @@ export declare class NeedleXRUtils {
12110
12292
  }): void;
12111
12293
  }
12112
12294
 
12113
- export declare class NEKeyboardEvent extends KeyboardEvent {
12295
+ export declare class NEKeyboardEvent extends KeyboardEventBase {
12114
12296
  source?: Event;
12115
12297
  constructor(type: InputEvents, source: Event, init: KeyboardEventInit);
12116
12298
  stopImmediatePropagation(): void;
@@ -12134,7 +12316,7 @@ export declare class NEKeyboardEvent extends KeyboardEvent {
12134
12316
  * @see {@link Input} for the input management system
12135
12317
  * @see {@link PointerType} for available pointer types
12136
12318
  */
12137
- export declare class NEPointerEvent extends PointerEvent {
12319
+ export declare class NEPointerEvent extends PointerEventBase {
12138
12320
  /**
12139
12321
  * Spatial input data
12140
12322
  */
@@ -12900,6 +13082,12 @@ export declare class ObjectUtils {
12900
13082
  private static applyDefaultObjectOptions;
12901
13083
  }
12902
13084
 
13085
+ /**
13086
+ * Remove a listener for before an XR session is requested
13087
+ * @param fn The function to remove from the listeners
13088
+ */
13089
+ export declare function offBeforeXRSession(fn: (args: XRSessionRequestEventArgs) => void): void;
13090
+
12903
13091
  /* Excluded from this release type: OffscreenCanvasExt */
12904
13092
 
12905
13093
  /**
@@ -13004,6 +13192,21 @@ export declare function onAfterRender(cb: LifecycleMethod, opts?: LifecycleMetho
13004
13192
  * */
13005
13193
  export declare function onBeforeRender(cb: LifecycleMethod, opts?: LifecycleMethodOptions): () => void;
13006
13194
 
13195
+ /**
13196
+ * Add a listener that fires before an XR session is requested.
13197
+ * Use this to modify the session init options, e.g. to add optional features like `camera-access`.
13198
+ * @param fn The function to call before the XR session is requested
13199
+ * @example
13200
+ * ```js
13201
+ * onBeforeXRSession((args) => {
13202
+ * args.init.optionalFeatures ??= [];
13203
+ * args.init.optionalFeatures.push("camera-access");
13204
+ * });
13205
+ * ```
13206
+ * @return A function to remove the listener
13207
+ */
13208
+ export declare function onBeforeXRSession(fn: (args: XRSessionRequestEventArgs) => void): () => void;
13209
+
13007
13210
  /**
13008
13211
  * Register a callback before the engine context is cleared.
13009
13212
  * This happens if e.g. `<needle-engine src>` changes
@@ -13225,8 +13428,9 @@ export declare function onUpdate(cb: LifecycleMethod, opts?: LifecycleMethodOpti
13225
13428
  * console.log("XR session ended", evt);
13226
13429
  * });
13227
13430
  * ```
13431
+ * @returns A function to remove the listener
13228
13432
  */
13229
- export declare function onXRSessionEnd(fn: (evt: XRSessionEventArgs) => void): void;
13433
+ export declare function onXRSessionEnd(fn: (evt: XRSessionEventArgs) => void): () => void;
13230
13434
 
13231
13435
  /**
13232
13436
  * Add a listener for when an XR session starts
@@ -13238,8 +13442,9 @@ export declare function onXRSessionEnd(fn: (evt: XRSessionEventArgs) => void): v
13238
13442
  * console.log("XR session started", evt);
13239
13443
  * });
13240
13444
  * ```
13445
+ * @returns A function to remove the listener
13241
13446
  */
13242
- export declare function onXRSessionStart(fn: (evt: XRSessionEventArgs) => void): void;
13447
+ export declare function onXRSessionStart(fn: (evt: XRSessionEventArgs) => void): () => void;
13243
13448
 
13244
13449
  /**
13245
13450
  * OpenURL behaviour opens a URL in a new tab or window when the object (or any if it's children) is clicked.
@@ -14943,6 +15148,9 @@ export declare class OrbitControls extends Component implements ICameraControlle
14943
15148
  PointerMove = "pointermove"
14944
15149
  }
14945
15150
 
15151
+ /** SSR-safe base class for pointer events. */
15152
+ declare const PointerEventBase: typeof PointerEvent;
15153
+
14946
15154
  /** [PointerEventData](https://engine.needle.tools/docs/api/PointerEventData) This pointer event data object is passed to all event receivers that are currently active
14947
15155
  * It contains hit information if an object was hovered or clicked
14948
15156
  * If the event is received in onPointerDown or onPointerMove, you can call `setPointerCapture` to receive onPointerMove events even when the pointer has left the object until you call `releasePointerCapture` or when the pointerUp event happens
@@ -16830,6 +17038,8 @@ export declare class OrbitControls extends Component implements ICameraControlle
16830
17038
  */
16831
17039
  declare type ScaleClipType = "linear" | "spring";
16832
17040
 
17041
+ export { SceneData }
17042
+
16833
17043
  export declare class SceneLightSettings extends Component {
16834
17044
  ambientMode: AmbientMode;
16835
17045
  ambientLight?: Color;
@@ -17977,6 +18187,7 @@ export declare class OrbitControls extends Component implements ICameraControlle
17977
18187
  export declare type SessionRequestedEvent = (args: {
17978
18188
  readonly mode: XRSessionMode;
17979
18189
  readonly init: XRSessionInit;
18190
+ readonly context: Context;
17980
18191
  }) => void;
17981
18192
 
17982
18193
  export declare function setActive(go: Object3D, active: boolean | number): boolean;
@@ -19614,6 +19825,24 @@ export declare class OrbitControls extends Component implements ICameraControlle
19614
19825
  instance?: StateMachineBehaviour;
19615
19826
  };
19616
19827
 
19828
+ /**
19829
+ * Configuration for an animation state in the builder
19830
+ */
19831
+ export declare type StateOptions = {
19832
+ /** The animation clip for this state */
19833
+ clip: AnimationClip;
19834
+ /** Whether the animation should loop (default: false) */
19835
+ loop?: boolean;
19836
+ /** Base speed multiplier (default: 1) */
19837
+ speed?: number;
19838
+ /** Name of a float parameter to multiply with speed */
19839
+ speedParameter?: string;
19840
+ /** Normalized cycle offset 0-1 (default: 0) */
19841
+ cycleOffset?: number;
19842
+ /** Name of a float parameter to use as cycle offset */
19843
+ cycleOffsetParameter?: string;
19844
+ };
19845
+
19617
19846
  declare type StickName = "xr-standard-thumbstick" | "xr-standard-touchpad";
19618
19847
 
19619
19848
  export declare class StreamEndedEvent {
@@ -20712,6 +20941,22 @@ export declare class OrbitControls extends Component implements ICameraControlle
20712
20941
  Animation = 3
20713
20942
  }
20714
20943
 
20944
+ /**
20945
+ * Configuration for a transition in the builder
20946
+ */
20947
+ export declare type TransitionOptions = {
20948
+ /** Duration of the crossfade in seconds (default: 0) */
20949
+ duration?: number;
20950
+ /** Normalized exit time 0-1 (default: 1). Only used when hasExitTime is true */
20951
+ exitTime?: number;
20952
+ /** Whether the transition waits for exitTime before transitioning (default: false) */
20953
+ hasExitTime?: boolean;
20954
+ /** Normalized offset into the destination state's animation (default: 0) */
20955
+ offset?: number;
20956
+ /** Whether duration is in seconds (true) or normalized (false) (default: false) */
20957
+ hasFixedDuration?: boolean;
20958
+ };
20959
+
20715
20960
  export declare class TriggerBuilder {
20716
20961
  private static __sceneStartTrigger?;
20717
20962
  static sceneStartTrigger(): TriggerModel;
@@ -23231,6 +23476,12 @@ export declare class OrbitControls extends Component implements ICameraControlle
23231
23476
  session: NeedleXRSession;
23232
23477
  };
23233
23478
 
23479
+ export declare type XRSessionRequestEventArgs = {
23480
+ readonly mode: XRSessionMode;
23481
+ readonly init: XRSessionInit;
23482
+ readonly context: Context;
23483
+ };
23484
+
23234
23485
  export declare class XRState {
23235
23486
  static Global: XRState;
23236
23487
  Mask: XRStateFlag;