@playcanvas/web-components 0.12.0 → 0.13.1

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 (95) hide show
  1. package/README.md +1 -1
  2. package/dist/app.d.cts +281 -0
  3. package/dist/app.d.ts +61 -3
  4. package/dist/asset.d.cts +224 -0
  5. package/dist/asset.d.ts +8 -2
  6. package/dist/async-element.d.cts +103 -0
  7. package/dist/async-element.d.ts +6 -4
  8. package/dist/colors.d.cts +1 -0
  9. package/dist/components/button-component.d.cts +186 -0
  10. package/dist/components/button-component.d.ts +1 -1
  11. package/dist/components/camera-component.d.cts +253 -0
  12. package/dist/components/camera-component.d.ts +1 -1
  13. package/dist/components/collision-component.d.cts +73 -0
  14. package/dist/components/collision-component.d.ts +1 -1
  15. package/dist/components/component.d.cts +82 -0
  16. package/dist/components/component.d.ts +1 -1
  17. package/dist/components/element-component.d.cts +316 -0
  18. package/dist/components/element-component.d.ts +1 -1
  19. package/dist/components/gsplat-component.d.cts +108 -0
  20. package/dist/components/gsplat-component.d.ts +1 -1
  21. package/dist/components/layoutchild-component.d.cts +110 -0
  22. package/dist/components/layoutchild-component.d.ts +1 -1
  23. package/dist/components/layoutgroup-component.d.cts +136 -0
  24. package/dist/components/layoutgroup-component.d.ts +1 -1
  25. package/dist/components/light-component.d.cts +264 -0
  26. package/dist/components/light-component.d.ts +1 -1
  27. package/dist/components/listener-component.d.cts +20 -0
  28. package/dist/components/listener-component.d.ts +1 -1
  29. package/dist/components/particlesystem-component.d.cts +52 -0
  30. package/dist/components/particlesystem-component.d.ts +1 -1
  31. package/dist/components/render-component.d.cts +76 -0
  32. package/dist/components/render-component.d.ts +1 -1
  33. package/dist/components/rigidbody-component.d.cts +88 -0
  34. package/dist/components/rigidbody-component.d.ts +1 -1
  35. package/dist/components/screen-component.d.cts +70 -0
  36. package/dist/components/screen-component.d.ts +1 -1
  37. package/dist/components/script-component.d.cts +163 -0
  38. package/dist/components/script-component.d.ts +1 -1
  39. package/dist/components/script.d.cts +94 -0
  40. package/dist/components/script.d.ts +1 -1
  41. package/dist/components/scrollbar-component.d.cts +69 -0
  42. package/dist/components/scrollbar-component.d.ts +1 -1
  43. package/dist/components/scrollview-component.d.cts +178 -0
  44. package/dist/components/scrollview-component.d.ts +1 -1
  45. package/dist/components/sound-component.d.cts +108 -0
  46. package/dist/components/sound-component.d.ts +1 -1
  47. package/dist/components/sound-slot.d.cts +134 -0
  48. package/dist/components/sound-slot.d.ts +2 -2
  49. package/dist/custom-elements.json +80 -22
  50. package/dist/entity-base.d.cts +67 -0
  51. package/dist/entity-base.d.ts +2 -2
  52. package/dist/entity.d.cts +131 -0
  53. package/dist/entity.d.ts +1 -1
  54. package/dist/index.d.cts +79 -0
  55. package/dist/index.d.ts +33 -33
  56. package/dist/loading-bar.d.cts +35 -0
  57. package/dist/material.d.cts +1011 -0
  58. package/dist/model.d.cts +72 -0
  59. package/dist/model.d.ts +1 -1
  60. package/dist/module.d.cts +29 -0
  61. package/dist/module.d.ts +16 -10
  62. package/dist/node.d.cts +253 -0
  63. package/dist/node.d.ts +1 -1
  64. package/dist/parse.d.cts +147 -0
  65. package/dist/pwc.cjs +285 -92
  66. package/dist/pwc.cjs.map +1 -1
  67. package/dist/pwc.js +286 -93
  68. package/dist/pwc.js.map +1 -1
  69. package/dist/pwc.min.js +1 -1
  70. package/dist/pwc.min.js.map +1 -1
  71. package/dist/pwc.min.mjs +1 -1
  72. package/dist/pwc.min.mjs.map +1 -1
  73. package/dist/pwc.mjs +286 -93
  74. package/dist/pwc.mjs.map +1 -1
  75. package/dist/scene.d.cts +117 -0
  76. package/dist/scene.d.ts +1 -1
  77. package/dist/sky.d.cts +121 -0
  78. package/dist/sky.d.ts +1 -1
  79. package/dist/vscode.html-custom-data.json +3 -3
  80. package/dist/web-types.json +42 -6
  81. package/package.json +16 -7
  82. package/src/app.ts +211 -49
  83. package/src/asset.ts +34 -2
  84. package/src/async-element.ts +4 -2
  85. package/src/components/button-component.ts +7 -7
  86. package/src/components/element-component.ts +7 -7
  87. package/src/components/gsplat-component.ts +3 -3
  88. package/src/components/particlesystem-component.ts +7 -8
  89. package/src/components/script-component.ts +2 -2
  90. package/src/components/sound-slot.ts +2 -2
  91. package/src/loading-bar.ts +2 -2
  92. package/src/material.ts +2 -2
  93. package/src/model.ts +2 -5
  94. package/src/module.ts +39 -20
  95. package/src/sky.ts +2 -3
@@ -0,0 +1,108 @@
1
+ import type { SoundComponent } from 'playcanvas';
2
+ import { ComponentElement } from './component.cjs';
3
+ /**
4
+ * The SoundComponentElement interface provides properties and methods for manipulating
5
+ * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-sounds/ | `<pc-sounds>`} elements.
6
+ * The SoundComponentElement interface also inherits the properties and methods of the
7
+ * {@link HTMLElement} interface.
8
+ *
9
+ * @category Components
10
+ */
11
+ declare class SoundComponentElement extends ComponentElement {
12
+ private _distanceModel;
13
+ private _maxDistance;
14
+ private _pitch;
15
+ private _positional;
16
+ private _refDistance;
17
+ private _rollOffFactor;
18
+ private _volume;
19
+ /** @ignore */
20
+ constructor();
21
+ protected getInitialComponentData(): {
22
+ distanceModel: "linear" | "exponential" | "inverse";
23
+ maxDistance: number;
24
+ pitch: number;
25
+ positional: boolean;
26
+ refDistance: number;
27
+ rollOffFactor: number;
28
+ volume: number;
29
+ };
30
+ /**
31
+ * Gets the underlying PlayCanvas sound component.
32
+ * @returns The sound component.
33
+ */
34
+ get component(): SoundComponent;
35
+ /**
36
+ * Sets which algorithm to use to reduce the volume of the sound as it moves away from the listener.
37
+ * @param value - The distance model.
38
+ */
39
+ set distanceModel(value: 'exponential' | 'inverse' | 'linear');
40
+ /**
41
+ * Gets which algorithm to use to reduce the volume of the sound as it moves away from the listener.
42
+ * @returns The distance model.
43
+ */
44
+ get distanceModel(): 'exponential' | 'inverse' | 'linear';
45
+ /**
46
+ * Sets the maximum distance from the listener at which audio falloff stops.
47
+ * @param value - The max distance.
48
+ */
49
+ set maxDistance(value: number);
50
+ /**
51
+ * Gets the maximum distance from the listener at which audio falloff stops.
52
+ * @returns The max distance.
53
+ */
54
+ get maxDistance(): number;
55
+ /**
56
+ * Sets the pitch of the sound.
57
+ * @param value - The pitch.
58
+ */
59
+ set pitch(value: number);
60
+ /**
61
+ * Gets the pitch of the sound.
62
+ * @returns The pitch.
63
+ */
64
+ get pitch(): number;
65
+ /**
66
+ * Sets the positional flag of the sound.
67
+ * @param value - The positional flag.
68
+ */
69
+ set positional(value: boolean);
70
+ /**
71
+ * Gets the positional flag of the sound.
72
+ * @returns The positional flag.
73
+ */
74
+ get positional(): boolean;
75
+ /**
76
+ * Sets the reference distance for reducing volume as the sound source moves further from the listener. Defaults to 1.
77
+ * @param value - The ref distance.
78
+ */
79
+ set refDistance(value: number);
80
+ /**
81
+ * Gets the reference distance for reducing volume as the sound source moves further from the listener.
82
+ * @returns The ref distance.
83
+ */
84
+ get refDistance(): number;
85
+ /**
86
+ * Sets the factor used in the falloff equation. Defaults to 1.
87
+ * @param value - The roll-off factor.
88
+ */
89
+ set rollOffFactor(value: number);
90
+ /**
91
+ * Gets the factor used in the falloff equation.
92
+ * @returns The roll-off factor.
93
+ */
94
+ get rollOffFactor(): number;
95
+ /**
96
+ * Sets the volume of the sound.
97
+ * @param value - The volume.
98
+ */
99
+ set volume(value: number);
100
+ /**
101
+ * Gets the volume of the sound.
102
+ * @returns The volume.
103
+ */
104
+ get volume(): number;
105
+ static get observedAttributes(): string[];
106
+ attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
107
+ }
108
+ export { SoundComponentElement };
@@ -1,5 +1,5 @@
1
1
  import type { SoundComponent } from 'playcanvas';
2
- import { ComponentElement } from './component';
2
+ import { ComponentElement } from './component.js';
3
3
  /**
4
4
  * The SoundComponentElement interface provides properties and methods for manipulating
5
5
  * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-sounds/ | `<pc-sounds>`} elements.
@@ -0,0 +1,134 @@
1
+ import type { SoundSlot } from 'playcanvas';
2
+ import { AsyncElement } from '../async-element.cjs';
3
+ import { SoundComponentElement } from './sound-component.cjs';
4
+ /**
5
+ * The SoundSlotElement interface provides properties and methods for manipulating
6
+ * `<pc-sound>` elements. The SoundSlotElement interface also inherits the properties and
7
+ * methods of the {@link AsyncElement} interface.
8
+ */
9
+ declare class SoundSlotElement extends AsyncElement {
10
+ private _asset;
11
+ private _autoPlay;
12
+ private _duration;
13
+ private _loop;
14
+ private _name;
15
+ private _overlap;
16
+ private _pitch;
17
+ private _startTime;
18
+ private _volume;
19
+ /**
20
+ * The `<pc-sounds>` this slot was added to, captured at connect time.
21
+ *
22
+ * `disconnectedCallback` cannot rediscover it: by the time the element is disconnected its
23
+ * `parentElement` is already `null`, so a lookup would both fail to find the component and
24
+ * emit a misleading "must be a direct child" warning for what is an ordinary removal.
25
+ */
26
+ private _soundElement;
27
+ /**
28
+ * Incremented on every connect and disconnect, and captured by connectedCallback on entry —
29
+ * a resume from an await abandons itself if the value has moved on, so a stale callback can
30
+ * neither act on a torn-down tree nor add its slot alongside a re-inserted element's own
31
+ * callback.
32
+ */
33
+ private _connectionGeneration;
34
+ /**
35
+ * The sound slot.
36
+ */
37
+ soundSlot: SoundSlot | null;
38
+ connectedCallback(): Promise<void>;
39
+ disconnectedCallback(): void;
40
+ protected get soundElement(): SoundComponentElement | null;
41
+ /**
42
+ * Sets the id of the `pc-asset` to use for the sound slot.
43
+ * @param value - The asset.
44
+ */
45
+ set asset(value: string);
46
+ /**
47
+ * Gets the id of the `pc-asset` to use for the sound slot.
48
+ * @returns The asset.
49
+ */
50
+ get asset(): string;
51
+ /**
52
+ * Sets the auto play flag of the sound slot.
53
+ * @param value - The auto play flag.
54
+ */
55
+ set autoPlay(value: boolean);
56
+ /**
57
+ * Gets the auto play flag of the sound slot.
58
+ * @returns The auto play flag.
59
+ */
60
+ get autoPlay(): boolean;
61
+ /**
62
+ * Sets the duration of the sound slot, in seconds (or `null` to play the whole clip).
63
+ * @param value - The duration.
64
+ */
65
+ set duration(value: number | null);
66
+ /**
67
+ * Gets the duration of the sound slot.
68
+ * @returns The duration.
69
+ */
70
+ get duration(): number | null;
71
+ /**
72
+ * Sets the loop flag of the sound slot.
73
+ * @param value - The loop flag.
74
+ */
75
+ set loop(value: boolean);
76
+ /**
77
+ * Gets the loop flag of the sound slot.
78
+ * @returns The loop flag.
79
+ */
80
+ get loop(): boolean;
81
+ /**
82
+ * Sets the name of the sound slot.
83
+ * @param value - The name.
84
+ */
85
+ set name(value: string);
86
+ /**
87
+ * Gets the name of the sound slot.
88
+ * @returns The name.
89
+ */
90
+ get name(): string;
91
+ /**
92
+ * Sets the overlap flag of the sound slot.
93
+ * @param value - The overlap flag.
94
+ */
95
+ set overlap(value: boolean);
96
+ /**
97
+ * Gets the overlap flag of the sound slot.
98
+ * @returns The overlap flag.
99
+ */
100
+ get overlap(): boolean;
101
+ /**
102
+ * Sets the pitch of the sound slot.
103
+ * @param value - The pitch.
104
+ */
105
+ set pitch(value: number);
106
+ /**
107
+ * Gets the pitch of the sound slot.
108
+ * @returns The pitch.
109
+ */
110
+ get pitch(): number;
111
+ /**
112
+ * Sets the start time of the sound slot.
113
+ * @param value - The start time.
114
+ */
115
+ set startTime(value: number);
116
+ /**
117
+ * Gets the start time of the sound slot.
118
+ * @returns The start time.
119
+ */
120
+ get startTime(): number;
121
+ /**
122
+ * Sets the volume of the sound slot.
123
+ * @param value - The volume.
124
+ */
125
+ set volume(value: number);
126
+ /**
127
+ * Gets the volume of the sound slot.
128
+ * @returns The volume.
129
+ */
130
+ get volume(): number;
131
+ static get observedAttributes(): string[];
132
+ attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
133
+ }
134
+ export { SoundSlotElement };
@@ -1,6 +1,6 @@
1
1
  import type { SoundSlot } from 'playcanvas';
2
- import { AsyncElement } from '../async-element';
3
- import { SoundComponentElement } from './sound-component';
2
+ import { AsyncElement } from '../async-element.js';
3
+ import { SoundComponentElement } from './sound-component.js';
4
4
  /**
5
5
  * The SoundSlotElement interface provides properties and methods for manipulating
6
6
  * `<pc-sound>` elements. The SoundSlotElement interface also inherits the properties and
@@ -8,7 +8,7 @@
8
8
  "declarations": [
9
9
  {
10
10
  "kind": "class",
11
- "description": "The AppElement interface provides properties and methods for manipulating\n[`<pc-app>`](https://developer.playcanvas.com/user-manual/web-components/tags/pc-app/) elements.\nThe AppElement interface also inherits the properties and methods of the\nHTMLElement interface.\n",
11
+ "description": "The AppElement interface provides properties and methods for manipulating\n[`<pc-app>`](https://developer.playcanvas.com/user-manual/web-components/tags/pc-app/) elements.\nThe AppElement interface also inherits the properties and methods of the\nHTMLElement interface.\n\nThe element is sized like a replaced element such as `<video>`: a block-level box that the\npage's CSS controls, 300x150 by default. The application's canvas always fills the element,\nand the drawing buffer resolution follows the element's size (capped by `max-pixel-ratio`),\ntracked live via a ResizeObserver — so the element can be embedded at any size, resized by\nits container, or made fullscreen with ordinary CSS such as `width: 100vw; height: 100dvh`.\n",
12
12
  "name": "AppElement",
13
13
  "members": [
14
14
  {
@@ -222,6 +222,13 @@
222
222
  }
223
223
  ],
224
224
  "events": [
225
+ {
226
+ "name": "error",
227
+ "type": {
228
+ "text": "ErrorEvent"
229
+ },
230
+ "description": "Fired when the application cannot boot because no graphics device could be created (for example, a browser with WebGL disabled). `message` names the requested backends and `error` holds the underlying failure. The element never becomes ready and `app` stays `null` — listen for this event to show a fallback UI. Removing the element and re-inserting it retries the boot with its current attributes. Does not bubble."
231
+ },
225
232
  {
226
233
  "name": "progress",
227
234
  "type": {
@@ -339,7 +346,7 @@
339
346
  "declarations": [
340
347
  {
341
348
  "kind": "class",
342
- "description": "The AssetElement interface provides properties and methods for manipulating\n[`<pc-asset>`](https://developer.playcanvas.com/user-manual/web-components/tags/pc-asset/) elements.\nThe AssetElement interface also inherits the properties and methods of the\nHTMLElement interface.\n\nThe element becomes ready once the containing application has started and the asset is in the\nstate declared by the markup: loaded for preloaded assets (even if loading failed — check the\nasset's `resource`), or registered and awaiting a load for `lazy` assets. Elements inserted\nwhile the application is running are created and registered on insertion, and begin loading\nimmediately unless `lazy`. A `pc-asset` must be a direct child of `pc-app` — elements placed\nelsewhere, or with an unsupported asset type, never become ready.\n\nFor `texture` and `textureatlas` assets, the texture options (`address-u`, `address-v`,\n`min-filter`, `mag-filter`, `anisotropy`, `mipmaps`, `srgb`, `flip-y`) apply when the texture is\ncreated and — like `lazy` — are observed: changing one updates a texture that has already\nloaded, and removing one restores the engine default. Changing `srgb` or `mipmaps` on a loaded\ntexture recreates the underlying GPU resource, so prefer declaring those up front. Each option\noverrides the matching key in the `data` JSON; options left unset write nothing, leaving the\nengine's per-format defaults in force.\n\nApart from `lazy` and the texture options, these attributes are read once when the asset is\ncreated, so changing them later has no effect.\n",
349
+ "description": "The AssetElement interface provides properties and methods for manipulating\n[`<pc-asset>`](https://developer.playcanvas.com/user-manual/web-components/tags/pc-asset/) elements.\nThe AssetElement interface also inherits the properties and methods of the\nHTMLElement interface.\n\nThe element becomes ready once the containing application has started and the asset is in the\nstate declared by the markup: loaded for preloaded assets (even if loading failed — check the\nasset's `resource`), or registered and awaiting a load for `lazy` assets. Elements inserted\nwhile the application is running are created and registered on insertion, and begin loading\nimmediately unless `lazy`. A `pc-asset` must be a direct child of `pc-app` — elements placed\nelsewhere, or with an unsupported asset type, never become ready.\n\nA `lazy` asset loads on first use: the first time any element resolves it by `id` — a model,\na material map, a sky, a script `asset:` reference — or when the `lazy` attribute is removed,\nwhichever comes first. Until then it stays registered and unloaded.\n\nFor `texture` and `textureatlas` assets, the texture options (`address-u`, `address-v`,\n`min-filter`, `mag-filter`, `anisotropy`, `mipmaps`, `srgb`, `flip-y`) apply when the texture is\ncreated and — like `lazy` — are observed: changing one updates a texture that has already\nloaded, and removing one restores the engine default. Changing `srgb` or `mipmaps` on a loaded\ntexture recreates the underlying GPU resource, so prefer declaring those up front. Each option\noverrides the matching key in the `data` JSON; options left unset write nothing, leaving the\nengine's per-format defaults in force.\n\nApart from `lazy` and the texture options, these attributes are read once when the asset is\ncreated, so changing them later has no effect.\n",
343
350
  "name": "AssetElement",
344
351
  "members": [
345
352
  {
@@ -862,7 +869,7 @@
862
869
  "description": "The tag name of the element to wait for (e.g. `'pc-app'`)."
863
870
  }
864
871
  ],
865
- "description": "Waits for the first element matching the given tag name to be fully initialized. Note that the\npromise never settles if the element cannot finish initializing (for example, a `<pc-script>`\nthat is not a direct child of `<pc-scripts>`). A component element outside a `<pc-entity>` is\nthe exception: it still becomes ready, but its `component` is `null`. Either way, a misplaced\nelement logs a warning naming the parent it requires."
872
+ "description": "Waits for the first element matching the given tag name to be fully initialized. Note that the\npromise never settles if the element cannot finish initializing (for example, a `<pc-script>`\nthat is not a direct child of `<pc-scripts>`, or a `<pc-app>` that could not create a graphics\ndevice — listen for its `error` event instead). A component element outside a `<pc-entity>` is\nthe exception: it still becomes ready, but its `component` is `null`. Either way, a misplaced\nelement logs a warning naming the parent it requires."
866
873
  },
867
874
  {
868
875
  "kind": "function",
@@ -900,7 +907,7 @@
900
907
  "description": "A CSS selector matching the element to wait for (e.g. `'#my-app'`)."
901
908
  }
902
909
  ],
903
- "description": "Waits for the first element matching the given CSS selector to be fully initialized. Note that\nthe promise never settles if the element cannot finish initializing (for example, a `<pc-script>`\nthat is not a direct child of `<pc-scripts>`). A component element outside a `<pc-entity>` is\nthe exception: it still becomes ready, but its `component` is `null`. Either way, a misplaced\nelement logs a warning naming the parent it requires."
910
+ "description": "Waits for the first element matching the given CSS selector to be fully initialized. Note that\nthe promise never settles if the element cannot finish initializing (for example, a `<pc-script>`\nthat is not a direct child of `<pc-scripts>`, or a `<pc-app>` that could not create a graphics\ndevice — listen for its `error` event instead). A component element outside a `<pc-entity>` is\nthe exception: it still becomes ready, but its `component` is `null`. Either way, a misplaced\nelement logs a warning naming the parent it requires."
904
911
  },
905
912
  {
906
913
  "kind": "function",
@@ -4089,8 +4096,60 @@
4089
4096
  "declarations": [
4090
4097
  {
4091
4098
  "kind": "class",
4092
- "description": "The ModuleElement interface provides properties and methods for manipulating\n[`<pc-module>`](https://developer.playcanvas.com/user-manual/web-components/tags/pc-module/) elements.\nThe ModuleElement interface also inherits the properties and methods of the\nHTMLElement interface.\n\nNote that these attributes are read once when the element is created, so changing them later\nhas no effect.\n",
4099
+ "description": "The ModuleElement interface provides properties and methods for manipulating\n[`<pc-module>`](https://developer.playcanvas.com/user-manual/web-components/tags/pc-module/)\nelements. The ModuleElement interface also inherits the properties and methods of the\nAsyncElement interface.\n\nThe attributes are read once, when the module starts loading - on the element's first\nconnection, or earlier if a containing `<pc-app>` boots first and collects it - so changing\nthem later has no effect. The element becomes ready once the module has loaded. WebAssembly\nmodules configure engine-global state that never unloads, so readiness is not re-armed by\nremoving the element, and a re-inserted element does not load again.\n\nA `<pc-module>` without a `name` warns and never becomes ready; a containing `<pc-app>` still\nboots.\n",
4093
4100
  "name": "ModuleElement",
4101
+ "members": [
4102
+ {
4103
+ "kind": "field",
4104
+ "name": "closestApp",
4105
+ "type": {
4106
+ "text": "AppElement | null"
4107
+ },
4108
+ "description": "The nearest ancestor `<pc-app>` element, or `null` if this element has no `<pc-app>`\nancestor. The search starts at the parent, so an element never resolves to itself.",
4109
+ "return": {
4110
+ "type": {
4111
+ "text": ""
4112
+ }
4113
+ },
4114
+ "readonly": true,
4115
+ "inheritedFrom": {
4116
+ "name": "AsyncElement",
4117
+ "module": "src/async-element.ts"
4118
+ }
4119
+ },
4120
+ {
4121
+ "kind": "field",
4122
+ "name": "closestEntity",
4123
+ "type": {
4124
+ "text": "EntityBaseElement | null"
4125
+ },
4126
+ "description": "The nearest ancestor element that fronts an entity — `<pc-entity>` or `<pc-node>` — or\n`null` if this element has no such ancestor. The search starts at the parent, so an element\nnever resolves to itself.",
4127
+ "return": {
4128
+ "type": {
4129
+ "text": ""
4130
+ }
4131
+ },
4132
+ "readonly": true,
4133
+ "inheritedFrom": {
4134
+ "name": "AsyncElement",
4135
+ "module": "src/async-element.ts"
4136
+ }
4137
+ },
4138
+ {
4139
+ "kind": "method",
4140
+ "name": "ready",
4141
+ "return": {
4142
+ "type": {
4143
+ "text": ""
4144
+ }
4145
+ },
4146
+ "description": "Returns a promise that resolves with this element when it's ready. This is the low-level\nprimitive underlying whenReady, which is the recommended way to wait for elements.\n\nReadiness tracks the element's current lifecycle: once a ready element is torn down (for\nexample by removing it from the document), this returns a fresh promise that resolves when\nthe element is next ready. A promise obtained earlier stays resolved — call this again\nafter re-inserting an element rather than reusing a promise from before its removal.",
4147
+ "inheritedFrom": {
4148
+ "name": "AsyncElement",
4149
+ "module": "src/async-element.ts"
4150
+ }
4151
+ }
4152
+ ],
4094
4153
  "attributes": [
4095
4154
  {
4096
4155
  "type": {
@@ -4122,25 +4181,24 @@
4122
4181
  }
4123
4182
  ],
4124
4183
  "superclass": {
4125
- "name": "HTMLElement"
4184
+ "name": "AsyncElement",
4185
+ "module": "/src/async-element"
4126
4186
  },
4127
4187
  "tagName": "pc-module",
4128
- "customElement": true
4129
- },
4130
- {
4131
- "kind": "variable",
4132
- "name": "glueUrl",
4133
- "default": "this.getAttribute('glue')!"
4134
- },
4135
- {
4136
- "kind": "variable",
4137
- "name": "wasmUrl",
4138
- "default": "this.getAttribute('wasm')!"
4139
- },
4140
- {
4141
- "kind": "variable",
4142
- "name": "fallbackUrl",
4143
- "default": "this.getAttribute('fallback')!"
4188
+ "customElement": true,
4189
+ "events": [
4190
+ {
4191
+ "name": "ready",
4192
+ "type": {
4193
+ "text": "CustomEvent"
4194
+ },
4195
+ "description": "Fired when the element is fully initialized — once per readiness cycle, so an element that is torn down and re-initialized (for example by removing and re-inserting it) fires it again. Bubbles and is composed.",
4196
+ "inheritedFrom": {
4197
+ "name": "AsyncElement",
4198
+ "module": "src/async-element.ts"
4199
+ }
4200
+ }
4201
+ ]
4144
4202
  }
4145
4203
  ],
4146
4204
  "exports": [
@@ -0,0 +1,67 @@
1
+ import type { Entity } from 'playcanvas';
2
+ import type { AppElement } from './app.cjs';
3
+ import { AsyncElement } from './async-element.cjs';
4
+ /**
5
+ * The attribute names of the inline `onpointer*` event handlers, shared by every element that
6
+ * fronts an engine entity. Spread into `observedAttributes` by subclasses.
7
+ * @ignore
8
+ */
9
+ declare const POINTER_ATTRIBUTES: readonly ["onpointerenter", "onpointerleave", "onpointerdown", "onpointerup", "onpointermove"];
10
+ /**
11
+ * The base class for elements that front an engine {@link Entity}: `<pc-entity>`, which creates
12
+ * one, and `<pc-node>`, which binds to one inside a model's instantiated hierarchy. It carries
13
+ * what both need — the `entity` contract, registration with the owning application (which joins
14
+ * picked scene nodes back to elements by identity, never by name), and the pointer listener
15
+ * bookkeeping that lets the application lazily attach its canvas handlers.
16
+ */
17
+ declare class EntityBaseElement extends AsyncElement {
18
+ protected _entity: Entity | null;
19
+ /**
20
+ * The application element this entity is registered with, cached at registration time so the
21
+ * entity can be unregistered even once this element has left the DOM.
22
+ */
23
+ protected _appElement: AppElement | null;
24
+ /**
25
+ * The pointer event listeners for the entity.
26
+ */
27
+ private _listeners;
28
+ /**
29
+ * The event types for which an inline `onpointer*` attribute is currently present.
30
+ */
31
+ private _inlineHandlerTypes;
32
+ /**
33
+ * The PlayCanvas entity instance. `null` until the element is ready, and again once the
34
+ * entity is gone — await {@link whenReady} or the element's `ready()` promise before
35
+ * accessing it.
36
+ * @returns The entity instance, or `null`.
37
+ */
38
+ get entity(): Entity | null;
39
+ /**
40
+ * Registers `entity` as this element's backing entity with the owning application, which
41
+ * joins engine nodes back to elements by identity (never by name).
42
+ *
43
+ * @param entity - The entity to register.
44
+ */
45
+ protected _registerEntity(entity: Entity): void;
46
+ /**
47
+ * Removes the registration for `entity`.
48
+ *
49
+ * @param entity - The entity to unregister.
50
+ */
51
+ protected _unregisterEntity(entity: Entity): void;
52
+ /**
53
+ * Tracks whether an inline `onpointer*` attribute is present. The browser itself compiles and
54
+ * runs these attributes — they are standard `GlobalEventHandlers`, so setting one replaces
55
+ * the previous handler and removing it removes the handler, exactly like `onclick` on any
56
+ * HTML element. But because they bypass {@link addEventListener}, the connect/disconnect
57
+ * bookkeeping that lets the application lazily attach its canvas pointer handlers must be
58
+ * kept in sync here.
59
+ *
60
+ * @param name - The attribute name (e.g. 'onpointerdown').
61
+ * @param value - The attribute value, or `null` when the attribute has been removed.
62
+ */
63
+ protected _updateInlineHandler(name: string, value: string | null): void;
64
+ addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void;
65
+ removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void;
66
+ }
67
+ export { EntityBaseElement, POINTER_ATTRIBUTES };
@@ -1,6 +1,6 @@
1
1
  import type { Entity } from 'playcanvas';
2
- import type { AppElement } from './app';
3
- import { AsyncElement } from './async-element';
2
+ import type { AppElement } from './app.js';
3
+ import { AsyncElement } from './async-element.js';
4
4
  /**
5
5
  * The attribute names of the inline `onpointer*` event handlers, shared by every element that
6
6
  * fronts an engine entity. Spread into `observedAttributes` by subclasses.
@@ -0,0 +1,131 @@
1
+ import { Vec3 } from 'playcanvas';
2
+ import { EntityBaseElement } from './entity-base.cjs';
3
+ /**
4
+ * The EntityElement interface provides properties and methods for manipulating
5
+ * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-entity/ | `<pc-entity>`} elements.
6
+ * The EntityElement interface also inherits the properties and methods of the
7
+ * {@link HTMLElement} interface.
8
+ *
9
+ * The pointer events below are dispatched by the containing `<pc-app>` element when the pointer
10
+ * intersects this entity's geometry. They are only generated while the entity has a listener for
11
+ * them, registered either with {@link addEventListener} or with the matching inline `onpointer*`
12
+ * attribute.
13
+ *
14
+ * @attribute {string} onpointerenter - Script to run when the pointer moves onto the entity.
15
+ * @attribute {string} onpointerleave - Script to run when the pointer moves off the entity.
16
+ * @attribute {string} onpointermove - Script to run when the pointer moves over the entity.
17
+ * @attribute {string} onpointerdown - Script to run when a pointer button is pressed over the
18
+ * entity.
19
+ * @attribute {string} onpointerup - Script to run when a pointer button is released over the
20
+ * entity.
21
+ * @fires {PointerEvent} pointerenter - Fired when the pointer moves onto the entity.
22
+ * @fires {PointerEvent} pointerleave - Fired when the pointer moves off the entity.
23
+ * @fires {PointerEvent} pointermove - Fired when the pointer moves over the entity.
24
+ * @fires {PointerEvent} pointerdown - Fired when a pointer button is pressed over the entity.
25
+ * @fires {PointerEvent} pointerup - Fired when a pointer button is released over the entity.
26
+ */
27
+ declare class EntityElement extends EntityBaseElement {
28
+ /**
29
+ * Whether the entity is enabled.
30
+ */
31
+ private _enabled;
32
+ /**
33
+ * The name of the entity.
34
+ */
35
+ private _name;
36
+ /**
37
+ * The position of the entity.
38
+ */
39
+ private _position;
40
+ /**
41
+ * The rotation of the entity.
42
+ */
43
+ private _rotation;
44
+ /**
45
+ * The scale of the entity.
46
+ */
47
+ private _scale;
48
+ /**
49
+ * The tags of the entity.
50
+ */
51
+ private _tags;
52
+ /**
53
+ * Whether the hierarchy has been built for this entity.
54
+ */
55
+ private _built;
56
+ /**
57
+ * Handles the destruction of the backing entity. Resets the element so a later re-insertion
58
+ * starts clean: `_built` must be cleared alongside `_entity`, or _buildHierarchy would bail
59
+ * and a re-created entity would never be parented. Readiness is re-armed for the same
60
+ * reason — with the entity gone, a resolved ready promise would resume its awaiters against
61
+ * a null `entity`.
62
+ *
63
+ * @param entity - The entity that was destroyed.
64
+ */
65
+ private _onEntityDestroy;
66
+ connectedCallback(): void;
67
+ disconnectedCallback(): void;
68
+ /**
69
+ * Sets the enabled state of the entity.
70
+ * @param value - Whether the entity is enabled.
71
+ */
72
+ set enabled(value: boolean);
73
+ /**
74
+ * Gets the enabled state of the entity.
75
+ * @returns Whether the entity is enabled.
76
+ */
77
+ get enabled(): boolean;
78
+ /**
79
+ * Sets the name of the entity.
80
+ * @param value - The name of the entity.
81
+ */
82
+ set name(value: string);
83
+ /**
84
+ * Gets the name of the entity.
85
+ * @returns The name of the entity.
86
+ */
87
+ get name(): string;
88
+ /**
89
+ * Sets the position of the entity.
90
+ * @param value - The position of the entity.
91
+ */
92
+ set position(value: Vec3);
93
+ /**
94
+ * Gets the position of the entity.
95
+ * @returns The position of the entity.
96
+ */
97
+ get position(): Vec3;
98
+ /**
99
+ * Sets the rotation of the entity.
100
+ * @param value - The rotation of the entity.
101
+ */
102
+ set rotation(value: Vec3);
103
+ /**
104
+ * Gets the rotation of the entity.
105
+ * @returns The rotation of the entity.
106
+ */
107
+ get rotation(): Vec3;
108
+ /**
109
+ * Sets the scale of the entity.
110
+ * @param value - The scale of the entity.
111
+ */
112
+ set scale(value: Vec3);
113
+ /**
114
+ * Gets the scale of the entity.
115
+ * @returns The scale of the entity.
116
+ */
117
+ get scale(): Vec3;
118
+ /**
119
+ * Sets the tags of the entity.
120
+ * @param value - The tags of the entity.
121
+ */
122
+ set tags(value: string[]);
123
+ /**
124
+ * Gets the tags of the entity.
125
+ * @returns The tags of the entity.
126
+ */
127
+ get tags(): string[];
128
+ static get observedAttributes(): string[];
129
+ attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
130
+ }
131
+ export { EntityElement };
package/dist/entity.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Vec3 } from 'playcanvas';
2
- import { EntityBaseElement } from './entity-base';
2
+ import { EntityBaseElement } from './entity-base.js';
3
3
  /**
4
4
  * The EntityElement interface provides properties and methods for manipulating
5
5
  * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-entity/ | `<pc-entity>`} elements.