@playcanvas/web-components 0.18.0 → 0.19.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.
package/dist/app.d.cts CHANGED
@@ -63,10 +63,24 @@ declare class AppElement extends AsyncElement {
63
63
  */
64
64
  private _entityElements;
65
65
  private _picker;
66
- private _hasPointerListeners;
67
66
  private _hoveredEntity;
68
67
  private _pickToken;
69
68
  private _pointerHandlers;
69
+ /**
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.
75
+ */
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;
70
84
  private _app;
71
85
  private _loadProgress;
72
86
  /**
@@ -187,8 +201,15 @@ declare class AppElement extends AsyncElement {
187
201
  private _onPointerMove;
188
202
  private _onPointerDown;
189
203
  private _onPointerUp;
190
- private _onPointerListenerAdded;
191
- private _onPointerListenerRemoved;
204
+ /**
205
+ * Attaches exactly the canvas listeners the tree's current element listeners need, and
206
+ * detaches the rest. Recomputed whenever a listener connects or disconnects anywhere under
207
+ * this element: several synthesized types can need the same canvas listener (enter, leave
208
+ * and move all ride the move pick; click rides the down/up pair), so one type's removal
209
+ * must not detach a listener another type still uses. Re-attaching an attached listener is
210
+ * a no-op by EventTarget semantics, so no attach state is kept.
211
+ */
212
+ private _syncCanvasListeners;
192
213
  /**
193
214
  * Warns that a graphics option was written too late to have any effect. These options are read
194
215
  * once, when the element connects and creates its graphics device, so a later write updates
package/dist/app.d.ts CHANGED
@@ -63,10 +63,24 @@ declare class AppElement extends AsyncElement {
63
63
  */
64
64
  private _entityElements;
65
65
  private _picker;
66
- private _hasPointerListeners;
67
66
  private _hoveredEntity;
68
67
  private _pickToken;
69
68
  private _pointerHandlers;
69
+ /**
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.
75
+ */
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;
70
84
  private _app;
71
85
  private _loadProgress;
72
86
  /**
@@ -187,8 +201,15 @@ declare class AppElement extends AsyncElement {
187
201
  private _onPointerMove;
188
202
  private _onPointerDown;
189
203
  private _onPointerUp;
190
- private _onPointerListenerAdded;
191
- private _onPointerListenerRemoved;
204
+ /**
205
+ * Attaches exactly the canvas listeners the tree's current element listeners need, and
206
+ * detaches the rest. Recomputed whenever a listener connects or disconnects anywhere under
207
+ * this element: several synthesized types can need the same canvas listener (enter, leave
208
+ * and move all ride the move pick; click rides the down/up pair), so one type's removal
209
+ * must not detach a listener another type still uses. Re-attaching an attached listener is
210
+ * a no-op by EventTarget semantics, so no attach state is kept.
211
+ */
212
+ private _syncCanvasListeners;
192
213
  /**
193
214
  * Warns that a graphics option was written too late to have any effect. These options are read
194
215
  * once, when the element connects and creates its graphics device, so a later write updates
@@ -16,8 +16,6 @@ import { AnimComponentElement } from './anim-component.cjs';
16
16
  * @elementSummary The `<pc-anim-clip>` element declares one named animation clip on its parent
17
17
  * `<pc-anim>`, taken from the `asset` it names or, without one, from the enclosing `<pc-model>`'s
18
18
  * own animations. Must be a direct child of `<pc-anim>`.
19
- *
20
- * @category Components
21
19
  */
22
20
  declare class AnimClipElement extends AsyncElement {
23
21
  /**
@@ -16,8 +16,6 @@ import { AnimComponentElement } from './anim-component.js';
16
16
  * @elementSummary The `<pc-anim-clip>` element declares one named animation clip on its parent
17
17
  * `<pc-anim>`, taken from the `asset` it names or, without one, from the enclosing `<pc-model>`'s
18
18
  * own animations. Must be a direct child of `<pc-anim>`.
19
- *
20
- * @category Components
21
19
  */
22
20
  declare class AnimClipElement extends AsyncElement {
23
21
  /**
@@ -1378,9 +1378,16 @@
1378
1378
  "declarations": [
1379
1379
  {
1380
1380
  "kind": "class",
1381
- "description": "The EntityElement interface provides properties and methods for manipulating\n[`<pc-entity>`](https://developer.playcanvas.com/user-manual/web-components/tags/pc-entity/) elements.\nThe EntityElement interface also inherits the properties and methods of the\nHTMLElement interface.\n\nThe pointer events below are dispatched by the containing `<pc-app>` element when the pointer\nintersects this entity's geometry. They are only generated while the entity has a listener for\nthem, registered either with EventTarget.addEventListener or with the matching inline `onpointer*`\nattribute.\n",
1381
+ "description": "The EntityElement interface provides properties and methods for manipulating\n[`<pc-entity>`](https://developer.playcanvas.com/user-manual/web-components/tags/pc-entity/) elements.\nThe EntityElement interface also inherits the properties and methods of the\nHTMLElement interface.\n\nThe pointer events below are dispatched by the containing `<pc-app>` element when the pointer\nintersects this entity's geometry. They are only generated while the entity has a listener for\nthem, registered either with EventTarget.addEventListener or with the matching inline\nattribute (`onpointerdown`, `onclick`, ...).\n",
1382
1382
  "name": "EntityElement",
1383
1383
  "events": [
1384
+ {
1385
+ "type": {
1386
+ "text": "PointerEvent"
1387
+ },
1388
+ "description": "Fired when a primary pointer button is pressed and then released over the entity. A press and release that picked different entities fires on their nearest common ancestor instead, as in the DOM. `detail` carries the click count, so a double click arrives as a click whose `detail` is 2.",
1389
+ "name": "click"
1390
+ },
1384
1391
  {
1385
1392
  "type": {
1386
1393
  "text": "PointerEvent"
@@ -1446,6 +1453,14 @@
1446
1453
  "description": "The name of the entity.",
1447
1454
  "fieldName": "name"
1448
1455
  },
1456
+ {
1457
+ "type": {
1458
+ "text": "string"
1459
+ },
1460
+ "description": "Script to run when the entity is clicked: a primary pointer button pressed and then released over it.",
1461
+ "name": "onclick",
1462
+ "fieldName": "onclick"
1463
+ },
1449
1464
  {
1450
1465
  "type": {
1451
1466
  "text": "string"
@@ -4711,6 +4726,13 @@
4711
4726
  }
4712
4727
  ],
4713
4728
  "events": [
4729
+ {
4730
+ "type": {
4731
+ "text": "PointerEvent"
4732
+ },
4733
+ "description": "Fired when a primary pointer button is pressed and then released over the model. A press and release that picked different entities fires on their nearest common ancestor instead, as in the DOM. `detail` carries the click count, so a double click arrives as a click whose `detail` is 2.",
4734
+ "name": "click"
4735
+ },
4714
4736
  {
4715
4737
  "name": "error",
4716
4738
  "type": {
@@ -4798,6 +4820,14 @@
4798
4820
  "description": "The name of the model.",
4799
4821
  "fieldName": "name"
4800
4822
  },
4823
+ {
4824
+ "type": {
4825
+ "text": "string"
4826
+ },
4827
+ "description": "Script to run when the model is clicked: a primary pointer button pressed and then released over it.",
4828
+ "name": "onclick",
4829
+ "fieldName": "onclick"
4830
+ },
4801
4831
  {
4802
4832
  "type": {
4803
4833
  "text": "string"
@@ -5235,6 +5265,13 @@
5235
5265
  }
5236
5266
  ],
5237
5267
  "events": [
5268
+ {
5269
+ "type": {
5270
+ "text": "PointerEvent"
5271
+ },
5272
+ "description": "Fired when a primary pointer button is pressed and then released over the node. A press and release that picked different entities fires on their nearest common ancestor instead, as in the DOM. `detail` carries the click count, so a double click arrives as a click whose `detail` is 2.",
5273
+ "name": "click"
5274
+ },
5238
5275
  {
5239
5276
  "type": {
5240
5277
  "text": "PointerEvent"
@@ -5315,6 +5352,14 @@
5315
5352
  "description": "The name of the node to bind, resolved within the nearest ancestor `pc-model` (or `pc-node`) once it has instantiated.",
5316
5353
  "fieldName": "name"
5317
5354
  },
5355
+ {
5356
+ "type": {
5357
+ "text": "string"
5358
+ },
5359
+ "description": "Script to run when the node is clicked: a primary pointer button pressed and then released over it.",
5360
+ "name": "onclick",
5361
+ "fieldName": "onclick"
5362
+ },
5318
5363
  {
5319
5364
  "type": {
5320
5365
  "text": "string"
@@ -5469,6 +5514,22 @@
5469
5514
  "module": "src/async-element.ts"
5470
5515
  }
5471
5516
  },
5517
+ {
5518
+ "kind": "field",
5519
+ "name": "exposure",
5520
+ "description": "Gets the exposure of the scene.",
5521
+ "parameters": [
5522
+ {
5523
+ "description": "The exposure.",
5524
+ "name": "value"
5525
+ }
5526
+ ],
5527
+ "return": {
5528
+ "type": {
5529
+ "text": ""
5530
+ }
5531
+ }
5532
+ },
5472
5533
  {
5473
5534
  "kind": "field",
5474
5535
  "name": "fog",
@@ -5595,6 +5656,15 @@
5595
5656
  }
5596
5657
  ],
5597
5658
  "attributes": [
5659
+ {
5660
+ "name": "exposure",
5661
+ "type": {
5662
+ "text": "number"
5663
+ },
5664
+ "fieldName": "exposure",
5665
+ "default": "1",
5666
+ "description": "The exposure of the scene."
5667
+ },
5598
5668
  {
5599
5669
  "name": "fog",
5600
5670
  "type": {
@@ -5654,7 +5724,7 @@
5654
5724
  "name": "AsyncElement",
5655
5725
  "module": "/src/async-element"
5656
5726
  },
5657
- "summary": "The `<pc-scene>` element holds the entity hierarchy the application renders,\nalong with the scene-wide fog and gravity settings. Must be a direct child of `<pc-app>`.\n",
5727
+ "summary": "The `<pc-scene>` element holds the entity hierarchy the application renders,\nalong with the scene-wide fog, exposure and gravity settings. Must be a direct child of\n`<pc-app>`.\n",
5658
5728
  "tagName": "pc-scene",
5659
5729
  "customElement": true,
5660
5730
  "events": [
@@ -17,11 +17,12 @@ declare class EntityBaseElement extends AsyncElement {
17
17
  */
18
18
  protected _appElement: AppElement | null;
19
19
  /**
20
- * The pointer event listeners for the entity.
20
+ * The event listeners registered on the element, by type.
21
21
  */
22
22
  private _listeners;
23
23
  /**
24
- * The event types for which an inline `onpointer*` attribute is currently present.
24
+ * The event types for which an inline handler attribute (`onpointerdown`, `onclick`, ...)
25
+ * is currently present.
25
26
  */
26
27
  private _inlineHandlerTypes;
27
28
  /**
@@ -45,7 +46,7 @@ declare class EntityBaseElement extends AsyncElement {
45
46
  */
46
47
  protected _unregisterEntity(entity: Entity): void;
47
48
  /**
48
- * Tracks whether an inline `onpointer*` attribute is present. The browser itself compiles and
49
+ * Tracks whether an inline handler attribute is present. The browser itself compiles and
49
50
  * runs these attributes — they are standard `GlobalEventHandlers`, so setting one replaces
50
51
  * the previous handler and removing it removes the handler, exactly like `onclick` on any
51
52
  * HTML element. But because they bypass {@link EventTarget.addEventListener}, the connect/disconnect
@@ -17,11 +17,12 @@ declare class EntityBaseElement extends AsyncElement {
17
17
  */
18
18
  protected _appElement: AppElement | null;
19
19
  /**
20
- * The pointer event listeners for the entity.
20
+ * The event listeners registered on the element, by type.
21
21
  */
22
22
  private _listeners;
23
23
  /**
24
- * The event types for which an inline `onpointer*` attribute is currently present.
24
+ * The event types for which an inline handler attribute (`onpointerdown`, `onclick`, ...)
25
+ * is currently present.
25
26
  */
26
27
  private _inlineHandlerTypes;
27
28
  /**
@@ -45,7 +46,7 @@ declare class EntityBaseElement extends AsyncElement {
45
46
  */
46
47
  protected _unregisterEntity(entity: Entity): void;
47
48
  /**
48
- * Tracks whether an inline `onpointer*` attribute is present. The browser itself compiles and
49
+ * Tracks whether an inline handler attribute is present. The browser itself compiles and
49
50
  * runs these attributes — they are standard `GlobalEventHandlers`, so setting one replaces
50
51
  * the previous handler and removing it removes the handler, exactly like `onclick` on any
51
52
  * HTML element. But because they bypass {@link EventTarget.addEventListener}, the connect/disconnect
package/dist/entity.d.cts CHANGED
@@ -7,8 +7,8 @@ import { EntityOwnerElement } from './entity-owner.cjs';
7
7
  *
8
8
  * The pointer events below are dispatched by the containing `<pc-app>` element when the pointer
9
9
  * intersects this entity's geometry. They are only generated while the entity has a listener for
10
- * them, registered either with {@link EventTarget.addEventListener} or with the matching inline `onpointer*`
11
- * attribute.
10
+ * them, registered either with {@link EventTarget.addEventListener} or with the matching inline
11
+ * attribute (`onpointerdown`, `onclick`, ...).
12
12
  *
13
13
  * @elementSummary The `<pc-entity>` element creates an entity: a named, transformable node of the
14
14
  * scene hierarchy, and the host for component elements such as `<pc-camera>`, `<pc-light>` and
@@ -28,11 +28,17 @@ import { EntityOwnerElement } from './entity-owner.cjs';
28
28
  * entity.
29
29
  * @attribute {string} onpointerup - Script to run when a pointer button is released over the
30
30
  * entity.
31
+ * @attribute {string} onclick - Script to run when the entity is clicked: a primary pointer
32
+ * button pressed and then released over it.
31
33
  * @fires {PointerEvent} pointerenter - Fired when the pointer moves onto the entity.
32
34
  * @fires {PointerEvent} pointerleave - Fired when the pointer moves off the entity.
33
35
  * @fires {PointerEvent} pointermove - Fired when the pointer moves over the entity.
34
36
  * @fires {PointerEvent} pointerdown - Fired when a pointer button is pressed over the entity.
35
37
  * @fires {PointerEvent} pointerup - Fired when a pointer button is released over the entity.
38
+ * @fires {PointerEvent} click - Fired when a primary pointer button is pressed and then released
39
+ * over the entity. A press and release that picked different entities fires on their nearest
40
+ * common ancestor instead, as in the DOM. `detail` carries the click count, so a double click
41
+ * arrives as a click whose `detail` is 2.
36
42
  */
37
43
  declare class EntityElement extends EntityOwnerElement {
38
44
  connectedCallback(): void;
package/dist/entity.d.ts CHANGED
@@ -7,8 +7,8 @@ import { EntityOwnerElement } from './entity-owner.js';
7
7
  *
8
8
  * The pointer events below are dispatched by the containing `<pc-app>` element when the pointer
9
9
  * intersects this entity's geometry. They are only generated while the entity has a listener for
10
- * them, registered either with {@link EventTarget.addEventListener} or with the matching inline `onpointer*`
11
- * attribute.
10
+ * them, registered either with {@link EventTarget.addEventListener} or with the matching inline
11
+ * attribute (`onpointerdown`, `onclick`, ...).
12
12
  *
13
13
  * @elementSummary The `<pc-entity>` element creates an entity: a named, transformable node of the
14
14
  * scene hierarchy, and the host for component elements such as `<pc-camera>`, `<pc-light>` and
@@ -28,11 +28,17 @@ import { EntityOwnerElement } from './entity-owner.js';
28
28
  * entity.
29
29
  * @attribute {string} onpointerup - Script to run when a pointer button is released over the
30
30
  * entity.
31
+ * @attribute {string} onclick - Script to run when the entity is clicked: a primary pointer
32
+ * button pressed and then released over it.
31
33
  * @fires {PointerEvent} pointerenter - Fired when the pointer moves onto the entity.
32
34
  * @fires {PointerEvent} pointerleave - Fired when the pointer moves off the entity.
33
35
  * @fires {PointerEvent} pointermove - Fired when the pointer moves over the entity.
34
36
  * @fires {PointerEvent} pointerdown - Fired when a pointer button is pressed over the entity.
35
37
  * @fires {PointerEvent} pointerup - Fired when a pointer button is released over the entity.
38
+ * @fires {PointerEvent} click - Fired when a primary pointer button is pressed and then released
39
+ * over the entity. A press and release that picked different entities fires on their nearest
40
+ * common ancestor instead, as in the DOM. `detail` carries the click count, so a double click
41
+ * arrives as a click whose `detail` is 2.
36
42
  */
37
43
  declare class EntityElement extends EntityOwnerElement {
38
44
  connectedCallback(): void;
package/dist/model.d.cts CHANGED
@@ -97,11 +97,17 @@ type HierarchyNode = {
97
97
  * model.
98
98
  * @attribute {string} onpointerup - Script to run when a pointer button is released over the
99
99
  * model.
100
+ * @attribute {string} onclick - Script to run when the model is clicked: a primary pointer
101
+ * button pressed and then released over it.
100
102
  * @fires {PointerEvent} pointerenter - Fired when the pointer moves onto the model.
101
103
  * @fires {PointerEvent} pointerleave - Fired when the pointer moves off the model.
102
104
  * @fires {PointerEvent} pointermove - Fired when the pointer moves over the model.
103
105
  * @fires {PointerEvent} pointerdown - Fired when a pointer button is pressed over the model.
104
106
  * @fires {PointerEvent} pointerup - Fired when a pointer button is released over the model.
107
+ * @fires {PointerEvent} click - Fired when a primary pointer button is pressed and then released
108
+ * over the model. A press and release that picked different entities fires on their nearest
109
+ * common ancestor instead, as in the DOM. `detail` carries the click count, so a double click
110
+ * arrives as a click whose `detail` is 2.
105
111
  * @fires {Event} load - Fired each time a container asset finishes instantiating, including
106
112
  * re-instantiation after `asset` changes. Does not bubble — listen on this element, or use a
107
113
  * capture-phase listener on an ancestor.
package/dist/model.d.ts CHANGED
@@ -97,11 +97,17 @@ type HierarchyNode = {
97
97
  * model.
98
98
  * @attribute {string} onpointerup - Script to run when a pointer button is released over the
99
99
  * model.
100
+ * @attribute {string} onclick - Script to run when the model is clicked: a primary pointer
101
+ * button pressed and then released over it.
100
102
  * @fires {PointerEvent} pointerenter - Fired when the pointer moves onto the model.
101
103
  * @fires {PointerEvent} pointerleave - Fired when the pointer moves off the model.
102
104
  * @fires {PointerEvent} pointermove - Fired when the pointer moves over the model.
103
105
  * @fires {PointerEvent} pointerdown - Fired when a pointer button is pressed over the model.
104
106
  * @fires {PointerEvent} pointerup - Fired when a pointer button is released over the model.
107
+ * @fires {PointerEvent} click - Fired when a primary pointer button is pressed and then released
108
+ * over the model. A press and release that picked different entities fires on their nearest
109
+ * common ancestor instead, as in the DOM. `detail` carries the click count, so a double click
110
+ * arrives as a click whose `detail` is 2.
105
111
  * @fires {Event} load - Fired each time a container asset finishes instantiating, including
106
112
  * re-instantiation after `asset` changes. Does not bubble — listen on this element, or use a
107
113
  * capture-phase listener on an ancestor.
package/dist/node.d.cts CHANGED
@@ -67,11 +67,17 @@ type MaterialOverrides = Readonly<Record<string, string>>;
67
67
  * node.
68
68
  * @attribute {string} onpointerup - Script to run when a pointer button is released over the
69
69
  * node.
70
+ * @attribute {string} onclick - Script to run when the node is clicked: a primary pointer
71
+ * button pressed and then released over it.
70
72
  * @fires {PointerEvent} pointerenter - Fired when the pointer moves onto the node.
71
73
  * @fires {PointerEvent} pointerleave - Fired when the pointer moves off the node.
72
74
  * @fires {PointerEvent} pointermove - Fired when the pointer moves over the node.
73
75
  * @fires {PointerEvent} pointerdown - Fired when a pointer button is pressed over the node.
74
76
  * @fires {PointerEvent} pointerup - Fired when a pointer button is released over the node.
77
+ * @fires {PointerEvent} click - Fired when a primary pointer button is pressed and then released
78
+ * over the node. A press and release that picked different entities fires on their nearest
79
+ * common ancestor instead, as in the DOM. `detail` carries the click count, so a double click
80
+ * arrives as a click whose `detail` is 2.
75
81
  */
76
82
  declare class NodeElement extends EntityBaseElement {
77
83
  private _name;
package/dist/node.d.ts CHANGED
@@ -67,11 +67,17 @@ type MaterialOverrides = Readonly<Record<string, string>>;
67
67
  * node.
68
68
  * @attribute {string} onpointerup - Script to run when a pointer button is released over the
69
69
  * node.
70
+ * @attribute {string} onclick - Script to run when the node is clicked: a primary pointer
71
+ * button pressed and then released over it.
70
72
  * @fires {PointerEvent} pointerenter - Fired when the pointer moves onto the node.
71
73
  * @fires {PointerEvent} pointerleave - Fired when the pointer moves off the node.
72
74
  * @fires {PointerEvent} pointermove - Fired when the pointer moves over the node.
73
75
  * @fires {PointerEvent} pointerdown - Fired when a pointer button is pressed over the node.
74
76
  * @fires {PointerEvent} pointerup - Fired when a pointer button is released over the node.
77
+ * @fires {PointerEvent} click - Fired when a primary pointer button is pressed and then released
78
+ * over the node. A press and release that picked different entities fires on their nearest
79
+ * common ancestor instead, as in the DOM. `detail` carries the click count, so a double click
80
+ * arrives as a click whose `detail` is 2.
75
81
  */
76
82
  declare class NodeElement extends EntityBaseElement {
77
83
  private _name;