@playcanvas/web-components 0.13.1 → 0.14.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/colors.d.cts +1 -1
- package/dist/colors.d.ts +1 -1
- package/dist/custom-elements.json +113 -0
- package/dist/entity-base.d.cts +1 -7
- package/dist/entity-base.d.ts +1 -7
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/loading-bar.d.cts +1 -35
- package/dist/loading-bar.d.ts +1 -35
- package/dist/material.d.cts +13 -0
- package/dist/material.d.ts +13 -0
- package/dist/model.d.cts +71 -0
- package/dist/model.d.ts +71 -0
- package/dist/node.d.cts +55 -0
- package/dist/node.d.ts +55 -0
- package/dist/parse.d.cts +1 -130
- package/dist/parse.d.ts +1 -130
- package/dist/pwc.cjs +362 -3
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +362 -3
- 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 +362 -3
- package/dist/pwc.mjs.map +1 -1
- package/dist/vscode.html-custom-data.json +11 -1
- package/dist/web-types.json +21 -2
- package/package.json +3 -3
- package/src/colors.ts +5 -0
- package/src/entity-base.ts +3 -3
- package/src/index.ts +2 -0
- package/src/loading-bar.ts +2 -3
- package/src/material.ts +29 -0
- package/src/model.ts +156 -0
- package/src/node.ts +277 -2
- package/src/parse.ts +11 -1
package/dist/node.d.ts
CHANGED
|
@@ -7,6 +7,13 @@ import { EntityBaseElement } from './entity-base.js';
|
|
|
7
7
|
* naming the cause.
|
|
8
8
|
*/
|
|
9
9
|
type NodeBindingState = 'pending' | 'bound' | 'missing' | 'ambiguous' | 'duplicate';
|
|
10
|
+
/**
|
|
11
|
+
* A sparse mapping from selector to `pc-material` id, as carried by the `material-overrides`
|
|
12
|
+
* attribute and `materialOverrides` property. A `name:X` key selects every mesh instance of the
|
|
13
|
+
* bound node's render component whose baseline material is named `X`; an `index:N` key selects
|
|
14
|
+
* mesh instance `N` and wins over a name rule for the same instance.
|
|
15
|
+
*/
|
|
16
|
+
type MaterialOverrides = Readonly<Record<string, string>>;
|
|
10
17
|
/**
|
|
11
18
|
* The NodeElement interface provides properties and methods for manipulating
|
|
12
19
|
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-node/ | `<pc-node>`}
|
|
@@ -41,6 +48,13 @@ type NodeBindingState = 'pending' | 'bound' | 'missing' | 'ambiguous' | 'duplica
|
|
|
41
48
|
* "x y z" triple.
|
|
42
49
|
* @attribute {string} scale - Overrides the node's local scale, as an "x y z" triple.
|
|
43
50
|
* @attribute {string} tags - Overrides the node's tags, separated by spaces or commas.
|
|
51
|
+
* @attribute {string} material-overrides - Overrides material assignments on the bound node's
|
|
52
|
+
* render component, as a JSON object from selector to `pc-material` id — for example
|
|
53
|
+
* `{"name:CarPaint": "candy-red", "index:7": "smoked-glass"}`. A `name:X` key selects every mesh
|
|
54
|
+
* instance whose baseline material is named `X`; an `index:N` key selects mesh instance `N` and
|
|
55
|
+
* wins over a name rule for the same instance. Assignments no rule matches keep their baseline
|
|
56
|
+
* materials, and removing the attribute restores all of them. Use `pc-model.hierarchy()` to
|
|
57
|
+
* discover the names and indices a node offers.
|
|
44
58
|
* @attribute {string} onpointerenter - Script to run when the pointer moves onto the node.
|
|
45
59
|
* @attribute {string} onpointerleave - Script to run when the pointer moves off the node.
|
|
46
60
|
* @attribute {string} onpointermove - Script to run when the pointer moves over the node.
|
|
@@ -76,11 +90,24 @@ declare class NodeElement extends EntityBaseElement {
|
|
|
76
90
|
private _destroyHandle;
|
|
77
91
|
/** The authored values displaced by this element's overrides, captured per property. */
|
|
78
92
|
private _authored;
|
|
93
|
+
/**
|
|
94
|
+
* The model-authored render component of the bound node, recorded at bind — before child
|
|
95
|
+
* decorations build — so a render component added later by a child `pc-render` can never
|
|
96
|
+
* become the override target. `null` when the bound node has none.
|
|
97
|
+
*/
|
|
98
|
+
private _authoredRender;
|
|
99
|
+
/**
|
|
100
|
+
* The baseline assignments displaced by the material overrides, captured for every mesh
|
|
101
|
+
* instance when the first non-empty mapping applies and released when the mapping goes
|
|
102
|
+
* absent (restoring them) or the binding dissolves.
|
|
103
|
+
*/
|
|
104
|
+
private _baseline;
|
|
79
105
|
private _enabled;
|
|
80
106
|
private _position;
|
|
81
107
|
private _rotation;
|
|
82
108
|
private _scale;
|
|
83
109
|
private _tags;
|
|
110
|
+
private _materialOverrides;
|
|
84
111
|
/**
|
|
85
112
|
* The binding state: `pending` until the host instantiates and `name` resolves, `bound`
|
|
86
113
|
* once decorated, `missing`/`ambiguous`/`duplicate` when resolution failed (each also
|
|
@@ -149,6 +176,19 @@ declare class NodeElement extends EntityBaseElement {
|
|
|
149
176
|
* themselves are kept - they re-apply on the next binding.
|
|
150
177
|
*/
|
|
151
178
|
private _revertOverrides;
|
|
179
|
+
/**
|
|
180
|
+
* Applies the material mapping to the authored render component: parse the mapping's valid
|
|
181
|
+
* rules, capture the baseline on first application, then recompute every assignment from
|
|
182
|
+
* that baseline - name rules write over it, index rules write over them, so `index:` wins -
|
|
183
|
+
* and assign whatever changed. An absent mapping, or one with no valid rules, restores the
|
|
184
|
+
* baseline instead. Called while bound, from `_applyOverrides` and the property setter.
|
|
185
|
+
*/
|
|
186
|
+
private _applyMaterialOverrides;
|
|
187
|
+
/**
|
|
188
|
+
* Restores every baseline assignment the material overrides displaced and releases the
|
|
189
|
+
* capture, so the next non-empty mapping captures afresh. Safe to call without a capture.
|
|
190
|
+
*/
|
|
191
|
+
private _restoreBaseline;
|
|
152
192
|
/**
|
|
153
193
|
* Renders the path of `node` below `root`, for the `path` property and the resolution
|
|
154
194
|
* warnings.
|
|
@@ -247,7 +287,22 @@ declare class NodeElement extends EntityBaseElement {
|
|
|
247
287
|
* @returns The tags, or `null` while no override is set.
|
|
248
288
|
*/
|
|
249
289
|
get tags(): string[] | null;
|
|
290
|
+
/**
|
|
291
|
+
* Sets the material overrides: a sparse mapping from selector to `pc-material` id, applied
|
|
292
|
+
* to the bound node's authored render component. A `name:X` key selects every mesh instance
|
|
293
|
+
* whose baseline material is named `X`; an `index:N` key selects mesh instance `N` and wins
|
|
294
|
+
* over a name rule for the same instance. Assignments no rule matches keep their baseline
|
|
295
|
+
* materials. `null` clears the mapping, restoring every baseline assignment.
|
|
296
|
+
* @param value - The mapping, or `null`.
|
|
297
|
+
*/
|
|
298
|
+
set materialOverrides(value: MaterialOverrides | null);
|
|
299
|
+
/**
|
|
300
|
+
* Gets the material overrides.
|
|
301
|
+
* @returns The mapping, or `null` while no override is set.
|
|
302
|
+
*/
|
|
303
|
+
get materialOverrides(): MaterialOverrides | null;
|
|
250
304
|
static get observedAttributes(): string[];
|
|
251
305
|
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
|
|
252
306
|
}
|
|
253
307
|
export { NodeElement };
|
|
308
|
+
export type { MaterialOverrides };
|
package/dist/parse.d.cts
CHANGED
|
@@ -15,133 +15,4 @@
|
|
|
15
15
|
* `getEntity` is the exception: it resolves a reference to a live entity rather than parsing a
|
|
16
16
|
* literal, and returns `null` instead of falling back to a default.
|
|
17
17
|
*/
|
|
18
|
-
|
|
19
|
-
import { Color, Quat, Vec2, Vec3, Vec4 } from 'playcanvas';
|
|
20
|
-
/**
|
|
21
|
-
* Splits an attribute value into exactly `count` numeric components. Returns `null` when the
|
|
22
|
-
* value does not consist of exactly `count` whitespace-separated finite numbers.
|
|
23
|
-
*
|
|
24
|
-
* @param value - The value to split.
|
|
25
|
-
* @param count - The required number of components.
|
|
26
|
-
* @returns The parsed components, or `null`.
|
|
27
|
-
* @ignore
|
|
28
|
-
*/
|
|
29
|
-
export declare const parseComponents: (value: string, count: number) => number[] | null;
|
|
30
|
-
/**
|
|
31
|
-
* Parse a boolean attribute value. The same rules apply to every boolean attribute:
|
|
32
|
-
*
|
|
33
|
-
* - Attribute absent (or removed): the supplied default is used.
|
|
34
|
-
* - Attribute set to the string 'false': `false`.
|
|
35
|
-
* - Attribute present with any other value, including the empty string of a bare boolean
|
|
36
|
-
* attribute (e.g. `<pc-light cast-shadows>`): `true`.
|
|
37
|
-
*
|
|
38
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
39
|
-
* @param defaultValue - The value to use when the attribute is absent or removed.
|
|
40
|
-
* @returns The parsed boolean.
|
|
41
|
-
*/
|
|
42
|
-
export declare const parseBool: (value: string | null, defaultValue: boolean) => boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Parse a color attribute value. The expected format is a CSS color name (e.g. 'rebeccapurple'),
|
|
45
|
-
* a hex color (e.g. '#ff0000' or '#f00'), or 3 or 4 space-separated numbers in the range 0 to 1
|
|
46
|
-
* (e.g. '1 0.5 0.5' or '1 0.5 0.5 0.5'). Returns `defaultValue` (cloned, when it is a color)
|
|
47
|
-
* when the attribute is absent (`null`), or when the value is malformed — the latter also logs
|
|
48
|
-
* a warning.
|
|
49
|
-
*
|
|
50
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
51
|
-
* @param defaultValue - The value to use when the attribute is absent or invalid.
|
|
52
|
-
* @param attribute - The attribute name, used in the warning message.
|
|
53
|
-
* @returns The parsed Color object.
|
|
54
|
-
*/
|
|
55
|
-
export declare const parseColor: <T extends Color | null>(value: string | null, defaultValue: T, attribute: string) => Color | T;
|
|
56
|
-
/**
|
|
57
|
-
* Resolves an enum attribute value against its set of valid names. Returns the value when it is
|
|
58
|
-
* one of the valid names. Returns `defaultValue` when the attribute is absent (`null`), or when
|
|
59
|
-
* the value is invalid — the latter also logs a warning listing the valid names.
|
|
60
|
-
*
|
|
61
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
62
|
-
* @param valid - The valid names: an array, or a map whose keys are the valid names. Only the keys
|
|
63
|
-
* are read, so the map's value type is unconstrained - engine enums are mostly numeric constants,
|
|
64
|
-
* but some (e.g. `SCALEMODE_BLEND`) are strings.
|
|
65
|
-
* @param defaultValue - The value to use when the attribute is absent or invalid.
|
|
66
|
-
* @param attribute - The attribute name, used in the warning message.
|
|
67
|
-
* @returns The resolved enum name.
|
|
68
|
-
*/
|
|
69
|
-
export declare const parseEnum: <T extends string>(value: string | null, valid: readonly T[] | ReadonlyMap<T, unknown>, defaultValue: T, attribute: string) => T;
|
|
70
|
-
/**
|
|
71
|
-
* Parses a number attribute value. Returns the parsed number when the value is a finite number.
|
|
72
|
-
* Returns `defaultValue` when the attribute is absent (`null`), or when the value is not a
|
|
73
|
-
* finite number — the latter also logs a warning.
|
|
74
|
-
*
|
|
75
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
76
|
-
* @param defaultValue - The value to use when the attribute is absent or invalid.
|
|
77
|
-
* @param attribute - The attribute name, used in the warning message.
|
|
78
|
-
* @returns The parsed number.
|
|
79
|
-
*/
|
|
80
|
-
export declare const parseNumber: <T extends number | null>(value: string | null, defaultValue: T, attribute: string) => number | T;
|
|
81
|
-
/**
|
|
82
|
-
* Parse an Euler-angles attribute value into a quaternion. The expected format is 3
|
|
83
|
-
* space-separated angles in degrees (e.g. '0 90 0'). Returns `defaultValue` (cloned, when it is
|
|
84
|
-
* a quaternion) when the attribute is absent (`null`), or when the value is malformed — the
|
|
85
|
-
* latter also logs a warning.
|
|
86
|
-
*
|
|
87
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
88
|
-
* @param defaultValue - The value to use when the attribute is absent or invalid.
|
|
89
|
-
* @param attribute - The attribute name, used in the warning message.
|
|
90
|
-
* @returns The parsed Quat object.
|
|
91
|
-
*/
|
|
92
|
-
export declare const parseQuat: <T extends Quat | null>(value: string | null, defaultValue: T, attribute: string) => Quat | T;
|
|
93
|
-
/**
|
|
94
|
-
* Parse a tags attribute value. The expected format is a comma-separated list of tag names
|
|
95
|
-
* (e.g. 'enemy, flying'). Surrounding whitespace is trimmed from each name and empty names are
|
|
96
|
-
* discarded, so a trailing comma or a doubled separator does not produce a blank tag. Returns a
|
|
97
|
-
* copy of `defaultValue` when the attribute is absent or removed (`null`).
|
|
98
|
-
*
|
|
99
|
-
* Every value is valid, so this never warns.
|
|
100
|
-
*
|
|
101
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
102
|
-
* @param defaultValue - The value to use when the attribute is absent or removed.
|
|
103
|
-
* @returns The parsed tag names.
|
|
104
|
-
*/
|
|
105
|
-
export declare const parseTags: (value: string | null, defaultValue?: string[]) => string[];
|
|
106
|
-
/**
|
|
107
|
-
* Parse a Vec2 attribute value. The expected format is 2 space-separated numbers (e.g. '1 2').
|
|
108
|
-
* Returns `defaultValue` (cloned, when it is a vector) when the attribute is absent (`null`),
|
|
109
|
-
* or when the value is malformed — the latter also logs a warning.
|
|
110
|
-
*
|
|
111
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
112
|
-
* @param defaultValue - The value to use when the attribute is absent or invalid.
|
|
113
|
-
* @param attribute - The attribute name, used in the warning message.
|
|
114
|
-
* @returns The parsed Vec2 object.
|
|
115
|
-
*/
|
|
116
|
-
export declare const parseVec2: <T extends Vec2 | null>(value: string | null, defaultValue: T, attribute: string) => Vec2 | T;
|
|
117
|
-
/**
|
|
118
|
-
* Parse a Vec3 attribute value. The expected format is 3 space-separated numbers (e.g. '1 2 3').
|
|
119
|
-
* Returns `defaultValue` (cloned, when it is a vector) when the attribute is absent (`null`),
|
|
120
|
-
* or when the value is malformed — the latter also logs a warning.
|
|
121
|
-
*
|
|
122
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
123
|
-
* @param defaultValue - The value to use when the attribute is absent or invalid.
|
|
124
|
-
* @param attribute - The attribute name, used in the warning message.
|
|
125
|
-
* @returns The parsed Vec3 object.
|
|
126
|
-
*/
|
|
127
|
-
export declare const parseVec3: <T extends Vec3 | null>(value: string | null, defaultValue: T, attribute: string) => Vec3 | T;
|
|
128
|
-
/**
|
|
129
|
-
* Parse a Vec4 attribute value. The expected format is 4 space-separated numbers
|
|
130
|
-
* (e.g. '1 2 3 4'). Returns `defaultValue` (cloned, when it is a vector) when the attribute is
|
|
131
|
-
* absent (`null`), or when the value is malformed — the latter also logs a warning.
|
|
132
|
-
*
|
|
133
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
134
|
-
* @param defaultValue - The value to use when the attribute is absent or invalid.
|
|
135
|
-
* @param attribute - The attribute name, used in the warning message.
|
|
136
|
-
* @returns The parsed Vec4 object.
|
|
137
|
-
*/
|
|
138
|
-
export declare const parseVec4: <T extends Vec4 | null>(value: string | null, defaultValue: T, attribute: string) => Vec4 | T;
|
|
139
|
-
/**
|
|
140
|
-
* Resolves a reference string to the {@link Entity} backing a `<pc-entity>` element. The reference
|
|
141
|
-
* can be a CSS selector (e.g. `#my-id`, `pc-entity[name="Foo"]`), a bare element id, or a bare
|
|
142
|
-
* entity name. Returns `null` if no matching element (or backing entity) is found.
|
|
143
|
-
*
|
|
144
|
-
* @param ref - The reference string to resolve.
|
|
145
|
-
* @returns The resolved entity, or `null`.
|
|
146
|
-
*/
|
|
147
|
-
export declare const getEntity: (ref: string) => Entity | null;
|
|
18
|
+
export {};
|
package/dist/parse.d.ts
CHANGED
|
@@ -15,133 +15,4 @@
|
|
|
15
15
|
* `getEntity` is the exception: it resolves a reference to a live entity rather than parsing a
|
|
16
16
|
* literal, and returns `null` instead of falling back to a default.
|
|
17
17
|
*/
|
|
18
|
-
|
|
19
|
-
import { Color, Quat, Vec2, Vec3, Vec4 } from 'playcanvas';
|
|
20
|
-
/**
|
|
21
|
-
* Splits an attribute value into exactly `count` numeric components. Returns `null` when the
|
|
22
|
-
* value does not consist of exactly `count` whitespace-separated finite numbers.
|
|
23
|
-
*
|
|
24
|
-
* @param value - The value to split.
|
|
25
|
-
* @param count - The required number of components.
|
|
26
|
-
* @returns The parsed components, or `null`.
|
|
27
|
-
* @ignore
|
|
28
|
-
*/
|
|
29
|
-
export declare const parseComponents: (value: string, count: number) => number[] | null;
|
|
30
|
-
/**
|
|
31
|
-
* Parse a boolean attribute value. The same rules apply to every boolean attribute:
|
|
32
|
-
*
|
|
33
|
-
* - Attribute absent (or removed): the supplied default is used.
|
|
34
|
-
* - Attribute set to the string 'false': `false`.
|
|
35
|
-
* - Attribute present with any other value, including the empty string of a bare boolean
|
|
36
|
-
* attribute (e.g. `<pc-light cast-shadows>`): `true`.
|
|
37
|
-
*
|
|
38
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
39
|
-
* @param defaultValue - The value to use when the attribute is absent or removed.
|
|
40
|
-
* @returns The parsed boolean.
|
|
41
|
-
*/
|
|
42
|
-
export declare const parseBool: (value: string | null, defaultValue: boolean) => boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Parse a color attribute value. The expected format is a CSS color name (e.g. 'rebeccapurple'),
|
|
45
|
-
* a hex color (e.g. '#ff0000' or '#f00'), or 3 or 4 space-separated numbers in the range 0 to 1
|
|
46
|
-
* (e.g. '1 0.5 0.5' or '1 0.5 0.5 0.5'). Returns `defaultValue` (cloned, when it is a color)
|
|
47
|
-
* when the attribute is absent (`null`), or when the value is malformed — the latter also logs
|
|
48
|
-
* a warning.
|
|
49
|
-
*
|
|
50
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
51
|
-
* @param defaultValue - The value to use when the attribute is absent or invalid.
|
|
52
|
-
* @param attribute - The attribute name, used in the warning message.
|
|
53
|
-
* @returns The parsed Color object.
|
|
54
|
-
*/
|
|
55
|
-
export declare const parseColor: <T extends Color | null>(value: string | null, defaultValue: T, attribute: string) => Color | T;
|
|
56
|
-
/**
|
|
57
|
-
* Resolves an enum attribute value against its set of valid names. Returns the value when it is
|
|
58
|
-
* one of the valid names. Returns `defaultValue` when the attribute is absent (`null`), or when
|
|
59
|
-
* the value is invalid — the latter also logs a warning listing the valid names.
|
|
60
|
-
*
|
|
61
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
62
|
-
* @param valid - The valid names: an array, or a map whose keys are the valid names. Only the keys
|
|
63
|
-
* are read, so the map's value type is unconstrained - engine enums are mostly numeric constants,
|
|
64
|
-
* but some (e.g. `SCALEMODE_BLEND`) are strings.
|
|
65
|
-
* @param defaultValue - The value to use when the attribute is absent or invalid.
|
|
66
|
-
* @param attribute - The attribute name, used in the warning message.
|
|
67
|
-
* @returns The resolved enum name.
|
|
68
|
-
*/
|
|
69
|
-
export declare const parseEnum: <T extends string>(value: string | null, valid: readonly T[] | ReadonlyMap<T, unknown>, defaultValue: T, attribute: string) => T;
|
|
70
|
-
/**
|
|
71
|
-
* Parses a number attribute value. Returns the parsed number when the value is a finite number.
|
|
72
|
-
* Returns `defaultValue` when the attribute is absent (`null`), or when the value is not a
|
|
73
|
-
* finite number — the latter also logs a warning.
|
|
74
|
-
*
|
|
75
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
76
|
-
* @param defaultValue - The value to use when the attribute is absent or invalid.
|
|
77
|
-
* @param attribute - The attribute name, used in the warning message.
|
|
78
|
-
* @returns The parsed number.
|
|
79
|
-
*/
|
|
80
|
-
export declare const parseNumber: <T extends number | null>(value: string | null, defaultValue: T, attribute: string) => number | T;
|
|
81
|
-
/**
|
|
82
|
-
* Parse an Euler-angles attribute value into a quaternion. The expected format is 3
|
|
83
|
-
* space-separated angles in degrees (e.g. '0 90 0'). Returns `defaultValue` (cloned, when it is
|
|
84
|
-
* a quaternion) when the attribute is absent (`null`), or when the value is malformed — the
|
|
85
|
-
* latter also logs a warning.
|
|
86
|
-
*
|
|
87
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
88
|
-
* @param defaultValue - The value to use when the attribute is absent or invalid.
|
|
89
|
-
* @param attribute - The attribute name, used in the warning message.
|
|
90
|
-
* @returns The parsed Quat object.
|
|
91
|
-
*/
|
|
92
|
-
export declare const parseQuat: <T extends Quat | null>(value: string | null, defaultValue: T, attribute: string) => Quat | T;
|
|
93
|
-
/**
|
|
94
|
-
* Parse a tags attribute value. The expected format is a comma-separated list of tag names
|
|
95
|
-
* (e.g. 'enemy, flying'). Surrounding whitespace is trimmed from each name and empty names are
|
|
96
|
-
* discarded, so a trailing comma or a doubled separator does not produce a blank tag. Returns a
|
|
97
|
-
* copy of `defaultValue` when the attribute is absent or removed (`null`).
|
|
98
|
-
*
|
|
99
|
-
* Every value is valid, so this never warns.
|
|
100
|
-
*
|
|
101
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
102
|
-
* @param defaultValue - The value to use when the attribute is absent or removed.
|
|
103
|
-
* @returns The parsed tag names.
|
|
104
|
-
*/
|
|
105
|
-
export declare const parseTags: (value: string | null, defaultValue?: string[]) => string[];
|
|
106
|
-
/**
|
|
107
|
-
* Parse a Vec2 attribute value. The expected format is 2 space-separated numbers (e.g. '1 2').
|
|
108
|
-
* Returns `defaultValue` (cloned, when it is a vector) when the attribute is absent (`null`),
|
|
109
|
-
* or when the value is malformed — the latter also logs a warning.
|
|
110
|
-
*
|
|
111
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
112
|
-
* @param defaultValue - The value to use when the attribute is absent or invalid.
|
|
113
|
-
* @param attribute - The attribute name, used in the warning message.
|
|
114
|
-
* @returns The parsed Vec2 object.
|
|
115
|
-
*/
|
|
116
|
-
export declare const parseVec2: <T extends Vec2 | null>(value: string | null, defaultValue: T, attribute: string) => Vec2 | T;
|
|
117
|
-
/**
|
|
118
|
-
* Parse a Vec3 attribute value. The expected format is 3 space-separated numbers (e.g. '1 2 3').
|
|
119
|
-
* Returns `defaultValue` (cloned, when it is a vector) when the attribute is absent (`null`),
|
|
120
|
-
* or when the value is malformed — the latter also logs a warning.
|
|
121
|
-
*
|
|
122
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
123
|
-
* @param defaultValue - The value to use when the attribute is absent or invalid.
|
|
124
|
-
* @param attribute - The attribute name, used in the warning message.
|
|
125
|
-
* @returns The parsed Vec3 object.
|
|
126
|
-
*/
|
|
127
|
-
export declare const parseVec3: <T extends Vec3 | null>(value: string | null, defaultValue: T, attribute: string) => Vec3 | T;
|
|
128
|
-
/**
|
|
129
|
-
* Parse a Vec4 attribute value. The expected format is 4 space-separated numbers
|
|
130
|
-
* (e.g. '1 2 3 4'). Returns `defaultValue` (cloned, when it is a vector) when the attribute is
|
|
131
|
-
* absent (`null`), or when the value is malformed — the latter also logs a warning.
|
|
132
|
-
*
|
|
133
|
-
* @param value - The attribute value to parse (`null` when the attribute is absent).
|
|
134
|
-
* @param defaultValue - The value to use when the attribute is absent or invalid.
|
|
135
|
-
* @param attribute - The attribute name, used in the warning message.
|
|
136
|
-
* @returns The parsed Vec4 object.
|
|
137
|
-
*/
|
|
138
|
-
export declare const parseVec4: <T extends Vec4 | null>(value: string | null, defaultValue: T, attribute: string) => Vec4 | T;
|
|
139
|
-
/**
|
|
140
|
-
* Resolves a reference string to the {@link Entity} backing a `<pc-entity>` element. The reference
|
|
141
|
-
* can be a CSS selector (e.g. `#my-id`, `pc-entity[name="Foo"]`), a bare element id, or a bare
|
|
142
|
-
* entity name. Returns `null` if no matching element (or backing entity) is found.
|
|
143
|
-
*
|
|
144
|
-
* @param ref - The reference string to resolve.
|
|
145
|
-
* @returns The resolved entity, or `null`.
|
|
146
|
-
*/
|
|
147
|
-
export declare const getEntity: (ref: string) => Entity | null;
|
|
18
|
+
export {};
|