@playcanvas/web-components 0.16.0 → 0.18.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 +5 -3
- package/dist/app.d.cts +18 -13
- package/dist/app.d.ts +18 -13
- package/dist/asset.d.cts +13 -3
- package/dist/asset.d.ts +13 -3
- package/dist/async-element.d.cts +13 -13
- package/dist/async-element.d.ts +13 -13
- package/dist/components/anim-clip.d.cts +4 -0
- package/dist/components/anim-clip.d.ts +4 -0
- package/dist/components/anim-component.d.cts +38 -5
- package/dist/components/anim-component.d.ts +38 -5
- package/dist/components/audio-listener-component.d.cts +26 -0
- package/dist/components/audio-listener-component.d.ts +26 -0
- package/dist/components/button-component.d.cts +10 -1
- package/dist/components/button-component.d.ts +10 -1
- package/dist/components/camera-component.d.cts +37 -1
- package/dist/components/camera-component.d.ts +37 -1
- package/dist/components/collision-component.d.cts +9 -1
- package/dist/components/collision-component.d.ts +9 -1
- package/dist/components/component.d.cts +3 -2
- package/dist/components/component.d.ts +3 -2
- package/dist/components/element-component.d.cts +11 -0
- package/dist/components/element-component.d.ts +11 -0
- package/dist/components/gsplat-component.d.cts +6 -0
- package/dist/components/gsplat-component.d.ts +6 -0
- package/dist/components/joint-component.d.cts +14 -2
- package/dist/components/joint-component.d.ts +14 -2
- package/dist/components/{layoutchild-component.d.cts → layout-child-component.d.cts} +7 -1
- package/dist/components/{layoutchild-component.d.ts → layout-child-component.d.ts} +7 -1
- package/dist/components/{layoutgroup-component.d.cts → layout-group-component.d.cts} +7 -1
- package/dist/components/{layoutgroup-component.d.ts → layout-group-component.d.ts} +7 -1
- package/dist/components/light-component.d.cts +52 -1
- package/dist/components/light-component.d.ts +52 -1
- package/dist/components/{particlesystem-component.d.cts → particle-system-component.d.cts} +7 -1
- package/dist/components/{particlesystem-component.d.ts → particle-system-component.d.ts} +7 -1
- package/dist/components/render-component.d.cts +7 -0
- package/dist/components/render-component.d.ts +7 -0
- package/dist/components/{rigidbody-component.d.cts → rigid-body-component.d.cts} +8 -1
- package/dist/components/{rigidbody-component.d.ts → rigid-body-component.d.ts} +8 -1
- package/dist/components/screen-component.d.cts +6 -0
- package/dist/components/screen-component.d.ts +6 -0
- package/dist/components/script-component.d.cts +26 -12
- package/dist/components/script-component.d.ts +26 -12
- package/dist/components/{script.d.cts → script-instance.d.cts} +11 -7
- package/dist/components/{script.d.ts → script-instance.d.ts} +11 -7
- package/dist/components/{scrollview-component.d.cts → scroll-view-component.d.cts} +7 -1
- package/dist/components/{scrollview-component.d.ts → scroll-view-component.d.ts} +7 -1
- package/dist/components/scrollbar-component.d.cts +6 -0
- package/dist/components/scrollbar-component.d.ts +6 -0
- package/dist/components/sound-component.d.cts +7 -1
- package/dist/components/sound-component.d.ts +7 -1
- package/dist/components/sound-slot.d.cts +5 -2
- package/dist/components/sound-slot.d.ts +5 -2
- package/dist/custom-elements.json +1852 -974
- package/dist/entity-base.d.cts +7 -6
- package/dist/entity-base.d.ts +7 -6
- package/dist/entity-owner.d.cts +118 -0
- package/dist/entity-owner.d.ts +118 -0
- package/dist/entity.d.cts +14 -102
- package/dist/entity.d.ts +14 -102
- package/dist/index.d.cts +26 -22
- package/dist/index.d.ts +26 -22
- package/dist/material.d.cts +18 -7
- package/dist/material.d.ts +18 -7
- package/dist/model.d.cts +72 -24
- package/dist/model.d.ts +72 -24
- package/dist/node.d.cts +6 -1
- package/dist/node.d.ts +6 -1
- package/dist/pwc.cjs +807 -293
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +807 -293
- 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 +805 -292
- package/dist/pwc.mjs.map +1 -1
- package/dist/scene.d.cts +3 -0
- package/dist/scene.d.ts +3 -0
- package/dist/sky.d.cts +4 -0
- package/dist/sky.d.ts +4 -0
- package/dist/vscode.html-custom-data.json +351 -121
- package/dist/{module.d.cts → wasm.d.cts} +10 -6
- package/dist/{module.d.ts → wasm.d.ts} +10 -6
- package/dist/web-types.json +465 -291
- package/package.json +7 -7
- package/src/app.ts +49 -35
- package/src/asset.ts +13 -4
- package/src/async-element.ts +14 -14
- package/src/components/anim-clip.ts +4 -0
- package/src/components/anim-component.ts +89 -14
- package/src/components/audio-listener-component.ts +36 -0
- package/src/components/button-component.ts +10 -1
- package/src/components/camera-component.ts +65 -6
- package/src/components/collision-component.ts +9 -1
- package/src/components/component.ts +4 -3
- package/src/components/element-component.ts +11 -0
- package/src/components/gsplat-component.ts +6 -0
- package/src/components/joint-component.ts +14 -2
- package/src/components/{layoutchild-component.ts → layout-child-component.ts} +8 -2
- package/src/components/{layoutgroup-component.ts → layout-group-component.ts} +8 -2
- package/src/components/light-component.ts +110 -17
- package/src/components/{particlesystem-component.ts → particle-system-component.ts} +8 -2
- package/src/components/render-component.ts +7 -0
- package/src/components/{rigidbody-component.ts → rigid-body-component.ts} +9 -2
- package/src/components/screen-component.ts +6 -0
- package/src/components/script-component.ts +66 -42
- package/src/components/{script.ts → script-instance.ts} +18 -14
- package/src/components/{scrollview-component.ts → scroll-view-component.ts} +8 -2
- package/src/components/scrollbar-component.ts +6 -0
- package/src/components/sound-component.ts +8 -2
- package/src/components/sound-slot.ts +7 -4
- package/src/entity-base.ts +8 -7
- package/src/entity-owner.ts +298 -0
- package/src/entity.ts +21 -271
- package/src/index.ts +38 -25
- package/src/material.ts +19 -8
- package/src/model.ts +164 -72
- package/src/node.ts +15 -6
- package/src/scene.ts +3 -0
- package/src/sky.ts +4 -0
- package/src/{module.ts → wasm.ts} +12 -8
- package/dist/components/listener-component.d.cts +0 -20
- package/dist/components/listener-component.d.ts +0 -20
- package/src/components/listener-component.ts +0 -30
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://www.reddit.com/r/PlayCanvas)
|
|
8
8
|
[](https://x.com/intent/follow?screen_name=playcanvas)
|
|
9
9
|
|
|
10
|
-
| [User Manual](https://developer.playcanvas.com
|
|
10
|
+
| [User Manual](https://developer.playcanvas.com/user-manual/web-components) | [API Reference](https://api.playcanvas.com/web-components) | [Examples](https://playcanvas.github.io/web-components/examples) | [Blog](https://blog.playcanvas.com) | [Forum](https://forum.playcanvas.com) |
|
|
11
11
|
|
|
12
12
|
PlayCanvas Web Components are a set of custom HTML elements for building 3D interactive web apps. Using the declarative nature of HTML makes it both easy and fun to incorporate 3D into your website. Check out this simple example:
|
|
13
13
|
|
|
@@ -30,9 +30,11 @@ PlayCanvas Web Components are a set of custom HTML elements for building 3D inte
|
|
|
30
30
|
|
|
31
31
|
## Examples
|
|
32
32
|
|
|
33
|
-
<
|
|
33
|
+
<a href="https://playcanvas.github.io/web-components/examples">
|
|
34
|
+
<img width="5120" height="2160" alt="PlayCanvas Web Components examples gallery showing interactive 3D demos" src="https://github.com/user-attachments/assets/92cf1156-c93f-46b5-8d05-e576967ceaf3" />
|
|
35
|
+
</a>
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
Explore the [PlayCanvas Web Components examples gallery](https://playcanvas.github.io/web-components/examples).
|
|
36
38
|
|
|
37
39
|
## Usage
|
|
38
40
|
|
package/dist/app.d.cts
CHANGED
|
@@ -14,6 +14,10 @@ import type { EntityBaseElement } from './entity-base.cjs';
|
|
|
14
14
|
* tracked live via a ResizeObserver — so the element can be embedded at any size, resized by
|
|
15
15
|
* its container, or made fullscreen with ordinary CSS such as `width: 100vw; height: 100dvh`.
|
|
16
16
|
*
|
|
17
|
+
* @elementSummary The `<pc-app>` element creates a PlayCanvas application and the canvas it renders
|
|
18
|
+
* into, and is the root of every scene. It holds the `<pc-asset>`, `<pc-material>`, `<pc-wasm>` and
|
|
19
|
+
* `<pc-scene>` elements, and the page's CSS sizes it, as it would a `<video>`.
|
|
20
|
+
*
|
|
17
21
|
* @fires {ProgressEvent} progress - Fired while the application preloads its assets. `loaded` and
|
|
18
22
|
* `total` are asset counts, not bytes, and an asset that fails to load still counts as loaded.
|
|
19
23
|
* Fired at least once per boot, and the final event always has `loaded` equal to `total`. Does
|
|
@@ -53,9 +57,9 @@ declare class AppElement extends AsyncElement {
|
|
|
53
57
|
private _bootGeneration;
|
|
54
58
|
/**
|
|
55
59
|
* The elements backing this application's entities, keyed by the entity itself. Registered
|
|
56
|
-
* by
|
|
57
|
-
*
|
|
58
|
-
* identity - never by name.
|
|
60
|
+
* by entity-owning elements at creation (pc-entity, and pc-model for its host) and by
|
|
61
|
+
* NodeElement at binding, and removed when an entity is destroyed or unbound, this joins
|
|
62
|
+
* engine scene nodes back to their owning elements by identity - never by name.
|
|
59
63
|
*/
|
|
60
64
|
private _entityElements;
|
|
61
65
|
private _picker;
|
|
@@ -103,25 +107,26 @@ declare class AppElement extends AsyncElement {
|
|
|
103
107
|
private _pickerCreate;
|
|
104
108
|
private _pickerDestroy;
|
|
105
109
|
/**
|
|
106
|
-
* Returns the `<pc-entity>` or `<pc-node>` element whose backing entity is
|
|
107
|
-
* `null` if the entity is not fronted by an element of this application - for
|
|
108
|
-
* unbound node inside a model's instantiated hierarchy, or an entity created
|
|
109
|
-
* engine API.
|
|
110
|
+
* Returns the `<pc-entity>`, `<pc-model>` or `<pc-node>` element whose backing entity is
|
|
111
|
+
* `entity`, or `null` if the entity is not fronted by an element of this application - for
|
|
112
|
+
* example, an unbound node inside a model's instantiated hierarchy, or an entity created
|
|
113
|
+
* through the engine API.
|
|
110
114
|
*
|
|
111
115
|
* @param entity - The entity to look up.
|
|
112
116
|
* @returns The element fronting the entity, or `null`.
|
|
113
117
|
*/
|
|
114
118
|
elementFromEntity(entity: Entity): EntityBaseElement | null;
|
|
115
119
|
/**
|
|
116
|
-
* Resolves the element that owns a picked node: the nearest node up the parent
|
|
117
|
-
* starting with the node itself -
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
+
* Resolves the element that owns hover for a picked node: the nearest node up the parent
|
|
121
|
+
* chain - starting with the node itself - whose element listens for any of the hover event
|
|
122
|
+
* types. Skipping silent elements matches {@link _elementWithListener}, so a registered
|
|
123
|
+
* element with no hover listeners (a `<pc-model>` host, a plain child entity) is transparent
|
|
124
|
+
* to hover rather than swallowing a listening ancestor's enter/leave pair.
|
|
120
125
|
*
|
|
121
126
|
* @param node - The picked node, or `null`.
|
|
122
|
-
* @returns The owning element, or `null`.
|
|
127
|
+
* @returns The hover-owning element, or `null`.
|
|
123
128
|
*/
|
|
124
|
-
private
|
|
129
|
+
private _hoverTarget;
|
|
125
130
|
/**
|
|
126
131
|
* Like {@link _elementFromNode}, but skips elements without a listener for `type`, so a hit
|
|
127
132
|
* on an unlistened child still reaches a listening ancestor.
|
package/dist/app.d.ts
CHANGED
|
@@ -14,6 +14,10 @@ import type { EntityBaseElement } from './entity-base.js';
|
|
|
14
14
|
* tracked live via a ResizeObserver — so the element can be embedded at any size, resized by
|
|
15
15
|
* its container, or made fullscreen with ordinary CSS such as `width: 100vw; height: 100dvh`.
|
|
16
16
|
*
|
|
17
|
+
* @elementSummary The `<pc-app>` element creates a PlayCanvas application and the canvas it renders
|
|
18
|
+
* into, and is the root of every scene. It holds the `<pc-asset>`, `<pc-material>`, `<pc-wasm>` and
|
|
19
|
+
* `<pc-scene>` elements, and the page's CSS sizes it, as it would a `<video>`.
|
|
20
|
+
*
|
|
17
21
|
* @fires {ProgressEvent} progress - Fired while the application preloads its assets. `loaded` and
|
|
18
22
|
* `total` are asset counts, not bytes, and an asset that fails to load still counts as loaded.
|
|
19
23
|
* Fired at least once per boot, and the final event always has `loaded` equal to `total`. Does
|
|
@@ -53,9 +57,9 @@ declare class AppElement extends AsyncElement {
|
|
|
53
57
|
private _bootGeneration;
|
|
54
58
|
/**
|
|
55
59
|
* The elements backing this application's entities, keyed by the entity itself. Registered
|
|
56
|
-
* by
|
|
57
|
-
*
|
|
58
|
-
* identity - never by name.
|
|
60
|
+
* by entity-owning elements at creation (pc-entity, and pc-model for its host) and by
|
|
61
|
+
* NodeElement at binding, and removed when an entity is destroyed or unbound, this joins
|
|
62
|
+
* engine scene nodes back to their owning elements by identity - never by name.
|
|
59
63
|
*/
|
|
60
64
|
private _entityElements;
|
|
61
65
|
private _picker;
|
|
@@ -103,25 +107,26 @@ declare class AppElement extends AsyncElement {
|
|
|
103
107
|
private _pickerCreate;
|
|
104
108
|
private _pickerDestroy;
|
|
105
109
|
/**
|
|
106
|
-
* Returns the `<pc-entity>` or `<pc-node>` element whose backing entity is
|
|
107
|
-
* `null` if the entity is not fronted by an element of this application - for
|
|
108
|
-
* unbound node inside a model's instantiated hierarchy, or an entity created
|
|
109
|
-
* engine API.
|
|
110
|
+
* Returns the `<pc-entity>`, `<pc-model>` or `<pc-node>` element whose backing entity is
|
|
111
|
+
* `entity`, or `null` if the entity is not fronted by an element of this application - for
|
|
112
|
+
* example, an unbound node inside a model's instantiated hierarchy, or an entity created
|
|
113
|
+
* through the engine API.
|
|
110
114
|
*
|
|
111
115
|
* @param entity - The entity to look up.
|
|
112
116
|
* @returns The element fronting the entity, or `null`.
|
|
113
117
|
*/
|
|
114
118
|
elementFromEntity(entity: Entity): EntityBaseElement | null;
|
|
115
119
|
/**
|
|
116
|
-
* Resolves the element that owns a picked node: the nearest node up the parent
|
|
117
|
-
* starting with the node itself -
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
+
* Resolves the element that owns hover for a picked node: the nearest node up the parent
|
|
121
|
+
* chain - starting with the node itself - whose element listens for any of the hover event
|
|
122
|
+
* types. Skipping silent elements matches {@link _elementWithListener}, so a registered
|
|
123
|
+
* element with no hover listeners (a `<pc-model>` host, a plain child entity) is transparent
|
|
124
|
+
* to hover rather than swallowing a listening ancestor's enter/leave pair.
|
|
120
125
|
*
|
|
121
126
|
* @param node - The picked node, or `null`.
|
|
122
|
-
* @returns The owning element, or `null`.
|
|
127
|
+
* @returns The hover-owning element, or `null`.
|
|
123
128
|
*/
|
|
124
|
-
private
|
|
129
|
+
private _hoverTarget;
|
|
125
130
|
/**
|
|
126
131
|
* Like {@link _elementFromNode}, but skips elements without a listener for `type`, so a hit
|
|
127
132
|
* on an unlistened child still reaches a listening ancestor.
|
package/dist/asset.d.cts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { Asset } from 'playcanvas';
|
|
2
2
|
import { AsyncElement } from './async-element.cjs';
|
|
3
|
-
|
|
4
|
-
type
|
|
5
|
-
|
|
3
|
+
/** The addressing modes for a texture asset. */
|
|
4
|
+
export type AddressMode = 'repeat' | 'clamp' | 'mirror';
|
|
5
|
+
/** The minification filter modes for a texture asset. */
|
|
6
|
+
export type MinFilterMode = 'nearest' | 'linear' | 'nearest-mip-nearest' | 'linear-mip-nearest' | 'nearest-mip-linear' | 'linear-mip-linear';
|
|
7
|
+
/**
|
|
8
|
+
* The magnification filter modes for a texture asset. Magnification has no mip variants - the
|
|
9
|
+
* engine (and the GPU) only accepts these two.
|
|
10
|
+
*/
|
|
11
|
+
export type MagFilterMode = 'nearest' | 'linear';
|
|
6
12
|
/**
|
|
7
13
|
* The AssetElement interface provides properties and methods for manipulating
|
|
8
14
|
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-asset/ | `<pc-asset>`} elements.
|
|
@@ -31,6 +37,10 @@ type MagFilterMode = 'nearest' | 'linear';
|
|
|
31
37
|
* Apart from `lazy` and the texture options, these attributes are read once when the asset is
|
|
32
38
|
* created, so changing them later has no effect.
|
|
33
39
|
*
|
|
40
|
+
* @elementSummary The `<pc-asset>` element declares an asset for the application to load — a model,
|
|
41
|
+
* texture, font, sound, script or JSON file — under an `id` that other elements reference. Must be
|
|
42
|
+
* a direct child of `<pc-app>`.
|
|
43
|
+
*
|
|
34
44
|
* @attribute {string} id - The identifier used to reference the asset from other elements.
|
|
35
45
|
* @attribute {string} src - The URL of the asset to load.
|
|
36
46
|
* @attribute {string} type - The asset type. Inferred from the `src` file extension when omitted.
|
package/dist/asset.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { Asset } from 'playcanvas';
|
|
2
2
|
import { AsyncElement } from './async-element.js';
|
|
3
|
-
|
|
4
|
-
type
|
|
5
|
-
|
|
3
|
+
/** The addressing modes for a texture asset. */
|
|
4
|
+
export type AddressMode = 'repeat' | 'clamp' | 'mirror';
|
|
5
|
+
/** The minification filter modes for a texture asset. */
|
|
6
|
+
export type MinFilterMode = 'nearest' | 'linear' | 'nearest-mip-nearest' | 'linear-mip-nearest' | 'nearest-mip-linear' | 'linear-mip-linear';
|
|
7
|
+
/**
|
|
8
|
+
* The magnification filter modes for a texture asset. Magnification has no mip variants - the
|
|
9
|
+
* engine (and the GPU) only accepts these two.
|
|
10
|
+
*/
|
|
11
|
+
export type MagFilterMode = 'nearest' | 'linear';
|
|
6
12
|
/**
|
|
7
13
|
* The AssetElement interface provides properties and methods for manipulating
|
|
8
14
|
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-asset/ | `<pc-asset>`} elements.
|
|
@@ -31,6 +37,10 @@ type MagFilterMode = 'nearest' | 'linear';
|
|
|
31
37
|
* Apart from `lazy` and the texture options, these attributes are read once when the asset is
|
|
32
38
|
* created, so changing them later has no effect.
|
|
33
39
|
*
|
|
40
|
+
* @elementSummary The `<pc-asset>` element declares an asset for the application to load — a model,
|
|
41
|
+
* texture, font, sound, script or JSON file — under an `id` that other elements reference. Must be
|
|
42
|
+
* a direct child of `<pc-app>`.
|
|
43
|
+
*
|
|
34
44
|
* @attribute {string} id - The identifier used to reference the asset from other elements.
|
|
35
45
|
* @attribute {string} src - The URL of the asset to load.
|
|
36
46
|
* @attribute {string} type - The asset type. Inferred from the `src` file extension when omitted.
|
package/dist/async-element.d.cts
CHANGED
|
@@ -20,9 +20,9 @@ declare class AsyncElement extends HTMLElement {
|
|
|
20
20
|
*/
|
|
21
21
|
get closestApp(): AppElement | null;
|
|
22
22
|
/**
|
|
23
|
-
* The nearest ancestor element that fronts an entity — `<pc-entity
|
|
24
|
-
* `null` if this element has no such ancestor. The search starts at the
|
|
25
|
-
* never resolves to itself.
|
|
23
|
+
* The nearest ancestor element that fronts an entity — `<pc-entity>`, `<pc-model>` or
|
|
24
|
+
* `<pc-node>` — or `null` if this element has no such ancestor. The search starts at the
|
|
25
|
+
* parent, so an element never resolves to itself.
|
|
26
26
|
* @returns The closest entity-fronting element, or `null`.
|
|
27
27
|
*/
|
|
28
28
|
get closestEntity(): EntityBaseElement | null;
|
|
@@ -62,11 +62,11 @@ type AsyncElementTagName = {
|
|
|
62
62
|
}[keyof HTMLElementTagNameMap];
|
|
63
63
|
/**
|
|
64
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-
|
|
67
|
-
* device — listen for its `error` event instead). A component element outside
|
|
68
|
-
* the exception: it still becomes ready, but its `component` is `null`. Either way, a
|
|
69
|
-
* element logs a warning naming the parent it requires.
|
|
65
|
+
* promise never settles if the element cannot finish initializing (for example, a `<pc-script-instance>`
|
|
66
|
+
* that is not a direct child of `<pc-script>`, or a `<pc-app>` that could not create a graphics
|
|
67
|
+
* device — listen for its `error` event instead). A component element outside an entity-fronting
|
|
68
|
+
* element is the exception: it still becomes ready, but its `component` is `null`. Either way, a
|
|
69
|
+
* misplaced element logs a warning naming the parent it requires.
|
|
70
70
|
* @param target - The tag name of the element to wait for (e.g. `'pc-app'`).
|
|
71
71
|
* @returns A promise that resolves with the element once it's ready.
|
|
72
72
|
* @example
|
|
@@ -87,11 +87,11 @@ declare function whenReady<K extends AsyncElementTagName>(target: K): Promise<HT
|
|
|
87
87
|
declare function whenReady<T extends AsyncElement>(target: T): Promise<T>;
|
|
88
88
|
/**
|
|
89
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-
|
|
92
|
-
* device — listen for its `error` event instead). A component element outside
|
|
93
|
-
* the exception: it still becomes ready, but its `component` is `null`. Either way, a
|
|
94
|
-
* element logs a warning naming the parent it requires.
|
|
90
|
+
* the promise never settles if the element cannot finish initializing (for example, a `<pc-script-instance>`
|
|
91
|
+
* that is not a direct child of `<pc-script>`, or a `<pc-app>` that could not create a graphics
|
|
92
|
+
* device — listen for its `error` event instead). A component element outside an entity-fronting
|
|
93
|
+
* element is the exception: it still becomes ready, but its `component` is `null`. Either way, a
|
|
94
|
+
* misplaced element logs a warning naming the parent it requires.
|
|
95
95
|
* @param target - A CSS selector matching the element to wait for (e.g. `'#my-app'`).
|
|
96
96
|
* @returns A promise that resolves with the element once it's ready.
|
|
97
97
|
* @example
|
package/dist/async-element.d.ts
CHANGED
|
@@ -20,9 +20,9 @@ declare class AsyncElement extends HTMLElement {
|
|
|
20
20
|
*/
|
|
21
21
|
get closestApp(): AppElement | null;
|
|
22
22
|
/**
|
|
23
|
-
* The nearest ancestor element that fronts an entity — `<pc-entity
|
|
24
|
-
* `null` if this element has no such ancestor. The search starts at the
|
|
25
|
-
* never resolves to itself.
|
|
23
|
+
* The nearest ancestor element that fronts an entity — `<pc-entity>`, `<pc-model>` or
|
|
24
|
+
* `<pc-node>` — or `null` if this element has no such ancestor. The search starts at the
|
|
25
|
+
* parent, so an element never resolves to itself.
|
|
26
26
|
* @returns The closest entity-fronting element, or `null`.
|
|
27
27
|
*/
|
|
28
28
|
get closestEntity(): EntityBaseElement | null;
|
|
@@ -62,11 +62,11 @@ type AsyncElementTagName = {
|
|
|
62
62
|
}[keyof HTMLElementTagNameMap];
|
|
63
63
|
/**
|
|
64
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-
|
|
67
|
-
* device — listen for its `error` event instead). A component element outside
|
|
68
|
-
* the exception: it still becomes ready, but its `component` is `null`. Either way, a
|
|
69
|
-
* element logs a warning naming the parent it requires.
|
|
65
|
+
* promise never settles if the element cannot finish initializing (for example, a `<pc-script-instance>`
|
|
66
|
+
* that is not a direct child of `<pc-script>`, or a `<pc-app>` that could not create a graphics
|
|
67
|
+
* device — listen for its `error` event instead). A component element outside an entity-fronting
|
|
68
|
+
* element is the exception: it still becomes ready, but its `component` is `null`. Either way, a
|
|
69
|
+
* misplaced element logs a warning naming the parent it requires.
|
|
70
70
|
* @param target - The tag name of the element to wait for (e.g. `'pc-app'`).
|
|
71
71
|
* @returns A promise that resolves with the element once it's ready.
|
|
72
72
|
* @example
|
|
@@ -87,11 +87,11 @@ declare function whenReady<K extends AsyncElementTagName>(target: K): Promise<HT
|
|
|
87
87
|
declare function whenReady<T extends AsyncElement>(target: T): Promise<T>;
|
|
88
88
|
/**
|
|
89
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-
|
|
92
|
-
* device — listen for its `error` event instead). A component element outside
|
|
93
|
-
* the exception: it still becomes ready, but its `component` is `null`. Either way, a
|
|
94
|
-
* element logs a warning naming the parent it requires.
|
|
90
|
+
* the promise never settles if the element cannot finish initializing (for example, a `<pc-script-instance>`
|
|
91
|
+
* that is not a direct child of `<pc-script>`, or a `<pc-app>` that could not create a graphics
|
|
92
|
+
* device — listen for its `error` event instead). A component element outside an entity-fronting
|
|
93
|
+
* element is the exception: it still becomes ready, but its `component` is `null`. Either way, a
|
|
94
|
+
* misplaced element logs a warning naming the parent it requires.
|
|
95
95
|
* @param target - A CSS selector matching the element to wait for (e.g. `'#my-app'`).
|
|
96
96
|
* @returns A promise that resolves with the element once it's ready.
|
|
97
97
|
* @example
|
|
@@ -13,6 +13,10 @@ import { AnimComponentElement } from './anim-component.cjs';
|
|
|
13
13
|
* named; in a multi-track source the track named `name` is chosen, falling back to the first
|
|
14
14
|
* with a warning. The element becomes ready once its resolved track is assigned.
|
|
15
15
|
*
|
|
16
|
+
* @elementSummary The `<pc-anim-clip>` element declares one named animation clip on its parent
|
|
17
|
+
* `<pc-anim>`, taken from the `asset` it names or, without one, from the enclosing `<pc-model>`'s
|
|
18
|
+
* own animations. Must be a direct child of `<pc-anim>`.
|
|
19
|
+
*
|
|
16
20
|
* @category Components
|
|
17
21
|
*/
|
|
18
22
|
declare class AnimClipElement extends AsyncElement {
|
|
@@ -13,6 +13,10 @@ import { AnimComponentElement } from './anim-component.js';
|
|
|
13
13
|
* named; in a multi-track source the track named `name` is chosen, falling back to the first
|
|
14
14
|
* with a warning. The element becomes ready once its resolved track is assigned.
|
|
15
15
|
*
|
|
16
|
+
* @elementSummary The `<pc-anim-clip>` element declares one named animation clip on its parent
|
|
17
|
+
* `<pc-anim>`, taken from the `asset` it names or, without one, from the enclosing `<pc-model>`'s
|
|
18
|
+
* own animations. Must be a direct child of `<pc-anim>`.
|
|
19
|
+
*
|
|
16
20
|
* @category Components
|
|
17
21
|
*/
|
|
18
22
|
declare class AnimClipElement extends AsyncElement {
|
|
@@ -25,6 +25,13 @@ type ContainerWithAnimations = ContainerResource & {
|
|
|
25
25
|
* the underlying {@link AnimComponent} (via {@link component}) for playback state beyond what
|
|
26
26
|
* this element exposes.
|
|
27
27
|
*
|
|
28
|
+
* Engine component: {@link AnimComponent} (`anim`).
|
|
29
|
+
*
|
|
30
|
+
* @elementSummary The `<pc-anim>` element plays animation clips over its entity's hierarchy, taken
|
|
31
|
+
* from `<pc-anim-clip>` children or from the enclosing `<pc-model>`'s own animations. The first
|
|
32
|
+
* clip plays automatically, and the `clip` attribute switches between them. Must be a child of a
|
|
33
|
+
* `<pc-entity>`, `<pc-model>` or `<pc-node>`.
|
|
34
|
+
*
|
|
28
35
|
* @category Components
|
|
29
36
|
*/
|
|
30
37
|
declare class AnimComponentElement extends ComponentElement {
|
|
@@ -46,6 +53,11 @@ declare class AnimComponentElement extends ComponentElement {
|
|
|
46
53
|
* The name of the active clip.
|
|
47
54
|
*/
|
|
48
55
|
private _clip;
|
|
56
|
+
/**
|
|
57
|
+
* The binding root this element last assigned through {@link _applyRootBone}, distinguishing
|
|
58
|
+
* its own writes from a `rootBone` assigned through the engine API — which is left alone.
|
|
59
|
+
*/
|
|
60
|
+
private _managedRootBone;
|
|
49
61
|
/**
|
|
50
62
|
* The element the model-readiness listener is attached to, held so disconnection can detach
|
|
51
63
|
* it after `closestEntity` no longer resolves.
|
|
@@ -71,14 +83,35 @@ declare class AnimComponentElement extends ComponentElement {
|
|
|
71
83
|
*/
|
|
72
84
|
private _warnedClip;
|
|
73
85
|
/**
|
|
74
|
-
* Rebinds when a model
|
|
75
|
-
*
|
|
86
|
+
* Rebinds when a model that is not this component's host announces readiness — a sibling or
|
|
87
|
+
* deeper model whose content changed under the assigned clips. The engine resolves each
|
|
88
|
+
* curve once, at the first tick after assignment, and never retries — and its mesh-instance
|
|
76
89
|
* broadcast fires before an instantiated hierarchy is parented, so a model that loads after
|
|
77
|
-
* the clips were assigned would otherwise stay silently unbound.
|
|
78
|
-
*
|
|
79
|
-
*
|
|
90
|
+
* the clips were assigned would otherwise stay silently unbound. The host model's own cycles
|
|
91
|
+
* are excluded: those re-enter through {@link initComponent}, which refreshes the whole clip
|
|
92
|
+
* set against the new container.
|
|
80
93
|
*/
|
|
81
94
|
private _onModelReady;
|
|
95
|
+
/**
|
|
96
|
+
* The model whose host entity scopes this component's curve binding: the parent `pc-model`,
|
|
97
|
+
* or the sole `pc-model` among the parent's direct children (the arrangement where clips
|
|
98
|
+
* live in a library asset beside the skeleton). `null` when there is no such model, or more
|
|
99
|
+
* than one — an ambiguous skeleton is left to the engine's name-based resolution.
|
|
100
|
+
*/
|
|
101
|
+
private _skeletonSource;
|
|
102
|
+
/**
|
|
103
|
+
* Keeps the component's binding root pointing at the skeleton source's host entity. The host
|
|
104
|
+
* wraps the instantiated content, so left at its default — the component's own entity — the
|
|
105
|
+
* engine binder mis-resolves curves that target the asset's root node: its fallback treats
|
|
106
|
+
* the graph as the asset root once the root is no longer a direct child.
|
|
107
|
+
*
|
|
108
|
+
* Authoritative in both directions for values this element assigned: a source appearing pins
|
|
109
|
+
* its host, and a source dissolving (the model gone, or a second model making the skeleton
|
|
110
|
+
* ambiguous) clears the pin rather than leaving it on a stale host. A root assigned through
|
|
111
|
+
* the engine API is never overwritten — the user's choice outranks the managed default.
|
|
112
|
+
* Writes are skipped while unchanged, because the engine setter itself triggers a rebind.
|
|
113
|
+
*/
|
|
114
|
+
private _applyRootBone;
|
|
82
115
|
/** @ignore */
|
|
83
116
|
constructor();
|
|
84
117
|
protected getInitialComponentData(): {
|
|
@@ -25,6 +25,13 @@ type ContainerWithAnimations = ContainerResource & {
|
|
|
25
25
|
* the underlying {@link AnimComponent} (via {@link component}) for playback state beyond what
|
|
26
26
|
* this element exposes.
|
|
27
27
|
*
|
|
28
|
+
* Engine component: {@link AnimComponent} (`anim`).
|
|
29
|
+
*
|
|
30
|
+
* @elementSummary The `<pc-anim>` element plays animation clips over its entity's hierarchy, taken
|
|
31
|
+
* from `<pc-anim-clip>` children or from the enclosing `<pc-model>`'s own animations. The first
|
|
32
|
+
* clip plays automatically, and the `clip` attribute switches between them. Must be a child of a
|
|
33
|
+
* `<pc-entity>`, `<pc-model>` or `<pc-node>`.
|
|
34
|
+
*
|
|
28
35
|
* @category Components
|
|
29
36
|
*/
|
|
30
37
|
declare class AnimComponentElement extends ComponentElement {
|
|
@@ -46,6 +53,11 @@ declare class AnimComponentElement extends ComponentElement {
|
|
|
46
53
|
* The name of the active clip.
|
|
47
54
|
*/
|
|
48
55
|
private _clip;
|
|
56
|
+
/**
|
|
57
|
+
* The binding root this element last assigned through {@link _applyRootBone}, distinguishing
|
|
58
|
+
* its own writes from a `rootBone` assigned through the engine API — which is left alone.
|
|
59
|
+
*/
|
|
60
|
+
private _managedRootBone;
|
|
49
61
|
/**
|
|
50
62
|
* The element the model-readiness listener is attached to, held so disconnection can detach
|
|
51
63
|
* it after `closestEntity` no longer resolves.
|
|
@@ -71,14 +83,35 @@ declare class AnimComponentElement extends ComponentElement {
|
|
|
71
83
|
*/
|
|
72
84
|
private _warnedClip;
|
|
73
85
|
/**
|
|
74
|
-
* Rebinds when a model
|
|
75
|
-
*
|
|
86
|
+
* Rebinds when a model that is not this component's host announces readiness — a sibling or
|
|
87
|
+
* deeper model whose content changed under the assigned clips. The engine resolves each
|
|
88
|
+
* curve once, at the first tick after assignment, and never retries — and its mesh-instance
|
|
76
89
|
* broadcast fires before an instantiated hierarchy is parented, so a model that loads after
|
|
77
|
-
* the clips were assigned would otherwise stay silently unbound.
|
|
78
|
-
*
|
|
79
|
-
*
|
|
90
|
+
* the clips were assigned would otherwise stay silently unbound. The host model's own cycles
|
|
91
|
+
* are excluded: those re-enter through {@link initComponent}, which refreshes the whole clip
|
|
92
|
+
* set against the new container.
|
|
80
93
|
*/
|
|
81
94
|
private _onModelReady;
|
|
95
|
+
/**
|
|
96
|
+
* The model whose host entity scopes this component's curve binding: the parent `pc-model`,
|
|
97
|
+
* or the sole `pc-model` among the parent's direct children (the arrangement where clips
|
|
98
|
+
* live in a library asset beside the skeleton). `null` when there is no such model, or more
|
|
99
|
+
* than one — an ambiguous skeleton is left to the engine's name-based resolution.
|
|
100
|
+
*/
|
|
101
|
+
private _skeletonSource;
|
|
102
|
+
/**
|
|
103
|
+
* Keeps the component's binding root pointing at the skeleton source's host entity. The host
|
|
104
|
+
* wraps the instantiated content, so left at its default — the component's own entity — the
|
|
105
|
+
* engine binder mis-resolves curves that target the asset's root node: its fallback treats
|
|
106
|
+
* the graph as the asset root once the root is no longer a direct child.
|
|
107
|
+
*
|
|
108
|
+
* Authoritative in both directions for values this element assigned: a source appearing pins
|
|
109
|
+
* its host, and a source dissolving (the model gone, or a second model making the skeleton
|
|
110
|
+
* ambiguous) clears the pin rather than leaving it on a stale host. A root assigned through
|
|
111
|
+
* the engine API is never overwritten — the user's choice outranks the managed default.
|
|
112
|
+
* Writes are skipped while unchanged, because the engine setter itself triggers a rebind.
|
|
113
|
+
*/
|
|
114
|
+
private _applyRootBone;
|
|
82
115
|
/** @ignore */
|
|
83
116
|
constructor();
|
|
84
117
|
protected getInitialComponentData(): {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AudioListenerComponent } from 'playcanvas';
|
|
2
|
+
import { ComponentElement } from './component.cjs';
|
|
3
|
+
/**
|
|
4
|
+
* The AudioListenerComponentElement interface provides properties and methods for manipulating
|
|
5
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-audio-listener/ | `<pc-audio-listener>`} elements.
|
|
6
|
+
* The AudioListenerComponentElement interface also inherits the properties and methods of the
|
|
7
|
+
* {@link HTMLElement} interface.
|
|
8
|
+
*
|
|
9
|
+
* Engine component: {@link AudioListenerComponent} (`audiolistener`).
|
|
10
|
+
*
|
|
11
|
+
* @elementSummary The `<pc-audio-listener>` element makes its entity the point from which
|
|
12
|
+
* positional sounds are heard, typically the entity holding the `<pc-camera>`. Must be a child of a
|
|
13
|
+
* `<pc-entity>`, `<pc-model>` or `<pc-node>`.
|
|
14
|
+
*
|
|
15
|
+
* @category Components
|
|
16
|
+
*/
|
|
17
|
+
declare class AudioListenerComponentElement extends ComponentElement {
|
|
18
|
+
/** @ignore */
|
|
19
|
+
constructor();
|
|
20
|
+
/**
|
|
21
|
+
* Gets the underlying PlayCanvas audio listener component.
|
|
22
|
+
* @returns The audio listener component.
|
|
23
|
+
*/
|
|
24
|
+
get component(): AudioListenerComponent;
|
|
25
|
+
}
|
|
26
|
+
export { AudioListenerComponentElement };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AudioListenerComponent } from 'playcanvas';
|
|
2
|
+
import { ComponentElement } from './component.js';
|
|
3
|
+
/**
|
|
4
|
+
* The AudioListenerComponentElement interface provides properties and methods for manipulating
|
|
5
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-audio-listener/ | `<pc-audio-listener>`} elements.
|
|
6
|
+
* The AudioListenerComponentElement interface also inherits the properties and methods of the
|
|
7
|
+
* {@link HTMLElement} interface.
|
|
8
|
+
*
|
|
9
|
+
* Engine component: {@link AudioListenerComponent} (`audiolistener`).
|
|
10
|
+
*
|
|
11
|
+
* @elementSummary The `<pc-audio-listener>` element makes its entity the point from which
|
|
12
|
+
* positional sounds are heard, typically the entity holding the `<pc-camera>`. Must be a child of a
|
|
13
|
+
* `<pc-entity>`, `<pc-model>` or `<pc-node>`.
|
|
14
|
+
*
|
|
15
|
+
* @category Components
|
|
16
|
+
*/
|
|
17
|
+
declare class AudioListenerComponentElement extends ComponentElement {
|
|
18
|
+
/** @ignore */
|
|
19
|
+
constructor();
|
|
20
|
+
/**
|
|
21
|
+
* Gets the underlying PlayCanvas audio listener component.
|
|
22
|
+
* @returns The audio listener component.
|
|
23
|
+
*/
|
|
24
|
+
get component(): AudioListenerComponent;
|
|
25
|
+
}
|
|
26
|
+
export { AudioListenerComponentElement };
|
|
@@ -7,6 +7,13 @@ import { ComponentElement } from './component.cjs';
|
|
|
7
7
|
* The ButtonComponentElement interface also inherits the properties and methods of the
|
|
8
8
|
* {@link HTMLElement} interface.
|
|
9
9
|
*
|
|
10
|
+
* Engine component: {@link ButtonComponent} (`button`).
|
|
11
|
+
*
|
|
12
|
+
* @elementSummary The `<pc-button>` element makes its entity respond to pointer input, tinting or
|
|
13
|
+
* swapping its image as the pointer hovers, presses and releases it. The entity also needs a
|
|
14
|
+
* `<pc-element>` with `use-input` set. Must be a child of a `<pc-entity>`, `<pc-model>` or
|
|
15
|
+
* `<pc-node>`.
|
|
16
|
+
*
|
|
10
17
|
* @category Components
|
|
11
18
|
*/
|
|
12
19
|
declare class ButtonComponentElement extends ComponentElement {
|
|
@@ -44,7 +51,9 @@ declare class ButtonComponentElement extends ComponentElement {
|
|
|
44
51
|
get active(): boolean;
|
|
45
52
|
/**
|
|
46
53
|
* 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
|
|
54
|
+
* element is used for visual transitions. Defaults to the button's own entity — inside a
|
|
55
|
+
* `<pc-model>`, that is the model's host entity, so supply an explicit reference to target a
|
|
56
|
+
* UI entity instead.
|
|
48
57
|
* @param value - The image entity reference.
|
|
49
58
|
*/
|
|
50
59
|
set image(value: string);
|
|
@@ -7,6 +7,13 @@ import { ComponentElement } from './component.js';
|
|
|
7
7
|
* The ButtonComponentElement interface also inherits the properties and methods of the
|
|
8
8
|
* {@link HTMLElement} interface.
|
|
9
9
|
*
|
|
10
|
+
* Engine component: {@link ButtonComponent} (`button`).
|
|
11
|
+
*
|
|
12
|
+
* @elementSummary The `<pc-button>` element makes its entity respond to pointer input, tinting or
|
|
13
|
+
* swapping its image as the pointer hovers, presses and releases it. The entity also needs a
|
|
14
|
+
* `<pc-element>` with `use-input` set. Must be a child of a `<pc-entity>`, `<pc-model>` or
|
|
15
|
+
* `<pc-node>`.
|
|
16
|
+
*
|
|
10
17
|
* @category Components
|
|
11
18
|
*/
|
|
12
19
|
declare class ButtonComponentElement extends ComponentElement {
|
|
@@ -44,7 +51,9 @@ declare class ButtonComponentElement extends ComponentElement {
|
|
|
44
51
|
get active(): boolean;
|
|
45
52
|
/**
|
|
46
53
|
* 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
|
|
54
|
+
* element is used for visual transitions. Defaults to the button's own entity — inside a
|
|
55
|
+
* `<pc-model>`, that is the model's host entity, so supply an explicit reference to target a
|
|
56
|
+
* UI entity instead.
|
|
48
57
|
* @param value - The image entity reference.
|
|
49
58
|
*/
|
|
50
59
|
set image(value: string);
|