@playcanvas/web-components 0.1.8 → 0.1.10

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 (58) hide show
  1. package/README.md +2 -2
  2. package/dist/app.d.ts +21 -1
  3. package/dist/asset.d.ts +3 -1
  4. package/dist/async-element.d.ts +2 -1
  5. package/dist/components/camera-component.d.ts +28 -4
  6. package/dist/components/collision-component.d.ts +4 -4
  7. package/dist/components/component.d.ts +3 -1
  8. package/dist/components/element-component.d.ts +4 -1
  9. package/dist/components/gsplat-component.d.ts +4 -1
  10. package/dist/components/light-component.d.ts +50 -4
  11. package/dist/components/listener-component.d.ts +4 -1
  12. package/dist/components/render-component.d.ts +4 -1
  13. package/dist/components/rigidbody-component.d.ts +4 -4
  14. package/dist/components/screen-component.d.ts +4 -1
  15. package/dist/components/script-component.d.ts +4 -1
  16. package/dist/components/script.d.ts +3 -1
  17. package/dist/components/sound-component.d.ts +5 -2
  18. package/dist/components/sound-slot.d.ts +3 -1
  19. package/dist/entity.d.ts +14 -3
  20. package/dist/fog.d.ts +28 -0
  21. package/dist/material.d.ts +3 -1
  22. package/dist/model.d.ts +3 -1
  23. package/dist/module.d.ts +6 -0
  24. package/dist/pwc.cjs +569 -96
  25. package/dist/pwc.cjs.map +1 -1
  26. package/dist/pwc.js +569 -96
  27. package/dist/pwc.js.map +1 -1
  28. package/dist/pwc.min.js +1 -1
  29. package/dist/pwc.min.js.map +1 -1
  30. package/dist/pwc.mjs +570 -97
  31. package/dist/pwc.mjs.map +1 -1
  32. package/dist/scene.d.ts +3 -1
  33. package/dist/sky.d.ts +3 -1
  34. package/package.json +10 -9
  35. package/src/app.ts +208 -2
  36. package/src/asset.ts +3 -1
  37. package/src/async-element.ts +2 -1
  38. package/src/components/camera-component.ts +69 -7
  39. package/src/components/collision-component.ts +4 -4
  40. package/src/components/component.ts +3 -1
  41. package/src/components/element-component.ts +4 -2
  42. package/src/components/gsplat-component.ts +4 -1
  43. package/src/components/light-component.ts +107 -7
  44. package/src/components/listener-component.ts +4 -1
  45. package/src/components/render-component.ts +4 -1
  46. package/src/components/rigidbody-component.ts +4 -4
  47. package/src/components/screen-component.ts +4 -1
  48. package/src/components/script-component.ts +26 -14
  49. package/src/components/script.ts +3 -1
  50. package/src/components/sound-component.ts +4 -1
  51. package/src/components/sound-slot.ts +3 -1
  52. package/src/entity.ts +149 -32
  53. package/src/fog.ts +121 -0
  54. package/src/material.ts +5 -3
  55. package/src/model.ts +3 -1
  56. package/src/module.ts +6 -0
  57. package/src/scene.ts +13 -11
  58. package/src/sky.ts +3 -1
package/dist/pwc.mjs CHANGED
@@ -1,9 +1,10 @@
1
- import { basisInitialize, WasmModule, Application, Keyboard, Mouse, FILLMODE_FILL_WINDOW, RESOLUTION_AUTO, Color, Quat, Vec2, Vec3, Vec4, Entity, Asset, XRTYPE_VR, PROJECTION_ORTHOGRAPHIC, PROJECTION_PERSPECTIVE, StandardMaterial, SCALEMODE_BLEND, SCALEMODE_NONE, EnvLighting, LAYERID_SKYBOX } from 'playcanvas';
1
+ import { basisInitialize, WasmModule, Application, Keyboard, Mouse, FILLMODE_FILL_WINDOW, RESOLUTION_AUTO, Picker, Color, Quat, Vec2, Vec3, Vec4, Entity, Asset, GAMMA_SRGB, GAMMA_NONE, XRTYPE_VR, PROJECTION_ORTHOGRAPHIC, PROJECTION_PERSPECTIVE, TONEMAP_NONE, TONEMAP_LINEAR, TONEMAP_FILMIC, TONEMAP_HEJL, TONEMAP_ACES, TONEMAP_ACES2, TONEMAP_NEUTRAL, SHADOW_PCF3_32F, SHADOW_PCF1_16F, SHADOW_PCF1_32F, SHADOW_PCF3_16F, SHADOW_PCF5_16F, SHADOW_PCF5_32F, SHADOW_VSM_16F, SHADOW_VSM_32F, SHADOW_PCSS_32F, StandardMaterial, SCALEMODE_BLEND, SCALEMODE_NONE, EnvLighting, LAYERID_SKYBOX } from 'playcanvas';
2
2
 
3
3
  /**
4
- * Base class for all PlayCanvas web components that initialize asynchronously.
4
+ * Base class for all PlayCanvas Web Components that initialize asynchronously.
5
5
  */
6
6
  class AsyncElement extends HTMLElement {
7
+ /** @ignore */
7
8
  constructor() {
8
9
  super();
9
10
  this._readyPromise = new Promise((resolve) => {
@@ -35,7 +36,13 @@ class AsyncElement extends HTMLElement {
35
36
  }
36
37
  }
37
38
 
39
+ /**
40
+ * The ModuleElement interface provides properties and methods for manipulating
41
+ * `<pc-module>` elements. The ModuleElement interface also inherits the properties and
42
+ * methods of the {@link HTMLElement} interface.
43
+ */
38
44
  class ModuleElement extends HTMLElement {
45
+ /** @ignore */
39
46
  constructor() {
40
47
  super();
41
48
  this.loadPromise = this.loadModule();
@@ -74,7 +81,9 @@ customElements.define('pc-module', ModuleElement);
74
81
  */
75
82
  class AppElement extends AsyncElement {
76
83
  /**
77
- * Creates a new AppElement.
84
+ * Creates a new AppElement instance.
85
+ *
86
+ * @ignore
78
87
  */
79
88
  constructor() {
80
89
  super();
@@ -87,6 +96,21 @@ class AppElement extends AsyncElement {
87
96
  this._depth = true;
88
97
  this._stencil = true;
89
98
  this._highResolution = false;
99
+ this._hierarchyReady = false;
100
+ this._picker = null;
101
+ this._hasPointerListeners = {
102
+ pointerenter: false,
103
+ pointerleave: false,
104
+ pointerdown: false,
105
+ pointerup: false,
106
+ pointermove: false
107
+ };
108
+ this._hoveredEntity = null;
109
+ this._pointerHandlers = {
110
+ pointermove: null,
111
+ pointerdown: null,
112
+ pointerup: null
113
+ };
90
114
  /**
91
115
  * The PlayCanvas application instance.
92
116
  */
@@ -116,6 +140,7 @@ class AppElement extends AsyncElement {
116
140
  this.app.graphicsDevice.maxPixelRatio = this._highResolution ? window.devicePixelRatio : 1;
117
141
  this.app.setCanvasFillMode(FILLMODE_FILL_WINDOW);
118
142
  this.app.setCanvasResolution(RESOLUTION_AUTO);
143
+ this._pickerCreate();
119
144
  // Get all pc-asset elements that are direct children of the pc-app element
120
145
  const assetElements = this.querySelectorAll(':scope > pc-asset');
121
146
  Array.from(assetElements).forEach((assetElement) => {
@@ -130,6 +155,16 @@ class AppElement extends AsyncElement {
130
155
  Array.from(materialElements).forEach((materialElement) => {
131
156
  materialElement.createMaterial();
132
157
  });
158
+ // Create all entities
159
+ const entityElements = this.querySelectorAll('pc-entity');
160
+ Array.from(entityElements).forEach((entityElement) => {
161
+ entityElement.createEntity(this.app);
162
+ });
163
+ // Build hierarchy
164
+ entityElements.forEach((entityElement) => {
165
+ entityElement.buildHierarchy(this.app);
166
+ });
167
+ this._hierarchyReady = true;
133
168
  // Load assets before starting the application
134
169
  this.app.preload(() => {
135
170
  // Start the application
@@ -140,6 +175,7 @@ class AppElement extends AsyncElement {
140
175
  });
141
176
  }
142
177
  disconnectedCallback() {
178
+ this._pickerDestroy();
143
179
  // Clean up the application
144
180
  if (this.app) {
145
181
  this.app.destroy();
@@ -158,6 +194,139 @@ class AppElement extends AsyncElement {
158
194
  this.app.resizeCanvas();
159
195
  }
160
196
  }
197
+ _pickerCreate() {
198
+ const { width, height } = this.app.graphicsDevice;
199
+ this._picker = new Picker(this.app, width, height);
200
+ // Create bound handlers but don't attach them yet
201
+ this._pointerHandlers.pointermove = this._onPointerMove.bind(this);
202
+ this._pointerHandlers.pointerdown = this._onPointerDown.bind(this);
203
+ this._pointerHandlers.pointerup = this._onPointerUp.bind(this);
204
+ // Listen for pointer listeners being added/removed
205
+ ['pointermove', 'pointerdown', 'pointerup', 'pointerenter', 'pointerleave'].forEach((type) => {
206
+ this.addEventListener(`${type}:connect`, () => this._onPointerListenerAdded(type));
207
+ this.addEventListener(`${type}:disconnect`, () => this._onPointerListenerRemoved(type));
208
+ });
209
+ }
210
+ _pickerDestroy() {
211
+ if (this._canvas) {
212
+ Object.entries(this._pointerHandlers).forEach(([type, handler]) => {
213
+ if (handler) {
214
+ this._canvas.removeEventListener(type, handler);
215
+ }
216
+ });
217
+ }
218
+ this._picker = null;
219
+ this._pointerHandlers = {
220
+ pointermove: null,
221
+ pointerdown: null,
222
+ pointerup: null
223
+ };
224
+ }
225
+ _onPointerMove(event) {
226
+ if (!this._picker || !this.app)
227
+ return;
228
+ const camera = this.app.root.findComponent('camera');
229
+ if (!camera)
230
+ return;
231
+ const canvasRect = this._canvas.getBoundingClientRect();
232
+ const x = event.clientX - canvasRect.left;
233
+ const y = event.clientY - canvasRect.top;
234
+ this._picker.prepare(camera, this.app.scene);
235
+ const selection = this._picker.getSelection(x, y);
236
+ // Get the currently hovered entity by walking up the hierarchy
237
+ let newHoverEntity = null;
238
+ if (selection.length > 0) {
239
+ let node = selection[0].node;
240
+ while (node && !newHoverEntity) {
241
+ const entityElement = this.querySelector(`pc-entity[name="${node.name}"]`);
242
+ if (entityElement) {
243
+ newHoverEntity = entityElement;
244
+ }
245
+ node = node.parent;
246
+ }
247
+ }
248
+ // Handle enter/leave events
249
+ if (this._hoveredEntity !== newHoverEntity) {
250
+ if (this._hoveredEntity && this._hoveredEntity.hasListeners('pointerleave')) {
251
+ this._hoveredEntity.dispatchEvent(new PointerEvent('pointerleave', event));
252
+ }
253
+ if (newHoverEntity && newHoverEntity.hasListeners('pointerenter')) {
254
+ newHoverEntity.dispatchEvent(new PointerEvent('pointerenter', event));
255
+ }
256
+ }
257
+ // Update hover state
258
+ this._hoveredEntity = newHoverEntity;
259
+ // Handle pointermove event
260
+ if (newHoverEntity && newHoverEntity.hasListeners('pointermove')) {
261
+ newHoverEntity.dispatchEvent(new PointerEvent('pointermove', event));
262
+ }
263
+ }
264
+ _onPointerDown(event) {
265
+ if (!this._picker || !this.app)
266
+ return;
267
+ const camera = this.app.root.findComponent('camera');
268
+ if (!camera)
269
+ return;
270
+ const canvasRect = this._canvas.getBoundingClientRect();
271
+ const x = event.clientX - canvasRect.left;
272
+ const y = event.clientY - canvasRect.top;
273
+ this._picker.prepare(camera, this.app.scene);
274
+ const selection = this._picker.getSelection(x, y);
275
+ if (selection.length > 0) {
276
+ let node = selection[0].node;
277
+ while (node) {
278
+ const entityElement = this.querySelector(`pc-entity[name="${node.name}"]`);
279
+ if (entityElement && entityElement.hasListeners('pointerdown')) {
280
+ entityElement.dispatchEvent(new PointerEvent('pointerdown', event));
281
+ break;
282
+ }
283
+ node = node.parent;
284
+ }
285
+ }
286
+ }
287
+ _onPointerUp(event) {
288
+ if (!this._picker || !this.app)
289
+ return;
290
+ const camera = this.app.root.findComponent('camera');
291
+ if (!camera)
292
+ return;
293
+ const canvasRect = this._canvas.getBoundingClientRect();
294
+ const x = event.clientX - canvasRect.left;
295
+ const y = event.clientY - canvasRect.top;
296
+ this._picker.prepare(camera, this.app.scene);
297
+ const selection = this._picker.getSelection(x, y);
298
+ if (selection.length > 0) {
299
+ const entityElement = this.querySelector(`pc-entity[name="${selection[0].node.name}"]`);
300
+ if (entityElement && entityElement.hasListeners('pointerup')) {
301
+ entityElement.dispatchEvent(new PointerEvent('pointerup', event));
302
+ }
303
+ }
304
+ }
305
+ _onPointerListenerAdded(type) {
306
+ if (!this._hasPointerListeners[type] && this._canvas) {
307
+ this._hasPointerListeners[type] = true;
308
+ // For enter/leave events, we need the move handler
309
+ const handler = (type === 'pointerenter' || type === 'pointerleave') ?
310
+ this._pointerHandlers.pointermove :
311
+ this._pointerHandlers[type];
312
+ if (handler) {
313
+ this._canvas.addEventListener(type === 'pointerenter' || type === 'pointerleave' ? 'pointermove' : type, handler);
314
+ }
315
+ }
316
+ }
317
+ _onPointerListenerRemoved(type) {
318
+ const hasListeners = Array.from(this.querySelectorAll('pc-entity'))
319
+ .some(entity => entity.hasListeners(type));
320
+ if (!hasListeners && this._canvas) {
321
+ this._hasPointerListeners[type] = false;
322
+ const handler = (type === 'pointerenter' || type === 'pointerleave') ?
323
+ this._pointerHandlers.pointermove :
324
+ this._pointerHandlers[type];
325
+ if (handler) {
326
+ this._canvas.removeEventListener(type === 'pointerenter' || type === 'pointerleave' ? 'pointermove' : type, handler);
327
+ }
328
+ }
329
+ }
161
330
  /**
162
331
  * Sets the alpha flag.
163
332
  * @param value - The alpha flag.
@@ -200,6 +369,14 @@ class AppElement extends AsyncElement {
200
369
  get depth() {
201
370
  return this._depth;
202
371
  }
372
+ /**
373
+ * Gets the hierarchy ready flag.
374
+ * @returns The hierarchy ready flag.
375
+ * @ignore
376
+ */
377
+ get hierarchyReady() {
378
+ return this._hierarchyReady;
379
+ }
203
380
  /**
204
381
  * Sets the high resolution flag. When true, the application will render at the device's
205
382
  * physical resolution. When false, the application will render at CSS resolution.
@@ -471,7 +648,9 @@ const parseVec4 = (value) => {
471
648
  };
472
649
 
473
650
  /**
474
- * Represents an entity in the PlayCanvas engine.
651
+ * The EntityElement interface provides properties and methods for manipulating
652
+ * `<pc-entity>` elements. The EntityElement interface also inherits the properties and
653
+ * methods of the {@link HTMLElement} interface.
475
654
  */
476
655
  class EntityElement extends AsyncElement {
477
656
  constructor() {
@@ -500,49 +679,93 @@ class EntityElement extends AsyncElement {
500
679
  * The tags of the entity.
501
680
  */
502
681
  this._tags = [];
682
+ /**
683
+ * The pointer event listeners for the entity.
684
+ */
685
+ this._listeners = {};
503
686
  /**
504
687
  * The PlayCanvas entity instance.
505
688
  */
506
689
  this.entity = null;
507
690
  }
508
- async connectedCallback() {
509
- const closestApp = this.closestApp;
510
- if (!closestApp)
511
- return;
512
- // Wait for the app to complete initialization
513
- await closestApp.ready();
514
- const app = closestApp.app;
691
+ createEntity(app) {
515
692
  // Create a new entity
516
- this.entity = new Entity(this._name, app);
517
- // Initialize from attributes
518
- const enabledAttr = this.getAttribute('enabled');
519
- const nameAttr = this.getAttribute('name');
520
- const positionAttr = this.getAttribute('position');
521
- const rotationAttr = this.getAttribute('rotation');
522
- const scaleAttr = this.getAttribute('scale');
523
- const tagsAttr = this.getAttribute('tags');
524
- if (enabledAttr)
525
- this.enabled = enabledAttr !== 'false';
526
- if (nameAttr)
527
- this.name = nameAttr;
528
- if (positionAttr)
529
- this.position = parseVec3(positionAttr);
530
- if (rotationAttr)
531
- this.rotation = parseVec3(rotationAttr);
532
- if (scaleAttr)
533
- this.scale = parseVec3(scaleAttr);
534
- if (tagsAttr)
535
- this.tags = tagsAttr.split(',').map(tag => tag.trim());
693
+ this.entity = new Entity(this.getAttribute('name') || this._name, app);
694
+ const enabled = this.getAttribute('enabled');
695
+ if (enabled) {
696
+ this.entity.enabled = enabled !== 'false';
697
+ }
698
+ const position = this.getAttribute('position');
699
+ if (position) {
700
+ this.entity.setLocalPosition(parseVec3(position));
701
+ }
702
+ const rotation = this.getAttribute('rotation');
703
+ if (rotation) {
704
+ this.entity.setLocalEulerAngles(parseVec3(rotation));
705
+ }
706
+ const scale = this.getAttribute('scale');
707
+ if (scale) {
708
+ this.entity.setLocalScale(parseVec3(scale));
709
+ }
710
+ const tags = this.getAttribute('tags');
711
+ if (tags) {
712
+ this.entity.tags.add(tags.split(',').map(tag => tag.trim()));
713
+ }
714
+ // Handle pointer events
715
+ const pointerEvents = [
716
+ 'onpointerenter',
717
+ 'onpointerleave',
718
+ 'onpointerdown',
719
+ 'onpointerup',
720
+ 'onpointermove'
721
+ ];
722
+ pointerEvents.forEach((eventName) => {
723
+ const handler = this.getAttribute(eventName);
724
+ if (handler) {
725
+ const eventType = eventName.substring(2); // remove 'on' prefix
726
+ const eventHandler = (event) => {
727
+ try {
728
+ /* eslint-disable-next-line no-new-func */
729
+ new Function('event', handler).call(this, event);
730
+ }
731
+ catch (e) {
732
+ console.error('Error in event handler:', e);
733
+ }
734
+ };
735
+ this.addEventListener(eventType, eventHandler);
736
+ }
737
+ });
738
+ }
739
+ buildHierarchy(app) {
740
+ if (!this.entity)
741
+ return;
536
742
  const closestEntity = this.closestEntity;
537
- if (closestEntity) {
538
- closestEntity.ready().then(() => {
539
- closestEntity.entity.addChild(this.entity);
540
- this._onReady();
541
- });
743
+ if (closestEntity === null || closestEntity === void 0 ? void 0 : closestEntity.entity) {
744
+ closestEntity.entity.addChild(this.entity);
542
745
  }
543
746
  else {
544
747
  app.root.addChild(this.entity);
545
- this._onReady();
748
+ }
749
+ this._onReady();
750
+ }
751
+ connectedCallback() {
752
+ // Wait for app to be ready
753
+ const closestApp = this.closestApp;
754
+ if (!closestApp)
755
+ return;
756
+ // If app is already running, create entity immediately
757
+ if (closestApp.hierarchyReady) {
758
+ const app = closestApp.app;
759
+ this.createEntity(app);
760
+ this.buildHierarchy(app);
761
+ // Handle any child entities that might exist
762
+ const childEntities = this.querySelectorAll('pc-entity');
763
+ childEntities.forEach((child) => {
764
+ child.createEntity(app);
765
+ });
766
+ childEntities.forEach((child) => {
767
+ child.buildHierarchy(app);
768
+ });
546
769
  }
547
770
  }
548
771
  disconnectedCallback() {
@@ -552,6 +775,7 @@ class EntityElement extends AsyncElement {
552
775
  children.forEach((child) => {
553
776
  child.entity = null;
554
777
  });
778
+ // Destroy the entity
555
779
  this.entity.destroy();
556
780
  this.entity = null;
557
781
  }
@@ -660,7 +884,19 @@ class EntityElement extends AsyncElement {
660
884
  return this._tags;
661
885
  }
662
886
  static get observedAttributes() {
663
- return ['enabled', 'name', 'position', 'rotation', 'scale', 'tags'];
887
+ return [
888
+ 'enabled',
889
+ 'name',
890
+ 'position',
891
+ 'rotation',
892
+ 'scale',
893
+ 'tags',
894
+ 'onpointerenter',
895
+ 'onpointerleave',
896
+ 'onpointerdown',
897
+ 'onpointerup',
898
+ 'onpointermove'
899
+ ];
664
900
  }
665
901
  attributeChangedCallback(name, _oldValue, newValue) {
666
902
  switch (name) {
@@ -682,7 +918,51 @@ class EntityElement extends AsyncElement {
682
918
  case 'tags':
683
919
  this.tags = newValue.split(',').map(tag => tag.trim());
684
920
  break;
921
+ case 'onpointerenter':
922
+ case 'onpointerleave':
923
+ case 'onpointerdown':
924
+ case 'onpointerup':
925
+ case 'onpointermove':
926
+ if (newValue) {
927
+ const eventName = name.substring(2);
928
+ // Use Function.prototype.bind to avoid new Function
929
+ const handler = (event) => {
930
+ try {
931
+ const handlerStr = this.getAttribute(eventName) || '';
932
+ /* eslint-disable-next-line no-new-func */
933
+ new Function('event', handlerStr).call(this, event);
934
+ }
935
+ catch (e) {
936
+ console.error('Error in event handler:', e);
937
+ }
938
+ };
939
+ this.addEventListener(eventName, handler);
940
+ }
941
+ break;
942
+ }
943
+ }
944
+ addEventListener(type, listener, options) {
945
+ if (!this._listeners[type]) {
946
+ this._listeners[type] = [];
685
947
  }
948
+ this._listeners[type].push(listener);
949
+ super.addEventListener(type, listener, options);
950
+ if (type.startsWith('pointer')) {
951
+ this.dispatchEvent(new CustomEvent(`${type}:connect`, { bubbles: true }));
952
+ }
953
+ }
954
+ removeEventListener(type, listener, options) {
955
+ if (this._listeners[type]) {
956
+ this._listeners[type] = this._listeners[type].filter(l => l !== listener);
957
+ }
958
+ super.removeEventListener(type, listener, options);
959
+ if (type.startsWith('pointer')) {
960
+ this.dispatchEvent(new CustomEvent(`${type}:disconnect`, { bubbles: true }));
961
+ }
962
+ }
963
+ hasListeners(type) {
964
+ var _a;
965
+ return Boolean((_a = this._listeners[type]) === null || _a === void 0 ? void 0 : _a.length);
686
966
  }
687
967
  }
688
968
  customElements.define('pc-entity', EntityElement);
@@ -707,7 +987,9 @@ const extToType = new Map([
707
987
  ['webp', 'texture']
708
988
  ]);
709
989
  /**
710
- * Loads an asset into the PlayCanvas engine.
990
+ * The AssetElement interface provides properties and methods for manipulating
991
+ * `<pc-asset>` elements. The AssetElement interface also inherits the properties and
992
+ * methods of the {@link HTMLElement} interface.
711
993
  */
712
994
  class AssetElement extends HTMLElement {
713
995
  constructor() {
@@ -783,8 +1065,10 @@ customElements.define('pc-asset', AssetElement);
783
1065
  */
784
1066
  class ComponentElement extends AsyncElement {
785
1067
  /**
786
- * Constructor for the ComponentElement.
1068
+ * Creates a new ComponentElement instance.
1069
+ *
787
1070
  * @param componentName - The name of the component.
1071
+ * @ignore
788
1072
  */
789
1073
  constructor(componentName) {
790
1074
  super();
@@ -853,11 +1137,14 @@ class ComponentElement extends AsyncElement {
853
1137
  }
854
1138
 
855
1139
  /**
856
- * Represents a audio listener component in the PlayCanvas engine.
1140
+ * The ListenerComponentElement interface provides properties and methods for manipulating
1141
+ * `<pc-listener>` elements. The ListenerComponentElement interface also inherits the properties
1142
+ * and methods of the {@link HTMLElement} interface.
857
1143
  *
858
1144
  * @category Components
859
1145
  */
860
1146
  class ListenerComponentElement extends ComponentElement {
1147
+ /** @ignore */
861
1148
  constructor() {
862
1149
  super('audiolistener');
863
1150
  }
@@ -871,15 +1158,24 @@ class ListenerComponentElement extends ComponentElement {
871
1158
  }
872
1159
  customElements.define('pc-listener', ListenerComponentElement);
873
1160
 
1161
+ const tonemaps = new Map([
1162
+ ['none', TONEMAP_NONE],
1163
+ ['linear', TONEMAP_LINEAR],
1164
+ ['filmic', TONEMAP_FILMIC],
1165
+ ['hejl', TONEMAP_HEJL],
1166
+ ['aces', TONEMAP_ACES],
1167
+ ['aces2', TONEMAP_ACES2],
1168
+ ['neutral', TONEMAP_NEUTRAL]
1169
+ ]);
874
1170
  /**
875
- * Represents a camera component in the PlayCanvas engine.
1171
+ * The CameraComponentElement interface provides properties and methods for manipulating
1172
+ * `<pc-camera>` elements. The CameraComponentElement interface also inherits the properties and
1173
+ * methods of the {@link HTMLElement} interface.
876
1174
  *
877
1175
  * @category Components
878
1176
  */
879
1177
  class CameraComponentElement extends ComponentElement {
880
- /**
881
- * Creates a new CameraComponentElement.
882
- */
1178
+ /** @ignore */
883
1179
  constructor() {
884
1180
  super('camera');
885
1181
  this._clearColor = new Color(0.75, 0.75, 0.75, 1);
@@ -891,12 +1187,14 @@ class CameraComponentElement extends ComponentElement {
891
1187
  this._flipFaces = false;
892
1188
  this._fov = 45;
893
1189
  this._frustumCulling = true;
1190
+ this._gamma = 'srgb';
894
1191
  this._nearClip = 0.1;
895
1192
  this._orthographic = false;
896
1193
  this._orthoHeight = 10;
897
1194
  this._priority = 0;
898
1195
  this._rect = new Vec4(0, 0, 1, 1);
899
1196
  this._scissorRect = new Vec4(0, 0, 1, 1);
1197
+ this._tonemap = 'none';
900
1198
  }
901
1199
  getInitialComponentData() {
902
1200
  return {
@@ -909,12 +1207,14 @@ class CameraComponentElement extends ComponentElement {
909
1207
  flipFaces: this._flipFaces,
910
1208
  fov: this._fov,
911
1209
  frustumCulling: this._frustumCulling,
1210
+ gammaCorrection: this._gamma === 'srgb' ? GAMMA_SRGB : GAMMA_NONE,
912
1211
  nearClip: this._nearClip,
913
1212
  orthographic: this._orthographic,
914
1213
  orthoHeight: this._orthoHeight,
915
1214
  priority: this._priority,
916
1215
  rect: this._rect,
917
- scissorRect: this._scissorRect
1216
+ scissorRect: this._scissorRect,
1217
+ toneMapping: tonemaps.get(this._tonemap)
918
1218
  };
919
1219
  }
920
1220
  get xrAvailable() {
@@ -1097,6 +1397,23 @@ class CameraComponentElement extends ComponentElement {
1097
1397
  get frustumCulling() {
1098
1398
  return this._frustumCulling;
1099
1399
  }
1400
+ /**
1401
+ * Sets the gamma correction of the camera.
1402
+ * @param value - The gamma correction.
1403
+ */
1404
+ set gamma(value) {
1405
+ this._gamma = value;
1406
+ if (this.component) {
1407
+ this.component.gammaCorrection = value === 'srgb' ? GAMMA_SRGB : GAMMA_NONE;
1408
+ }
1409
+ }
1410
+ /**
1411
+ * Gets the gamma correction of the camera.
1412
+ * @returns The gamma correction.
1413
+ */
1414
+ get gamma() {
1415
+ return this._gamma;
1416
+ }
1100
1417
  /**
1101
1418
  * Sets the near clip distance of the camera.
1102
1419
  * @param value - The near clip distance.
@@ -1199,6 +1516,24 @@ class CameraComponentElement extends ComponentElement {
1199
1516
  get scissorRect() {
1200
1517
  return this._scissorRect;
1201
1518
  }
1519
+ /**
1520
+ * Sets the tone mapping of the camera.
1521
+ * @param value - The tone mapping.
1522
+ */
1523
+ set tonemap(value) {
1524
+ var _a;
1525
+ this._tonemap = value;
1526
+ if (this.component) {
1527
+ this.component.toneMapping = (_a = tonemaps.get(value)) !== null && _a !== void 0 ? _a : TONEMAP_NONE;
1528
+ }
1529
+ }
1530
+ /**
1531
+ * Gets the tone mapping of the camera.
1532
+ * @returns The tone mapping.
1533
+ */
1534
+ get tonemap() {
1535
+ return this._tonemap;
1536
+ }
1202
1537
  static get observedAttributes() {
1203
1538
  return [
1204
1539
  ...super.observedAttributes,
@@ -1211,12 +1546,14 @@ class CameraComponentElement extends ComponentElement {
1211
1546
  'flip-faces',
1212
1547
  'fov',
1213
1548
  'frustum-culling',
1549
+ 'gamma',
1214
1550
  'near-clip',
1215
1551
  'orthographic',
1216
1552
  'ortho-height',
1217
1553
  'priority',
1218
1554
  'rect',
1219
- 'scissor-rect'
1555
+ 'scissor-rect',
1556
+ 'tonemap'
1220
1557
  ];
1221
1558
  }
1222
1559
  attributeChangedCallback(name, _oldValue, newValue) {
@@ -1249,6 +1586,9 @@ class CameraComponentElement extends ComponentElement {
1249
1586
  case 'frustum-culling':
1250
1587
  this.frustumCulling = newValue !== 'false';
1251
1588
  break;
1589
+ case 'gamma':
1590
+ this.gamma = newValue;
1591
+ break;
1252
1592
  case 'near-clip':
1253
1593
  this.nearClip = parseFloat(newValue);
1254
1594
  break;
@@ -1267,20 +1607,23 @@ class CameraComponentElement extends ComponentElement {
1267
1607
  case 'scissor-rect':
1268
1608
  this.scissorRect = parseVec4(newValue);
1269
1609
  break;
1610
+ case 'tonemap':
1611
+ this.tonemap = newValue;
1612
+ break;
1270
1613
  }
1271
1614
  }
1272
1615
  }
1273
1616
  customElements.define('pc-camera', CameraComponentElement);
1274
1617
 
1275
1618
  /**
1276
- * Represents a collision component in the PlayCanvas engine.
1619
+ * The CollisionComponentElement interface provides properties and methods for manipulating
1620
+ * `<pc-collision>` elements. The CollisionComponentElement interface also inherits the properties
1621
+ * and methods of the {@link HTMLElement} interface.
1277
1622
  *
1278
1623
  * @category Components
1279
1624
  */
1280
1625
  class CollisionComponentElement extends ComponentElement {
1281
- /**
1282
- * Creates a new CollisionComponentElement.
1283
- */
1626
+ /** @ignore */
1284
1627
  constructor() {
1285
1628
  super('collision');
1286
1629
  this._angularOffset = new Quat();
@@ -1419,11 +1762,14 @@ class CollisionComponentElement extends ComponentElement {
1419
1762
  customElements.define('pc-collision', CollisionComponentElement);
1420
1763
 
1421
1764
  /**
1422
- * Represents an element component in the PlayCanvas engine.
1765
+ * The ElementComponentElement interface provides properties and methods for manipulating
1766
+ * `<pc-element>` elements. The ElementComponentElement interface also inherits the properties and
1767
+ * methods of the {@link HTMLElement} interface.
1423
1768
  *
1424
1769
  * @category Components
1425
1770
  */
1426
1771
  class ElementComponentElement extends ComponentElement {
1772
+ /** @ignore */
1427
1773
  constructor() {
1428
1774
  super('element');
1429
1775
  this._anchor = new Vec4(0.5, 0.5, 0.5, 0.5);
@@ -1629,11 +1975,14 @@ class ElementComponentElement extends ComponentElement {
1629
1975
  customElements.define('pc-element', ElementComponentElement);
1630
1976
 
1631
1977
  /**
1632
- * Represents a gsplat component in the PlayCanvas engine.
1978
+ * The GSplatComponentElement interface provides properties and methods for manipulating
1979
+ * `<pc-splat>` elements. The GSplatComponentElement interface also inherits the properties and
1980
+ * methods of the {@link HTMLElement} interface.
1633
1981
  *
1634
1982
  * @category Components
1635
1983
  */
1636
1984
  class GSplatComponentElement extends ComponentElement {
1985
+ /** @ignore */
1637
1986
  constructor() {
1638
1987
  super('gsplat');
1639
1988
  this._asset = '';
@@ -1674,15 +2023,26 @@ class GSplatComponentElement extends ComponentElement {
1674
2023
  }
1675
2024
  customElements.define('pc-splat', GSplatComponentElement);
1676
2025
 
2026
+ const shadowTypes = new Map([
2027
+ ['pcf1-16f', SHADOW_PCF1_16F],
2028
+ ['pcf1-32f', SHADOW_PCF1_32F],
2029
+ ['pcf3-16f', SHADOW_PCF3_16F],
2030
+ ['pcf3-32f', SHADOW_PCF3_32F],
2031
+ ['pcf5-16f', SHADOW_PCF5_16F],
2032
+ ['pcf5-32f', SHADOW_PCF5_32F],
2033
+ ['vsm-16f', SHADOW_VSM_16F],
2034
+ ['vsm-32f', SHADOW_VSM_32F],
2035
+ ['pcss-32f', SHADOW_PCSS_32F]
2036
+ ]);
1677
2037
  /**
1678
- * Represents a light component in the PlayCanvas engine.
2038
+ * The LightComponentElement interface provides properties and methods for manipulating
2039
+ * `<pc-light>` elements. The LightComponentElement interface also inherits the properties and
2040
+ * methods of the {@link HTMLElement} interface.
1679
2041
  *
1680
2042
  * @category Components
1681
2043
  */
1682
2044
  class LightComponentElement extends ComponentElement {
1683
- /**
1684
- * Creates a new LightComponentElement.
1685
- */
2045
+ /** @ignore */
1686
2046
  constructor() {
1687
2047
  super('light');
1688
2048
  this._castShadows = false;
@@ -1694,8 +2054,11 @@ class LightComponentElement extends ComponentElement {
1694
2054
  this._range = 10;
1695
2055
  this._shadowBias = 0.2;
1696
2056
  this._shadowDistance = 16;
2057
+ this._shadowIntensity = 1;
1697
2058
  this._shadowResolution = 1024;
2059
+ this._shadowType = 'pcf3-32f';
1698
2060
  this._type = 'directional';
2061
+ this._vsmBias = 0.01;
1699
2062
  }
1700
2063
  getInitialComponentData() {
1701
2064
  return {
@@ -1708,8 +2071,11 @@ class LightComponentElement extends ComponentElement {
1708
2071
  range: this._range,
1709
2072
  shadowBias: this._shadowBias,
1710
2073
  shadowDistance: this._shadowDistance,
2074
+ shadowIntensity: this._shadowIntensity,
1711
2075
  shadowResolution: this._shadowResolution,
1712
- type: this._type
2076
+ shadowType: shadowTypes.get(this._shadowType),
2077
+ type: this._type,
2078
+ vsmBias: this._vsmBias
1713
2079
  };
1714
2080
  }
1715
2081
  /**
@@ -1872,6 +2238,23 @@ class LightComponentElement extends ComponentElement {
1872
2238
  get shadowDistance() {
1873
2239
  return this._shadowDistance;
1874
2240
  }
2241
+ /**
2242
+ * Sets the shadow intensity of the light.
2243
+ * @param value - The shadow intensity.
2244
+ */
2245
+ set shadowIntensity(value) {
2246
+ this._shadowIntensity = value;
2247
+ if (this.component) {
2248
+ this.component.shadowIntensity = value;
2249
+ }
2250
+ }
2251
+ /**
2252
+ * Gets the shadow intensity of the light.
2253
+ * @returns The shadow intensity.
2254
+ */
2255
+ get shadowIntensity() {
2256
+ return this._shadowIntensity;
2257
+ }
1875
2258
  /**
1876
2259
  * Sets the shadow resolution of the light.
1877
2260
  * @param value - The shadow resolution.
@@ -1889,6 +2272,34 @@ class LightComponentElement extends ComponentElement {
1889
2272
  get shadowResolution() {
1890
2273
  return this._shadowResolution;
1891
2274
  }
2275
+ /**
2276
+ * Sets the shadow type of the light.
2277
+ * @param value - The shadow type. Can be:
2278
+ *
2279
+ * - `pcf1-16f` - 1-tap percentage-closer filtered shadow map with 16-bit depth.
2280
+ * - `pcf1-32f` - 1-tap percentage-closer filtered shadow map with 32-bit depth.
2281
+ * - `pcf3-16f` - 3-tap percentage-closer filtered shadow map with 16-bit depth.
2282
+ * - `pcf3-32f` - 3-tap percentage-closer filtered shadow map with 32-bit depth.
2283
+ * - `pcf5-16f` - 5-tap percentage-closer filtered shadow map with 16-bit depth.
2284
+ * - `pcf5-32f` - 5-tap percentage-closer filtered shadow map with 32-bit depth.
2285
+ * - `vsm-16f` - Variance shadow map with 16-bit depth.
2286
+ * - `vsm-32f` - Variance shadow map with 32-bit depth.
2287
+ * - `pcss-32f` - Percentage-closer soft shadow with 32-bit depth.
2288
+ */
2289
+ set shadowType(value) {
2290
+ var _a;
2291
+ this._shadowType = value;
2292
+ if (this.component) {
2293
+ this.component.shadowType = (_a = shadowTypes.get(value)) !== null && _a !== void 0 ? _a : SHADOW_PCF3_32F;
2294
+ }
2295
+ }
2296
+ /**
2297
+ * Gets the shadow type of the light.
2298
+ * @returns The shadow type.
2299
+ */
2300
+ get shadowType() {
2301
+ return this._shadowType;
2302
+ }
1892
2303
  /**
1893
2304
  * Sets the type of the light.
1894
2305
  * @param value - The type.
@@ -1910,6 +2321,23 @@ class LightComponentElement extends ComponentElement {
1910
2321
  get type() {
1911
2322
  return this._type;
1912
2323
  }
2324
+ /**
2325
+ * Sets the VSM bias of the light.
2326
+ * @param value - The VSM bias.
2327
+ */
2328
+ set vsmBias(value) {
2329
+ this._vsmBias = value;
2330
+ if (this.component) {
2331
+ this.component.vsmBias = value;
2332
+ }
2333
+ }
2334
+ /**
2335
+ * Gets the VSM bias of the light.
2336
+ * @returns The VSM bias.
2337
+ */
2338
+ get vsmBias() {
2339
+ return this._vsmBias;
2340
+ }
1913
2341
  static get observedAttributes() {
1914
2342
  return [
1915
2343
  ...super.observedAttributes,
@@ -1922,8 +2350,11 @@ class LightComponentElement extends ComponentElement {
1922
2350
  'range',
1923
2351
  'shadow-bias',
1924
2352
  'shadow-distance',
2353
+ 'shadow-intensity',
1925
2354
  'shadow-resolution',
1926
- 'type'
2355
+ 'shadow-type',
2356
+ 'type',
2357
+ 'vsm-bias'
1927
2358
  ];
1928
2359
  }
1929
2360
  attributeChangedCallback(name, _oldValue, newValue) {
@@ -1959,16 +2390,27 @@ class LightComponentElement extends ComponentElement {
1959
2390
  case 'shadow-resolution':
1960
2391
  this.shadowResolution = Number(newValue);
1961
2392
  break;
2393
+ case 'shadow-intensity':
2394
+ this.shadowIntensity = Number(newValue);
2395
+ break;
2396
+ case 'shadow-type':
2397
+ this.shadowType = newValue;
2398
+ break;
1962
2399
  case 'type':
1963
2400
  this.type = newValue;
1964
2401
  break;
2402
+ case 'vsm-bias':
2403
+ this.vsmBias = Number(newValue);
2404
+ break;
1965
2405
  }
1966
2406
  }
1967
2407
  }
1968
2408
  customElements.define('pc-light', LightComponentElement);
1969
2409
 
1970
2410
  /**
1971
- * Represents a material in the PlayCanvas engine.
2411
+ * The MaterialElement interface provides properties and methods for manipulating
2412
+ * `<pc-material>` elements. The MaterialElement interface also inherits the properties and
2413
+ * methods of the {@link HTMLElement} interface.
1972
2414
  */
1973
2415
  class MaterialElement extends HTMLElement {
1974
2416
  constructor() {
@@ -1982,8 +2424,8 @@ class MaterialElement extends HTMLElement {
1982
2424
  }
1983
2425
  createMaterial() {
1984
2426
  this.material = new StandardMaterial();
1985
- this.material.glossInvert = true;
1986
- this.material.useMetalness = true;
2427
+ this.material.glossInvert = false;
2428
+ this.material.useMetalness = false;
1987
2429
  this.material.diffuse = this._diffuse;
1988
2430
  this.diffuseMap = this._diffuseMap;
1989
2431
  this.metalnessMap = this._metalnessMap;
@@ -2082,11 +2524,14 @@ class MaterialElement extends HTMLElement {
2082
2524
  customElements.define('pc-material', MaterialElement);
2083
2525
 
2084
2526
  /**
2085
- * Represents a render component in the PlayCanvas engine.
2527
+ * The RenderComponentElement interface provides properties and methods for manipulating
2528
+ * `<pc-render>` elements. The RenderComponentElement interface also inherits the properties and
2529
+ * methods of the {@link HTMLElement} interface.
2086
2530
  *
2087
2531
  * @category Components
2088
2532
  */
2089
2533
  class RenderComponentElement extends ComponentElement {
2534
+ /** @ignore */
2090
2535
  constructor() {
2091
2536
  super('render');
2092
2537
  this._castShadows = true;
@@ -2201,14 +2646,14 @@ class RenderComponentElement extends ComponentElement {
2201
2646
  customElements.define('pc-render', RenderComponentElement);
2202
2647
 
2203
2648
  /**
2204
- * Represents a rigidbody component in the PlayCanvas engine.
2649
+ * The RigidBodyComponentElement interface provides properties and methods for manipulating
2650
+ * `<pc-rigidbody>` elements. The RigidBodyComponentElement interface also inherits the properties
2651
+ * and methods of the {@link HTMLElement} interface.
2205
2652
  *
2206
2653
  * @category Components
2207
2654
  */
2208
2655
  class RigidBodyComponentElement extends ComponentElement {
2209
- /**
2210
- * Creates a new RigidBodyComponentElement.
2211
- */
2656
+ /** @ignore */
2212
2657
  constructor() {
2213
2658
  super('rigidbody');
2214
2659
  /**
@@ -2388,11 +2833,14 @@ class RigidBodyComponentElement extends ComponentElement {
2388
2833
  customElements.define('pc-rigidbody', RigidBodyComponentElement);
2389
2834
 
2390
2835
  /**
2391
- * Represents a screen component in the PlayCanvas engine.
2836
+ * The ScreenComponentElement interface provides properties and methods for manipulating
2837
+ * `<pc-screen>` elements. The ScreenComponentElement interface also inherits the properties and
2838
+ * methods of the {@link HTMLElement} interface.
2392
2839
  *
2393
2840
  * @category Components
2394
2841
  */
2395
2842
  class ScreenComponentElement extends ComponentElement {
2843
+ /** @ignore */
2396
2844
  constructor() {
2397
2845
  super('screen');
2398
2846
  this._screenSpace = false;
@@ -2510,15 +2958,15 @@ class ScreenComponentElement extends ComponentElement {
2510
2958
  }
2511
2959
  customElements.define('pc-screen', ScreenComponentElement);
2512
2960
 
2513
- const tmpV2 = new Vec2();
2514
- const tmpV3 = new Vec3();
2515
- const tmpV4 = new Vec4();
2516
2961
  /**
2517
- * Represents a script component in the PlayCanvas engine.
2962
+ * The ScriptComponentElement interface provides properties and methods for manipulating
2963
+ * `<pc-scripts>` elements. The ScriptComponentElement interface also inherits the properties and
2964
+ * methods of the {@link HTMLElement} interface.
2518
2965
  *
2519
2966
  * @category Components
2520
2967
  */
2521
2968
  class ScriptComponentElement extends ComponentElement {
2969
+ /** @ignore */
2522
2970
  constructor() {
2523
2971
  super('script');
2524
2972
  // Create mutation observer to watch for child script elements
@@ -2553,22 +3001,34 @@ class ScriptComponentElement extends ComponentElement {
2553
3001
  return;
2554
3002
  }
2555
3003
  }
2556
- // Handle vectors
2557
- if (Array.isArray(value)) {
2558
- if (target[key] instanceof Vec2) {
2559
- target[key] = tmpV2.set(value[0], value[1]);
3004
+ // Handle arrays
3005
+ if (value && typeof value === 'object' && Array.isArray(value)) {
3006
+ // If it's an array of objects, recursively apply to each object
3007
+ if (value.length > 0 && typeof value[0] === 'object') {
3008
+ target[key] = value.map((item) => {
3009
+ const obj = {};
3010
+ for (const itemKey in item) {
3011
+ applyValue(obj, itemKey, item[itemKey]);
3012
+ }
3013
+ return obj;
3014
+ });
3015
+ return;
3016
+ }
3017
+ // Handle vectors
3018
+ if (value.length === 2 && typeof value[0] === 'number') {
3019
+ target[key] = new Vec2(value[0], value[1]);
2560
3020
  return;
2561
3021
  }
2562
- if (target[key] instanceof Vec3) {
2563
- target[key] = tmpV3.set(value[0], value[1], value[2]);
3022
+ if (value.length === 3 && typeof value[0] === 'number') {
3023
+ target[key] = new Vec3(value[0], value[1], value[2]);
2564
3024
  return;
2565
3025
  }
2566
- if (target[key] instanceof Vec4) {
2567
- target[key] = tmpV4.set(value[0], value[1], value[2], value[3]);
3026
+ if (value.length === 4 && typeof value[0] === 'number') {
3027
+ target[key] = new Vec4(value[0], value[1], value[2], value[3]);
2568
3028
  return;
2569
3029
  }
2570
3030
  }
2571
- // Handle nested objects
3031
+ // Handle nested objects (non-array)
2572
3032
  if (value && typeof value === 'object' && !Array.isArray(value)) {
2573
3033
  if (!target[key] || typeof target[key] !== 'object') {
2574
3034
  target[key] = {};
@@ -2661,7 +3121,9 @@ class ScriptComponentElement extends ComponentElement {
2661
3121
  customElements.define('pc-scripts', ScriptComponentElement);
2662
3122
 
2663
3123
  /**
2664
- * Represents a script in the PlayCanvas engine.
3124
+ * The ScriptElement interface provides properties and methods for manipulating
3125
+ * `<pc-script>` elements. The ScriptElement interface also inherits the properties and
3126
+ * methods of the {@link HTMLElement} interface.
2665
3127
  */
2666
3128
  class ScriptElement extends HTMLElement {
2667
3129
  constructor() {
@@ -2740,11 +3202,14 @@ class ScriptElement extends HTMLElement {
2740
3202
  customElements.define('pc-script', ScriptElement);
2741
3203
 
2742
3204
  /**
2743
- * Represents a sound component in the PlayCanvas engine.
3205
+ * The SoundComponentElement interface provides properties and methods for manipulating
3206
+ * `<pc-sounds>` elements. The SoundComponentElement interface also inherits the properties and
3207
+ * methods of the {@link HTMLElement} interface.
2744
3208
  *
2745
3209
  * @category Components
2746
3210
  */
2747
3211
  class SoundComponentElement extends ComponentElement {
3212
+ /** @ignore */
2748
3213
  constructor() {
2749
3214
  super('sound');
2750
3215
  this._distanceModel = 'linear';
@@ -2934,7 +3399,9 @@ class SoundComponentElement extends ComponentElement {
2934
3399
  customElements.define('pc-sounds', SoundComponentElement);
2935
3400
 
2936
3401
  /**
2937
- * Represents a sound slot in the PlayCanvas engine.
3402
+ * The SoundSlotElement interface provides properties and methods for manipulating
3403
+ * `<pc-sound>` elements. The SoundSlotElement interface also inherits the properties and
3404
+ * methods of the {@link AsyncElement} interface.
2938
3405
  */
2939
3406
  class SoundSlotElement extends AsyncElement {
2940
3407
  constructor() {
@@ -3175,7 +3642,9 @@ class SoundSlotElement extends AsyncElement {
3175
3642
  customElements.define('pc-sound', SoundSlotElement);
3176
3643
 
3177
3644
  /**
3178
- * Represents a model in the PlayCanvas engine.
3645
+ * The ModelElement interface provides properties and methods for manipulating
3646
+ * `<pc-model>` elements. The ModelElement interface also inherits the properties and
3647
+ * methods of the {@link HTMLElement} interface.
3179
3648
  */
3180
3649
  class ModelElement extends AsyncElement {
3181
3650
  constructor() {
@@ -3268,7 +3737,9 @@ class ModelElement extends AsyncElement {
3268
3737
  customElements.define('pc-model', ModelElement);
3269
3738
 
3270
3739
  /**
3271
- * Represents a scene in the PlayCanvas engine.
3740
+ * The SceneElement interface provides properties and methods for manipulating
3741
+ * `<pc-scene>` elements. The SceneElement interface also inherits the properties and
3742
+ * methods of the {@link HTMLElement} interface.
3272
3743
  */
3273
3744
  class SceneElement extends AsyncElement {
3274
3745
  constructor() {
@@ -3307,11 +3778,11 @@ class SceneElement extends AsyncElement {
3307
3778
  }
3308
3779
  updateSceneSettings() {
3309
3780
  if (this.scene) {
3310
- this.scene.rendering.fog = this._fog;
3311
- this.scene.rendering.fogColor = this._fogColor;
3312
- this.scene.rendering.fogDensity = this._fogDensity;
3313
- this.scene.rendering.fogStart = this._fogStart;
3314
- this.scene.rendering.fogEnd = this._fogEnd;
3781
+ this.scene.fog.type = this._fog;
3782
+ this.scene.fog.color = this._fogColor;
3783
+ this.scene.fog.density = this._fogDensity;
3784
+ this.scene.fog.start = this._fogStart;
3785
+ this.scene.fog.end = this._fogEnd;
3315
3786
  // ... set other properties on the scene as well
3316
3787
  }
3317
3788
  }
@@ -3322,7 +3793,7 @@ class SceneElement extends AsyncElement {
3322
3793
  set fog(value) {
3323
3794
  this._fog = value;
3324
3795
  if (this.scene) {
3325
- this.scene.rendering.fog = value;
3796
+ this.scene.fog.type = value;
3326
3797
  }
3327
3798
  }
3328
3799
  /**
@@ -3339,7 +3810,7 @@ class SceneElement extends AsyncElement {
3339
3810
  set fogColor(value) {
3340
3811
  this._fogColor = value;
3341
3812
  if (this.scene) {
3342
- this.scene.rendering.fogColor = value;
3813
+ this.scene.fog.color = value;
3343
3814
  }
3344
3815
  }
3345
3816
  /**
@@ -3356,7 +3827,7 @@ class SceneElement extends AsyncElement {
3356
3827
  set fogDensity(value) {
3357
3828
  this._fogDensity = value;
3358
3829
  if (this.scene) {
3359
- this.scene.rendering.fogDensity = value;
3830
+ this.scene.fog.density = value;
3360
3831
  }
3361
3832
  }
3362
3833
  /**
@@ -3373,7 +3844,7 @@ class SceneElement extends AsyncElement {
3373
3844
  set fogStart(value) {
3374
3845
  this._fogStart = value;
3375
3846
  if (this.scene) {
3376
- this.scene.rendering.fogStart = value;
3847
+ this.scene.fog.start = value;
3377
3848
  }
3378
3849
  }
3379
3850
  /**
@@ -3390,7 +3861,7 @@ class SceneElement extends AsyncElement {
3390
3861
  set fogEnd(value) {
3391
3862
  this._fogEnd = value;
3392
3863
  if (this.scene) {
3393
- this.scene.rendering.fogEnd = value;
3864
+ this.scene.fog.end = value;
3394
3865
  }
3395
3866
  }
3396
3867
  /**
@@ -3427,7 +3898,9 @@ class SceneElement extends AsyncElement {
3427
3898
  customElements.define('pc-scene', SceneElement);
3428
3899
 
3429
3900
  /**
3430
- * Represents a sky in the PlayCanvas engine.
3901
+ * The SkyElement interface provides properties and methods for manipulating
3902
+ * `<pc-sky>` elements. The SkyElement interface also inherits the properties and
3903
+ * methods of the {@link HTMLElement} interface.
3431
3904
  */
3432
3905
  class SkyElement extends AsyncElement {
3433
3906
  constructor() {