@needle-tools/engine 5.1.0-alpha → 5.1.0-canary.0d9f44e

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 (195) hide show
  1. package/.needle/generated/needle-bindings.gen.d.ts +5 -0
  2. package/CHANGELOG.md +9 -1
  3. package/SKILL.md +39 -21
  4. package/components.needle.json +1 -1
  5. package/dist/{gltf-progressive-DJBMx-zB.umd.cjs → gltf-progressive-BmblPzFj.umd.cjs} +4 -4
  6. package/dist/{gltf-progressive-BryRjllq.min.js → gltf-progressive-CN_mbb66.min.js} +2 -2
  7. package/dist/{gltf-progressive-Cl167Vjx.js → gltf-progressive-DUlhxdv4.js} +5 -2
  8. package/dist/{needle-engine.bundle-CwhCzjep.js → needle-engine.bundle-B35n_IHX.js} +13637 -13081
  9. package/dist/{needle-engine.bundle-wM-BWPX9.umd.cjs → needle-engine.bundle-CDj15wRB.umd.cjs} +250 -174
  10. package/dist/needle-engine.bundle-D5zzggEG.min.js +1732 -0
  11. package/dist/needle-engine.d.ts +316 -26
  12. package/dist/needle-engine.js +569 -563
  13. package/dist/needle-engine.min.js +1 -1
  14. package/dist/needle-engine.umd.cjs +1 -1
  15. package/dist/{postprocessing-B_9sKVU7.min.js → postprocessing-B571qGWR.min.js} +34 -34
  16. package/dist/{postprocessing-WDc9WwI3.js → postprocessing-CfrLAbLX.js} +0 -1
  17. package/dist/{postprocessing-B2wb6pzI.umd.cjs → postprocessing-CiGkAeM9.umd.cjs} +17 -17
  18. package/dist/three-examples.js +4289 -3778
  19. package/dist/three-examples.min.js +301 -14
  20. package/dist/three-examples.umd.cjs +301 -14
  21. package/dist/{vendor-CAcsI0eU.js → vendor-BFrMaK9q.js} +8983 -9136
  22. package/dist/vendor-CJmyOrCq.min.js +1116 -0
  23. package/dist/vendor-DkMW3WY4.umd.cjs +1116 -0
  24. package/lib/engine/api.d.ts +12 -0
  25. package/lib/engine/api.js +2 -0
  26. package/lib/engine/api.js.map +1 -1
  27. package/lib/engine/debug/debug_environment.js +1 -1
  28. package/lib/engine/debug/debug_environment.js.map +1 -1
  29. package/lib/engine/engine_application.js +8 -6
  30. package/lib/engine/engine_application.js.map +1 -1
  31. package/lib/engine/engine_components.js +5 -1
  32. package/lib/engine/engine_components.js.map +1 -1
  33. package/lib/engine/engine_constants.js +6 -0
  34. package/lib/engine/engine_constants.js.map +1 -1
  35. package/lib/engine/engine_context.d.ts +31 -2
  36. package/lib/engine/engine_context.js +43 -2
  37. package/lib/engine/engine_context.js.map +1 -1
  38. package/lib/engine/engine_context_registry.js +1 -1
  39. package/lib/engine/engine_context_registry.js.map +1 -1
  40. package/lib/engine/engine_init.js +7 -0
  41. package/lib/engine/engine_init.js.map +1 -1
  42. package/lib/engine/engine_input.d.ts +3 -2
  43. package/lib/engine/engine_input.js +3 -2
  44. package/lib/engine/engine_input.js.map +1 -1
  45. package/lib/engine/engine_license.d.ts +2 -0
  46. package/lib/engine/engine_license.js +25 -15
  47. package/lib/engine/engine_license.js.map +1 -1
  48. package/lib/engine/engine_lifecycle_functions_internal.js +5 -0
  49. package/lib/engine/engine_lifecycle_functions_internal.js.map +1 -1
  50. package/lib/engine/engine_networking_blob.d.ts +1 -1
  51. package/lib/engine/engine_networking_blob.js +5 -11
  52. package/lib/engine/engine_networking_blob.js.map +1 -1
  53. package/lib/engine/engine_physics_rapier.d.ts +3 -0
  54. package/lib/engine/engine_physics_rapier.js +13 -10
  55. package/lib/engine/engine_physics_rapier.js.map +1 -1
  56. package/lib/engine/engine_pmrem.js +2 -2
  57. package/lib/engine/engine_pmrem.js.map +1 -1
  58. package/lib/engine/engine_scenedata.d.ts +34 -0
  59. package/lib/engine/engine_scenedata.js +135 -0
  60. package/lib/engine/engine_scenedata.js.map +1 -0
  61. package/lib/engine/engine_ssr.d.ts +18 -0
  62. package/lib/engine/engine_ssr.js +40 -0
  63. package/lib/engine/engine_ssr.js.map +1 -0
  64. package/lib/engine/engine_three_utils.d.ts +14 -7
  65. package/lib/engine/engine_three_utils.js +14 -7
  66. package/lib/engine/engine_three_utils.js.map +1 -1
  67. package/lib/engine/engine_types.d.ts +2 -0
  68. package/lib/engine/engine_types.js.map +1 -1
  69. package/lib/engine/engine_utils.js +4 -2
  70. package/lib/engine/engine_utils.js.map +1 -1
  71. package/lib/engine/engine_utils_hash.d.ts +9 -0
  72. package/lib/engine/engine_utils_hash.js +112 -0
  73. package/lib/engine/engine_utils_hash.js.map +1 -0
  74. package/lib/engine/webcomponents/logo-element.d.ts +10 -1
  75. package/lib/engine/webcomponents/logo-element.js +2 -1
  76. package/lib/engine/webcomponents/logo-element.js.map +1 -1
  77. package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +12 -4
  78. package/lib/engine/webcomponents/needle menu/needle-menu.js +2 -1
  79. package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
  80. package/lib/engine/webcomponents/needle-button.d.ts +15 -1
  81. package/lib/engine/webcomponents/needle-button.js +2 -1
  82. package/lib/engine/webcomponents/needle-button.js.map +1 -1
  83. package/lib/engine/webcomponents/needle-engine.d.ts +7 -1
  84. package/lib/engine/webcomponents/needle-engine.js +2 -1
  85. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  86. package/lib/engine/xr/NeedleXRSession.d.ts +1 -0
  87. package/lib/engine/xr/NeedleXRSession.js +5 -5
  88. package/lib/engine/xr/NeedleXRSession.js.map +1 -1
  89. package/lib/engine/xr/events.d.ts +30 -3
  90. package/lib/engine/xr/events.js +38 -0
  91. package/lib/engine/xr/events.js.map +1 -1
  92. package/lib/engine/xr/init.js +1 -7
  93. package/lib/engine/xr/init.js.map +1 -1
  94. package/lib/engine-components/AnimatorController.d.ts +135 -2
  95. package/lib/engine-components/AnimatorController.js +218 -2
  96. package/lib/engine-components/AnimatorController.js.map +1 -1
  97. package/lib/engine-components/GroundProjection.d.ts +1 -0
  98. package/lib/engine-components/GroundProjection.js +184 -48
  99. package/lib/engine-components/GroundProjection.js.map +1 -1
  100. package/lib/engine-components/Light.d.ts +25 -8
  101. package/lib/engine-components/Light.js +132 -27
  102. package/lib/engine-components/Light.js.map +1 -1
  103. package/lib/engine-components/RigidBody.js +3 -3
  104. package/lib/engine-components/RigidBody.js.map +1 -1
  105. package/lib/engine-components/SceneSwitcher.js +2 -0
  106. package/lib/engine-components/SceneSwitcher.js.map +1 -1
  107. package/lib/engine-components/api.d.ts +1 -0
  108. package/lib/engine-components/api.js +1 -0
  109. package/lib/engine-components/api.js.map +1 -1
  110. package/lib/engine-components/codegen/components.d.ts +1 -0
  111. package/lib/engine-components/codegen/components.js +1 -0
  112. package/lib/engine-components/codegen/components.js.map +1 -1
  113. package/lib/engine-components/postprocessing/Effects/BloomEffect.d.ts +1 -1
  114. package/lib/engine-components/postprocessing/Effects/Sharpening.js +1 -2
  115. package/lib/engine-components/postprocessing/Effects/Sharpening.js.map +1 -1
  116. package/lib/engine-components/postprocessing/PostProcessingHandler.js +5 -6
  117. package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
  118. package/lib/engine-components/web/ScrollFollow.d.ts +0 -1
  119. package/lib/engine-components/web/ScrollFollow.js +3 -2
  120. package/lib/engine-components/web/ScrollFollow.js.map +1 -1
  121. package/lib/needle-engine.d.ts +1 -0
  122. package/lib/needle-engine.js +1 -0
  123. package/lib/needle-engine.js.map +1 -1
  124. package/package.json +7 -5
  125. package/plugins/common/logger.js +42 -19
  126. package/plugins/dts-generator/dts.codegen.js +334 -0
  127. package/plugins/dts-generator/dts.scan.js +99 -0
  128. package/plugins/dts-generator/dts.writer.js +59 -0
  129. package/plugins/dts-generator/glb.discovery.js +279 -0
  130. package/plugins/dts-generator/glb.extractor.js +215 -0
  131. package/plugins/dts-generator/glb.reader.js +167 -0
  132. package/plugins/dts-generator/index.js +36 -0
  133. package/plugins/dts-generator/manifest.types.js +174 -0
  134. package/plugins/types/index.d.ts +2 -1
  135. package/plugins/types/needle-bindings.d.ts +30 -0
  136. package/plugins/types/userconfig.d.ts +21 -2
  137. package/plugins/vite/asap.js +1 -1
  138. package/plugins/vite/dependency-watcher.d.ts +2 -2
  139. package/plugins/vite/dependency-watcher.js +3 -4
  140. package/plugins/vite/drop.d.ts +2 -2
  141. package/plugins/vite/drop.js +3 -4
  142. package/plugins/vite/dts-generator.d.ts +7 -0
  143. package/plugins/vite/dts-generator.js +191 -0
  144. package/plugins/vite/index.d.ts +10 -3
  145. package/plugins/vite/index.js +27 -10
  146. package/plugins/vite/logger.client.js +4 -3
  147. package/plugins/vite/logging.js +2 -2
  148. package/plugins/vite/meta.js +4 -2
  149. package/plugins/vite/poster.d.ts +2 -2
  150. package/plugins/vite/poster.js +3 -5
  151. package/plugins/vite/reload.d.ts +2 -2
  152. package/plugins/vite/reload.js +5 -5
  153. package/src/engine/api.ts +15 -1
  154. package/src/engine/debug/debug_environment.ts +1 -1
  155. package/src/engine/engine_application.ts +8 -6
  156. package/src/engine/engine_components.ts +7 -4
  157. package/src/engine/engine_constants.ts +11 -6
  158. package/src/engine/engine_context.ts +47 -2
  159. package/src/engine/engine_context_registry.ts +1 -1
  160. package/src/engine/engine_init.ts +6 -0
  161. package/src/engine/engine_input.ts +3 -2
  162. package/src/engine/engine_license.ts +23 -19
  163. package/src/engine/engine_lifecycle_functions_internal.ts +7 -0
  164. package/src/engine/engine_networking_blob.ts +5 -11
  165. package/src/engine/engine_physics_rapier.ts +14 -12
  166. package/src/engine/engine_pmrem.ts +3 -3
  167. package/src/engine/engine_scenedata.ts +133 -0
  168. package/src/engine/engine_ssr.ts +48 -0
  169. package/src/engine/engine_three_utils.ts +15 -7
  170. package/src/engine/engine_types.ts +2 -0
  171. package/src/engine/engine_utils.ts +3 -2
  172. package/src/engine/engine_utils_hash.ts +65 -0
  173. package/src/engine/webcomponents/logo-element.ts +10 -1
  174. package/src/engine/webcomponents/needle menu/needle-menu.ts +11 -2
  175. package/src/engine/webcomponents/needle-button.ts +15 -1
  176. package/src/engine/webcomponents/needle-engine.ts +8 -1
  177. package/src/engine/xr/NeedleXRSession.ts +6 -6
  178. package/src/engine/xr/events.ts +44 -1
  179. package/src/engine/xr/init.ts +0 -7
  180. package/src/engine-components/AnimatorController.ts +286 -4
  181. package/src/engine-components/GroundProjection.ts +226 -52
  182. package/src/engine-components/Light.ts +132 -27
  183. package/src/engine-components/RigidBody.ts +3 -3
  184. package/src/engine-components/SceneSwitcher.ts +1 -0
  185. package/src/engine-components/api.ts +1 -0
  186. package/src/engine-components/codegen/components.ts +1 -0
  187. package/src/engine-components/postprocessing/Effects/BloomEffect.ts +1 -1
  188. package/src/engine-components/postprocessing/Effects/Sharpening.ts +1 -2
  189. package/src/engine-components/postprocessing/PostProcessingHandler.ts +4 -8
  190. package/src/engine-components/web/ScrollFollow.ts +2 -2
  191. package/src/needle-engine.ts +2 -0
  192. package/src/vite-env.d.ts +16 -0
  193. package/dist/needle-engine.bundle-qDahLTqW.min.js +0 -1656
  194. package/dist/vendor-CEM38hLE.umd.cjs +0 -1116
  195. 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);
@@ -4376,8 +4504,12 @@ export declare class Context implements IContext {
4376
4504
  connection: NetworkConnection;
4377
4505
  /** @deprecated AssetDatabase is deprecated */
4378
4506
  assets: AssetDatabase;
4379
- /** The main light in the scene */
4380
- mainLight: ILight | null;
4507
+ /** All registered lights in the scene, maintained by the Light component */
4508
+ readonly lights: Set<ILight>;
4509
+ /** The brightest registered directional light, or null if none are registered
4510
+ * @see lights
4511
+ */
4512
+ get mainLight(): ILight | null;
4381
4513
  /** @deprecated Use sceneLighting */
4382
4514
  get rendererData(): RendererData;
4383
4515
  /** Access the scene lighting manager to control lighting settings in the context */
@@ -7027,6 +7159,20 @@ export declare function getPeerOptions(): PeerJSOption | undefined;
7027
7159
 
7028
7160
  export declare function getResourceUserCount(object: object): number | undefined;
7029
7161
 
7162
+ /**
7163
+ * Returns a lazily-resolved proxy typed as {@link SceneData}.
7164
+ * The proxy is cached per context — each context gets exactly one instance.
7165
+ *
7166
+ * Shape mirrors the generated `needle-bindings.gen.d.ts`:
7167
+ * ctx.sceneData.MyGlb.Camera.$components.OrbitControls.autoRotate = true;
7168
+ * ctx.sceneData.MyGlb.Camera.$object // → THREE.Camera
7169
+ * ctx.sceneData.MyGlb.UI.Button.$components.Button // → Needle Button component
7170
+ *
7171
+ * GLB name is ignored at runtime (scene is already loaded).
7172
+ * Node lookup starts at the scene root.
7173
+ */
7174
+ export declare function getSceneData(ctx: IContext): SceneData;
7175
+
7030
7176
  export declare function getTempColor(color?: Color): Color;
7031
7177
 
7032
7178
  /**
@@ -7357,13 +7503,20 @@ export declare class GraphicRaycaster extends ObjectRaycaster {
7357
7503
  * Utility class to perform various graphics operations like copying textures to canvas
7358
7504
  */
7359
7505
  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;
7506
+ private static _planeGeometry;
7507
+ private static _renderer;
7508
+ private static _perspectiveCam;
7509
+ private static _orthographicCam;
7510
+ private static _scene;
7511
+ private static _blitMaterial;
7512
+ private static _mesh;
7513
+ private static get planeGeometry();
7514
+ private static get renderer();
7515
+ private static get perspectiveCam();
7516
+ private static get orthographicCam();
7517
+ private static get scene();
7518
+ private static get blitMaterial();
7519
+ private static get mesh();
7367
7520
  /**
7368
7521
  * Copy a texture to a new texture
7369
7522
  * @param texture the texture to copy
@@ -7516,6 +7669,7 @@ export declare class GroundProjectedEnv extends Component {
7516
7669
  updateProjection(): void;
7517
7670
  private _blurrynessShader;
7518
7671
  private _lastBlurriness;
7672
+ private updateProjectionMaterial;
7519
7673
  private updateBlurriness;
7520
7674
  }
7521
7675
 
@@ -7826,6 +7980,9 @@ export declare class HoverAnimation extends Component {
7826
7980
  private playHover;
7827
7981
  }
7828
7982
 
7983
+ /** SSR-safe base class for web components. */
7984
+ declare const HTMLElementBase: typeof HTMLElement;
7985
+
7829
7986
  export declare type IAnimationComponent = Pick<IComponent, "gameObject"> & {
7830
7987
  isAnimationComponent: boolean;
7831
7988
  addClip?(clip: AnimationClip): any;
@@ -8085,6 +8242,8 @@ declare interface ILayoutGroup extends IComponent {
8085
8242
  export declare interface ILight extends IComponent {
8086
8243
  intensity: number;
8087
8244
  color: Color;
8245
+ /** The type of light as a lowercase string: `"directional"`, `"point"`, `"spot"` */
8246
+ readonly type: "directional" | "point" | "spot";
8088
8247
  }
8089
8248
 
8090
8249
  declare interface ILightDataRegistry {
@@ -8301,6 +8460,10 @@ export declare class InheritVelocityModule {
8301
8460
  applyCurrent(vel: Vector3 | Vector3_2, t01: number, lerpFactor: number): void;
8302
8461
  }
8303
8462
 
8463
+ /** Register the Rapier physics backend. Called from {@link initEngine}
8464
+ * to ensure it runs regardless of tree-shaking. */
8465
+ export declare function initPhysics(): void;
8466
+
8304
8467
  /**
8305
8468
  * Handles all input events including mouse, touch, keyboard, and XR controllers.
8306
8469
  * Access via `this.context.input` from any component.
@@ -9591,6 +9754,9 @@ declare const enum KeyboardEnumType {
9591
9754
  KeyPressed = "keypress"
9592
9755
  }
9593
9756
 
9757
+ /** SSR-safe base class for keyboard events. */
9758
+ declare const KeyboardEventBase: typeof KeyboardEvent;
9759
+
9594
9760
  declare type KeyboardEventListener = (evt: NEKeyboardEvent) => void;
9595
9761
 
9596
9762
  declare type KeyboardEventNames = EnumToPrimitiveUnion<KeyboardEnumType>;
@@ -9715,10 +9881,13 @@ declare type LifecycleMethodOptions = {
9715
9881
  */
9716
9882
  export declare class Light extends Component implements ILight {
9717
9883
  /**
9718
- * The type of light (spot, directional, point, etc.)
9719
- * Can not be changed at runtime.
9884
+ * The type of light as a lowercase string: `"directional"`, `"point"`, `"spot"`.
9885
+ * Implements {@link ILight.type}. Can not be changed at runtime.
9720
9886
  */
9721
- private type;
9887
+ get type(): ILight["type"];
9888
+ /** Numeric LightType serialized from Unity/Blender — converts to string on write */
9889
+ set type(value: LightType | ILight["type"]);
9890
+ private _type;
9722
9891
  /**
9723
9892
  * The maximum distance the light affects.
9724
9893
  * Only applicable for spot and point lights.
@@ -9798,6 +9967,19 @@ export declare class Light extends Component implements ILight {
9798
9967
  get shadowResolution(): number;
9799
9968
  set shadowResolution(val: number);
9800
9969
  private _shadowResolution?;
9970
+ /**
9971
+ * Number of shadow cascade levels (only used when `useCascades` is true)
9972
+ */
9973
+ cascades: number;
9974
+ /**
9975
+ * Cascade split mode (only used when `useCascades` is true):
9976
+ * - `practical` — balanced (default, recommended)
9977
+ * - `logarithmic` — more resolution close up
9978
+ * - `uniform` — equal splits
9979
+ */
9980
+ cascadeMode: "practical" | "logarithmic" | "uniform";
9981
+ private _csm?;
9982
+ private _csmHelper?;
9801
9983
  /**
9802
9984
  * Whether this light's illumination is entirely baked into lightmaps
9803
9985
  */
@@ -9819,16 +10001,12 @@ export declare class Light extends Component implements ILight {
9819
10001
  awake(): void;
9820
10002
  onEnable(): void;
9821
10003
  onDisable(): void;
10004
+ onBeforeRender(): void;
9822
10005
  /**
9823
10006
  * Creates the appropriate three.js light based on the configured light type
9824
10007
  * and applies all settings like shadows, intensity, and color.
9825
10008
  */
9826
10009
  createLight(): void;
9827
- /**
9828
- * Coroutine that updates the main light reference in the context
9829
- * if this directional light should be the main light
9830
- */
9831
- updateMainLightRoutine(): Generator<undefined, void, unknown>;
9832
10010
  /**
9833
10011
  * Controls whether the renderer's shadow map type can be changed when soft shadows are used
9834
10012
  */
@@ -9844,6 +10022,11 @@ export declare class Light extends Component implements ILight {
9844
10022
  * When the rig is scaled, world-space distances change proportionally
9845
10023
  * causing lights to appear brighter or dimmer due to distance falloff. */
9846
10024
  private applyXRScale;
10025
+ /**
10026
+ * Creates and initializes a CSM instance for this directional light.
10027
+ * CSM manages its own cascade DirectionalLights internally.
10028
+ */
10029
+ private createCSM;
9847
10030
  /**
9848
10031
  * Configures a directional light by adding and positioning its target
9849
10032
  * @param dirLight The directional light to set up
@@ -9877,6 +10060,25 @@ declare enum LightShadows {
9877
10060
  Soft = 2
9878
10061
  }
9879
10062
 
10063
+ /**
10064
+ * Defines the type of light in a scene.
10065
+ * @see {@link Light} for configuring light properties and behavior
10066
+ */
10067
+ declare enum LightType {
10068
+ /** Spot light that emits light in a cone shape */
10069
+ Spot = 0,
10070
+ /** Directional light that emits parallel light rays in a specific direction */
10071
+ Directional = 1,
10072
+ /** Point light that emits light in all directions from a single point */
10073
+ Point = 2,
10074
+ /** Area light */
10075
+ Area = 3,
10076
+ /** Rectangle shaped area light that only affects baked lightmaps and light probes */
10077
+ Rectangle = 3,
10078
+ /** Disc shaped area light that only affects baked lightmaps and light probes */
10079
+ Disc = 4
10080
+ }
10081
+
9880
10082
  export declare class LimitVelocityOverLifetimeModule {
9881
10083
  enabled: boolean;
9882
10084
  dampen: number;
@@ -10864,6 +11066,25 @@ export declare type MouseButtonName = "left" | "right" | "middle";
10864
11066
 
10865
11067
  /* Excluded from this release type: nameofFactory */
10866
11068
 
11069
+ /**
11070
+ * Global proxy for the primary Needle Engine context.
11071
+ * Resolves lazily on property access via `ContextRegistry.Current` —
11072
+ * safe to import at module level, including in SSR environments
11073
+ * (returns a silent error proxy when no context is active).
11074
+ *
11075
+ * Use this outside of Needle component lifecycle (e.g. in Svelte/React/Vue
11076
+ * components, button handlers, or vanilla JS) instead of threading `ctx` around.
11077
+ *
11078
+ * For multiple `<needle-engine>` elements on the same page, use `ctx` directly.
11079
+ *
11080
+ * @example
11081
+ * import { needle } from "@needle-tools/engine";
11082
+ * button.onclick = () => {
11083
+ * needle.sceneData.Camera.OrbitControls.autoRotate = true;
11084
+ * };
11085
+ */
11086
+ export declare const needle: IContext;
11087
+
10867
11088
  declare class NEEDLE_components implements GLTFLoaderPlugin {
10868
11089
  get name(): string;
10869
11090
  exportContext: {
@@ -10997,7 +11218,7 @@ export { NEEDLE_progressive }
10997
11218
  * @see {@link NeedleEngineWebComponent} for the main &lt;needle-engine&gt; element
10998
11219
  * @see {@link NeedleMenu} for the built-in menu component that can display similar buttons
10999
11220
  */
11000
- export declare class NeedleButtonElement extends HTMLElement {
11221
+ export declare class NeedleButtonElement extends HTMLElementBase {
11001
11222
  #private;
11002
11223
  static observedAttributes: string[];
11003
11224
  constructor();
@@ -11137,7 +11358,7 @@ export declare namespace NeedleEngineModelLoader {
11137
11358
  * @see {@link NeedleButtonElement} for adding AR/VR/Quicklook buttons via &lt;needle-button&gt;
11138
11359
  * @see {@link NeedleMenu} for the built-in menu configuration component
11139
11360
  */
11140
- export declare class NeedleEngineWebComponent extends HTMLElement implements INeedleEngineComponent {
11361
+ export declare class NeedleEngineWebComponent extends HTMLElementBase implements INeedleEngineComponent {
11141
11362
  static get observedAttributes(): string[];
11142
11363
  get loadingProgress01(): number;
11143
11364
  get loadingFinished(): boolean;
@@ -12110,7 +12331,7 @@ export declare class NeedleXRUtils {
12110
12331
  }): void;
12111
12332
  }
12112
12333
 
12113
- export declare class NEKeyboardEvent extends KeyboardEvent {
12334
+ export declare class NEKeyboardEvent extends KeyboardEventBase {
12114
12335
  source?: Event;
12115
12336
  constructor(type: InputEvents, source: Event, init: KeyboardEventInit);
12116
12337
  stopImmediatePropagation(): void;
@@ -12134,7 +12355,7 @@ export declare class NEKeyboardEvent extends KeyboardEvent {
12134
12355
  * @see {@link Input} for the input management system
12135
12356
  * @see {@link PointerType} for available pointer types
12136
12357
  */
12137
- export declare class NEPointerEvent extends PointerEvent {
12358
+ export declare class NEPointerEvent extends PointerEventBase {
12138
12359
  /**
12139
12360
  * Spatial input data
12140
12361
  */
@@ -12900,6 +13121,12 @@ export declare class ObjectUtils {
12900
13121
  private static applyDefaultObjectOptions;
12901
13122
  }
12902
13123
 
13124
+ /**
13125
+ * Remove a listener for before an XR session is requested
13126
+ * @param fn The function to remove from the listeners
13127
+ */
13128
+ export declare function offBeforeXRSession(fn: (args: XRSessionRequestEventArgs) => void): void;
13129
+
12903
13130
  /* Excluded from this release type: OffscreenCanvasExt */
12904
13131
 
12905
13132
  /**
@@ -13004,6 +13231,21 @@ export declare function onAfterRender(cb: LifecycleMethod, opts?: LifecycleMetho
13004
13231
  * */
13005
13232
  export declare function onBeforeRender(cb: LifecycleMethod, opts?: LifecycleMethodOptions): () => void;
13006
13233
 
13234
+ /**
13235
+ * Add a listener that fires before an XR session is requested.
13236
+ * Use this to modify the session init options, e.g. to add optional features like `camera-access`.
13237
+ * @param fn The function to call before the XR session is requested
13238
+ * @example
13239
+ * ```js
13240
+ * onBeforeXRSession((args) => {
13241
+ * args.init.optionalFeatures ??= [];
13242
+ * args.init.optionalFeatures.push("camera-access");
13243
+ * });
13244
+ * ```
13245
+ * @return A function to remove the listener
13246
+ */
13247
+ export declare function onBeforeXRSession(fn: (args: XRSessionRequestEventArgs) => void): () => void;
13248
+
13007
13249
  /**
13008
13250
  * Register a callback before the engine context is cleared.
13009
13251
  * This happens if e.g. `<needle-engine src>` changes
@@ -13225,8 +13467,9 @@ export declare function onUpdate(cb: LifecycleMethod, opts?: LifecycleMethodOpti
13225
13467
  * console.log("XR session ended", evt);
13226
13468
  * });
13227
13469
  * ```
13470
+ * @returns A function to remove the listener
13228
13471
  */
13229
- export declare function onXRSessionEnd(fn: (evt: XRSessionEventArgs) => void): void;
13472
+ export declare function onXRSessionEnd(fn: (evt: XRSessionEventArgs) => void): () => void;
13230
13473
 
13231
13474
  /**
13232
13475
  * Add a listener for when an XR session starts
@@ -13238,8 +13481,9 @@ export declare function onXRSessionEnd(fn: (evt: XRSessionEventArgs) => void): v
13238
13481
  * console.log("XR session started", evt);
13239
13482
  * });
13240
13483
  * ```
13484
+ * @returns A function to remove the listener
13241
13485
  */
13242
- export declare function onXRSessionStart(fn: (evt: XRSessionEventArgs) => void): void;
13486
+ export declare function onXRSessionStart(fn: (evt: XRSessionEventArgs) => void): () => void;
13243
13487
 
13244
13488
  /**
13245
13489
  * OpenURL behaviour opens a URL in a new tab or window when the object (or any if it's children) is clicked.
@@ -14943,6 +15187,9 @@ export declare class OrbitControls extends Component implements ICameraControlle
14943
15187
  PointerMove = "pointermove"
14944
15188
  }
14945
15189
 
15190
+ /** SSR-safe base class for pointer events. */
15191
+ declare const PointerEventBase: typeof PointerEvent;
15192
+
14946
15193
  /** [PointerEventData](https://engine.needle.tools/docs/api/PointerEventData) This pointer event data object is passed to all event receivers that are currently active
14947
15194
  * It contains hit information if an object was hovered or clicked
14948
15195
  * 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 +17077,8 @@ export declare class OrbitControls extends Component implements ICameraControlle
16830
17077
  */
16831
17078
  declare type ScaleClipType = "linear" | "spring";
16832
17079
 
17080
+ export { SceneData }
17081
+
16833
17082
  export declare class SceneLightSettings extends Component {
16834
17083
  ambientMode: AmbientMode;
16835
17084
  ambientLight?: Color;
@@ -17977,6 +18226,7 @@ export declare class OrbitControls extends Component implements ICameraControlle
17977
18226
  export declare type SessionRequestedEvent = (args: {
17978
18227
  readonly mode: XRSessionMode;
17979
18228
  readonly init: XRSessionInit;
18229
+ readonly context: Context;
17980
18230
  }) => void;
17981
18231
 
17982
18232
  export declare function setActive(go: Object3D, active: boolean | number): boolean;
@@ -19614,6 +19864,24 @@ export declare class OrbitControls extends Component implements ICameraControlle
19614
19864
  instance?: StateMachineBehaviour;
19615
19865
  };
19616
19866
 
19867
+ /**
19868
+ * Configuration for an animation state in the builder
19869
+ */
19870
+ export declare type StateOptions = {
19871
+ /** The animation clip for this state */
19872
+ clip: AnimationClip;
19873
+ /** Whether the animation should loop (default: false) */
19874
+ loop?: boolean;
19875
+ /** Base speed multiplier (default: 1) */
19876
+ speed?: number;
19877
+ /** Name of a float parameter to multiply with speed */
19878
+ speedParameter?: string;
19879
+ /** Normalized cycle offset 0-1 (default: 0) */
19880
+ cycleOffset?: number;
19881
+ /** Name of a float parameter to use as cycle offset */
19882
+ cycleOffsetParameter?: string;
19883
+ };
19884
+
19617
19885
  declare type StickName = "xr-standard-thumbstick" | "xr-standard-touchpad";
19618
19886
 
19619
19887
  export declare class StreamEndedEvent {
@@ -20712,6 +20980,22 @@ export declare class OrbitControls extends Component implements ICameraControlle
20712
20980
  Animation = 3
20713
20981
  }
20714
20982
 
20983
+ /**
20984
+ * Configuration for a transition in the builder
20985
+ */
20986
+ export declare type TransitionOptions = {
20987
+ /** Duration of the crossfade in seconds (default: 0) */
20988
+ duration?: number;
20989
+ /** Normalized exit time 0-1 (default: 1). Only used when hasExitTime is true */
20990
+ exitTime?: number;
20991
+ /** Whether the transition waits for exitTime before transitioning (default: false) */
20992
+ hasExitTime?: boolean;
20993
+ /** Normalized offset into the destination state's animation (default: 0) */
20994
+ offset?: number;
20995
+ /** Whether duration is in seconds (true) or normalized (false) (default: false) */
20996
+ hasFixedDuration?: boolean;
20997
+ };
20998
+
20715
20999
  export declare class TriggerBuilder {
20716
21000
  private static __sceneStartTrigger?;
20717
21001
  static sceneStartTrigger(): TriggerModel;
@@ -23231,6 +23515,12 @@ export declare class OrbitControls extends Component implements ICameraControlle
23231
23515
  session: NeedleXRSession;
23232
23516
  };
23233
23517
 
23518
+ export declare type XRSessionRequestEventArgs = {
23519
+ readonly mode: XRSessionMode;
23520
+ readonly init: XRSessionInit;
23521
+ readonly context: Context;
23522
+ };
23523
+
23234
23524
  export declare class XRState {
23235
23525
  static Global: XRState;
23236
23526
  Mask: XRStateFlag;