@playcanvas/web-components 0.10.1 → 0.11.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.ts +103 -32
- package/dist/components/camera-component.d.ts +13 -13
- package/dist/components/screen-component.d.ts +25 -4
- package/dist/components/scrollview-component.d.ts +6 -4
- package/dist/custom-elements.json +239 -96
- package/dist/entity.d.ts +13 -0
- package/dist/parse.d.ts +4 -2
- package/dist/pwc.cjs +308 -156
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +308 -156
- 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 +309 -157
- package/dist/pwc.mjs.map +1 -1
- package/dist/sky.d.ts +12 -11
- package/dist/vscode.html-custom-data.json +40 -20
- package/dist/web-types.json +67 -48
- package/package.json +1 -1
- package/src/app.ts +189 -79
- package/src/components/camera-component.ts +31 -26
- package/src/components/screen-component.ts +42 -12
- package/src/components/scrollview-component.ts +6 -4
- package/src/entity.ts +35 -17
- package/src/parse.ts +5 -3
- package/src/sky.ts +26 -25
package/dist/app.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { AppBase } from 'playcanvas';
|
|
1
|
+
import { AppBase, Entity } from 'playcanvas';
|
|
2
2
|
import { AsyncElement } from './async-element';
|
|
3
|
+
import { EntityElement } from './entity';
|
|
3
4
|
/**
|
|
4
5
|
* The AppElement interface provides properties and methods for manipulating
|
|
5
6
|
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-app/ | `<pc-app>`} elements.
|
|
@@ -19,12 +20,24 @@ declare class AppElement extends AsyncElement {
|
|
|
19
20
|
private _alpha;
|
|
20
21
|
private _backend;
|
|
21
22
|
private _antialias;
|
|
22
|
-
private
|
|
23
|
-
private
|
|
24
|
-
private
|
|
23
|
+
private _depthBuffer;
|
|
24
|
+
private _stencilBuffer;
|
|
25
|
+
private _maxPixelRatio;
|
|
25
26
|
private _loadingBar;
|
|
27
|
+
/**
|
|
28
|
+
* Set once the graphics options above have been handed to `createGraphicsDevice`, after which
|
|
29
|
+
* writing any of them changes nothing. Guards the warning in {@link _warnIfBooted}, and is
|
|
30
|
+
* cleared on disconnect so a re-connected element boots from its current attributes.
|
|
31
|
+
*/
|
|
32
|
+
private _optionsLocked;
|
|
26
33
|
private _bar;
|
|
27
34
|
private _hierarchyReady;
|
|
35
|
+
/**
|
|
36
|
+
* The elements backing this application's entities, keyed by the entity itself. Registered
|
|
37
|
+
* by EntityElement at creation and removed when an entity is destroyed, this joins engine
|
|
38
|
+
* scene nodes back to their owning elements by identity - never by name.
|
|
39
|
+
*/
|
|
40
|
+
private _entityElements;
|
|
28
41
|
private _picker;
|
|
29
42
|
private _hasPointerListeners;
|
|
30
43
|
private _hoveredEntity;
|
|
@@ -58,6 +71,50 @@ declare class AppElement extends AsyncElement {
|
|
|
58
71
|
_onWindowResize(): void;
|
|
59
72
|
_pickerCreate(): void;
|
|
60
73
|
_pickerDestroy(): void;
|
|
74
|
+
/**
|
|
75
|
+
* Registers the element that created an entity. Called by EntityElement when it creates its
|
|
76
|
+
* entity.
|
|
77
|
+
*
|
|
78
|
+
* @param entity - The entity.
|
|
79
|
+
* @param element - The element that created it.
|
|
80
|
+
* @ignore
|
|
81
|
+
*/
|
|
82
|
+
_registerEntityElement(entity: Entity, element: EntityElement): void;
|
|
83
|
+
/**
|
|
84
|
+
* Removes the registration for a destroyed entity. Called by EntityElement.
|
|
85
|
+
*
|
|
86
|
+
* @param entity - The entity.
|
|
87
|
+
* @ignore
|
|
88
|
+
*/
|
|
89
|
+
_unregisterEntityElement(entity: Entity): void;
|
|
90
|
+
/**
|
|
91
|
+
* Returns the `<pc-entity>` element whose backing entity is `entity`, or `null` if the
|
|
92
|
+
* entity was not created by an element of this application - for example, a node inside a
|
|
93
|
+
* model's instantiated hierarchy, or an entity created through the engine API.
|
|
94
|
+
*
|
|
95
|
+
* @param entity - The entity to look up.
|
|
96
|
+
* @returns The element backing the entity, or `null`.
|
|
97
|
+
*/
|
|
98
|
+
elementFromEntity(entity: Entity): EntityElement | null;
|
|
99
|
+
/**
|
|
100
|
+
* Resolves the element that owns a picked node: the nearest node up the parent chain -
|
|
101
|
+
* starting with the node itself - that was created by a `<pc-entity>` of this application.
|
|
102
|
+
* A hit inside a model's instantiated hierarchy therefore resolves to the element hosting
|
|
103
|
+
* the model.
|
|
104
|
+
*
|
|
105
|
+
* @param node - The picked node, or `null`.
|
|
106
|
+
* @returns The owning element, or `null`.
|
|
107
|
+
*/
|
|
108
|
+
private _elementFromNode;
|
|
109
|
+
/**
|
|
110
|
+
* Like {@link _elementFromNode}, but skips elements without a listener for `type`, so a hit
|
|
111
|
+
* on an unlistened child still reaches a listening ancestor.
|
|
112
|
+
*
|
|
113
|
+
* @param node - The picked node, or `null`.
|
|
114
|
+
* @param type - The pointer event type a listener is required for.
|
|
115
|
+
* @returns The nearest listening element, or `null`.
|
|
116
|
+
*/
|
|
117
|
+
private _elementWithListener;
|
|
61
118
|
private _getPickerCoordinates;
|
|
62
119
|
/**
|
|
63
120
|
* Picks the scene under the pointer and returns the graph node that was hit, or `null`.
|
|
@@ -77,28 +134,37 @@ declare class AppElement extends AsyncElement {
|
|
|
77
134
|
_onPointerListenerAdded(type: string): void;
|
|
78
135
|
_onPointerListenerRemoved(type: string): void;
|
|
79
136
|
/**
|
|
80
|
-
*
|
|
137
|
+
* Warns that a graphics option was written too late to have any effect. These options are read
|
|
138
|
+
* once, when the element connects and creates its graphics device, so a later write updates
|
|
139
|
+
* only the element's own property - silently, without this.
|
|
140
|
+
*
|
|
141
|
+
* @param name - The name of the option, as its attribute.
|
|
142
|
+
*/
|
|
143
|
+
private _warnIfBooted;
|
|
144
|
+
/**
|
|
145
|
+
* Sets whether the frame buffer has an alpha channel, which is what lets the page show through
|
|
146
|
+
* wherever the scene has not drawn. Read only when the application boots.
|
|
81
147
|
* @param value - The alpha flag.
|
|
82
148
|
*/
|
|
83
149
|
set alpha(value: boolean);
|
|
84
150
|
/**
|
|
85
|
-
* Gets the alpha
|
|
151
|
+
* Gets whether the frame buffer has an alpha channel.
|
|
86
152
|
* @returns The alpha flag.
|
|
87
153
|
*/
|
|
88
154
|
get alpha(): boolean;
|
|
89
155
|
/**
|
|
90
|
-
* Sets the
|
|
156
|
+
* Sets whether the frame buffer is anti-aliased. Read only when the application boots.
|
|
91
157
|
* @param value - The antialias flag.
|
|
92
158
|
*/
|
|
93
159
|
set antialias(value: boolean);
|
|
94
160
|
/**
|
|
95
|
-
* Gets the
|
|
161
|
+
* Gets whether the frame buffer is anti-aliased.
|
|
96
162
|
* @returns The antialias flag.
|
|
97
163
|
*/
|
|
98
164
|
get antialias(): boolean;
|
|
99
165
|
/**
|
|
100
166
|
* Sets the graphics backend. Defaults to 'webgpu', which falls back to 'webgl2' if WebGPU
|
|
101
|
-
* is not supported by the browser.
|
|
167
|
+
* is not supported by the browser. Read only when the application boots.
|
|
102
168
|
* @param value - The graphics backend ('webgpu', 'webgl2', or 'null').
|
|
103
169
|
*/
|
|
104
170
|
set backend(value: 'webgpu' | 'webgl2' | 'null');
|
|
@@ -108,32 +174,22 @@ declare class AppElement extends AsyncElement {
|
|
|
108
174
|
*/
|
|
109
175
|
get backend(): "webgpu" | "webgl2" | "null";
|
|
110
176
|
/**
|
|
111
|
-
* Sets the depth
|
|
112
|
-
*
|
|
177
|
+
* Sets whether the frame buffer has a depth buffer, which the renderer needs to resolve which
|
|
178
|
+
* surface is nearest the camera. Read only when the application boots.
|
|
179
|
+
* @param value - The depth buffer flag.
|
|
113
180
|
*/
|
|
114
|
-
set
|
|
181
|
+
set depthBuffer(value: boolean);
|
|
115
182
|
/**
|
|
116
|
-
* Gets the depth
|
|
117
|
-
* @returns The depth flag.
|
|
183
|
+
* Gets whether the frame buffer has a depth buffer.
|
|
184
|
+
* @returns The depth buffer flag.
|
|
118
185
|
*/
|
|
119
|
-
get
|
|
186
|
+
get depthBuffer(): boolean;
|
|
120
187
|
/**
|
|
121
188
|
* Gets the hierarchy ready flag.
|
|
122
189
|
* @returns The hierarchy ready flag.
|
|
123
190
|
* @ignore
|
|
124
191
|
*/
|
|
125
192
|
get hierarchyReady(): boolean;
|
|
126
|
-
/**
|
|
127
|
-
* Sets the high resolution flag. When true, the application will render at the device's
|
|
128
|
-
* physical resolution. When false, the application will render at CSS resolution.
|
|
129
|
-
* @param value - The high resolution flag.
|
|
130
|
-
*/
|
|
131
|
-
set highResolution(value: boolean);
|
|
132
|
-
/**
|
|
133
|
-
* Gets the high resolution flag.
|
|
134
|
-
* @returns The high resolution flag.
|
|
135
|
-
*/
|
|
136
|
-
get highResolution(): boolean;
|
|
137
193
|
/**
|
|
138
194
|
* Sets whether the application shows its built-in loading bar while it boots and preloads its
|
|
139
195
|
* assets. Enabled by default; setting `false` removes the bar immediately, while setting
|
|
@@ -150,15 +206,30 @@ declare class AppElement extends AsyncElement {
|
|
|
150
206
|
*/
|
|
151
207
|
get loadingBar(): boolean;
|
|
152
208
|
/**
|
|
153
|
-
* Sets the
|
|
154
|
-
*
|
|
209
|
+
* Sets the cap on the pixel ratio the application renders at. The canvas is sized by the
|
|
210
|
+
* smaller of this value and the display's own device pixel ratio, so the default of `Infinity`
|
|
211
|
+
* renders at full physical resolution, `1` renders at CSS resolution, and an intermediate
|
|
212
|
+
* value such as `2` keeps a dense display sharp without paying for every one of its pixels.
|
|
213
|
+
* Must be greater than 0. Unlike the other graphics options, this applies immediately.
|
|
214
|
+
* @param value - The maximum pixel ratio.
|
|
215
|
+
*/
|
|
216
|
+
set maxPixelRatio(value: number);
|
|
217
|
+
/**
|
|
218
|
+
* Gets the cap on the pixel ratio the application renders at.
|
|
219
|
+
* @returns The maximum pixel ratio.
|
|
220
|
+
*/
|
|
221
|
+
get maxPixelRatio(): number;
|
|
222
|
+
/**
|
|
223
|
+
* Sets whether the frame buffer has a stencil buffer, which stencil-based effects and UI
|
|
224
|
+
* masking need. Read only when the application boots.
|
|
225
|
+
* @param value - The stencil buffer flag.
|
|
155
226
|
*/
|
|
156
|
-
set
|
|
227
|
+
set stencilBuffer(value: boolean);
|
|
157
228
|
/**
|
|
158
|
-
* Gets the stencil
|
|
159
|
-
* @returns The stencil flag.
|
|
229
|
+
* Gets whether the frame buffer has a stencil buffer.
|
|
230
|
+
* @returns The stencil buffer flag.
|
|
160
231
|
*/
|
|
161
|
-
get
|
|
232
|
+
get stencilBuffer(): boolean;
|
|
162
233
|
static get observedAttributes(): string[];
|
|
163
234
|
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
|
|
164
235
|
}
|
|
@@ -21,7 +21,7 @@ declare class CameraComponentElement extends ComponentElement {
|
|
|
21
21
|
private _gamma;
|
|
22
22
|
private _horizontalFov;
|
|
23
23
|
private _nearClip;
|
|
24
|
-
private
|
|
24
|
+
private _projection;
|
|
25
25
|
private _orthoHeight;
|
|
26
26
|
private _priority;
|
|
27
27
|
private _rect;
|
|
@@ -42,12 +42,12 @@ declare class CameraComponentElement extends ComponentElement {
|
|
|
42
42
|
gammaCorrection: 0 | 1;
|
|
43
43
|
horizontalFov: boolean;
|
|
44
44
|
nearClip: number;
|
|
45
|
-
projection:
|
|
45
|
+
projection: number;
|
|
46
46
|
orthoHeight: number;
|
|
47
47
|
priority: number;
|
|
48
48
|
rect: Vec4;
|
|
49
49
|
scissorRect: Vec4;
|
|
50
|
-
toneMapping: number
|
|
50
|
+
toneMapping: number;
|
|
51
51
|
};
|
|
52
52
|
get xrAvailable(): boolean | null;
|
|
53
53
|
/**
|
|
@@ -186,16 +186,6 @@ declare class CameraComponentElement extends ComponentElement {
|
|
|
186
186
|
* @returns The near clip distance.
|
|
187
187
|
*/
|
|
188
188
|
get nearClip(): number;
|
|
189
|
-
/**
|
|
190
|
-
* Sets the orthographic projection of the camera.
|
|
191
|
-
* @param value - The orthographic projection.
|
|
192
|
-
*/
|
|
193
|
-
set orthographic(value: boolean);
|
|
194
|
-
/**
|
|
195
|
-
* Gets the orthographic projection of the camera.
|
|
196
|
-
* @returns The orthographic projection.
|
|
197
|
-
*/
|
|
198
|
-
get orthographic(): boolean;
|
|
199
189
|
/**
|
|
200
190
|
* Sets the orthographic height of the camera.
|
|
201
191
|
* @param value - The orthographic height.
|
|
@@ -216,6 +206,16 @@ declare class CameraComponentElement extends ComponentElement {
|
|
|
216
206
|
* @returns The priority.
|
|
217
207
|
*/
|
|
218
208
|
get priority(): number;
|
|
209
|
+
/**
|
|
210
|
+
* Sets the projection of the camera. Use `orthoHeight` to size an orthographic projection.
|
|
211
|
+
* @param value - The projection ('perspective' or 'orthographic').
|
|
212
|
+
*/
|
|
213
|
+
set projection(value: 'perspective' | 'orthographic');
|
|
214
|
+
/**
|
|
215
|
+
* Gets the projection of the camera.
|
|
216
|
+
* @returns The projection.
|
|
217
|
+
*/
|
|
218
|
+
get projection(): "perspective" | "orthographic";
|
|
219
219
|
/**
|
|
220
220
|
* Sets the rect of the camera.
|
|
221
221
|
* @param value - The rect.
|
|
@@ -13,7 +13,7 @@ declare class ScreenComponentElement extends ComponentElement {
|
|
|
13
13
|
private _resolution;
|
|
14
14
|
private _referenceResolution;
|
|
15
15
|
private _priority;
|
|
16
|
-
private
|
|
16
|
+
private _scaleMode;
|
|
17
17
|
private _scaleBlend;
|
|
18
18
|
/** @ignore */
|
|
19
19
|
constructor();
|
|
@@ -22,7 +22,7 @@ declare class ScreenComponentElement extends ComponentElement {
|
|
|
22
22
|
referenceResolution: Vec2;
|
|
23
23
|
resolution: Vec2;
|
|
24
24
|
scaleBlend: number;
|
|
25
|
-
scaleMode:
|
|
25
|
+
scaleMode: string;
|
|
26
26
|
screenSpace: boolean;
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
@@ -36,10 +36,31 @@ declare class ScreenComponentElement extends ComponentElement {
|
|
|
36
36
|
get referenceResolution(): Vec2;
|
|
37
37
|
set resolution(value: Vec2);
|
|
38
38
|
get resolution(): Vec2;
|
|
39
|
+
/**
|
|
40
|
+
* Sets how the screen's `resolution` and `referenceResolution` are weighted against each other
|
|
41
|
+
* when `scaleMode` is `blend`, from 0 (follow the resolution) to 1 (follow the reference
|
|
42
|
+
* resolution). Ignored while `scaleMode` is `none`.
|
|
43
|
+
* @param value - The scale blend factor.
|
|
44
|
+
*/
|
|
39
45
|
set scaleBlend(value: number);
|
|
46
|
+
/**
|
|
47
|
+
* Gets how the screen's resolutions are weighted against each other.
|
|
48
|
+
* @returns The scale blend factor.
|
|
49
|
+
*/
|
|
40
50
|
get scaleBlend(): number;
|
|
41
|
-
|
|
42
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Sets how the screen scales its contents. `none` renders at `resolution` and ignores
|
|
53
|
+
* `referenceResolution`; `blend` scales between the two, weighted by `scaleBlend`, which is what
|
|
54
|
+
* keeps a UI laid out at one resolution usable at another. Requires `screenSpace` - the engine
|
|
55
|
+
* forces `none` on a world-space screen, which does not support scaling.
|
|
56
|
+
* @param value - The scale mode ('none' or 'blend').
|
|
57
|
+
*/
|
|
58
|
+
set scaleMode(value: 'none' | 'blend');
|
|
59
|
+
/**
|
|
60
|
+
* Gets how the screen scales its contents.
|
|
61
|
+
* @returns The scale mode.
|
|
62
|
+
*/
|
|
63
|
+
get scaleMode(): "none" | "blend";
|
|
43
64
|
set screenSpace(value: boolean);
|
|
44
65
|
get screenSpace(): boolean;
|
|
45
66
|
static get observedAttributes(): string[];
|
|
@@ -31,22 +31,24 @@ declare class ScrollViewComponentElement extends ComponentElement {
|
|
|
31
31
|
*/
|
|
32
32
|
get component(): ScrollViewComponent;
|
|
33
33
|
/**
|
|
34
|
-
* Sets whether horizontal
|
|
34
|
+
* Sets whether scrolling along the horizontal axis is enabled. This is a toggle, unlike the
|
|
35
|
+
* `orientation` of a `<pc-scrollbar>`, for which `horizontal` is one of the accepted values.
|
|
35
36
|
* @param value - Whether horizontal scrolling is enabled.
|
|
36
37
|
*/
|
|
37
38
|
set horizontal(value: boolean);
|
|
38
39
|
/**
|
|
39
|
-
* Gets whether horizontal
|
|
40
|
+
* Gets whether scrolling along the horizontal axis is enabled.
|
|
40
41
|
* @returns Whether horizontal scrolling is enabled.
|
|
41
42
|
*/
|
|
42
43
|
get horizontal(): boolean;
|
|
43
44
|
/**
|
|
44
|
-
* Sets whether vertical
|
|
45
|
+
* Sets whether scrolling along the vertical axis is enabled. This is a toggle, unlike the
|
|
46
|
+
* `orientation` of a `<pc-scrollbar>`, for which `vertical` is one of the accepted values.
|
|
45
47
|
* @param value - Whether vertical scrolling is enabled.
|
|
46
48
|
*/
|
|
47
49
|
set vertical(value: boolean);
|
|
48
50
|
/**
|
|
49
|
-
* Gets whether vertical
|
|
51
|
+
* Gets whether scrolling along the vertical axis is enabled.
|
|
50
52
|
* @returns Whether vertical scrolling is enabled.
|
|
51
53
|
*/
|
|
52
54
|
get vertical(): boolean;
|