From cecc15939bc8692111786b28d7d7e0c44eae8304 Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Sun, 5 Jan 2020 12:43:26 +0100 Subject: [PATCH] Examples: Avoid creating instances of LightShadow. --- examples/webgl_geometry_spline_editor.html | 4 +++- examples/webgl_shading_physical.html | 24 ++++++++-------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/examples/webgl_geometry_spline_editor.html b/examples/webgl_geometry_spline_editor.html index b4f9561d184a39..455950d33201d7 100644 --- a/examples/webgl_geometry_spline_editor.html +++ b/examples/webgl_geometry_spline_editor.html @@ -87,8 +87,10 @@ scene.add( new THREE.AmbientLight( 0xf0f0f0 ) ); var light = new THREE.SpotLight( 0xffffff, 1.5 ); light.position.set( 0, 1500, 200 ); + light.angle = Math.PI * 0.2; light.castShadow = true; - light.shadow = new THREE.LightShadow( new THREE.PerspectiveCamera( 70, 1, 200, 2000 ) ); + light.shadow.camera.near = 200; + light.shadow.camera.far = 2000; light.shadow.bias = - 0.000222; light.shadow.mapSize.width = 1024; light.shadow.mapSize.height = 1024; diff --git a/examples/webgl_shading_physical.html b/examples/webgl_shading_physical.html index 4ab62f759560ee..8d62f17fd60990 100644 --- a/examples/webgl_shading_physical.html +++ b/examples/webgl_shading_physical.html @@ -43,7 +43,6 @@ shadowCameraVisible: false, shadowCameraNear: 750, shadowCameraFar: 4000, - shadowCameraFov: 30, shadowBias: - 0.0002 }; @@ -191,9 +190,6 @@ var s = 200; mesh.scale.set( s, s, s ); - //morph.duration = 8000; - //morph.mirroredLoop = true; - mesh.castShadow = true; mesh.receiveShadow = true; @@ -209,12 +205,16 @@ pointLight = new THREE.PointLight( 0xffaa00, 1, 5000 ); scene.add( pointLight ); - sunLight = new THREE.SpotLight( 0xffffff, 0.3, 0, Math.PI / 2 ); + sunLight = new THREE.DirectionalLight( 0xffffff, 0.3 ); sunLight.position.set( 1000, 2000, 1000 ); - sunLight.castShadow = true; - - sunLight.shadow = new THREE.LightShadow( new THREE.PerspectiveCamera( shadowConfig.shadowCameraFov, 1, shadowConfig.shadowCameraNear, shadowConfig.shadowCameraFar ) ); + sunLight.shadow.camera.top = 750; + sunLight.shadow.camera.bottom = - 750; + sunLight.shadow.camera.left = - 750; + sunLight.shadow.camera.right = 750; + sunLight.shadow.camera.near = shadowConfig.shadowCameraNear; + sunLight.shadow.camera.far = shadowConfig.shadowCameraFar; + sunLight.shadow.mapSize.set( 1024, 1024 ); sunLight.shadow.bias = shadowConfig.shadowBias; scene.add( sunLight ); @@ -291,14 +291,6 @@ } ); - shadowGUI.add( shadowConfig, 'shadowCameraFov', 1, 120 ).onChange( function () { - - sunLight.shadow.camera.fov = shadowConfig.shadowCameraFov; - sunLight.shadow.camera.updateProjectionMatrix(); - shadowCameraHelper.update(); - - } ); - shadowGUI.add( shadowConfig, 'shadowBias', - 0.01, 0.01 ).onChange( function () { sunLight.shadow.bias = shadowConfig.shadowBias;