diff --git a/examples/webvr_shadow.html b/examples/webvr_shadow.html index 24928d1945bf715dea7d943ed8ff5cf95ce9857b..56bbbcae63c532d333c221c4abff12cc761a6f3b 100644 --- a/examples/webvr_shadow.html +++ b/examples/webvr_shadow.html @@ -43,18 +43,14 @@ scene = new THREE.Scene(); - var dummy = new THREE.Camera(); - dummy.position.set( 0, 0.5, 3 ); - dummy.lookAt( new THREE.Vector3( 0, 0.5, 0 ) ); - scene.add( dummy ); - camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 0.1, 10 ); - dummy.add( camera ); + scene.add( camera ); var geometry = new THREE.TorusKnotGeometry( 0.4, 0.15, 150, 20 ); var material = new THREE.MeshStandardMaterial( { roughness: 0.01, metalness: 0.2 } ); var mesh = new THREE.Mesh( geometry, material ); mesh.position.y = 0.75; + mesh.position.z = - 2; mesh.castShadow = true; mesh.receiveShadow = true; scene.add( mesh ); @@ -63,28 +59,39 @@ var material = new THREE.MeshStandardMaterial( { roughness: 1.0, metalness: 0.0 } ); var mesh = new THREE.Mesh( geometry, material ); mesh.position.y = - 0.2; + mesh.position.z = - 2; mesh.castShadow = true; mesh.receiveShadow = true; scene.add( mesh ); var light = new THREE.DirectionalLight( 0x8800ff ); - light.position.set( - 1, 1.5, 0.5 ); + light.position.set( - 1, 1.5, - 1.5 ); light.castShadow = true; light.shadow.camera.zoom = 4; scene.add( light ); + light.target.position.set( 0, 0, - 2 ); + scene.add( light.target ); + + var helper = new THREE.CameraHelper( light.shadow.camera ); + // scene.add( helper ); var light = new THREE.DirectionalLight( 0xff0000 ); - light.position.set( 1, 1.5, - 0.5 ); + light.position.set( 1, 1.5, - 2.5 ); light.castShadow = true; light.shadow.camera.zoom = 4; scene.add( light ); + light.target.position.set( 0, 0, - 2 ); + scene.add( light.target ); + + var helper = new THREE.CameraHelper( light.shadow.camera ); + // scene.add( helper ); // mirror = new THREE.Mirror( 1.4, 1.4, { textureWidth: window.innerWidth, textureHeight: window.innerHeight } ); mirror.position.x = 1; mirror.position.y = 0.5; - mirror.position.z = -1; + mirror.position.z = -3; mirror.rotation.y = - Math.PI / 4; scene.add( mirror );