@playcanvas/web-components 0.13.1 → 0.15.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/components/joint-component.d.cts +521 -0
- package/dist/components/joint-component.d.ts +521 -0
- package/dist/custom-elements.json +1029 -0
- package/dist/entity-base.d.cts +1 -7
- package/dist/entity-base.d.ts +1 -7
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- 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 +1410 -148
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +1410 -148
- 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 +1410 -149
- package/dist/pwc.mjs.map +1 -1
- package/dist/vscode.html-custom-data.json +203 -1
- package/dist/web-types.json +368 -2
- package/package.json +5 -4
- package/src/app.ts +18 -0
- package/src/colors.ts +5 -0
- package/src/components/joint-component.ts +984 -0
- package/src/entity-base.ts +3 -3
- package/src/entity.ts +28 -7
- package/src/index.ts +6 -0
- package/src/loading-bar.ts +2 -3
- package/src/material.ts +29 -0
- package/src/model.ts +156 -0
- package/src/node.ts +279 -9
- package/src/parse.ts +11 -1
package/dist/entity-base.d.cts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import type { Entity } from 'playcanvas';
|
|
2
2
|
import type { AppElement } from './app.cjs';
|
|
3
3
|
import { AsyncElement } from './async-element.cjs';
|
|
4
|
-
/**
|
|
5
|
-
* The attribute names of the inline `onpointer*` event handlers, shared by every element that
|
|
6
|
-
* fronts an engine entity. Spread into `observedAttributes` by subclasses.
|
|
7
|
-
* @ignore
|
|
8
|
-
*/
|
|
9
|
-
declare const POINTER_ATTRIBUTES: readonly ["onpointerenter", "onpointerleave", "onpointerdown", "onpointerup", "onpointermove"];
|
|
10
4
|
/**
|
|
11
5
|
* The base class for elements that front an engine {@link Entity}: `<pc-entity>`, which creates
|
|
12
6
|
* one, and `<pc-node>`, which binds to one inside a model's instantiated hierarchy. It carries
|
|
@@ -64,4 +58,4 @@ declare class EntityBaseElement extends AsyncElement {
|
|
|
64
58
|
addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void;
|
|
65
59
|
removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void;
|
|
66
60
|
}
|
|
67
|
-
export { EntityBaseElement
|
|
61
|
+
export { EntityBaseElement };
|
package/dist/entity-base.d.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import type { Entity } from 'playcanvas';
|
|
2
2
|
import type { AppElement } from './app.js';
|
|
3
3
|
import { AsyncElement } from './async-element.js';
|
|
4
|
-
/**
|
|
5
|
-
* The attribute names of the inline `onpointer*` event handlers, shared by every element that
|
|
6
|
-
* fronts an engine entity. Spread into `observedAttributes` by subclasses.
|
|
7
|
-
* @ignore
|
|
8
|
-
*/
|
|
9
|
-
declare const POINTER_ATTRIBUTES: readonly ["onpointerenter", "onpointerleave", "onpointerdown", "onpointerup", "onpointermove"];
|
|
10
4
|
/**
|
|
11
5
|
* The base class for elements that front an engine {@link Entity}: `<pc-entity>`, which creates
|
|
12
6
|
* one, and `<pc-node>`, which binds to one inside a model's instantiated hierarchy. It carries
|
|
@@ -64,4 +58,4 @@ declare class EntityBaseElement extends AsyncElement {
|
|
|
64
58
|
addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void;
|
|
65
59
|
removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void;
|
|
66
60
|
}
|
|
67
|
-
export { EntityBaseElement
|
|
61
|
+
export { EntityBaseElement };
|
package/dist/index.d.cts
CHANGED
|
@@ -17,6 +17,7 @@ import { CameraComponentElement } from './components/camera-component.cjs';
|
|
|
17
17
|
import { CollisionComponentElement } from './components/collision-component.cjs';
|
|
18
18
|
import { ComponentElement } from './components/component.cjs';
|
|
19
19
|
import { ElementComponentElement } from './components/element-component.cjs';
|
|
20
|
+
import { JointComponentElement } from './components/joint-component.cjs';
|
|
20
21
|
import { LayoutChildComponentElement } from './components/layoutchild-component.cjs';
|
|
21
22
|
import { LayoutGroupComponentElement } from './components/layoutgroup-component.cjs';
|
|
22
23
|
import { LightComponentElement } from './components/light-component.cjs';
|
|
@@ -40,6 +41,7 @@ import { SkyElement } from './sky.cjs';
|
|
|
40
41
|
import type { ScriptAttributesChangeEvent, ScriptEnableChangeEvent, ScriptNameChangeEvent } from './components/script-component.cjs';
|
|
41
42
|
declare global {
|
|
42
43
|
interface HTMLElementEventMap {
|
|
44
|
+
break: CustomEvent;
|
|
43
45
|
scriptattributeschange: ScriptAttributesChangeEvent;
|
|
44
46
|
scriptenablechange: ScriptEnableChangeEvent;
|
|
45
47
|
scriptnamechange: ScriptNameChangeEvent;
|
|
@@ -53,6 +55,7 @@ declare global {
|
|
|
53
55
|
'pc-element': ElementComponentElement;
|
|
54
56
|
'pc-entity': EntityElement;
|
|
55
57
|
'pc-gsplat': GSplatComponentElement;
|
|
58
|
+
'pc-joint': JointComponentElement;
|
|
56
59
|
'pc-layoutchild': LayoutChildComponentElement;
|
|
57
60
|
'pc-layoutgroup': LayoutGroupComponentElement;
|
|
58
61
|
'pc-light': LightComponentElement;
|
|
@@ -75,5 +78,7 @@ declare global {
|
|
|
75
78
|
'pc-sounds': SoundComponentElement;
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
|
-
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, EntityBaseElement, MaterialElement, ModelElement, NodeElement, SceneElement, SkyElement, whenReady };
|
|
81
|
+
export { AsyncElement, ModuleElement, AppElement, EntityElement, AssetElement, ButtonComponentElement, CameraComponentElement, CollisionComponentElement, ComponentElement, ElementComponentElement, JointComponentElement, LayoutChildComponentElement, LayoutGroupComponentElement, ParticleSystemComponentElement, LightComponentElement, ListenerComponentElement, RenderComponentElement, RigidBodyComponentElement, ScreenComponentElement, ScrollbarComponentElement, ScrollViewComponentElement, ScriptComponentElement, ScriptElement, SoundComponentElement, SoundSlotElement, GSplatComponentElement, EntityBaseElement, MaterialElement, ModelElement, NodeElement, SceneElement, SkyElement, whenReady };
|
|
79
82
|
export type { AsyncElementTagName } from './async-element.cjs';
|
|
83
|
+
export type { HierarchyMaterial, HierarchyNode } from './model.cjs';
|
|
84
|
+
export type { MaterialOverrides } from './node.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { CameraComponentElement } from './components/camera-component.js';
|
|
|
17
17
|
import { CollisionComponentElement } from './components/collision-component.js';
|
|
18
18
|
import { ComponentElement } from './components/component.js';
|
|
19
19
|
import { ElementComponentElement } from './components/element-component.js';
|
|
20
|
+
import { JointComponentElement } from './components/joint-component.js';
|
|
20
21
|
import { LayoutChildComponentElement } from './components/layoutchild-component.js';
|
|
21
22
|
import { LayoutGroupComponentElement } from './components/layoutgroup-component.js';
|
|
22
23
|
import { LightComponentElement } from './components/light-component.js';
|
|
@@ -40,6 +41,7 @@ import { SkyElement } from './sky.js';
|
|
|
40
41
|
import type { ScriptAttributesChangeEvent, ScriptEnableChangeEvent, ScriptNameChangeEvent } from './components/script-component.js';
|
|
41
42
|
declare global {
|
|
42
43
|
interface HTMLElementEventMap {
|
|
44
|
+
break: CustomEvent;
|
|
43
45
|
scriptattributeschange: ScriptAttributesChangeEvent;
|
|
44
46
|
scriptenablechange: ScriptEnableChangeEvent;
|
|
45
47
|
scriptnamechange: ScriptNameChangeEvent;
|
|
@@ -53,6 +55,7 @@ declare global {
|
|
|
53
55
|
'pc-element': ElementComponentElement;
|
|
54
56
|
'pc-entity': EntityElement;
|
|
55
57
|
'pc-gsplat': GSplatComponentElement;
|
|
58
|
+
'pc-joint': JointComponentElement;
|
|
56
59
|
'pc-layoutchild': LayoutChildComponentElement;
|
|
57
60
|
'pc-layoutgroup': LayoutGroupComponentElement;
|
|
58
61
|
'pc-light': LightComponentElement;
|
|
@@ -75,5 +78,7 @@ declare global {
|
|
|
75
78
|
'pc-sounds': SoundComponentElement;
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
|
-
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, EntityBaseElement, MaterialElement, ModelElement, NodeElement, SceneElement, SkyElement, whenReady };
|
|
81
|
+
export { AsyncElement, ModuleElement, AppElement, EntityElement, AssetElement, ButtonComponentElement, CameraComponentElement, CollisionComponentElement, ComponentElement, ElementComponentElement, JointComponentElement, LayoutChildComponentElement, LayoutGroupComponentElement, ParticleSystemComponentElement, LightComponentElement, ListenerComponentElement, RenderComponentElement, RigidBodyComponentElement, ScreenComponentElement, ScrollbarComponentElement, ScrollViewComponentElement, ScriptComponentElement, ScriptElement, SoundComponentElement, SoundSlotElement, GSplatComponentElement, EntityBaseElement, MaterialElement, ModelElement, NodeElement, SceneElement, SkyElement, whenReady };
|
|
79
82
|
export type { AsyncElementTagName } from './async-element.js';
|
|
83
|
+
export type { HierarchyMaterial, HierarchyNode } from './model.js';
|
|
84
|
+
export type { MaterialOverrides } from './node.js';
|
package/dist/loading-bar.d.cts
CHANGED
|
@@ -1,35 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* The slim progress bar `<pc-app>` shows while it boots and preloads. An implementation detail of
|
|
3
|
-
* AppElement rather than a custom element, so its shape can change without a breaking change.
|
|
4
|
-
*
|
|
5
|
-
* All styling is inline, so the library injects no stylesheet. The colors and height resolve CSS
|
|
6
|
-
* custom properties — `--pc-loading-bar-color`, `--pc-loading-bar-background` and
|
|
7
|
-
* `--pc-loading-bar-height` — so a page can theme the bar from `pc-app` or `:root`.
|
|
8
|
-
*/
|
|
9
|
-
declare class LoadingBar {
|
|
10
|
-
private _track;
|
|
11
|
-
private _fill;
|
|
12
|
-
private _sweep;
|
|
13
|
-
private _removal;
|
|
14
|
-
/**
|
|
15
|
-
* Creates the bar and appends it to `parent`, starting in the indeterminate state.
|
|
16
|
-
* @param parent - The element to append the bar to.
|
|
17
|
-
*/
|
|
18
|
-
constructor(parent: HTMLElement);
|
|
19
|
-
/**
|
|
20
|
-
* Reflects preload progress, switching the bar from indeterminate to determinate on the first
|
|
21
|
-
* call.
|
|
22
|
-
* @param loaded - The number of assets that have finished loading.
|
|
23
|
-
* @param total - The number of assets being preloaded.
|
|
24
|
-
*/
|
|
25
|
-
progress(loaded: number, total: number): void;
|
|
26
|
-
/**
|
|
27
|
-
* Fills the bar, fades it out and removes it. Idempotent.
|
|
28
|
-
*/
|
|
29
|
-
complete(): void;
|
|
30
|
-
/**
|
|
31
|
-
* Removes the bar immediately, cancelling any pending fade. Idempotent.
|
|
32
|
-
*/
|
|
33
|
-
destroy(): void;
|
|
34
|
-
}
|
|
35
|
-
export { LoadingBar };
|
|
1
|
+
export {};
|
package/dist/loading-bar.d.ts
CHANGED
|
@@ -1,35 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* The slim progress bar `<pc-app>` shows while it boots and preloads. An implementation detail of
|
|
3
|
-
* AppElement rather than a custom element, so its shape can change without a breaking change.
|
|
4
|
-
*
|
|
5
|
-
* All styling is inline, so the library injects no stylesheet. The colors and height resolve CSS
|
|
6
|
-
* custom properties — `--pc-loading-bar-color`, `--pc-loading-bar-background` and
|
|
7
|
-
* `--pc-loading-bar-height` — so a page can theme the bar from `pc-app` or `:root`.
|
|
8
|
-
*/
|
|
9
|
-
declare class LoadingBar {
|
|
10
|
-
private _track;
|
|
11
|
-
private _fill;
|
|
12
|
-
private _sweep;
|
|
13
|
-
private _removal;
|
|
14
|
-
/**
|
|
15
|
-
* Creates the bar and appends it to `parent`, starting in the indeterminate state.
|
|
16
|
-
* @param parent - The element to append the bar to.
|
|
17
|
-
*/
|
|
18
|
-
constructor(parent: HTMLElement);
|
|
19
|
-
/**
|
|
20
|
-
* Reflects preload progress, switching the bar from indeterminate to determinate on the first
|
|
21
|
-
* call.
|
|
22
|
-
* @param loaded - The number of assets that have finished loading.
|
|
23
|
-
* @param total - The number of assets being preloaded.
|
|
24
|
-
*/
|
|
25
|
-
progress(loaded: number, total: number): void;
|
|
26
|
-
/**
|
|
27
|
-
* Fills the bar, fades it out and removes it. Idempotent.
|
|
28
|
-
*/
|
|
29
|
-
complete(): void;
|
|
30
|
-
/**
|
|
31
|
-
* Removes the bar immediately, cancelling any pending fade. Idempotent.
|
|
32
|
-
*/
|
|
33
|
-
destroy(): void;
|
|
34
|
-
}
|
|
35
|
-
export { LoadingBar };
|
|
1
|
+
export {};
|
package/dist/material.d.cts
CHANGED
|
@@ -91,6 +91,7 @@ declare class MaterialElement extends HTMLElement {
|
|
|
91
91
|
private _metalnessMapRotation;
|
|
92
92
|
private _metalnessMapTiling;
|
|
93
93
|
private _metalnessMapUv;
|
|
94
|
+
private _name;
|
|
94
95
|
private _normalMap;
|
|
95
96
|
private _normalMapOffset;
|
|
96
97
|
private _normalMapRotation;
|
|
@@ -706,6 +707,18 @@ declare class MaterialElement extends HTMLElement {
|
|
|
706
707
|
* @returns The UV channel.
|
|
707
708
|
*/
|
|
708
709
|
get metalnessMapUv(): number;
|
|
710
|
+
/**
|
|
711
|
+
* Sets the name of the material.
|
|
712
|
+
* @param value - The material name.
|
|
713
|
+
*/
|
|
714
|
+
set name(value: string);
|
|
715
|
+
/**
|
|
716
|
+
* Gets the name of the material - the label shown wherever materials surface by name, such
|
|
717
|
+
* as profilers, GPU captures and the assignments `pc-model.hierarchy()` reports. Purely a
|
|
718
|
+
* label: element references resolve through `id`.
|
|
719
|
+
* @returns The material name.
|
|
720
|
+
*/
|
|
721
|
+
get name(): string;
|
|
709
722
|
/**
|
|
710
723
|
* Sets the id of the `pc-asset` to use as the normal map.
|
|
711
724
|
* @param value - The asset id.
|
package/dist/material.d.ts
CHANGED
|
@@ -91,6 +91,7 @@ declare class MaterialElement extends HTMLElement {
|
|
|
91
91
|
private _metalnessMapRotation;
|
|
92
92
|
private _metalnessMapTiling;
|
|
93
93
|
private _metalnessMapUv;
|
|
94
|
+
private _name;
|
|
94
95
|
private _normalMap;
|
|
95
96
|
private _normalMapOffset;
|
|
96
97
|
private _normalMapRotation;
|
|
@@ -706,6 +707,18 @@ declare class MaterialElement extends HTMLElement {
|
|
|
706
707
|
* @returns The UV channel.
|
|
707
708
|
*/
|
|
708
709
|
get metalnessMapUv(): number;
|
|
710
|
+
/**
|
|
711
|
+
* Sets the name of the material.
|
|
712
|
+
* @param value - The material name.
|
|
713
|
+
*/
|
|
714
|
+
set name(value: string);
|
|
715
|
+
/**
|
|
716
|
+
* Gets the name of the material - the label shown wherever materials surface by name, such
|
|
717
|
+
* as profilers, GPU captures and the assignments `pc-model.hierarchy()` reports. Purely a
|
|
718
|
+
* label: element references resolve through `id`.
|
|
719
|
+
* @returns The material name.
|
|
720
|
+
*/
|
|
721
|
+
get name(): string;
|
|
709
722
|
/**
|
|
710
723
|
* Sets the id of the `pc-asset` to use as the normal map.
|
|
711
724
|
* @param value - The asset id.
|
package/dist/model.d.cts
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
import type { Entity } from 'playcanvas';
|
|
2
2
|
import { AsyncElement } from './async-element.cjs';
|
|
3
|
+
/**
|
|
4
|
+
* One material assignment of a {@link HierarchyNode} with a render component: a mesh instance's
|
|
5
|
+
* position within the component and the runtime name of its current material.
|
|
6
|
+
*/
|
|
7
|
+
type HierarchyMaterial = {
|
|
8
|
+
/** The mesh instance's position in the render component's `meshInstances` array. */
|
|
9
|
+
index: number;
|
|
10
|
+
/**
|
|
11
|
+
* The runtime name of the mesh instance's current material, reported as-is: the engine
|
|
12
|
+
* names an unnamed glTF material `Untitled`, and assigns a shared material named
|
|
13
|
+
* `defaultGlbMaterial` to a primitive authored without one — neither is a unique authored
|
|
14
|
+
* identifier. `null` when a script has cleared the assignment.
|
|
15
|
+
*/
|
|
16
|
+
name: string | null;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* One node of the tree returned by {@link ModelElement.hierarchy}. A plain-data snapshot —
|
|
20
|
+
* `JSON.stringify` serializes it — whose `toString()` renders the node's subtree as a printable
|
|
21
|
+
* tree.
|
|
22
|
+
*/
|
|
23
|
+
type HierarchyNode = {
|
|
24
|
+
/**
|
|
25
|
+
* The node's name as instantiated, which is the name `pc-node` binding resolves: the engine
|
|
26
|
+
* parser synthesizes `node_<index>` names for unnamed nodes and renames identically named
|
|
27
|
+
* siblings apart (`Wheel`, `Wheel1`, ...), so it can differ from the name authored in the
|
|
28
|
+
* source asset.
|
|
29
|
+
*/
|
|
30
|
+
name: string;
|
|
31
|
+
/**
|
|
32
|
+
* The node's `/`-separated path below the model root — the path a `pc-node` bound to this
|
|
33
|
+
* node reports. The root's path is its own name.
|
|
34
|
+
*/
|
|
35
|
+
path: string;
|
|
36
|
+
/**
|
|
37
|
+
* The node's position among identically named nodes in the model, counted in depth-first
|
|
38
|
+
* order over the whole tree: the match a `pc-node`'s `index` attribute selects when `name`
|
|
39
|
+
* alone is ambiguous.
|
|
40
|
+
*/
|
|
41
|
+
index: number;
|
|
42
|
+
/** The types of the components attached to the node (e.g. 'render'), sorted. */
|
|
43
|
+
components: string[];
|
|
44
|
+
/**
|
|
45
|
+
* The material assignments of the node's render component, one entry per mesh instance in
|
|
46
|
+
* component order. Empty for a node without a render component.
|
|
47
|
+
*/
|
|
48
|
+
materials: HierarchyMaterial[];
|
|
49
|
+
/** The node's children. */
|
|
50
|
+
children: HierarchyNode[];
|
|
51
|
+
/**
|
|
52
|
+
* Renders the subtree rooted at this node as a printable tree, one line per node: the name,
|
|
53
|
+
* `[index]` after a name that several nodes in the model share, the component types in
|
|
54
|
+
* parentheses, and the material names of a render component in braces.
|
|
55
|
+
*/
|
|
56
|
+
toString(): string;
|
|
57
|
+
};
|
|
3
58
|
/**
|
|
4
59
|
* The ModelElement interface provides properties and methods for manipulating
|
|
5
60
|
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-model/ | `<pc-model>`} elements.
|
|
@@ -44,6 +99,21 @@ declare class ModelElement extends AsyncElement {
|
|
|
44
99
|
* @returns The model's root entity, or `null`.
|
|
45
100
|
*/
|
|
46
101
|
get entity(): Entity | null;
|
|
102
|
+
/**
|
|
103
|
+
* Returns a snapshot of the instantiated node tree, or `null` while there is none (the
|
|
104
|
+
* container asset has not loaded, or the element has left the document). One call grounds a
|
|
105
|
+
* session — a browser console, a test, an agent — in the vocabulary `pc-node` binding
|
|
106
|
+
* resolves against: the instantiated names ({@link HierarchyNode.name}), paths, match
|
|
107
|
+
* indices, attached component types and the material assignments of render components
|
|
108
|
+
* ({@link HierarchyNode.materials}). `String(...)` of the result, or of any node in it,
|
|
109
|
+
* is the printable form.
|
|
110
|
+
*
|
|
111
|
+
* The snapshot is plain data, computed afresh each call: it does not follow later changes
|
|
112
|
+
* to the hierarchy, and mutating it changes nothing.
|
|
113
|
+
*
|
|
114
|
+
* @returns The root of the instantiated node tree, or `null`.
|
|
115
|
+
*/
|
|
116
|
+
hierarchy(): HierarchyNode | null;
|
|
47
117
|
connectedCallback(): void;
|
|
48
118
|
disconnectedCallback(): void;
|
|
49
119
|
private _detachLoadHandlers;
|
|
@@ -70,3 +140,4 @@ declare class ModelElement extends AsyncElement {
|
|
|
70
140
|
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
|
|
71
141
|
}
|
|
72
142
|
export { ModelElement };
|
|
143
|
+
export type { HierarchyMaterial, HierarchyNode };
|
package/dist/model.d.ts
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
import type { Entity } from 'playcanvas';
|
|
2
2
|
import { AsyncElement } from './async-element.js';
|
|
3
|
+
/**
|
|
4
|
+
* One material assignment of a {@link HierarchyNode} with a render component: a mesh instance's
|
|
5
|
+
* position within the component and the runtime name of its current material.
|
|
6
|
+
*/
|
|
7
|
+
type HierarchyMaterial = {
|
|
8
|
+
/** The mesh instance's position in the render component's `meshInstances` array. */
|
|
9
|
+
index: number;
|
|
10
|
+
/**
|
|
11
|
+
* The runtime name of the mesh instance's current material, reported as-is: the engine
|
|
12
|
+
* names an unnamed glTF material `Untitled`, and assigns a shared material named
|
|
13
|
+
* `defaultGlbMaterial` to a primitive authored without one — neither is a unique authored
|
|
14
|
+
* identifier. `null` when a script has cleared the assignment.
|
|
15
|
+
*/
|
|
16
|
+
name: string | null;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* One node of the tree returned by {@link ModelElement.hierarchy}. A plain-data snapshot —
|
|
20
|
+
* `JSON.stringify` serializes it — whose `toString()` renders the node's subtree as a printable
|
|
21
|
+
* tree.
|
|
22
|
+
*/
|
|
23
|
+
type HierarchyNode = {
|
|
24
|
+
/**
|
|
25
|
+
* The node's name as instantiated, which is the name `pc-node` binding resolves: the engine
|
|
26
|
+
* parser synthesizes `node_<index>` names for unnamed nodes and renames identically named
|
|
27
|
+
* siblings apart (`Wheel`, `Wheel1`, ...), so it can differ from the name authored in the
|
|
28
|
+
* source asset.
|
|
29
|
+
*/
|
|
30
|
+
name: string;
|
|
31
|
+
/**
|
|
32
|
+
* The node's `/`-separated path below the model root — the path a `pc-node` bound to this
|
|
33
|
+
* node reports. The root's path is its own name.
|
|
34
|
+
*/
|
|
35
|
+
path: string;
|
|
36
|
+
/**
|
|
37
|
+
* The node's position among identically named nodes in the model, counted in depth-first
|
|
38
|
+
* order over the whole tree: the match a `pc-node`'s `index` attribute selects when `name`
|
|
39
|
+
* alone is ambiguous.
|
|
40
|
+
*/
|
|
41
|
+
index: number;
|
|
42
|
+
/** The types of the components attached to the node (e.g. 'render'), sorted. */
|
|
43
|
+
components: string[];
|
|
44
|
+
/**
|
|
45
|
+
* The material assignments of the node's render component, one entry per mesh instance in
|
|
46
|
+
* component order. Empty for a node without a render component.
|
|
47
|
+
*/
|
|
48
|
+
materials: HierarchyMaterial[];
|
|
49
|
+
/** The node's children. */
|
|
50
|
+
children: HierarchyNode[];
|
|
51
|
+
/**
|
|
52
|
+
* Renders the subtree rooted at this node as a printable tree, one line per node: the name,
|
|
53
|
+
* `[index]` after a name that several nodes in the model share, the component types in
|
|
54
|
+
* parentheses, and the material names of a render component in braces.
|
|
55
|
+
*/
|
|
56
|
+
toString(): string;
|
|
57
|
+
};
|
|
3
58
|
/**
|
|
4
59
|
* The ModelElement interface provides properties and methods for manipulating
|
|
5
60
|
* {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-model/ | `<pc-model>`} elements.
|
|
@@ -44,6 +99,21 @@ declare class ModelElement extends AsyncElement {
|
|
|
44
99
|
* @returns The model's root entity, or `null`.
|
|
45
100
|
*/
|
|
46
101
|
get entity(): Entity | null;
|
|
102
|
+
/**
|
|
103
|
+
* Returns a snapshot of the instantiated node tree, or `null` while there is none (the
|
|
104
|
+
* container asset has not loaded, or the element has left the document). One call grounds a
|
|
105
|
+
* session — a browser console, a test, an agent — in the vocabulary `pc-node` binding
|
|
106
|
+
* resolves against: the instantiated names ({@link HierarchyNode.name}), paths, match
|
|
107
|
+
* indices, attached component types and the material assignments of render components
|
|
108
|
+
* ({@link HierarchyNode.materials}). `String(...)` of the result, or of any node in it,
|
|
109
|
+
* is the printable form.
|
|
110
|
+
*
|
|
111
|
+
* The snapshot is plain data, computed afresh each call: it does not follow later changes
|
|
112
|
+
* to the hierarchy, and mutating it changes nothing.
|
|
113
|
+
*
|
|
114
|
+
* @returns The root of the instantiated node tree, or `null`.
|
|
115
|
+
*/
|
|
116
|
+
hierarchy(): HierarchyNode | null;
|
|
47
117
|
connectedCallback(): void;
|
|
48
118
|
disconnectedCallback(): void;
|
|
49
119
|
private _detachLoadHandlers;
|
|
@@ -70,3 +140,4 @@ declare class ModelElement extends AsyncElement {
|
|
|
70
140
|
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
|
|
71
141
|
}
|
|
72
142
|
export { ModelElement };
|
|
143
|
+
export type { HierarchyMaterial, HierarchyNode };
|
package/dist/node.d.cts
CHANGED
|
@@ -7,6 +7,13 @@ import { EntityBaseElement } from './entity-base.cjs';
|
|
|
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/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 };
|