@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
@@ -9,21 +9,32 @@ import { AnimationExtension, RegisteredAnimationInfo, type UsdzAnimation } from
9
9
  import type { BehaviorExtension, UsdzBehaviour } from "./Behaviour.js";
10
10
  import { EmphasizeActionMotionType, GroupActionModel, Target } from "./BehavioursBuilder.js";
11
11
  /**
12
- * Make the object move to the target object's transform when clicked.
12
+ * Moves an object to the target object's transform when clicked.
13
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
14
+ *
15
+ * @see {@link SetActiveOnClick}to toggle visibility of objects when clicked
16
+ * @see {@link PlayAnimationOnClick} to play animations when clicked
17
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
13
18
  * @summary Moves an object to a target transform upon click
14
19
  * @category Everywhere Actions
15
20
  * @group Components
16
21
  */
17
22
  export declare class ChangeTransformOnClick extends Behaviour implements IPointerClickHandler, UsdzBehaviour {
23
+ /** The object to move. */
18
24
  object?: Object3D;
25
+ /** The target object whose transform to move to. */
19
26
  target?: Object3D;
27
+ /** The duration of the movement animation in seconds. */
20
28
  duration: number;
29
+ /** If true, the motion is relative to the object's current transform instead of moving to the target's absolute position. */
21
30
  relativeMotion: boolean;
22
31
  private coroutine;
23
32
  private targetPos;
24
33
  private targetRot;
25
34
  private targetScale;
26
- start(): void;
35
+ onEnable(): void;
36
+ onDisable(): void;
37
+ onDestroy(): void;
27
38
  onPointerEnter(): void;
28
39
  onPointerExit(): void;
29
40
  onPointerClick(args: PointerEventData): void;
@@ -32,7 +43,15 @@ export declare class ChangeTransformOnClick extends Behaviour implements IPointe
32
43
  beforeCreateDocument(ext: any): void;
33
44
  }
34
45
  /**
35
- * Change the material of objects when clicked.
46
+ * Switches the material of objects in the scene when clicked.
47
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
48
+ *
49
+ * Finds all objects in the scene that use `materialToSwitch` and replaces it with `variantMaterial`.
50
+ * Multiple `ChangeMaterialOnClick` components using the same `materialToSwitch` can be combined to create a material selection UI.
51
+ *
52
+ * @see {@link SetActiveOnClick} to toggle visibility of objects when clicked
53
+ * @see {@link PlayAnimationOnClick} to play animations when clicked
54
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
36
55
  * @summary Changes the material of objects when clicked
37
56
  * @category Everywhere Actions
38
57
  * @group Components
@@ -52,6 +71,9 @@ export declare class ChangeMaterialOnClick extends Behaviour implements IPointer
52
71
  */
53
72
  fadeDuration: number;
54
73
  start(): void;
74
+ onEnable(): void;
75
+ onDisable(): void;
76
+ onDestroy(): void;
55
77
  onPointerEnter(_args: PointerEventData): void;
56
78
  onPointerExit(_: PointerEventData): void;
57
79
  onPointerClick(args: PointerEventData): void;
@@ -72,17 +94,28 @@ export declare class ChangeMaterialOnClick extends Behaviour implements IPointer
72
94
  private createVariants;
73
95
  }
74
96
  /**
75
- * Set the active state of an object when clicked.
97
+ * Shows or hides a target object when this object is clicked.
98
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
99
+ *
100
+ * Optionally hides itself after being clicked (`hideSelf`), or toggles the target's visibility on each click (`toggleOnClick`).
101
+ *
102
+ * @see {@link HideOnStart}to hide an object when the scene starts
103
+ * @see {@link PlayAnimationOnClick} to play animations when clicked
104
+ * @see {@link ChangeMaterialOnClick} to change material when clicked
105
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
76
106
  * @summary Sets the active state of an object when clicked
77
107
  * @category Everywhere Actions
78
108
  * @group Components
79
109
  */
80
110
  export declare class SetActiveOnClick extends Behaviour implements IPointerClickHandler, UsdzBehaviour {
111
+ /** The target object to show or hide. */
81
112
  target?: Object3D;
113
+ /** If true, the target's visibility will be toggled on each click. When enabled, `hideSelf` and `targetState` are ignored. */
82
114
  toggleOnClick: boolean;
115
+ /** The visibility state to apply to the target when clicked. Only used when `toggleOnClick` is false. */
83
116
  targetState: boolean;
117
+ /** If true, this object will hide itself after being clicked. Only used when `toggleOnClick` is false. */
84
118
  hideSelf: boolean;
85
- start(): void;
86
119
  onPointerEnter(): void;
87
120
  onPointerExit(): void;
88
121
  onPointerClick(args: PointerEventData): void;
@@ -102,7 +135,13 @@ export declare class SetActiveOnClick extends Behaviour implements IPointerClick
102
135
  afterSerialize(_ext: BehaviorExtension, _context: USDZExporterContext): void;
103
136
  }
104
137
  /**
105
- * Hides the object on scene start.
138
+ * Hides the object when the scene starts.
139
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
140
+ *
141
+ * Useful for setting up objects that should initially be hidden and shown later via a {@link SetActiveOnClick} component.
142
+ *
143
+ * @see {@link SetActiveOnClick} to show or hide objects on click
144
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
106
145
  * @summary Hides the object on scene start
107
146
  * @category Everywhere Actions
108
147
  * @group Components
@@ -117,50 +156,93 @@ export declare class HideOnStart extends Behaviour implements UsdzBehaviour {
117
156
  beforeCreateDocument(): void;
118
157
  }
119
158
  /**
120
- * Emphasize the target object when clicked.
159
+ * Applies an emphasis animation to a target object when this object is clicked.
160
+ * Works in USDZ/QuickLook (Everywhere Actions).
161
+ *
162
+ * The emphasis effect can be a bounce, jiggle, or other motion type defined by `motionType`.
163
+ *
164
+ * @see {@link PlayAnimationOnClick} to play animations when clicked
165
+ * @see {@link SetActiveOnClick} to toggle visibility when clicked
166
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
121
167
  * @summary Emphasizes the target object when clicked
122
168
  * @category Everywhere Actions
123
169
  * @group Components
124
170
  */
125
171
  export declare class EmphasizeOnClick extends Behaviour implements UsdzBehaviour {
172
+ /** The target object to emphasize. */
126
173
  target?: Object3D;
174
+ /** The duration of the emphasis animation in seconds. */
127
175
  duration: number;
176
+ /** The type of motion to use for the emphasis effect (e.g. `"bounce"`, `"jiggle"`). */
128
177
  motionType: EmphasizeActionMotionType;
178
+ onEnable(): void;
179
+ onDisable(): void;
180
+ onDestroy(): void;
129
181
  beforeCreateDocument(): void;
130
182
  createBehaviours(ext: any, model: any, _context: any): void;
131
183
  afterCreateDocument(_ext: any, _context: any): void;
132
184
  }
133
185
  /**
134
- * Plays an audio clip when clicked.
186
+ * Plays an audio clip when this object is clicked.
187
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
188
+ *
189
+ * Assign a `target` {@link AudioSource} to use its spatial audio settings, or assign a `clip` URL directly.
190
+ * If no `target` is assigned, an {@link AudioSource} will be created automatically on this object.
191
+ *
192
+ * @see {@link AudioSource}for spatial audio settings
193
+ * @see {@link PlayAnimationOnClick} to play animations when clicked
194
+ * @see {@link SetActiveOnClick} to toggle visibility when clicked
195
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
135
196
  * @summary Plays an audio clip when clicked
136
197
  * @category Everywhere Actions
137
198
  * @group Components
138
199
  */
139
200
  export declare class PlayAudioOnClick extends Behaviour implements IPointerClickHandler, UsdzBehaviour {
201
+ /** The {@link AudioSource} to use for playback. If not set, one will be created automatically on this object. */
140
202
  target?: AudioSource;
203
+ /** URL of the audio clip to play. If not set, the clip assigned to `target` is used. */
141
204
  clip: string;
205
+ /** If true, clicking again while the audio is playing will stop it. */
142
206
  toggleOnClick: boolean;
143
207
  trigger: "tap" | "start";
144
- start(): void;
145
208
  ensureAudioSource(): void;
209
+ onEnable(): void;
210
+ onDisable(): void;
211
+ onDestroy(): void;
146
212
  onPointerEnter(): void;
147
213
  onPointerExit(): void;
148
214
  onPointerClick(args: PointerEventData): void;
149
215
  createBehaviours(ext: BehaviorExtension, model: USDObject, _context: USDZExporterContext): void;
150
216
  }
151
217
  /**
152
- * Plays an animation when clicked.
218
+ * Plays an animation state when this object is clicked.
219
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
220
+ *
221
+ * Assign an {@link Animator} and a `stateName` to play a specific animation state,
222
+ * or assign an {@link Animation} component to play a legacy animation clip.
223
+ *
224
+ * For USDZ export, the component follows animator state transitions automatically, including looping states.
225
+ *
226
+ * @see {@link Animator}for playing animator state machine animations
227
+ * @see {@link Animation} for playing legacy animation clips
228
+ * @see {@link PlayAudioOnClick} to play audio when clicked
229
+ * @see {@link SetActiveOnClick} to toggle visibility when clicked
230
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
153
231
  * @summary Plays an animation when clicked
154
232
  * @category Everywhere Actions
155
233
  * @group Components
156
234
  */
157
235
  export declare class PlayAnimationOnClick extends Behaviour implements IPointerClickHandler, UsdzBehaviour, UsdzAnimation {
236
+ /** The {@link Animator} component whose state to play when clicked. */
158
237
  animator?: Animator;
238
+ /** The name of the animation state to play. Required when using an {@link Animator}. */
159
239
  stateName?: string;
160
240
  trigger: "tap" | "start";
161
241
  animation?: Animation;
162
242
  private get target();
163
- start(): void;
243
+ onEnable(): void;
244
+ onDisable(): void;
245
+ onDestroy(): void;
164
246
  onPointerEnter(): void;
165
247
  onPointerExit(): void;
166
248
  onPointerClick(args: PointerEventData): void;
@@ -191,19 +273,31 @@ export declare class PreliminaryTrigger extends Behaviour {
191
273
  target?: PreliminaryAction;
192
274
  }
193
275
  /**
194
- * Hides or shows the object when clicked.
276
+ * Action to show or hide an object.
277
+ * Use together with a {@link TapGestureTrigger} to show or hide objects when tapped or clicked.
278
+ *
279
+ * @see {@link TapGestureTrigger} to trigger actions on tap/click
280
+ * @see {@link SetActiveOnClick} for a combined trigger and action component
281
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
195
282
  * @summary Hides or shows the object when clicked
196
283
  * @category Everywhere Actions
197
284
  * @group Components
198
285
  */
199
286
  export declare class VisibilityAction extends PreliminaryAction {
287
+ /** The type of visibility action to apply. */
200
288
  type: VisibilityActionType;
289
+ /** The duration of the fade animation in seconds. */
201
290
  duration: number;
202
291
  getType(): "show" | "hide";
203
292
  getDuration(): number;
204
293
  }
205
294
  /**
206
- * Triggers an action when the object is tapped/clicked.
295
+ * Triggers a {@link PreliminaryAction} (such as {@link VisibilityAction}) when the object is tapped or clicked.
296
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
297
+ *
298
+ * @see {@link VisibilityAction} for controlling object visibility on tap
299
+ * @see {@link SetActiveOnClick} for a combined trigger and action component
300
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
207
301
  * @summary Triggers an action when the object is tapped/clicked
208
302
  * @category Everywhere Actions
209
303
  * @group Components
@@ -16,38 +16,49 @@ import { Animator } from "../../../../Animator.js";
16
16
  import { AudioSource } from "../../../../AudioSource.js";
17
17
  import { Behaviour, GameObject } from "../../../../Component.js";
18
18
  import { Rigidbody } from "../../../../RigidBody.js";
19
- import { ObjectRaycaster, Raycaster } from "../../../../ui/Raycaster.js";
20
19
  import { makeNameSafeForUSD, USDDocument, USDObject } from "../../ThreeUSDZExporter.js";
21
20
  import { AnimationExtension } from "../Animation.js";
22
21
  import { AudioExtension } from "./AudioExtension.js";
23
22
  import { ActionBuilder, BehaviorModel, TriggerBuilder } from "./BehavioursBuilder.js";
24
23
  const debug = getParam("debugusdzbehaviours");
25
- function ensureRaycaster(obj) {
26
- if (!obj)
27
- return;
28
- if (!obj.getComponentInParent(Raycaster)) {
29
- if (isDevEnvironment())
30
- console.debug("Raycaster on \"" + obj.name + "\" was automatically added, because no raycaster was found in the parent hierarchy.");
31
- obj.addComponent(ObjectRaycaster);
32
- }
33
- }
34
24
  /**
35
- * Make the object move to the target object's transform when clicked.
25
+ * Moves an object to the target object's transform when clicked.
26
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
27
+ *
28
+ * @see {@link SetActiveOnClick}to toggle visibility of objects when clicked
29
+ * @see {@link PlayAnimationOnClick} to play animations when clicked
30
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
36
31
  * @summary Moves an object to a target transform upon click
37
32
  * @category Everywhere Actions
38
33
  * @group Components
39
34
  */
40
35
  export class ChangeTransformOnClick extends Behaviour {
36
+ /** The object to move. */
41
37
  object;
38
+ /** The target object whose transform to move to. */
42
39
  target;
40
+ /** The duration of the movement animation in seconds. */
43
41
  duration = 1;
42
+ /** If true, the motion is relative to the object's current transform instead of moving to the target's absolute position. */
44
43
  relativeMotion = false;
45
44
  coroutine = null;
46
45
  targetPos = new Vector3();
47
46
  targetRot = new Quaternion();
48
47
  targetScale = new Vector3();
49
- start() {
50
- ensureRaycaster(this.gameObject);
48
+ onEnable() {
49
+ this.context.accessibility.updateElement(this, {
50
+ role: "button",
51
+ label: "Move " + (this.object?.name || "object") + " to " + (this.target?.name || "target") + " on click",
52
+ hidden: false,
53
+ });
54
+ }
55
+ onDisable() {
56
+ this.context.accessibility.updateElement(this, {
57
+ hidden: true,
58
+ });
59
+ }
60
+ onDestroy() {
61
+ this.context.accessibility.removeElement(this);
51
62
  }
52
63
  onPointerEnter() {
53
64
  this.context.input.setCursor("pointer");
@@ -159,7 +170,15 @@ __decorate([
159
170
  serializable()
160
171
  ], ChangeTransformOnClick.prototype, "relativeMotion", void 0);
161
172
  /**
162
- * Change the material of objects when clicked.
173
+ * Switches the material of objects in the scene when clicked.
174
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
175
+ *
176
+ * Finds all objects in the scene that use `materialToSwitch` and replaces it with `variantMaterial`.
177
+ * Multiple `ChangeMaterialOnClick` components using the same `materialToSwitch` can be combined to create a material selection UI.
178
+ *
179
+ * @see {@link SetActiveOnClick} to toggle visibility of objects when clicked
180
+ * @see {@link PlayAnimationOnClick} to play animations when clicked
181
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
163
182
  * @summary Changes the material of objects when clicked
164
183
  * @category Everywhere Actions
165
184
  * @group Components
@@ -181,11 +200,25 @@ export class ChangeMaterialOnClick extends Behaviour {
181
200
  start() {
182
201
  // initialize the object list
183
202
  this._objectsWithThisMaterial = this.objectsWithThisMaterial;
184
- ensureRaycaster(this.gameObject);
185
203
  if (isDevEnvironment() && this._objectsWithThisMaterial.length <= 0) {
186
204
  console.warn("ChangeMaterialOnClick: No objects found with material \"" + this.materialToSwitch?.name + "\"");
187
205
  }
188
206
  }
207
+ onEnable() {
208
+ this.context.accessibility.updateElement(this, {
209
+ role: "button",
210
+ label: "Change material to " + (this.variantMaterial?.name || "unknown material"),
211
+ hidden: false,
212
+ });
213
+ }
214
+ onDisable() {
215
+ this.context.accessibility.updateElement(this, {
216
+ hidden: true,
217
+ });
218
+ }
219
+ onDestroy() {
220
+ this.context.accessibility.removeElement(this);
221
+ }
189
222
  onPointerEnter(_args) {
190
223
  this.context.input.setCursor("pointer");
191
224
  }
@@ -333,19 +366,28 @@ __decorate([
333
366
  serializable()
334
367
  ], ChangeMaterialOnClick.prototype, "fadeDuration", void 0);
335
368
  /**
336
- * Set the active state of an object when clicked.
369
+ * Shows or hides a target object when this object is clicked.
370
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
371
+ *
372
+ * Optionally hides itself after being clicked (`hideSelf`), or toggles the target's visibility on each click (`toggleOnClick`).
373
+ *
374
+ * @see {@link HideOnStart}to hide an object when the scene starts
375
+ * @see {@link PlayAnimationOnClick} to play animations when clicked
376
+ * @see {@link ChangeMaterialOnClick} to change material when clicked
377
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
337
378
  * @summary Sets the active state of an object when clicked
338
379
  * @category Everywhere Actions
339
380
  * @group Components
340
381
  */
341
382
  export class SetActiveOnClick extends Behaviour {
383
+ /** The target object to show or hide. */
342
384
  target;
385
+ /** If true, the target's visibility will be toggled on each click. When enabled, `hideSelf` and `targetState` are ignored. */
343
386
  toggleOnClick = false;
387
+ /** The visibility state to apply to the target when clicked. Only used when `toggleOnClick` is false. */
344
388
  targetState = true;
389
+ /** If true, this object will hide itself after being clicked. Only used when `toggleOnClick` is false. */
345
390
  hideSelf = true;
346
- start() {
347
- ensureRaycaster(this.gameObject);
348
- }
349
391
  onPointerEnter() {
350
392
  this.context.input.setCursor("pointer");
351
393
  }
@@ -533,7 +575,13 @@ __decorate([
533
575
  serializable()
534
576
  ], SetActiveOnClick.prototype, "hideSelf", void 0);
535
577
  /**
536
- * Hides the object on scene start.
578
+ * Hides the object when the scene starts.
579
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
580
+ *
581
+ * Useful for setting up objects that should initially be hidden and shown later via a {@link SetActiveOnClick} component.
582
+ *
583
+ * @see {@link SetActiveOnClick} to show or hide objects on click
584
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
537
585
  * @summary Hides the object on scene start
538
586
  * @category Everywhere Actions
539
587
  * @group Components
@@ -573,15 +621,40 @@ export class HideOnStart extends Behaviour {
573
621
  }
574
622
  }
575
623
  /**
576
- * Emphasize the target object when clicked.
624
+ * Applies an emphasis animation to a target object when this object is clicked.
625
+ * Works in USDZ/QuickLook (Everywhere Actions).
626
+ *
627
+ * The emphasis effect can be a bounce, jiggle, or other motion type defined by `motionType`.
628
+ *
629
+ * @see {@link PlayAnimationOnClick} to play animations when clicked
630
+ * @see {@link SetActiveOnClick} to toggle visibility when clicked
631
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
577
632
  * @summary Emphasizes the target object when clicked
578
633
  * @category Everywhere Actions
579
634
  * @group Components
580
635
  */
581
636
  export class EmphasizeOnClick extends Behaviour {
637
+ /** The target object to emphasize. */
582
638
  target;
639
+ /** The duration of the emphasis animation in seconds. */
583
640
  duration = 0.5;
641
+ /** The type of motion to use for the emphasis effect (e.g. `"bounce"`, `"jiggle"`). */
584
642
  motionType = "bounce";
643
+ onEnable() {
644
+ this.context.accessibility.updateElement(this, {
645
+ role: "button",
646
+ label: "Emphasize " + this.target?.name + " on click",
647
+ hidden: false,
648
+ });
649
+ }
650
+ onDisable() {
651
+ this.context.accessibility.updateElement(this, {
652
+ hidden: true,
653
+ });
654
+ }
655
+ onDestroy() {
656
+ this.context.accessibility.removeElement(this);
657
+ }
585
658
  beforeCreateDocument() { }
586
659
  createBehaviours(ext, model, _context) {
587
660
  if (!this.target)
@@ -603,20 +676,29 @@ __decorate([
603
676
  serializable()
604
677
  ], EmphasizeOnClick.prototype, "motionType", void 0);
605
678
  /**
606
- * Plays an audio clip when clicked.
679
+ * Plays an audio clip when this object is clicked.
680
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
681
+ *
682
+ * Assign a `target` {@link AudioSource} to use its spatial audio settings, or assign a `clip` URL directly.
683
+ * If no `target` is assigned, an {@link AudioSource} will be created automatically on this object.
684
+ *
685
+ * @see {@link AudioSource}for spatial audio settings
686
+ * @see {@link PlayAnimationOnClick} to play animations when clicked
687
+ * @see {@link SetActiveOnClick} to toggle visibility when clicked
688
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
607
689
  * @summary Plays an audio clip when clicked
608
690
  * @category Everywhere Actions
609
691
  * @group Components
610
692
  */
611
693
  export class PlayAudioOnClick extends Behaviour {
694
+ /** The {@link AudioSource} to use for playback. If not set, one will be created automatically on this object. */
612
695
  target;
696
+ /** URL of the audio clip to play. If not set, the clip assigned to `target` is used. */
613
697
  clip = "";
698
+ /** If true, clicking again while the audio is playing will stop it. */
614
699
  toggleOnClick = false;
615
700
  // Not exposed, but used for implicit playback of PlayOnAwake audio sources
616
701
  trigger = "tap";
617
- start() {
618
- ensureRaycaster(this.gameObject);
619
- }
620
702
  ensureAudioSource() {
621
703
  if (!this.target) {
622
704
  const newAudioSource = this.gameObject.addComponent(AudioSource);
@@ -629,6 +711,21 @@ export class PlayAudioOnClick extends Behaviour {
629
711
  }
630
712
  }
631
713
  }
714
+ onEnable() {
715
+ this.context.accessibility.updateElement(this, {
716
+ role: "button",
717
+ label: "Play audio: " + (this.clip || this.target?.clip || "unknown clip"),
718
+ hidden: false,
719
+ });
720
+ }
721
+ onDisable() {
722
+ this.context.accessibility.updateElement(this, {
723
+ hidden: true,
724
+ });
725
+ }
726
+ onDestroy() {
727
+ this.context.accessibility.removeElement(this);
728
+ }
632
729
  onPointerEnter() {
633
730
  this.context.input.setCursor("pointer");
634
731
  }
@@ -716,13 +813,27 @@ __decorate([
716
813
  serializable()
717
814
  ], PlayAudioOnClick.prototype, "toggleOnClick", void 0);
718
815
  /**
719
- * Plays an animation when clicked.
816
+ * Plays an animation state when this object is clicked.
817
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
818
+ *
819
+ * Assign an {@link Animator} and a `stateName` to play a specific animation state,
820
+ * or assign an {@link Animation} component to play a legacy animation clip.
821
+ *
822
+ * For USDZ export, the component follows animator state transitions automatically, including looping states.
823
+ *
824
+ * @see {@link Animator}for playing animator state machine animations
825
+ * @see {@link Animation} for playing legacy animation clips
826
+ * @see {@link PlayAudioOnClick} to play audio when clicked
827
+ * @see {@link SetActiveOnClick} to toggle visibility when clicked
828
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
720
829
  * @summary Plays an animation when clicked
721
830
  * @category Everywhere Actions
722
831
  * @group Components
723
832
  */
724
833
  export class PlayAnimationOnClick extends Behaviour {
834
+ /** The {@link Animator} component whose state to play when clicked. */
725
835
  animator;
836
+ /** The name of the animation state to play. Required when using an {@link Animator}. */
726
837
  stateName;
727
838
  // Not editable from the outside yet, but from code
728
839
  // we want to expose this once we have a nice drawer for "Triggers" (e.g. shows proximity distance)
@@ -730,11 +841,24 @@ export class PlayAnimationOnClick extends Behaviour {
730
841
  trigger = "tap"; // "proximity"
731
842
  animation;
732
843
  get target() { return this.animator?.gameObject || this.animation?.gameObject; }
733
- start() {
734
- ensureRaycaster(this.gameObject);
844
+ onEnable() {
845
+ this.context.accessibility.updateElement(this, {
846
+ role: "button",
847
+ label: "Plays animation " + (this.stateName || "") + " on " + (this.target ? this.target.name : ""),
848
+ hidden: false
849
+ });
850
+ }
851
+ onDisable() {
852
+ this.context.accessibility.updateElement(this, {
853
+ hidden: true,
854
+ });
855
+ }
856
+ onDestroy() {
857
+ this.context.accessibility.removeElement(this);
735
858
  }
736
859
  onPointerEnter() {
737
860
  this.context.input.setCursor("pointer");
861
+ this.context.accessibility.hover(this, "Click to play animation " + (this.stateName || "") + " on " + (this.target ? this.target.name : ""));
738
862
  }
739
863
  onPointerExit() {
740
864
  this.context.input.unsetCursor("pointer");
@@ -744,6 +868,7 @@ export class PlayAnimationOnClick extends Behaviour {
744
868
  if (!this.target)
745
869
  return;
746
870
  if (this.stateName) {
871
+ this.context.accessibility.focus(this);
747
872
  // TODO this is currently quite annoying to use,
748
873
  // as for the web we use the Animator component and its states directly,
749
874
  // while in QuickLook we use explicit animations / states.
@@ -1070,14 +1195,21 @@ __decorate([
1070
1195
  serializable(PreliminaryAction)
1071
1196
  ], PreliminaryTrigger.prototype, "target", void 0);
1072
1197
  /**
1073
- * Hides or shows the object when clicked.
1198
+ * Action to show or hide an object.
1199
+ * Use together with a {@link TapGestureTrigger} to show or hide objects when tapped or clicked.
1200
+ *
1201
+ * @see {@link TapGestureTrigger} to trigger actions on tap/click
1202
+ * @see {@link SetActiveOnClick} for a combined trigger and action component
1203
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
1074
1204
  * @summary Hides or shows the object when clicked
1075
1205
  * @category Everywhere Actions
1076
1206
  * @group Components
1077
1207
  */
1078
1208
  export class VisibilityAction extends PreliminaryAction {
1209
+ /** The type of visibility action to apply. */
1079
1210
  //@type int
1080
1211
  type = VisibilityActionType.Hide;
1212
+ /** The duration of the fade animation in seconds. */
1081
1213
  duration = 1;
1082
1214
  getType() {
1083
1215
  switch (this.type) {
@@ -1096,7 +1228,12 @@ __decorate([
1096
1228
  serializable()
1097
1229
  ], VisibilityAction.prototype, "duration", void 0);
1098
1230
  /**
1099
- * Triggers an action when the object is tapped/clicked.
1231
+ * Triggers a {@link PreliminaryAction} (such as {@link VisibilityAction}) when the object is tapped or clicked.
1232
+ * Works in the browser and in USDZ/QuickLook (Everywhere Actions).
1233
+ *
1234
+ * @see {@link VisibilityAction} for controlling object visibility on tap
1235
+ * @see {@link SetActiveOnClick} for a combined trigger and action component
1236
+ * @see [Everywhere Actions](https://engine.needle.tools/docs/everywhere-actions)
1100
1237
  * @summary Triggers an action when the object is tapped/clicked
1101
1238
  * @category Everywhere Actions
1102
1239
  * @group Components