diff --git a/docs/api/lights/shadows/SpotLightShadow.html b/docs/api/lights/shadows/SpotLightShadow.html index f09340cbf3bfd1..2f3a4e584ec0fc 100644 --- a/docs/api/lights/shadows/SpotLightShadow.html +++ b/docs/api/lights/shadows/SpotLightShadow.html @@ -79,6 +79,14 @@

[property:Camera camera]

+

[property:Boolean cameraAutoUpdate]

+

+ If set to *true*, the shadow camera will be automatically updated each frame to match the + geometry of the spotLight (a square frustum tightly fitting the cone of the spot light defined + by the [page:.angle angle] and [page:.distance distance] properties). + The default is *true*. +

+

[property:Boolean isSpotLightShadow]

Used to check whether this or derived classes are spot light shadows. Default is *true*.

diff --git a/examples/webgl_lights_spotlight.html b/examples/webgl_lights_spotlight.html index 6c973a7e69abff..4e8032b6634351 100644 --- a/examples/webgl_lights_spotlight.html +++ b/examples/webgl_lights_spotlight.html @@ -139,6 +139,8 @@ function render() { + spotLight.shadow.update(spotLight); + lightHelper.update(); shadowCameraHelper.update(); @@ -157,7 +159,8 @@ distance: spotLight.distance, angle: spotLight.angle, penumbra: spotLight.penumbra, - decay: spotLight.decay + decay: spotLight.decay, + cameraAutoUpdate: spotLight.shadow.cameraAutoUpdate } gui.addColor( params, 'light color' ).onChange( function ( val ) { @@ -203,6 +206,13 @@ } ); + gui.add( params, 'cameraAutoUpdate').onChange( function ( val ) { + + spotLight.shadow.cameraAutoUpdate = val; + render(); + + } ); + gui.open(); } diff --git a/examples/webgl_shadowmap.html b/examples/webgl_shadowmap.html index b44db405cfb89b..d5864680a9a203 100644 --- a/examples/webgl_shadowmap.html +++ b/examples/webgl_shadowmap.html @@ -112,7 +112,12 @@ light.castShadow = true; - light.shadow = new THREE.LightShadow( new THREE.PerspectiveCamera( 50, 1, 1200, 2500 ) ); + light.shadow.camera.fov = 50; + light.shadow.camera.aspect = 1; + light.shadow.camera.near = 1200; + light.shadow.camera.far = 2500; + light.shadow.cameraAutoUpdate = false; + light.shadow.bias = 0.0001; light.shadow.mapSize.width = SHADOW_MAP_WIDTH; diff --git a/examples/webgl_shadowmap_performance.html b/examples/webgl_shadowmap_performance.html index 1531ef44c6982a..081dd900b93706 100644 --- a/examples/webgl_shadowmap_performance.html +++ b/examples/webgl_shadowmap_performance.html @@ -107,7 +107,11 @@ light.castShadow = true; - light.shadow = new THREE.LightShadow( new THREE.PerspectiveCamera( 50, 1, 700, FAR ) ); + light.shadow.camera.fov = 50; + light.shadow.camera.aspect = 1; + light.shadow.camera.near = 700; + light.shadow.camera.far = FAR; + light.shadow.cameraAutoUpdate = false; light.shadow.bias = 0.0001; diff --git a/src/lights/SpotLightShadow.js b/src/lights/SpotLightShadow.js index 0a80e7b0bc14ad..1b65e8e8c2857a 100644 --- a/src/lights/SpotLightShadow.js +++ b/src/lights/SpotLightShadow.js @@ -9,6 +9,7 @@ import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js'; function SpotLightShadow() { LightShadow.call( this, new PerspectiveCamera( 50, 1, 0.5, 500 ) ); + this.cameraAutoUpdate = true; } @@ -20,6 +21,8 @@ SpotLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype update: function ( light ) { + if ( ! this.cameraAutoUpdate ) return; + var camera = this.camera; var fov = _Math.RAD2DEG * 2 * light.angle;