@playcanvas/web-components 0.16.0 → 0.18.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 (126) hide show
  1. package/README.md +5 -3
  2. package/dist/app.d.cts +18 -13
  3. package/dist/app.d.ts +18 -13
  4. package/dist/asset.d.cts +13 -3
  5. package/dist/asset.d.ts +13 -3
  6. package/dist/async-element.d.cts +13 -13
  7. package/dist/async-element.d.ts +13 -13
  8. package/dist/components/anim-clip.d.cts +4 -0
  9. package/dist/components/anim-clip.d.ts +4 -0
  10. package/dist/components/anim-component.d.cts +38 -5
  11. package/dist/components/anim-component.d.ts +38 -5
  12. package/dist/components/audio-listener-component.d.cts +26 -0
  13. package/dist/components/audio-listener-component.d.ts +26 -0
  14. package/dist/components/button-component.d.cts +10 -1
  15. package/dist/components/button-component.d.ts +10 -1
  16. package/dist/components/camera-component.d.cts +37 -1
  17. package/dist/components/camera-component.d.ts +37 -1
  18. package/dist/components/collision-component.d.cts +9 -1
  19. package/dist/components/collision-component.d.ts +9 -1
  20. package/dist/components/component.d.cts +3 -2
  21. package/dist/components/component.d.ts +3 -2
  22. package/dist/components/element-component.d.cts +11 -0
  23. package/dist/components/element-component.d.ts +11 -0
  24. package/dist/components/gsplat-component.d.cts +6 -0
  25. package/dist/components/gsplat-component.d.ts +6 -0
  26. package/dist/components/joint-component.d.cts +14 -2
  27. package/dist/components/joint-component.d.ts +14 -2
  28. package/dist/components/{layoutchild-component.d.cts → layout-child-component.d.cts} +7 -1
  29. package/dist/components/{layoutchild-component.d.ts → layout-child-component.d.ts} +7 -1
  30. package/dist/components/{layoutgroup-component.d.cts → layout-group-component.d.cts} +7 -1
  31. package/dist/components/{layoutgroup-component.d.ts → layout-group-component.d.ts} +7 -1
  32. package/dist/components/light-component.d.cts +52 -1
  33. package/dist/components/light-component.d.ts +52 -1
  34. package/dist/components/{particlesystem-component.d.cts → particle-system-component.d.cts} +7 -1
  35. package/dist/components/{particlesystem-component.d.ts → particle-system-component.d.ts} +7 -1
  36. package/dist/components/render-component.d.cts +7 -0
  37. package/dist/components/render-component.d.ts +7 -0
  38. package/dist/components/{rigidbody-component.d.cts → rigid-body-component.d.cts} +8 -1
  39. package/dist/components/{rigidbody-component.d.ts → rigid-body-component.d.ts} +8 -1
  40. package/dist/components/screen-component.d.cts +6 -0
  41. package/dist/components/screen-component.d.ts +6 -0
  42. package/dist/components/script-component.d.cts +26 -12
  43. package/dist/components/script-component.d.ts +26 -12
  44. package/dist/components/{script.d.cts → script-instance.d.cts} +11 -7
  45. package/dist/components/{script.d.ts → script-instance.d.ts} +11 -7
  46. package/dist/components/{scrollview-component.d.cts → scroll-view-component.d.cts} +7 -1
  47. package/dist/components/{scrollview-component.d.ts → scroll-view-component.d.ts} +7 -1
  48. package/dist/components/scrollbar-component.d.cts +6 -0
  49. package/dist/components/scrollbar-component.d.ts +6 -0
  50. package/dist/components/sound-component.d.cts +7 -1
  51. package/dist/components/sound-component.d.ts +7 -1
  52. package/dist/components/sound-slot.d.cts +5 -2
  53. package/dist/components/sound-slot.d.ts +5 -2
  54. package/dist/custom-elements.json +1852 -974
  55. package/dist/entity-base.d.cts +7 -6
  56. package/dist/entity-base.d.ts +7 -6
  57. package/dist/entity-owner.d.cts +118 -0
  58. package/dist/entity-owner.d.ts +118 -0
  59. package/dist/entity.d.cts +14 -102
  60. package/dist/entity.d.ts +14 -102
  61. package/dist/index.d.cts +26 -22
  62. package/dist/index.d.ts +26 -22
  63. package/dist/material.d.cts +18 -7
  64. package/dist/material.d.ts +18 -7
  65. package/dist/model.d.cts +72 -24
  66. package/dist/model.d.ts +72 -24
  67. package/dist/node.d.cts +6 -1
  68. package/dist/node.d.ts +6 -1
  69. package/dist/pwc.cjs +807 -293
  70. package/dist/pwc.cjs.map +1 -1
  71. package/dist/pwc.js +807 -293
  72. package/dist/pwc.js.map +1 -1
  73. package/dist/pwc.min.js +1 -1
  74. package/dist/pwc.min.js.map +1 -1
  75. package/dist/pwc.min.mjs +1 -1
  76. package/dist/pwc.min.mjs.map +1 -1
  77. package/dist/pwc.mjs +805 -292
  78. package/dist/pwc.mjs.map +1 -1
  79. package/dist/scene.d.cts +3 -0
  80. package/dist/scene.d.ts +3 -0
  81. package/dist/sky.d.cts +4 -0
  82. package/dist/sky.d.ts +4 -0
  83. package/dist/vscode.html-custom-data.json +351 -121
  84. package/dist/{module.d.cts → wasm.d.cts} +10 -6
  85. package/dist/{module.d.ts → wasm.d.ts} +10 -6
  86. package/dist/web-types.json +465 -291
  87. package/package.json +7 -7
  88. package/src/app.ts +49 -35
  89. package/src/asset.ts +13 -4
  90. package/src/async-element.ts +14 -14
  91. package/src/components/anim-clip.ts +4 -0
  92. package/src/components/anim-component.ts +89 -14
  93. package/src/components/audio-listener-component.ts +36 -0
  94. package/src/components/button-component.ts +10 -1
  95. package/src/components/camera-component.ts +65 -6
  96. package/src/components/collision-component.ts +9 -1
  97. package/src/components/component.ts +4 -3
  98. package/src/components/element-component.ts +11 -0
  99. package/src/components/gsplat-component.ts +6 -0
  100. package/src/components/joint-component.ts +14 -2
  101. package/src/components/{layoutchild-component.ts → layout-child-component.ts} +8 -2
  102. package/src/components/{layoutgroup-component.ts → layout-group-component.ts} +8 -2
  103. package/src/components/light-component.ts +110 -17
  104. package/src/components/{particlesystem-component.ts → particle-system-component.ts} +8 -2
  105. package/src/components/render-component.ts +7 -0
  106. package/src/components/{rigidbody-component.ts → rigid-body-component.ts} +9 -2
  107. package/src/components/screen-component.ts +6 -0
  108. package/src/components/script-component.ts +66 -42
  109. package/src/components/{script.ts → script-instance.ts} +18 -14
  110. package/src/components/{scrollview-component.ts → scroll-view-component.ts} +8 -2
  111. package/src/components/scrollbar-component.ts +6 -0
  112. package/src/components/sound-component.ts +8 -2
  113. package/src/components/sound-slot.ts +7 -4
  114. package/src/entity-base.ts +8 -7
  115. package/src/entity-owner.ts +298 -0
  116. package/src/entity.ts +21 -271
  117. package/src/index.ts +38 -25
  118. package/src/material.ts +19 -8
  119. package/src/model.ts +164 -72
  120. package/src/node.ts +15 -6
  121. package/src/scene.ts +3 -0
  122. package/src/sky.ts +4 -0
  123. package/src/{module.ts → wasm.ts} +12 -8
  124. package/dist/components/listener-component.d.cts +0 -20
  125. package/dist/components/listener-component.d.ts +0 -20
  126. package/src/components/listener-component.ts +0 -30
package/dist/index.d.ts CHANGED
@@ -7,36 +7,37 @@
7
7
  * @module EngineWebComponents
8
8
  */
9
9
  import { AsyncElement, whenReady } from './async-element.js';
10
- import { ModuleElement } from './module.js';
10
+ import { WasmElement } from './wasm.js';
11
11
  import { AppElement } from './app.js';
12
12
  import { EntityElement } from './entity.js';
13
+ import { ModelElement } from './model.js';
13
14
  import { AssetElement } from './asset.js';
14
15
  import { AnimComponentElement } from './components/anim-component.js';
15
16
  import { AnimClipElement } from './components/anim-clip.js';
16
- import { ListenerComponentElement } from './components/listener-component.js';
17
+ import { AudioListenerComponentElement } from './components/audio-listener-component.js';
17
18
  import { ButtonComponentElement } from './components/button-component.js';
18
19
  import { CameraComponentElement } from './components/camera-component.js';
19
20
  import { CollisionComponentElement } from './components/collision-component.js';
20
21
  import { ComponentElement } from './components/component.js';
21
22
  import { ElementComponentElement } from './components/element-component.js';
22
23
  import { JointComponentElement } from './components/joint-component.js';
23
- import { LayoutChildComponentElement } from './components/layoutchild-component.js';
24
- import { LayoutGroupComponentElement } from './components/layoutgroup-component.js';
24
+ import { LayoutChildComponentElement } from './components/layout-child-component.js';
25
+ import { LayoutGroupComponentElement } from './components/layout-group-component.js';
25
26
  import { LightComponentElement } from './components/light-component.js';
26
- import { ParticleSystemComponentElement } from './components/particlesystem-component.js';
27
+ import { ParticleSystemComponentElement } from './components/particle-system-component.js';
27
28
  import { RenderComponentElement } from './components/render-component.js';
28
- import { RigidBodyComponentElement } from './components/rigidbody-component.js';
29
+ import { RigidBodyComponentElement } from './components/rigid-body-component.js';
29
30
  import { ScreenComponentElement } from './components/screen-component.js';
30
31
  import { ScrollbarComponentElement } from './components/scrollbar-component.js';
31
- import { ScrollViewComponentElement } from './components/scrollview-component.js';
32
+ import { ScrollViewComponentElement } from './components/scroll-view-component.js';
32
33
  import { ScriptComponentElement } from './components/script-component.js';
33
- import { ScriptElement } from './components/script.js';
34
+ import { ScriptInstanceElement } from './components/script-instance.js';
34
35
  import { SoundComponentElement } from './components/sound-component.js';
35
36
  import { SoundSlotElement } from './components/sound-slot.js';
36
37
  import { GSplatComponentElement } from './components/gsplat-component.js';
37
38
  import { EntityBaseElement } from './entity-base.js';
39
+ import { EntityOwnerElement } from './entity-owner.js';
38
40
  import { MaterialElement } from './material.js';
39
- import { ModelElement } from './model.js';
40
41
  import { NodeElement } from './node.js';
41
42
  import { SceneElement } from './scene.js';
42
43
  import { SkyElement } from './sky.js';
@@ -60,29 +61,32 @@ declare global {
60
61
  'pc-entity': EntityElement;
61
62
  'pc-gsplat': GSplatComponentElement;
62
63
  'pc-joint': JointComponentElement;
63
- 'pc-layoutchild': LayoutChildComponentElement;
64
- 'pc-layoutgroup': LayoutGroupComponentElement;
64
+ 'pc-layout-child': LayoutChildComponentElement;
65
+ 'pc-layout-group': LayoutGroupComponentElement;
65
66
  'pc-light': LightComponentElement;
66
- 'pc-listener': ListenerComponentElement;
67
+ 'pc-audio-listener': AudioListenerComponentElement;
67
68
  'pc-material': MaterialElement;
68
69
  'pc-model': ModelElement;
69
- 'pc-module': ModuleElement;
70
+ 'pc-wasm': WasmElement;
70
71
  'pc-node': NodeElement;
71
- 'pc-particles': ParticleSystemComponentElement;
72
+ 'pc-particle-system': ParticleSystemComponentElement;
72
73
  'pc-render': RenderComponentElement;
73
- 'pc-rigidbody': RigidBodyComponentElement;
74
+ 'pc-rigid-body': RigidBodyComponentElement;
74
75
  'pc-scene': SceneElement;
75
76
  'pc-screen': ScreenComponentElement;
76
- 'pc-script': ScriptElement;
77
- 'pc-scripts': ScriptComponentElement;
77
+ 'pc-script-instance': ScriptInstanceElement;
78
+ 'pc-script': ScriptComponentElement;
78
79
  'pc-scrollbar': ScrollbarComponentElement;
79
- 'pc-scrollview': ScrollViewComponentElement;
80
+ 'pc-scroll-view': ScrollViewComponentElement;
80
81
  'pc-sky': SkyElement;
81
- 'pc-sound': SoundSlotElement;
82
- 'pc-sounds': SoundComponentElement;
82
+ 'pc-sound-slot': SoundSlotElement;
83
+ 'pc-sound': SoundComponentElement;
83
84
  }
84
85
  }
85
- export { AsyncElement, ModuleElement, AppElement, EntityElement, AssetElement, AnimComponentElement, AnimClipElement, 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 };
86
+ export { AsyncElement, WasmElement, AppElement, EntityElement, AssetElement, AnimComponentElement, AnimClipElement, ButtonComponentElement, CameraComponentElement, CollisionComponentElement, ComponentElement, ElementComponentElement, JointComponentElement, LayoutChildComponentElement, LayoutGroupComponentElement, ParticleSystemComponentElement, LightComponentElement, AudioListenerComponentElement, RenderComponentElement, RigidBodyComponentElement, ScreenComponentElement, ScrollbarComponentElement, ScrollViewComponentElement, ScriptComponentElement, ScriptInstanceElement, SoundComponentElement, SoundSlotElement, GSplatComponentElement, EntityBaseElement, EntityOwnerElement, MaterialElement, ModelElement, NodeElement, SceneElement, SkyElement, whenReady };
87
+ export type { AddressMode, MagFilterMode, MinFilterMode } from './asset.js';
86
88
  export type { AsyncElementTagName } from './async-element.js';
89
+ export type { JointType, MotionMode } from './components/joint-component.js';
90
+ export type { BlendType, ColorChannel, CullMode, FresnelModel, OccludeSpecular, OpacityDither, ScalarChannel } from './material.js';
87
91
  export type { HierarchyMaterial, HierarchyNode } from './model.js';
88
- export type { MaterialOverrides } from './node.js';
92
+ export type { MaterialOverrides, NodeBindingState } from './node.js';
@@ -1,11 +1,18 @@
1
1
  import { Color, StandardMaterial, Vec2 } from 'playcanvas';
2
- type BlendType = 'none' | 'normal' | 'additive' | 'additive-alpha' | 'premultiplied' | 'multiplicative' | 'multiplicative-2x' | 'screen' | 'min' | 'max' | 'subtractive';
3
- type CullMode = 'none' | 'back' | 'front' | 'front-and-back';
4
- type FresnelModel = 'none' | 'schlick';
5
- type OccludeSpecular = 'none' | 'ao' | 'gloss-dependent';
6
- type OpacityDither = 'none' | 'bayer8' | 'bluenoise' | 'ignnoise';
7
- type ColorChannel = 'r' | 'g' | 'b' | 'a' | 'rgb';
8
- type ScalarChannel = 'r' | 'g' | 'b' | 'a';
2
+ /** The blend modes for a material. */
3
+ export type BlendType = 'none' | 'normal' | 'additive' | 'additive-alpha' | 'premultiplied' | 'multiplicative' | 'multiplicative-2x' | 'screen' | 'min' | 'max' | 'subtractive';
4
+ /** The face culling modes for a material. */
5
+ export type CullMode = 'none' | 'back' | 'front' | 'front-and-back';
6
+ /** The Fresnel models for a material. */
7
+ export type FresnelModel = 'none' | 'schlick';
8
+ /** The specular occlusion modes for a material. */
9
+ export type OccludeSpecular = 'none' | 'ao' | 'gloss-dependent';
10
+ /** The opacity dithering modes for a material. */
11
+ export type OpacityDither = 'none' | 'bayer8' | 'bluenoise' | 'ignnoise';
12
+ /** The texture channels a color map can sample. */
13
+ export type ColorChannel = 'r' | 'g' | 'b' | 'a' | 'rgb';
14
+ /** The texture channels a scalar map can sample. */
15
+ export type ScalarChannel = 'r' | 'g' | 'b' | 'a';
9
16
  /**
10
17
  * The MaterialElement interface provides properties and methods for manipulating
11
18
  * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-material/ | `<pc-material>`} elements.
@@ -30,6 +37,10 @@ type ScalarChannel = 'r' | 'g' | 'b' | 'a';
30
37
  * The two aliases are documented here rather than on an accessor, because they resolve to the
31
38
  * `gloss` properties and would otherwise inherit gloss's description - which reads inverted.
32
39
  *
40
+ * @elementSummary The `<pc-material>` element defines a physically based material, which
41
+ * `<pc-render>` elements apply by naming its `id`. It is metal/rough by default, with `metalness`
42
+ * starting at 0. Must be a direct child of `<pc-app>`.
43
+ *
33
44
  * @attribute {number} roughness - The roughness of the material, from 0 (shiny) to 1 (rough). An
34
45
  * alias for `gloss` that also inverts it, so do not combine it with the `gloss` attributes.
35
46
  * @attribute {string} roughness-map - The id of the `pc-asset` to use as the roughness map. An
@@ -1,11 +1,18 @@
1
1
  import { Color, StandardMaterial, Vec2 } from 'playcanvas';
2
- type BlendType = 'none' | 'normal' | 'additive' | 'additive-alpha' | 'premultiplied' | 'multiplicative' | 'multiplicative-2x' | 'screen' | 'min' | 'max' | 'subtractive';
3
- type CullMode = 'none' | 'back' | 'front' | 'front-and-back';
4
- type FresnelModel = 'none' | 'schlick';
5
- type OccludeSpecular = 'none' | 'ao' | 'gloss-dependent';
6
- type OpacityDither = 'none' | 'bayer8' | 'bluenoise' | 'ignnoise';
7
- type ColorChannel = 'r' | 'g' | 'b' | 'a' | 'rgb';
8
- type ScalarChannel = 'r' | 'g' | 'b' | 'a';
2
+ /** The blend modes for a material. */
3
+ export type BlendType = 'none' | 'normal' | 'additive' | 'additive-alpha' | 'premultiplied' | 'multiplicative' | 'multiplicative-2x' | 'screen' | 'min' | 'max' | 'subtractive';
4
+ /** The face culling modes for a material. */
5
+ export type CullMode = 'none' | 'back' | 'front' | 'front-and-back';
6
+ /** The Fresnel models for a material. */
7
+ export type FresnelModel = 'none' | 'schlick';
8
+ /** The specular occlusion modes for a material. */
9
+ export type OccludeSpecular = 'none' | 'ao' | 'gloss-dependent';
10
+ /** The opacity dithering modes for a material. */
11
+ export type OpacityDither = 'none' | 'bayer8' | 'bluenoise' | 'ignnoise';
12
+ /** The texture channels a color map can sample. */
13
+ export type ColorChannel = 'r' | 'g' | 'b' | 'a' | 'rgb';
14
+ /** The texture channels a scalar map can sample. */
15
+ export type ScalarChannel = 'r' | 'g' | 'b' | 'a';
9
16
  /**
10
17
  * The MaterialElement interface provides properties and methods for manipulating
11
18
  * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-material/ | `<pc-material>`} elements.
@@ -30,6 +37,10 @@ type ScalarChannel = 'r' | 'g' | 'b' | 'a';
30
37
  * The two aliases are documented here rather than on an accessor, because they resolve to the
31
38
  * `gloss` properties and would otherwise inherit gloss's description - which reads inverted.
32
39
  *
40
+ * @elementSummary The `<pc-material>` element defines a physically based material, which
41
+ * `<pc-render>` elements apply by naming its `id`. It is metal/rough by default, with `metalness`
42
+ * starting at 0. Must be a direct child of `<pc-app>`.
43
+ *
33
44
  * @attribute {number} roughness - The roughness of the material, from 0 (shiny) to 1 (rough). An
34
45
  * alias for `gloss` that also inverts it, so do not combine it with the `gloss` attributes.
35
46
  * @attribute {string} roughness-map - The id of the `pc-asset` to use as the roughness map. An
package/dist/model.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Entity } from 'playcanvas';
2
- import { AsyncElement } from './async-element.cjs';
2
+ import { EntityOwnerElement } from './entity-owner.cjs';
3
3
  /**
4
4
  * One material assignment of a {@link HierarchyNode} with a render component: a mesh instance's
5
5
  * position within the component and the runtime name of its current material.
@@ -61,14 +61,47 @@ type HierarchyNode = {
61
61
  * The ModelElement interface also inherits the properties and methods of the
62
62
  * {@link HTMLElement} interface.
63
63
  *
64
- * The element becomes ready once its container asset has loaded and the instantiated hierarchy has
65
- * been added to the scene `entity` is non-null by then. A failed load also settles readiness,
66
- * with `entity` remaining `null`: readiness means the load settled, not that it succeeded — listen
67
- * for `error`, or check `entity`, to tell the outcomes apart. Changing `asset` re-arms readiness
68
- * and instantiates anew, so a `ready()` obtained after the change resolves against the new
69
- * hierarchy. A `pc-model` outside a `pc-app`, or referencing an unknown asset id, warns and never
70
- * becomes ready.
64
+ * The element creates and fronts a stable host entity: `entity` is that host, created when the
65
+ * application builds its hierarchy and kept across `asset` changes, so the element's transform
66
+ * and tags are instance placement that composes with whatever transform the asset authored on
67
+ * its root. The instantiated content is parented beneath the host and exposed as
68
+ * {@link contentEntity}.
71
69
  *
70
+ * The element becomes ready once its current asset selection has settled: the container asset
71
+ * has loaded and its content root has been parented beneath the host, the load has failed
72
+ * (`contentEntity` stays `null` — listen for `error`, or check `contentEntity`, to tell the
73
+ * outcomes apart), or no asset is assigned at all. Changing `asset` re-arms readiness and
74
+ * instantiates anew, so a `ready()` obtained after the change resolves against the new content.
75
+ * A `pc-model` outside a `pc-app`, or referencing an unknown asset id, warns and never becomes
76
+ * ready.
77
+ *
78
+ * The pointer events below are dispatched by the containing `<pc-app>` element when the pointer
79
+ * intersects the model's geometry, exactly as for `<pc-entity>` — a hit on a content node that no
80
+ * `pc-node` fronts resolves to this element.
81
+ *
82
+ * @elementSummary The `<pc-model>` element instantiates a 3D model from a container asset
83
+ * (typically a GLB) beneath an entity of its own, so the element's transform and tags place the
84
+ * instance in the scene. Its `<pc-node>` children override what the asset authored. Place it in the
85
+ * `<pc-scene>`, or nest it under a `<pc-entity>`, another `<pc-model>` or a `<pc-node>`.
86
+ *
87
+ * @attribute {boolean} enabled - The enabled state of the model.
88
+ * @attribute {string} name - The name of the model.
89
+ * @attribute {string} position - The position of the model.
90
+ * @attribute {string} rotation - The rotation of the model.
91
+ * @attribute {string} scale - The scale of the model.
92
+ * @attribute {string} tags - The tags of the model.
93
+ * @attribute {string} onpointerenter - Script to run when the pointer moves onto the model.
94
+ * @attribute {string} onpointerleave - Script to run when the pointer moves off the model.
95
+ * @attribute {string} onpointermove - Script to run when the pointer moves over the model.
96
+ * @attribute {string} onpointerdown - Script to run when a pointer button is pressed over the
97
+ * model.
98
+ * @attribute {string} onpointerup - Script to run when a pointer button is released over the
99
+ * model.
100
+ * @fires {PointerEvent} pointerenter - Fired when the pointer moves onto the model.
101
+ * @fires {PointerEvent} pointerleave - Fired when the pointer moves off the model.
102
+ * @fires {PointerEvent} pointermove - Fired when the pointer moves over the model.
103
+ * @fires {PointerEvent} pointerdown - Fired when a pointer button is pressed over the model.
104
+ * @fires {PointerEvent} pointerup - Fired when a pointer button is released over the model.
72
105
  * @fires {Event} load - Fired each time a container asset finishes instantiating, including
73
106
  * re-instantiation after `asset` changes. Does not bubble — listen on this element, or use a
74
107
  * capture-phase listener on an ancestor.
@@ -76,14 +109,14 @@ type HierarchyNode = {
76
109
  * error in `message`. Does not bubble. The element still becomes ready — readiness means the load
77
110
  * settled, not that it succeeded.
78
111
  */
79
- declare class ModelElement extends AsyncElement {
112
+ declare class ModelElement extends EntityOwnerElement {
80
113
  private _asset;
81
- private _entity;
114
+ private _contentEntity;
82
115
  /**
83
- * Incremented on every new load and on disconnect, and captured by a load when it starts. A
84
- * load that resumes from an await or a load callback abandons itself if the value has moved
85
- * on, so a superseded load can neither instantiate a second entity nor parent one that has
86
- * since been destroyed.
116
+ * Incremented on every new load, on disconnect, and when the host entity dies, and captured
117
+ * by a load when it starts. A load that resumes from an await or a load callback abandons
118
+ * itself if the value has moved on, so a superseded load can neither instantiate a second
119
+ * content root nor parent one under a host a newer cycle has already replaced.
87
120
  */
88
121
  private _loadGeneration;
89
122
  /**
@@ -94,11 +127,12 @@ declare class ModelElement extends AsyncElement {
94
127
  private _loadHandle;
95
128
  private _errorHandle;
96
129
  /**
97
- * The root entity of the instantiated model. `null` until the container asset has loaded
98
- * and been instantiated, and again once the element has been removed from the document.
99
- * @returns The model's root entity, or `null`.
130
+ * The root entity of the instantiated model content, parented beneath the host entity.
131
+ * `null` until the container asset has loaded and been instantiated, after a failed load,
132
+ * and again once the element has been removed from the document.
133
+ * @returns The content root entity, or `null`.
100
134
  */
101
- get entity(): Entity | null;
135
+ get contentEntity(): Entity | null;
102
136
  /**
103
137
  * Returns a snapshot of the instantiated node tree, or `null` while there is none (the
104
138
  * container asset has not loaded, or the element has left the document). One call grounds a
@@ -109,23 +143,37 @@ declare class ModelElement extends AsyncElement {
109
143
  * is the printable form.
110
144
  *
111
145
  * The snapshot is plain data, computed afresh each call: it does not follow later changes
112
- * to the hierarchy, and mutating it changes nothing.
146
+ * to the hierarchy, and mutating it changes nothing. It covers the instantiated content
147
+ * only — the host entity the element fronts is not part of the asset's node tree.
113
148
  *
114
149
  * @returns The root of the instantiated node tree, or `null`.
115
150
  */
116
151
  hierarchy(): HierarchyNode | null;
117
152
  connectedCallback(): void;
118
153
  disconnectedCallback(): void;
154
+ /**
155
+ * Starts (or restarts) the content load once the host has been parented. Readiness is not
156
+ * announced here — it tracks the content settling, not the host entering the scene graph.
157
+ */
158
+ protected _onBuilt(): void;
159
+ /**
160
+ * Extends the owner reset for the content: the engine's destroy cascade has already taken
161
+ * the content root down with the host subtree, so only the reference and the in-flight load
162
+ * are dropped here. The next build re-creates the host and re-instantiates the content.
163
+ *
164
+ * @param entity - The host entity that was destroyed.
165
+ */
166
+ protected _onEntityDestroy(entity: Entity): void;
119
167
  private _detachLoadHandlers;
120
168
  /**
121
- * Resolves readiness and dispatches the `load` event. Called once the instantiated hierarchy
122
- * has been parented — readiness means "in the scene graph", matching `pc-entity`, so a ready
123
- * model's entity always has world transforms.
169
+ * Resolves readiness and dispatches the `load` event. Called once the instantiated content
170
+ * has been parented beneath the host the host itself is already in the scene graph by
171
+ * then, so a ready model's content always has world transforms.
124
172
  */
125
173
  private _announceLoad;
126
174
  private _instantiate;
127
- private _loadModel;
128
- private _unloadModel;
175
+ private _destroyContent;
176
+ private _loadContent;
129
177
  /**
130
178
  * Sets the id of the `pc-asset` to use for the model.
131
179
  * @param value - The asset ID.
package/dist/model.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Entity } from 'playcanvas';
2
- import { AsyncElement } from './async-element.js';
2
+ import { EntityOwnerElement } from './entity-owner.js';
3
3
  /**
4
4
  * One material assignment of a {@link HierarchyNode} with a render component: a mesh instance's
5
5
  * position within the component and the runtime name of its current material.
@@ -61,14 +61,47 @@ type HierarchyNode = {
61
61
  * The ModelElement interface also inherits the properties and methods of the
62
62
  * {@link HTMLElement} interface.
63
63
  *
64
- * The element becomes ready once its container asset has loaded and the instantiated hierarchy has
65
- * been added to the scene `entity` is non-null by then. A failed load also settles readiness,
66
- * with `entity` remaining `null`: readiness means the load settled, not that it succeeded — listen
67
- * for `error`, or check `entity`, to tell the outcomes apart. Changing `asset` re-arms readiness
68
- * and instantiates anew, so a `ready()` obtained after the change resolves against the new
69
- * hierarchy. A `pc-model` outside a `pc-app`, or referencing an unknown asset id, warns and never
70
- * becomes ready.
64
+ * The element creates and fronts a stable host entity: `entity` is that host, created when the
65
+ * application builds its hierarchy and kept across `asset` changes, so the element's transform
66
+ * and tags are instance placement that composes with whatever transform the asset authored on
67
+ * its root. The instantiated content is parented beneath the host and exposed as
68
+ * {@link contentEntity}.
71
69
  *
70
+ * The element becomes ready once its current asset selection has settled: the container asset
71
+ * has loaded and its content root has been parented beneath the host, the load has failed
72
+ * (`contentEntity` stays `null` — listen for `error`, or check `contentEntity`, to tell the
73
+ * outcomes apart), or no asset is assigned at all. Changing `asset` re-arms readiness and
74
+ * instantiates anew, so a `ready()` obtained after the change resolves against the new content.
75
+ * A `pc-model` outside a `pc-app`, or referencing an unknown asset id, warns and never becomes
76
+ * ready.
77
+ *
78
+ * The pointer events below are dispatched by the containing `<pc-app>` element when the pointer
79
+ * intersects the model's geometry, exactly as for `<pc-entity>` — a hit on a content node that no
80
+ * `pc-node` fronts resolves to this element.
81
+ *
82
+ * @elementSummary The `<pc-model>` element instantiates a 3D model from a container asset
83
+ * (typically a GLB) beneath an entity of its own, so the element's transform and tags place the
84
+ * instance in the scene. Its `<pc-node>` children override what the asset authored. Place it in the
85
+ * `<pc-scene>`, or nest it under a `<pc-entity>`, another `<pc-model>` or a `<pc-node>`.
86
+ *
87
+ * @attribute {boolean} enabled - The enabled state of the model.
88
+ * @attribute {string} name - The name of the model.
89
+ * @attribute {string} position - The position of the model.
90
+ * @attribute {string} rotation - The rotation of the model.
91
+ * @attribute {string} scale - The scale of the model.
92
+ * @attribute {string} tags - The tags of the model.
93
+ * @attribute {string} onpointerenter - Script to run when the pointer moves onto the model.
94
+ * @attribute {string} onpointerleave - Script to run when the pointer moves off the model.
95
+ * @attribute {string} onpointermove - Script to run when the pointer moves over the model.
96
+ * @attribute {string} onpointerdown - Script to run when a pointer button is pressed over the
97
+ * model.
98
+ * @attribute {string} onpointerup - Script to run when a pointer button is released over the
99
+ * model.
100
+ * @fires {PointerEvent} pointerenter - Fired when the pointer moves onto the model.
101
+ * @fires {PointerEvent} pointerleave - Fired when the pointer moves off the model.
102
+ * @fires {PointerEvent} pointermove - Fired when the pointer moves over the model.
103
+ * @fires {PointerEvent} pointerdown - Fired when a pointer button is pressed over the model.
104
+ * @fires {PointerEvent} pointerup - Fired when a pointer button is released over the model.
72
105
  * @fires {Event} load - Fired each time a container asset finishes instantiating, including
73
106
  * re-instantiation after `asset` changes. Does not bubble — listen on this element, or use a
74
107
  * capture-phase listener on an ancestor.
@@ -76,14 +109,14 @@ type HierarchyNode = {
76
109
  * error in `message`. Does not bubble. The element still becomes ready — readiness means the load
77
110
  * settled, not that it succeeded.
78
111
  */
79
- declare class ModelElement extends AsyncElement {
112
+ declare class ModelElement extends EntityOwnerElement {
80
113
  private _asset;
81
- private _entity;
114
+ private _contentEntity;
82
115
  /**
83
- * Incremented on every new load and on disconnect, and captured by a load when it starts. A
84
- * load that resumes from an await or a load callback abandons itself if the value has moved
85
- * on, so a superseded load can neither instantiate a second entity nor parent one that has
86
- * since been destroyed.
116
+ * Incremented on every new load, on disconnect, and when the host entity dies, and captured
117
+ * by a load when it starts. A load that resumes from an await or a load callback abandons
118
+ * itself if the value has moved on, so a superseded load can neither instantiate a second
119
+ * content root nor parent one under a host a newer cycle has already replaced.
87
120
  */
88
121
  private _loadGeneration;
89
122
  /**
@@ -94,11 +127,12 @@ declare class ModelElement extends AsyncElement {
94
127
  private _loadHandle;
95
128
  private _errorHandle;
96
129
  /**
97
- * The root entity of the instantiated model. `null` until the container asset has loaded
98
- * and been instantiated, and again once the element has been removed from the document.
99
- * @returns The model's root entity, or `null`.
130
+ * The root entity of the instantiated model content, parented beneath the host entity.
131
+ * `null` until the container asset has loaded and been instantiated, after a failed load,
132
+ * and again once the element has been removed from the document.
133
+ * @returns The content root entity, or `null`.
100
134
  */
101
- get entity(): Entity | null;
135
+ get contentEntity(): Entity | null;
102
136
  /**
103
137
  * Returns a snapshot of the instantiated node tree, or `null` while there is none (the
104
138
  * container asset has not loaded, or the element has left the document). One call grounds a
@@ -109,23 +143,37 @@ declare class ModelElement extends AsyncElement {
109
143
  * is the printable form.
110
144
  *
111
145
  * The snapshot is plain data, computed afresh each call: it does not follow later changes
112
- * to the hierarchy, and mutating it changes nothing.
146
+ * to the hierarchy, and mutating it changes nothing. It covers the instantiated content
147
+ * only — the host entity the element fronts is not part of the asset's node tree.
113
148
  *
114
149
  * @returns The root of the instantiated node tree, or `null`.
115
150
  */
116
151
  hierarchy(): HierarchyNode | null;
117
152
  connectedCallback(): void;
118
153
  disconnectedCallback(): void;
154
+ /**
155
+ * Starts (or restarts) the content load once the host has been parented. Readiness is not
156
+ * announced here — it tracks the content settling, not the host entering the scene graph.
157
+ */
158
+ protected _onBuilt(): void;
159
+ /**
160
+ * Extends the owner reset for the content: the engine's destroy cascade has already taken
161
+ * the content root down with the host subtree, so only the reference and the in-flight load
162
+ * are dropped here. The next build re-creates the host and re-instantiates the content.
163
+ *
164
+ * @param entity - The host entity that was destroyed.
165
+ */
166
+ protected _onEntityDestroy(entity: Entity): void;
119
167
  private _detachLoadHandlers;
120
168
  /**
121
- * Resolves readiness and dispatches the `load` event. Called once the instantiated hierarchy
122
- * has been parented — readiness means "in the scene graph", matching `pc-entity`, so a ready
123
- * model's entity always has world transforms.
169
+ * Resolves readiness and dispatches the `load` event. Called once the instantiated content
170
+ * has been parented beneath the host the host itself is already in the scene graph by
171
+ * then, so a ready model's content always has world transforms.
124
172
  */
125
173
  private _announceLoad;
126
174
  private _instantiate;
127
- private _loadModel;
128
- private _unloadModel;
175
+ private _destroyContent;
176
+ private _loadContent;
129
177
  /**
130
178
  * Sets the id of the `pc-asset` to use for the model.
131
179
  * @param value - The asset ID.
package/dist/node.d.cts CHANGED
@@ -6,7 +6,7 @@ import { EntityBaseElement } from './entity-base.cjs';
6
6
  * `missing`/`ambiguous`/`duplicate` when resolution failed — each accompanied by a warning
7
7
  * naming the cause.
8
8
  */
9
- type NodeBindingState = 'pending' | 'bound' | 'missing' | 'ambiguous' | 'duplicate';
9
+ export type NodeBindingState = 'pending' | 'bound' | 'missing' | 'ambiguous' | 'duplicate';
10
10
  /**
11
11
  * A sparse mapping from selector to `pc-material` id, as carried by the `material-overrides`
12
12
  * attribute and `materialOverrides` property. A `name:X` key selects every mesh instance of the
@@ -38,6 +38,11 @@ type MaterialOverrides = Readonly<Record<string, string>>;
38
38
  * The pointer events below are dispatched by the containing `<pc-app>` element when the pointer
39
39
  * intersects the bound node's geometry, exactly as for `<pc-entity>`.
40
40
  *
41
+ * @elementSummary The `<pc-node>` element binds to a node inside the hierarchy a `<pc-model>`
42
+ * instantiated and declares overrides against it: a transform, an enabled state, tags, components
43
+ * to add, or content to attach. Its `name` is a lookup, never a rename. Must be a descendant of
44
+ * `<pc-model>`.
45
+ *
41
46
  * @attribute {string} name - The name of the node to bind, resolved within the nearest ancestor
42
47
  * `pc-model` (or `pc-node`) once it has instantiated.
43
48
  * @attribute {number} index - Which match to bind when `name` matches more than one node,
package/dist/node.d.ts CHANGED
@@ -6,7 +6,7 @@ import { EntityBaseElement } from './entity-base.js';
6
6
  * `missing`/`ambiguous`/`duplicate` when resolution failed — each accompanied by a warning
7
7
  * naming the cause.
8
8
  */
9
- type NodeBindingState = 'pending' | 'bound' | 'missing' | 'ambiguous' | 'duplicate';
9
+ export type NodeBindingState = 'pending' | 'bound' | 'missing' | 'ambiguous' | 'duplicate';
10
10
  /**
11
11
  * A sparse mapping from selector to `pc-material` id, as carried by the `material-overrides`
12
12
  * attribute and `materialOverrides` property. A `name:X` key selects every mesh instance of the
@@ -38,6 +38,11 @@ type MaterialOverrides = Readonly<Record<string, string>>;
38
38
  * The pointer events below are dispatched by the containing `<pc-app>` element when the pointer
39
39
  * intersects the bound node's geometry, exactly as for `<pc-entity>`.
40
40
  *
41
+ * @elementSummary The `<pc-node>` element binds to a node inside the hierarchy a `<pc-model>`
42
+ * instantiated and declares overrides against it: a transform, an enabled state, tags, components
43
+ * to add, or content to attach. Its `name` is a lookup, never a rename. Must be a descendant of
44
+ * `<pc-model>`.
45
+ *
41
46
  * @attribute {string} name - The name of the node to bind, resolved within the nearest ancestor
42
47
  * `pc-model` (or `pc-node`) once it has instantiated.
43
48
  * @attribute {number} index - Which match to bind when `name` matches more than one node,