@needle-tools/engine 4.14.0-beta → 4.14.0-next.52fdb13

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 (97) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/components.needle.json +1 -1
  3. package/dist/{needle-engine.bundle-BW2VusZV.min.js → needle-engine.bundle-BwfaInTa.min.js} +131 -123
  4. package/dist/{needle-engine.bundle-Cb5bKEqa.umd.cjs → needle-engine.bundle-DJE-Bjpa.umd.cjs} +124 -116
  5. package/dist/{needle-engine.bundle-D9VPvp5o.js → needle-engine.bundle-TmE5-_na.js} +3457 -3227
  6. package/dist/needle-engine.d.ts +430 -94
  7. package/dist/needle-engine.js +570 -569
  8. package/dist/needle-engine.min.js +1 -1
  9. package/dist/needle-engine.umd.cjs +1 -1
  10. package/dist/{postprocessing-CctM1XIO.min.js → postprocessing-06AXuvdv.min.js} +2 -2
  11. package/dist/{postprocessing-DGm6qJ-I.js → postprocessing-CI2x8Cln.js} +2 -2
  12. package/dist/{postprocessing-Dbl2PJpd.umd.cjs → postprocessing-CPDcA21P.umd.cjs} +2 -2
  13. package/lib/engine/api.d.ts +203 -18
  14. package/lib/engine/api.js +271 -18
  15. package/lib/engine/api.js.map +1 -1
  16. package/lib/engine/engine_accessibility.d.ts +58 -0
  17. package/lib/engine/engine_accessibility.js +143 -0
  18. package/lib/engine/engine_accessibility.js.map +1 -0
  19. package/lib/engine/engine_context.d.ts +2 -0
  20. package/lib/engine/engine_context.js +7 -0
  21. package/lib/engine/engine_context.js.map +1 -1
  22. package/lib/engine/engine_materialpropertyblock.d.ts +91 -5
  23. package/lib/engine/engine_materialpropertyblock.js +97 -7
  24. package/lib/engine/engine_materialpropertyblock.js.map +1 -1
  25. package/lib/engine/engine_math.d.ts +34 -1
  26. package/lib/engine/engine_math.js +34 -1
  27. package/lib/engine/engine_math.js.map +1 -1
  28. package/lib/engine/engine_networking.js +1 -1
  29. package/lib/engine/engine_networking.js.map +1 -1
  30. package/lib/engine/engine_types.d.ts +2 -0
  31. package/lib/engine/engine_types.js +2 -0
  32. package/lib/engine/engine_types.js.map +1 -1
  33. package/lib/engine/webcomponents/icons.js +3 -0
  34. package/lib/engine/webcomponents/icons.js.map +1 -1
  35. package/lib/engine/webcomponents/logo-element.d.ts +1 -0
  36. package/lib/engine/webcomponents/logo-element.js +3 -1
  37. package/lib/engine/webcomponents/logo-element.js.map +1 -1
  38. package/lib/engine/webcomponents/needle-button.d.ts +37 -11
  39. package/lib/engine/webcomponents/needle-button.js +42 -11
  40. package/lib/engine/webcomponents/needle-button.js.map +1 -1
  41. package/lib/engine/webcomponents/needle-engine.d.ts +10 -2
  42. package/lib/engine/webcomponents/needle-engine.js +13 -3
  43. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  44. package/lib/engine-components/Component.d.ts +1 -2
  45. package/lib/engine-components/Component.js +1 -2
  46. package/lib/engine-components/Component.js.map +1 -1
  47. package/lib/engine-components/DragControls.d.ts +1 -0
  48. package/lib/engine-components/DragControls.js +21 -0
  49. package/lib/engine-components/DragControls.js.map +1 -1
  50. package/lib/engine-components/GroundProjection.js.map +1 -1
  51. package/lib/engine-components/NeedleMenu.d.ts +2 -0
  52. package/lib/engine-components/NeedleMenu.js +2 -0
  53. package/lib/engine-components/NeedleMenu.js.map +1 -1
  54. package/lib/engine-components/Networking.d.ts +28 -3
  55. package/lib/engine-components/Networking.js +28 -3
  56. package/lib/engine-components/Networking.js.map +1 -1
  57. package/lib/engine-components/ReflectionProbe.d.ts +1 -0
  58. package/lib/engine-components/ReflectionProbe.js +21 -3
  59. package/lib/engine-components/ReflectionProbe.js.map +1 -1
  60. package/lib/engine-components/RendererLightmap.js +1 -1
  61. package/lib/engine-components/RendererLightmap.js.map +1 -1
  62. package/lib/engine-components/SeeThrough.js +1 -1
  63. package/lib/engine-components/SeeThrough.js.map +1 -1
  64. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.d.ts +107 -13
  65. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +167 -30
  66. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js.map +1 -1
  67. package/lib/engine-components/ui/Button.d.ts +1 -0
  68. package/lib/engine-components/ui/Button.js +11 -0
  69. package/lib/engine-components/ui/Button.js.map +1 -1
  70. package/lib/engine-components/ui/Text.d.ts +1 -0
  71. package/lib/engine-components/ui/Text.js +11 -0
  72. package/lib/engine-components/ui/Text.js.map +1 -1
  73. package/lib/engine-components/web/ViewBox.js.map +1 -1
  74. package/package.json +2 -2
  75. package/src/engine/api.ts +371 -19
  76. package/src/engine/engine_accessibility.ts +178 -0
  77. package/src/engine/engine_context.ts +9 -0
  78. package/src/engine/engine_materialpropertyblock.ts +103 -12
  79. package/src/engine/engine_math.ts +34 -1
  80. package/src/engine/engine_networking.ts +1 -1
  81. package/src/engine/engine_types.ts +5 -0
  82. package/src/engine/webcomponents/icons.ts +3 -0
  83. package/src/engine/webcomponents/logo-element.ts +4 -1
  84. package/src/engine/webcomponents/needle-button.ts +44 -13
  85. package/src/engine/webcomponents/needle-engine.ts +18 -7
  86. package/src/engine-components/Component.ts +1 -3
  87. package/src/engine-components/DragControls.ts +29 -4
  88. package/src/engine-components/GroundProjection.ts +1 -1
  89. package/src/engine-components/NeedleMenu.ts +5 -3
  90. package/src/engine-components/Networking.ts +29 -4
  91. package/src/engine-components/ReflectionProbe.ts +22 -3
  92. package/src/engine-components/RendererLightmap.ts +1 -1
  93. package/src/engine-components/SeeThrough.ts +1 -1
  94. package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +198 -65
  95. package/src/engine-components/ui/Button.ts +12 -0
  96. package/src/engine-components/ui/Text.ts +13 -0
  97. package/src/engine-components/web/ViewBox.ts +3 -3
@@ -111,7 +111,7 @@ import { XRControllerModelFactory } from 'three/examples/jsm/webxr/XRControllerM
111
111
  import { XRHandMeshModel } from 'three/examples/jsm/webxr/XRHandMeshModel.js';
112
112
  import { XRHandSpace } from 'three';
113
113
 
114
- declare const $componentName: unique symbol;
114
+ export declare const $componentName: unique symbol;
115
115
 
116
116
  export declare const $physicsKey: unique symbol;
117
117
 
@@ -120,6 +120,62 @@ export declare class __Ignore {
120
120
 
121
121
  export declare function __internalNotifyObjectDestroyed(obj: Object3D): void;
122
122
 
123
+ /** Data describing the accessible semantics for a 3D object or component. */
124
+ declare type AccessibilityData = {
125
+ /** ARIA role (e.g. `"button"`, `"img"`, `"region"`). */
126
+ role: string;
127
+ /** Human-readable label announced by screen readers. */
128
+ label: string;
129
+ /** When `true`, the element is hidden from the accessibility tree. */
130
+ hidden?: boolean;
131
+ /** When `true`, indicates the element's content is being updated. */
132
+ busy?: boolean;
133
+ };
134
+
135
+ /**
136
+ * Manages an accessible, screen-reader-friendly overlay for a Needle Engine {@link Context}.
137
+ *
138
+ * The manager maintains a visually-hidden DOM tree that mirrors relevant 3D scene objects
139
+ * with appropriate ARIA roles and labels. It also provides a live region so that hover
140
+ * events in the 3D scene can be announced to assistive technology without stealing focus.
141
+ */
142
+ declare class AccessibilityManager {
143
+ private readonly context;
144
+ private static readonly _managers;
145
+ /** Returns the {@link AccessibilityManager} associated with the given context or component. */
146
+ static get(obj: Context | IComponent): AccessibilityManager | undefined;
147
+ constructor(context: Context);
148
+ private _enabled;
149
+ /** Enables or disables the accessibility overlay. When disabled, the overlay DOM is removed. */
150
+ set enabled(value: boolean);
151
+ /** Removes all tracked accessibility elements, keeping only the live region. */
152
+ clear(): void;
153
+ /** Removes the overlay from the DOM and unregisters this manager from the context. */
154
+ dispose(): void;
155
+ private readonly root;
156
+ private readonly liveRegion;
157
+ private readonly treeElements;
158
+ /**
159
+ * Creates or updates the accessible DOM element for a 3D object or component.
160
+ * @param obj - The scene object or component to represent.
161
+ * @param data - Partial accessibility data (role, label, hidden, busy) to apply.
162
+ */
163
+ updateElement<T extends Object3D | IComponent>(obj: T, data: Partial<AccessibilityData>): void;
164
+ /** Moves keyboard focus to the accessible element representing the given object. */
165
+ focus<T extends Object3D | IComponent>(obj: T): void;
166
+ /** Removes keyboard focus from the accessible element representing the given object. */
167
+ unfocus<T extends Object3D | IComponent>(obj: T): void;
168
+ /**
169
+ * Announces a hover event to screen readers via the ARIA live region.
170
+ * @param obj - The hovered object (used to look up its label if `text` is not provided).
171
+ * @param text - Optional text to announce. Falls back to the element's `aria-label`.
172
+ */
173
+ hover<T extends Object3D | IComponent>(obj: T, text?: string): void;
174
+ /** Removes the accessible DOM element for the given object and stops tracking it. */
175
+ removeElement(obj: Object3D | IComponent): void;
176
+ private set liveRegionMode(value);
177
+ }
178
+
123
179
  export declare class ActionBuilder {
124
180
  static sequence(...params: IBehaviorElement[]): GroupActionModel;
125
181
  static parallel(...params: IBehaviorElement[]): GroupActionModel;
@@ -2267,6 +2323,7 @@ export declare class Button extends Component implements IPointerEventHandler {
2267
2323
  awake(): void;
2268
2324
  start(): void;
2269
2325
  onEnable(): void;
2326
+ onDisable(): void;
2270
2327
  onDestroy(): void;
2271
2328
  private _requestedAnimatorTrigger?;
2272
2329
  private setAnimatorTriggerAtEndOfFrame;
@@ -2815,7 +2872,15 @@ export declare class CapsuleCollider extends Collider {
2815
2872
  }
2816
2873
 
2817
2874
  /**
2818
- * Change the material of objects when clicked.
2875
+ * Switches the material of objects in the scene when clicked.
2876
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
2877
+ *
2878
+ * Finds all objects in the scene that use `materialToSwitch` and replaces it with `variantMaterial`.
2879
+ * Multiple `ChangeMaterialOnClick` components using the same `materialToSwitch` can be combined to create a material selection UI.
2880
+ *
2881
+ * @see {@link SetActiveOnClick} to toggle visibility of objects when clicked
2882
+ * @see {@link PlayAnimationOnClick} to play animations when clicked
2883
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
2819
2884
  * @summary Changes the material of objects when clicked
2820
2885
  * @category Everywhere Actions
2821
2886
  * @group Components
@@ -2835,6 +2900,9 @@ export declare class ChangeMaterialOnClick extends Component implements IPointer
2835
2900
  */
2836
2901
  fadeDuration: number;
2837
2902
  start(): void;
2903
+ onEnable(): void;
2904
+ onDisable(): void;
2905
+ onDestroy(): void;
2838
2906
  onPointerEnter(_args: PointerEventData): void;
2839
2907
  onPointerExit(_: PointerEventData): void;
2840
2908
  onPointerClick(args: PointerEventData): void;
@@ -2856,21 +2924,32 @@ export declare class ChangeMaterialOnClick extends Component implements IPointer
2856
2924
  }
2857
2925
 
2858
2926
  /**
2859
- * Make the object move to the target object's transform when clicked.
2927
+ * Moves an object to the target object's transform when clicked.
2928
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
2929
+ *
2930
+ * @see {@link SetActiveOnClick}to toggle visibility of objects when clicked
2931
+ * @see {@link PlayAnimationOnClick} to play animations when clicked
2932
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
2860
2933
  * @summary Moves an object to a target transform upon click
2861
2934
  * @category Everywhere Actions
2862
2935
  * @group Components
2863
2936
  */
2864
2937
  export declare class ChangeTransformOnClick extends Component implements IPointerClickHandler, UsdzBehaviour {
2938
+ /** The object to move. */
2865
2939
  object?: Object3D;
2940
+ /** The target object whose transform to move to. */
2866
2941
  target?: Object3D;
2942
+ /** The duration of the movement animation in seconds. */
2867
2943
  duration: number;
2944
+ /** If true, the motion is relative to the object's current transform instead of moving to the target's absolute position. */
2868
2945
  relativeMotion: boolean;
2869
2946
  private coroutine;
2870
2947
  private targetPos;
2871
2948
  private targetRot;
2872
2949
  private targetScale;
2873
- start(): void;
2950
+ onEnable(): void;
2951
+ onDisable(): void;
2952
+ onDestroy(): void;
2874
2953
  onPointerEnter(): void;
2875
2954
  onPointerExit(): void;
2876
2955
  onPointerClick(args: PointerEventData): void;
@@ -4276,6 +4355,7 @@ export declare class Context implements IContext {
4276
4355
  readonly lodsManager: LODsManager;
4277
4356
  /** Access the needle menu to add or remove buttons to the menu element */
4278
4357
  readonly menu: NeedleMenu_2;
4358
+ readonly accessibility: AccessibilityManager;
4279
4359
  /**
4280
4360
  * Checks if the context is fully created and ready
4281
4361
  * @returns true if the context is fully created and ready
@@ -5266,6 +5346,7 @@ export declare class DragControls extends Component implements IPointerEventHand
5266
5346
  /* Excluded from this release type: start */
5267
5347
  /* Excluded from this release type: onEnable */
5268
5348
  /* Excluded from this release type: onDisable */
5349
+ onDestroy(): void;
5269
5350
  /**
5270
5351
  * Checks if editing is allowed for the current networking connection.
5271
5352
  * @param _obj Optional object to check edit permissions for
@@ -5638,15 +5719,28 @@ export declare class EmissionModule {
5638
5719
  /* Excluded from this release type: EmphasizeActionMotionType */
5639
5720
 
5640
5721
  /**
5641
- * Emphasize the target object when clicked.
5722
+ * Applies an emphasis animation to a target object when this object is clicked.
5723
+ * Works in USDZ/QuickLook (Everywhere Actions).
5724
+ *
5725
+ * The emphasis effect can be a bounce, jiggle, or other motion type defined by `motionType`.
5726
+ *
5727
+ * @see {@link PlayAnimationOnClick} to play animations when clicked
5728
+ * @see {@link SetActiveOnClick} to toggle visibility when clicked
5729
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
5642
5730
  * @summary Emphasizes the target object when clicked
5643
5731
  * @category Everywhere Actions
5644
5732
  * @group Components
5645
5733
  */
5646
5734
  export declare class EmphasizeOnClick extends Component implements UsdzBehaviour {
5735
+ /** The target object to emphasize. */
5647
5736
  target?: Object3D;
5737
+ /** The duration of the emphasis animation in seconds. */
5648
5738
  duration: number;
5739
+ /** The type of motion to use for the emphasis effect (e.g. `"bounce"`, `"jiggle"`). */
5649
5740
  motionType: EmphasizeActionMotionType;
5741
+ onEnable(): void;
5742
+ onDisable(): void;
5743
+ onDestroy(): void;
5650
5744
  beforeCreateDocument(): void;
5651
5745
  createBehaviours(ext: any, model: any, _context: any): void;
5652
5746
  afterCreateDocument(_ext: any, _context: any): void;
@@ -7398,7 +7492,13 @@ export declare enum HideFlags {
7398
7492
  }
7399
7493
 
7400
7494
  /**
7401
- * Hides the object on scene start.
7495
+ * Hides the object when the scene starts.
7496
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
7497
+ *
7498
+ * Useful for setting up objects that should initially be hidden and shown later via a {@link SetActiveOnClick} component.
7499
+ *
7500
+ * @see {@link SetActiveOnClick} to show or hide objects on click
7501
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
7402
7502
  * @summary Hides the object on scene start
7403
7503
  * @category Everywhere Actions
7404
7504
  * @group Components
@@ -7744,6 +7844,7 @@ export declare type ICollisionContext = {
7744
7844
 
7745
7845
  export declare interface IComponent extends IHasGuid {
7746
7846
  get isComponent(): boolean;
7847
+ get [$componentName](): string | undefined;
7747
7848
  /** the object this component is attached to */
7748
7849
  gameObject: IGameObject;
7749
7850
  enabled: boolean;
@@ -10061,13 +10162,22 @@ export declare class MaskableGraphic extends Graphic {
10061
10162
  * This is useful for rendering multiple objects with the same base material but different properties
10062
10163
  * (e.g., different colors, textures, or shader parameters).
10063
10164
  *
10165
+ * ## How Property Blocks Work
10166
+ *
10167
+ * **Important**: Overrides are registered on the **Object3D**, not on the material.
10168
+ * This means:
10169
+ * - If you change the object's material, the overrides will still be applied to the new material
10170
+ * - Multiple objects can share the same material but have different property overrides
10171
+ * - If you don't want overrides applied after changing a material, you must remove them using {@link removeOveride}, {@link clearAllOverrides}, or {@link dispose}
10172
+ *
10064
10173
  * The property block system works by:
10065
10174
  * - Temporarily applying overrides in onBeforeRender
10066
10175
  * - Restoring original values in onAfterRender
10067
10176
  * - Managing shader defines and program cache keys for correct shader compilation
10068
10177
  * - Supporting texture coordinate transforms per object
10069
10178
  *
10070
- * Common use cases:
10179
+ * ## Common Use Cases
10180
+ *
10071
10181
  * - **Lightmaps**: Apply unique lightmap textures to individual objects sharing the same material
10072
10182
  * - **Reflection Probes**: Apply different environment maps per object for localized reflections
10073
10183
  * - **See-through effects**: Temporarily override transparency/transmission properties for X-ray effects
@@ -10105,6 +10215,26 @@ export declare class MaskableGraphic extends Graphic {
10105
10215
  * block.setDefine("USE_CUSTOM_FEATURE", 1);
10106
10216
  * ```
10107
10217
  *
10218
+ * @example Material swapping behavior
10219
+ * ```typescript
10220
+ * const mesh = new Mesh(geometry, materialA);
10221
+ * const block = MaterialPropertyBlock.get(mesh);
10222
+ * block.setOverride("color", new Color(1, 0, 0));
10223
+ *
10224
+ * // The color override is red for materialA
10225
+ *
10226
+ * // Swap the material - overrides persist and apply to the new material!
10227
+ * mesh.material = materialB;
10228
+ * // The color override is now red for materialB too
10229
+ *
10230
+ * // If you don't want overrides on the new material, remove them:
10231
+ * block.clearAllOverrides(); // Remove all overrides
10232
+ * // or
10233
+ * block.removeOveride("color"); // Remove specific override
10234
+ * // or
10235
+ * block.dispose(); // Remove the entire property block
10236
+ * ```
10237
+ *
10108
10238
  * @example Lightmap usage
10109
10239
  * ```typescript
10110
10240
  * const block = MaterialPropertyBlock.get(mesh);
@@ -10212,12 +10342,69 @@ export declare class MaterialPropertyBlock<T extends Material = Material> {
10212
10342
  getOverride<K extends NonFunctionPropertyNames<T>>(name: K): PropertyBlockOverride<T[K] & MaterialPropertyType> | undefined;
10213
10343
  getOverride<V extends MaterialPropertyType = MaterialPropertyType>(name: string): PropertyBlockOverride<V> | undefined;
10214
10344
  /**
10215
- * Removes a specific property override
10216
- * @param name The property name to clear
10345
+ * Removes a specific property override.
10346
+ * After removal, the material will use its original property value for this property.
10347
+ *
10348
+ * @param name The property name to remove the override for
10349
+ *
10350
+ * @example
10351
+ * ```typescript
10352
+ * const block = MaterialPropertyBlock.get(mesh);
10353
+ *
10354
+ * // Set some overrides
10355
+ * block.setOverride("color", new Color(1, 0, 0));
10356
+ * block.setOverride("roughness", 0.5);
10357
+ * block.setOverride("lightMap", lightmapTexture);
10358
+ *
10359
+ * // Remove a specific override - the material will now use its original color
10360
+ * block.removeOveride("color");
10361
+ *
10362
+ * // Other overrides (roughness, lightMap) remain active
10363
+ * ```
10217
10364
  */
10218
10365
  removeOveride<K extends NonFunctionPropertyNames<T>>(name: K | ({} & string)): void;
10219
10366
  /**
10220
- * Removes all property overrides from this block
10367
+ * Removes all property overrides from this block.
10368
+ * After calling this, the material will use its original values for all properties.
10369
+ *
10370
+ * **Note**: This does NOT remove shader defines. Use {@link clearDefine} or {@link dispose} for that.
10371
+ *
10372
+ * @example Remove all overrides but keep the property block
10373
+ * ```typescript
10374
+ * const block = MaterialPropertyBlock.get(mesh);
10375
+ *
10376
+ * // Set multiple overrides
10377
+ * block.setOverride("color", new Color(1, 0, 0));
10378
+ * block.setOverride("roughness", 0.5);
10379
+ * block.setOverride("lightMap", lightmapTexture);
10380
+ *
10381
+ * // Later, remove all overrides at once
10382
+ * block.clearAllOverrides();
10383
+ *
10384
+ * // The material now uses its original values
10385
+ * // The property block still exists and can be reused with new overrides
10386
+ * ```
10387
+ *
10388
+ * @example Temporarily disable all overrides
10389
+ * ```typescript
10390
+ * const block = MaterialPropertyBlock.get(mesh);
10391
+ *
10392
+ * // Save current overrides if you want to restore them later
10393
+ * const savedOverrides = [...block.overrides];
10394
+ *
10395
+ * // Clear all overrides temporarily
10396
+ * block.clearAllOverrides();
10397
+ *
10398
+ * // Do some rendering without overrides...
10399
+ *
10400
+ * // Restore overrides
10401
+ * savedOverrides.forEach(override => {
10402
+ * block.setOverride(override.name, override.value, override.textureTransform);
10403
+ * });
10404
+ * ```
10405
+ *
10406
+ * @see {@link removeOveride} - To remove a single override
10407
+ * @see {@link dispose} - To completely remove the property block and clean up resources
10221
10408
  */
10222
10409
  clearAllOverrides(): void;
10223
10410
  /**
@@ -10618,32 +10805,58 @@ export declare namespace NEEDLE_ENGINE_MODULES {
10618
10805
  export { NEEDLE_progressive }
10619
10806
 
10620
10807
  /**
10621
- * A <needle-button> can be used to simply add VR, AR or Quicklook buttons to your website without having to write any code.
10622
- * @example
10808
+ * [&lt;needle-button&gt;](https://engine.needle.tools/docs/api/NeedleButtonElement) is a web component for easily adding AR, VR, Quicklook, or QR code buttons to your website without writing JavaScript code.
10809
+ *
10810
+ * The button automatically handles session management and displays appropriate UI based on device capabilities.
10811
+ * It comes with default styling (glassmorphism design) but can be fully customized with CSS.
10812
+ *
10813
+ * **Supported button types:**
10814
+ * - `ar` - WebXR AR session button
10815
+ * - `vr` - WebXR VR session button
10816
+ * - `quicklook` - Apple AR Quick Look button (iOS only)
10817
+ * - `qrcode` - QR code sharing button
10818
+ *
10819
+ * @example Basic AR/VR buttons
10623
10820
  * ```html
10821
+ * <needle-engine src="scene.glb"></needle-engine>
10624
10822
  * <needle-button ar></needle-button>
10625
10823
  * <needle-button vr></needle-button>
10626
10824
  * <needle-button quicklook></needle-button>
10627
10825
  * ```
10628
10826
  *
10629
- * @example custom label
10827
+ * @example Custom button labels
10630
10828
  * ```html
10631
- * <needle-button ar>Start AR</needle-button>
10632
- * <needle-button vr>Start VR</needle-button>
10829
+ * <needle-button ar>Start AR Experience</needle-button>
10830
+ * <needle-button vr>Enter VR Mode</needle-button>
10633
10831
  * <needle-button quicklook>View in AR</needle-button>
10634
10832
  * ```
10635
10833
  *
10636
- * @example custom styling
10834
+ * @example Custom styling
10637
10835
  * ```html
10638
- * <!-- You can either style the element directly or use a CSS stylesheet -->
10639
10836
  * <style>
10640
- * needle-button {
10641
- * background-color: red;
10642
- * color: white;
10643
- * }
10837
+ * needle-button {
10838
+ * background-color: #ff6b6b;
10839
+ * color: white;
10840
+ * border-radius: 8px;
10841
+ * padding: 1rem 2rem;
10842
+ * }
10843
+ * needle-button:hover {
10844
+ * background-color: #ff5252;
10845
+ * }
10644
10846
  * </style>
10645
10847
  * <needle-button ar>Start AR</needle-button>
10646
10848
  * ```
10849
+ *
10850
+ * @example Unstyled button (for complete custom styling)
10851
+ * ```html
10852
+ * <needle-button ar unstyled>
10853
+ * <span class="my-icon">🥽</span>
10854
+ * Launch AR
10855
+ * </needle-button>
10856
+ * ```
10857
+ *
10858
+ * @see {@link NeedleEngineWebComponent} for the main &lt;needle-engine&gt; element
10859
+ * @see {@link NeedleMenu} for the built-in menu component that can display similar buttons
10647
10860
  */
10648
10861
  export declare class NeedleButtonElement extends HTMLElement {
10649
10862
  #private;
@@ -10720,10 +10933,18 @@ export declare namespace NeedleEngineModelLoader {
10720
10933
  * The context is accessible from the `<needle-engine>` element: `document.querySelector("needle-engine").context`.
10721
10934
  * See {@link https://engine.needle.tools/docs/reference/needle-engine-attributes}
10722
10935
  *
10723
- * @example
10936
+ * @example Basic usage
10937
+ * ```html
10724
10938
  * <needle-engine src="https://example.com/scene.glb"></needle-engine>
10725
- * @example
10939
+ * ```
10940
+ *
10941
+ * @example With camera controls disabled
10942
+ * ```html
10726
10943
  * <needle-engine src="https://example.com/scene.glb" camera-controls="false"></needle-engine>
10944
+ * ```
10945
+ *
10946
+ * @see {@link NeedleButtonElement} for adding AR/VR/Quicklook buttons via &lt;needle-button&gt;
10947
+ * @see {@link NeedleMenu} for the built-in menu configuration component
10727
10948
  */
10728
10949
  export declare class NeedleEngineWebComponent extends HTMLElement implements INeedleEngineComponent {
10729
10950
  static get observedAttributes(): string[];
@@ -11050,6 +11271,8 @@ declare class NeedleGamepadButton {
11050
11271
  * @category User Interface
11051
11272
  * @group Components
11052
11273
  * @see {@link Context.menu} for programmatic menu control
11274
+ * @see {@link NeedleButtonElement} for standalone &lt;needle-button&gt; web component
11275
+ * @see {@link NeedleEngineWebComponent} for the main &lt;needle-engine&gt; element
11053
11276
  * @see {@link Voip} adds a microphone button to the menu
11054
11277
  * @see {@link ScreenCapture} adds a screen sharing button
11055
11278
  **/
@@ -12271,10 +12494,34 @@ export declare class NetworkedStreams extends EventDispatcher<any> {
12271
12494
  }
12272
12495
 
12273
12496
  /**
12274
- * Provides configuration to the built-in networking system.
12275
- * This component supplies websocket URLs for establishing connections.
12276
- * It implements the {@link INetworkingWebsocketUrlProvider} interface.
12497
+ * Provides websocket URL configuration for the built-in networking system.
12498
+ * Add this component to override the default networking backend URL used by {@link NetworkConnection} (`this.context.connection`).
12499
+ *
12500
+ * The component registers itself as a URL provider on `awake()`. When the networking system connects,
12501
+ * it queries this provider for the websocket URL to use instead of the default Needle networking backend.
12277
12502
  *
12503
+ * **URL resolution order:**
12504
+ * 1. If `urlParameterName` is set and the corresponding URL parameter exists in the browser URL, that value is used
12505
+ * 2. If running on a local network and `localhost` is set, the `localhost` URL is used
12506
+ * 3. Otherwise, the `url` field is used
12507
+ *
12508
+ * Without this component, the default backend URL `wss://networking-2.needle.tools/socket` is used.
12509
+ *
12510
+ * **Note:** This component only configures the websocket URL. To actually join a networked room,
12511
+ * use a `SyncedRoom` component or call `this.context.connection.joinRoom("room-name")` directly.
12512
+ *
12513
+ * @example Overriding the URL via browser parameter
12514
+ * ```ts
12515
+ * // With urlParameterName="server", visiting:
12516
+ * // https://myapp.com/?server=wss://my-server.com/socket
12517
+ * // will connect to that server instead
12518
+ * ```
12519
+ *
12520
+ * @see {@link NetworkConnection} for the main networking API (`this.context.connection`)
12521
+ * @see {@link SyncedRoom} for automatic room joining
12522
+ * @see {@link OwnershipModel} for networked object ownership
12523
+ * @see {@link RoomEvents} for room lifecycle events
12524
+ * @link https://engine.needle.tools/docs/how-to-guides/networking/
12278
12525
  * @summary Networking configuration
12279
12526
  * @category Networking
12280
12527
  * @group Components
@@ -12283,6 +12530,7 @@ export declare class Networking extends Component implements INetworkingWebsocke
12283
12530
  /**
12284
12531
  * The websocket URL to connect to for networking functionality.
12285
12532
  * Can be a complete URL or a relative path that will be resolved against the current origin.
12533
+ * @default null
12286
12534
  */
12287
12535
  url: string | null;
12288
12536
  /**
@@ -12656,7 +12904,40 @@ export declare function onClear(cb: LifecycleMethod, opts?: LifecycleMethodOptio
12656
12904
  export declare function onDestroy(cb: LifecycleMethod, opts?: LifecycleMethodOptions): () => void;
12657
12905
 
12658
12906
  /**
12659
- * OneEuroFilter is a simple low-pass filter for noisy signals. It uses a one-euro filter to smooth the signal.
12907
+ * [OneEuroFilter](https://engine.needle.tools/docs/api/OneEuroFilter) is a low-pass filter designed to reduce jitter in noisy signals while maintaining low latency.
12908
+ * It's particularly useful for smoothing tracking data from XR controllers, hand tracking, or other input devices where the signal contains noise but responsiveness is important.
12909
+ *
12910
+ * The filter automatically adapts its smoothing strength based on the signal's velocity:
12911
+ * - When the signal moves slowly, it applies strong smoothing to reduce jitter
12912
+ * - When the signal moves quickly, it reduces smoothing to maintain responsiveness
12913
+ *
12914
+ * Based on the research paper: [1€ Filter: A Simple Speed-based Low-pass Filter for Noisy Input](http://cristal.univ-lille.fr/~casiez/1euro/)
12915
+ *
12916
+ * @example Basic usage with timestamp
12917
+ * ```ts
12918
+ * const filter = new OneEuroFilter(120, 1.0, 0.0);
12919
+ *
12920
+ * // In your update loop:
12921
+ * const smoothedValue = filter.filter(noisyValue, this.context.time.time);
12922
+ * ```
12923
+ *
12924
+ * @example Without timestamps (using frequency estimate)
12925
+ * ```ts
12926
+ * // Assuming 60 FPS update rate
12927
+ * const filter = new OneEuroFilter(60, 1.0, 0.5);
12928
+ *
12929
+ * // Call without timestamp - uses the frequency estimate
12930
+ * const smoothedValue = filter.filter(noisyValue);
12931
+ * ```
12932
+ *
12933
+ * @example Smoothing 3D positions
12934
+ * ```ts
12935
+ * const posFilter = new OneEuroFilterXYZ(90, 0.5, 0.0);
12936
+ *
12937
+ * posFilter.filter(trackedPosition, smoothedPosition, this.context.time.time);
12938
+ * ```
12939
+ *
12940
+ * @see {@link OneEuroFilterXYZ} for filtering 3D vectors
12660
12941
  */
12661
12942
  export declare class OneEuroFilter {
12662
12943
  /**
@@ -14142,18 +14423,34 @@ export declare class OrbitControls extends Component implements ICameraControlle
14142
14423
  /* Excluded from this release type: PlayAction */
14143
14424
 
14144
14425
  /**
14145
- * Plays an animation when clicked.
14426
+ * Plays an animation state when this object is clicked.
14427
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
14428
+ *
14429
+ * Assign an {@link Animator} and a `stateName` to play a specific animation state,
14430
+ * or assign an {@link Animation} component to play a legacy animation clip.
14431
+ *
14432
+ * For USDZ export, the component follows animator state transitions automatically, including looping states.
14433
+ *
14434
+ * @see {@link Animator}for playing animator state machine animations
14435
+ * @see {@link Animation} for playing legacy animation clips
14436
+ * @see {@link PlayAudioOnClick} to play audio when clicked
14437
+ * @see {@link SetActiveOnClick} to toggle visibility when clicked
14438
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
14146
14439
  * @summary Plays an animation when clicked
14147
14440
  * @category Everywhere Actions
14148
14441
  * @group Components
14149
14442
  */
14150
14443
  export declare class PlayAnimationOnClick extends Component implements IPointerClickHandler, UsdzBehaviour, UsdzAnimation {
14444
+ /** The {@link Animator} component whose state to play when clicked. */
14151
14445
  animator?: Animator;
14446
+ /** The name of the animation state to play. Required when using an {@link Animator}. */
14152
14447
  stateName?: string;
14153
14448
  trigger: "tap" | "start";
14154
14449
  animation?: Animation_2;
14155
14450
  private get target();
14156
- start(): void;
14451
+ onEnable(): void;
14452
+ onDisable(): void;
14453
+ onDestroy(): void;
14157
14454
  onPointerEnter(): void;
14158
14455
  onPointerExit(): void;
14159
14456
  onPointerClick(args: PointerEventData): void;
@@ -14177,18 +14474,32 @@ export declare class OrbitControls extends Component implements ICameraControlle
14177
14474
  }
14178
14475
 
14179
14476
  /**
14180
- * Plays an audio clip when clicked.
14477
+ * Plays an audio clip when this object is clicked.
14478
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
14479
+ *
14480
+ * Assign a `target` {@link AudioSource} to use its spatial audio settings, or assign a `clip` URL directly.
14481
+ * If no `target` is assigned, an {@link AudioSource} will be created automatically on this object.
14482
+ *
14483
+ * @see {@link AudioSource}for spatial audio settings
14484
+ * @see {@link PlayAnimationOnClick} to play animations when clicked
14485
+ * @see {@link SetActiveOnClick} to toggle visibility when clicked
14486
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
14181
14487
  * @summary Plays an audio clip when clicked
14182
14488
  * @category Everywhere Actions
14183
14489
  * @group Components
14184
14490
  */
14185
14491
  export declare class PlayAudioOnClick extends Component implements IPointerClickHandler, UsdzBehaviour {
14492
+ /** The {@link AudioSource} to use for playback. If not set, one will be created automatically on this object. */
14186
14493
  target?: AudioSource;
14494
+ /** URL of the audio clip to play. If not set, the clip assigned to `target` is used. */
14187
14495
  clip: string;
14496
+ /** If true, clicking again while the audio is playing will stop it. */
14188
14497
  toggleOnClick: boolean;
14189
14498
  trigger: "tap" | "start";
14190
- start(): void;
14191
14499
  ensureAudioSource(): void;
14500
+ onEnable(): void;
14501
+ onDisable(): void;
14502
+ onDestroy(): void;
14192
14503
  onPointerEnter(): void;
14193
14504
  onPointerExit(): void;
14194
14505
  onPointerClick(args: PointerEventData): void;
@@ -15319,6 +15630,7 @@ export declare class OrbitControls extends Component implements ICameraControlle
15319
15630
  */
15320
15631
  static get(object: Object3D | null | undefined, context: Context, isAnchor: boolean, anchor?: Object3D): ReflectionProbe | null;
15321
15632
  private _texture;
15633
+ private _textureUrlInFlight?;
15322
15634
  set texture(tex: Texture);
15323
15635
  get texture(): Texture;
15324
15636
  intensity: number;
@@ -17303,17 +17615,28 @@ export declare class OrbitControls extends Component implements ICameraControlle
17303
17615
  export declare function setActive(go: Object3D, active: boolean | number): boolean;
17304
17616
 
17305
17617
  /**
17306
- * Set the active state of an object when clicked.
17618
+ * Shows or hides a target object when this object is clicked.
17619
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
17620
+ *
17621
+ * Optionally hides itself after being clicked (`hideSelf`), or toggles the target's visibility on each click (`toggleOnClick`).
17622
+ *
17623
+ * @see {@link HideOnStart}to hide an object when the scene starts
17624
+ * @see {@link PlayAnimationOnClick} to play animations when clicked
17625
+ * @see {@link ChangeMaterialOnClick} to change material when clicked
17626
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
17307
17627
  * @summary Sets the active state of an object when clicked
17308
17628
  * @category Everywhere Actions
17309
17629
  * @group Components
17310
17630
  */
17311
17631
  export declare class SetActiveOnClick extends Component implements IPointerClickHandler, UsdzBehaviour {
17632
+ /** The target object to show or hide. */
17312
17633
  target?: Object3D;
17634
+ /** If true, the target's visibility will be toggled on each click. When enabled, `hideSelf` and `targetState` are ignored. */
17313
17635
  toggleOnClick: boolean;
17636
+ /** The visibility state to apply to the target when clicked. Only used when `toggleOnClick` is false. */
17314
17637
  targetState: boolean;
17638
+ /** If true, this object will hide itself after being clicked. Only used when `toggleOnClick` is false. */
17315
17639
  hideSelf: boolean;
17316
- start(): void;
17317
17640
  onPointerEnter(): void;
17318
17641
  onPointerExit(): void;
17319
17642
  onPointerClick(args: PointerEventData): void;
@@ -19293,7 +19616,12 @@ export declare class OrbitControls extends Component implements ICameraControlle
19293
19616
  export declare type SyncInstantiateOptions = IInstantiateOptions & Pick<IModel, "deleteOnDisconnect">;
19294
19617
 
19295
19618
  /**
19296
- * Triggers an action when the object is tapped/clicked.
19619
+ * Triggers a {@link PreliminaryAction} (such as {@link VisibilityAction}) when the object is tapped or clicked.
19620
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
19621
+ *
19622
+ * @see {@link VisibilityAction} for controlling object visibility on tap
19623
+ * @see {@link SetActiveOnClick} for a combined trigger and action component
19624
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
19297
19625
  * @summary Triggers an action when the object is tapped/clicked
19298
19626
  * @category Everywhere Actions
19299
19627
  * @group Components
@@ -19416,6 +19744,7 @@ export declare class OrbitControls extends Component implements ICameraControlle
19416
19744
  private getTextOpts;
19417
19745
  onEnable(): void;
19418
19746
  onDisable(): void;
19747
+ onDestroy(): void;
19419
19748
  private getAlignment;
19420
19749
  private feedText;
19421
19750
  private _didHandleTextRenderOnTop;
@@ -20932,13 +21261,20 @@ export declare class OrbitControls extends Component implements ICameraControlle
20932
21261
  }
20933
21262
 
20934
21263
  /**
20935
- * Hides or shows the object when clicked.
21264
+ * Action to show or hide an object.
21265
+ * Use together with a {@link TapGestureTrigger} to show or hide objects when tapped or clicked.
21266
+ *
21267
+ * @see {@link TapGestureTrigger} to trigger actions on tap/click
21268
+ * @see {@link SetActiveOnClick} for a combined trigger and action component
21269
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
20936
21270
  * @summary Hides or shows the object when clicked
20937
21271
  * @category Everywhere Actions
20938
21272
  * @group Components
20939
21273
  */
20940
21274
  export declare class VisibilityAction extends PreliminaryAction {
21275
+ /** The type of visibility action to apply. */
20941
21276
  type: VisibilityActionType;
21277
+ /** The duration of the fade animation in seconds. */
20942
21278
  duration: number;
20943
21279
  getType(): "show" | "hide";
20944
21280
  getDuration(): number;
@@ -22389,45 +22725,6 @@ declare global {
22389
22725
  }
22390
22726
  }
22391
22727
 
22392
-
22393
- declare module 'three/examples/jsm/controls/OrbitControls.js' {
22394
- interface OrbitControls {
22395
- _sphericalDelta: import("three").Spherical;
22396
- _rotateLeft: (angleInRadians: number) => void;
22397
- _rotateUp: (angleInRadians: number) => void;
22398
- _pan: (dx: number, dy: number) => void;
22399
- _dollyIn: (dollyScale: number) => void;
22400
- _dollyOut: (dollyScale: number) => void;
22401
- }
22402
- interface OrbitControlsEventMap {
22403
- endMovement: Event;
22404
- }
22405
- }
22406
-
22407
-
22408
- declare global {
22409
- interface ViewTimeline {
22410
- axis: 'block' | 'inline';
22411
- currentTime: {
22412
- unit: 'seconds' | 'percent';
22413
- value: number;
22414
- };
22415
- duration: {
22416
- unit: 'seconds' | 'percent';
22417
- value: number;
22418
- };
22419
- source: Element | null;
22420
- startOffset: {
22421
- unit: 'px';
22422
- value: number;
22423
- };
22424
- endOffset: {
22425
- unit: 'px';
22426
- value: number;
22427
- };
22428
- }
22429
- }
22430
-
22431
22728
  export declare namespace NEEDLE_ENGINE_FEATURE_FLAGS {
22432
22729
  let experimentalSmartHierarchyUpdate: boolean;
22433
22730
  }
@@ -22566,6 +22863,45 @@ export declare namespace DeviceUtilities {
22566
22863
  }
22567
22864
 
22568
22865
 
22866
+ declare module 'three/examples/jsm/controls/OrbitControls.js' {
22867
+ interface OrbitControls {
22868
+ _sphericalDelta: import("three").Spherical;
22869
+ _rotateLeft: (angleInRadians: number) => void;
22870
+ _rotateUp: (angleInRadians: number) => void;
22871
+ _pan: (dx: number, dy: number) => void;
22872
+ _dollyIn: (dollyScale: number) => void;
22873
+ _dollyOut: (dollyScale: number) => void;
22874
+ }
22875
+ interface OrbitControlsEventMap {
22876
+ endMovement: Event;
22877
+ }
22878
+ }
22879
+
22880
+
22881
+ declare global {
22882
+ interface ViewTimeline {
22883
+ axis: 'block' | 'inline';
22884
+ currentTime: {
22885
+ unit: 'seconds' | 'percent';
22886
+ value: number;
22887
+ };
22888
+ duration: {
22889
+ unit: 'seconds' | 'percent';
22890
+ value: number;
22891
+ };
22892
+ source: Element | null;
22893
+ startOffset: {
22894
+ unit: 'px';
22895
+ value: number;
22896
+ };
22897
+ endOffset: {
22898
+ unit: 'px';
22899
+ value: number;
22900
+ };
22901
+ }
22902
+ }
22903
+
22904
+
22569
22905
  declare global {
22570
22906
  interface Window {
22571
22907
  SPECTOR?: {
@@ -22600,12 +22936,6 @@ export declare namespace MaterialX {
22600
22936
  }): Promise<import("three").Material | null>;
22601
22937
  }
22602
22938
 
22603
- declare global {
22604
- interface HTMLElementTagNameMap {
22605
- "needle-button": NeedleButtonElement;
22606
- }
22607
- }
22608
-
22609
22939
  /**
22610
22940
  * @internal
22611
22941
  */
@@ -22655,20 +22985,10 @@ export declare namespace InternalAttributeUtils {
22655
22985
  }): false | string | null;
22656
22986
  }
22657
22987
 
22658
-
22659
- /**
22660
- * @category Splines
22661
- * @see {@link SplineContainer} for the main spline component that defines the path and knots
22662
- */
22663
- export declare namespace SplineUtils {
22664
- /**
22665
- * Creates a SplineContainer from an array of points.
22666
- * @param positions The positions of the knots.
22667
- * @param closed Whether the spline is closed (the last knot connects to the first).
22668
- * @param tension The tension of the spline. 0 is no tension, 1 is high tension (straight lines between knots). Default is 0.75.
22669
- * @return The created SplineContainer component - add it to an Object3D to use it.
22670
- */
22671
- function createFromPoints(positions: Vector3[], closed?: boolean, tension?: number): SplineContainer;
22988
+ declare global {
22989
+ interface HTMLElementTagNameMap {
22990
+ "needle-button": NeedleButtonElement;
22991
+ }
22672
22992
  }
22673
22993
 
22674
22994
 
@@ -22811,6 +23131,22 @@ declare module 'three' {
22811
23131
  }
22812
23132
  }
22813
23133
 
23134
+
23135
+ /**
23136
+ * @category Splines
23137
+ * @see {@link SplineContainer} for the main spline component that defines the path and knots
23138
+ */
23139
+ export declare namespace SplineUtils {
23140
+ /**
23141
+ * Creates a SplineContainer from an array of points.
23142
+ * @param positions The positions of the knots.
23143
+ * @param closed Whether the spline is closed (the last knot connects to the first).
23144
+ * @param tension The tension of the spline. 0 is no tension, 1 is high tension (straight lines between knots). Default is 0.75.
23145
+ * @return The created SplineContainer component - add it to an Object3D to use it.
23146
+ */
23147
+ function createFromPoints(positions: Vector3[], closed?: boolean, tension?: number): SplineContainer;
23148
+ }
23149
+
22814
23150
  declare global {
22815
23151
  interface HTMLElementTagNameMap {
22816
23152
  "needle-logo-element": NeedleLogoElement;