Skip to content

Commit

Permalink
PointLightShadow: Use PointLight.distance for far value if set. (#21526)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 committed Mar 26, 2021
1 parent ad0a4b1 commit b197c7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 0 additions & 2 deletions examples/webgl_shadowmap_pointlight.html
Expand Up @@ -41,8 +41,6 @@

const light = new THREE.PointLight( color, intensity, 20 );
light.castShadow = true;
light.shadow.camera.near = 1;
light.shadow.camera.far = 60;
light.shadow.bias = - 0.005; // reduces self-shadowing on double-sided objects

let geometry = new THREE.SphereGeometry( 0.3, 12, 6 );
Expand Down
9 changes: 9 additions & 0 deletions src/lights/PointLightShadow.js
Expand Up @@ -64,6 +64,15 @@ class PointLightShadow extends LightShadow {
const camera = this.camera;
const shadowMatrix = this.matrix;

const far = light.distance || camera.far;

if ( far !== camera.far ) {

camera.far = far;
camera.updateProjectionMatrix();

}

_lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
camera.position.copy( _lightPositionWorld );

Expand Down

0 comments on commit b197c7f

Please sign in to comment.