Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions examples/animation.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<pc-asset src="../node_modules/playcanvas/scripts/esm/camera-controls.mjs"></pc-asset>
<pc-asset src="../node_modules/playcanvas/scripts/esm/xr-controllers.mjs"></pc-asset>
<pc-asset src="../node_modules/playcanvas/scripts/esm/xr-navigation.mjs"></pc-asset>
<pc-asset src="assets/scripts/shadow-catcher.mjs"></pc-asset>
<pc-asset src="../node_modules/playcanvas/scripts/esm/shadow-catcher.mjs"></pc-asset>
<pc-asset src="assets/skies/dry-lake-bed-2k.hdr" id="lake-bed"></pc-asset>
<pc-asset src="assets/models/t-rex.glb" id="t-rex"></pc-asset>
<!-- Scene -->
Expand All @@ -46,12 +46,19 @@
<pc-script name="xrNavigation"></pc-script>
</pc-scripts>
</pc-entity>
<!-- Light -->
<pc-entity name="light">
<pc-light cast-shadows shadow-distance="30" shadow-intensity="0.6" shadow-resolution="1024" shadow-type="vsm-16f"></pc-light>
</pc-entity>
<!-- T-Rex -->
<pc-entity name="t-rex" scale="3 3 3">
<pc-model asset="t-rex"></pc-model>
</pc-entity>
<!-- Shadow Catcher -->
<pc-entity name="shadow catcher">
<pc-scripts>
<pc-script name="shadowCatcher" attributes='{
"size": "vec2:14,14"
"scale": "vec3:14,14,14"
}'></pc-script>
</pc-scripts>
</pc-entity>
Expand Down
19 changes: 13 additions & 6 deletions examples/annotations.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<pc-asset src="../node_modules/playcanvas/scripts/esm/camera-controls.mjs"></pc-asset>
<pc-asset src="../node_modules/playcanvas/scripts/esm/xr-controllers.mjs"></pc-asset>
<pc-asset src="../node_modules/playcanvas/scripts/esm/xr-navigation.mjs"></pc-asset>
<pc-asset src="../node_modules/playcanvas/scripts/esm/shadow-catcher.mjs"></pc-asset>
<pc-asset src="assets/scripts/annotation.mjs"></pc-asset>
<pc-asset src="assets/scripts/shadow-catcher.mjs"></pc-asset>
<pc-asset src="assets/skies/shanghai-riverside-4k.hdr" id="shanghai"></pc-asset>
<pc-asset src="assets/models/jet-fighter.glb" id="jet-fighter"></pc-asset>
<!-- Scene -->
Expand All @@ -48,14 +48,13 @@
<pc-script name="xrNavigation"></pc-script>
</pc-scripts>
</pc-entity>
<!-- Light -->
<pc-entity name="light">
<pc-light cast-shadows shadow-distance="30" shadow-intensity="0.6" shadow-resolution="1024" shadow-type="vsm-16f"></pc-light>
</pc-entity>
<!-- Jet Fighter -->
<pc-entity name="jet-fighter" position="-2 1.6 0" rotation="0 0 3">
<pc-model asset="jet-fighter"></pc-model>
<pc-scripts>
<pc-script name="shadowCatcher" attributes='{
"size": "vec2:14,14"
}'></pc-script>
</pc-scripts>
<pc-entity name="annotation1" position="5.5 1.2 0">
<pc-scripts>
<pc-script name="annotation" attributes='{
Expand Down Expand Up @@ -113,6 +112,14 @@
</pc-scripts>
</pc-entity>
</pc-entity>
<!-- Shadow Catcher -->
<pc-entity name="shadow catcher">
<pc-scripts>
<pc-script name="shadowCatcher" attributes='{
"scale": "vec3:15,15,15"
}'></pc-script>
</pc-scripts>
</pc-entity>
</pc-scene>
</pc-app>
<script type="module" src="js/example.mjs"></script>
Expand Down
105 changes: 0 additions & 105 deletions examples/assets/scripts/shadow-catcher.mjs

This file was deleted.

12 changes: 9 additions & 3 deletions examples/shoe-configurator.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<pc-asset src="../node_modules/playcanvas/scripts/esm/camera-controls.mjs"></pc-asset>
<pc-asset src="../node_modules/playcanvas/scripts/esm/xr-controllers.mjs"></pc-asset>
<pc-asset src="../node_modules/playcanvas/scripts/esm/xr-navigation.mjs"></pc-asset>
<pc-asset src="assets/scripts/shadow-catcher.mjs"></pc-asset>
<pc-asset src="../node_modules/playcanvas/scripts/esm/shadow-catcher.mjs"></pc-asset>
<pc-asset src="assets/skies/octagon-lamps-photo-studio-2k.hdr" id="studio"></pc-asset>
<pc-asset src="assets/models/shoe.glb" id="shoe"></pc-asset>
<!-- Scene -->
Expand All @@ -47,13 +47,19 @@
<pc-script name="xrNavigation"></pc-script>
</pc-scripts>
</pc-entity>
<!-- Light -->
<pc-entity name="light">
<pc-light type="directional" cast-shadows shadow-distance="1" shadow-intensity="0.6" shadow-resolution="1024" shadow-type="vsm-16f"></pc-light>
</pc-entity>
<!-- Shoe -->
<pc-entity name="shoe">
<pc-model asset="shoe"></pc-model>
</pc-entity>
<!-- Shadow Catcher -->
<pc-entity name="shadow catcher">
<pc-scripts>
<pc-script name="shadowCatcher" attributes='{
"size": "vec2:0.5,0.5",
"shadowDistance": 1
"scale": "vec3:0.5,0.5,0.5"
}'></pc-script>
</pc-scripts>
</pc-entity>
Expand Down
17 changes: 10 additions & 7 deletions examples/video-texture.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<pc-asset src="../node_modules/playcanvas/scripts/esm/camera-controls.mjs"></pc-asset>
<pc-asset src="../node_modules/playcanvas/scripts/esm/xr-controllers.mjs"></pc-asset>
<pc-asset src="../node_modules/playcanvas/scripts/esm/xr-navigation.mjs"></pc-asset>
<pc-asset src="assets/scripts/shadow-catcher.mjs"></pc-asset>
<pc-asset src="../node_modules/playcanvas/scripts/esm/shadow-catcher.mjs"></pc-asset>
<pc-asset src="assets/scripts/video-texture.mjs"></pc-asset>
<pc-asset src="assets/skies/octagon-lamps-photo-studio-2k.hdr" id="studio"></pc-asset>
<pc-asset src="assets/models/vintage-pc.glb" id="vintage-pc"></pc-asset>
Expand Down Expand Up @@ -54,23 +54,26 @@
</pc-entity>
<!-- Light -->
<pc-entity name="light" rotation="45 -35 0">
<pc-light cast-shadows shadow-distance="5"></pc-light>
<pc-light cast-shadows shadow-distance="5" shadow-intensity="0.4" shadow-resolution="1024" shadow-type="vsm-16f" vsm-blur-size="16"></pc-light>
</pc-entity>
<!-- PC -->
<pc-entity name="pc">
<pc-model asset="vintage-pc"></pc-model>
<pc-scripts>
<pc-script name="shadowCatcher" attributes='{
"size": "vec2:3,3",
"shadowDistance": 4,
"blurSize": 16
}'></pc-script>
<pc-script name="videoTexture" attributes='{
"materialName": "Screen",
"url": "assets/videos/doom.mp4"
}'></pc-script>
</pc-scripts>
</pc-entity>
<!-- Shadow Catcher -->
<pc-entity name="shadow catcher">
<pc-scripts>
<pc-script name="shadowCatcher" attributes='{
"scale": "vec3:2,3,3"
}'></pc-script>
</pc-scripts>
</pc-entity>
</pc-scene>
</pc-app>
<script type="module" src="js/example.mjs"></script>
Expand Down
30 changes: 28 additions & 2 deletions src/components/light-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class LightComponentElement extends ComponentElement {

private _vsmBias = 0.01;

private _vsmBlurSize = 11;

/** @ignore */
constructor() {
super('light');
Expand All @@ -72,7 +74,8 @@ class LightComponentElement extends ComponentElement {
shadowResolution: this._shadowResolution,
shadowType: shadowTypes.get(this._shadowType),
type: this._type,
vsmBias: this._vsmBias
vsmBias: this._vsmBias,
vsmBlurSize: this._vsmBlurSize
};
}

Expand Down Expand Up @@ -365,6 +368,25 @@ class LightComponentElement extends ComponentElement {
return this._vsmBias;
}

/**
* Sets the VSM blur size of the light. Minimum is 1, maximum is 25. Default is 11.
* @param value - The VSM blur size.
*/
set vsmBlurSize(value: number) {
this._vsmBlurSize = value;
if (this.component) {
this.component.vsmBlurSize = value;
}
}

/**
* Gets the VSM blur size of the light.
* @returns The VSM blur size.
*/
get vsmBlurSize() {
return this._vsmBlurSize;
}

static get observedAttributes() {
return [
...super.observedAttributes,
Expand All @@ -381,7 +403,8 @@ class LightComponentElement extends ComponentElement {
'shadow-resolution',
'shadow-type',
'type',
'vsm-bias'
'vsm-bias',
'vsm-blur-size'
];
}

Expand Down Expand Up @@ -431,6 +454,9 @@ class LightComponentElement extends ComponentElement {
case 'vsm-bias':
this.vsmBias = Number(newValue);
break;
case 'vsm-blur-size':
this.vsmBlurSize = Number(newValue);
break;
}
}
}
Expand Down