@playcanvas/web-components 0.15.0 → 0.17.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.cts +14 -13
- package/dist/app.d.ts +14 -13
- package/dist/async-element.d.cts +13 -13
- package/dist/async-element.d.ts +13 -13
- package/dist/components/anim-clip.d.cts +127 -0
- package/dist/components/anim-clip.d.ts +127 -0
- package/dist/components/anim-component.d.cts +235 -0
- package/dist/components/anim-component.d.ts +235 -0
- package/dist/components/{listener-component.d.cts → audio-listener-component.d.cts} +7 -5
- package/dist/components/{listener-component.d.ts → audio-listener-component.d.ts} +7 -5
- package/dist/components/button-component.d.cts +5 -1
- package/dist/components/button-component.d.ts +5 -1
- package/dist/components/camera-component.d.cts +2 -0
- package/dist/components/camera-component.d.ts +2 -0
- package/dist/components/collision-component.d.cts +5 -1
- package/dist/components/collision-component.d.ts +5 -1
- package/dist/components/component.d.cts +3 -2
- package/dist/components/component.d.ts +3 -2
- package/dist/components/element-component.d.cts +7 -0
- package/dist/components/element-component.d.ts +7 -0
- package/dist/components/gsplat-component.d.cts +2 -0
- package/dist/components/gsplat-component.d.ts +2 -0
- package/dist/components/joint-component.d.cts +2 -0
- package/dist/components/joint-component.d.ts +2 -0
- package/dist/components/{layoutchild-component.d.cts → layout-child-component.d.cts} +3 -1
- package/dist/components/{layoutchild-component.d.ts → layout-child-component.d.ts} +3 -1
- package/dist/components/{layoutgroup-component.d.cts → layout-group-component.d.cts} +3 -1
- package/dist/components/{layoutgroup-component.d.ts → layout-group-component.d.ts} +3 -1
- package/dist/components/light-component.d.cts +2 -0
- package/dist/components/light-component.d.ts +2 -0
- package/dist/components/{particlesystem-component.d.cts → particle-system-component.d.cts} +3 -1
- package/dist/components/{particlesystem-component.d.ts → particle-system-component.d.ts} +3 -1
- package/dist/components/render-component.d.cts +2 -0
- package/dist/components/render-component.d.ts +2 -0
- package/dist/components/{rigidbody-component.d.cts → rigid-body-component.d.cts} +3 -1
- package/dist/components/{rigidbody-component.d.ts → rigid-body-component.d.ts} +3 -1
- package/dist/components/screen-component.d.cts +2 -0
- package/dist/components/screen-component.d.ts +2 -0
- package/dist/components/script-component.d.cts +23 -12
- package/dist/components/script-component.d.ts +23 -12
- package/dist/components/{script.d.cts → script-instance.d.cts} +7 -7
- package/dist/components/{script.d.ts → script-instance.d.ts} +7 -7
- package/dist/components/{scrollview-component.d.cts → scroll-view-component.d.cts} +3 -1
- package/dist/components/{scrollview-component.d.ts → scroll-view-component.d.ts} +3 -1
- package/dist/components/scrollbar-component.d.cts +2 -0
- package/dist/components/scrollbar-component.d.ts +2 -0
- package/dist/components/sound-component.d.cts +3 -1
- package/dist/components/sound-component.d.ts +3 -1
- package/dist/components/sound-slot.d.cts +2 -2
- package/dist/components/sound-slot.d.ts +2 -2
- package/dist/custom-elements.json +3154 -2005
- package/dist/entity-base.d.cts +6 -5
- package/dist/entity-base.d.ts +6 -5
- package/dist/entity-owner.d.cts +118 -0
- package/dist/entity-owner.d.ts +118 -0
- package/dist/entity.d.cts +8 -101
- package/dist/entity.d.ts +8 -101
- package/dist/index.d.cts +26 -21
- package/dist/index.d.ts +26 -21
- package/dist/model.d.cts +67 -24
- package/dist/model.d.ts +67 -24
- package/dist/pwc.cjs +1766 -619
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +1766 -619
- 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 +1762 -618
- package/dist/pwc.mjs.map +1 -1
- package/dist/vscode.html-custom-data.json +203 -89
- package/dist/{module.d.cts → wasm.d.cts} +6 -6
- package/dist/{module.d.ts → wasm.d.ts} +6 -6
- package/dist/web-types.json +556 -273
- package/package.json +7 -7
- package/src/app.ts +45 -35
- package/src/async-element.ts +14 -14
- package/src/components/anim-clip.ts +395 -0
- package/src/components/anim-component.ts +719 -0
- package/src/components/{listener-component.ts → audio-listener-component.ts} +8 -6
- package/src/components/button-component.ts +5 -1
- package/src/components/camera-component.ts +2 -0
- package/src/components/collision-component.ts +5 -1
- package/src/components/component.ts +4 -3
- package/src/components/element-component.ts +7 -0
- package/src/components/gsplat-component.ts +2 -0
- package/src/components/joint-component.ts +2 -0
- package/src/components/{layoutchild-component.ts → layout-child-component.ts} +4 -2
- package/src/components/{layoutgroup-component.ts → layout-group-component.ts} +4 -2
- package/src/components/light-component.ts +2 -0
- package/src/components/{particlesystem-component.ts → particle-system-component.ts} +4 -2
- package/src/components/render-component.ts +2 -0
- package/src/components/{rigidbody-component.ts → rigid-body-component.ts} +4 -2
- package/src/components/screen-component.ts +2 -0
- package/src/components/script-component.ts +63 -42
- package/src/components/{script.ts → script-instance.ts} +14 -14
- package/src/components/{scrollview-component.ts → scroll-view-component.ts} +4 -2
- package/src/components/scrollbar-component.ts +2 -0
- package/src/components/sound-component.ts +4 -2
- package/src/components/sound-slot.ts +4 -4
- package/src/entity-base.ts +6 -5
- package/src/entity-owner.ts +298 -0
- package/src/entity.ts +15 -270
- package/src/index.ts +32 -24
- package/src/model.ts +159 -79
- package/src/node.ts +9 -5
- package/src/{module.ts → wasm.ts} +8 -8
package/dist/app.d.cts
CHANGED
|
@@ -53,9 +53,9 @@ declare class AppElement extends AsyncElement {
|
|
|
53
53
|
private _bootGeneration;
|
|
54
54
|
/**
|
|
55
55
|
* The elements backing this application's entities, keyed by the entity itself. Registered
|
|
56
|
-
* by
|
|
57
|
-
*
|
|
58
|
-
* identity - never by name.
|
|
56
|
+
* by entity-owning elements at creation (pc-entity, and pc-model for its host) and by
|
|
57
|
+
* NodeElement at binding, and removed when an entity is destroyed or unbound, this joins
|
|
58
|
+
* engine scene nodes back to their owning elements by identity - never by name.
|
|
59
59
|
*/
|
|
60
60
|
private _entityElements;
|
|
61
61
|
private _picker;
|
|
@@ -103,25 +103,26 @@ declare class AppElement extends AsyncElement {
|
|
|
103
103
|
private _pickerCreate;
|
|
104
104
|
private _pickerDestroy;
|
|
105
105
|
/**
|
|
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.
|
|
106
|
+
* Returns the `<pc-entity>`, `<pc-model>` or `<pc-node>` element whose backing entity is
|
|
107
|
+
* `entity`, or `null` if the entity is not fronted by an element of this application - for
|
|
108
|
+
* example, an unbound node inside a model's instantiated hierarchy, or an entity created
|
|
109
|
+
* through the engine API.
|
|
110
110
|
*
|
|
111
111
|
* @param entity - The entity to look up.
|
|
112
112
|
* @returns The element fronting the entity, or `null`.
|
|
113
113
|
*/
|
|
114
114
|
elementFromEntity(entity: Entity): EntityBaseElement | null;
|
|
115
115
|
/**
|
|
116
|
-
* Resolves the element that owns a picked node: the nearest node up the parent
|
|
117
|
-
* starting with the node itself -
|
|
118
|
-
*
|
|
119
|
-
*
|
|
116
|
+
* Resolves the element that owns hover for a picked node: the nearest node up the parent
|
|
117
|
+
* chain - starting with the node itself - whose element listens for any of the hover event
|
|
118
|
+
* types. Skipping silent elements matches {@link _elementWithListener}, so a registered
|
|
119
|
+
* element with no hover listeners (a `<pc-model>` host, a plain child entity) is transparent
|
|
120
|
+
* to hover rather than swallowing a listening ancestor's enter/leave pair.
|
|
120
121
|
*
|
|
121
122
|
* @param node - The picked node, or `null`.
|
|
122
|
-
* @returns The owning element, or `null`.
|
|
123
|
+
* @returns The hover-owning element, or `null`.
|
|
123
124
|
*/
|
|
124
|
-
private
|
|
125
|
+
private _hoverTarget;
|
|
125
126
|
/**
|
|
126
127
|
* Like {@link _elementFromNode}, but skips elements without a listener for `type`, so a hit
|
|
127
128
|
* on an unlistened child still reaches a listening ancestor.
|
package/dist/app.d.ts
CHANGED
|
@@ -53,9 +53,9 @@ declare class AppElement extends AsyncElement {
|
|
|
53
53
|
private _bootGeneration;
|
|
54
54
|
/**
|
|
55
55
|
* The elements backing this application's entities, keyed by the entity itself. Registered
|
|
56
|
-
* by
|
|
57
|
-
*
|
|
58
|
-
* identity - never by name.
|
|
56
|
+
* by entity-owning elements at creation (pc-entity, and pc-model for its host) and by
|
|
57
|
+
* NodeElement at binding, and removed when an entity is destroyed or unbound, this joins
|
|
58
|
+
* engine scene nodes back to their owning elements by identity - never by name.
|
|
59
59
|
*/
|
|
60
60
|
private _entityElements;
|
|
61
61
|
private _picker;
|
|
@@ -103,25 +103,26 @@ declare class AppElement extends AsyncElement {
|
|
|
103
103
|
private _pickerCreate;
|
|
104
104
|
private _pickerDestroy;
|
|
105
105
|
/**
|
|
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.
|
|
106
|
+
* Returns the `<pc-entity>`, `<pc-model>` or `<pc-node>` element whose backing entity is
|
|
107
|
+
* `entity`, or `null` if the entity is not fronted by an element of this application - for
|
|
108
|
+
* example, an unbound node inside a model's instantiated hierarchy, or an entity created
|
|
109
|
+
* through the engine API.
|
|
110
110
|
*
|
|
111
111
|
* @param entity - The entity to look up.
|
|
112
112
|
* @returns The element fronting the entity, or `null`.
|
|
113
113
|
*/
|
|
114
114
|
elementFromEntity(entity: Entity): EntityBaseElement | null;
|
|
115
115
|
/**
|
|
116
|
-
* Resolves the element that owns a picked node: the nearest node up the parent
|
|
117
|
-
* starting with the node itself -
|
|
118
|
-
*
|
|
119
|
-
*
|
|
116
|
+
* Resolves the element that owns hover for a picked node: the nearest node up the parent
|
|
117
|
+
* chain - starting with the node itself - whose element listens for any of the hover event
|
|
118
|
+
* types. Skipping silent elements matches {@link _elementWithListener}, so a registered
|
|
119
|
+
* element with no hover listeners (a `<pc-model>` host, a plain child entity) is transparent
|
|
120
|
+
* to hover rather than swallowing a listening ancestor's enter/leave pair.
|
|
120
121
|
*
|
|
121
122
|
* @param node - The picked node, or `null`.
|
|
122
|
-
* @returns The owning element, or `null`.
|
|
123
|
+
* @returns The hover-owning element, or `null`.
|
|
123
124
|
*/
|
|
124
|
-
private
|
|
125
|
+
private _hoverTarget;
|
|
125
126
|
/**
|
|
126
127
|
* Like {@link _elementFromNode}, but skips elements without a listener for `type`, so a hit
|
|
127
128
|
* on an unlistened child still reaches a listening ancestor.
|
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
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { AsyncElement } from '../async-element.cjs';
|
|
2
|
+
import { AnimComponentElement } from './anim-component.cjs';
|
|
3
|
+
/**
|
|
4
|
+
* The AnimClipElement interface provides properties and methods for manipulating
|
|
5
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-anim-clip/ | `<pc-anim-clip>`}
|
|
6
|
+
* elements. The AnimClipElement interface also inherits the properties and methods of the
|
|
7
|
+
* {@link HTMLElement} interface.
|
|
8
|
+
*
|
|
9
|
+
* A clip declares one named animation on its parent `<pc-anim>`. `name` is both the clip's name
|
|
10
|
+
* and the track looked up in the clip's source: an explicit `asset` (a `container`, an
|
|
11
|
+
* `animation` `.glb`, or an `animclip` JSON), or, without one, the container of the `<pc-model>`
|
|
12
|
+
* enclosing the parent `<pc-anim>`. A source holding a single track supplies it whatever it is
|
|
13
|
+
* named; in a multi-track source the track named `name` is chosen, falling back to the first
|
|
14
|
+
* with a warning. The element becomes ready once its resolved track is assigned.
|
|
15
|
+
*
|
|
16
|
+
* @category Components
|
|
17
|
+
*/
|
|
18
|
+
declare class AnimClipElement extends AsyncElement {
|
|
19
|
+
/**
|
|
20
|
+
* The `<pc-anim>` this clip was adopted by, captured when the parent adopts the clip and on
|
|
21
|
+
* connection.
|
|
22
|
+
*
|
|
23
|
+
* `disconnectedCallback` cannot rediscover it: by the time the element is disconnected its
|
|
24
|
+
* `parentElement` is already `null`, so a lookup would both fail to find the component and
|
|
25
|
+
* emit a misleading "must be a direct child" warning for what is an ordinary removal.
|
|
26
|
+
*/
|
|
27
|
+
private _animElement;
|
|
28
|
+
private _asset;
|
|
29
|
+
/**
|
|
30
|
+
* Incremented on every connect and disconnect, and captured by connectedCallback on entry —
|
|
31
|
+
* a resume from an await abandons itself if the value has moved on, so a stale callback can
|
|
32
|
+
* neither act on a torn-down tree nor register its clip alongside a re-inserted element's
|
|
33
|
+
* own callback.
|
|
34
|
+
*/
|
|
35
|
+
private _connectionGeneration;
|
|
36
|
+
private _errorHandle;
|
|
37
|
+
/**
|
|
38
|
+
* Incremented on every track resolution and on disconnect, and captured by a resolution when
|
|
39
|
+
* it starts. A resolution that resumes from an await or an asset callback abandons itself if
|
|
40
|
+
* the value has moved on, so a superseded resolution cannot hand a stale track to the parent.
|
|
41
|
+
*/
|
|
42
|
+
private _loadGeneration;
|
|
43
|
+
/**
|
|
44
|
+
* The pending asset subscriptions of the current resolution, if it is waiting for its asset.
|
|
45
|
+
* Held so that whatever supersedes the resolution can detach the handlers from the asset,
|
|
46
|
+
* rather than leave them registered until the asset settles (or forever, if it never does).
|
|
47
|
+
*/
|
|
48
|
+
private _loadHandle;
|
|
49
|
+
private _loop;
|
|
50
|
+
private _name;
|
|
51
|
+
private _speed;
|
|
52
|
+
/**
|
|
53
|
+
* The source complaint already made — the asset id it was made for, or `''` for the
|
|
54
|
+
* no-asset-no-model case — so re-resolutions (host cycles, model reloads) do not repeat it.
|
|
55
|
+
*/
|
|
56
|
+
private _warnedSource;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the owning `<pc-anim>` already rejected this clip's name — its sweeps re-run on
|
|
59
|
+
* host cycles and must not repeat the complaint.
|
|
60
|
+
*/
|
|
61
|
+
private _warnedInvalid;
|
|
62
|
+
connectedCallback(): Promise<void>;
|
|
63
|
+
disconnectedCallback(): void;
|
|
64
|
+
protected get animElement(): AnimComponentElement | null;
|
|
65
|
+
private _detachLoadHandlers;
|
|
66
|
+
/**
|
|
67
|
+
* Complains about the clip's source, once per source value — resolutions re-run on host
|
|
68
|
+
* cycles and model reloads, and must not repeat the complaint.
|
|
69
|
+
*/
|
|
70
|
+
private _warnSource;
|
|
71
|
+
/**
|
|
72
|
+
* Picks the clip's track out of a loaded source asset: the track named `name`, or a lone
|
|
73
|
+
* track whatever it is named, or the first of several with a warning.
|
|
74
|
+
*
|
|
75
|
+
* @param asset - The loaded source asset.
|
|
76
|
+
* @param source - How warnings name the source.
|
|
77
|
+
*/
|
|
78
|
+
private _extractTrack;
|
|
79
|
+
/**
|
|
80
|
+
* Sets the id of the `pc-asset` supplying the clip's track: a `container`, an `animation`
|
|
81
|
+
* `.glb`, or an `animclip` JSON. When empty, the track comes from the container of the
|
|
82
|
+
* `<pc-model>` enclosing the parent `<pc-anim>`.
|
|
83
|
+
* @param value - The asset id.
|
|
84
|
+
*/
|
|
85
|
+
set asset(value: string);
|
|
86
|
+
/**
|
|
87
|
+
* Gets the id of the `pc-asset` supplying the clip's track.
|
|
88
|
+
* @returns The asset id.
|
|
89
|
+
*/
|
|
90
|
+
get asset(): string;
|
|
91
|
+
/**
|
|
92
|
+
* Sets whether the clip loops. A non-looping clip holds its last pose when it ends — the
|
|
93
|
+
* engine reports no completion. Defaults to `true`.
|
|
94
|
+
* @param value - Whether the clip loops.
|
|
95
|
+
*/
|
|
96
|
+
set loop(value: boolean);
|
|
97
|
+
/**
|
|
98
|
+
* Gets whether the clip loops.
|
|
99
|
+
* @returns Whether the clip loops.
|
|
100
|
+
*/
|
|
101
|
+
get loop(): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Sets the name of the clip: the name it is played by, and the track looked up in the
|
|
104
|
+
* clip's source. Names must be unique within a `<pc-anim>` and must not contain `.`.
|
|
105
|
+
* @param value - The clip name.
|
|
106
|
+
*/
|
|
107
|
+
set name(value: string);
|
|
108
|
+
/**
|
|
109
|
+
* Gets the name of the clip.
|
|
110
|
+
* @returns The clip name.
|
|
111
|
+
*/
|
|
112
|
+
get name(): string;
|
|
113
|
+
/**
|
|
114
|
+
* Sets the playback speed of the clip, where negative values play it backwards. Applies
|
|
115
|
+
* immediately, preserving the playhead. Defaults to 1.
|
|
116
|
+
* @param value - The playback speed.
|
|
117
|
+
*/
|
|
118
|
+
set speed(value: number);
|
|
119
|
+
/**
|
|
120
|
+
* Gets the playback speed of the clip.
|
|
121
|
+
* @returns The playback speed.
|
|
122
|
+
*/
|
|
123
|
+
get speed(): number;
|
|
124
|
+
static get observedAttributes(): string[];
|
|
125
|
+
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
|
|
126
|
+
}
|
|
127
|
+
export { AnimClipElement };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { AsyncElement } from '../async-element.js';
|
|
2
|
+
import { AnimComponentElement } from './anim-component.js';
|
|
3
|
+
/**
|
|
4
|
+
* The AnimClipElement interface provides properties and methods for manipulating
|
|
5
|
+
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-anim-clip/ | `<pc-anim-clip>`}
|
|
6
|
+
* elements. The AnimClipElement interface also inherits the properties and methods of the
|
|
7
|
+
* {@link HTMLElement} interface.
|
|
8
|
+
*
|
|
9
|
+
* A clip declares one named animation on its parent `<pc-anim>`. `name` is both the clip's name
|
|
10
|
+
* and the track looked up in the clip's source: an explicit `asset` (a `container`, an
|
|
11
|
+
* `animation` `.glb`, or an `animclip` JSON), or, without one, the container of the `<pc-model>`
|
|
12
|
+
* enclosing the parent `<pc-anim>`. A source holding a single track supplies it whatever it is
|
|
13
|
+
* named; in a multi-track source the track named `name` is chosen, falling back to the first
|
|
14
|
+
* with a warning. The element becomes ready once its resolved track is assigned.
|
|
15
|
+
*
|
|
16
|
+
* @category Components
|
|
17
|
+
*/
|
|
18
|
+
declare class AnimClipElement extends AsyncElement {
|
|
19
|
+
/**
|
|
20
|
+
* The `<pc-anim>` this clip was adopted by, captured when the parent adopts the clip and on
|
|
21
|
+
* connection.
|
|
22
|
+
*
|
|
23
|
+
* `disconnectedCallback` cannot rediscover it: by the time the element is disconnected its
|
|
24
|
+
* `parentElement` is already `null`, so a lookup would both fail to find the component and
|
|
25
|
+
* emit a misleading "must be a direct child" warning for what is an ordinary removal.
|
|
26
|
+
*/
|
|
27
|
+
private _animElement;
|
|
28
|
+
private _asset;
|
|
29
|
+
/**
|
|
30
|
+
* Incremented on every connect and disconnect, and captured by connectedCallback on entry —
|
|
31
|
+
* a resume from an await abandons itself if the value has moved on, so a stale callback can
|
|
32
|
+
* neither act on a torn-down tree nor register its clip alongside a re-inserted element's
|
|
33
|
+
* own callback.
|
|
34
|
+
*/
|
|
35
|
+
private _connectionGeneration;
|
|
36
|
+
private _errorHandle;
|
|
37
|
+
/**
|
|
38
|
+
* Incremented on every track resolution and on disconnect, and captured by a resolution when
|
|
39
|
+
* it starts. A resolution that resumes from an await or an asset callback abandons itself if
|
|
40
|
+
* the value has moved on, so a superseded resolution cannot hand a stale track to the parent.
|
|
41
|
+
*/
|
|
42
|
+
private _loadGeneration;
|
|
43
|
+
/**
|
|
44
|
+
* The pending asset subscriptions of the current resolution, if it is waiting for its asset.
|
|
45
|
+
* Held so that whatever supersedes the resolution can detach the handlers from the asset,
|
|
46
|
+
* rather than leave them registered until the asset settles (or forever, if it never does).
|
|
47
|
+
*/
|
|
48
|
+
private _loadHandle;
|
|
49
|
+
private _loop;
|
|
50
|
+
private _name;
|
|
51
|
+
private _speed;
|
|
52
|
+
/**
|
|
53
|
+
* The source complaint already made — the asset id it was made for, or `''` for the
|
|
54
|
+
* no-asset-no-model case — so re-resolutions (host cycles, model reloads) do not repeat it.
|
|
55
|
+
*/
|
|
56
|
+
private _warnedSource;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the owning `<pc-anim>` already rejected this clip's name — its sweeps re-run on
|
|
59
|
+
* host cycles and must not repeat the complaint.
|
|
60
|
+
*/
|
|
61
|
+
private _warnedInvalid;
|
|
62
|
+
connectedCallback(): Promise<void>;
|
|
63
|
+
disconnectedCallback(): void;
|
|
64
|
+
protected get animElement(): AnimComponentElement | null;
|
|
65
|
+
private _detachLoadHandlers;
|
|
66
|
+
/**
|
|
67
|
+
* Complains about the clip's source, once per source value — resolutions re-run on host
|
|
68
|
+
* cycles and model reloads, and must not repeat the complaint.
|
|
69
|
+
*/
|
|
70
|
+
private _warnSource;
|
|
71
|
+
/**
|
|
72
|
+
* Picks the clip's track out of a loaded source asset: the track named `name`, or a lone
|
|
73
|
+
* track whatever it is named, or the first of several with a warning.
|
|
74
|
+
*
|
|
75
|
+
* @param asset - The loaded source asset.
|
|
76
|
+
* @param source - How warnings name the source.
|
|
77
|
+
*/
|
|
78
|
+
private _extractTrack;
|
|
79
|
+
/**
|
|
80
|
+
* Sets the id of the `pc-asset` supplying the clip's track: a `container`, an `animation`
|
|
81
|
+
* `.glb`, or an `animclip` JSON. When empty, the track comes from the container of the
|
|
82
|
+
* `<pc-model>` enclosing the parent `<pc-anim>`.
|
|
83
|
+
* @param value - The asset id.
|
|
84
|
+
*/
|
|
85
|
+
set asset(value: string);
|
|
86
|
+
/**
|
|
87
|
+
* Gets the id of the `pc-asset` supplying the clip's track.
|
|
88
|
+
* @returns The asset id.
|
|
89
|
+
*/
|
|
90
|
+
get asset(): string;
|
|
91
|
+
/**
|
|
92
|
+
* Sets whether the clip loops. A non-looping clip holds its last pose when it ends — the
|
|
93
|
+
* engine reports no completion. Defaults to `true`.
|
|
94
|
+
* @param value - Whether the clip loops.
|
|
95
|
+
*/
|
|
96
|
+
set loop(value: boolean);
|
|
97
|
+
/**
|
|
98
|
+
* Gets whether the clip loops.
|
|
99
|
+
* @returns Whether the clip loops.
|
|
100
|
+
*/
|
|
101
|
+
get loop(): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Sets the name of the clip: the name it is played by, and the track looked up in the
|
|
104
|
+
* clip's source. Names must be unique within a `<pc-anim>` and must not contain `.`.
|
|
105
|
+
* @param value - The clip name.
|
|
106
|
+
*/
|
|
107
|
+
set name(value: string);
|
|
108
|
+
/**
|
|
109
|
+
* Gets the name of the clip.
|
|
110
|
+
* @returns The clip name.
|
|
111
|
+
*/
|
|
112
|
+
get name(): string;
|
|
113
|
+
/**
|
|
114
|
+
* Sets the playback speed of the clip, where negative values play it backwards. Applies
|
|
115
|
+
* immediately, preserving the playhead. Defaults to 1.
|
|
116
|
+
* @param value - The playback speed.
|
|
117
|
+
*/
|
|
118
|
+
set speed(value: number);
|
|
119
|
+
/**
|
|
120
|
+
* Gets the playback speed of the clip.
|
|
121
|
+
* @returns The playback speed.
|
|
122
|
+
*/
|
|
123
|
+
get speed(): number;
|
|
124
|
+
static get observedAttributes(): string[];
|
|
125
|
+
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
|
|
126
|
+
}
|
|
127
|
+
export { AnimClipElement };
|