@playcanvas/web-components 0.11.1 → 0.13.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/README.md +1 -1
- package/dist/app.d.cts +246 -0
- package/dist/app.d.ts +38 -13
- package/dist/asset.d.cts +218 -0
- package/dist/asset.d.ts +145 -6
- package/dist/async-element.d.cts +103 -0
- package/dist/async-element.d.ts +11 -8
- package/dist/colors.d.cts +1 -0
- package/dist/components/button-component.d.cts +186 -0
- package/dist/components/button-component.d.ts +1 -1
- package/dist/components/camera-component.d.cts +253 -0
- package/dist/components/camera-component.d.ts +1 -1
- package/dist/components/collision-component.d.cts +73 -0
- package/dist/components/collision-component.d.ts +17 -1
- package/dist/components/component.d.cts +82 -0
- package/dist/components/component.d.ts +20 -1
- package/dist/components/element-component.d.cts +316 -0
- package/dist/components/element-component.d.ts +1 -1
- package/dist/components/gsplat-component.d.cts +108 -0
- package/dist/components/gsplat-component.d.ts +1 -1
- package/dist/components/layoutchild-component.d.cts +110 -0
- package/dist/components/layoutchild-component.d.ts +1 -1
- package/dist/components/layoutgroup-component.d.cts +136 -0
- package/dist/components/layoutgroup-component.d.ts +1 -1
- package/dist/components/light-component.d.cts +264 -0
- package/dist/components/light-component.d.ts +1 -1
- package/dist/components/listener-component.d.cts +20 -0
- package/dist/components/listener-component.d.ts +1 -1
- package/dist/components/particlesystem-component.d.cts +52 -0
- package/dist/components/particlesystem-component.d.ts +1 -1
- package/dist/components/render-component.d.cts +76 -0
- package/dist/components/render-component.d.ts +1 -1
- package/dist/components/rigidbody-component.d.cts +88 -0
- package/dist/components/rigidbody-component.d.ts +1 -1
- package/dist/components/screen-component.d.cts +70 -0
- package/dist/components/screen-component.d.ts +1 -1
- package/dist/components/script-component.d.cts +163 -0
- package/dist/components/script-component.d.ts +1 -1
- package/dist/components/script.d.cts +94 -0
- package/dist/components/script.d.ts +1 -1
- package/dist/components/scrollbar-component.d.cts +69 -0
- package/dist/components/scrollbar-component.d.ts +1 -1
- package/dist/components/scrollview-component.d.cts +178 -0
- package/dist/components/scrollview-component.d.ts +1 -1
- package/dist/components/sound-component.d.cts +108 -0
- package/dist/components/sound-component.d.ts +1 -1
- package/dist/components/sound-slot.d.cts +134 -0
- package/dist/components/sound-slot.d.ts +2 -2
- package/dist/custom-elements.json +1127 -179
- package/dist/entity-base.d.cts +67 -0
- package/dist/entity-base.d.ts +67 -0
- package/dist/entity.d.cts +131 -0
- package/dist/entity.d.ts +3 -38
- package/dist/index.d.cts +79 -0
- package/dist/index.d.ts +35 -32
- package/dist/loading-bar.d.cts +35 -0
- package/dist/material.d.cts +1011 -0
- package/dist/material.d.ts +2 -1
- package/dist/model.d.cts +72 -0
- package/dist/model.d.ts +27 -5
- package/dist/module.d.cts +29 -0
- package/dist/module.d.ts +16 -10
- package/dist/node.d.cts +253 -0
- package/dist/node.d.ts +253 -0
- package/dist/parse.d.cts +147 -0
- package/dist/pwc.cjs +1496 -200
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +1497 -201
- package/dist/pwc.js.map +1 -1
- package/dist/pwc.min.js +1 -1
- package/dist/pwc.min.js.map +1 -1
- package/dist/pwc.min.mjs +1 -1
- package/dist/pwc.min.mjs.map +1 -1
- package/dist/pwc.mjs +1496 -202
- package/dist/pwc.mjs.map +1 -1
- package/dist/scene.d.cts +117 -0
- package/dist/scene.d.ts +1 -1
- package/dist/sky.d.cts +121 -0
- package/dist/sky.d.ts +1 -1
- package/dist/vscode.html-custom-data.json +127 -5
- package/dist/web-types.json +399 -59
- package/package.json +16 -7
- package/src/app.ts +137 -45
- package/src/asset.ts +439 -9
- package/src/async-element.ts +11 -8
- package/src/components/collision-component.ts +35 -0
- package/src/components/component.ts +93 -3
- package/src/entity-base.ts +136 -0
- package/src/entity.ts +23 -117
- package/src/index.ts +5 -0
- package/src/loading-bar.ts +2 -2
- package/src/material.ts +2 -2
- package/src/model.ts +79 -11
- package/src/module.ts +39 -20
- package/src/node.ts +715 -0
- package/src/sky.ts +0 -1
package/dist/asset.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Asset } from 'playcanvas';
|
|
2
|
-
import { AsyncElement } from './async-element';
|
|
2
|
+
import { AsyncElement } from './async-element.js';
|
|
3
|
+
type AddressMode = 'repeat' | 'clamp' | 'mirror';
|
|
4
|
+
type MinFilterMode = 'nearest' | 'linear' | 'nearest-mip-nearest' | 'linear-mip-nearest' | 'nearest-mip-linear' | 'linear-mip-linear';
|
|
5
|
+
type MagFilterMode = 'nearest' | 'linear';
|
|
3
6
|
/**
|
|
4
7
|
* The AssetElement interface provides properties and methods for manipulating
|
|
5
8
|
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-asset/ | `<pc-asset>`} elements.
|
|
@@ -13,8 +16,16 @@ import { AsyncElement } from './async-element';
|
|
|
13
16
|
* immediately unless `lazy`. A `pc-asset` must be a direct child of `pc-app` — elements placed
|
|
14
17
|
* elsewhere, or with an unsupported asset type, never become ready.
|
|
15
18
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
19
|
+
* For `texture` and `textureatlas` assets, the texture options (`address-u`, `address-v`,
|
|
20
|
+
* `min-filter`, `mag-filter`, `anisotropy`, `mipmaps`, `srgb`, `flip-y`) apply when the texture is
|
|
21
|
+
* created and — like `lazy` — are observed: changing one updates a texture that has already
|
|
22
|
+
* loaded, and removing one restores the engine default. Changing `srgb` or `mipmaps` on a loaded
|
|
23
|
+
* texture recreates the underlying GPU resource, so prefer declaring those up front. Each option
|
|
24
|
+
* overrides the matching key in the `data` JSON; options left unset write nothing, leaving the
|
|
25
|
+
* engine's per-format defaults in force.
|
|
26
|
+
*
|
|
27
|
+
* Apart from `lazy` and the texture options, these attributes are read once when the asset is
|
|
28
|
+
* created, so changing them later has no effect.
|
|
18
29
|
*
|
|
19
30
|
* @attribute {string} id - The identifier used to reference the asset from other elements.
|
|
20
31
|
* @attribute {string} src - The URL of the asset to load.
|
|
@@ -36,7 +47,15 @@ import { AsyncElement } from './async-element';
|
|
|
36
47
|
* not that it succeeded.
|
|
37
48
|
*/
|
|
38
49
|
declare class AssetElement extends AsyncElement {
|
|
50
|
+
private _addressU;
|
|
51
|
+
private _addressV;
|
|
52
|
+
private _anisotropy;
|
|
53
|
+
private _flipY;
|
|
39
54
|
private _lazy;
|
|
55
|
+
private _magFilter;
|
|
56
|
+
private _minFilter;
|
|
57
|
+
private _mipmaps;
|
|
58
|
+
private _srgb;
|
|
40
59
|
/**
|
|
41
60
|
* The asset that is loaded. Available once the element is ready — await
|
|
42
61
|
* {@link whenReady} or the element's `ready()` promise before accessing it.
|
|
@@ -47,14 +66,85 @@ declare class AssetElement extends AsyncElement {
|
|
|
47
66
|
private _onAssetLoad;
|
|
48
67
|
private _onAssetError;
|
|
49
68
|
/**
|
|
50
|
-
* Builds the `data` object for the asset from an optional inline `data` attribute (JSON)
|
|
51
|
-
*
|
|
52
|
-
* `render-mode`).
|
|
69
|
+
* Builds the `data` object for the asset from an optional inline `data` attribute (JSON), the
|
|
70
|
+
* texture option attributes (for `texture` and `textureatlas` assets), and the sprite
|
|
71
|
+
* convenience attributes (`atlas`, `frame-keys`, `pixels-per-unit`, `render-mode`). An
|
|
72
|
+
* attribute overrides the matching `data` JSON key. Returns `undefined` when there is no data
|
|
73
|
+
* to apply.
|
|
53
74
|
* @param type - The resolved asset type.
|
|
54
75
|
* @returns The asset data, or `undefined`.
|
|
55
76
|
*/
|
|
56
77
|
private _buildData;
|
|
78
|
+
/**
|
|
79
|
+
* Returns the engine texture behind this asset, when there is one: the resource itself for a
|
|
80
|
+
* `texture` asset, the atlas's texture for a `textureatlas` asset, `null` otherwise
|
|
81
|
+
* (including before the asset has loaded).
|
|
82
|
+
* @returns The texture, or `null`.
|
|
83
|
+
*/
|
|
84
|
+
private _texture;
|
|
85
|
+
/**
|
|
86
|
+
* Writes one texture option through to the created asset, if any. The engine-JSON key is
|
|
87
|
+
* written into `asset.data`, mutated in place - replacing the whole object would make the
|
|
88
|
+
* registry re-patch every key, and a re-patched `srgb` or `mipmaps` recreates the texture
|
|
89
|
+
* even when unchanged. The in-place key is what a not-yet-started load reads at texture
|
|
90
|
+
* construction, and what any later reload reads. When the texture already exists, the
|
|
91
|
+
* corresponding property is assigned directly; `null` (attribute removed) deletes the key
|
|
92
|
+
* and restores the engine default. Assets of any other type are left untouched.
|
|
93
|
+
*
|
|
94
|
+
* @param key - The engine texture JSON key in `asset.data`.
|
|
95
|
+
* @param property - The Texture property to assign.
|
|
96
|
+
* @param dataValue - The engine-JSON value for `asset.data`, or `null` to delete the key.
|
|
97
|
+
* @param textureValue - The value for the Texture property, or `null` for the engine default.
|
|
98
|
+
*/
|
|
99
|
+
private _applyTextureOption;
|
|
57
100
|
private _destroyAsset;
|
|
101
|
+
/**
|
|
102
|
+
* Sets the texture's horizontal (U) address mode: how texture coordinates outside the 0 to 1
|
|
103
|
+
* range sample the texture. Applies to `texture` and `textureatlas` assets, both when the
|
|
104
|
+
* texture is created and after it has loaded.
|
|
105
|
+
* @param value - The address mode, or `null` to use the engine default of 'repeat'.
|
|
106
|
+
*/
|
|
107
|
+
set addressU(value: AddressMode | null);
|
|
108
|
+
/**
|
|
109
|
+
* Gets the texture's horizontal (U) address mode.
|
|
110
|
+
* @returns The address mode, or `null` when unset.
|
|
111
|
+
*/
|
|
112
|
+
get addressU(): AddressMode | null;
|
|
113
|
+
/**
|
|
114
|
+
* Sets the texture's vertical (V) address mode: how texture coordinates outside the 0 to 1
|
|
115
|
+
* range sample the texture. Applies to `texture` and `textureatlas` assets, both when the
|
|
116
|
+
* texture is created and after it has loaded.
|
|
117
|
+
* @param value - The address mode, or `null` to use the engine default of 'repeat'.
|
|
118
|
+
*/
|
|
119
|
+
set addressV(value: AddressMode | null);
|
|
120
|
+
/**
|
|
121
|
+
* Gets the texture's vertical (V) address mode.
|
|
122
|
+
* @returns The address mode, or `null` when unset.
|
|
123
|
+
*/
|
|
124
|
+
get addressV(): AddressMode | null;
|
|
125
|
+
/**
|
|
126
|
+
* Sets the texture's maximum anisotropic filtering level, which improves quality at oblique
|
|
127
|
+
* viewing angles. Applies to `texture` and `textureatlas` assets, both when the texture is
|
|
128
|
+
* created and after it has loaded.
|
|
129
|
+
* @param value - The anisotropy level, or `null` to use the engine default of 1.
|
|
130
|
+
*/
|
|
131
|
+
set anisotropy(value: number | null);
|
|
132
|
+
/**
|
|
133
|
+
* Gets the texture's maximum anisotropic filtering level.
|
|
134
|
+
* @returns The anisotropy level, or `null` when unset.
|
|
135
|
+
*/
|
|
136
|
+
get anisotropy(): number | null;
|
|
137
|
+
/**
|
|
138
|
+
* Sets whether the texture's image data is flipped vertically at upload. Applies to `texture`
|
|
139
|
+
* and `textureatlas` assets, both when the texture is created and after it has loaded.
|
|
140
|
+
* @param value - The flip flag, or `null` to use the engine default of `false`.
|
|
141
|
+
*/
|
|
142
|
+
set flipY(value: boolean | null);
|
|
143
|
+
/**
|
|
144
|
+
* Gets whether the texture's image data is flipped vertically at upload.
|
|
145
|
+
* @returns The flip flag, or `null` when unset.
|
|
146
|
+
*/
|
|
147
|
+
get flipY(): boolean | null;
|
|
58
148
|
/**
|
|
59
149
|
* Sets whether the asset should be loaded lazily.
|
|
60
150
|
* @param value - The lazy loading flag.
|
|
@@ -65,6 +155,55 @@ declare class AssetElement extends AsyncElement {
|
|
|
65
155
|
* @returns The lazy loading flag.
|
|
66
156
|
*/
|
|
67
157
|
get lazy(): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Sets the texture's magnification filter, used when the texture is displayed larger than its
|
|
160
|
+
* source size. Applies to `texture` and `textureatlas` assets, both when the texture is
|
|
161
|
+
* created and after it has loaded.
|
|
162
|
+
* @param value - The filter, or `null` to use the engine default of 'linear'.
|
|
163
|
+
*/
|
|
164
|
+
set magFilter(value: MagFilterMode | null);
|
|
165
|
+
/**
|
|
166
|
+
* Gets the texture's magnification filter.
|
|
167
|
+
* @returns The filter, or `null` when unset.
|
|
168
|
+
*/
|
|
169
|
+
get magFilter(): MagFilterMode | null;
|
|
170
|
+
/**
|
|
171
|
+
* Sets the texture's minification filter, used when the texture is displayed smaller than its
|
|
172
|
+
* source size. The mip variants blend within (and, for the second `linear`, between) mipmap
|
|
173
|
+
* levels. Applies to `texture` and `textureatlas` assets, both when the texture is created
|
|
174
|
+
* and after it has loaded.
|
|
175
|
+
* @param value - The filter, or `null` to use the engine default of 'linear-mip-linear'.
|
|
176
|
+
*/
|
|
177
|
+
set minFilter(value: MinFilterMode | null);
|
|
178
|
+
/**
|
|
179
|
+
* Gets the texture's minification filter.
|
|
180
|
+
* @returns The filter, or `null` when unset.
|
|
181
|
+
*/
|
|
182
|
+
get minFilter(): MinFilterMode | null;
|
|
183
|
+
/**
|
|
184
|
+
* Sets whether the texture generates and uses mipmaps. Changing this on a loaded texture
|
|
185
|
+
* recreates the underlying GPU resource, so prefer declaring it up front. Applies to
|
|
186
|
+
* `texture` and `textureatlas` assets.
|
|
187
|
+
* @param value - The mipmaps flag, or `null` to use the engine default of `true`.
|
|
188
|
+
*/
|
|
189
|
+
set mipmaps(value: boolean | null);
|
|
190
|
+
/**
|
|
191
|
+
* Gets whether the texture generates and uses mipmaps.
|
|
192
|
+
* @returns The mipmaps flag, or `null` when unset.
|
|
193
|
+
*/
|
|
194
|
+
get mipmaps(): boolean | null;
|
|
195
|
+
/**
|
|
196
|
+
* Sets whether the texture holds sRGB (gamma-encoded) color data, enabling hardware gamma
|
|
197
|
+
* decode. Free when set before the texture loads; changing it on a loaded texture recreates
|
|
198
|
+
* the underlying GPU resource. Applies to `texture` and `textureatlas` assets.
|
|
199
|
+
* @param value - The sRGB flag, or `null` to use the engine default of `false`.
|
|
200
|
+
*/
|
|
201
|
+
set srgb(value: boolean | null);
|
|
202
|
+
/**
|
|
203
|
+
* Gets whether the texture holds sRGB (gamma-encoded) color data.
|
|
204
|
+
* @returns The sRGB flag, or `null` when unset.
|
|
205
|
+
*/
|
|
206
|
+
get srgb(): boolean | null;
|
|
68
207
|
/**
|
|
69
208
|
* Returns the {@link Asset} created by the `<pc-asset>` element with the given `id`, or
|
|
70
209
|
* `undefined` if there is no such element or its asset has not been created yet.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { AppElement } from './app.cjs';
|
|
2
|
+
import type { EntityBaseElement } from './entity-base.cjs';
|
|
3
|
+
/**
|
|
4
|
+
* Base class for all PlayCanvas Web Components that initialize asynchronously.
|
|
5
|
+
*
|
|
6
|
+
* @fires {CustomEvent} ready - Fired when the element is fully initialized — once per readiness
|
|
7
|
+
* cycle, so an element that is torn down and re-initialized (for example by removing and
|
|
8
|
+
* re-inserting it) fires it again. Bubbles and is composed.
|
|
9
|
+
*/
|
|
10
|
+
declare class AsyncElement extends HTMLElement {
|
|
11
|
+
private _readyPromise;
|
|
12
|
+
private _readyResolve;
|
|
13
|
+
private _readyResolved;
|
|
14
|
+
/** @ignore */
|
|
15
|
+
constructor();
|
|
16
|
+
/**
|
|
17
|
+
* The nearest ancestor `<pc-app>` element, or `null` if this element has no `<pc-app>`
|
|
18
|
+
* ancestor. The search starts at the parent, so an element never resolves to itself.
|
|
19
|
+
* @returns The closest app element, or `null`.
|
|
20
|
+
*/
|
|
21
|
+
get closestApp(): AppElement | null;
|
|
22
|
+
/**
|
|
23
|
+
* The nearest ancestor element that fronts an entity — `<pc-entity>` or `<pc-node>` — or
|
|
24
|
+
* `null` if this element has no such ancestor. The search starts at the parent, so an element
|
|
25
|
+
* never resolves to itself.
|
|
26
|
+
* @returns The closest entity-fronting element, or `null`.
|
|
27
|
+
*/
|
|
28
|
+
get closestEntity(): EntityBaseElement | null;
|
|
29
|
+
/**
|
|
30
|
+
* Called when the element is fully initialized and ready. Subclasses should call this when
|
|
31
|
+
* they're ready. Resolves the ready promise and dispatches a bubbling, composed `ready`
|
|
32
|
+
* event. Signals at most once per readiness cycle: a repeat call before {@link _resetReady}
|
|
33
|
+
* has re-armed the promise does nothing.
|
|
34
|
+
*/
|
|
35
|
+
protected _onReady(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the ready promise to its pending state. Subclasses should call this when the
|
|
38
|
+
* resource their readiness announced is torn down (typically from `disconnectedCallback`),
|
|
39
|
+
* so that a later re-initialization can signal readiness again. Does nothing while the
|
|
40
|
+
* promise is still pending — an in-flight waiter carries over to the next readiness cycle
|
|
41
|
+
* rather than being stranded on a promise nothing will ever resolve.
|
|
42
|
+
*/
|
|
43
|
+
protected _resetReady(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Returns a promise that resolves with this element when it's ready. This is the low-level
|
|
46
|
+
* primitive underlying {@link whenReady}, which is the recommended way to wait for elements.
|
|
47
|
+
*
|
|
48
|
+
* Readiness tracks the element's current lifecycle: once a ready element is torn down (for
|
|
49
|
+
* example by removing it from the document), this returns a fresh promise that resolves when
|
|
50
|
+
* the element is next ready. A promise obtained earlier stays resolved — call this again
|
|
51
|
+
* after re-inserting an element rather than reusing a promise from before its removal.
|
|
52
|
+
* @returns A promise that resolves with this element when it's ready.
|
|
53
|
+
*/
|
|
54
|
+
ready(): Promise<this>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A union of the tag names of all elements that initialize asynchronously (i.e. elements whose
|
|
58
|
+
* classes extend {@link AsyncElement}).
|
|
59
|
+
*/
|
|
60
|
+
type AsyncElementTagName = {
|
|
61
|
+
[K in keyof HTMLElementTagNameMap]: HTMLElementTagNameMap[K] extends AsyncElement ? K : never;
|
|
62
|
+
}[keyof HTMLElementTagNameMap];
|
|
63
|
+
/**
|
|
64
|
+
* Waits for the first element matching the given tag name to be fully initialized. Note that the
|
|
65
|
+
* promise never settles if the element cannot finish initializing (for example, a `<pc-script>`
|
|
66
|
+
* that is not a direct child of `<pc-scripts>`, or a `<pc-app>` that could not create a graphics
|
|
67
|
+
* device — listen for its `error` event instead). A component element outside a `<pc-entity>` is
|
|
68
|
+
* the exception: it still becomes ready, but its `component` is `null`. Either way, a misplaced
|
|
69
|
+
* element logs a warning naming the parent it requires.
|
|
70
|
+
* @param target - The tag name of the element to wait for (e.g. `'pc-app'`).
|
|
71
|
+
* @returns A promise that resolves with the element once it's ready.
|
|
72
|
+
* @example
|
|
73
|
+
* const { app } = await whenReady('pc-app');
|
|
74
|
+
*/
|
|
75
|
+
declare function whenReady<K extends AsyncElementTagName>(target: K): Promise<HTMLElementTagNameMap[K]>;
|
|
76
|
+
/**
|
|
77
|
+
* Waits for the given element to be fully initialized. Note that the promise never settles if
|
|
78
|
+
* the element cannot finish initializing (for example, an element that is never added to the
|
|
79
|
+
* document).
|
|
80
|
+
* @param target - The element to wait for.
|
|
81
|
+
* @returns A promise that resolves with the element once it's ready.
|
|
82
|
+
* @example
|
|
83
|
+
* const appElement = document.createElement('pc-app');
|
|
84
|
+
* document.body.appendChild(appElement);
|
|
85
|
+
* const { app } = await whenReady(appElement);
|
|
86
|
+
*/
|
|
87
|
+
declare function whenReady<T extends AsyncElement>(target: T): Promise<T>;
|
|
88
|
+
/**
|
|
89
|
+
* Waits for the first element matching the given CSS selector to be fully initialized. Note that
|
|
90
|
+
* the promise never settles if the element cannot finish initializing (for example, a `<pc-script>`
|
|
91
|
+
* that is not a direct child of `<pc-scripts>`, or a `<pc-app>` that could not create a graphics
|
|
92
|
+
* device — listen for its `error` event instead). A component element outside a `<pc-entity>` is
|
|
93
|
+
* the exception: it still becomes ready, but its `component` is `null`. Either way, a misplaced
|
|
94
|
+
* element logs a warning naming the parent it requires.
|
|
95
|
+
* @param target - A CSS selector matching the element to wait for (e.g. `'#my-app'`).
|
|
96
|
+
* @returns A promise that resolves with the element once it's ready.
|
|
97
|
+
* @example
|
|
98
|
+
* // In TypeScript, supply the element type when using an arbitrary selector
|
|
99
|
+
* const { entity } = await whenReady<EntityElement>('pc-entity[name="camera"]');
|
|
100
|
+
*/
|
|
101
|
+
declare function whenReady<T extends AsyncElement = AsyncElement, S extends string = string>(target: S extends Exclude<keyof HTMLElementTagNameMap, AsyncElementTagName> ? never : S): Promise<T>;
|
|
102
|
+
export { AsyncElement, whenReady };
|
|
103
|
+
export type { AsyncElementTagName };
|
package/dist/async-element.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AppElement } from './app';
|
|
2
|
-
import type {
|
|
1
|
+
import type { AppElement } from './app.js';
|
|
2
|
+
import type { EntityBaseElement } from './entity-base.js';
|
|
3
3
|
/**
|
|
4
4
|
* Base class for all PlayCanvas Web Components that initialize asynchronously.
|
|
5
5
|
*
|
|
@@ -20,11 +20,12 @@ declare class AsyncElement extends HTMLElement {
|
|
|
20
20
|
*/
|
|
21
21
|
get closestApp(): AppElement | null;
|
|
22
22
|
/**
|
|
23
|
-
* The nearest ancestor
|
|
24
|
-
* ancestor. The search starts at the parent, so an element
|
|
25
|
-
*
|
|
23
|
+
* The nearest ancestor element that fronts an entity — `<pc-entity>` or `<pc-node>` — or
|
|
24
|
+
* `null` if this element has no such ancestor. The search starts at the parent, so an element
|
|
25
|
+
* never resolves to itself.
|
|
26
|
+
* @returns The closest entity-fronting element, or `null`.
|
|
26
27
|
*/
|
|
27
|
-
get closestEntity():
|
|
28
|
+
get closestEntity(): EntityBaseElement | null;
|
|
28
29
|
/**
|
|
29
30
|
* Called when the element is fully initialized and ready. Subclasses should call this when
|
|
30
31
|
* they're ready. Resolves the ready promise and dispatches a bubbling, composed `ready`
|
|
@@ -62,7 +63,8 @@ type AsyncElementTagName = {
|
|
|
62
63
|
/**
|
|
63
64
|
* Waits for the first element matching the given tag name to be fully initialized. Note that the
|
|
64
65
|
* promise never settles if the element cannot finish initializing (for example, a `<pc-script>`
|
|
65
|
-
* that is not a direct child of `<pc-scripts
|
|
66
|
+
* that is not a direct child of `<pc-scripts>`, or a `<pc-app>` that could not create a graphics
|
|
67
|
+
* device — listen for its `error` event instead). A component element outside a `<pc-entity>` is
|
|
66
68
|
* the exception: it still becomes ready, but its `component` is `null`. Either way, a misplaced
|
|
67
69
|
* element logs a warning naming the parent it requires.
|
|
68
70
|
* @param target - The tag name of the element to wait for (e.g. `'pc-app'`).
|
|
@@ -86,7 +88,8 @@ declare function whenReady<T extends AsyncElement>(target: T): Promise<T>;
|
|
|
86
88
|
/**
|
|
87
89
|
* Waits for the first element matching the given CSS selector to be fully initialized. Note that
|
|
88
90
|
* the promise never settles if the element cannot finish initializing (for example, a `<pc-script>`
|
|
89
|
-
* that is not a direct child of `<pc-scripts
|
|
91
|
+
* that is not a direct child of `<pc-scripts>`, or a `<pc-app>` that could not create a graphics
|
|
92
|
+
* device — listen for its `error` event instead). A component element outside a `<pc-entity>` is
|
|
90
93
|
* the exception: it still becomes ready, but its `component` is `null`. Either way, a misplaced
|
|
91
94
|
* element logs a warning naming the parent it requires.
|
|
92
95
|
* @param target - A CSS selector matching the element to wait for (e.g. `'#my-app'`).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CSS_COLORS: Record<string, string>;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import type { ButtonComponent } from 'playcanvas';
|
|
2
|
+
import { Color, Vec4 } from 'playcanvas';
|
|
3
|
+
import { ComponentElement } from './component.cjs';
|
|
4
|
+
/**
|
|
5
|
+
* The ButtonComponentElement interface provides properties and methods for manipulating
|
|
6
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-button/ | `<pc-button>`} elements.
|
|
7
|
+
* The ButtonComponentElement interface also inherits the properties and methods of the
|
|
8
|
+
* {@link HTMLElement} interface.
|
|
9
|
+
*
|
|
10
|
+
* @category Components
|
|
11
|
+
*/
|
|
12
|
+
declare class ButtonComponentElement extends ComponentElement {
|
|
13
|
+
private _active;
|
|
14
|
+
private _image;
|
|
15
|
+
private _hitPadding;
|
|
16
|
+
private _transitionMode;
|
|
17
|
+
private _hoverTint;
|
|
18
|
+
private _pressedTint;
|
|
19
|
+
private _inactiveTint;
|
|
20
|
+
private _fadeDuration;
|
|
21
|
+
private _hoverSpriteAsset;
|
|
22
|
+
private _hoverSpriteFrame;
|
|
23
|
+
private _pressedSpriteAsset;
|
|
24
|
+
private _pressedSpriteFrame;
|
|
25
|
+
private _inactiveSpriteAsset;
|
|
26
|
+
private _inactiveSpriteFrame;
|
|
27
|
+
/** @ignore */
|
|
28
|
+
constructor();
|
|
29
|
+
protected getInitialComponentData(): Record<string, any>;
|
|
30
|
+
/**
|
|
31
|
+
* Gets the underlying PlayCanvas button component.
|
|
32
|
+
* @returns The button component.
|
|
33
|
+
*/
|
|
34
|
+
get component(): ButtonComponent;
|
|
35
|
+
/**
|
|
36
|
+
* Sets whether the button is active and responds to input.
|
|
37
|
+
* @param value - Whether the button is active.
|
|
38
|
+
*/
|
|
39
|
+
set active(value: boolean);
|
|
40
|
+
/**
|
|
41
|
+
* Gets whether the button is active.
|
|
42
|
+
* @returns Whether the button is active.
|
|
43
|
+
*/
|
|
44
|
+
get active(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Sets the reference (CSS selector, element id or entity name) to the `<pc-entity>` whose image
|
|
47
|
+
* element is used for visual transitions. Defaults to the button's own entity.
|
|
48
|
+
* @param value - The image entity reference.
|
|
49
|
+
*/
|
|
50
|
+
set image(value: string);
|
|
51
|
+
/**
|
|
52
|
+
* Gets the reference to the `<pc-entity>` whose image element is used for visual transitions.
|
|
53
|
+
* @returns The image entity reference.
|
|
54
|
+
*/
|
|
55
|
+
get image(): string;
|
|
56
|
+
/**
|
|
57
|
+
* Sets the padding used to expand the button's hit area, as a Vec4 (left, bottom, right, top).
|
|
58
|
+
* @param value - The hit padding.
|
|
59
|
+
*/
|
|
60
|
+
set hitPadding(value: Vec4);
|
|
61
|
+
/**
|
|
62
|
+
* Gets the padding used to expand the button's hit area.
|
|
63
|
+
* @returns The hit padding.
|
|
64
|
+
*/
|
|
65
|
+
get hitPadding(): Vec4;
|
|
66
|
+
/**
|
|
67
|
+
* Sets how the button reacts to being hovered/pressed. Can be `tint` or `sprite`. Defaults to
|
|
68
|
+
* `tint`.
|
|
69
|
+
* @param value - The transition mode.
|
|
70
|
+
*/
|
|
71
|
+
set transitionMode(value: 'tint' | 'sprite');
|
|
72
|
+
/**
|
|
73
|
+
* Gets how the button reacts to being hovered/pressed.
|
|
74
|
+
* @returns The transition mode.
|
|
75
|
+
*/
|
|
76
|
+
get transitionMode(): "tint" | "sprite";
|
|
77
|
+
/**
|
|
78
|
+
* Sets the tint color applied to the image entity when the button is hovered (tint transition
|
|
79
|
+
* mode).
|
|
80
|
+
* @param value - The hover tint.
|
|
81
|
+
*/
|
|
82
|
+
set hoverTint(value: Color);
|
|
83
|
+
/**
|
|
84
|
+
* Gets the hover tint color.
|
|
85
|
+
* @returns The hover tint.
|
|
86
|
+
*/
|
|
87
|
+
get hoverTint(): Color;
|
|
88
|
+
/**
|
|
89
|
+
* Sets the tint color applied to the image entity when the button is pressed (tint transition
|
|
90
|
+
* mode).
|
|
91
|
+
* @param value - The pressed tint.
|
|
92
|
+
*/
|
|
93
|
+
set pressedTint(value: Color);
|
|
94
|
+
/**
|
|
95
|
+
* Gets the pressed tint color.
|
|
96
|
+
* @returns The pressed tint.
|
|
97
|
+
*/
|
|
98
|
+
get pressedTint(): Color;
|
|
99
|
+
/**
|
|
100
|
+
* Sets the tint color applied to the image entity when the button is inactive (tint transition
|
|
101
|
+
* mode).
|
|
102
|
+
* @param value - The inactive tint.
|
|
103
|
+
*/
|
|
104
|
+
set inactiveTint(value: Color);
|
|
105
|
+
/**
|
|
106
|
+
* Gets the inactive tint color.
|
|
107
|
+
* @returns The inactive tint.
|
|
108
|
+
*/
|
|
109
|
+
get inactiveTint(): Color;
|
|
110
|
+
/**
|
|
111
|
+
* Sets the duration (in milliseconds) over which tint transitions are applied.
|
|
112
|
+
* @param value - The fade duration.
|
|
113
|
+
*/
|
|
114
|
+
set fadeDuration(value: number);
|
|
115
|
+
/**
|
|
116
|
+
* Gets the duration over which tint transitions are applied.
|
|
117
|
+
* @returns The fade duration.
|
|
118
|
+
*/
|
|
119
|
+
get fadeDuration(): number;
|
|
120
|
+
/**
|
|
121
|
+
* Sets the id of the `pc-asset` sprite shown when the button is hovered (sprite transition
|
|
122
|
+
* mode).
|
|
123
|
+
* @param value - The hover sprite asset id.
|
|
124
|
+
*/
|
|
125
|
+
set hoverSpriteAsset(value: string);
|
|
126
|
+
/**
|
|
127
|
+
* Gets the id of the `pc-asset` sprite shown when the button is hovered.
|
|
128
|
+
* @returns The hover sprite asset id.
|
|
129
|
+
*/
|
|
130
|
+
get hoverSpriteAsset(): string;
|
|
131
|
+
/**
|
|
132
|
+
* Sets the frame of the hover sprite to show.
|
|
133
|
+
* @param value - The hover sprite frame.
|
|
134
|
+
*/
|
|
135
|
+
set hoverSpriteFrame(value: number);
|
|
136
|
+
/**
|
|
137
|
+
* Gets the frame of the hover sprite to show.
|
|
138
|
+
* @returns The hover sprite frame.
|
|
139
|
+
*/
|
|
140
|
+
get hoverSpriteFrame(): number;
|
|
141
|
+
/**
|
|
142
|
+
* Sets the id of the `pc-asset` sprite shown when the button is pressed (sprite transition
|
|
143
|
+
* mode).
|
|
144
|
+
* @param value - The pressed sprite asset id.
|
|
145
|
+
*/
|
|
146
|
+
set pressedSpriteAsset(value: string);
|
|
147
|
+
/**
|
|
148
|
+
* Gets the id of the `pc-asset` sprite shown when the button is pressed.
|
|
149
|
+
* @returns The pressed sprite asset id.
|
|
150
|
+
*/
|
|
151
|
+
get pressedSpriteAsset(): string;
|
|
152
|
+
/**
|
|
153
|
+
* Sets the frame of the pressed sprite to show.
|
|
154
|
+
* @param value - The pressed sprite frame.
|
|
155
|
+
*/
|
|
156
|
+
set pressedSpriteFrame(value: number);
|
|
157
|
+
/**
|
|
158
|
+
* Gets the frame of the pressed sprite to show.
|
|
159
|
+
* @returns The pressed sprite frame.
|
|
160
|
+
*/
|
|
161
|
+
get pressedSpriteFrame(): number;
|
|
162
|
+
/**
|
|
163
|
+
* Sets the id of the `pc-asset` sprite shown when the button is inactive (sprite transition
|
|
164
|
+
* mode).
|
|
165
|
+
* @param value - The inactive sprite asset id.
|
|
166
|
+
*/
|
|
167
|
+
set inactiveSpriteAsset(value: string);
|
|
168
|
+
/**
|
|
169
|
+
* Gets the id of the `pc-asset` sprite shown when the button is inactive.
|
|
170
|
+
* @returns The inactive sprite asset id.
|
|
171
|
+
*/
|
|
172
|
+
get inactiveSpriteAsset(): string;
|
|
173
|
+
/**
|
|
174
|
+
* Sets the frame of the inactive sprite to show.
|
|
175
|
+
* @param value - The inactive sprite frame.
|
|
176
|
+
*/
|
|
177
|
+
set inactiveSpriteFrame(value: number);
|
|
178
|
+
/**
|
|
179
|
+
* Gets the frame of the inactive sprite to show.
|
|
180
|
+
* @returns The inactive sprite frame.
|
|
181
|
+
*/
|
|
182
|
+
get inactiveSpriteFrame(): number;
|
|
183
|
+
static get observedAttributes(): string[];
|
|
184
|
+
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
|
|
185
|
+
}
|
|
186
|
+
export { ButtonComponentElement };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ButtonComponent } from 'playcanvas';
|
|
2
2
|
import { Color, Vec4 } from 'playcanvas';
|
|
3
|
-
import { ComponentElement } from './component';
|
|
3
|
+
import { ComponentElement } from './component.js';
|
|
4
4
|
/**
|
|
5
5
|
* The ButtonComponentElement interface provides properties and methods for manipulating
|
|
6
6
|
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-button/ | `<pc-button>`} elements.
|