@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.js CHANGED
@@ -17,11 +17,11 @@
17
17
  }
18
18
  get closestApp() {
19
19
  var _a;
20
- return (_a = this.parentElement) === null || _a === void 0 ? void 0 : _a.closest('pc-app');
20
+ return (_a = this.parentElement) === null || _a === undefined ? undefined : _a.closest('pc-app');
21
21
  }
22
22
  get closestEntity() {
23
23
  var _a;
24
- return (_a = this.parentElement) === null || _a === void 0 ? void 0 : _a.closest('pc-entity');
24
+ return (_a = this.parentElement) === null || _a === undefined ? undefined : _a.closest('pc-entity');
25
25
  }
26
26
  /**
27
27
  * Called when the element is fully initialized and ready.
@@ -744,7 +744,7 @@
744
744
  if (!this.entity)
745
745
  return;
746
746
  const closestEntity = this.closestEntity;
747
- if (closestEntity === null || closestEntity === void 0 ? void 0 : closestEntity.entity) {
747
+ if (closestEntity === null || closestEntity === undefined ? undefined : closestEntity.entity) {
748
748
  closestEntity.entity.addChild(this.entity);
749
749
  }
750
750
  else {
@@ -966,7 +966,7 @@
966
966
  }
967
967
  hasListeners(type) {
968
968
  var _a;
969
- return Boolean((_a = this._listeners[type]) === null || _a === void 0 ? void 0 : _a.length);
969
+ return Boolean((_a = this._listeners[type]) === null || _a === undefined ? undefined : _a.length);
970
970
  }
971
971
  }
972
972
  customElements.define('pc-entity', EntityElement);
@@ -1015,7 +1015,7 @@
1015
1015
  // If no type is specified, try to infer it from the file extension.
1016
1016
  if (!type) {
1017
1017
  const ext = src.split('.').pop();
1018
- type = (_a = extToType.get(ext || '')) !== null && _a !== void 0 ? _a : null;
1018
+ type = (_a = extToType.get(ext || '')) !== null && _a !== undefined ? _a : null;
1019
1019
  }
1020
1020
  if (!type) {
1021
1021
  console.warn(`Unsupported asset type: ${src}`);
@@ -1049,7 +1049,7 @@
1049
1049
  }
1050
1050
  static get(id) {
1051
1051
  const assetElement = document.querySelector(`pc-asset[id="${id}"]`);
1052
- return assetElement === null || assetElement === void 0 ? void 0 : assetElement.asset;
1052
+ return assetElement === null || assetElement === undefined ? undefined : assetElement.asset;
1053
1053
  }
1054
1054
  static get observedAttributes() {
1055
1055
  return ['preload'];
@@ -1096,7 +1096,7 @@
1096
1096
  initComponent() { }
1097
1097
  async connectedCallback() {
1098
1098
  var _a;
1099
- await ((_a = this.closestApp) === null || _a === void 0 ? void 0 : _a.ready());
1099
+ await ((_a = this.closestApp) === null || _a === undefined ? undefined : _a.ready());
1100
1100
  await this.addComponent();
1101
1101
  this.initComponent();
1102
1102
  this._onReady();
@@ -1192,6 +1192,7 @@
1192
1192
  this._fov = 45;
1193
1193
  this._frustumCulling = true;
1194
1194
  this._gamma = 'srgb';
1195
+ this._horizontalFov = false;
1195
1196
  this._nearClip = 0.1;
1196
1197
  this._orthographic = false;
1197
1198
  this._orthoHeight = 10;
@@ -1212,6 +1213,7 @@
1212
1213
  fov: this._fov,
1213
1214
  frustumCulling: this._frustumCulling,
1214
1215
  gammaCorrection: this._gamma === 'srgb' ? playcanvas.GAMMA_SRGB : playcanvas.GAMMA_NONE,
1216
+ horizontalFov: this._horizontalFov,
1215
1217
  nearClip: this._nearClip,
1216
1218
  orthographic: this._orthographic,
1217
1219
  orthoHeight: this._orthoHeight,
@@ -1223,7 +1225,7 @@
1223
1225
  }
1224
1226
  get xrAvailable() {
1225
1227
  var _a;
1226
- const xrManager = (_a = this.component) === null || _a === void 0 ? void 0 : _a.system.app.xr;
1228
+ const xrManager = (_a = this.component) === null || _a === undefined ? undefined : _a.system.app.xr;
1227
1229
  return xrManager && xrManager.supported && xrManager.isAvailable(playcanvas.XRTYPE_VR);
1228
1230
  }
1229
1231
  startXr(type, space) {
@@ -1418,6 +1420,24 @@
1418
1420
  get gamma() {
1419
1421
  return this._gamma;
1420
1422
  }
1423
+ /**
1424
+ * Sets whether the camera's field of view (fov) is horizontal or vertical. Defaults to false
1425
+ * (meaning it is vertical be default).
1426
+ * @param value - Whether the camera's field of view is horizontal.
1427
+ */
1428
+ set horizontalFov(value) {
1429
+ this._horizontalFov = value;
1430
+ if (this.component) {
1431
+ this.component.horizontalFov = value;
1432
+ }
1433
+ }
1434
+ /**
1435
+ * Gets whether the camera's field of view (fov) is horizontal or vertical.
1436
+ * @returns Whether the camera's field of view is horizontal.
1437
+ */
1438
+ get horizontalFov() {
1439
+ return this._horizontalFov;
1440
+ }
1421
1441
  /**
1422
1442
  * Sets the near clip distance of the camera.
1423
1443
  * @param value - The near clip distance.
@@ -1528,7 +1548,7 @@
1528
1548
  var _a;
1529
1549
  this._tonemap = value;
1530
1550
  if (this.component) {
1531
- this.component.toneMapping = (_a = tonemaps.get(value)) !== null && _a !== void 0 ? _a : playcanvas.TONEMAP_NONE;
1551
+ this.component.toneMapping = (_a = tonemaps.get(value)) !== null && _a !== undefined ? _a : playcanvas.TONEMAP_NONE;
1532
1552
  }
1533
1553
  }
1534
1554
  /**
@@ -1551,6 +1571,7 @@
1551
1571
  'fov',
1552
1572
  'frustum-culling',
1553
1573
  'gamma',
1574
+ 'horizontal-fov',
1554
1575
  'near-clip',
1555
1576
  'orthographic',
1556
1577
  'ortho-height',
@@ -1593,6 +1614,9 @@
1593
1614
  case 'gamma':
1594
1615
  this.gamma = newValue;
1595
1616
  break;
1617
+ case 'horizontal-fov':
1618
+ this.horizontalFov = this.hasAttribute('horizontal-fov');
1619
+ break;
1596
1620
  case 'near-clip':
1597
1621
  this.nearClip = parseFloat(newValue);
1598
1622
  break;
@@ -2294,7 +2318,7 @@
2294
2318
  var _a;
2295
2319
  this._shadowType = value;
2296
2320
  if (this.component) {
2297
- this.component.shadowType = (_a = shadowTypes.get(value)) !== null && _a !== void 0 ? _a : playcanvas.SHADOW_PCF3_32F;
2321
+ this.component.shadowType = (_a = shadowTypes.get(value)) !== null && _a !== undefined ? _a : playcanvas.SHADOW_PCF3_32F;
2298
2322
  }
2299
2323
  }
2300
2324
  /**
@@ -2500,7 +2524,7 @@
2500
2524
  }
2501
2525
  static get(id) {
2502
2526
  const materialElement = document.querySelector(`pc-material[id="${id}"]`);
2503
- return materialElement === null || materialElement === void 0 ? void 0 : materialElement.material;
2527
+ return materialElement === null || materialElement === undefined ? undefined : materialElement.material;
2504
2528
  }
2505
2529
  static get observedAttributes() {
2506
2530
  return ['diffuse', 'diffuse-map', 'metalness-map', 'normal-map', 'roughness-map'];
@@ -3112,7 +3136,7 @@
3112
3136
  disconnectedCallback() {
3113
3137
  var _a;
3114
3138
  this.observer.disconnect();
3115
- (_a = super.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
3139
+ (_a = super.disconnectedCallback) === null || _a === undefined ? undefined : _a.call(this);
3116
3140
  }
3117
3141
  /**
3118
3142
  * Gets the script component.
@@ -3426,7 +3450,7 @@
3426
3450
  }
3427
3451
  async connectedCallback() {
3428
3452
  var _a;
3429
- await ((_a = this.soundElement) === null || _a === void 0 ? void 0 : _a.ready());
3453
+ await ((_a = this.soundElement) === null || _a === undefined ? undefined : _a.ready());
3430
3454
  const options = {
3431
3455
  autoPlay: this._autoPlay,
3432
3456
  loop: this._loop,
@@ -3462,7 +3486,7 @@
3462
3486
  var _a;
3463
3487
  this._asset = value;
3464
3488
  if (this.soundSlot) {
3465
- const id = (_a = AssetElement.get(value)) === null || _a === void 0 ? void 0 : _a.id;
3489
+ const id = (_a = AssetElement.get(value)) === null || _a === undefined ? undefined : _a.id;
3466
3490
  if (id) {
3467
3491
  this.soundSlot.asset = id;
3468
3492
  }
@@ -3689,8 +3713,8 @@
3689
3713
  async _loadModel() {
3690
3714
  var _a;
3691
3715
  this._unloadModel();
3692
- const appElement = await ((_a = this.closestApp) === null || _a === void 0 ? void 0 : _a.ready());
3693
- const app = appElement === null || appElement === void 0 ? void 0 : appElement.app;
3716
+ const appElement = await ((_a = this.closestApp) === null || _a === undefined ? undefined : _a.ready());
3717
+ const app = appElement === null || appElement === undefined ? undefined : appElement.app;
3694
3718
  const asset = AssetElement.get(this._asset);
3695
3719
  if (!asset) {
3696
3720
  return;
@@ -3707,7 +3731,7 @@
3707
3731
  }
3708
3732
  _unloadModel() {
3709
3733
  var _a;
3710
- (_a = this._entity) === null || _a === void 0 ? void 0 : _a.destroy();
3734
+ (_a = this._entity) === null || _a === undefined ? undefined : _a.destroy();
3711
3735
  this._entity = null;
3712
3736
  }
3713
3737
  /**
@@ -3775,7 +3799,7 @@
3775
3799
  }
3776
3800
  async connectedCallback() {
3777
3801
  var _a;
3778
- await ((_a = this.closestApp) === null || _a === void 0 ? void 0 : _a.ready());
3802
+ await ((_a = this.closestApp) === null || _a === undefined ? undefined : _a.ready());
3779
3803
  this.scene = this.closestApp.app.scene;
3780
3804
  this.updateSceneSettings();
3781
3805
  this._onReady();
@@ -3949,8 +3973,8 @@
3949
3973
  }
3950
3974
  async _loadSkybox() {
3951
3975
  var _a;
3952
- const appElement = await ((_a = this.closestApp) === null || _a === void 0 ? void 0 : _a.ready());
3953
- const app = appElement === null || appElement === void 0 ? void 0 : appElement.app;
3976
+ const appElement = await ((_a = this.closestApp) === null || _a === undefined ? undefined : _a.ready());
3977
+ const app = appElement === null || appElement === undefined ? undefined : appElement.app;
3954
3978
  if (!app) {
3955
3979
  return;
3956
3980
  }
@@ -3973,10 +3997,10 @@
3973
3997
  var _a, _b;
3974
3998
  if (!this._scene)
3975
3999
  return;
3976
- (_a = this._scene.skybox) === null || _a === void 0 ? void 0 : _a.destroy();
4000
+ (_a = this._scene.skybox) === null || _a === undefined ? undefined : _a.destroy();
3977
4001
  // @ts-ignore
3978
4002
  this._scene.skybox = null;
3979
- (_b = this._scene.envAtlas) === null || _b === void 0 ? void 0 : _b.destroy();
4003
+ (_b = this._scene.envAtlas) === null || _b === undefined ? undefined : _b.destroy();
3980
4004
  // @ts-ignore
3981
4005
  this._scene.envAtlas = null;
3982
4006
  this._scene = null;