Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PointLightShadow: Use PointLight.distance for far value if set. #21526

Merged
merged 1 commit into from Mar 26, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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