@playcanvas/web-components 0.8.2 → 0.9.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 +10 -2
- package/dist/asset.d.ts +18 -3
- package/dist/async-element.d.ts +51 -4
- package/dist/components/button-component.d.ts +10 -4
- package/dist/components/camera-component.d.ts +9 -4
- package/dist/components/collision-component.d.ts +9 -4
- package/dist/components/component.d.ts +7 -1
- package/dist/components/element-component.d.ts +17 -12
- package/dist/components/gsplat-component.d.ts +6 -1
- package/dist/components/layoutchild-component.d.ts +6 -1
- package/dist/components/layoutgroup-component.d.ts +21 -15
- package/dist/components/light-component.d.ts +12 -6
- package/dist/components/listener-component.d.ts +6 -1
- package/dist/components/particlesystem-component.d.ts +6 -1
- package/dist/components/render-component.d.ts +13 -4
- package/dist/components/rigidbody-component.d.ts +9 -4
- package/dist/components/screen-component.d.ts +6 -1
- package/dist/components/script-component.d.ts +116 -16
- package/dist/components/script.d.ts +72 -8
- package/dist/components/scrollbar-component.d.ts +10 -4
- package/dist/components/scrollview-component.d.ts +17 -10
- package/dist/components/sound-component.d.ts +6 -1
- package/dist/components/sound-slot.d.ts +8 -3
- package/dist/entity.d.ts +26 -2
- package/dist/index.d.ts +3 -2
- package/dist/material.d.ts +10 -0
- package/dist/model.d.ts +5 -0
- package/dist/module.d.ts +5 -0
- package/dist/pwc.cjs +1574 -853
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +1574 -853
- 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.mjs +1575 -855
- package/dist/pwc.mjs.map +1 -1
- package/dist/scene.d.ts +14 -5
- package/dist/sky.d.ts +6 -0
- package/dist/utils.d.ts +81 -23
- package/package.json +7 -7
- package/src/app.ts +38 -12
- package/src/asset.ts +61 -8
- package/src/async-element.ts +86 -5
- package/src/components/button-component.ts +26 -19
- package/src/components/camera-component.ts +29 -23
- package/src/components/collision-component.ts +19 -13
- package/src/components/component.ts +32 -13
- package/src/components/element-component.ts +58 -52
- package/src/components/gsplat-component.ts +14 -7
- package/src/components/layoutchild-component.ts +16 -9
- package/src/components/layoutgroup-component.ts +38 -31
- package/src/components/light-component.ts +33 -31
- package/src/components/listener-component.ts +8 -2
- package/src/components/particlesystem-component.ts +8 -2
- package/src/components/render-component.ts +19 -8
- package/src/components/rigidbody-component.ts +21 -15
- package/src/components/screen-component.ts +15 -9
- package/src/components/script-component.ts +512 -125
- package/src/components/script.ts +116 -16
- package/src/components/scrollbar-component.ts +19 -12
- package/src/components/scrollview-component.ts +37 -29
- package/src/components/sound-component.ts +16 -9
- package/src/components/sound-slot.ts +23 -14
- package/src/entity.ts +61 -71
- package/src/index.ts +5 -2
- package/src/material.ts +34 -1
- package/src/model.ts +6 -0
- package/src/module.ts +6 -0
- package/src/scene.ts +25 -12
- package/src/sky.ts +34 -16
- package/src/utils.ts +180 -40
|
@@ -2,7 +2,7 @@ import { ScriptComponent } from 'playcanvas';
|
|
|
2
2
|
import { ComponentElement } from './component';
|
|
3
3
|
interface ScriptAttributesChangeEvent extends CustomEvent {
|
|
4
4
|
detail: {
|
|
5
|
-
attributes: any
|
|
5
|
+
attributes: Record<string, any>;
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
8
|
interface ScriptEnableChangeEvent extends CustomEvent {
|
|
@@ -10,10 +10,17 @@ interface ScriptEnableChangeEvent extends CustomEvent {
|
|
|
10
10
|
enabled: boolean;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
+
interface ScriptNameChangeEvent extends CustomEvent {
|
|
14
|
+
detail: {
|
|
15
|
+
oldName: string;
|
|
16
|
+
newName: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
13
19
|
declare global {
|
|
14
20
|
interface HTMLElementEventMap {
|
|
15
21
|
'scriptattributeschange': ScriptAttributesChangeEvent;
|
|
16
22
|
'scriptenablechange': ScriptEnableChangeEvent;
|
|
23
|
+
'scriptnamechange': ScriptNameChangeEvent;
|
|
17
24
|
}
|
|
18
25
|
}
|
|
19
26
|
/**
|
|
@@ -28,41 +35,129 @@ declare class ScriptComponentElement extends ComponentElement {
|
|
|
28
35
|
private observer;
|
|
29
36
|
/** @ignore */
|
|
30
37
|
constructor();
|
|
38
|
+
connectedCallback(): Promise<void>;
|
|
31
39
|
initComponent(): void;
|
|
32
40
|
/**
|
|
33
41
|
* Recursively converts raw attribute data into proper PlayCanvas types. Supported conversions:
|
|
34
|
-
* - "asset:
|
|
35
|
-
* - "entity:
|
|
36
|
-
*
|
|
37
|
-
* - "
|
|
38
|
-
* - "
|
|
39
|
-
* - "
|
|
42
|
+
* - "asset:id" → the Asset created by the `pc-asset` element with that id
|
|
43
|
+
* - "entity:ref" → the Entity backing a `pc-entity` element. The reference can be a CSS
|
|
44
|
+
* selector, an element id or an entity name.
|
|
45
|
+
* - "vec2:1 2" → new Vec2(1, 2)
|
|
46
|
+
* - "vec3:1 2 3" → new Vec3(1, 2, 3)
|
|
47
|
+
* - "vec4:1 2 3 4" → new Vec4(1, 2, 3, 4)
|
|
48
|
+
* - "color:1 0.5 0.5 1" → new Color(1, 0.5, 0.5, 1)
|
|
49
|
+
*
|
|
50
|
+
* A prefixed string that fails to resolve or parse logs a warning and is left as the raw
|
|
51
|
+
* string.
|
|
40
52
|
* @param item - The item to convert.
|
|
41
53
|
* @returns The converted item.
|
|
42
54
|
*/
|
|
43
55
|
private convertAttributes;
|
|
44
56
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
|
|
49
|
-
private preprocessAttributes;
|
|
50
|
-
/**
|
|
51
|
-
* Recursively merge properties from source into target.
|
|
57
|
+
* Recursively merge properties from source into target. When the target value is a Vec2,
|
|
58
|
+
* Vec3, Vec4 or Color and the source value is a plain numeric array, the array is converted
|
|
59
|
+
* to the target's type — so script attributes with math-typed defaults can be written as
|
|
60
|
+
* plain JSON arrays (e.g. `"focusPoint": [0, 1.75, 0]`).
|
|
52
61
|
* @param target - The target object to merge into.
|
|
53
62
|
* @param source - The source object to merge from.
|
|
54
63
|
* @returns The merged object.
|
|
55
64
|
*/
|
|
56
65
|
private mergeDeep;
|
|
57
66
|
/**
|
|
58
|
-
*
|
|
67
|
+
* Checks whether a value is one of the math types that plain numeric arrays convert to.
|
|
68
|
+
* @param value - The value to check.
|
|
69
|
+
* @returns Whether the value is a math type.
|
|
70
|
+
*/
|
|
71
|
+
private isMathType;
|
|
72
|
+
/**
|
|
73
|
+
* Converts a plain numeric array to the math type of `current`. A 3-element array targeting
|
|
74
|
+
* a Quat is interpreted as Euler angles in degrees, mirroring the `parseQuat` attribute
|
|
75
|
+
* grammar. Returns `null` (and logs a warning) when the array's length or contents don't
|
|
76
|
+
* match the type.
|
|
77
|
+
* @param current - The current (typed) value of the property.
|
|
78
|
+
* @param value - The incoming array.
|
|
79
|
+
* @param key - The property name, used in the warning message.
|
|
80
|
+
* @returns The converted value, or `null`.
|
|
81
|
+
*/
|
|
82
|
+
private arrayToMathType;
|
|
83
|
+
/**
|
|
84
|
+
* Update script attributes by merging converted values into the script. `enabled` is always
|
|
85
|
+
* excluded (it is configured through the element's `enabled` attribute, not the JSON blob),
|
|
86
|
+
* as are any keys in `exclude` — used to keep per-property attributes authoritative over
|
|
87
|
+
* the blob without writing a property twice.
|
|
59
88
|
* @param script - The script to update.
|
|
60
89
|
* @param attributes - The attributes to merge into the script.
|
|
90
|
+
* @param exclude - Keys to strip from the merge.
|
|
61
91
|
*/
|
|
62
92
|
private applyAttributes;
|
|
93
|
+
/**
|
|
94
|
+
* Returns the camelCase keys of the per-property attributes present on a `pc-script`
|
|
95
|
+
* element.
|
|
96
|
+
* @param scriptElement - The `pc-script` element.
|
|
97
|
+
* @returns The camelCase keys.
|
|
98
|
+
*/
|
|
99
|
+
private inlineKeys;
|
|
100
|
+
/**
|
|
101
|
+
* Resolves the script instance owned by a `pc-script` element. Returns `null` when the
|
|
102
|
+
* element has no created script, or when its name resolves to a script created by a
|
|
103
|
+
* different element (e.g. a duplicate-named sibling).
|
|
104
|
+
* @param scriptElement - The `pc-script` element.
|
|
105
|
+
* @returns The owned script, or `null`.
|
|
106
|
+
*/
|
|
107
|
+
private scriptFor;
|
|
63
108
|
private handleScriptAttributesChange;
|
|
64
109
|
private handleScriptEnableChange;
|
|
110
|
+
/**
|
|
111
|
+
* Handles a runtime `name` change on a child `pc-script`, swapping the engine script instance
|
|
112
|
+
* to match. Without this the element would keep pointing at the old-name instance: the old
|
|
113
|
+
* script would go on running while every subsequent update (attribute changes, enable
|
|
114
|
+
* changes, destruction on removal) resolved the new name and silently no-opped.
|
|
115
|
+
*
|
|
116
|
+
* The new instance is built by the normal creation path, so both attribute channels are
|
|
117
|
+
* re-applied to it and the declared enabled state is restored.
|
|
118
|
+
* @param event - The name change event.
|
|
119
|
+
*/
|
|
120
|
+
private handleScriptNameChange;
|
|
121
|
+
/**
|
|
122
|
+
* Creates the script instance for a `pc-script` element. The instance is created disabled,
|
|
123
|
+
* the element's converted attributes are merged over the instance's defaults (which is what
|
|
124
|
+
* allows plain numeric arrays to be typed against those defaults), and only then is the
|
|
125
|
+
* declared enabled state applied — so `initialize()` runs with every attribute in place.
|
|
126
|
+
* @param scriptElement - The `pc-script` element to create the script instance for.
|
|
127
|
+
* @returns The created script, or `null`.
|
|
128
|
+
*/
|
|
65
129
|
private createScript;
|
|
130
|
+
/**
|
|
131
|
+
* Applies the per-property attributes present on a `pc-script` element — any attribute that
|
|
132
|
+
* is not part of the element's own API or a reserved HTML attribute name. These are applied
|
|
133
|
+
* after the `attributes` JSON, so an individual attribute always takes precedence over the
|
|
134
|
+
* blob.
|
|
135
|
+
* @param script - The script to apply the attributes to.
|
|
136
|
+
* @param scriptElement - The `pc-script` element holding the attributes.
|
|
137
|
+
*/
|
|
138
|
+
private applyInlineAttributes;
|
|
139
|
+
/**
|
|
140
|
+
* Applies a single per-property attribute change to the script of a `pc-script` element.
|
|
141
|
+
* When the attribute has been removed, the value from the `attributes` JSON (if any) takes
|
|
142
|
+
* effect again.
|
|
143
|
+
* @param scriptElement - The `pc-script` element whose attribute changed.
|
|
144
|
+
* @param attributeName - The name of the changed attribute.
|
|
145
|
+
*/
|
|
146
|
+
private applyScriptProperty;
|
|
147
|
+
/**
|
|
148
|
+
* Applies one attribute string to a script property. A string-typed attribute takes the
|
|
149
|
+
* value verbatim (so literals like 'color:red' are never hijacked by prefix conversion).
|
|
150
|
+
* Otherwise, explicit prefixes (`asset:`, `entity:`, `vec2:`, `vec3:`, `vec4:`, `color:`)
|
|
151
|
+
* carry their own type, and unprefixed values are parsed according to the type of the
|
|
152
|
+
* attribute's current value. The Script API itself (methods, `entity`, `app`) is never
|
|
153
|
+
* overwritten, invalid values keep the current value, and exceptions thrown by user
|
|
154
|
+
* getters/setters are contained so one bad attribute cannot abort the rest of a batch.
|
|
155
|
+
* @param script - The script to apply the value to.
|
|
156
|
+
* @param scriptName - The script name, used in warning messages.
|
|
157
|
+
* @param attributeName - The (kebab-case) element attribute name.
|
|
158
|
+
* @param value - The attribute value.
|
|
159
|
+
*/
|
|
160
|
+
private setScriptProperty;
|
|
66
161
|
private destroyScript;
|
|
67
162
|
private handleMutations;
|
|
68
163
|
disconnectedCallback(): void;
|
|
@@ -70,6 +165,11 @@ declare class ScriptComponentElement extends ComponentElement {
|
|
|
70
165
|
* Gets the underlying PlayCanvas script component.
|
|
71
166
|
* @returns The script component.
|
|
72
167
|
*/
|
|
73
|
-
get component(): ScriptComponent
|
|
168
|
+
get component(): ScriptComponent;
|
|
169
|
+
}
|
|
170
|
+
declare global {
|
|
171
|
+
interface HTMLElementTagNameMap {
|
|
172
|
+
'pc-scripts': ScriptComponentElement;
|
|
173
|
+
}
|
|
74
174
|
}
|
|
75
175
|
export { ScriptComponentElement };
|
|
@@ -1,22 +1,59 @@
|
|
|
1
|
+
import { Script } from 'playcanvas';
|
|
2
|
+
import { AsyncElement } from '../async-element';
|
|
1
3
|
/**
|
|
2
4
|
* The ScriptElement interface provides properties and methods for manipulating
|
|
3
5
|
* `<pc-script>` elements. The ScriptElement interface also inherits the properties and
|
|
4
|
-
* methods of the {@link
|
|
6
|
+
* methods of the {@link AsyncElement} interface.
|
|
7
|
+
*
|
|
8
|
+
* Script attributes can be supplied through two channels:
|
|
9
|
+
*
|
|
10
|
+
* - **Per-property attributes**: any non-reserved attribute on the element maps to the script
|
|
11
|
+
* attribute of the same name (kebab-case to camelCase, e.g. `focus-point` → `focusPoint`).
|
|
12
|
+
* Values are parsed according to the type of the attribute's current value — initially the
|
|
13
|
+
* script's declared default (numbers, booleans, strings, Vec2/3/4, Color, Quat as Euler
|
|
14
|
+
* angles) — and the `asset:`/`entity:`/`vec2:`/`vec3:`/`vec4:`/`color:` prefixes may be used
|
|
15
|
+
* to be explicit.
|
|
16
|
+
* - **The `attributes` JSON attribute**: an object supporting nested structures and attribute
|
|
17
|
+
* names that collide with reserved HTML attribute names (e.g. `title`).
|
|
18
|
+
*
|
|
19
|
+
* When both specify the same attribute, the per-property attribute wins — at creation and
|
|
20
|
+
* whenever either channel changes at runtime. The element's own `name` and `enabled`
|
|
21
|
+
* attributes configure the element itself and are not script attributes.
|
|
22
|
+
*
|
|
23
|
+
* Changing `name` on a live element destroys the old-name script instance and creates the
|
|
24
|
+
* new-name one, re-applying both attribute channels to it.
|
|
25
|
+
*
|
|
26
|
+
* The element becomes ready once its script instance has been created by the parent
|
|
27
|
+
* `<pc-scripts>` element.
|
|
5
28
|
*/
|
|
6
|
-
declare class ScriptElement extends
|
|
29
|
+
declare class ScriptElement extends AsyncElement {
|
|
7
30
|
private _attributes;
|
|
8
31
|
private _enabled;
|
|
9
|
-
private _name;
|
|
10
32
|
/**
|
|
11
|
-
*
|
|
33
|
+
* Whether readiness has been signalled. Creation can happen more than once over an
|
|
34
|
+
* element's life (a runtime `name` change recreates the instance), but `ready` is a
|
|
35
|
+
* one-shot signal, so only the first successful creation fires it.
|
|
36
|
+
*/
|
|
37
|
+
private _readySignalled;
|
|
38
|
+
/**
|
|
39
|
+
* The Script instance created for this element by its parent `<pc-scripts>` element.
|
|
40
|
+
* @ignore
|
|
41
|
+
*/
|
|
42
|
+
_script: Script | null;
|
|
43
|
+
/**
|
|
44
|
+
* Sets the attributes of the script as an object. Values are converted with the same rules
|
|
45
|
+
* as the `attributes` attribute: `asset:`/`entity:` references and `vec2:`/`vec3:`/`vec4:`/
|
|
46
|
+
* `color:` prefixed strings are resolved, and a plain numeric array is converted to the
|
|
47
|
+
* type of the attribute it targets when that attribute currently holds a Vec2, Vec3, Vec4
|
|
48
|
+
* or Color.
|
|
12
49
|
* @param value - The attributes of the script.
|
|
13
50
|
*/
|
|
14
|
-
set scriptAttributes(value: string);
|
|
51
|
+
set scriptAttributes(value: Record<string, any>);
|
|
15
52
|
/**
|
|
16
53
|
* Gets the attributes of the script.
|
|
17
54
|
* @returns The attributes of the script.
|
|
18
55
|
*/
|
|
19
|
-
get scriptAttributes(): string
|
|
56
|
+
get scriptAttributes(): Record<string, any>;
|
|
20
57
|
/**
|
|
21
58
|
* Sets the enabled state of the script.
|
|
22
59
|
* @param value - The enabled state of the script.
|
|
@@ -28,7 +65,16 @@ declare class ScriptElement extends HTMLElement {
|
|
|
28
65
|
*/
|
|
29
66
|
get enabled(): boolean;
|
|
30
67
|
/**
|
|
31
|
-
* Sets the name of the script to create.
|
|
68
|
+
* Sets the name of the script to create. The `name` attribute is the single source of truth
|
|
69
|
+
* (it is what the parent `<pc-scripts>` element reads when creating the instance), so the
|
|
70
|
+
* property writes through to it — assigning before insertion works as expected:
|
|
71
|
+
*
|
|
72
|
+
* ```js
|
|
73
|
+
* const script = document.createElement('pc-script');
|
|
74
|
+
* script.name = 'rotate';
|
|
75
|
+
* scriptsElement.appendChild(script);
|
|
76
|
+
* await script.ready();
|
|
77
|
+
* ```
|
|
32
78
|
* @param value - The name.
|
|
33
79
|
*/
|
|
34
80
|
set name(value: string);
|
|
@@ -37,7 +83,25 @@ declare class ScriptElement extends HTMLElement {
|
|
|
37
83
|
* @returns The name.
|
|
38
84
|
*/
|
|
39
85
|
get name(): string;
|
|
86
|
+
/**
|
|
87
|
+
* Gets the {@link Script} instance created for this element. Returns `null` until the
|
|
88
|
+
* instance exists — await {@link whenReady} or the element's `ready()` promise before
|
|
89
|
+
* accessing it.
|
|
90
|
+
* @returns The script instance, or `null`.
|
|
91
|
+
*/
|
|
92
|
+
get script(): Script | null;
|
|
93
|
+
connectedCallback(): void;
|
|
94
|
+
/**
|
|
95
|
+
* Called by the parent `<pc-scripts>` element when the script instance has been created.
|
|
96
|
+
* @ignore
|
|
97
|
+
*/
|
|
98
|
+
_onScriptCreated(): void;
|
|
40
99
|
static get observedAttributes(): string[];
|
|
41
|
-
attributeChangedCallback(name: string,
|
|
100
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
101
|
+
}
|
|
102
|
+
declare global {
|
|
103
|
+
interface HTMLElementTagNameMap {
|
|
104
|
+
'pc-script': ScriptElement;
|
|
105
|
+
}
|
|
42
106
|
}
|
|
43
107
|
export { ScriptElement };
|
|
@@ -20,17 +20,18 @@ declare class ScrollbarComponentElement extends ComponentElement {
|
|
|
20
20
|
* Gets the underlying PlayCanvas scrollbar component.
|
|
21
21
|
* @returns The scrollbar component.
|
|
22
22
|
*/
|
|
23
|
-
get component(): ScrollbarComponent
|
|
23
|
+
get component(): ScrollbarComponent;
|
|
24
24
|
/**
|
|
25
|
-
* Sets the orientation of the scrollbar. Can be `horizontal`
|
|
25
|
+
* Sets the orientation of the scrollbar. Can be `horizontal` or `vertical`. Defaults to
|
|
26
|
+
* `horizontal`.
|
|
26
27
|
* @param value - The orientation.
|
|
27
28
|
*/
|
|
28
|
-
set orientation(value:
|
|
29
|
+
set orientation(value: 'horizontal' | 'vertical');
|
|
29
30
|
/**
|
|
30
31
|
* Gets the orientation of the scrollbar.
|
|
31
32
|
* @returns The orientation.
|
|
32
33
|
*/
|
|
33
|
-
get orientation():
|
|
34
|
+
get orientation(): "horizontal" | "vertical";
|
|
34
35
|
/**
|
|
35
36
|
* Sets the current position value of the scrollbar, in the range 0 to 1.
|
|
36
37
|
* @param value - The scrollbar value.
|
|
@@ -65,4 +66,9 @@ declare class ScrollbarComponentElement extends ComponentElement {
|
|
|
65
66
|
static get observedAttributes(): string[];
|
|
66
67
|
attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
|
|
67
68
|
}
|
|
69
|
+
declare global {
|
|
70
|
+
interface HTMLElementTagNameMap {
|
|
71
|
+
'pc-scrollbar': ScrollbarComponentElement;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
68
74
|
export { ScrollbarComponentElement };
|
|
@@ -29,7 +29,7 @@ declare class ScrollViewComponentElement extends ComponentElement {
|
|
|
29
29
|
* Gets the underlying PlayCanvas scroll view component.
|
|
30
30
|
* @returns The scroll view component.
|
|
31
31
|
*/
|
|
32
|
-
get component(): ScrollViewComponent
|
|
32
|
+
get component(): ScrollViewComponent;
|
|
33
33
|
/**
|
|
34
34
|
* Sets whether horizontal scrolling is enabled.
|
|
35
35
|
* @param value - Whether horizontal scrolling is enabled.
|
|
@@ -52,15 +52,15 @@ declare class ScrollViewComponentElement extends ComponentElement {
|
|
|
52
52
|
get vertical(): boolean;
|
|
53
53
|
/**
|
|
54
54
|
* Sets how the scroll view should behave when the content is scrolled beyond its bounds. Can be
|
|
55
|
-
* `clamp
|
|
55
|
+
* `clamp`, `bounce` or `infinite`. Defaults to `bounce`.
|
|
56
56
|
* @param value - The scroll mode.
|
|
57
57
|
*/
|
|
58
|
-
set scrollMode(value:
|
|
58
|
+
set scrollMode(value: 'clamp' | 'bounce' | 'infinite');
|
|
59
59
|
/**
|
|
60
60
|
* Gets how the scroll view behaves when the content is scrolled beyond its bounds.
|
|
61
61
|
* @returns The scroll mode.
|
|
62
62
|
*/
|
|
63
|
-
get scrollMode():
|
|
63
|
+
get scrollMode(): "clamp" | "bounce" | "infinite";
|
|
64
64
|
/**
|
|
65
65
|
* Sets how far the content is allowed to bounce beyond its bounds when `scroll-mode` is
|
|
66
66
|
* `bounce`, in the range 0 to 1.
|
|
@@ -104,25 +104,27 @@ declare class ScrollViewComponentElement extends ComponentElement {
|
|
|
104
104
|
*/
|
|
105
105
|
get mouseWheelSensitivity(): Vec2;
|
|
106
106
|
/**
|
|
107
|
-
* Sets the visibility of the horizontal scrollbar. Can be `always`
|
|
107
|
+
* Sets the visibility of the horizontal scrollbar. Can be `always` or `when-required`.
|
|
108
|
+
* Defaults to `when-required`.
|
|
108
109
|
* @param value - The horizontal scrollbar visibility.
|
|
109
110
|
*/
|
|
110
|
-
set horizontalScrollbarVisibility(value:
|
|
111
|
+
set horizontalScrollbarVisibility(value: 'always' | 'when-required');
|
|
111
112
|
/**
|
|
112
113
|
* Gets the visibility of the horizontal scrollbar.
|
|
113
114
|
* @returns The horizontal scrollbar visibility.
|
|
114
115
|
*/
|
|
115
|
-
get horizontalScrollbarVisibility():
|
|
116
|
+
get horizontalScrollbarVisibility(): "always" | "when-required";
|
|
116
117
|
/**
|
|
117
|
-
* Sets the visibility of the vertical scrollbar. Can be `always`
|
|
118
|
+
* Sets the visibility of the vertical scrollbar. Can be `always` or `when-required`.
|
|
119
|
+
* Defaults to `when-required`.
|
|
118
120
|
* @param value - The vertical scrollbar visibility.
|
|
119
121
|
*/
|
|
120
|
-
set verticalScrollbarVisibility(value:
|
|
122
|
+
set verticalScrollbarVisibility(value: 'always' | 'when-required');
|
|
121
123
|
/**
|
|
122
124
|
* Gets the visibility of the vertical scrollbar.
|
|
123
125
|
* @returns The vertical scrollbar visibility.
|
|
124
126
|
*/
|
|
125
|
-
get verticalScrollbarVisibility():
|
|
127
|
+
get verticalScrollbarVisibility(): "always" | "when-required";
|
|
126
128
|
/**
|
|
127
129
|
* Sets the reference (CSS selector, element id or entity name) to the `<pc-entity>` used as the
|
|
128
130
|
* viewport, which clips the content to the scroll view's bounds.
|
|
@@ -170,4 +172,9 @@ declare class ScrollViewComponentElement extends ComponentElement {
|
|
|
170
172
|
static get observedAttributes(): string[];
|
|
171
173
|
attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
|
|
172
174
|
}
|
|
175
|
+
declare global {
|
|
176
|
+
interface HTMLElementTagNameMap {
|
|
177
|
+
'pc-scrollview': ScrollViewComponentElement;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
173
180
|
export { ScrollViewComponentElement };
|
|
@@ -31,7 +31,7 @@ declare class SoundComponentElement extends ComponentElement {
|
|
|
31
31
|
* Gets the underlying PlayCanvas sound component.
|
|
32
32
|
* @returns The sound component.
|
|
33
33
|
*/
|
|
34
|
-
get component(): SoundComponent
|
|
34
|
+
get component(): SoundComponent;
|
|
35
35
|
/**
|
|
36
36
|
* Sets which algorithm to use to reduce the volume of the sound as it moves away from the listener.
|
|
37
37
|
* @param value - The distance model.
|
|
@@ -105,4 +105,9 @@ declare class SoundComponentElement extends ComponentElement {
|
|
|
105
105
|
static get observedAttributes(): string[];
|
|
106
106
|
attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
|
|
107
107
|
}
|
|
108
|
+
declare global {
|
|
109
|
+
interface HTMLElementTagNameMap {
|
|
110
|
+
'pc-sounds': SoundComponentElement;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
108
113
|
export { SoundComponentElement };
|
|
@@ -44,15 +44,15 @@ declare class SoundSlotElement extends AsyncElement {
|
|
|
44
44
|
*/
|
|
45
45
|
get autoPlay(): boolean;
|
|
46
46
|
/**
|
|
47
|
-
* Sets the duration of the sound slot.
|
|
47
|
+
* Sets the duration of the sound slot, in seconds (or `null` to play the whole clip).
|
|
48
48
|
* @param value - The duration.
|
|
49
49
|
*/
|
|
50
|
-
set duration(value: number);
|
|
50
|
+
set duration(value: number | null);
|
|
51
51
|
/**
|
|
52
52
|
* Gets the duration of the sound slot.
|
|
53
53
|
* @returns The duration.
|
|
54
54
|
*/
|
|
55
|
-
get duration(): number;
|
|
55
|
+
get duration(): number | null;
|
|
56
56
|
/**
|
|
57
57
|
* Sets the loop flag of the sound slot.
|
|
58
58
|
* @param value - The loop flag.
|
|
@@ -116,4 +116,9 @@ declare class SoundSlotElement extends AsyncElement {
|
|
|
116
116
|
static get observedAttributes(): string[];
|
|
117
117
|
attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
|
|
118
118
|
}
|
|
119
|
+
declare global {
|
|
120
|
+
interface HTMLElementTagNameMap {
|
|
121
|
+
'pc-sound': SoundSlotElement;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
119
124
|
export { SoundSlotElement };
|
package/dist/entity.d.ts
CHANGED
|
@@ -35,14 +35,21 @@ declare class EntityElement extends AsyncElement {
|
|
|
35
35
|
* The pointer event listeners for the entity.
|
|
36
36
|
*/
|
|
37
37
|
private _listeners;
|
|
38
|
+
/**
|
|
39
|
+
* The event types for which an inline `onpointer*` attribute is currently present.
|
|
40
|
+
*/
|
|
41
|
+
private _inlineHandlerTypes;
|
|
38
42
|
/**
|
|
39
43
|
* Whether the hierarchy has been built for this entity.
|
|
40
44
|
*/
|
|
41
45
|
private _built;
|
|
46
|
+
private _entity;
|
|
42
47
|
/**
|
|
43
|
-
* The PlayCanvas entity instance.
|
|
48
|
+
* The PlayCanvas entity instance. Available once the element is ready — await
|
|
49
|
+
* {@link whenReady} or the element's `ready()` promise before accessing it.
|
|
50
|
+
* @returns The entity instance.
|
|
44
51
|
*/
|
|
45
|
-
entity: Entity
|
|
52
|
+
get entity(): Entity;
|
|
46
53
|
createEntity(app: AppBase): void;
|
|
47
54
|
buildHierarchy(app: AppBase): void;
|
|
48
55
|
connectedCallback(): void;
|
|
@@ -107,10 +114,27 @@ declare class EntityElement extends AsyncElement {
|
|
|
107
114
|
* @returns The tags of the entity.
|
|
108
115
|
*/
|
|
109
116
|
get tags(): string[];
|
|
117
|
+
/**
|
|
118
|
+
* Tracks whether an inline `onpointer*` attribute is present. The browser itself compiles and
|
|
119
|
+
* runs these attributes — they are standard `GlobalEventHandlers`, so setting one replaces
|
|
120
|
+
* the previous handler and removing it removes the handler, exactly like `onclick` on any
|
|
121
|
+
* HTML element. But because they bypass {@link addEventListener}, the connect/disconnect
|
|
122
|
+
* bookkeeping that lets the application lazily attach its canvas pointer handlers must be
|
|
123
|
+
* kept in sync here.
|
|
124
|
+
*
|
|
125
|
+
* @param name - The attribute name (e.g. 'onpointerdown').
|
|
126
|
+
* @param value - The attribute value, or `null` when the attribute has been removed.
|
|
127
|
+
*/
|
|
128
|
+
private _updateInlineHandler;
|
|
110
129
|
static get observedAttributes(): string[];
|
|
111
130
|
attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
|
|
112
131
|
addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void;
|
|
113
132
|
removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void;
|
|
114
133
|
hasListeners(type: string): boolean;
|
|
115
134
|
}
|
|
135
|
+
declare global {
|
|
136
|
+
interface HTMLElementTagNameMap {
|
|
137
|
+
'pc-entity': EntityElement;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
116
140
|
export { EntityElement };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module EngineWebComponents
|
|
8
8
|
*/
|
|
9
|
-
import { AsyncElement } from './async-element';
|
|
9
|
+
import { AsyncElement, whenReady } from './async-element';
|
|
10
10
|
import { ModuleElement } from './module';
|
|
11
11
|
import { AppElement } from './app';
|
|
12
12
|
import { EntityElement } from './entity';
|
|
@@ -35,4 +35,5 @@ import { MaterialElement } from './material';
|
|
|
35
35
|
import { ModelElement } from './model';
|
|
36
36
|
import { SceneElement } from './scene';
|
|
37
37
|
import { SkyElement } from './sky';
|
|
38
|
-
export { AsyncElement, ModuleElement, AppElement, EntityElement, AssetElement, ButtonComponentElement, CameraComponentElement, CollisionComponentElement, ComponentElement, ElementComponentElement, LayoutChildComponentElement, LayoutGroupComponentElement, ParticleSystemComponentElement, LightComponentElement, ListenerComponentElement, RenderComponentElement, RigidBodyComponentElement, ScreenComponentElement, ScrollbarComponentElement, ScrollViewComponentElement, ScriptComponentElement, ScriptElement, SoundComponentElement, SoundSlotElement, GSplatComponentElement, MaterialElement, ModelElement, SceneElement, SkyElement };
|
|
38
|
+
export { AsyncElement, ModuleElement, AppElement, EntityElement, AssetElement, ButtonComponentElement, CameraComponentElement, CollisionComponentElement, ComponentElement, ElementComponentElement, LayoutChildComponentElement, LayoutGroupComponentElement, ParticleSystemComponentElement, LightComponentElement, ListenerComponentElement, RenderComponentElement, RigidBodyComponentElement, ScreenComponentElement, ScrollbarComponentElement, ScrollViewComponentElement, ScriptComponentElement, ScriptElement, SoundComponentElement, SoundSlotElement, GSplatComponentElement, MaterialElement, ModelElement, SceneElement, SkyElement, whenReady };
|
|
39
|
+
export type { AsyncElementTagName } from './async-element';
|
package/dist/material.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ import { Color, StandardMaterial } from 'playcanvas';
|
|
|
4
4
|
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-material/ | `<pc-material>`} elements.
|
|
5
5
|
* The MaterialElement interface also inherits the properties and methods of the
|
|
6
6
|
* {@link HTMLElement} interface.
|
|
7
|
+
*
|
|
8
|
+
* A `pc-material` must be a direct child of `pc-app` — elements placed elsewhere log a warning
|
|
9
|
+
* and never create a material. Elements inserted while the application is already running are
|
|
10
|
+
* created on insertion.
|
|
7
11
|
*/
|
|
8
12
|
declare class MaterialElement extends HTMLElement {
|
|
9
13
|
private _diffuse;
|
|
@@ -12,6 +16,7 @@ declare class MaterialElement extends HTMLElement {
|
|
|
12
16
|
private _normalMap;
|
|
13
17
|
private _roughnessMap;
|
|
14
18
|
material: StandardMaterial | null;
|
|
19
|
+
connectedCallback(): Promise<void>;
|
|
15
20
|
createMaterial(): void;
|
|
16
21
|
disconnectedCallback(): void;
|
|
17
22
|
setMap(map: string, property: 'diffuseMap' | 'metalnessMap' | 'normalMap' | 'glossMap'): void;
|
|
@@ -29,4 +34,9 @@ declare class MaterialElement extends HTMLElement {
|
|
|
29
34
|
static get observedAttributes(): string[];
|
|
30
35
|
attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
|
|
31
36
|
}
|
|
37
|
+
declare global {
|
|
38
|
+
interface HTMLElementTagNameMap {
|
|
39
|
+
'pc-material': MaterialElement;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
32
42
|
export { MaterialElement };
|
package/dist/model.d.ts
CHANGED
|
@@ -26,4 +26,9 @@ declare class ModelElement extends AsyncElement {
|
|
|
26
26
|
static get observedAttributes(): string[];
|
|
27
27
|
attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
|
|
28
28
|
}
|
|
29
|
+
declare global {
|
|
30
|
+
interface HTMLElementTagNameMap {
|
|
31
|
+
'pc-model': ModelElement;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
29
34
|
export { ModelElement };
|
package/dist/module.d.ts
CHANGED