@playcanvas/web-components 0.2.5 → 0.2.6

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/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![License](https://img.shields.io/npm/l/@playcanvas/web-components.svg)](https://github.com/playcanvas/web-components/blob/main/LICENSE)
6
6
  [![GitHub Actions Build Status](https://github.com/playcanvas/web-components/actions/workflows/deploy.yml/badge.svg)](https://github.com/playcanvas/web-components/actions/workflows/deploy.yml)
7
7
 
8
- | [User Guide](https://developer.playcanvas.com/user-manual/engine/web-components) | [API Reference](https://api.playcanvas.com/modules/EngineWebComponents.html) | [Examples](https://playcanvas.github.io/web-components/examples) | [Blog](https://blog.playcanvas.com/) | [Forum](https://forum.playcanvas.com/) | [Discord](https://discord.gg/RSaMRzg) |
8
+ | [User Guide](https://developer.playcanvas.com/user-manual/engine/web-components) | [API Reference](https://api.playcanvas.com/web-components/) | [Examples](https://playcanvas.github.io/web-components/examples) | [Blog](https://blog.playcanvas.com/) | [Forum](https://forum.playcanvas.com/) | [Discord](https://discord.gg/RSaMRzg) |
9
9
 
10
10
  PlayCanvas Web Components are a set of custom HTML elements for building 3D interactive web apps. Using the declarative nature of HTML makes it both easy and fun to incorporate 3D into your website. Check out this simple example:
11
11
 
@@ -39,7 +39,7 @@ declare class CameraComponentElement extends ComponentElement {
39
39
  flipFaces: boolean;
40
40
  fov: number;
41
41
  frustumCulling: boolean;
42
- gammaCorrection: number;
42
+ gammaCorrection: 0 | 1;
43
43
  horizontalFov: boolean;
44
44
  nearClip: number;
45
45
  orthographic: boolean;
@@ -47,7 +47,7 @@ declare class CameraComponentElement extends ComponentElement {
47
47
  priority: number;
48
48
  rect: Vec4;
49
49
  scissorRect: Vec4;
50
- toneMapping: number | undefined;
50
+ toneMapping: 0 | 2 | 1 | 3 | 4 | 5 | 6 | undefined;
51
51
  };
52
52
  get xrAvailable(): boolean | null | undefined;
53
53
  /**
@@ -38,7 +38,7 @@ declare class LightComponentElement extends ComponentElement {
38
38
  shadowDistance: number;
39
39
  shadowIntensity: number;
40
40
  shadowResolution: number;
41
- shadowType: number | undefined;
41
+ shadowType: 0 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined;
42
42
  type: string;
43
43
  vsmBias: number;
44
44
  vsmBlurSize: number;
@@ -22,7 +22,7 @@ declare class ScreenComponentElement extends ComponentElement {
22
22
  referenceResolution: Vec2;
23
23
  resolution: Vec2;
24
24
  scaleBlend: number;
25
- scaleMode: string;
25
+ scaleMode: "none" | "blend";
26
26
  screenSpace: boolean;
27
27
  };
28
28
  /**
@@ -10,10 +10,12 @@ import { ComponentElement } from './component';
10
10
  */
11
11
  declare class SplatComponentElement extends ComponentElement {
12
12
  private _asset;
13
+ private _castShadows;
13
14
  /** @ignore */
14
15
  constructor();
15
16
  getInitialComponentData(): {
16
17
  asset: import("playcanvas").Asset | null | undefined;
18
+ castShadows: boolean;
17
19
  };
18
20
  /**
19
21
  * Gets the underlying PlayCanvas splat component.
@@ -30,6 +32,16 @@ declare class SplatComponentElement extends ComponentElement {
30
32
  * @returns The asset ID.
31
33
  */
32
34
  get asset(): string;
35
+ /**
36
+ * Sets whether the splat casts shadows.
37
+ * @param value - Whether the splat casts shadows.
38
+ */
39
+ set castShadows(value: boolean);
40
+ /**
41
+ * Gets whether the splat casts shadows.
42
+ * @returns Whether the splat casts shadows.
43
+ */
44
+ get castShadows(): boolean;
33
45
  static get observedAttributes(): string[];
34
46
  attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
35
47
  }
package/dist/pwc.cjs CHANGED
@@ -52,22 +52,15 @@ class ModuleElement extends HTMLElement {
52
52
  }
53
53
  async loadModule() {
54
54
  const name = this.getAttribute('name');
55
- const glue = this.getAttribute('glue');
56
- const wasm = this.getAttribute('wasm');
57
- const fallback = this.getAttribute('fallback');
55
+ const glueUrl = this.getAttribute('glue');
56
+ const wasmUrl = this.getAttribute('wasm');
57
+ const fallbackUrl = this.getAttribute('fallback');
58
+ const config = { glueUrl, wasmUrl, fallbackUrl };
58
59
  if (name === 'Basis') {
59
- playcanvas.basisInitialize({
60
- glueUrl: glue,
61
- wasmUrl: wasm,
62
- fallbackUrl: fallback
63
- });
60
+ playcanvas.basisInitialize(config);
64
61
  }
65
62
  else {
66
- playcanvas.WasmModule.setConfig(name, {
67
- glueUrl: glue,
68
- wasmUrl: wasm,
69
- fallbackUrl: fallback
70
- });
63
+ playcanvas.WasmModule.setConfig(name, config);
71
64
  await new Promise((resolve) => {
72
65
  playcanvas.WasmModule.getInstance(name, () => resolve());
73
66
  });
@@ -1241,6 +1234,7 @@ class AssetElement extends HTMLElement {
1241
1234
  });
1242
1235
  }
1243
1236
  else {
1237
+ // @ts-ignore
1244
1238
  this.asset = new playcanvas.Asset(id, type, { url: src });
1245
1239
  }
1246
1240
  this.asset.preload = !this._lazy;
@@ -4174,10 +4168,12 @@ class SplatComponentElement extends ComponentElement {
4174
4168
  constructor() {
4175
4169
  super('gsplat');
4176
4170
  this._asset = '';
4171
+ this._castShadows = false;
4177
4172
  }
4178
4173
  getInitialComponentData() {
4179
4174
  return {
4180
- asset: AssetElement.get(this._asset)
4175
+ asset: AssetElement.get(this._asset),
4176
+ castShadows: this._castShadows
4181
4177
  };
4182
4178
  }
4183
4179
  /**
@@ -4205,8 +4201,29 @@ class SplatComponentElement extends ComponentElement {
4205
4201
  get asset() {
4206
4202
  return this._asset;
4207
4203
  }
4204
+ /**
4205
+ * Sets whether the splat casts shadows.
4206
+ * @param value - Whether the splat casts shadows.
4207
+ */
4208
+ set castShadows(value) {
4209
+ this._castShadows = value;
4210
+ if (this.component) {
4211
+ this.component.castShadows = value;
4212
+ }
4213
+ }
4214
+ /**
4215
+ * Gets whether the splat casts shadows.
4216
+ * @returns Whether the splat casts shadows.
4217
+ */
4218
+ get castShadows() {
4219
+ return this._castShadows;
4220
+ }
4208
4221
  static get observedAttributes() {
4209
- return [...super.observedAttributes, 'asset'];
4222
+ return [
4223
+ ...super.observedAttributes,
4224
+ 'asset',
4225
+ 'cast-shadows'
4226
+ ];
4210
4227
  }
4211
4228
  attributeChangedCallback(name, _oldValue, newValue) {
4212
4229
  super.attributeChangedCallback(name, _oldValue, newValue);
@@ -4214,6 +4231,9 @@ class SplatComponentElement extends ComponentElement {
4214
4231
  case 'asset':
4215
4232
  this.asset = newValue;
4216
4233
  break;
4234
+ case 'cast-shadows':
4235
+ this.castShadows = this.hasAttribute('cast-shadows');
4236
+ break;
4217
4237
  }
4218
4238
  }
4219
4239
  }