@playcanvas/web-components 0.2.4 → 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 +1 -1
- package/dist/components/camera-component.d.ts +2 -2
- package/dist/components/light-component.d.ts +13 -1
- package/dist/components/screen-component.d.ts +1 -1
- package/dist/components/splat-component.d.ts +12 -0
- package/dist/pwc.cjs +60 -17
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +60 -17
- package/dist/pwc.js.map +1 -1
- package/dist/pwc.min.js +1 -1
- package/dist/pwc.min.js.map +1 -1
- package/dist/pwc.mjs +60 -17
- package/dist/pwc.mjs.map +1 -1
- package/package.json +11 -11
- package/src/asset.ts +2 -1
- package/src/components/light-component.ts +28 -2
- package/src/components/splat-component.ts +32 -3
- package/src/module.ts +6 -13
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://github.com/playcanvas/web-components/blob/main/LICENSE)
|
|
6
6
|
[](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/
|
|
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:
|
|
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:
|
|
50
|
+
toneMapping: 0 | 2 | 1 | 3 | 4 | 5 | 6 | undefined;
|
|
51
51
|
};
|
|
52
52
|
get xrAvailable(): boolean | null | undefined;
|
|
53
53
|
/**
|
|
@@ -23,6 +23,7 @@ declare class LightComponentElement extends ComponentElement {
|
|
|
23
23
|
private _shadowType;
|
|
24
24
|
private _type;
|
|
25
25
|
private _vsmBias;
|
|
26
|
+
private _vsmBlurSize;
|
|
26
27
|
/** @ignore */
|
|
27
28
|
constructor();
|
|
28
29
|
getInitialComponentData(): {
|
|
@@ -37,9 +38,10 @@ declare class LightComponentElement extends ComponentElement {
|
|
|
37
38
|
shadowDistance: number;
|
|
38
39
|
shadowIntensity: number;
|
|
39
40
|
shadowResolution: number;
|
|
40
|
-
shadowType:
|
|
41
|
+
shadowType: 0 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined;
|
|
41
42
|
type: string;
|
|
42
43
|
vsmBias: number;
|
|
44
|
+
vsmBlurSize: number;
|
|
43
45
|
};
|
|
44
46
|
/**
|
|
45
47
|
* Gets the underlying PlayCanvas light component.
|
|
@@ -196,6 +198,16 @@ declare class LightComponentElement extends ComponentElement {
|
|
|
196
198
|
* @returns The VSM bias.
|
|
197
199
|
*/
|
|
198
200
|
get vsmBias(): number;
|
|
201
|
+
/**
|
|
202
|
+
* Sets the VSM blur size of the light. Minimum is 1, maximum is 25. Default is 11.
|
|
203
|
+
* @param value - The VSM blur size.
|
|
204
|
+
*/
|
|
205
|
+
set vsmBlurSize(value: number);
|
|
206
|
+
/**
|
|
207
|
+
* Gets the VSM blur size of the light.
|
|
208
|
+
* @returns The VSM blur size.
|
|
209
|
+
*/
|
|
210
|
+
get vsmBlurSize(): number;
|
|
199
211
|
static get observedAttributes(): string[];
|
|
200
212
|
attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
|
|
201
213
|
}
|
|
@@ -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
|
|
56
|
-
const
|
|
57
|
-
const
|
|
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;
|
|
@@ -2352,6 +2346,7 @@ class LightComponentElement extends ComponentElement {
|
|
|
2352
2346
|
this._shadowType = 'pcf3-32f';
|
|
2353
2347
|
this._type = 'directional';
|
|
2354
2348
|
this._vsmBias = 0.01;
|
|
2349
|
+
this._vsmBlurSize = 11;
|
|
2355
2350
|
}
|
|
2356
2351
|
getInitialComponentData() {
|
|
2357
2352
|
return {
|
|
@@ -2368,7 +2363,8 @@ class LightComponentElement extends ComponentElement {
|
|
|
2368
2363
|
shadowResolution: this._shadowResolution,
|
|
2369
2364
|
shadowType: shadowTypes.get(this._shadowType),
|
|
2370
2365
|
type: this._type,
|
|
2371
|
-
vsmBias: this._vsmBias
|
|
2366
|
+
vsmBias: this._vsmBias,
|
|
2367
|
+
vsmBlurSize: this._vsmBlurSize
|
|
2372
2368
|
};
|
|
2373
2369
|
}
|
|
2374
2370
|
/**
|
|
@@ -2631,6 +2627,23 @@ class LightComponentElement extends ComponentElement {
|
|
|
2631
2627
|
get vsmBias() {
|
|
2632
2628
|
return this._vsmBias;
|
|
2633
2629
|
}
|
|
2630
|
+
/**
|
|
2631
|
+
* Sets the VSM blur size of the light. Minimum is 1, maximum is 25. Default is 11.
|
|
2632
|
+
* @param value - The VSM blur size.
|
|
2633
|
+
*/
|
|
2634
|
+
set vsmBlurSize(value) {
|
|
2635
|
+
this._vsmBlurSize = value;
|
|
2636
|
+
if (this.component) {
|
|
2637
|
+
this.component.vsmBlurSize = value;
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
/**
|
|
2641
|
+
* Gets the VSM blur size of the light.
|
|
2642
|
+
* @returns The VSM blur size.
|
|
2643
|
+
*/
|
|
2644
|
+
get vsmBlurSize() {
|
|
2645
|
+
return this._vsmBlurSize;
|
|
2646
|
+
}
|
|
2634
2647
|
static get observedAttributes() {
|
|
2635
2648
|
return [
|
|
2636
2649
|
...super.observedAttributes,
|
|
@@ -2647,7 +2660,8 @@ class LightComponentElement extends ComponentElement {
|
|
|
2647
2660
|
'shadow-resolution',
|
|
2648
2661
|
'shadow-type',
|
|
2649
2662
|
'type',
|
|
2650
|
-
'vsm-bias'
|
|
2663
|
+
'vsm-bias',
|
|
2664
|
+
'vsm-blur-size'
|
|
2651
2665
|
];
|
|
2652
2666
|
}
|
|
2653
2667
|
attributeChangedCallback(name, _oldValue, newValue) {
|
|
@@ -2695,6 +2709,9 @@ class LightComponentElement extends ComponentElement {
|
|
|
2695
2709
|
case 'vsm-bias':
|
|
2696
2710
|
this.vsmBias = Number(newValue);
|
|
2697
2711
|
break;
|
|
2712
|
+
case 'vsm-blur-size':
|
|
2713
|
+
this.vsmBlurSize = Number(newValue);
|
|
2714
|
+
break;
|
|
2698
2715
|
}
|
|
2699
2716
|
}
|
|
2700
2717
|
}
|
|
@@ -4151,10 +4168,12 @@ class SplatComponentElement extends ComponentElement {
|
|
|
4151
4168
|
constructor() {
|
|
4152
4169
|
super('gsplat');
|
|
4153
4170
|
this._asset = '';
|
|
4171
|
+
this._castShadows = false;
|
|
4154
4172
|
}
|
|
4155
4173
|
getInitialComponentData() {
|
|
4156
4174
|
return {
|
|
4157
|
-
asset: AssetElement.get(this._asset)
|
|
4175
|
+
asset: AssetElement.get(this._asset),
|
|
4176
|
+
castShadows: this._castShadows
|
|
4158
4177
|
};
|
|
4159
4178
|
}
|
|
4160
4179
|
/**
|
|
@@ -4182,8 +4201,29 @@ class SplatComponentElement extends ComponentElement {
|
|
|
4182
4201
|
get asset() {
|
|
4183
4202
|
return this._asset;
|
|
4184
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
|
+
}
|
|
4185
4221
|
static get observedAttributes() {
|
|
4186
|
-
return [
|
|
4222
|
+
return [
|
|
4223
|
+
...super.observedAttributes,
|
|
4224
|
+
'asset',
|
|
4225
|
+
'cast-shadows'
|
|
4226
|
+
];
|
|
4187
4227
|
}
|
|
4188
4228
|
attributeChangedCallback(name, _oldValue, newValue) {
|
|
4189
4229
|
super.attributeChangedCallback(name, _oldValue, newValue);
|
|
@@ -4191,6 +4231,9 @@ class SplatComponentElement extends ComponentElement {
|
|
|
4191
4231
|
case 'asset':
|
|
4192
4232
|
this.asset = newValue;
|
|
4193
4233
|
break;
|
|
4234
|
+
case 'cast-shadows':
|
|
4235
|
+
this.castShadows = this.hasAttribute('cast-shadows');
|
|
4236
|
+
break;
|
|
4194
4237
|
}
|
|
4195
4238
|
}
|
|
4196
4239
|
}
|