@playcanvas/web-components 0.13.0 → 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.
Files changed (51) hide show
  1. package/dist/app.d.cts +35 -0
  2. package/dist/app.d.ts +35 -0
  3. package/dist/asset.d.cts +7 -1
  4. package/dist/asset.d.ts +7 -1
  5. package/dist/colors.d.cts +1 -1
  6. package/dist/colors.d.ts +1 -1
  7. package/dist/custom-elements.json +114 -1
  8. package/dist/entity-base.d.cts +1 -7
  9. package/dist/entity-base.d.ts +1 -7
  10. package/dist/index.d.cts +2 -0
  11. package/dist/index.d.ts +2 -0
  12. package/dist/loading-bar.d.cts +1 -35
  13. package/dist/loading-bar.d.ts +1 -35
  14. package/dist/material.d.cts +13 -0
  15. package/dist/material.d.ts +13 -0
  16. package/dist/model.d.cts +71 -0
  17. package/dist/model.d.ts +71 -0
  18. package/dist/node.d.cts +55 -0
  19. package/dist/node.d.ts +55 -0
  20. package/dist/parse.d.cts +1 -130
  21. package/dist/parse.d.ts +1 -130
  22. package/dist/pwc.cjs +506 -54
  23. package/dist/pwc.cjs.map +1 -1
  24. package/dist/pwc.js +506 -54
  25. package/dist/pwc.js.map +1 -1
  26. package/dist/pwc.min.js +1 -1
  27. package/dist/pwc.min.js.map +1 -1
  28. package/dist/pwc.min.mjs +1 -1
  29. package/dist/pwc.min.mjs.map +1 -1
  30. package/dist/pwc.mjs +506 -54
  31. package/dist/pwc.mjs.map +1 -1
  32. package/dist/vscode.html-custom-data.json +12 -2
  33. package/dist/web-types.json +22 -3
  34. package/package.json +3 -3
  35. package/src/app.ts +92 -19
  36. package/src/asset.ts +34 -2
  37. package/src/colors.ts +5 -0
  38. package/src/components/button-component.ts +7 -7
  39. package/src/components/element-component.ts +7 -7
  40. package/src/components/gsplat-component.ts +3 -3
  41. package/src/components/particlesystem-component.ts +7 -8
  42. package/src/components/script-component.ts +2 -2
  43. package/src/components/sound-slot.ts +2 -2
  44. package/src/entity-base.ts +3 -3
  45. package/src/index.ts +2 -0
  46. package/src/loading-bar.ts +2 -3
  47. package/src/material.ts +31 -2
  48. package/src/model.ts +158 -5
  49. package/src/node.ts +277 -2
  50. package/src/parse.ts +11 -1
  51. package/src/sky.ts +2 -3
package/dist/app.d.cts CHANGED
@@ -131,10 +131,45 @@ declare class AppElement extends AsyncElement {
131
131
  * @returns The nearest listening element, or `null`.
132
132
  */
133
133
  private _elementWithListener;
134
+ /**
135
+ * Converts a pointer event's client coordinates into drawing-buffer coordinates - the space
136
+ * the pick buffer and the camera viewports are laid out in. When the canvas has no CSS box
137
+ * to map through (jsdom; a hidden canvas receives no pointer events in a browser), the
138
+ * client coordinates are passed through unmapped and `mapped` is false, so callers know the
139
+ * coordinates correspond to no real geometry.
140
+ *
141
+ * @param event - The pointer event to convert.
142
+ * @param canvas - The canvas the event was dispatched on.
143
+ * @returns The buffer-space coordinates, and whether they were actually mapped.
144
+ */
134
145
  private _getPickerCoordinates;
146
+ /**
147
+ * Whether a camera's viewport contains the point. A camera renders into its normalized
148
+ * `rect`, whose origin is the bottom-left of the canvas while buffer coordinates run from
149
+ * the top-left - so the vertical test flips, as the engine's ElementInput flips it for UI
150
+ * input. The right and bottom edges are exclusive: a viewport rasterizes the half-open
151
+ * pixel range [left, right) x [top, bottom), so a coordinate on a shared edge belongs to
152
+ * the viewport whose first pixel it is - never to the one it just left, whose pick buffer
153
+ * holds nothing there.
154
+ *
155
+ * @param camera - The camera to test.
156
+ * @param x - The x coordinate, in buffer space.
157
+ * @param y - The y coordinate, in buffer space.
158
+ * @param canvas - The canvas the coordinates are relative to.
159
+ * @returns Whether the camera's viewport contains the point.
160
+ */
161
+ private _cameraContains;
135
162
  /**
136
163
  * Picks the scene under the pointer and returns the graph node that was hit, or `null`.
137
164
  *
165
+ * The camera is resolved the way the engine's ElementInput resolves it for UI input:
166
+ * enabled cameras are tried topmost-first (they render in ascending `priority` order),
167
+ * skipping cameras that render to a texture and cameras whose viewport `rect` does not
168
+ * contain the pointer. A camera that picks nothing ends the search if it clears the color
169
+ * buffer - its background visually owns the pixel - and otherwise cedes to the cameras
170
+ * beneath it, so an overlay camera only intercepts picks where it actually drew something.
171
+ * The pick buffer is prepared per camera, so each camera picks from its own layers.
172
+ *
138
173
  * The read back is asynchronous because the synchronous {@link Picker.getSelection} is not
139
174
  * supported on WebGPU, where it returns an empty selection rather than failing - which
140
175
  * silently disabled every `onpointer*` handler once WebGPU became the resolved backend. The
package/dist/app.d.ts CHANGED
@@ -131,10 +131,45 @@ declare class AppElement extends AsyncElement {
131
131
  * @returns The nearest listening element, or `null`.
132
132
  */
133
133
  private _elementWithListener;
134
+ /**
135
+ * Converts a pointer event's client coordinates into drawing-buffer coordinates - the space
136
+ * the pick buffer and the camera viewports are laid out in. When the canvas has no CSS box
137
+ * to map through (jsdom; a hidden canvas receives no pointer events in a browser), the
138
+ * client coordinates are passed through unmapped and `mapped` is false, so callers know the
139
+ * coordinates correspond to no real geometry.
140
+ *
141
+ * @param event - The pointer event to convert.
142
+ * @param canvas - The canvas the event was dispatched on.
143
+ * @returns The buffer-space coordinates, and whether they were actually mapped.
144
+ */
134
145
  private _getPickerCoordinates;
146
+ /**
147
+ * Whether a camera's viewport contains the point. A camera renders into its normalized
148
+ * `rect`, whose origin is the bottom-left of the canvas while buffer coordinates run from
149
+ * the top-left - so the vertical test flips, as the engine's ElementInput flips it for UI
150
+ * input. The right and bottom edges are exclusive: a viewport rasterizes the half-open
151
+ * pixel range [left, right) x [top, bottom), so a coordinate on a shared edge belongs to
152
+ * the viewport whose first pixel it is - never to the one it just left, whose pick buffer
153
+ * holds nothing there.
154
+ *
155
+ * @param camera - The camera to test.
156
+ * @param x - The x coordinate, in buffer space.
157
+ * @param y - The y coordinate, in buffer space.
158
+ * @param canvas - The canvas the coordinates are relative to.
159
+ * @returns Whether the camera's viewport contains the point.
160
+ */
161
+ private _cameraContains;
135
162
  /**
136
163
  * Picks the scene under the pointer and returns the graph node that was hit, or `null`.
137
164
  *
165
+ * The camera is resolved the way the engine's ElementInput resolves it for UI input:
166
+ * enabled cameras are tried topmost-first (they render in ascending `priority` order),
167
+ * skipping cameras that render to a texture and cameras whose viewport `rect` does not
168
+ * contain the pointer. A camera that picks nothing ends the search if it clears the color
169
+ * buffer - its background visually owns the pixel - and otherwise cedes to the cameras
170
+ * beneath it, so an overlay camera only intercepts picks where it actually drew something.
171
+ * The pick buffer is prepared per camera, so each camera picks from its own layers.
172
+ *
138
173
  * The read back is asynchronous because the synchronous {@link Picker.getSelection} is not
139
174
  * supported on WebGPU, where it returns an empty selection rather than failing - which
140
175
  * silently disabled every `onpointer*` handler once WebGPU became the resolved backend. The
package/dist/asset.d.cts CHANGED
@@ -16,6 +16,10 @@ type MagFilterMode = 'nearest' | 'linear';
16
16
  * immediately unless `lazy`. A `pc-asset` must be a direct child of `pc-app` — elements placed
17
17
  * elsewhere, or with an unsupported asset type, never become ready.
18
18
  *
19
+ * A `lazy` asset loads on first use: the first time any element resolves it by `id` — a model,
20
+ * a material map, a sky, a script `asset:` reference — or when the `lazy` attribute is removed,
21
+ * whichever comes first. Until then it stays registered and unloaded.
22
+ *
19
23
  * For `texture` and `textureatlas` assets, the texture options (`address-u`, `address-v`,
20
24
  * `min-filter`, `mag-filter`, `anisotropy`, `mipmaps`, `srgb`, `flip-y`) apply when the texture is
21
25
  * created and — like `lazy` — are observed: changing one updates a texture that has already
@@ -146,7 +150,9 @@ declare class AssetElement extends AsyncElement {
146
150
  */
147
151
  get flipY(): boolean | null;
148
152
  /**
149
- * Sets whether the asset should be loaded lazily.
153
+ * Sets whether the asset should be loaded lazily. A lazy asset is registered without being
154
+ * loaded; it loads on first use - the first time any element resolves it by `id` - or when
155
+ * this flag is cleared on a registered asset, whichever comes first.
150
156
  * @param value - The lazy loading flag.
151
157
  */
152
158
  set lazy(value: boolean);
package/dist/asset.d.ts CHANGED
@@ -16,6 +16,10 @@ type MagFilterMode = 'nearest' | 'linear';
16
16
  * immediately unless `lazy`. A `pc-asset` must be a direct child of `pc-app` — elements placed
17
17
  * elsewhere, or with an unsupported asset type, never become ready.
18
18
  *
19
+ * A `lazy` asset loads on first use: the first time any element resolves it by `id` — a model,
20
+ * a material map, a sky, a script `asset:` reference — or when the `lazy` attribute is removed,
21
+ * whichever comes first. Until then it stays registered and unloaded.
22
+ *
19
23
  * For `texture` and `textureatlas` assets, the texture options (`address-u`, `address-v`,
20
24
  * `min-filter`, `mag-filter`, `anisotropy`, `mipmaps`, `srgb`, `flip-y`) apply when the texture is
21
25
  * created and — like `lazy` — are observed: changing one updates a texture that has already
@@ -146,7 +150,9 @@ declare class AssetElement extends AsyncElement {
146
150
  */
147
151
  get flipY(): boolean | null;
148
152
  /**
149
- * Sets whether the asset should be loaded lazily.
153
+ * Sets whether the asset should be loaded lazily. A lazy asset is registered without being
154
+ * loaded; it loads on first use - the first time any element resolves it by `id` - or when
155
+ * this flag is cleared on a registered asset, whichever comes first.
150
156
  * @param value - The lazy loading flag.
151
157
  */
152
158
  set lazy(value: boolean);
package/dist/colors.d.cts CHANGED
@@ -1 +1 @@
1
- export declare const CSS_COLORS: Record<string, string>;
1
+ export {};
package/dist/colors.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const CSS_COLORS: Record<string, string>;
1
+ export {};
@@ -346,7 +346,7 @@
346
346
  "declarations": [
347
347
  {
348
348
  "kind": "class",
349
- "description": "The AssetElement interface provides properties and methods for manipulating\n[`<pc-asset>`](https://developer.playcanvas.com/user-manual/web-components/tags/pc-asset/) elements.\nThe AssetElement interface also inherits the properties and methods of the\nHTMLElement interface.\n\nThe element becomes ready once the containing application has started and the asset is in the\nstate declared by the markup: loaded for preloaded assets (even if loading failed — check the\nasset's `resource`), or registered and awaiting a load for `lazy` assets. Elements inserted\nwhile the application is running are created and registered on insertion, and begin loading\nimmediately unless `lazy`. A `pc-asset` must be a direct child of `pc-app` — elements placed\nelsewhere, or with an unsupported asset type, never become ready.\n\nFor `texture` and `textureatlas` assets, the texture options (`address-u`, `address-v`,\n`min-filter`, `mag-filter`, `anisotropy`, `mipmaps`, `srgb`, `flip-y`) apply when the texture is\ncreated and — like `lazy` — are observed: changing one updates a texture that has already\nloaded, and removing one restores the engine default. Changing `srgb` or `mipmaps` on a loaded\ntexture recreates the underlying GPU resource, so prefer declaring those up front. Each option\noverrides the matching key in the `data` JSON; options left unset write nothing, leaving the\nengine's per-format defaults in force.\n\nApart from `lazy` and the texture options, these attributes are read once when the asset is\ncreated, so changing them later has no effect.\n",
349
+ "description": "The AssetElement interface provides properties and methods for manipulating\n[`<pc-asset>`](https://developer.playcanvas.com/user-manual/web-components/tags/pc-asset/) elements.\nThe AssetElement interface also inherits the properties and methods of the\nHTMLElement interface.\n\nThe element becomes ready once the containing application has started and the asset is in the\nstate declared by the markup: loaded for preloaded assets (even if loading failed — check the\nasset's `resource`), or registered and awaiting a load for `lazy` assets. Elements inserted\nwhile the application is running are created and registered on insertion, and begin loading\nimmediately unless `lazy`. A `pc-asset` must be a direct child of `pc-app` — elements placed\nelsewhere, or with an unsupported asset type, never become ready.\n\nA `lazy` asset loads on first use: the first time any element resolves it by `id` — a model,\na material map, a sky, a script `asset:` reference — or when the `lazy` attribute is removed,\nwhichever comes first. Until then it stays registered and unloaded.\n\nFor `texture` and `textureatlas` assets, the texture options (`address-u`, `address-v`,\n`min-filter`, `mag-filter`, `anisotropy`, `mipmaps`, `srgb`, `flip-y`) apply when the texture is\ncreated and — like `lazy` — are observed: changing one updates a texture that has already\nloaded, and removing one restores the engine default. Changing `srgb` or `mipmaps` on a loaded\ntexture recreates the underlying GPU resource, so prefer declaring those up front. Each option\noverrides the matching key in the `data` JSON; options left unset write nothing, leaving the\nengine's per-format defaults in force.\n\nApart from `lazy` and the texture options, these attributes are read once when the asset is\ncreated, so changing them later has no effect.\n",
350
350
  "name": "AssetElement",
351
351
  "members": [
352
352
  {
@@ -1777,6 +1777,30 @@
1777
1777
  "name": "AsyncElementTagName",
1778
1778
  "module": "./async-element"
1779
1779
  }
1780
+ },
1781
+ {
1782
+ "kind": "js",
1783
+ "name": "HierarchyMaterial",
1784
+ "declaration": {
1785
+ "name": "HierarchyMaterial",
1786
+ "module": "./model"
1787
+ }
1788
+ },
1789
+ {
1790
+ "kind": "js",
1791
+ "name": "HierarchyNode",
1792
+ "declaration": {
1793
+ "name": "HierarchyNode",
1794
+ "module": "./model"
1795
+ }
1796
+ },
1797
+ {
1798
+ "kind": "js",
1799
+ "name": "MaterialOverrides",
1800
+ "declaration": {
1801
+ "name": "MaterialOverrides",
1802
+ "module": "./node"
1803
+ }
1780
1804
  }
1781
1805
  ]
1782
1806
  },
@@ -2715,6 +2739,22 @@
2715
2739
  }
2716
2740
  }
2717
2741
  },
2742
+ {
2743
+ "kind": "field",
2744
+ "name": "name",
2745
+ "description": "Gets the name of the material - the label shown wherever materials surface by name, such\nas profilers, GPU captures and the assignments `pc-model.hierarchy()` reports. Purely a\nlabel: element references resolve through `id`.",
2746
+ "parameters": [
2747
+ {
2748
+ "description": "The material name.",
2749
+ "name": "value"
2750
+ }
2751
+ ],
2752
+ "return": {
2753
+ "type": {
2754
+ "text": ""
2755
+ }
2756
+ }
2757
+ },
2718
2758
  {
2719
2759
  "kind": "field",
2720
2760
  "name": "normalMap",
@@ -3657,6 +3697,14 @@
3657
3697
  "default": "0",
3658
3698
  "description": "The UV channel the metalness map samples."
3659
3699
  },
3700
+ {
3701
+ "name": "name",
3702
+ "type": {
3703
+ "text": "string"
3704
+ },
3705
+ "fieldName": "name",
3706
+ "description": "The name of the material - the label shown wherever materials surface by name, such as profilers, GPU captures and the assignments `pc-model.hierarchy()` reports."
3707
+ },
3660
3708
  {
3661
3709
  "name": "normal-map",
3662
3710
  "type": {
@@ -3937,6 +3985,10 @@
3937
3985
  "kind": "javascript-module",
3938
3986
  "path": "src/model.ts",
3939
3987
  "declarations": [
3988
+ {
3989
+ "kind": "variable",
3990
+ "name": "index"
3991
+ },
3940
3992
  {
3941
3993
  "kind": "class",
3942
3994
  "description": "The ModelElement interface provides properties and methods for manipulating\n[`<pc-model>`](https://developer.playcanvas.com/user-manual/web-components/tags/pc-model/) elements.\nThe ModelElement interface also inherits the properties and methods of the\nHTMLElement interface.\n\nThe element becomes ready once its container asset has loaded and the instantiated hierarchy has\nbeen added to the scene — `entity` is non-null by then. A failed load also settles readiness,\nwith `entity` remaining `null`: readiness means the load settled, not that it succeeded — listen\nfor `error`, or check `entity`, to tell the outcomes apart. Changing `asset` re-arms readiness\nand instantiates anew, so a `ready()` obtained after the change resolves against the new\nhierarchy. A `pc-model` outside a `pc-app`, or referencing an unknown asset id, warns and never\nbecomes ready.\n",
@@ -4011,6 +4063,16 @@
4011
4063
  },
4012
4064
  "readonly": true
4013
4065
  },
4066
+ {
4067
+ "kind": "method",
4068
+ "name": "hierarchy",
4069
+ "return": {
4070
+ "type": {
4071
+ "text": ""
4072
+ }
4073
+ },
4074
+ "description": "Returns a snapshot of the instantiated node tree, or `null` while there is none (the\ncontainer asset has not loaded, or the element has left the document). One call grounds a\nsession — a browser console, a test, an agent — in the vocabulary `pc-node` binding\nresolves against: the instantiated names (HierarchyNode.name), paths, match\nindices, attached component types and the material assignments of render components\n(HierarchyNode.materials). `String(...)` of the result, or of any node in it,\nis the printable form.\n\nThe snapshot is plain data, computed afresh each call: it does not follow later changes\nto the hierarchy, and mutating it changes nothing."
4075
+ },
4014
4076
  {
4015
4077
  "kind": "method",
4016
4078
  "name": "ready",
@@ -4087,6 +4149,22 @@
4087
4149
  "name": "ModelElement",
4088
4150
  "module": "src/model.ts"
4089
4151
  }
4152
+ },
4153
+ {
4154
+ "kind": "js",
4155
+ "name": "HierarchyMaterial",
4156
+ "declaration": {
4157
+ "name": "HierarchyMaterial",
4158
+ "module": "src/model.ts"
4159
+ }
4160
+ },
4161
+ {
4162
+ "kind": "js",
4163
+ "name": "HierarchyNode",
4164
+ "declaration": {
4165
+ "name": "HierarchyNode",
4166
+ "module": "src/model.ts"
4167
+ }
4090
4168
  }
4091
4169
  ]
4092
4170
  },
@@ -4350,6 +4428,25 @@
4350
4428
  }
4351
4429
  }
4352
4430
  },
4431
+ {
4432
+ "kind": "field",
4433
+ "name": "materialOverrides",
4434
+ "description": "Gets the material overrides.",
4435
+ "parameters": [
4436
+ {
4437
+ "description": "The mapping, or `null`.",
4438
+ "name": "value"
4439
+ }
4440
+ ],
4441
+ "type": {
4442
+ "text": "MaterialOverrides | null"
4443
+ },
4444
+ "return": {
4445
+ "type": {
4446
+ "text": ""
4447
+ }
4448
+ }
4449
+ },
4353
4450
  {
4354
4451
  "kind": "field",
4355
4452
  "name": "name",
@@ -4582,6 +4679,14 @@
4582
4679
  "description": "Which match to bind when `name` matches more than one node, 0-based in depth-first order. Optional for a unique match; required for an ambiguous one.",
4583
4680
  "fieldName": "index"
4584
4681
  },
4682
+ {
4683
+ "name": "material-overrides",
4684
+ "type": {
4685
+ "text": "string"
4686
+ },
4687
+ "description": "Overrides material assignments on the bound node's render component, as a JSON object from selector to `pc-material` id — for example `{\"name:CarPaint\": \"candy-red\", \"index:7\": \"smoked-glass\"}`. A `name:X` key selects every mesh instance whose baseline material is named `X`; an `index:N` key selects mesh instance `N` and wins over a name rule for the same instance. Assignments no rule matches keep their baseline materials, and removing the attribute restores all of them. Use `pc-model.hierarchy()` to discover the names and indices a node offers.",
4688
+ "fieldName": "materialOverrides"
4689
+ },
4585
4690
  {
4586
4691
  "name": "name",
4587
4692
  "type": {
@@ -4687,6 +4792,14 @@
4687
4792
  "name": "NodeElement",
4688
4793
  "module": "src/node.ts"
4689
4794
  }
4795
+ },
4796
+ {
4797
+ "kind": "js",
4798
+ "name": "MaterialOverrides",
4799
+ "declaration": {
4800
+ "name": "MaterialOverrides",
4801
+ "module": "src/node.ts"
4802
+ }
4690
4803
  }
4691
4804
  ]
4692
4805
  },
@@ -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, POINTER_ATTRIBUTES };
61
+ export { EntityBaseElement };
@@ -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, POINTER_ATTRIBUTES };
61
+ export { EntityBaseElement };
package/dist/index.d.cts CHANGED
@@ -77,3 +77,5 @@ declare global {
77
77
  }
78
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 };
79
79
  export type { AsyncElementTagName } from './async-element.cjs';
80
+ export type { HierarchyMaterial, HierarchyNode } from './model.cjs';
81
+ export type { MaterialOverrides } from './node.cjs';
package/dist/index.d.ts CHANGED
@@ -77,3 +77,5 @@ declare global {
77
77
  }
78
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 };
79
79
  export type { AsyncElementTagName } from './async-element.js';
80
+ export type { HierarchyMaterial, HierarchyNode } from './model.js';
81
+ export type { MaterialOverrides } from './node.js';
@@ -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 {};
@@ -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 {};
@@ -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.
@@ -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 };