@playcanvas/web-components 0.11.1 → 0.12.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 +13 -11
- package/dist/asset.d.ts +144 -5
- package/dist/async-element.d.ts +6 -5
- package/dist/components/collision-component.d.ts +16 -0
- package/dist/components/component.d.ts +19 -0
- package/dist/custom-elements.json +1054 -164
- package/dist/entity-base.d.ts +67 -0
- package/dist/entity.d.ts +3 -38
- package/dist/index.d.ts +4 -1
- package/dist/material.d.ts +2 -1
- package/dist/model.d.ts +26 -4
- package/dist/node.d.ts +253 -0
- package/dist/pwc.cjs +1364 -168
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +1364 -168
- 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 +1364 -170
- package/dist/pwc.mjs.map +1 -1
- package/dist/vscode.html-custom-data.json +126 -4
- package/dist/web-types.json +360 -56
- package/package.json +2 -2
- package/src/app.ts +27 -24
- package/src/asset.ts +439 -9
- package/src/async-element.ts +7 -6
- 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/material.ts +2 -2
- package/src/model.ts +79 -11
- package/src/node.ts +715 -0
- package/src/sky.ts +0 -1
package/dist/app.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Entity } from 'playcanvas';
|
|
2
2
|
import { AppBase } from 'playcanvas';
|
|
3
3
|
import { AsyncElement } from './async-element';
|
|
4
|
-
import type {
|
|
4
|
+
import type { EntityBaseElement } from './entity-base';
|
|
5
5
|
/**
|
|
6
6
|
* The AppElement interface provides properties and methods for manipulating
|
|
7
7
|
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-app/ | `<pc-app>`} elements.
|
|
@@ -41,8 +41,9 @@ declare class AppElement extends AsyncElement {
|
|
|
41
41
|
private _bootGeneration;
|
|
42
42
|
/**
|
|
43
43
|
* The elements backing this application's entities, keyed by the entity itself. Registered
|
|
44
|
-
* by EntityElement at creation and removed when an entity is
|
|
45
|
-
* scene nodes back to their owning elements by
|
|
44
|
+
* by EntityElement at creation (and NodeElement at binding) and removed when an entity is
|
|
45
|
+
* destroyed or unbound, this joins engine scene nodes back to their owning elements by
|
|
46
|
+
* identity - never by name.
|
|
46
47
|
*/
|
|
47
48
|
private _entityElements;
|
|
48
49
|
private _picker;
|
|
@@ -79,19 +80,20 @@ declare class AppElement extends AsyncElement {
|
|
|
79
80
|
private _pickerCreate;
|
|
80
81
|
private _pickerDestroy;
|
|
81
82
|
/**
|
|
82
|
-
* Returns the `<pc-entity>` element whose backing entity is `entity`, or
|
|
83
|
-
* entity
|
|
84
|
-
* model's instantiated hierarchy, or an entity created through the
|
|
83
|
+
* Returns the `<pc-entity>` or `<pc-node>` element whose backing entity is `entity`, or
|
|
84
|
+
* `null` if the entity is not fronted by an element of this application - for example, an
|
|
85
|
+
* unbound node inside a model's instantiated hierarchy, or an entity created through the
|
|
86
|
+
* engine API.
|
|
85
87
|
*
|
|
86
88
|
* @param entity - The entity to look up.
|
|
87
|
-
* @returns The element
|
|
89
|
+
* @returns The element fronting the entity, or `null`.
|
|
88
90
|
*/
|
|
89
|
-
elementFromEntity(entity: Entity):
|
|
91
|
+
elementFromEntity(entity: Entity): EntityBaseElement | null;
|
|
90
92
|
/**
|
|
91
93
|
* Resolves the element that owns a picked node: the nearest node up the parent chain -
|
|
92
|
-
* starting with the node itself - that
|
|
93
|
-
* A hit inside a model's instantiated hierarchy therefore resolves to the
|
|
94
|
-
* the model.
|
|
94
|
+
* starting with the node itself - that is fronted by a `<pc-entity>` or `<pc-node>` of this
|
|
95
|
+
* application. A hit inside a model's instantiated hierarchy therefore resolves to the
|
|
96
|
+
* nearest bound `<pc-node>`, or failing that the element hosting the model.
|
|
95
97
|
*
|
|
96
98
|
* @param node - The picked node, or `null`.
|
|
97
99
|
* @returns The owning element, or `null`.
|
package/dist/asset.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Asset } from 'playcanvas';
|
|
2
2
|
import { AsyncElement } from './async-element';
|
|
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.
|
package/dist/async-element.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AppElement } from './app';
|
|
2
|
-
import type {
|
|
2
|
+
import type { EntityBaseElement } from './entity-base';
|
|
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`
|
|
@@ -7,6 +7,12 @@ import { ComponentElement } from './component';
|
|
|
7
7
|
* The CollisionComponentElement interface also inherits the properties and methods of the
|
|
8
8
|
* {@link HTMLElement} interface.
|
|
9
9
|
*
|
|
10
|
+
* For `type="mesh"`, the collision geometry defaults to the host entity's own render component
|
|
11
|
+
* (its render asset) — a collider matching the visible mesh, which is what a mesh collider on a
|
|
12
|
+
* glTF node means. The default resolves each time the component applies, so a `pc-node` that
|
|
13
|
+
* retargets or rebinds picks up the new node's geometry. An entity with no asset-backed render
|
|
14
|
+
* component warns, and the collider has no shape.
|
|
15
|
+
*
|
|
10
16
|
* @category Components
|
|
11
17
|
*/
|
|
12
18
|
declare class CollisionComponentElement extends ComponentElement {
|
|
@@ -30,6 +36,16 @@ declare class CollisionComponentElement extends ComponentElement {
|
|
|
30
36
|
radius: number;
|
|
31
37
|
type: "box" | "capsule" | "compound" | "cone" | "cylinder" | "mesh" | "sphere";
|
|
32
38
|
};
|
|
39
|
+
protected initComponent(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Defaults a mesh collider's geometry to the host entity's own render component. The
|
|
42
|
+
* engine's mesh collider only works with explicitly supplied geometry, and the element has
|
|
43
|
+
* no attribute to supply it - so the host's visible geometry, the meaning a mesh collider
|
|
44
|
+
* on a glTF node carries, fills the gap. Runs on every application (so a rebound `pc-node`
|
|
45
|
+
* recomputes it) and on a runtime switch to `type="mesh"`; an explicitly assigned
|
|
46
|
+
* `renderAsset` is never overwritten.
|
|
47
|
+
*/
|
|
48
|
+
private _applyMeshGeometryDefault;
|
|
33
49
|
/**
|
|
34
50
|
* Gets the underlying PlayCanvas collision component.
|
|
35
51
|
* @returns The collision component.
|
|
@@ -10,6 +10,16 @@ declare class ComponentElement extends AsyncElement {
|
|
|
10
10
|
private _enabled;
|
|
11
11
|
private _component;
|
|
12
12
|
private _appElement;
|
|
13
|
+
/**
|
|
14
|
+
* The element hosting this component, held so the host's readiness cycles can be observed
|
|
15
|
+
* even after `closestEntity` would no longer resolve (during teardown).
|
|
16
|
+
*/
|
|
17
|
+
private _hostElement;
|
|
18
|
+
/**
|
|
19
|
+
* The listener re-applying this component when the host's readiness cycles. Held for
|
|
20
|
+
* removal on disconnect.
|
|
21
|
+
*/
|
|
22
|
+
private _hostReadyListener;
|
|
13
23
|
/**
|
|
14
24
|
* Incremented on every connect and disconnect. connectedCallback captures the value on entry
|
|
15
25
|
* and abandons itself wherever it resumes from an await if the value has moved on — so a
|
|
@@ -32,6 +42,15 @@ declare class ComponentElement extends AsyncElement {
|
|
|
32
42
|
* @returns The initial component data.
|
|
33
43
|
*/
|
|
34
44
|
protected getInitialComponentData(): {};
|
|
45
|
+
/**
|
|
46
|
+
* Creates the component on the host's current entity, removing it first from a previous
|
|
47
|
+
* entity that is still alive (a retargeted `<pc-node>` moves its decorations with it). When
|
|
48
|
+
* the entity already has a component of this type — a glTF node arriving with its authored
|
|
49
|
+
* `render` component, say — warns and leaves `component` null. The element-level warning is
|
|
50
|
+
* load-bearing: the engine's own duplicate-addComponent warning is Debug-stripped from
|
|
51
|
+
* production builds, which would otherwise leave a silent null.
|
|
52
|
+
*/
|
|
53
|
+
private _applyComponent;
|
|
35
54
|
private _addComponent;
|
|
36
55
|
/**
|
|
37
56
|
* Configures the newly added component. Overridden by subclasses whose setup goes beyond
|