From afcc4aacefae4ecdfc9d2aa6b2c51aecef1c5b46 Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Fri, 26 Mar 2021 15:08:13 +0100 Subject: [PATCH] PointLightShadow: Use PointLight.distance for far value if set. --- examples/webgl_shadowmap_pointlight.html | 2 -- src/lights/PointLightShadow.js | 9 +++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/webgl_shadowmap_pointlight.html b/examples/webgl_shadowmap_pointlight.html index 4545eea509056..cbb37398d2181 100644 --- a/examples/webgl_shadowmap_pointlight.html +++ b/examples/webgl_shadowmap_pointlight.html @@ -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 ); diff --git a/src/lights/PointLightShadow.js b/src/lights/PointLightShadow.js index ee635cb93c6ea..995a0bca050b3 100644 --- a/src/lights/PointLightShadow.js +++ b/src/lights/PointLightShadow.js @@ -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 );