@needle-tools/engine 5.1.0-canary.db0c38f → 5.1.0-canary.deec6e4

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 (106) hide show
  1. package/.needle/generated/needle-bindings.gen.d.ts +5 -0
  2. package/CHANGELOG.md +34 -0
  3. package/components.needle.json +1 -1
  4. package/dist/{needle-engine.bundle-YnpzzOPL.min.js → needle-engine.bundle-1s2gOoKZ.min.js} +144 -144
  5. package/dist/{needle-engine.bundle-B29kieh0.js → needle-engine.bundle-CvtELXh0.js} +6650 -6584
  6. package/dist/{needle-engine.bundle-Dq0Ly8fW.umd.cjs → needle-engine.bundle-j4nGJXCs.umd.cjs} +138 -138
  7. package/dist/needle-engine.d.ts +101 -89
  8. package/dist/needle-engine.js +188 -186
  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 +1 -1
  12. package/lib/engine/debug/debug_spatial_console.d.ts +2 -0
  13. package/lib/engine/debug/debug_spatial_console.js +10 -7
  14. package/lib/engine/debug/debug_spatial_console.js.map +1 -1
  15. package/lib/engine/engine_addressables.d.ts +2 -0
  16. package/lib/engine/engine_addressables.js +6 -3
  17. package/lib/engine/engine_addressables.js.map +1 -1
  18. package/lib/engine/engine_context.d.ts +21 -20
  19. package/lib/engine/engine_context.js +25 -14
  20. package/lib/engine/engine_context.js.map +1 -1
  21. package/lib/engine/engine_init.js +15 -0
  22. package/lib/engine/engine_init.js.map +1 -1
  23. package/lib/engine/engine_license.d.ts +2 -0
  24. package/lib/engine/engine_license.js +14 -6
  25. package/lib/engine/engine_license.js.map +1 -1
  26. package/lib/engine/engine_lifecycle_functions_internal.js +5 -0
  27. package/lib/engine/engine_lifecycle_functions_internal.js.map +1 -1
  28. package/lib/engine/engine_pmrem.js +2 -2
  29. package/lib/engine/engine_pmrem.js.map +1 -1
  30. package/lib/engine/engine_scenedata.d.ts +13 -17
  31. package/lib/engine/engine_scenedata.js +56 -29
  32. package/lib/engine/engine_scenedata.js.map +1 -1
  33. package/lib/engine/engine_serialization_builtin_serializer.d.ts +10 -16
  34. package/lib/engine/engine_serialization_builtin_serializer.js +28 -41
  35. package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
  36. package/lib/engine/engine_ssr.d.ts +2 -0
  37. package/lib/engine/engine_ssr.js +20 -0
  38. package/lib/engine/engine_ssr.js.map +1 -1
  39. package/lib/engine/engine_types.d.ts +2 -0
  40. package/lib/engine/engine_types.js.map +1 -1
  41. package/lib/engine/webcomponents/jsx.d.ts +51 -0
  42. package/lib/engine/webcomponents/logo-element.js.map +1 -1
  43. package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +2 -3
  44. package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
  45. package/lib/engine/webcomponents/needle-button.js.map +1 -1
  46. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  47. package/lib/engine-components/AnimatorController.d.ts +2 -0
  48. package/lib/engine-components/AnimatorController.js +4 -1
  49. package/lib/engine-components/AnimatorController.js.map +1 -1
  50. package/lib/engine-components/Light.d.ts +6 -8
  51. package/lib/engine-components/Light.js +40 -27
  52. package/lib/engine-components/Light.js.map +1 -1
  53. package/lib/engine-components/ReflectionProbe.js +2 -0
  54. package/lib/engine-components/ReflectionProbe.js.map +1 -1
  55. package/lib/engine-components/postprocessing/VolumeParameter.d.ts +2 -0
  56. package/lib/engine-components/postprocessing/VolumeParameter.js +4 -1
  57. package/lib/engine-components/postprocessing/VolumeParameter.js.map +1 -1
  58. package/lib/needle-engine.d.ts +2 -0
  59. package/lib/needle-engine.js +2 -0
  60. package/lib/needle-engine.js.map +1 -1
  61. package/package.json +3 -2
  62. package/plugins/dts-generator/dts.codegen.js +255 -50
  63. package/plugins/dts-generator/dts.scan.js +37 -9
  64. package/plugins/dts-generator/dts.writer.js +1 -1
  65. package/plugins/dts-generator/glb.discovery.js +140 -23
  66. package/plugins/dts-generator/glb.extractor.js +48 -8
  67. package/plugins/dts-generator/glb.reader.js +80 -27
  68. package/plugins/dts-generator/index.js +1 -1
  69. package/plugins/types/needle-bindings.d.ts +25 -14
  70. package/plugins/types/userconfig.d.ts +12 -0
  71. package/plugins/vite/asap.js +1 -1
  72. package/plugins/vite/dependency-watcher.d.ts +2 -2
  73. package/plugins/vite/dependency-watcher.js +3 -4
  74. package/plugins/vite/drop.d.ts +2 -2
  75. package/plugins/vite/drop.js +3 -4
  76. package/plugins/vite/dts-generator.d.ts +2 -2
  77. package/plugins/vite/dts-generator.js +43 -9
  78. package/plugins/vite/index.d.ts +9 -3
  79. package/plugins/vite/index.js +23 -10
  80. package/plugins/vite/meta.js +4 -2
  81. package/plugins/vite/poster.d.ts +2 -2
  82. package/plugins/vite/poster.js +3 -5
  83. package/plugins/vite/reload.d.ts +2 -2
  84. package/plugins/vite/reload.js +22 -22
  85. package/src/engine/api.ts +1 -1
  86. package/src/engine/debug/debug_spatial_console.ts +10 -7
  87. package/src/engine/engine_addressables.ts +6 -3
  88. package/src/engine/engine_context.ts +34 -20
  89. package/src/engine/engine_init.ts +14 -0
  90. package/src/engine/engine_license.ts +12 -10
  91. package/src/engine/engine_lifecycle_functions_internal.ts +7 -0
  92. package/src/engine/engine_pmrem.ts +3 -3
  93. package/src/engine/engine_scenedata.ts +53 -27
  94. package/src/engine/engine_serialization_builtin_serializer.ts +32 -43
  95. package/src/engine/engine_ssr.ts +29 -3
  96. package/src/engine/engine_types.ts +2 -0
  97. package/src/engine/webcomponents/jsx.d.ts +51 -0
  98. package/src/engine/webcomponents/logo-element.ts +1 -0
  99. package/src/engine/webcomponents/needle menu/needle-menu.ts +2 -1
  100. package/src/engine/webcomponents/needle-button.ts +1 -0
  101. package/src/engine/webcomponents/needle-engine.ts +1 -0
  102. package/src/engine-components/AnimatorController.ts +4 -1
  103. package/src/engine-components/Light.ts +40 -26
  104. package/src/engine-components/ReflectionProbe.ts +2 -0
  105. package/src/engine-components/postprocessing/VolumeParameter.ts +4 -1
  106. package/src/needle-engine.ts +3 -0
@@ -3623,7 +3623,7 @@ declare class ColorSerializer extends TypeSerializer {
3623
3623
  onSerialize(data: any): any | void;
3624
3624
  }
3625
3625
 
3626
- export declare const colorSerializer: ColorSerializer;
3626
+ export declare let colorSerializer: ColorSerializer;
3627
3627
 
3628
3628
  /**
3629
3629
  * Utility method to check if two materials were created from the same glTF material
@@ -4097,7 +4097,7 @@ declare class ComponentSerializer extends TypeSerializer {
4097
4097
  findObjectForGuid(guid: string, root: Object3D): any;
4098
4098
  }
4099
4099
 
4100
- export declare const componentSerializer: ComponentSerializer;
4100
+ export declare let componentSerializer: ComponentSerializer;
4101
4101
 
4102
4102
  declare type ComponentType = "button" | "thumbstick" | "squeeze" | "touchpad";
4103
4103
 
@@ -4460,13 +4460,14 @@ export declare class Context implements IContext {
4460
4460
  * Use `setCurrentCamera` for updating the main camera.
4461
4461
  */
4462
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.
4463
+ * Access your scene's full hierarchy, objects, and components directly by name with full autocomplete.
4464
+ * Types are generated automatically from your GLB files when the dev server starts.
4466
4465
  *
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)`.
4466
+ * You can store references to objects or components for later use.
4467
+ * Note that the scene hierarchy can change at runtime (e.g. when objects are added, removed, or re-parented),
4468
+ * in which case stored references may become stale.
4469
+ *
4470
+ * @experimental This API may change in future versions.
4470
4471
  *
4471
4472
  * @example
4472
4473
  * // Toggle auto-rotate on the orbit camera
@@ -4475,12 +4476,6 @@ export declare class Context implements IContext {
4475
4476
  * @example
4476
4477
  * // Change the background color
4477
4478
  * 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
4479
  */
4485
4480
  get sceneData(): SceneData;
4486
4481
  get mainCamera(): Camera_2;
@@ -4504,15 +4499,21 @@ export declare class Context implements IContext {
4504
4499
  connection: NetworkConnection;
4505
4500
  /** @deprecated AssetDatabase is deprecated */
4506
4501
  assets: AssetDatabase;
4507
- /** The main light in the scene */
4508
- mainLight: ILight | null;
4502
+ /** All registered lights in the scene, maintained by the Light component.
4503
+ * @see mainLight for accessing the main directional light in the scene
4504
+ */
4505
+ readonly lights: ILight[];
4506
+ /** The brightest registered directional light, or null if none are registered
4507
+ * @see lights
4508
+ */
4509
+ get mainLight(): ILight | null;
4509
4510
  /** @deprecated Use sceneLighting */
4510
- get rendererData(): RendererData;
4511
+ private get rendererData();
4511
4512
  /** Access the scene lighting manager to control lighting settings in the context */
4512
- sceneLighting: RendererData;
4513
- addressables: Addressables;
4514
- lightmaps: ILightDataRegistry;
4515
- players: PlayerViewManager;
4513
+ readonly sceneLighting: RendererData;
4514
+ readonly addressables: Addressables;
4515
+ readonly lightmaps: ILightDataRegistry;
4516
+ readonly players: PlayerViewManager;
4516
4517
  /** Access the LODs manager to control LOD behavior in the context */
4517
4518
  readonly lodsManager: LODsManager;
4518
4519
  /** Access the needle menu to add or remove buttons to the menu element */
@@ -5919,19 +5920,6 @@ export declare class EnvironmentScene extends Scene {
5919
5920
  createAreaLightMaterial(intensity: number): MeshBasicMaterial;
5920
5921
  }
5921
5922
 
5922
- export declare const euler: EulerSerializer;
5923
-
5924
- declare class EulerSerializer extends TypeSerializer {
5925
- constructor();
5926
- onDeserialize(data: any, _context: SerializationContext): Euler | undefined;
5927
- onSerialize(data: any, _context: SerializationContext): {
5928
- x: any;
5929
- y: any;
5930
- z: any;
5931
- order: any;
5932
- };
5933
- }
5934
-
5935
5923
  /**
5936
5924
  * EventList manages a list of callbacks that can be invoked together.
5937
5925
  * Used for Unity-style events that can be configured in the editor (Unity or Blender).
@@ -6064,7 +6052,7 @@ declare class EventListSerializer extends TypeSerializer {
6064
6052
  onDeserialize(data: EventListData, context: SerializationContext): EventList<any> | undefined | null;
6065
6053
  }
6066
6054
 
6067
- export declare const eventListSerializer: EventListSerializer;
6055
+ export declare let eventListSerializer: EventListSerializer;
6068
6056
 
6069
6057
  /**
6070
6058
  * [EventSystem](https://engine.needle.tools/docs/api/EventSystem) is responsible for managing and dispatching input events to UI components within the scene.
@@ -7159,16 +7147,13 @@ export declare function getResourceUserCount(object: object): number | undefined
7159
7147
  * Returns a lazily-resolved proxy typed as {@link SceneData}.
7160
7148
  * The proxy is cached per context — each context gets exactly one instance.
7161
7149
  *
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
7150
+ * Shape mirrors the generated `needle-bindings.gen.d.ts`:
7151
+ * ctx.sceneData.MyGlb.Camera.$components.OrbitControls.autoRotate = true;
7152
+ * ctx.sceneData.MyGlb.Camera.$object //THREE.Camera
7153
+ * ctx.sceneData.MyGlb.UI.Button.$components.Button //Needle Button component
7166
7154
  *
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;
7155
+ * GLB name is ignored at runtime (scene is already loaded).
7156
+ * Node lookup starts at the scene root.
7172
7157
  */
7173
7158
  export declare function getSceneData(ctx: IContext): SceneData;
7174
7159
 
@@ -8241,6 +8226,8 @@ declare interface ILayoutGroup extends IComponent {
8241
8226
  export declare interface ILight extends IComponent {
8242
8227
  intensity: number;
8243
8228
  color: Color;
8229
+ /** The type of light as a lowercase string: `"directional"`, `"point"`, `"spot"` */
8230
+ readonly type: "directional" | "point" | "spot";
8244
8231
  }
8245
8232
 
8246
8233
  declare interface ILightDataRegistry {
@@ -8457,10 +8444,20 @@ export declare class InheritVelocityModule {
8457
8444
  applyCurrent(vel: Vector3 | Vector3_2, t01: number, lerpFactor: number): void;
8458
8445
  }
8459
8446
 
8447
+ /* Excluded from this release type: initAddressableSerializers */
8448
+
8449
+ /** Register all builtin serializers and prototype patches.
8450
+ * Must be called from {@link initEngine} so the registrations survive tree-shaking
8451
+ * when the package declares `sideEffects: false`.
8452
+ */
8453
+ export declare function initBuiltinSerializers(): void;
8454
+
8460
8455
  /** Register the Rapier physics backend. Called from {@link initEngine}
8461
8456
  * to ensure it runs regardless of tree-shaking. */
8462
8457
  export declare function initPhysics(): void;
8463
8458
 
8459
+ /* Excluded from this release type: initVolumeParameterSerializer */
8460
+
8464
8461
  /**
8465
8462
  * Handles all input events including mouse, touch, keyboard, and XR controllers.
8466
8463
  * Access via `this.context.input` from any component.
@@ -9878,10 +9875,13 @@ declare type LifecycleMethodOptions = {
9878
9875
  */
9879
9876
  export declare class Light extends Component implements ILight {
9880
9877
  /**
9881
- * The type of light (spot, directional, point, etc.)
9882
- * Can not be changed at runtime.
9878
+ * The type of light as a lowercase string: `"directional"`, `"point"`, `"spot"`.
9879
+ * Implements {@link ILight.type}. Can not be changed at runtime.
9883
9880
  */
9884
- private type;
9881
+ get type(): ILight["type"];
9882
+ /** Numeric LightType serialized from Unity/Blender — converts to string on write */
9883
+ set type(value: LightType | ILight["type"]);
9884
+ private _type;
9885
9885
  /**
9886
9886
  * The maximum distance the light affects.
9887
9887
  * Only applicable for spot and point lights.
@@ -9987,11 +9987,6 @@ export declare class Light extends Component implements ILight {
9987
9987
  * and applies all settings like shadows, intensity, and color.
9988
9988
  */
9989
9989
  createLight(): void;
9990
- /**
9991
- * Coroutine that updates the main light reference in the context
9992
- * if this directional light should be the main light
9993
- */
9994
- updateMainLightRoutine(): Generator<undefined, void, unknown>;
9995
9990
  /**
9996
9991
  * Controls whether the renderer's shadow map type can be changed when soft shadows are used
9997
9992
  */
@@ -10040,6 +10035,25 @@ declare enum LightShadows {
10040
10035
  Soft = 2
10041
10036
  }
10042
10037
 
10038
+ /**
10039
+ * Defines the type of light in a scene.
10040
+ * @see {@link Light} for configuring light properties and behavior
10041
+ */
10042
+ declare enum LightType {
10043
+ /** Spot light that emits light in a cone shape */
10044
+ Spot = 0,
10045
+ /** Directional light that emits parallel light rays in a specific direction */
10046
+ Directional = 1,
10047
+ /** Point light that emits light in all directions from a single point */
10048
+ Point = 2,
10049
+ /** Area light */
10050
+ Area = 3,
10051
+ /** Rectangle shaped area light that only affects baked lightmaps and light probes */
10052
+ Rectangle = 3,
10053
+ /** Disc shaped area light that only affects baked lightmaps and light probes */
10054
+ Disc = 4
10055
+ }
10056
+
10043
10057
  export declare class LimitVelocityOverLifetimeModule {
10044
10058
  enabled: boolean;
10045
10059
  dampen: number;
@@ -11028,15 +11042,13 @@ export declare type MouseButtonName = "left" | "right" | "middle";
11028
11042
  /* Excluded from this release type: nameofFactory */
11029
11043
 
11030
11044
  /**
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).
11045
+ * Quick access to the current Needle Engine context from anywhere — no need to pass `ctx` around.
11046
+ * Use it in React/Svelte/Vue components, button handlers, or plain JavaScript.
11035
11047
  *
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.
11048
+ * Safe to import at module level, including in SSR environments.
11049
+ * For pages with multiple `<needle-engine>` elements, use `ctx` directly instead.
11038
11050
  *
11039
- * For multiple `<needle-engine>` elements on the same page, use `ctx` directly.
11051
+ * @experimental This API may change in future releases.
11040
11052
  *
11041
11053
  * @example
11042
11054
  * import { needle } from "@needle-tools/engine";
@@ -13039,7 +13051,7 @@ declare class ObjectSerializer extends TypeSerializer {
13039
13051
  onDeserialize(data: ObjectData | string | null, context: SerializationContext): Object3D<Object3DEventMap> | Component | null | undefined;
13040
13052
  }
13041
13053
 
13042
- export declare const objectSerializer: ObjectSerializer;
13054
+ export declare let objectSerializer: ObjectSerializer;
13043
13055
 
13044
13056
  declare type ObjectToNodeMap = {
13045
13057
  [uuid: string]: number;
@@ -23507,6 +23519,35 @@ export declare class OrbitControls extends Component implements ICameraControlle
23507
23519
  export { }
23508
23520
 
23509
23521
 
23522
+ declare module 'three' {
23523
+ interface SkinnedMesh {
23524
+ staticGenerator?: StaticGeometryGenerator;
23525
+ staticGeometry?: BufferGeometry;
23526
+ staticGeometryLastUpdate?: number;
23527
+ }
23528
+ interface Mesh {
23529
+ acceleratedRaycast?: any;
23530
+ }
23531
+ interface SkinnedMesh {
23532
+ /** @deprecated use autoUpdateMeshBvhInterval */
23533
+ autoUpdateMeshBVH?: boolean;
23534
+ /**
23535
+ * Interval in milliseconds to automatically update the mesh BVH. When set to >= 0 the BVH will be updated every x milliseconds.
23536
+ * @default undefined (disabled)
23537
+ */
23538
+ autoUpdateMeshBvhInterval?: number;
23539
+ bvhNeedsUpdate?: boolean;
23540
+ }
23541
+ }
23542
+
23543
+
23544
+ declare module 'three' {
23545
+ interface Vector3 {
23546
+ slerp(end: Vector3, t: number): Vector3;
23547
+ }
23548
+ }
23549
+
23550
+
23510
23551
  declare module 'three' {
23511
23552
  interface Object3D {
23512
23553
  get guid(): string | undefined;
@@ -23645,32 +23686,3 @@ declare module 'three' {
23645
23686
  contains(object: Object3D | null | undefined): boolean;
23646
23687
  }
23647
23688
  }
23648
-
23649
-
23650
- declare module 'three' {
23651
- interface Vector3 {
23652
- slerp(end: Vector3, t: number): Vector3;
23653
- }
23654
- }
23655
-
23656
-
23657
- declare module 'three' {
23658
- interface SkinnedMesh {
23659
- staticGenerator?: StaticGeometryGenerator;
23660
- staticGeometry?: BufferGeometry;
23661
- staticGeometryLastUpdate?: number;
23662
- }
23663
- interface Mesh {
23664
- acceleratedRaycast?: any;
23665
- }
23666
- interface SkinnedMesh {
23667
- /** @deprecated use autoUpdateMeshBvhInterval */
23668
- autoUpdateMeshBVH?: boolean;
23669
- /**
23670
- * Interval in milliseconds to automatically update the mesh BVH. When set to >= 0 the BVH will be updated every x milliseconds.
23671
- * @default undefined (disabled)
23672
- */
23673
- autoUpdateMeshBvhInterval?: number;
23674
- bvhNeedsUpdate?: boolean;
23675
- }
23676
- }