@playcanvas/web-components 0.9.0 → 0.10.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 +18 -0
- package/dist/app.d.ts +3 -2
- package/dist/asset.d.ts +16 -1
- package/dist/async-element.d.ts +3 -0
- package/dist/components/button-component.d.ts +1 -1
- package/dist/components/camera-component.d.ts +1 -1
- package/dist/components/collision-component.d.ts +1 -1
- package/dist/components/component.d.ts +1 -1
- package/dist/components/element-component.d.ts +1 -1
- package/dist/components/gsplat-component.d.ts +1 -1
- package/dist/components/layoutchild-component.d.ts +1 -1
- package/dist/components/layoutgroup-component.d.ts +1 -1
- package/dist/components/light-component.d.ts +1 -1
- package/dist/components/particlesystem-component.d.ts +1 -1
- package/dist/components/render-component.d.ts +1 -1
- package/dist/components/rigidbody-component.d.ts +1 -1
- package/dist/components/screen-component.d.ts +1 -1
- package/dist/components/script.d.ts +8 -1
- package/dist/components/scrollbar-component.d.ts +1 -1
- package/dist/components/scrollview-component.d.ts +1 -1
- package/dist/components/sound-component.d.ts +1 -1
- package/dist/components/sound-slot.d.ts +9 -1
- package/dist/custom-elements.json +16231 -0
- package/dist/entity.d.ts +19 -1
- package/dist/material.d.ts +966 -4
- package/dist/model.d.ts +1 -1
- package/dist/module.d.ts +10 -0
- package/dist/{utils.d.ts → parse.d.ts} +63 -33
- package/dist/pwc.cjs +2677 -586
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +2677 -586
- 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 +2 -0
- package/dist/pwc.min.mjs.map +1 -0
- package/dist/pwc.mjs +2678 -587
- package/dist/pwc.mjs.map +1 -1
- package/dist/scene.d.ts +1 -1
- package/dist/sky.d.ts +1 -1
- package/dist/vscode.html-custom-data.json +1795 -0
- package/dist/web-types.json +3592 -0
- package/package.json +29 -11
- package/src/app.ts +6 -5
- package/src/asset.ts +19 -2
- package/src/async-element.ts +3 -0
- package/src/components/button-component.ts +6 -6
- package/src/components/camera-component.ts +2 -2
- package/src/components/collision-component.ts +2 -2
- package/src/components/component.ts +2 -2
- package/src/components/element-component.ts +6 -6
- package/src/components/gsplat-component.ts +3 -3
- package/src/components/layoutchild-component.ts +2 -2
- package/src/components/layoutgroup-component.ts +2 -2
- package/src/components/light-component.ts +2 -2
- package/src/components/particlesystem-component.ts +2 -2
- package/src/components/render-component.ts +10 -5
- package/src/components/rigidbody-component.ts +2 -2
- package/src/components/screen-component.ts +2 -2
- package/src/components/script-component.ts +4 -4
- package/src/components/script.ts +9 -2
- package/src/components/scrollbar-component.ts +3 -3
- package/src/components/scrollview-component.ts +6 -6
- package/src/components/sound-component.ts +2 -2
- package/src/components/sound-slot.ts +31 -9
- package/src/entity.ts +25 -7
- package/src/material.ts +2396 -59
- package/src/model.ts +2 -2
- package/src/module.ts +10 -0
- package/src/{utils.ts → parse.ts} +104 -65
- package/src/scene.ts +2 -2
- package/src/sky.ts +3 -3
package/dist/model.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ declare class ModelElement extends AsyncElement {
|
|
|
24
24
|
*/
|
|
25
25
|
get asset(): string;
|
|
26
26
|
static get observedAttributes(): string[];
|
|
27
|
-
attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
|
|
27
|
+
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
|
|
28
28
|
}
|
|
29
29
|
declare global {
|
|
30
30
|
interface HTMLElementTagNameMap {
|
package/dist/module.d.ts
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-module/ | `<pc-module>`} elements.
|
|
4
4
|
* The ModuleElement interface also inherits the properties and methods of the
|
|
5
5
|
* {@link HTMLElement} interface.
|
|
6
|
+
*
|
|
7
|
+
* Note that these attributes are read once when the element is created, so changing them later
|
|
8
|
+
* has no effect.
|
|
9
|
+
*
|
|
10
|
+
* @attribute {string} name - The name of the WebAssembly module to configure, e.g. `Basis` or
|
|
11
|
+
* `Ammo`.
|
|
12
|
+
* @attribute {string} glue - The URL of the module's glue script.
|
|
13
|
+
* @attribute {string} wasm - The URL of the module's WebAssembly binary.
|
|
14
|
+
* @attribute {string} fallback - The URL of the module's asm.js fallback script, used when
|
|
15
|
+
* WebAssembly is unavailable.
|
|
6
16
|
*/
|
|
7
17
|
declare class ModuleElement extends HTMLElement {
|
|
8
18
|
private loadPromise;
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import { Color, Entity, Quat, Vec2, Vec3, Vec4 } from 'playcanvas';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* Converts HTML attribute values into the values the engine expects. Every element's
|
|
3
|
+
* `attributeChangedCallback` funnels through this module.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* - Attribute set to the string 'false': `false`.
|
|
7
|
-
* - Attribute present with any other value, including the empty string of a bare boolean
|
|
8
|
-
* attribute (e.g. `<pc-light cast-shadows>`): `true`.
|
|
5
|
+
* The parsers share one contract:
|
|
9
6
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
7
|
+
* - A `null` value means the attribute is absent or was removed, and yields the supplied default.
|
|
8
|
+
* - A malformed value yields the same default and logs exactly one `console.warn` naming the
|
|
9
|
+
* attribute, so misuse is reported rather than thrown — nothing here throws or rejects.
|
|
10
|
+
* - A math-type default is cloned on the way out, which is what makes it safe to pass the engine's
|
|
11
|
+
* shared frozen constants (`Vec3.ZERO`, `Color.WHITE`) as defaults.
|
|
12
|
+
* - `parseBool` and `parseTags` take no attribute name, because every value is valid for them and
|
|
13
|
+
* so they never warn.
|
|
14
|
+
*
|
|
15
|
+
* `getEntity` is the exception: it resolves a reference to a live entity rather than parsing a
|
|
16
|
+
* literal, and returns `null` instead of falling back to a default.
|
|
13
17
|
*/
|
|
14
|
-
|
|
18
|
+
import { Color, Entity, Quat, Vec2, Vec3, Vec4 } from 'playcanvas';
|
|
15
19
|
/**
|
|
16
20
|
* Splits an attribute value into exactly `count` numeric components. Returns `null` when the
|
|
17
21
|
* value does not consist of exactly `count` whitespace-separated finite numbers.
|
|
@@ -22,6 +26,19 @@ export declare const parseBool: (value: string | null, defaultValue: boolean) =>
|
|
|
22
26
|
* @ignore
|
|
23
27
|
*/
|
|
24
28
|
export declare const parseComponents: (value: string, count: number) => number[] | null;
|
|
29
|
+
/**
|
|
30
|
+
* Parse a boolean attribute value. The same rules apply to every boolean attribute:
|
|
31
|
+
*
|
|
32
|
+
* - Attribute absent (or removed): the supplied default is used.
|
|
33
|
+
* - Attribute set to the string 'false': `false`.
|
|
34
|
+
* - Attribute present with any other value, including the empty string of a bare boolean
|
|
35
|
+
* attribute (e.g. `<pc-light cast-shadows>`): `true`.
|
|
36
|
+
*
|
|
37
|
+
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
38
|
+
* @param defaultValue - The value to use when the attribute is absent or removed.
|
|
39
|
+
* @returns The parsed boolean.
|
|
40
|
+
*/
|
|
41
|
+
export declare const parseBool: (value: string | null, defaultValue: boolean) => boolean;
|
|
25
42
|
/**
|
|
26
43
|
* Parse a color attribute value. The expected format is a CSS color name (e.g. 'rebeccapurple'),
|
|
27
44
|
* a hex color (e.g. '#ff0000' or '#f00'), or 3 or 4 space-separated numbers in the range 0 to 1
|
|
@@ -35,6 +52,29 @@ export declare const parseComponents: (value: string, count: number) => number[]
|
|
|
35
52
|
* @returns The parsed Color object.
|
|
36
53
|
*/
|
|
37
54
|
export declare const parseColor: <T extends Color | null>(value: string | null, defaultValue: T, attribute: string) => Color | T;
|
|
55
|
+
/**
|
|
56
|
+
* Resolves an enum attribute value against its set of valid names. Returns the value when it is
|
|
57
|
+
* one of the valid names. Returns `defaultValue` when the attribute is absent (`null`), or when
|
|
58
|
+
* the value is invalid — the latter also logs a warning listing the valid names.
|
|
59
|
+
*
|
|
60
|
+
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
61
|
+
* @param valid - The valid names: an array, or a map whose keys are the valid names.
|
|
62
|
+
* @param defaultValue - The value to use when the attribute is absent or invalid.
|
|
63
|
+
* @param attribute - The attribute name, used in the warning message.
|
|
64
|
+
* @returns The resolved enum name.
|
|
65
|
+
*/
|
|
66
|
+
export declare const parseEnum: <T extends string>(value: string | null, valid: readonly T[] | ReadonlyMap<T, number>, defaultValue: T, attribute: string) => T;
|
|
67
|
+
/**
|
|
68
|
+
* Parses a number attribute value. Returns the parsed number when the value is a finite number.
|
|
69
|
+
* Returns `defaultValue` when the attribute is absent (`null`), or when the value is not a
|
|
70
|
+
* finite number — the latter also logs a warning.
|
|
71
|
+
*
|
|
72
|
+
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
73
|
+
* @param defaultValue - The value to use when the attribute is absent or invalid.
|
|
74
|
+
* @param attribute - The attribute name, used in the warning message.
|
|
75
|
+
* @returns The parsed number.
|
|
76
|
+
*/
|
|
77
|
+
export declare const parseNumber: <T extends number | null>(value: string | null, defaultValue: T, attribute: string) => number | T;
|
|
38
78
|
/**
|
|
39
79
|
* Parse an Euler-angles attribute value into a quaternion. The expected format is 3
|
|
40
80
|
* space-separated angles in degrees (e.g. '0 90 0'). Returns `defaultValue` (cloned, when it is
|
|
@@ -47,6 +87,19 @@ export declare const parseColor: <T extends Color | null>(value: string | null,
|
|
|
47
87
|
* @returns The parsed Quat object.
|
|
48
88
|
*/
|
|
49
89
|
export declare const parseQuat: <T extends Quat | null>(value: string | null, defaultValue: T, attribute: string) => Quat | T;
|
|
90
|
+
/**
|
|
91
|
+
* Parse a tags attribute value. The expected format is a comma-separated list of tag names
|
|
92
|
+
* (e.g. 'enemy, flying'). Surrounding whitespace is trimmed from each name and empty names are
|
|
93
|
+
* discarded, so a trailing comma or a doubled separator does not produce a blank tag. Returns a
|
|
94
|
+
* copy of `defaultValue` when the attribute is absent or removed (`null`).
|
|
95
|
+
*
|
|
96
|
+
* Every value is valid, so this never warns.
|
|
97
|
+
*
|
|
98
|
+
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
99
|
+
* @param defaultValue - The value to use when the attribute is absent or removed.
|
|
100
|
+
* @returns The parsed tag names.
|
|
101
|
+
*/
|
|
102
|
+
export declare const parseTags: (value: string | null, defaultValue?: string[]) => string[];
|
|
50
103
|
/**
|
|
51
104
|
* Parse a Vec2 attribute value. The expected format is 2 space-separated numbers (e.g. '1 2').
|
|
52
105
|
* Returns `defaultValue` (cloned, when it is a vector) when the attribute is absent (`null`),
|
|
@@ -80,29 +133,6 @@ export declare const parseVec3: <T extends Vec3 | null>(value: string | null, de
|
|
|
80
133
|
* @returns The parsed Vec4 object.
|
|
81
134
|
*/
|
|
82
135
|
export declare const parseVec4: <T extends Vec4 | null>(value: string | null, defaultValue: T, attribute: string) => Vec4 | T;
|
|
83
|
-
/**
|
|
84
|
-
* Resolves an enum attribute value against its set of valid names. Returns the value when it is
|
|
85
|
-
* one of the valid names. Returns `defaultValue` when the attribute is absent (`null`), or when
|
|
86
|
-
* the value is invalid — the latter also logs a warning listing the valid names.
|
|
87
|
-
*
|
|
88
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
89
|
-
* @param valid - The valid names: an array, or a map whose keys are the valid names.
|
|
90
|
-
* @param defaultValue - The value to use when the attribute is absent or invalid.
|
|
91
|
-
* @param attribute - The attribute name, used in the warning message.
|
|
92
|
-
* @returns The resolved enum name.
|
|
93
|
-
*/
|
|
94
|
-
export declare const parseEnum: <T extends string>(value: string | null, valid: readonly T[] | ReadonlyMap<T, number>, defaultValue: T, attribute: string) => T;
|
|
95
|
-
/**
|
|
96
|
-
* Parses a number attribute value. Returns the parsed number when the value is a finite number.
|
|
97
|
-
* Returns `defaultValue` when the attribute is absent (`null`), or when the value is not a
|
|
98
|
-
* finite number — the latter also logs a warning.
|
|
99
|
-
*
|
|
100
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
101
|
-
* @param defaultValue - The value to use when the attribute is absent or invalid.
|
|
102
|
-
* @param attribute - The attribute name, used in the warning message.
|
|
103
|
-
* @returns The parsed number.
|
|
104
|
-
*/
|
|
105
|
-
export declare const parseNumber: <T extends number | null>(value: string | null, defaultValue: T, attribute: string) => number | T;
|
|
106
136
|
/**
|
|
107
137
|
* Resolves a reference string to the {@link Entity} backing a `<pc-entity>` element. The reference
|
|
108
138
|
* can be a CSS selector (e.g. `#my-id`, `pc-entity[name="Foo"]`), a bare element id, or a bare
|