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