@playcanvas/web-components 0.10.0 → 0.10.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.
- package/dist/app.d.ts +52 -7
- package/dist/asset.d.ts +9 -0
- package/dist/async-element.d.ts +12 -2
- package/dist/components/component.d.ts +5 -4
- package/dist/custom-elements.json +583 -110
- package/dist/entity.d.ts +5 -4
- package/dist/loading-bar.d.ts +35 -0
- package/dist/material.d.ts +8 -2
- package/dist/pwc.cjs +385 -105
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +385 -105
- 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 +385 -105
- package/dist/pwc.mjs.map +1 -1
- package/dist/scene.d.ts +11 -3
- package/dist/vscode.html-custom-data.json +8 -3
- package/dist/web-types.json +322 -78
- package/package.json +1 -1
- package/src/app.ts +172 -73
- package/src/asset.ts +25 -0
- package/src/async-element.ts +14 -4
- package/src/components/component.ts +6 -5
- package/src/entity.ts +34 -18
- package/src/loading-bar.ts +122 -0
- package/src/material.ts +10 -4
- package/src/scene.ts +49 -19
package/dist/app.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ import { AsyncElement } from './async-element';
|
|
|
5
5
|
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-app/ | `<pc-app>`} elements.
|
|
6
6
|
* The AppElement interface also inherits the properties and methods of the
|
|
7
7
|
* {@link HTMLElement} interface.
|
|
8
|
+
*
|
|
9
|
+
* @fires {ProgressEvent} progress - Fired while the application preloads its assets. `loaded` and
|
|
10
|
+
* `total` are asset counts, not bytes, and an asset that fails to load still counts as loaded.
|
|
11
|
+
* Fired at least once per boot, and the final event always has `loaded` equal to `total`. Does
|
|
12
|
+
* not bubble.
|
|
8
13
|
*/
|
|
9
14
|
declare class AppElement extends AsyncElement {
|
|
10
15
|
/**
|
|
@@ -17,18 +22,31 @@ declare class AppElement extends AsyncElement {
|
|
|
17
22
|
private _depth;
|
|
18
23
|
private _stencil;
|
|
19
24
|
private _highResolution;
|
|
25
|
+
private _loadingBar;
|
|
26
|
+
private _bar;
|
|
20
27
|
private _hierarchyReady;
|
|
21
28
|
private _picker;
|
|
22
29
|
private _hasPointerListeners;
|
|
23
30
|
private _hoveredEntity;
|
|
31
|
+
private _pickToken;
|
|
24
32
|
private _pointerHandlers;
|
|
25
33
|
private _app;
|
|
34
|
+
private _loadProgress;
|
|
26
35
|
/**
|
|
27
|
-
* The PlayCanvas application instance.
|
|
28
|
-
* {@link whenReady} or the element's `ready()`
|
|
29
|
-
*
|
|
36
|
+
* The PlayCanvas application instance. `null` until the element is ready, and again once it
|
|
37
|
+
* has been removed from the document — await {@link whenReady} or the element's `ready()`
|
|
38
|
+
* promise before accessing it.
|
|
39
|
+
* @returns The application instance, or `null`.
|
|
30
40
|
*/
|
|
31
|
-
get app(): AppBase;
|
|
41
|
+
get app(): AppBase | null;
|
|
42
|
+
/**
|
|
43
|
+
* The asset preload progress of the application, as a fraction from 0 to 1. It is 0 until
|
|
44
|
+
* preloading begins (and again once the element has been removed from the document), and 1
|
|
45
|
+
* once preloading has finished — including when there was nothing to preload. Read this to
|
|
46
|
+
* initialize a loading UI; subsequent updates arrive via the `progress` event.
|
|
47
|
+
* @returns The preload progress.
|
|
48
|
+
*/
|
|
49
|
+
get loadProgress(): number;
|
|
32
50
|
/**
|
|
33
51
|
* Creates a new AppElement instance.
|
|
34
52
|
*
|
|
@@ -41,9 +59,21 @@ declare class AppElement extends AsyncElement {
|
|
|
41
59
|
_pickerCreate(): void;
|
|
42
60
|
_pickerDestroy(): void;
|
|
43
61
|
private _getPickerCoordinates;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Picks the scene under the pointer and returns the graph node that was hit, or `null`.
|
|
64
|
+
*
|
|
65
|
+
* The read back is asynchronous because the synchronous {@link Picker.getSelection} is not
|
|
66
|
+
* supported on WebGPU, where it returns an empty selection rather than failing - which
|
|
67
|
+
* silently disabled every `onpointer*` handler once WebGPU became the resolved backend. The
|
|
68
|
+
* async variant works on both backends and does not block the main thread on a GPU read.
|
|
69
|
+
*
|
|
70
|
+
* @param event - The pointer event to pick under.
|
|
71
|
+
* @returns The graph node under the pointer, or `null` if nothing was hit.
|
|
72
|
+
*/
|
|
73
|
+
private _pickNode;
|
|
74
|
+
_onPointerMove(event: PointerEvent): Promise<void>;
|
|
75
|
+
_onPointerDown(event: PointerEvent): Promise<void>;
|
|
76
|
+
_onPointerUp(event: PointerEvent): Promise<void>;
|
|
47
77
|
_onPointerListenerAdded(type: string): void;
|
|
48
78
|
_onPointerListenerRemoved(type: string): void;
|
|
49
79
|
/**
|
|
@@ -104,6 +134,21 @@ declare class AppElement extends AsyncElement {
|
|
|
104
134
|
* @returns The high resolution flag.
|
|
105
135
|
*/
|
|
106
136
|
get highResolution(): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Sets whether the application shows its built-in loading bar while it boots and preloads its
|
|
139
|
+
* assets. Enabled by default; setting `false` removes the bar immediately, while setting
|
|
140
|
+
* `true` has no effect until the element is next connected. The bar can be themed with the
|
|
141
|
+
* CSS custom properties `--pc-loading-bar-color`, `--pc-loading-bar-background` and
|
|
142
|
+
* `--pc-loading-bar-height`.
|
|
143
|
+
* @param value - The loading bar flag.
|
|
144
|
+
*/
|
|
145
|
+
set loadingBar(value: boolean);
|
|
146
|
+
/**
|
|
147
|
+
* Gets whether the application shows its built-in loading bar while it boots and preloads
|
|
148
|
+
* its assets.
|
|
149
|
+
* @returns The loading bar flag.
|
|
150
|
+
*/
|
|
151
|
+
get loadingBar(): boolean;
|
|
107
152
|
/**
|
|
108
153
|
* Sets the stencil flag.
|
|
109
154
|
* @param value - The stencil flag.
|
package/dist/asset.d.ts
CHANGED
|
@@ -27,6 +27,13 @@ import { AsyncElement } from './async-element';
|
|
|
27
27
|
* @attribute {number} pixels-per-unit - For a `sprite` asset, the number of pixels per world unit.
|
|
28
28
|
* @attribute {'simple' | 'sliced' | 'tiled'} render-mode - For a `sprite` asset, how the sprite is
|
|
29
29
|
* rendered when resized.
|
|
30
|
+
*
|
|
31
|
+
* @fires {Event} load - Fired each time the asset finishes loading, including a `lazy` asset
|
|
32
|
+
* loaded later and any subsequent reloads. Does not bubble — listen on this element, or use a
|
|
33
|
+
* capture-phase listener on an ancestor to observe every asset.
|
|
34
|
+
* @fires {ErrorEvent} error - Fired when the asset fails to load, with the engine's error in
|
|
35
|
+
* `message`. Does not bubble. The element still becomes ready — readiness means the load settled,
|
|
36
|
+
* not that it succeeded.
|
|
30
37
|
*/
|
|
31
38
|
declare class AssetElement extends AsyncElement {
|
|
32
39
|
private _lazy;
|
|
@@ -37,6 +44,8 @@ declare class AssetElement extends AsyncElement {
|
|
|
37
44
|
asset: Asset | null;
|
|
38
45
|
connectedCallback(): Promise<void>;
|
|
39
46
|
disconnectedCallback(): void;
|
|
47
|
+
private _onAssetLoad;
|
|
48
|
+
private _onAssetError;
|
|
40
49
|
createAsset(): void;
|
|
41
50
|
/**
|
|
42
51
|
* Builds the `data` object for the asset from an optional inline `data` attribute (JSON) and,
|
package/dist/async-element.d.ts
CHANGED
|
@@ -11,8 +11,18 @@ declare class AsyncElement extends HTMLElement {
|
|
|
11
11
|
private _readyResolve;
|
|
12
12
|
/** @ignore */
|
|
13
13
|
constructor();
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* The nearest ancestor `<pc-app>` element, or `null` if this element has no `<pc-app>`
|
|
16
|
+
* ancestor. The search starts at the parent, so an element never resolves to itself.
|
|
17
|
+
* @returns The closest app element, or `null`.
|
|
18
|
+
*/
|
|
19
|
+
get closestApp(): AppElement | null;
|
|
20
|
+
/**
|
|
21
|
+
* The nearest ancestor `<pc-entity>` element, or `null` if this element has no `<pc-entity>`
|
|
22
|
+
* ancestor. The search starts at the parent, so an element never resolves to itself.
|
|
23
|
+
* @returns The closest entity element, or `null`.
|
|
24
|
+
*/
|
|
25
|
+
get closestEntity(): EntityElement | null;
|
|
16
26
|
/**
|
|
17
27
|
* Called when the element is fully initialized and ready. Subclasses should call this when
|
|
18
28
|
* they're ready. Resolves the ready promise and dispatches a bubbling, composed `ready`
|
|
@@ -23,11 +23,12 @@ declare class ComponentElement extends AsyncElement {
|
|
|
23
23
|
connectedCallback(): Promise<void>;
|
|
24
24
|
disconnectedCallback(): void;
|
|
25
25
|
/**
|
|
26
|
-
* The PlayCanvas component instance.
|
|
27
|
-
* {@link whenReady} or the
|
|
28
|
-
*
|
|
26
|
+
* The PlayCanvas component instance. `null` until the element is ready, and also for an
|
|
27
|
+
* element that is not a descendant of a `<pc-entity>` — await {@link whenReady} or the
|
|
28
|
+
* element's `ready()` promise before accessing it.
|
|
29
|
+
* @returns The component instance, or `null`.
|
|
29
30
|
*/
|
|
30
|
-
get component(): Component;
|
|
31
|
+
get component(): Component | null;
|
|
31
32
|
/**
|
|
32
33
|
* Sets the enabled state of the component.
|
|
33
34
|
* @param value - The enabled state of the component.
|