@playcanvas/web-components 0.20.0 → 0.21.0

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 (100) hide show
  1. package/dist/app.d.cts +5 -113
  2. package/dist/app.d.ts +5 -113
  3. package/dist/asset-binding.d.cts +1 -0
  4. package/dist/asset-binding.d.ts +1 -0
  5. package/dist/components/anim-clip.d.cts +8 -10
  6. package/dist/components/anim-clip.d.ts +8 -10
  7. package/dist/components/anim-component.d.cts +5 -4
  8. package/dist/components/anim-component.d.ts +5 -4
  9. package/dist/components/audio-listener-component.d.cts +5 -4
  10. package/dist/components/audio-listener-component.d.ts +5 -4
  11. package/dist/components/button-component.d.cts +5 -4
  12. package/dist/components/button-component.d.ts +5 -4
  13. package/dist/components/camera-component.d.cts +5 -4
  14. package/dist/components/camera-component.d.ts +5 -4
  15. package/dist/components/collision-component.d.cts +5 -4
  16. package/dist/components/collision-component.d.ts +5 -4
  17. package/dist/components/component.d.cts +2 -2
  18. package/dist/components/component.d.ts +2 -2
  19. package/dist/components/element-component.d.cts +5 -4
  20. package/dist/components/element-component.d.ts +5 -4
  21. package/dist/components/gsplat-component.d.cts +5 -4
  22. package/dist/components/gsplat-component.d.ts +5 -4
  23. package/dist/components/joint-component.d.cts +5 -4
  24. package/dist/components/joint-component.d.ts +5 -4
  25. package/dist/components/layout-child-component.d.cts +5 -4
  26. package/dist/components/layout-child-component.d.ts +5 -4
  27. package/dist/components/layout-group-component.d.cts +5 -4
  28. package/dist/components/layout-group-component.d.ts +5 -4
  29. package/dist/components/light-component.d.cts +5 -4
  30. package/dist/components/light-component.d.ts +5 -4
  31. package/dist/components/particle-system-component.d.cts +22 -5
  32. package/dist/components/particle-system-component.d.ts +22 -5
  33. package/dist/components/render-component.d.cts +5 -4
  34. package/dist/components/render-component.d.ts +5 -4
  35. package/dist/components/rigid-body-component.d.cts +5 -4
  36. package/dist/components/rigid-body-component.d.ts +5 -4
  37. package/dist/components/screen-component.d.cts +5 -4
  38. package/dist/components/screen-component.d.ts +5 -4
  39. package/dist/components/script-component.d.cts +5 -4
  40. package/dist/components/script-component.d.ts +5 -4
  41. package/dist/components/scroll-view-component.d.cts +5 -4
  42. package/dist/components/scroll-view-component.d.ts +5 -4
  43. package/dist/components/scrollbar-component.d.cts +5 -4
  44. package/dist/components/scrollbar-component.d.ts +5 -4
  45. package/dist/components/sound-component.d.cts +5 -4
  46. package/dist/components/sound-component.d.ts +5 -4
  47. package/dist/custom-elements.json +38 -38
  48. package/dist/entity-reference.d.cts +13 -0
  49. package/dist/entity-reference.d.ts +13 -0
  50. package/dist/material.d.cts +8 -6
  51. package/dist/material.d.ts +8 -6
  52. package/dist/model.d.cts +8 -9
  53. package/dist/model.d.ts +8 -9
  54. package/dist/parse.d.cts +0 -8
  55. package/dist/parse.d.ts +0 -8
  56. package/dist/pointer-controller.d.cts +1 -0
  57. package/dist/pointer-controller.d.ts +1 -0
  58. package/dist/pwc.cjs +1360 -1186
  59. package/dist/pwc.cjs.map +1 -1
  60. package/dist/pwc.js +1360 -1186
  61. package/dist/pwc.js.map +1 -1
  62. package/dist/pwc.min.js +1 -1
  63. package/dist/pwc.min.js.map +1 -1
  64. package/dist/pwc.min.mjs +1 -1
  65. package/dist/pwc.min.mjs.map +1 -1
  66. package/dist/pwc.mjs +1361 -1187
  67. package/dist/pwc.mjs.map +1 -1
  68. package/dist/sky.d.cts +6 -7
  69. package/dist/sky.d.ts +6 -7
  70. package/dist/web-types.json +39 -39
  71. package/package.json +2 -2
  72. package/src/app.ts +16 -451
  73. package/src/asset-binding.ts +141 -0
  74. package/src/components/anim-clip.ts +22 -45
  75. package/src/components/anim-component.ts +10 -6
  76. package/src/components/audio-listener-component.ts +6 -5
  77. package/src/components/button-component.ts +8 -6
  78. package/src/components/camera-component.ts +6 -5
  79. package/src/components/collision-component.ts +6 -5
  80. package/src/components/component.ts +6 -4
  81. package/src/components/element-component.ts +6 -5
  82. package/src/components/gsplat-component.ts +6 -5
  83. package/src/components/joint-component.ts +8 -6
  84. package/src/components/layout-child-component.ts +6 -5
  85. package/src/components/layout-group-component.ts +6 -5
  86. package/src/components/light-component.ts +6 -5
  87. package/src/components/particle-system-component.ts +56 -30
  88. package/src/components/render-component.ts +6 -5
  89. package/src/components/rigid-body-component.ts +6 -5
  90. package/src/components/screen-component.ts +6 -5
  91. package/src/components/script-component.ts +8 -10
  92. package/src/components/scroll-view-component.ts +8 -6
  93. package/src/components/scrollbar-component.ts +8 -6
  94. package/src/components/sound-component.ts +6 -5
  95. package/src/entity-reference.ts +237 -0
  96. package/src/material.ts +25 -29
  97. package/src/model.ts +24 -48
  98. package/src/parse.ts +0 -232
  99. package/src/pointer-controller.ts +550 -0
  100. package/src/sky.ts +19 -30
package/dist/app.d.cts CHANGED
@@ -62,31 +62,13 @@ declare class AppElement extends AsyncElement {
62
62
  * engine scene nodes back to their owning elements by identity - never by name.
63
63
  */
64
64
  private _entityElements;
65
- private _picker;
66
- private _hoveredEntity;
67
- private _pickToken;
68
- private _pointerHandlers;
69
65
  /**
70
- * The pick of each pointer's primary-button press, keyed by pointerId and kept while a click
71
- * may still conclude it. The promise is stored rather than its result, so a release can
72
- * await a press pick that has not resolved yet. Entries are removed by the matching
73
- * pointerup or pointercancel, and only ever stored while some element listens for click -
74
- * which is also what keeps those two canvas listeners attached.
66
+ * The pointer-input subsystem: the picker, the canvas handlers, and the synthesized-event
67
+ * dispatch. The element drives its lifecycle (connect on boot, resize with the drawing
68
+ * buffer, listener syncs, disconnect on teardown) and hands it the two lookups it needs -
69
+ * everything else about pointer input lives in the controller.
75
70
  */
76
- private _downPicks;
77
- /** Whether any element in the tree listens for click. Maintained by _syncCanvasListeners. */
78
- private _clickListened;
79
- /**
80
- * The previous click's target, time and count, for chaining successive clicks into the
81
- * click count that `detail` carries. `null` until a click has fired.
82
- */
83
- private _lastClick;
84
- /**
85
- * Serializes dispatch of the discrete synthesized events (pointerdown, pointerup, click),
86
- * whose picks resolve in GPU order, not canvas-event order. Replaced on teardown, so a pick
87
- * that never resolves cannot stall the dispatches of a later boot.
88
- */
89
- private _dispatchChain;
71
+ private _pointer;
90
72
  private _app;
91
73
  private _loadProgress;
92
74
  /**
@@ -124,8 +106,6 @@ declare class AppElement extends AsyncElement {
124
106
  * an XR session presents - the session owns the buffer size.
125
107
  */
126
108
  private _syncCanvasSize;
127
- private _pickerCreate;
128
- private _pickerDestroy;
129
109
  /**
130
110
  * Returns the `<pc-entity>`, `<pc-model>` or `<pc-node>` element whose backing entity is
131
111
  * `entity`, or `null` if the entity is not fronted by an element of this application - for
@@ -136,94 +116,6 @@ declare class AppElement extends AsyncElement {
136
116
  * @returns The element fronting the entity, or `null`.
137
117
  */
138
118
  elementFromEntity(entity: Entity): EntityBaseElement | null;
139
- /**
140
- * Resolves the element that owns hover for a picked node: the nearest node up the parent
141
- * chain - starting with the node itself - whose element listens for any of the hover event
142
- * types. Skipping silent elements matches {@link _elementWithListener}, so a registered
143
- * element with no hover listeners (a `<pc-model>` host, a plain child entity) is transparent
144
- * to hover rather than swallowing a listening ancestor's enter/leave pair.
145
- *
146
- * @param node - The picked node, or `null`.
147
- * @returns The hover-owning element, or `null`.
148
- */
149
- private _hoverTarget;
150
- /**
151
- * Like {@link _elementFromNode}, but skips elements without a listener for `type`, so a hit
152
- * on an unlistened child still reaches a listening ancestor.
153
- *
154
- * @param node - The picked node, or `null`.
155
- * @param type - The pointer event type a listener is required for.
156
- * @returns The nearest listening element, or `null`.
157
- */
158
- private _elementWithListener;
159
- /**
160
- * Converts a pointer event's client coordinates into drawing-buffer coordinates - the space
161
- * the pick buffer and the camera viewports are laid out in. When the canvas has no CSS box
162
- * to map through (jsdom; a hidden canvas receives no pointer events in a browser), the
163
- * client coordinates are passed through unmapped and `mapped` is false, so callers know the
164
- * coordinates correspond to no real geometry.
165
- *
166
- * @param event - The pointer event to convert.
167
- * @param canvas - The canvas the event was dispatched on.
168
- * @returns The buffer-space coordinates, and whether they were actually mapped.
169
- */
170
- private _getPickerCoordinates;
171
- /**
172
- * Whether a camera's viewport contains the point. A camera renders into its normalized
173
- * `rect`, whose origin is the bottom-left of the canvas while buffer coordinates run from
174
- * the top-left - so the vertical test flips, as the engine's ElementInput flips it for UI
175
- * input. The right and bottom edges are exclusive: a viewport rasterizes the half-open
176
- * pixel range [left, right) x [top, bottom), so a coordinate on a shared edge belongs to
177
- * the viewport whose first pixel it is - never to the one it just left, whose pick buffer
178
- * holds nothing there.
179
- *
180
- * @param camera - The camera to test.
181
- * @param x - The x coordinate, in buffer space.
182
- * @param y - The y coordinate, in buffer space.
183
- * @param canvas - The canvas the coordinates are relative to.
184
- * @returns Whether the camera's viewport contains the point.
185
- */
186
- private _cameraContains;
187
- /**
188
- * Picks the scene under the pointer and returns the graph node that was hit, or `null`.
189
- *
190
- * The camera is resolved the way the engine's ElementInput resolves it for UI input:
191
- * enabled cameras are tried topmost-first (they render in ascending `priority` order),
192
- * skipping cameras that render to a texture and cameras whose viewport `rect` does not
193
- * contain the pointer. A camera that picks nothing ends the search if it clears the color
194
- * buffer - its background visually owns the pixel - and otherwise cedes to the cameras
195
- * beneath it, so an overlay camera only intercepts picks where it actually drew something.
196
- * The pick buffer is prepared per camera, so each camera picks from its own layers.
197
- *
198
- * The read back is asynchronous because the synchronous {@link Picker.getSelection} is not
199
- * supported on WebGPU, where it returns an empty selection rather than failing - which
200
- * silently disabled every `onpointer*` handler once WebGPU became the resolved backend. The
201
- * async variant works on both backends and does not block the main thread on a GPU read.
202
- *
203
- * @param event - The pointer event to pick under.
204
- * @returns The graph node under the pointer, or `null` if nothing was hit.
205
- */
206
- private _pickNode;
207
- private _onPointerMove;
208
- /**
209
- * Appends a dispatch step to {@link _dispatchChain}. Must be called synchronously from the
210
- * canvas event handler - the order of appends is what carries canvas-event order. A step
211
- * that rejects is reported and released, so the steps queued behind it still dispatch.
212
- *
213
- * @param step - The dispatch work to run once every earlier step has finished.
214
- */
215
- private _chainDispatch;
216
- private _onPointerDown;
217
- private _onPointerUp;
218
- /**
219
- * Attaches exactly the canvas listeners the tree's current element listeners need, and
220
- * detaches the rest. Recomputed whenever a listener connects or disconnects anywhere under
221
- * this element: several synthesized types can need the same canvas listener (enter, leave
222
- * and move all ride the move pick; click rides the down/up pair), so one type's removal
223
- * must not detach a listener another type still uses. Re-attaching an attached listener is
224
- * a no-op by EventTarget semantics, so no attach state is kept.
225
- */
226
- private _syncCanvasListeners;
227
119
  /**
228
120
  * Warns that a graphics option was written too late to have any effect. These options are read
229
121
  * once, when the element connects and creates its graphics device, so a later write updates
package/dist/app.d.ts CHANGED
@@ -62,31 +62,13 @@ declare class AppElement extends AsyncElement {
62
62
  * engine scene nodes back to their owning elements by identity - never by name.
63
63
  */
64
64
  private _entityElements;
65
- private _picker;
66
- private _hoveredEntity;
67
- private _pickToken;
68
- private _pointerHandlers;
69
65
  /**
70
- * The pick of each pointer's primary-button press, keyed by pointerId and kept while a click
71
- * may still conclude it. The promise is stored rather than its result, so a release can
72
- * await a press pick that has not resolved yet. Entries are removed by the matching
73
- * pointerup or pointercancel, and only ever stored while some element listens for click -
74
- * which is also what keeps those two canvas listeners attached.
66
+ * The pointer-input subsystem: the picker, the canvas handlers, and the synthesized-event
67
+ * dispatch. The element drives its lifecycle (connect on boot, resize with the drawing
68
+ * buffer, listener syncs, disconnect on teardown) and hands it the two lookups it needs -
69
+ * everything else about pointer input lives in the controller.
75
70
  */
76
- private _downPicks;
77
- /** Whether any element in the tree listens for click. Maintained by _syncCanvasListeners. */
78
- private _clickListened;
79
- /**
80
- * The previous click's target, time and count, for chaining successive clicks into the
81
- * click count that `detail` carries. `null` until a click has fired.
82
- */
83
- private _lastClick;
84
- /**
85
- * Serializes dispatch of the discrete synthesized events (pointerdown, pointerup, click),
86
- * whose picks resolve in GPU order, not canvas-event order. Replaced on teardown, so a pick
87
- * that never resolves cannot stall the dispatches of a later boot.
88
- */
89
- private _dispatchChain;
71
+ private _pointer;
90
72
  private _app;
91
73
  private _loadProgress;
92
74
  /**
@@ -124,8 +106,6 @@ declare class AppElement extends AsyncElement {
124
106
  * an XR session presents - the session owns the buffer size.
125
107
  */
126
108
  private _syncCanvasSize;
127
- private _pickerCreate;
128
- private _pickerDestroy;
129
109
  /**
130
110
  * Returns the `<pc-entity>`, `<pc-model>` or `<pc-node>` element whose backing entity is
131
111
  * `entity`, or `null` if the entity is not fronted by an element of this application - for
@@ -136,94 +116,6 @@ declare class AppElement extends AsyncElement {
136
116
  * @returns The element fronting the entity, or `null`.
137
117
  */
138
118
  elementFromEntity(entity: Entity): EntityBaseElement | null;
139
- /**
140
- * Resolves the element that owns hover for a picked node: the nearest node up the parent
141
- * chain - starting with the node itself - whose element listens for any of the hover event
142
- * types. Skipping silent elements matches {@link _elementWithListener}, so a registered
143
- * element with no hover listeners (a `<pc-model>` host, a plain child entity) is transparent
144
- * to hover rather than swallowing a listening ancestor's enter/leave pair.
145
- *
146
- * @param node - The picked node, or `null`.
147
- * @returns The hover-owning element, or `null`.
148
- */
149
- private _hoverTarget;
150
- /**
151
- * Like {@link _elementFromNode}, but skips elements without a listener for `type`, so a hit
152
- * on an unlistened child still reaches a listening ancestor.
153
- *
154
- * @param node - The picked node, or `null`.
155
- * @param type - The pointer event type a listener is required for.
156
- * @returns The nearest listening element, or `null`.
157
- */
158
- private _elementWithListener;
159
- /**
160
- * Converts a pointer event's client coordinates into drawing-buffer coordinates - the space
161
- * the pick buffer and the camera viewports are laid out in. When the canvas has no CSS box
162
- * to map through (jsdom; a hidden canvas receives no pointer events in a browser), the
163
- * client coordinates are passed through unmapped and `mapped` is false, so callers know the
164
- * coordinates correspond to no real geometry.
165
- *
166
- * @param event - The pointer event to convert.
167
- * @param canvas - The canvas the event was dispatched on.
168
- * @returns The buffer-space coordinates, and whether they were actually mapped.
169
- */
170
- private _getPickerCoordinates;
171
- /**
172
- * Whether a camera's viewport contains the point. A camera renders into its normalized
173
- * `rect`, whose origin is the bottom-left of the canvas while buffer coordinates run from
174
- * the top-left - so the vertical test flips, as the engine's ElementInput flips it for UI
175
- * input. The right and bottom edges are exclusive: a viewport rasterizes the half-open
176
- * pixel range [left, right) x [top, bottom), so a coordinate on a shared edge belongs to
177
- * the viewport whose first pixel it is - never to the one it just left, whose pick buffer
178
- * holds nothing there.
179
- *
180
- * @param camera - The camera to test.
181
- * @param x - The x coordinate, in buffer space.
182
- * @param y - The y coordinate, in buffer space.
183
- * @param canvas - The canvas the coordinates are relative to.
184
- * @returns Whether the camera's viewport contains the point.
185
- */
186
- private _cameraContains;
187
- /**
188
- * Picks the scene under the pointer and returns the graph node that was hit, or `null`.
189
- *
190
- * The camera is resolved the way the engine's ElementInput resolves it for UI input:
191
- * enabled cameras are tried topmost-first (they render in ascending `priority` order),
192
- * skipping cameras that render to a texture and cameras whose viewport `rect` does not
193
- * contain the pointer. A camera that picks nothing ends the search if it clears the color
194
- * buffer - its background visually owns the pixel - and otherwise cedes to the cameras
195
- * beneath it, so an overlay camera only intercepts picks where it actually drew something.
196
- * The pick buffer is prepared per camera, so each camera picks from its own layers.
197
- *
198
- * The read back is asynchronous because the synchronous {@link Picker.getSelection} is not
199
- * supported on WebGPU, where it returns an empty selection rather than failing - which
200
- * silently disabled every `onpointer*` handler once WebGPU became the resolved backend. The
201
- * async variant works on both backends and does not block the main thread on a GPU read.
202
- *
203
- * @param event - The pointer event to pick under.
204
- * @returns The graph node under the pointer, or `null` if nothing was hit.
205
- */
206
- private _pickNode;
207
- private _onPointerMove;
208
- /**
209
- * Appends a dispatch step to {@link _dispatchChain}. Must be called synchronously from the
210
- * canvas event handler - the order of appends is what carries canvas-event order. A step
211
- * that rejects is reported and released, so the steps queued behind it still dispatch.
212
- *
213
- * @param step - The dispatch work to run once every earlier step has finished.
214
- */
215
- private _chainDispatch;
216
- private _onPointerDown;
217
- private _onPointerUp;
218
- /**
219
- * Attaches exactly the canvas listeners the tree's current element listeners need, and
220
- * detaches the rest. Recomputed whenever a listener connects or disconnects anywhere under
221
- * this element: several synthesized types can need the same canvas listener (enter, leave
222
- * and move all ride the move pick; click rides the down/up pair), so one type's removal
223
- * must not detach a listener another type still uses. Re-attaching an attached listener is
224
- * a no-op by EventTarget semantics, so no attach state is kept.
225
- */
226
- private _syncCanvasListeners;
227
119
  /**
228
120
  * Warns that a graphics option was written too late to have any effect. These options are read
229
121
  * once, when the element connects and creates its graphics device, so a later write updates
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -28,6 +28,11 @@ declare class AnimClipElement extends AsyncElement {
28
28
  */
29
29
  private _animElement;
30
30
  private _asset;
31
+ /**
32
+ * Watches the current source asset while it loads. Starting a new resolution or
33
+ * disconnecting cancels it, so a superseded source can never hand its track to the parent.
34
+ */
35
+ private _binding;
31
36
  /**
32
37
  * Incremented on every connect and disconnect, and captured by connectedCallback on entry —
33
38
  * a resume from an await abandons itself if the value has moved on, so a stale callback can
@@ -35,19 +40,13 @@ declare class AnimClipElement extends AsyncElement {
35
40
  * own callback.
36
41
  */
37
42
  private _connectionGeneration;
38
- private _errorHandle;
39
43
  /**
40
44
  * Incremented on every track resolution and on disconnect, and captured by a resolution when
41
- * it starts. A resolution that resumes from an await or an asset callback abandons itself if
42
- * the value has moved on, so a superseded resolution cannot hand a stale track to the parent.
45
+ * it starts. A resolution that resumes from an await abandons itself if the value has moved
46
+ * on, so a superseded resolution cannot hand a stale track to the parent. The asset
47
+ * subscription itself is guarded by the binding above.
43
48
  */
44
49
  private _loadGeneration;
45
- /**
46
- * The pending asset subscriptions of the current resolution, if it is waiting for its asset.
47
- * Held so that whatever supersedes the resolution can detach the handlers from the asset,
48
- * rather than leave them registered until the asset settles (or forever, if it never does).
49
- */
50
- private _loadHandle;
51
50
  private _loop;
52
51
  private _name;
53
52
  private _speed;
@@ -64,7 +63,6 @@ declare class AnimClipElement extends AsyncElement {
64
63
  connectedCallback(): Promise<void>;
65
64
  disconnectedCallback(): void;
66
65
  protected get animElement(): AnimComponentElement | null;
67
- private _detachLoadHandlers;
68
66
  /**
69
67
  * Complains about the clip's source, once per source value — resolutions re-run on host
70
68
  * cycles and model reloads, and must not repeat the complaint.
@@ -28,6 +28,11 @@ declare class AnimClipElement extends AsyncElement {
28
28
  */
29
29
  private _animElement;
30
30
  private _asset;
31
+ /**
32
+ * Watches the current source asset while it loads. Starting a new resolution or
33
+ * disconnecting cancels it, so a superseded source can never hand its track to the parent.
34
+ */
35
+ private _binding;
31
36
  /**
32
37
  * Incremented on every connect and disconnect, and captured by connectedCallback on entry —
33
38
  * a resume from an await abandons itself if the value has moved on, so a stale callback can
@@ -35,19 +40,13 @@ declare class AnimClipElement extends AsyncElement {
35
40
  * own callback.
36
41
  */
37
42
  private _connectionGeneration;
38
- private _errorHandle;
39
43
  /**
40
44
  * Incremented on every track resolution and on disconnect, and captured by a resolution when
41
- * it starts. A resolution that resumes from an await or an asset callback abandons itself if
42
- * the value has moved on, so a superseded resolution cannot hand a stale track to the parent.
45
+ * it starts. A resolution that resumes from an await abandons itself if the value has moved
46
+ * on, so a superseded resolution cannot hand a stale track to the parent. The asset
47
+ * subscription itself is guarded by the binding above.
43
48
  */
44
49
  private _loadGeneration;
45
- /**
46
- * The pending asset subscriptions of the current resolution, if it is waiting for its asset.
47
- * Held so that whatever supersedes the resolution can detach the handlers from the asset,
48
- * rather than leave them registered until the asset settles (or forever, if it never does).
49
- */
50
- private _loadHandle;
51
50
  private _loop;
52
51
  private _name;
53
52
  private _speed;
@@ -64,7 +63,6 @@ declare class AnimClipElement extends AsyncElement {
64
63
  connectedCallback(): Promise<void>;
65
64
  disconnectedCallback(): void;
66
65
  protected get animElement(): AnimComponentElement | null;
67
- private _detachLoadHandlers;
68
66
  /**
69
67
  * Complains about the clip's source, once per source value — resolutions re-run on host
70
68
  * cycles and model reloads, and must not repeat the complaint.
@@ -34,7 +34,7 @@ type ContainerWithAnimations = ContainerResource & {
34
34
  *
35
35
  * @category Components
36
36
  */
37
- declare class AnimComponentElement extends ComponentElement {
37
+ declare class AnimComponentElement extends ComponentElement<AnimComponent> {
38
38
  /**
39
39
  * Whether playback starts automatically once a clip is assigned.
40
40
  */
@@ -179,10 +179,11 @@ declare class AnimComponentElement extends ComponentElement {
179
179
  */
180
180
  transition(name: string, time?: number): void;
181
181
  /**
182
- * Gets the underlying PlayCanvas anim component.
183
- * @returns The anim component.
182
+ * Gets the underlying PlayCanvas anim component. `null` until the element is
183
+ * ready see {@link ComponentElement.component}.
184
+ * @returns The anim component, or `null`.
184
185
  */
185
- get component(): AnimComponent;
186
+ get component(): AnimComponent | null;
186
187
  /**
187
188
  * Gets the names of the assigned clips.
188
189
  * @returns The clip names, in assignment order.
@@ -34,7 +34,7 @@ type ContainerWithAnimations = ContainerResource & {
34
34
  *
35
35
  * @category Components
36
36
  */
37
- declare class AnimComponentElement extends ComponentElement {
37
+ declare class AnimComponentElement extends ComponentElement<AnimComponent> {
38
38
  /**
39
39
  * Whether playback starts automatically once a clip is assigned.
40
40
  */
@@ -179,10 +179,11 @@ declare class AnimComponentElement extends ComponentElement {
179
179
  */
180
180
  transition(name: string, time?: number): void;
181
181
  /**
182
- * Gets the underlying PlayCanvas anim component.
183
- * @returns The anim component.
182
+ * Gets the underlying PlayCanvas anim component. `null` until the element is
183
+ * ready see {@link ComponentElement.component}.
184
+ * @returns The anim component, or `null`.
184
185
  */
185
- get component(): AnimComponent;
186
+ get component(): AnimComponent | null;
186
187
  /**
187
188
  * Gets the names of the assigned clips.
188
189
  * @returns The clip names, in assignment order.
@@ -14,13 +14,14 @@ import { ComponentElement } from './component.cjs';
14
14
  *
15
15
  * @category Components
16
16
  */
17
- declare class AudioListenerComponentElement extends ComponentElement {
17
+ declare class AudioListenerComponentElement extends ComponentElement<AudioListenerComponent> {
18
18
  /** @ignore */
19
19
  constructor();
20
20
  /**
21
- * Gets the underlying PlayCanvas audio listener component.
22
- * @returns The audio listener component.
21
+ * Gets the underlying PlayCanvas audio listener component. `null` until the element is
22
+ * ready see {@link ComponentElement.component}.
23
+ * @returns The audio listener component, or `null`.
23
24
  */
24
- get component(): AudioListenerComponent;
25
+ get component(): AudioListenerComponent | null;
25
26
  }
26
27
  export { AudioListenerComponentElement };
@@ -14,13 +14,14 @@ import { ComponentElement } from './component.js';
14
14
  *
15
15
  * @category Components
16
16
  */
17
- declare class AudioListenerComponentElement extends ComponentElement {
17
+ declare class AudioListenerComponentElement extends ComponentElement<AudioListenerComponent> {
18
18
  /** @ignore */
19
19
  constructor();
20
20
  /**
21
- * Gets the underlying PlayCanvas audio listener component.
22
- * @returns The audio listener component.
21
+ * Gets the underlying PlayCanvas audio listener component. `null` until the element is
22
+ * ready see {@link ComponentElement.component}.
23
+ * @returns The audio listener component, or `null`.
23
24
  */
24
- get component(): AudioListenerComponent;
25
+ get component(): AudioListenerComponent | null;
25
26
  }
26
27
  export { AudioListenerComponentElement };
@@ -16,7 +16,7 @@ import { ComponentElement } from './component.cjs';
16
16
  *
17
17
  * @category Components
18
18
  */
19
- declare class ButtonComponentElement extends ComponentElement {
19
+ declare class ButtonComponentElement extends ComponentElement<ButtonComponent> {
20
20
  private _active;
21
21
  private _image;
22
22
  private _hitPadding;
@@ -35,10 +35,11 @@ declare class ButtonComponentElement extends ComponentElement {
35
35
  constructor();
36
36
  protected getInitialComponentData(): Record<string, any>;
37
37
  /**
38
- * Gets the underlying PlayCanvas button component.
39
- * @returns The button component.
38
+ * Gets the underlying PlayCanvas button component. `null` until the element is
39
+ * ready see {@link ComponentElement.component}.
40
+ * @returns The button component, or `null`.
40
41
  */
41
- get component(): ButtonComponent;
42
+ get component(): ButtonComponent | null;
42
43
  /**
43
44
  * Sets whether the button is active and responds to input.
44
45
  * @param value - Whether the button is active.
@@ -16,7 +16,7 @@ import { ComponentElement } from './component.js';
16
16
  *
17
17
  * @category Components
18
18
  */
19
- declare class ButtonComponentElement extends ComponentElement {
19
+ declare class ButtonComponentElement extends ComponentElement<ButtonComponent> {
20
20
  private _active;
21
21
  private _image;
22
22
  private _hitPadding;
@@ -35,10 +35,11 @@ declare class ButtonComponentElement extends ComponentElement {
35
35
  constructor();
36
36
  protected getInitialComponentData(): Record<string, any>;
37
37
  /**
38
- * Gets the underlying PlayCanvas button component.
39
- * @returns The button component.
38
+ * Gets the underlying PlayCanvas button component. `null` until the element is
39
+ * ready see {@link ComponentElement.component}.
40
+ * @returns The button component, or `null`.
40
41
  */
41
- get component(): ButtonComponent;
42
+ get component(): ButtonComponent | null;
42
43
  /**
43
44
  * Sets whether the button is active and responds to input.
44
45
  * @param value - Whether the button is active.
@@ -15,7 +15,7 @@ import { ComponentElement } from './component.cjs';
15
15
  *
16
16
  * @category Components
17
17
  */
18
- declare class CameraComponentElement extends ComponentElement {
18
+ declare class CameraComponentElement extends ComponentElement<CameraComponent> {
19
19
  private _clearColor;
20
20
  private _clearColorBuffer;
21
21
  private _clearDepth;
@@ -88,10 +88,11 @@ declare class CameraComponentElement extends ComponentElement {
88
88
  */
89
89
  endXr(): void;
90
90
  /**
91
- * Gets the underlying PlayCanvas camera component.
92
- * @returns The camera component.
91
+ * Gets the underlying PlayCanvas camera component. `null` until the element is
92
+ * ready see {@link ComponentElement.component}.
93
+ * @returns The camera component, or `null`.
93
94
  */
94
- get component(): CameraComponent;
95
+ get component(): CameraComponent | null;
95
96
  /**
96
97
  * Sets the clear color of the camera.
97
98
  * @param value - The clear color.
@@ -15,7 +15,7 @@ import { ComponentElement } from './component.js';
15
15
  *
16
16
  * @category Components
17
17
  */
18
- declare class CameraComponentElement extends ComponentElement {
18
+ declare class CameraComponentElement extends ComponentElement<CameraComponent> {
19
19
  private _clearColor;
20
20
  private _clearColorBuffer;
21
21
  private _clearDepth;
@@ -88,10 +88,11 @@ declare class CameraComponentElement extends ComponentElement {
88
88
  */
89
89
  endXr(): void;
90
90
  /**
91
- * Gets the underlying PlayCanvas camera component.
92
- * @returns The camera component.
91
+ * Gets the underlying PlayCanvas camera component. `null` until the element is
92
+ * ready see {@link ComponentElement.component}.
93
+ * @returns The camera component, or `null`.
93
94
  */
94
- get component(): CameraComponent;
95
+ get component(): CameraComponent | null;
95
96
  /**
96
97
  * Sets the clear color of the camera.
97
98
  * @param value - The clear color.
@@ -21,7 +21,7 @@ import { ComponentElement } from './component.cjs';
21
21
  *
22
22
  * @category Components
23
23
  */
24
- declare class CollisionComponentElement extends ComponentElement {
24
+ declare class CollisionComponentElement extends ComponentElement<CollisionComponent> {
25
25
  private _angularOffset;
26
26
  private _axis;
27
27
  private _convexHull;
@@ -55,10 +55,11 @@ declare class CollisionComponentElement extends ComponentElement {
55
55
  */
56
56
  private _applyMeshGeometryDefault;
57
57
  /**
58
- * Gets the underlying PlayCanvas collision component.
59
- * @returns The collision component.
58
+ * Gets the underlying PlayCanvas collision component. `null` until the element is
59
+ * ready see {@link ComponentElement.component}.
60
+ * @returns The collision component, or `null`.
60
61
  */
61
- get component(): CollisionComponent;
62
+ get component(): CollisionComponent | null;
62
63
  set angularOffset(value: Quat);
63
64
  get angularOffset(): Quat;
64
65
  set axis(value: number);
@@ -21,7 +21,7 @@ import { ComponentElement } from './component.js';
21
21
  *
22
22
  * @category Components
23
23
  */
24
- declare class CollisionComponentElement extends ComponentElement {
24
+ declare class CollisionComponentElement extends ComponentElement<CollisionComponent> {
25
25
  private _angularOffset;
26
26
  private _axis;
27
27
  private _convexHull;
@@ -55,10 +55,11 @@ declare class CollisionComponentElement extends ComponentElement {
55
55
  */
56
56
  private _applyMeshGeometryDefault;
57
57
  /**
58
- * Gets the underlying PlayCanvas collision component.
59
- * @returns The collision component.
58
+ * Gets the underlying PlayCanvas collision component. `null` until the element is
59
+ * ready see {@link ComponentElement.component}.
60
+ * @returns The collision component, or `null`.
60
61
  */
61
- get component(): CollisionComponent;
62
+ get component(): CollisionComponent | null;
62
63
  set angularOffset(value: Quat);
63
64
  get angularOffset(): Quat;
64
65
  set axis(value: number);
@@ -5,7 +5,7 @@ import { AsyncElement } from '../async-element.cjs';
5
5
  *
6
6
  * @category Components
7
7
  */
8
- declare class ComponentElement extends AsyncElement {
8
+ declare class ComponentElement<T extends Component = Component> extends AsyncElement {
9
9
  private _componentName;
10
10
  private _enabled;
11
11
  private _component;
@@ -66,7 +66,7 @@ declare class ComponentElement extends AsyncElement {
66
66
  * before accessing it.
67
67
  * @returns The component instance, or `null`.
68
68
  */
69
- get component(): Component | null;
69
+ get component(): T | null;
70
70
  /**
71
71
  * Sets the enabled state of the component.
72
72
  * @param value - The enabled state of the component.
@@ -5,7 +5,7 @@ import { AsyncElement } from '../async-element.js';
5
5
  *
6
6
  * @category Components
7
7
  */
8
- declare class ComponentElement extends AsyncElement {
8
+ declare class ComponentElement<T extends Component = Component> extends AsyncElement {
9
9
  private _componentName;
10
10
  private _enabled;
11
11
  private _component;
@@ -66,7 +66,7 @@ declare class ComponentElement extends AsyncElement {
66
66
  * before accessing it.
67
67
  * @returns The component instance, or `null`.
68
68
  */
69
- get component(): Component | null;
69
+ get component(): T | null;
70
70
  /**
71
71
  * Sets the enabled state of the component.
72
72
  * @param value - The enabled state of the component.