@playcanvas/web-components 0.1.10 → 0.1.11

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.
package/dist/pwc.mjs CHANGED
@@ -13,11 +13,11 @@ class AsyncElement extends HTMLElement {
13
13
  }
14
14
  get closestApp() {
15
15
  var _a;
16
- return (_a = this.parentElement) === null || _a === void 0 ? void 0 : _a.closest('pc-app');
16
+ return (_a = this.parentElement) === null || _a === undefined ? undefined : _a.closest('pc-app');
17
17
  }
18
18
  get closestEntity() {
19
19
  var _a;
20
- return (_a = this.parentElement) === null || _a === void 0 ? void 0 : _a.closest('pc-entity');
20
+ return (_a = this.parentElement) === null || _a === undefined ? undefined : _a.closest('pc-entity');
21
21
  }
22
22
  /**
23
23
  * Called when the element is fully initialized and ready.
@@ -740,7 +740,7 @@ class EntityElement extends AsyncElement {
740
740
  if (!this.entity)
741
741
  return;
742
742
  const closestEntity = this.closestEntity;
743
- if (closestEntity === null || closestEntity === void 0 ? void 0 : closestEntity.entity) {
743
+ if (closestEntity === null || closestEntity === undefined ? undefined : closestEntity.entity) {
744
744
  closestEntity.entity.addChild(this.entity);
745
745
  }
746
746
  else {
@@ -962,7 +962,7 @@ class EntityElement extends AsyncElement {
962
962
  }
963
963
  hasListeners(type) {
964
964
  var _a;
965
- return Boolean((_a = this._listeners[type]) === null || _a === void 0 ? void 0 : _a.length);
965
+ return Boolean((_a = this._listeners[type]) === null || _a === undefined ? undefined : _a.length);
966
966
  }
967
967
  }
968
968
  customElements.define('pc-entity', EntityElement);
@@ -1011,7 +1011,7 @@ class AssetElement extends HTMLElement {
1011
1011
  // If no type is specified, try to infer it from the file extension.
1012
1012
  if (!type) {
1013
1013
  const ext = src.split('.').pop();
1014
- type = (_a = extToType.get(ext || '')) !== null && _a !== void 0 ? _a : null;
1014
+ type = (_a = extToType.get(ext || '')) !== null && _a !== undefined ? _a : null;
1015
1015
  }
1016
1016
  if (!type) {
1017
1017
  console.warn(`Unsupported asset type: ${src}`);
@@ -1045,7 +1045,7 @@ class AssetElement extends HTMLElement {
1045
1045
  }
1046
1046
  static get(id) {
1047
1047
  const assetElement = document.querySelector(`pc-asset[id="${id}"]`);
1048
- return assetElement === null || assetElement === void 0 ? void 0 : assetElement.asset;
1048
+ return assetElement === null || assetElement === undefined ? undefined : assetElement.asset;
1049
1049
  }
1050
1050
  static get observedAttributes() {
1051
1051
  return ['preload'];
@@ -1092,7 +1092,7 @@ class ComponentElement extends AsyncElement {
1092
1092
  initComponent() { }
1093
1093
  async connectedCallback() {
1094
1094
  var _a;
1095
- await ((_a = this.closestApp) === null || _a === void 0 ? void 0 : _a.ready());
1095
+ await ((_a = this.closestApp) === null || _a === undefined ? undefined : _a.ready());
1096
1096
  await this.addComponent();
1097
1097
  this.initComponent();
1098
1098
  this._onReady();
@@ -1188,6 +1188,7 @@ class CameraComponentElement extends ComponentElement {
1188
1188
  this._fov = 45;
1189
1189
  this._frustumCulling = true;
1190
1190
  this._gamma = 'srgb';
1191
+ this._horizontalFov = false;
1191
1192
  this._nearClip = 0.1;
1192
1193
  this._orthographic = false;
1193
1194
  this._orthoHeight = 10;
@@ -1208,6 +1209,7 @@ class CameraComponentElement extends ComponentElement {
1208
1209
  fov: this._fov,
1209
1210
  frustumCulling: this._frustumCulling,
1210
1211
  gammaCorrection: this._gamma === 'srgb' ? GAMMA_SRGB : GAMMA_NONE,
1212
+ horizontalFov: this._horizontalFov,
1211
1213
  nearClip: this._nearClip,
1212
1214
  orthographic: this._orthographic,
1213
1215
  orthoHeight: this._orthoHeight,
@@ -1219,7 +1221,7 @@ class CameraComponentElement extends ComponentElement {
1219
1221
  }
1220
1222
  get xrAvailable() {
1221
1223
  var _a;
1222
- const xrManager = (_a = this.component) === null || _a === void 0 ? void 0 : _a.system.app.xr;
1224
+ const xrManager = (_a = this.component) === null || _a === undefined ? undefined : _a.system.app.xr;
1223
1225
  return xrManager && xrManager.supported && xrManager.isAvailable(XRTYPE_VR);
1224
1226
  }
1225
1227
  startXr(type, space) {
@@ -1414,6 +1416,24 @@ class CameraComponentElement extends ComponentElement {
1414
1416
  get gamma() {
1415
1417
  return this._gamma;
1416
1418
  }
1419
+ /**
1420
+ * Sets whether the camera's field of view (fov) is horizontal or vertical. Defaults to false
1421
+ * (meaning it is vertical be default).
1422
+ * @param value - Whether the camera's field of view is horizontal.
1423
+ */
1424
+ set horizontalFov(value) {
1425
+ this._horizontalFov = value;
1426
+ if (this.component) {
1427
+ this.component.horizontalFov = value;
1428
+ }
1429
+ }
1430
+ /**
1431
+ * Gets whether the camera's field of view (fov) is horizontal or vertical.
1432
+ * @returns Whether the camera's field of view is horizontal.
1433
+ */
1434
+ get horizontalFov() {
1435
+ return this._horizontalFov;
1436
+ }
1417
1437
  /**
1418
1438
  * Sets the near clip distance of the camera.
1419
1439
  * @param value - The near clip distance.
@@ -1524,7 +1544,7 @@ class CameraComponentElement extends ComponentElement {
1524
1544
  var _a;
1525
1545
  this._tonemap = value;
1526
1546
  if (this.component) {
1527
- this.component.toneMapping = (_a = tonemaps.get(value)) !== null && _a !== void 0 ? _a : TONEMAP_NONE;
1547
+ this.component.toneMapping = (_a = tonemaps.get(value)) !== null && _a !== undefined ? _a : TONEMAP_NONE;
1528
1548
  }
1529
1549
  }
1530
1550
  /**
@@ -1547,6 +1567,7 @@ class CameraComponentElement extends ComponentElement {
1547
1567
  'fov',
1548
1568
  'frustum-culling',
1549
1569
  'gamma',
1570
+ 'horizontal-fov',
1550
1571
  'near-clip',
1551
1572
  'orthographic',
1552
1573
  'ortho-height',
@@ -1589,6 +1610,9 @@ class CameraComponentElement extends ComponentElement {
1589
1610
  case 'gamma':
1590
1611
  this.gamma = newValue;
1591
1612
  break;
1613
+ case 'horizontal-fov':
1614
+ this.horizontalFov = this.hasAttribute('horizontal-fov');
1615
+ break;
1592
1616
  case 'near-clip':
1593
1617
  this.nearClip = parseFloat(newValue);
1594
1618
  break;
@@ -2290,7 +2314,7 @@ class LightComponentElement extends ComponentElement {
2290
2314
  var _a;
2291
2315
  this._shadowType = value;
2292
2316
  if (this.component) {
2293
- this.component.shadowType = (_a = shadowTypes.get(value)) !== null && _a !== void 0 ? _a : SHADOW_PCF3_32F;
2317
+ this.component.shadowType = (_a = shadowTypes.get(value)) !== null && _a !== undefined ? _a : SHADOW_PCF3_32F;
2294
2318
  }
2295
2319
  }
2296
2320
  /**
@@ -2496,7 +2520,7 @@ class MaterialElement extends HTMLElement {
2496
2520
  }
2497
2521
  static get(id) {
2498
2522
  const materialElement = document.querySelector(`pc-material[id="${id}"]`);
2499
- return materialElement === null || materialElement === void 0 ? void 0 : materialElement.material;
2523
+ return materialElement === null || materialElement === undefined ? undefined : materialElement.material;
2500
2524
  }
2501
2525
  static get observedAttributes() {
2502
2526
  return ['diffuse', 'diffuse-map', 'metalness-map', 'normal-map', 'roughness-map'];
@@ -3108,7 +3132,7 @@ class ScriptComponentElement extends ComponentElement {
3108
3132
  disconnectedCallback() {
3109
3133
  var _a;
3110
3134
  this.observer.disconnect();
3111
- (_a = super.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
3135
+ (_a = super.disconnectedCallback) === null || _a === undefined ? undefined : _a.call(this);
3112
3136
  }
3113
3137
  /**
3114
3138
  * Gets the script component.
@@ -3422,7 +3446,7 @@ class SoundSlotElement extends AsyncElement {
3422
3446
  }
3423
3447
  async connectedCallback() {
3424
3448
  var _a;
3425
- await ((_a = this.soundElement) === null || _a === void 0 ? void 0 : _a.ready());
3449
+ await ((_a = this.soundElement) === null || _a === undefined ? undefined : _a.ready());
3426
3450
  const options = {
3427
3451
  autoPlay: this._autoPlay,
3428
3452
  loop: this._loop,
@@ -3458,7 +3482,7 @@ class SoundSlotElement extends AsyncElement {
3458
3482
  var _a;
3459
3483
  this._asset = value;
3460
3484
  if (this.soundSlot) {
3461
- const id = (_a = AssetElement.get(value)) === null || _a === void 0 ? void 0 : _a.id;
3485
+ const id = (_a = AssetElement.get(value)) === null || _a === undefined ? undefined : _a.id;
3462
3486
  if (id) {
3463
3487
  this.soundSlot.asset = id;
3464
3488
  }
@@ -3685,8 +3709,8 @@ class ModelElement extends AsyncElement {
3685
3709
  async _loadModel() {
3686
3710
  var _a;
3687
3711
  this._unloadModel();
3688
- const appElement = await ((_a = this.closestApp) === null || _a === void 0 ? void 0 : _a.ready());
3689
- const app = appElement === null || appElement === void 0 ? void 0 : appElement.app;
3712
+ const appElement = await ((_a = this.closestApp) === null || _a === undefined ? undefined : _a.ready());
3713
+ const app = appElement === null || appElement === undefined ? undefined : appElement.app;
3690
3714
  const asset = AssetElement.get(this._asset);
3691
3715
  if (!asset) {
3692
3716
  return;
@@ -3703,7 +3727,7 @@ class ModelElement extends AsyncElement {
3703
3727
  }
3704
3728
  _unloadModel() {
3705
3729
  var _a;
3706
- (_a = this._entity) === null || _a === void 0 ? void 0 : _a.destroy();
3730
+ (_a = this._entity) === null || _a === undefined ? undefined : _a.destroy();
3707
3731
  this._entity = null;
3708
3732
  }
3709
3733
  /**
@@ -3771,7 +3795,7 @@ class SceneElement extends AsyncElement {
3771
3795
  }
3772
3796
  async connectedCallback() {
3773
3797
  var _a;
3774
- await ((_a = this.closestApp) === null || _a === void 0 ? void 0 : _a.ready());
3798
+ await ((_a = this.closestApp) === null || _a === undefined ? undefined : _a.ready());
3775
3799
  this.scene = this.closestApp.app.scene;
3776
3800
  this.updateSceneSettings();
3777
3801
  this._onReady();
@@ -3945,8 +3969,8 @@ class SkyElement extends AsyncElement {
3945
3969
  }
3946
3970
  async _loadSkybox() {
3947
3971
  var _a;
3948
- const appElement = await ((_a = this.closestApp) === null || _a === void 0 ? void 0 : _a.ready());
3949
- const app = appElement === null || appElement === void 0 ? void 0 : appElement.app;
3972
+ const appElement = await ((_a = this.closestApp) === null || _a === undefined ? undefined : _a.ready());
3973
+ const app = appElement === null || appElement === undefined ? undefined : appElement.app;
3950
3974
  if (!app) {
3951
3975
  return;
3952
3976
  }
@@ -3969,10 +3993,10 @@ class SkyElement extends AsyncElement {
3969
3993
  var _a, _b;
3970
3994
  if (!this._scene)
3971
3995
  return;
3972
- (_a = this._scene.skybox) === null || _a === void 0 ? void 0 : _a.destroy();
3996
+ (_a = this._scene.skybox) === null || _a === undefined ? undefined : _a.destroy();
3973
3997
  // @ts-ignore
3974
3998
  this._scene.skybox = null;
3975
- (_b = this._scene.envAtlas) === null || _b === void 0 ? void 0 : _b.destroy();
3999
+ (_b = this._scene.envAtlas) === null || _b === undefined ? undefined : _b.destroy();
3976
4000
  // @ts-ignore
3977
4001
  this._scene.envAtlas = null;
3978
4002
  this._scene = null;