@playcanvas/web-components 0.17.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 (117) hide show
  1. package/README.md +5 -3
  2. package/dist/app.d.cts +4 -0
  3. package/dist/app.d.ts +4 -0
  4. package/dist/asset.d.cts +13 -3
  5. package/dist/asset.d.ts +13 -3
  6. package/dist/components/anim-clip.d.cts +4 -0
  7. package/dist/components/anim-clip.d.ts +4 -0
  8. package/dist/components/anim-component.d.cts +5 -0
  9. package/dist/components/anim-component.d.ts +5 -0
  10. package/dist/components/audio-listener-component.d.cts +4 -0
  11. package/dist/components/audio-listener-component.d.ts +4 -0
  12. package/dist/components/button-component.d.cts +5 -0
  13. package/dist/components/button-component.d.ts +5 -0
  14. package/dist/components/camera-component.d.cts +35 -1
  15. package/dist/components/camera-component.d.ts +35 -1
  16. package/dist/components/collision-component.d.cts +4 -0
  17. package/dist/components/collision-component.d.ts +4 -0
  18. package/dist/components/element-component.d.cts +4 -0
  19. package/dist/components/element-component.d.ts +4 -0
  20. package/dist/components/gsplat-component.d.cts +4 -0
  21. package/dist/components/gsplat-component.d.ts +4 -0
  22. package/dist/components/joint-component.d.cts +12 -2
  23. package/dist/components/joint-component.d.ts +12 -2
  24. package/dist/components/layout-child-component.d.cts +4 -0
  25. package/dist/components/layout-child-component.d.ts +4 -0
  26. package/dist/components/layout-group-component.d.cts +4 -0
  27. package/dist/components/layout-group-component.d.ts +4 -0
  28. package/dist/components/light-component.d.cts +50 -1
  29. package/dist/components/light-component.d.ts +50 -1
  30. package/dist/components/particle-system-component.d.cts +4 -0
  31. package/dist/components/particle-system-component.d.ts +4 -0
  32. package/dist/components/render-component.d.cts +5 -0
  33. package/dist/components/render-component.d.ts +5 -0
  34. package/dist/components/rigid-body-component.d.cts +5 -0
  35. package/dist/components/rigid-body-component.d.ts +5 -0
  36. package/dist/components/screen-component.d.cts +4 -0
  37. package/dist/components/screen-component.d.ts +4 -0
  38. package/dist/components/script-component.d.cts +3 -0
  39. package/dist/components/script-component.d.ts +3 -0
  40. package/dist/components/script-instance.d.cts +4 -0
  41. package/dist/components/script-instance.d.ts +4 -0
  42. package/dist/components/scroll-view-component.d.cts +4 -0
  43. package/dist/components/scroll-view-component.d.ts +4 -0
  44. package/dist/components/scrollbar-component.d.cts +4 -0
  45. package/dist/components/scrollbar-component.d.ts +4 -0
  46. package/dist/components/sound-component.d.cts +4 -0
  47. package/dist/components/sound-component.d.ts +4 -0
  48. package/dist/components/sound-slot.d.cts +3 -0
  49. package/dist/components/sound-slot.d.ts +3 -0
  50. package/dist/custom-elements.json +268 -7
  51. package/dist/entity-base.d.cts +1 -1
  52. package/dist/entity-base.d.ts +1 -1
  53. package/dist/entity-owner.d.cts +2 -2
  54. package/dist/entity-owner.d.ts +2 -2
  55. package/dist/entity.d.cts +6 -1
  56. package/dist/entity.d.ts +6 -1
  57. package/dist/index.d.cts +4 -1
  58. package/dist/index.d.ts +4 -1
  59. package/dist/material.d.cts +18 -7
  60. package/dist/material.d.ts +18 -7
  61. package/dist/model.d.cts +5 -0
  62. package/dist/model.d.ts +5 -0
  63. package/dist/node.d.cts +6 -1
  64. package/dist/node.d.ts +6 -1
  65. package/dist/pwc.cjs +284 -28
  66. package/dist/pwc.cjs.map +1 -1
  67. package/dist/pwc.js +284 -28
  68. package/dist/pwc.js.map +1 -1
  69. package/dist/pwc.min.js +1 -1
  70. package/dist/pwc.min.js.map +1 -1
  71. package/dist/pwc.min.mjs +1 -1
  72. package/dist/pwc.min.mjs.map +1 -1
  73. package/dist/pwc.mjs +285 -29
  74. package/dist/pwc.mjs.map +1 -1
  75. package/dist/scene.d.cts +3 -0
  76. package/dist/scene.d.ts +3 -0
  77. package/dist/sky.d.cts +4 -0
  78. package/dist/sky.d.ts +4 -0
  79. package/dist/vscode.html-custom-data.json +237 -62
  80. package/dist/wasm.d.cts +4 -0
  81. package/dist/wasm.d.ts +4 -0
  82. package/dist/web-types.json +115 -69
  83. package/package.json +1 -1
  84. package/src/app.ts +4 -0
  85. package/src/asset.ts +13 -4
  86. package/src/components/anim-clip.ts +4 -0
  87. package/src/components/anim-component.ts +5 -0
  88. package/src/components/audio-listener-component.ts +4 -0
  89. package/src/components/button-component.ts +5 -0
  90. package/src/components/camera-component.ts +63 -6
  91. package/src/components/collision-component.ts +4 -0
  92. package/src/components/element-component.ts +4 -0
  93. package/src/components/gsplat-component.ts +4 -0
  94. package/src/components/joint-component.ts +12 -2
  95. package/src/components/layout-child-component.ts +4 -0
  96. package/src/components/layout-group-component.ts +4 -0
  97. package/src/components/light-component.ts +108 -17
  98. package/src/components/particle-system-component.ts +4 -0
  99. package/src/components/render-component.ts +5 -0
  100. package/src/components/rigid-body-component.ts +5 -0
  101. package/src/components/screen-component.ts +4 -0
  102. package/src/components/script-component.ts +3 -0
  103. package/src/components/script-instance.ts +4 -0
  104. package/src/components/scroll-view-component.ts +4 -0
  105. package/src/components/scrollbar-component.ts +4 -0
  106. package/src/components/sound-component.ts +4 -0
  107. package/src/components/sound-slot.ts +3 -0
  108. package/src/entity-base.ts +2 -2
  109. package/src/entity-owner.ts +2 -2
  110. package/src/entity.ts +6 -1
  111. package/src/index.ts +12 -1
  112. package/src/material.ts +19 -8
  113. package/src/model.ts +5 -0
  114. package/src/node.ts +6 -1
  115. package/src/scene.ts +3 -0
  116. package/src/sky.ts +4 -0
  117. package/src/wasm.ts +4 -0
package/dist/pwc.js CHANGED
@@ -125,6 +125,10 @@
125
125
  * A `<pc-wasm>` without a `name` warns and never becomes ready; a containing `<pc-app>` still
126
126
  * boots.
127
127
  *
128
+ * @elementSummary The `<pc-wasm>` element loads a WebAssembly module the engine needs before the
129
+ * application starts — `Ammo` for physics, `Basis` or `DracoDecoderModule` for compressed assets.
130
+ * Must be a direct child of `<pc-app>`.
131
+ *
128
132
  * @attribute {string} name - The name of the WebAssembly module to configure, e.g. `Basis` or
129
133
  * `Ammo`.
130
134
  * @attribute {string} glue - The URL of the module's glue script.
@@ -766,6 +770,10 @@
766
770
  * tracked live via a ResizeObserver — so the element can be embedded at any size, resized by
767
771
  * its container, or made fullscreen with ordinary CSS such as `width: 100vw; height: 100dvh`.
768
772
  *
773
+ * @elementSummary The `<pc-app>` element creates a PlayCanvas application and the canvas it renders
774
+ * into, and is the root of every scene. It holds the `<pc-asset>`, `<pc-material>`, `<pc-wasm>` and
775
+ * `<pc-scene>` elements, and the page's CSS sizes it, as it would a `<video>`.
776
+ *
769
777
  * @fires {ProgressEvent} progress - Fired while the application preloads its assets. `loaded` and
770
778
  * `total` are asset counts, not bytes, and an asset that fails to load still counts as loaded.
771
779
  * Fired at least once per boot, and the final event always has `loaded` equal to `total`. Does
@@ -1704,7 +1712,7 @@
1704
1712
  * Tracks whether an inline `onpointer*` attribute is present. The browser itself compiles and
1705
1713
  * runs these attributes — they are standard `GlobalEventHandlers`, so setting one replaces
1706
1714
  * the previous handler and removing it removes the handler, exactly like `onclick` on any
1707
- * HTML element. But because they bypass {@link addEventListener}, the connect/disconnect
1715
+ * HTML element. But because they bypass {@link EventTarget.addEventListener}, the connect/disconnect
1708
1716
  * bookkeeping that lets the application lazily attach its canvas pointer handlers must be
1709
1717
  * kept in sync here.
1710
1718
  *
@@ -1745,7 +1753,7 @@
1745
1753
  }
1746
1754
  /**
1747
1755
  * Whether the element has a listener for an event type, registered either with
1748
- * {@link addEventListener} or with the matching inline `onpointer*` attribute. Read by the
1756
+ * {@link EventTarget.addEventListener} or with the matching inline `onpointer*` attribute. Read by the
1749
1757
  * containing `<pc-app>` element to gate pointer event synthesis.
1750
1758
  *
1751
1759
  * @param type - The event type.
@@ -1814,7 +1822,7 @@
1814
1822
  */
1815
1823
  _tags = [];
1816
1824
  /**
1817
- * Whether the hierarchy has been built for this entity — set once {@link _buildHierarchy} has
1825
+ * Whether the hierarchy has been built for this entity — set once `_buildHierarchy` has
1818
1826
  * parented it. Read by subclasses that gate work on the entity being in the scene graph.
1819
1827
  */
1820
1828
  _built = false;
@@ -1903,7 +1911,7 @@
1903
1911
  this._onBuilt();
1904
1912
  }
1905
1913
  /**
1906
- * Called by {@link _buildHierarchy} once the backing entity has been parented — exactly once
1914
+ * Called by `_buildHierarchy` once the backing entity has been parented — exactly once
1907
1915
  * per build cycle. The default announces readiness, which is what a parented `<pc-entity>`
1908
1916
  * means; `<pc-model>` overrides it to start loading content instead, because its readiness
1909
1917
  * tracks the content settling rather than the host entering the scene graph.
@@ -2024,9 +2032,14 @@
2024
2032
  *
2025
2033
  * The pointer events below are dispatched by the containing `<pc-app>` element when the pointer
2026
2034
  * intersects this entity's geometry. They are only generated while the entity has a listener for
2027
- * them, registered either with {@link addEventListener} or with the matching inline `onpointer*`
2035
+ * them, registered either with {@link EventTarget.addEventListener} or with the matching inline `onpointer*`
2028
2036
  * attribute.
2029
2037
  *
2038
+ * @elementSummary The `<pc-entity>` element creates an entity: a named, transformable node of the
2039
+ * scene hierarchy, and the host for component elements such as `<pc-camera>`, `<pc-light>` and
2040
+ * `<pc-render>`. Place it in the `<pc-scene>`, or nest it under another `<pc-entity>`, a
2041
+ * `<pc-model>` or a `<pc-node>` to parent it there.
2042
+ *
2030
2043
  * @attribute {boolean} enabled - The enabled state of the entity.
2031
2044
  * @attribute {string} name - The name of the entity.
2032
2045
  * @attribute {string} position - The position of the entity.
@@ -2407,6 +2420,10 @@
2407
2420
  * Apart from `lazy` and the texture options, these attributes are read once when the asset is
2408
2421
  * created, so changing them later has no effect.
2409
2422
  *
2423
+ * @elementSummary The `<pc-asset>` element declares an asset for the application to load — a model,
2424
+ * texture, font, sound, script or JSON file — under an `id` that other elements reference. Must be
2425
+ * a direct child of `<pc-app>`.
2426
+ *
2410
2427
  * @attribute {string} id - The identifier used to reference the asset from other elements.
2411
2428
  * @attribute {string} src - The URL of the asset to load.
2412
2429
  * @attribute {string} type - The asset type. Inferred from the `src` file extension when omitted.
@@ -3033,6 +3050,11 @@
3033
3050
  * intersects the model's geometry, exactly as for `<pc-entity>` — a hit on a content node that no
3034
3051
  * `pc-node` fronts resolves to this element.
3035
3052
  *
3053
+ * @elementSummary The `<pc-model>` element instantiates a 3D model from a container asset
3054
+ * (typically a GLB) beneath an entity of its own, so the element's transform and tags place the
3055
+ * instance in the scene. Its `<pc-node>` children override what the asset authored. Place it in the
3056
+ * `<pc-scene>`, or nest it under a `<pc-entity>`, another `<pc-model>` or a `<pc-node>`.
3057
+ *
3036
3058
  * @attribute {boolean} enabled - The enabled state of the model.
3037
3059
  * @attribute {string} name - The name of the model.
3038
3060
  * @attribute {string} position - The position of the model.
@@ -3566,6 +3588,11 @@
3566
3588
  *
3567
3589
  * Engine component: {@link AnimComponent} (`anim`).
3568
3590
  *
3591
+ * @elementSummary The `<pc-anim>` element plays animation clips over its entity's hierarchy, taken
3592
+ * from `<pc-anim-clip>` children or from the enclosing `<pc-model>`'s own animations. The first
3593
+ * clip plays automatically, and the `clip` attribute switches between them. Must be a child of a
3594
+ * `<pc-entity>`, `<pc-model>` or `<pc-node>`.
3595
+ *
3569
3596
  * @category Components
3570
3597
  */
3571
3598
  class AnimComponentElement extends ComponentElement {
@@ -4184,6 +4211,10 @@
4184
4211
  * named; in a multi-track source the track named `name` is chosen, falling back to the first
4185
4212
  * with a warning. The element becomes ready once its resolved track is assigned.
4186
4213
  *
4214
+ * @elementSummary The `<pc-anim-clip>` element declares one named animation clip on its parent
4215
+ * `<pc-anim>`, taken from the `asset` it names or, without one, from the enclosing `<pc-model>`'s
4216
+ * own animations. Must be a direct child of `<pc-anim>`.
4217
+ *
4187
4218
  * @category Components
4188
4219
  */
4189
4220
  class AnimClipElement extends AsyncElement {
@@ -4512,6 +4543,10 @@
4512
4543
  *
4513
4544
  * Engine component: {@link AudioListenerComponent} (`audiolistener`).
4514
4545
  *
4546
+ * @elementSummary The `<pc-audio-listener>` element makes its entity the point from which
4547
+ * positional sounds are heard, typically the entity holding the `<pc-camera>`. Must be a child of a
4548
+ * `<pc-entity>`, `<pc-model>` or `<pc-node>`.
4549
+ *
4515
4550
  * @category Components
4516
4551
  */
4517
4552
  class AudioListenerComponentElement extends ComponentElement {
@@ -4541,6 +4576,11 @@
4541
4576
  *
4542
4577
  * Engine component: {@link ButtonComponent} (`button`).
4543
4578
  *
4579
+ * @elementSummary The `<pc-button>` element makes its entity respond to pointer input, tinting or
4580
+ * swapping its image as the pointer hovers, presses and releases it. The entity also needs a
4581
+ * `<pc-element>` with `use-input` set. Must be a child of a `<pc-entity>`, `<pc-model>` or
4582
+ * `<pc-node>`.
4583
+ *
4544
4584
  * @category Components
4545
4585
  */
4546
4586
  class ButtonComponentElement extends ComponentElement {
@@ -4944,13 +4984,18 @@
4944
4984
  *
4945
4985
  * Engine component: {@link CameraComponent} (`camera`).
4946
4986
  *
4987
+ * @elementSummary The `<pc-camera>` element renders the scene from its entity's transform, with
4988
+ * attributes for the projection, field of view, clip planes, clear color and tonemapping. Must be a
4989
+ * child of a `<pc-entity>`, `<pc-model>` or `<pc-node>`.
4990
+ *
4947
4991
  * @category Components
4948
4992
  */
4949
4993
  class CameraComponentElement extends ComponentElement {
4950
4994
  _clearColor = new playcanvas.Color(0.75, 0.75, 0.75, 1);
4951
4995
  _clearColorBuffer = true;
4996
+ _clearDepth = 1;
4952
4997
  _clearDepthBuffer = true;
4953
- _clearStencilBuffer = false;
4998
+ _clearStencilBuffer = true;
4954
4999
  _cullFaces = true;
4955
5000
  _farClip = 1000;
4956
5001
  _flipFaces = false;
@@ -4973,6 +5018,7 @@
4973
5018
  return {
4974
5019
  clearColor: this._clearColor,
4975
5020
  clearColorBuffer: this._clearColorBuffer,
5021
+ clearDepth: this._clearDepth,
4976
5022
  clearDepthBuffer: this._clearDepthBuffer,
4977
5023
  clearStencilBuffer: this._clearStencilBuffer,
4978
5024
  cullFaces: this._cullFaces,
@@ -4991,9 +5037,31 @@
4991
5037
  toneMapping: tonemaps.get(this._tonemap) ?? playcanvas.TONEMAP_NONE
4992
5038
  };
4993
5039
  }
4994
- get xrAvailable() {
5040
+ /**
5041
+ * Whether immersive AR is available. Independent of {@link vrAvailable}: a device can offer
5042
+ * either mode without the other.
5043
+ * @returns Whether immersive AR is available.
5044
+ */
5045
+ get arAvailable() {
5046
+ return this._available(playcanvas.XRTYPE_AR);
5047
+ }
5048
+ /**
5049
+ * Whether immersive VR is available. Independent of {@link arAvailable}: a device can offer
5050
+ * either mode without the other.
5051
+ * @returns Whether immersive VR is available.
5052
+ */
5053
+ get vrAvailable() {
5054
+ return this._available(playcanvas.XRTYPE_VR);
5055
+ }
5056
+ /**
5057
+ * Whether one XR session type is available on this device.
5058
+ *
5059
+ * @param type - The XR session type to test.
5060
+ * @returns Whether that type is available.
5061
+ */
5062
+ _available(type) {
4995
5063
  const xrManager = this.component?.system.app.xr;
4996
- return xrManager && xrManager.supported && xrManager.isAvailable(playcanvas.XRTYPE_VR);
5064
+ return Boolean(xrManager?.supported && xrManager.isAvailable(type));
4997
5065
  }
4998
5066
  /**
4999
5067
  * Starts the camera in XR mode.
@@ -5001,11 +5069,13 @@
5001
5069
  * @param space - The space to start the camera in.
5002
5070
  */
5003
5071
  startXr(type, space) {
5004
- if (this.component && this.xrAvailable) {
5072
+ // Gated on the mode being started, not on XR in general: a device that offers only
5073
+ // one of the two would otherwise accept a session it cannot serve
5074
+ if (this.component && this._available(type)) {
5005
5075
  this.component.startXr(type, space, {
5006
5076
  callback: (err) => {
5007
5077
  if (err)
5008
- console.error(`WebXR Immersive VR failed to start: ${err.message}`);
5078
+ console.error(`WebXR ${type} failed to start: ${err.message}`);
5009
5079
  }
5010
5080
  });
5011
5081
  }
@@ -5059,6 +5129,23 @@
5059
5129
  get clearColorBuffer() {
5060
5130
  return this._clearColorBuffer;
5061
5131
  }
5132
+ /**
5133
+ * Sets the depth value the depth buffer is cleared to. Defaults to 1.
5134
+ * @param value - The clear depth value.
5135
+ */
5136
+ set clearDepth(value) {
5137
+ this._clearDepth = value;
5138
+ if (this.component) {
5139
+ this.component.clearDepth = value;
5140
+ }
5141
+ }
5142
+ /**
5143
+ * Gets the depth value the depth buffer is cleared to.
5144
+ * @returns The clear depth value.
5145
+ */
5146
+ get clearDepth() {
5147
+ return this._clearDepth;
5148
+ }
5062
5149
  /**
5063
5150
  * Sets the clear depth buffer of the camera.
5064
5151
  * @param value - The clear depth buffer.
@@ -5337,6 +5424,7 @@
5337
5424
  ...super.observedAttributes,
5338
5425
  'clear-color',
5339
5426
  'clear-color-buffer',
5427
+ 'clear-depth',
5340
5428
  'clear-depth-buffer',
5341
5429
  'clear-stencil-buffer',
5342
5430
  'cull-faces',
@@ -5364,11 +5452,14 @@
5364
5452
  case 'clear-color-buffer':
5365
5453
  this.clearColorBuffer = parseBool(newValue, true);
5366
5454
  break;
5455
+ case 'clear-depth':
5456
+ this.clearDepth = parseNumber(newValue, 1, name);
5457
+ break;
5367
5458
  case 'clear-depth-buffer':
5368
5459
  this.clearDepthBuffer = parseBool(newValue, true);
5369
5460
  break;
5370
5461
  case 'clear-stencil-buffer':
5371
- this.clearStencilBuffer = parseBool(newValue, false);
5462
+ this.clearStencilBuffer = parseBool(newValue, true);
5372
5463
  break;
5373
5464
  case 'cull-faces':
5374
5465
  this.cullFaces = parseBool(newValue, true);
@@ -5431,6 +5522,10 @@
5431
5522
  *
5432
5523
  * Engine component: {@link CollisionComponent} (`collision`).
5433
5524
  *
5525
+ * @elementSummary The `<pc-collision>` element gives its entity a collision shape — a box, sphere,
5526
+ * capsule, cone, cylinder or mesh — for the physics simulation to collide against. Pair it with a
5527
+ * `<pc-rigid-body>`. Must be a child of a `<pc-entity>`, `<pc-model>` or `<pc-node>`.
5528
+ *
5434
5529
  * @category Components
5435
5530
  */
5436
5531
  class CollisionComponentElement extends ComponentElement {
@@ -5621,6 +5716,10 @@
5621
5716
  *
5622
5717
  * Engine component: {@link ElementComponent} (`element`).
5623
5718
  *
5719
+ * @elementSummary The `<pc-element>` element gives its entity a 2D UI rectangle inside a
5720
+ * `<pc-screen>` hierarchy, drawing an image, a line of text or nothing (`type="image"`, `"text"` or
5721
+ * `"group"`). Must be a child of a `<pc-entity>`, `<pc-model>` or `<pc-node>`.
5722
+ *
5624
5723
  * @category Components
5625
5724
  */
5626
5725
  class ElementComponentElement extends ComponentElement {
@@ -6305,6 +6404,11 @@
6305
6404
  * a rigid body component; leaving `entity-b` empty constrains `entity-a` to a fixed point in world
6306
6405
  * space. The underlying engine component is in alpha, so its API may change.
6307
6406
  *
6407
+ * @elementSummary The `<pc-joint>` element constrains two rigid bodies to each other — a hinged
6408
+ * door, a swinging chain, a sliding drawer. Its entity's transform is the joint frame, and
6409
+ * `entity-a` and `entity-b` name the bodies. Must be a child of a `<pc-entity>`, `<pc-model>` or
6410
+ * `<pc-node>`.
6411
+ *
6308
6412
  * @fires {CustomEvent} break - Fired when the impulse on the joint exceeds `break-impulse` and the
6309
6413
  * constraint breaks. A broken joint no longer constrains its bodies; calling `refreshFrames()` on
6310
6414
  * the underlying component re-attaches it. Bubbles and is composed.
@@ -7175,6 +7279,10 @@
7175
7279
  *
7176
7280
  * Engine component: {@link LayoutChildComponent} (`layoutchild`).
7177
7281
  *
7282
+ * @elementSummary The `<pc-layout-child>` element controls how its entity is sized by the
7283
+ * `<pc-layout-group>` above it, through minimum and maximum sizes and fit proportions. Must be a
7284
+ * child of a `<pc-entity>`, `<pc-model>` or `<pc-node>`.
7285
+ *
7178
7286
  * @category Components
7179
7287
  */
7180
7288
  class LayoutChildComponentElement extends ComponentElement {
@@ -7387,6 +7495,10 @@
7387
7495
  *
7388
7496
  * Engine component: {@link LayoutGroupComponent} (`layoutgroup`).
7389
7497
  *
7498
+ * @elementSummary The `<pc-layout-group>` element arranges its entity's children in a row or
7499
+ * column, with spacing, padding, alignment and fitting. Must be a child of a `<pc-entity>`,
7500
+ * `<pc-model>` or `<pc-node>`.
7501
+ *
7390
7502
  * @category Components
7391
7503
  */
7392
7504
  class LayoutGroupComponentElement extends ComponentElement {
@@ -7647,23 +7759,30 @@
7647
7759
  *
7648
7760
  * Engine component: {@link LightComponent} (`light`).
7649
7761
  *
7762
+ * @elementSummary The `<pc-light>` element lights the scene from its entity — as a directional,
7763
+ * omni or spot light — with attributes for color, intensity, range and shadows. Must be a child of
7764
+ * a `<pc-entity>`, `<pc-model>` or `<pc-node>`.
7765
+ *
7650
7766
  * @category Components
7651
7767
  */
7652
7768
  class LightComponentElement extends ComponentElement {
7769
+ _cascadeBlend = 0;
7770
+ _cascadeDistribution = 0.5;
7653
7771
  _castShadows = false;
7654
7772
  _color = new playcanvas.Color(1, 1, 1);
7655
7773
  _innerConeAngle = 40;
7656
7774
  _intensity = 1;
7657
- _normalOffsetBias = 0.05;
7775
+ _normalOffsetBias = 0;
7776
+ _numCascades = 1;
7658
7777
  _outerConeAngle = 45;
7659
7778
  _range = 10;
7660
- _shadowBias = 0.2;
7661
- _shadowDistance = 16;
7779
+ _shadowBias = 0.05;
7780
+ _shadowDistance = 40;
7662
7781
  _shadowIntensity = 1;
7663
7782
  _shadowResolution = 1024;
7664
7783
  _shadowType = 'pcf3-32f';
7665
7784
  _type = 'directional';
7666
- _vsmBias = 0.01;
7785
+ _vsmBias = 0.0025;
7667
7786
  _vsmBlurSize = 11;
7668
7787
  _penumbraSize = 1;
7669
7788
  _penumbraFalloff = 1;
@@ -7675,11 +7794,14 @@
7675
7794
  }
7676
7795
  getInitialComponentData() {
7677
7796
  return {
7797
+ cascadeBlend: this._cascadeBlend,
7798
+ cascadeDistribution: this._cascadeDistribution,
7678
7799
  castShadows: this._castShadows,
7679
7800
  color: this._color,
7680
7801
  innerConeAngle: this._innerConeAngle,
7681
7802
  intensity: this._intensity,
7682
7803
  normalOffsetBias: this._normalOffsetBias,
7804
+ numCascades: this._numCascades,
7683
7805
  outerConeAngle: this._outerConeAngle,
7684
7806
  penumbraFalloff: this._penumbraFalloff,
7685
7807
  penumbraSize: this._penumbraSize,
@@ -7690,7 +7812,7 @@
7690
7812
  shadowIntensity: this._shadowIntensity,
7691
7813
  shadowResolution: this._shadowResolution,
7692
7814
  shadowSamples: this._shadowSamples,
7693
- shadowType: shadowTypes.get(this._shadowType),
7815
+ shadowType: shadowTypes.get(this._shadowType) ?? playcanvas.SHADOW_PCF3_32F,
7694
7816
  type: this._type,
7695
7817
  vsmBias: this._vsmBias,
7696
7818
  vsmBlurSize: this._vsmBlurSize
@@ -7703,6 +7825,47 @@
7703
7825
  get component() {
7704
7826
  return super.component;
7705
7827
  }
7828
+ /**
7829
+ * Sets the fraction of each shadow cascade that is blended into the next one, from 0 (no
7830
+ * blending) to 1, which applies only to `directional` lights with `num-cascades` greater than
7831
+ * 1. Defaults to 0.
7832
+ * @param value - The cascade blend factor.
7833
+ */
7834
+ set cascadeBlend(value) {
7835
+ this._cascadeBlend = value;
7836
+ if (this.component) {
7837
+ this.component.cascadeBlend = value;
7838
+ }
7839
+ }
7840
+ /**
7841
+ * Gets the cascade blend factor of the light, from 0 (no blending) to 1, which applies only to
7842
+ * `directional` lights with `num-cascades` greater than 1.
7843
+ * @returns The cascade blend factor.
7844
+ */
7845
+ get cascadeBlend() {
7846
+ return this._cascadeBlend;
7847
+ }
7848
+ /**
7849
+ * Sets the distribution of the camera frustum split between shadow cascades, from 0 (linear
7850
+ * split) to 1 (logarithmic split, concentrating shadow resolution near the camera), which
7851
+ * applies only to `directional` lights with `num-cascades` greater than 1. Defaults to 0.5.
7852
+ * @param value - The cascade distribution.
7853
+ */
7854
+ set cascadeDistribution(value) {
7855
+ this._cascadeDistribution = value;
7856
+ if (this.component) {
7857
+ this.component.cascadeDistribution = value;
7858
+ }
7859
+ }
7860
+ /**
7861
+ * Gets the cascade distribution of the light, from 0 (linear split) to 1 (logarithmic split,
7862
+ * concentrating shadow resolution near the camera), which applies only to `directional` lights
7863
+ * with `num-cascades` greater than 1.
7864
+ * @returns The cascade distribution.
7865
+ */
7866
+ get cascadeDistribution() {
7867
+ return this._cascadeDistribution;
7868
+ }
7706
7869
  /**
7707
7870
  * Sets the cast shadows flag of the light.
7708
7871
  * @param value - The cast shadows flag.
@@ -7788,6 +7951,25 @@
7788
7951
  get normalOffsetBias() {
7789
7952
  return this._normalOffsetBias;
7790
7953
  }
7954
+ /**
7955
+ * Sets the number of shadow cascades of the light, an integer from 1 (no cascades) to 4, which
7956
+ * applies only to `directional` lights. Defaults to 1.
7957
+ * @param value - The number of shadow cascades.
7958
+ */
7959
+ set numCascades(value) {
7960
+ this._numCascades = value;
7961
+ if (this.component) {
7962
+ this.component.numCascades = value;
7963
+ }
7964
+ }
7965
+ /**
7966
+ * Gets the number of shadow cascades of the light, an integer from 1 (no cascades) to 4, which
7967
+ * applies only to `directional` lights.
7968
+ * @returns The number of shadow cascades.
7969
+ */
7970
+ get numCascades() {
7971
+ return this._numCascades;
7972
+ }
7791
7973
  /**
7792
7974
  * Sets the outer cone angle of the light.
7793
7975
  * @param value - The outer cone angle.
@@ -8040,11 +8222,14 @@
8040
8222
  static get observedAttributes() {
8041
8223
  return [
8042
8224
  ...super.observedAttributes,
8043
- 'color',
8225
+ 'cascade-blend',
8226
+ 'cascade-distribution',
8044
8227
  'cast-shadows',
8045
- 'intensity',
8228
+ 'color',
8046
8229
  'inner-cone-angle',
8230
+ 'intensity',
8047
8231
  'normal-offset-bias',
8232
+ 'num-cascades',
8048
8233
  'outer-cone-angle',
8049
8234
  'penumbra-falloff',
8050
8235
  'penumbra-size',
@@ -8064,12 +8249,18 @@
8064
8249
  attributeChangedCallback(name, _oldValue, newValue) {
8065
8250
  super.attributeChangedCallback(name, _oldValue, newValue);
8066
8251
  switch (name) {
8067
- case 'color':
8068
- this.color = parseColor(newValue, playcanvas.Color.WHITE, name);
8252
+ case 'cascade-blend':
8253
+ this.cascadeBlend = parseNumber(newValue, 0, name);
8254
+ break;
8255
+ case 'cascade-distribution':
8256
+ this.cascadeDistribution = parseNumber(newValue, 0.5, name);
8069
8257
  break;
8070
8258
  case 'cast-shadows':
8071
8259
  this.castShadows = parseBool(newValue, false);
8072
8260
  break;
8261
+ case 'color':
8262
+ this.color = parseColor(newValue, playcanvas.Color.WHITE, name);
8263
+ break;
8073
8264
  case 'inner-cone-angle':
8074
8265
  this.innerConeAngle = parseNumber(newValue, 40, name);
8075
8266
  break;
@@ -8077,7 +8268,10 @@
8077
8268
  this.intensity = parseNumber(newValue, 1, name);
8078
8269
  break;
8079
8270
  case 'normal-offset-bias':
8080
- this.normalOffsetBias = parseNumber(newValue, 0.05, name);
8271
+ this.normalOffsetBias = parseNumber(newValue, 0, name);
8272
+ break;
8273
+ case 'num-cascades':
8274
+ this.numCascades = parseNumber(newValue, 1, name);
8081
8275
  break;
8082
8276
  case 'outer-cone-angle':
8083
8277
  this.outerConeAngle = parseNumber(newValue, 45, name);
@@ -8092,20 +8286,20 @@
8092
8286
  this.range = parseNumber(newValue, 10, name);
8093
8287
  break;
8094
8288
  case 'shadow-bias':
8095
- this.shadowBias = parseNumber(newValue, 0.2, name);
8096
- break;
8097
- case 'shadow-distance':
8098
- this.shadowDistance = parseNumber(newValue, 16, name);
8289
+ this.shadowBias = parseNumber(newValue, 0.05, name);
8099
8290
  break;
8100
8291
  case 'shadow-blocker-samples':
8101
8292
  this.shadowBlockerSamples = parseNumber(newValue, 16, name);
8102
8293
  break;
8103
- case 'shadow-resolution':
8104
- this.shadowResolution = parseNumber(newValue, 1024, name);
8294
+ case 'shadow-distance':
8295
+ this.shadowDistance = parseNumber(newValue, 40, name);
8105
8296
  break;
8106
8297
  case 'shadow-intensity':
8107
8298
  this.shadowIntensity = parseNumber(newValue, 1, name);
8108
8299
  break;
8300
+ case 'shadow-resolution':
8301
+ this.shadowResolution = parseNumber(newValue, 1024, name);
8302
+ break;
8109
8303
  case 'shadow-samples':
8110
8304
  this.shadowSamples = parseNumber(newValue, 16, name);
8111
8305
  break;
@@ -8116,7 +8310,7 @@
8116
8310
  this.type = parseEnum(newValue, ['directional', 'omni', 'spot'], 'directional', name);
8117
8311
  break;
8118
8312
  case 'vsm-bias':
8119
- this.vsmBias = parseNumber(newValue, 0.01, name);
8313
+ this.vsmBias = parseNumber(newValue, 0.0025, name);
8120
8314
  break;
8121
8315
  case 'vsm-blur-size':
8122
8316
  this.vsmBlurSize = parseNumber(newValue, 11, name);
@@ -8134,6 +8328,10 @@
8134
8328
  *
8135
8329
  * Engine component: {@link ParticleSystemComponent} (`particlesystem`).
8136
8330
  *
8331
+ * @elementSummary The `<pc-particle-system>` element emits particles from its entity, with
8332
+ * attributes for the emitter's shape, rate, lifetime, textures and blending. Must be a child of a
8333
+ * `<pc-entity>`, `<pc-model>` or `<pc-node>`.
8334
+ *
8137
8335
  * @category Components
8138
8336
  */
8139
8337
  class ParticleSystemComponentElement extends ComponentElement {
@@ -8282,6 +8480,8 @@
8282
8480
  ['ao', playcanvas.SPECOCC_AO],
8283
8481
  ['gloss-dependent', playcanvas.SPECOCC_GLOSSDEPENDENT]
8284
8482
  ]);
8483
+ // The DITHER_* constants are strings whose values are exactly these names, so a parsed value is
8484
+ // assigned to the material unchanged rather than mapped through a table.
8285
8485
  const opacityDithers = ['none', 'bayer8', 'bluenoise', 'ignnoise'];
8286
8486
  const colorChannels = ['r', 'g', 'b', 'a', 'rgb'];
8287
8487
  const scalarChannels = ['r', 'g', 'b', 'a'];
@@ -8318,6 +8518,10 @@
8318
8518
  * The two aliases are documented here rather than on an accessor, because they resolve to the
8319
8519
  * `gloss` properties and would otherwise inherit gloss's description - which reads inverted.
8320
8520
  *
8521
+ * @elementSummary The `<pc-material>` element defines a physically based material, which
8522
+ * `<pc-render>` elements apply by naming its `id`. It is metal/rough by default, with `metalness`
8523
+ * starting at 0. Must be a direct child of `<pc-app>`.
8524
+ *
8321
8525
  * @attribute {number} roughness - The roughness of the material, from 0 (shiny) to 1 (rough). An
8322
8526
  * alias for `gloss` that also inverts it, so do not combine it with the `gloss` attributes.
8323
8527
  * @attribute {string} roughness-map - The id of the `pc-asset` to use as the roughness map. An
@@ -10486,6 +10690,11 @@
10486
10690
  *
10487
10691
  * Engine component: {@link RenderComponent} (`render`).
10488
10692
  *
10693
+ * @elementSummary The `<pc-render>` element renders one of the engine's built-in primitives at its
10694
+ * entity — box, sphere, capsule, cone, cylinder or plane — shaded by the `<pc-material>` its
10695
+ * `material` attribute names. For glTF content, use `<pc-model>` instead. Must be a child of a
10696
+ * `<pc-entity>`, `<pc-model>` or `<pc-node>`.
10697
+ *
10489
10698
  * @category Components
10490
10699
  */
10491
10700
  class RenderComponentElement extends ComponentElement {
@@ -10616,6 +10825,11 @@
10616
10825
  *
10617
10826
  * Engine component: {@link RigidBodyComponent} (`rigidbody`).
10618
10827
  *
10828
+ * @elementSummary The `<pc-rigid-body>` element hands its entity to the physics simulation, with
10829
+ * attributes for its type, mass, friction and restitution. It needs a sibling `<pc-collision>` for
10830
+ * its shape, and `Ammo` loaded through `<pc-wasm>`. Must be a child of a `<pc-entity>`,
10831
+ * `<pc-model>` or `<pc-node>`.
10832
+ *
10619
10833
  * @category Components
10620
10834
  */
10621
10835
  class RigidBodyComponentElement extends ComponentElement {
@@ -10825,6 +11039,10 @@
10825
11039
  *
10826
11040
  * Engine component: {@link ScreenComponent} (`screen`).
10827
11041
  *
11042
+ * @elementSummary The `<pc-screen>` element gives its entity a 2D space — in screen space or in the
11043
+ * world — that a hierarchy of `<pc-element>` descendants lays out inside. Must be a child of a
11044
+ * `<pc-entity>`, `<pc-model>` or `<pc-node>`.
11045
+ *
10828
11046
  * @category Components
10829
11047
  */
10830
11048
  class ScreenComponentElement extends ComponentElement {
@@ -10979,6 +11197,10 @@
10979
11197
  *
10980
11198
  * Engine component: {@link ScrollbarComponent} (`scrollbar`).
10981
11199
  *
11200
+ * @elementSummary The `<pc-scrollbar>` element gives its entity a draggable handle reporting a
11201
+ * position from 0 to 1, which a `<pc-scroll-view>` references to scroll its content. Must be a
11202
+ * child of a `<pc-entity>`, `<pc-model>` or `<pc-node>`.
11203
+ *
10982
11204
  * @category Components
10983
11205
  */
10984
11206
  class ScrollbarComponentElement extends ComponentElement {
@@ -11120,6 +11342,10 @@
11120
11342
  *
11121
11343
  * Engine component: {@link ScrollViewComponent} (`scrollview`).
11122
11344
  *
11345
+ * @elementSummary The `<pc-scroll-view>` element scrolls a larger content entity within a clipped
11346
+ * viewport at its entity, optionally driven by the `<pc-scrollbar>` elements it references. Must be
11347
+ * a child of a `<pc-entity>`, `<pc-model>` or `<pc-node>`.
11348
+ *
11123
11349
  * @category Components
11124
11350
  */
11125
11351
  class ScrollViewComponentElement extends ComponentElement {
@@ -11506,6 +11732,10 @@
11506
11732
  * The element becomes ready once its script instance has been created by the parent
11507
11733
  * `<pc-script>` element.
11508
11734
  *
11735
+ * @elementSummary The `<pc-script-instance>` element attaches one script class, named by `name`, to
11736
+ * the entity of its parent `<pc-script>`. Its other attributes set script attributes of the same
11737
+ * name, and `attributes` takes a JSON object instead. Must be a direct child of `<pc-script>`.
11738
+ *
11509
11739
  * @fires {CustomEvent} scriptattributeschange - Fired when the script's attributes change. The
11510
11740
  * `detail` carries the new `attributes` object. Bubbles.
11511
11741
  * @fires {CustomEvent} scriptenablechange - Fired when the script's enabled state changes. The
@@ -11850,6 +12080,9 @@
11850
12080
  *
11851
12081
  * Engine component: {@link ScriptComponent} (`script`).
11852
12082
  *
12083
+ * @elementSummary The `<pc-script>` element holds the `<pc-script-instance>` children that attach
12084
+ * scripts to its entity. Must be a child of a `<pc-entity>`, `<pc-model>` or `<pc-node>`.
12085
+ *
11853
12086
  * @category Components
11854
12087
  */
11855
12088
  class ScriptComponentElement extends ComponentElement {
@@ -12299,6 +12532,10 @@
12299
12532
  *
12300
12533
  * Engine component: {@link SoundComponent} (`sound`).
12301
12534
  *
12535
+ * @elementSummary The `<pc-sound>` element holds the `<pc-sound-slot>` children that play sounds at
12536
+ * its entity, along with the positional audio settings they share. Must be a child of a
12537
+ * `<pc-entity>`, `<pc-model>` or `<pc-node>`.
12538
+ *
12302
12539
  * @category Components
12303
12540
  */
12304
12541
  class SoundComponentElement extends ComponentElement {
@@ -12495,6 +12732,9 @@
12495
12732
  * The SoundSlotElement interface provides properties and methods for manipulating
12496
12733
  * `<pc-sound-slot>` elements. The SoundSlotElement interface also inherits the properties and
12497
12734
  * methods of the {@link AsyncElement} interface.
12735
+ *
12736
+ * @elementSummary The `<pc-sound-slot>` element declares one named sound on its parent `<pc-sound>`
12737
+ * — its asset, volume, pitch, looping and autoplay. Must be a direct child of `<pc-sound>`.
12498
12738
  */
12499
12739
  class SoundSlotElement extends AsyncElement {
12500
12740
  _asset = '';
@@ -12776,6 +13016,10 @@
12776
13016
  *
12777
13017
  * Engine component: {@link GSplatComponent} (`gsplat`).
12778
13018
  *
13019
+ * @elementSummary The `<pc-gsplat>` element renders the 3D Gaussian splats of a `gsplat` asset at
13020
+ * its entity, with attributes for shadow casting and level of detail. Must be a child of a
13021
+ * `<pc-entity>`, `<pc-model>` or `<pc-node>`.
13022
+ *
12779
13023
  * @category Components
12780
13024
  */
12781
13025
  class GSplatComponentElement extends ComponentElement {
@@ -13071,6 +13315,11 @@
13071
13315
  * The pointer events below are dispatched by the containing `<pc-app>` element when the pointer
13072
13316
  * intersects the bound node's geometry, exactly as for `<pc-entity>`.
13073
13317
  *
13318
+ * @elementSummary The `<pc-node>` element binds to a node inside the hierarchy a `<pc-model>`
13319
+ * instantiated and declares overrides against it: a transform, an enabled state, tags, components
13320
+ * to add, or content to attach. Its `name` is a lookup, never a rename. Must be a descendant of
13321
+ * `<pc-model>`.
13322
+ *
13074
13323
  * @attribute {string} name - The name of the node to bind, resolved within the nearest ancestor
13075
13324
  * `pc-model` (or `pc-node`) once it has instantiated.
13076
13325
  * @attribute {number} index - Which match to bind when `name` matches more than one node,
@@ -13811,6 +14060,9 @@
13811
14060
  * {@link https://developer.playcanvas.com/user-manual/web-components/tags/pc-scene/ | `<pc-scene>`} elements.
13812
14061
  * The SceneElement interface also inherits the properties and methods of the
13813
14062
  * {@link HTMLElement} interface.
14063
+ *
14064
+ * @elementSummary The `<pc-scene>` element holds the entity hierarchy the application renders,
14065
+ * along with the scene-wide fog and gravity settings. Must be a direct child of `<pc-app>`.
13814
14066
  */
13815
14067
  class SceneElement extends AsyncElement {
13816
14068
  /**
@@ -14034,6 +14286,10 @@
14034
14286
  * The SkyElement interface provides properties and methods for manipulating
14035
14287
  * `<pc-sky>` elements. The SkyElement interface also inherits the properties and
14036
14288
  * methods of the {@link HTMLElement} interface.
14289
+ *
14290
+ * @elementSummary The `<pc-sky>` element renders a skybox from a texture asset, projected as an
14291
+ * infinite background, a box or a dome, and optionally lights the scene from it. Must be a direct
14292
+ * child of `<pc-scene>`.
14037
14293
  */
14038
14294
  class SkyElement extends AsyncElement {
14039
14295
  _asset = '';