diff --git a/docs/api/lights/DirectionalLight.html b/docs/api/lights/DirectionalLight.html index 90a2709b27b9bc..90fd5a499dca45 100644 --- a/docs/api/lights/DirectionalLight.html +++ b/docs/api/lights/DirectionalLight.html @@ -21,23 +21,6 @@

[name]

This light can cast shadows - see the [page:DirectionalLightShadow] page for details.

-

A Note about Position, Target and rotation

-

- A common point of confusion for directional lights is that setting the rotation has no effect. - This is because three.js's DirectionalLight is the equivalent to what is often called a 'Target - Direct Light' in other applications.

- - This means that its direction is calculated as pointing - from the light's [page:Object3D.position position] to the [page:.target target]'s position - (as opposed to a 'Free Direct Light' that just has a rotation component).

- - The reason for this is to allow the light to cast shadows - the [page:.shadow shadow] - camera needs a position to calculate shadows from.

- - See the [page:.target target] property below for details on updating the target. -

- -

Example

[example:canvas_morphtargets_horse morphtargets / horse ]
@@ -99,30 +82,34 @@

[property:DirectionalLightShadow shadow]

[property:Object3D target]

- The DirectionalLight points from its [page:.position position] to target.position. The default - position of the target is *(0, 0, 0)*.
- - *Note*: For the target's position to be changed to anything other than the default, - it must be added to the [page:Scene scene] using + If [page:.targeted targeted] is *true*, the DirectionalLight points from its world [page:.position position] + to the world position of its [page:.target target] object, extracted from [page:Object3D.matrixWorld target.matrixWorld]. + This 'Target Direct Light' mode may be used to have the light track a moving object : + +// track an existing object, already added to the scene +light.targeted = true; +light.target = targetObject; + +// or use the default target object +light.targeted = true; +scene.add( light.target ); + + *Note*: The target object mush be added to the [page:Scene scene] to get its + [page:Object3D.matrixWorld matrixWorld] automatically updated each frame.
+ *Note*: The light [page:Object3D.rotation rotation] and [page:Object3D.quaternion quaternion] are + unused when the [page:.targeted targeted] is true.

- - scene.add( light.target ); - -

- This is so that the target's [page:Object3D.matrixWorld matrixWorld] gets automatically - updated each frame.

- It is also possible to set the target to be another object in the scene (anything with a - [page:Object3D.position position] property), like so: -

- - var targetObject = new THREE.Object3D(); - scene.add(targetObject); - light.target = targetObject; - +

[property:Boolean targeted]

- The directionalLight will now track the target object. + If set to *true*, the light direction will track the [page:.target target] world position, otherwise the SpotLight is directed along the positive Z axis of its local + frame ('Free Direct Light' mode) and thus affected by its world rotation.
+ + The default is *false*.
+ + *Note*: In both modes, the [page:.position position] is used by the [page:.shadow shadow] camera + to cast shadows.

diff --git a/docs/api/lights/SpotLight.html b/docs/api/lights/SpotLight.html index 07ebb677f12d99..5d32c38c480c22 100644 --- a/docs/api/lights/SpotLight.html +++ b/docs/api/lights/SpotLight.html @@ -149,32 +149,33 @@

[property:SpotLightShadow shadow]

A [page:SpotLightShadow] used to calculate shadows for this light.

-

[property:Object3D target]

- The Spotlight points from its [page:.position position] to target.position. The default - position of the target is *(0, 0, 0)*.
- - *Note*: For the target's position to be changed to anything other than the default, - it must be added to the [page:Scene scene] using - - scene.add( light.target ); - - - This is so that the target's [page:Object3D.matrixWorld matrixWorld] gets automatically - updated each frame.

- - It is also possible to set the target to be another object in the scene (anything with a - [page:Object3D.position position] property), like so: + If [page:.targeted targeted] is *true*, the SpotLight points from its world [page:.position position] + to the world position of its [page:.target target] object, extracted from [page:Object3D.matrixWorld target.matrixWorld]. + This may be used to have the light track a moving object : -var targetObject = new THREE.Object3D(); -scene.add(targetObject); - +// track an existing object, already added to the scene +light.targeted = true; light.target = targetObject; + +// or use the default target object +light.targeted = true; +scene.add( light.target ); - The spotlight will now track the target object. + *Note*: The target object mush be added to the [page:Scene scene] to get its + [page:Object3D.matrixWorld matrixWorld] automatically updated each frame.
+ *Note*: The light [page:Object3D.rotation rotation] and [page:Object3D.quaternion quaternion] are + unused when the [page:.targeted targeted] is true.

+

[property:Boolean targeted]

+

+ If set to *true*, the light direction will track the [page:.target target] world position, otherwise the SpotLight is directed along the positive Z axis of its local + frame and thus affected by its world rotation.
+ + The default is *false*. +

Methods

diff --git a/examples/canvas_camera_orthographic.html b/examples/canvas_camera_orthographic.html index e20cc8319b794e..1171f7e0cafe6f 100644 --- a/examples/canvas_camera_orthographic.html +++ b/examples/canvas_camera_orthographic.html @@ -85,6 +85,7 @@ directionalLight.position.y = Math.random() - 0.5; directionalLight.position.z = Math.random() - 0.5; directionalLight.position.normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); var directionalLight = new THREE.DirectionalLight( Math.random() * 0xffffff ); @@ -92,6 +93,7 @@ directionalLight.position.y = Math.random() - 0.5; directionalLight.position.z = Math.random() - 0.5; directionalLight.position.normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); renderer = new THREE.CanvasRenderer(); diff --git a/examples/canvas_interactive_voxelpainter.html b/examples/canvas_interactive_voxelpainter.html index b016dd0c11ac62..ba9aaf9627a760 100644 --- a/examples/canvas_interactive_voxelpainter.html +++ b/examples/canvas_interactive_voxelpainter.html @@ -86,6 +86,7 @@ directionalLight.position.y = Math.random() - 0.5; directionalLight.position.z = Math.random() - 0.5; directionalLight.position.normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); var directionalLight = new THREE.DirectionalLight( 0x808080 ); @@ -93,6 +94,7 @@ directionalLight.position.y = Math.random() - 0.5; directionalLight.position.z = Math.random() - 0.5; directionalLight.position.normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); renderer = new THREE.CanvasRenderer(); diff --git a/examples/canvas_materials.html b/examples/canvas_materials.html index c076a530a042ec..d2718b04e7955c 100644 --- a/examples/canvas_materials.html +++ b/examples/canvas_materials.html @@ -117,6 +117,7 @@ directionalLight.position.y = Math.random() - 0.5; directionalLight.position.z = Math.random() - 0.5; directionalLight.position.normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); pointLight = new THREE.PointLight( 0xffffff, 1 ); diff --git a/examples/canvas_morphtargets_horse.html b/examples/canvas_morphtargets_horse.html index c25afe0dd3d7bd..2ed2e46e921a2e 100644 --- a/examples/canvas_morphtargets_horse.html +++ b/examples/canvas_morphtargets_horse.html @@ -57,10 +57,12 @@ var light = new THREE.DirectionalLight( 0xefefff, 1.5 ); light.position.set( 1, 1, 1 ).normalize(); + light.lookAt( 0, 0, 0 ); scene.add( light ); var light = new THREE.DirectionalLight( 0xffefef, 1.5 ); light.position.set( -1, -1, -1 ).normalize(); + light.lookAt( 0, 0, 0 ); scene.add( light ); var loader = new THREE.JSONLoader(); diff --git a/examples/canvas_performance.html b/examples/canvas_performance.html index 821f8939e650c1..6e8891f4e134c8 100644 --- a/examples/canvas_performance.html +++ b/examples/canvas_performance.html @@ -74,6 +74,7 @@ var directionalLight = new THREE.DirectionalLight( Math.random() * 0xffffff ); directionalLight.position.set( 0, 1, 0 ); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); light = new THREE.PointLight( 0xff0000, 1, 500 ); diff --git a/examples/css2d_label.html b/examples/css2d_label.html index 01c62a9b9f3a3b..068d677037cf1c 100644 --- a/examples/css2d_label.html +++ b/examples/css2d_label.html @@ -72,6 +72,7 @@ var dirLight = new THREE.DirectionalLight( 0xffffff ); dirLight.position.set( 0, 0, 1 ); + dirLight.lookAt( 0, 0, 0 ); scene.add( dirLight ); var axesHelper = new THREE.AxesHelper( 5 ); diff --git a/examples/js/crossfade/scenes.js b/examples/js/crossfade/scenes.js index 6ad37668521029..fb9f02ec8fe61a 100644 --- a/examples/js/crossfade/scenes.js +++ b/examples/js/crossfade/scenes.js @@ -82,6 +82,7 @@ function Scene( type, numObjects, cameraZ, fov, rotationSpeed, clearColor ) { var light = new THREE.SpotLight( 0xffffff, 1.5 ); light.position.set( 0, 500, 2000 ); + light.lookAt( 0, 0, 0 ); this.scene.add( light ); this.rotationSpeed = rotationSpeed; diff --git a/examples/js/loaders/BabylonLoader.js b/examples/js/loaders/BabylonLoader.js index 17844172faa886..11bc1126161b28 100644 --- a/examples/js/loaders/BabylonLoader.js +++ b/examples/js/loaders/BabylonLoader.js @@ -168,10 +168,12 @@ THREE.BabylonLoader.prototype = { case 1: light = new THREE.DirectionalLight(); + light.targeted = true; break; case 2: light = new THREE.SpotLight(); + light.targeted = true; break; case 3: diff --git a/examples/js/loaders/ColladaLoader.js b/examples/js/loaders/ColladaLoader.js index 32130233c5a48a..40e50964f4d5da 100644 --- a/examples/js/loaders/ColladaLoader.js +++ b/examples/js/loaders/ColladaLoader.js @@ -1936,6 +1936,7 @@ THREE.ColladaLoader.prototype = { case 'directional': light = new THREE.DirectionalLight(); + light.targeted = true; break; case 'point': @@ -1944,6 +1945,7 @@ THREE.ColladaLoader.prototype = { case 'spot': light = new THREE.SpotLight(); + light.targeted = true; break; case 'ambient': diff --git a/examples/js/loaders/GLTFLoader.js b/examples/js/loaders/GLTFLoader.js index 99bab78f476c71..86a08390352dea 100644 --- a/examples/js/loaders/GLTFLoader.js +++ b/examples/js/loaders/GLTFLoader.js @@ -291,6 +291,7 @@ THREE.GLTFLoader = ( function () { case 'directional': lightNode = new THREE.DirectionalLight( color ); + lightNode.targeted = true; lightNode.target.position.set( 0, 0, 1 ); lightNode.add( lightNode.target ); break; @@ -309,6 +310,7 @@ THREE.GLTFLoader = ( function () { lightDef.spot.outerConeAngle = lightDef.spot.outerConeAngle !== undefined ? lightDef.spot.outerConeAngle : Math.PI / 4.0; lightNode.angle = lightDef.spot.outerConeAngle; lightNode.penumbra = 1.0 - lightDef.spot.innerConeAngle / lightDef.spot.outerConeAngle; + lightNode.targeted = true; lightNode.target.position.set( 0, 0, 1 ); lightNode.add( lightNode.target ); break; diff --git a/examples/js/loaders/deprecated/LegacyGLTFLoader.js b/examples/js/loaders/deprecated/LegacyGLTFLoader.js index d67a4548831bfa..622889e5b24422 100644 --- a/examples/js/loaders/deprecated/LegacyGLTFLoader.js +++ b/examples/js/loaders/deprecated/LegacyGLTFLoader.js @@ -313,6 +313,7 @@ THREE.LegacyGLTFLoader = ( function () { case "directional": lightNode = new THREE.DirectionalLight( color ); lightNode.position.set( 0, 0, 1 ); + lightNode.lookAt( 0, 0, 0 ); break; case "point": @@ -322,6 +323,7 @@ THREE.LegacyGLTFLoader = ( function () { case "spot": lightNode = new THREE.SpotLight( color ); lightNode.position.set( 0, 0, 1 ); + lightNode.lookAt( 0, 0, 0 ); break; case "ambient": diff --git a/examples/js/renderers/WebGLDeferredRenderer.js b/examples/js/renderers/WebGLDeferredRenderer.js index 057ed2d1dd8690..29ca8c9cf08c17 100644 --- a/examples/js/renderers/WebGLDeferredRenderer.js +++ b/examples/js/renderers/WebGLDeferredRenderer.js @@ -890,14 +890,12 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { uniforms.lightAngle.value = originalLight.angle; uniforms.lightColor.value.copy( originalLight.color ); uniforms.lightIntensity.value = originalLight.intensity; - uniforms.lightPositionVS.value.setFromMatrixPosition( originalLight.matrixWorld ).applyMatrix4( _currentCamera.matrixWorldInverse ); + uniforms.lightPositionVS.value.setFromMatrixPosition( originalLight.matrixWorld ) + uniforms.lightPositionVS.value.applyMatrix4( _currentCamera.matrixWorldInverse ); - var vec = uniforms.lightDirectionVS.value; - var vec2 = _tmpVector3; - - vec.setFromMatrixPosition( originalLight.matrixWorld ); - vec2.setFromMatrixPosition( originalLight.target.matrixWorld ); - vec.sub( vec2 ).normalize().transformDirection( _currentCamera.matrixWorldInverse ); + uniforms.lightDirectionVS.value.set( 0, 0, - 1 ); + uniforms.lightDirectionVS.value.transformDirection( originalLight.shadow.camera.matrixWorld ); + uniforms.lightDirectionVS.value.transformDirection( _currentCamera.matrixWorldInverse ); updateDeferredLightCommonUniforms( uniforms ); @@ -933,12 +931,9 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { uniforms.lightColor.value.copy( originalLight.color ); uniforms.lightIntensity.value = originalLight.intensity; - var vec = uniforms.lightDirectionVS.value; - var vec2 = _tmpVector3; - - vec.setFromMatrixPosition( originalLight.matrixWorld ); - vec2.setFromMatrixPosition( originalLight.target.matrixWorld ); - vec.sub( vec2 ).normalize().transformDirection( _currentCamera.matrixWorldInverse ); + uniforms.lightDirectionVS.value.set( 0, 0, - 1 ); + uniforms.lightDirectionVS.value.transformDirection( originalLight.shadow.camera.matrixWorld ); + uniforms.lightDirectionVS.value.transformDirection( _currentCamera.matrixWorldInverse ); updateDeferredLightCommonUniforms( uniforms ); diff --git a/examples/misc_animation_authoring.html b/examples/misc_animation_authoring.html index 45b14cb515cd81..84fdf736bee5ca 100644 --- a/examples/misc_animation_authoring.html +++ b/examples/misc_animation_authoring.html @@ -60,6 +60,7 @@ var light = new THREE.DirectionalLight( 0xffffff, 2 ); light.position.set( 1, 1, 1 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); diff --git a/examples/misc_controls_fly.html b/examples/misc_controls_fly.html index 01dd637fbe4d9d..972e29e98410d3 100644 --- a/examples/misc_controls_fly.html +++ b/examples/misc_controls_fly.html @@ -97,6 +97,7 @@ dirLight = new THREE.DirectionalLight( 0xffffff ); dirLight.position.set( -1, 0, 1 ).normalize(); + dirLight.lookAt( 0, 0, 0 ); scene.add( dirLight ); var materialNormalMap = new THREE.MeshPhongMaterial( { diff --git a/examples/misc_controls_map.html b/examples/misc_controls_map.html index 99403e4dc0a32c..137421feac4ee2 100644 --- a/examples/misc_controls_map.html +++ b/examples/misc_controls_map.html @@ -107,10 +107,12 @@ var light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 1, 1, 1 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); var light = new THREE.DirectionalLight( 0x002288 ); light.position.set( - 1, - 1, - 1 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); var light = new THREE.AmbientLight( 0x222222 ); diff --git a/examples/misc_controls_orbit.html b/examples/misc_controls_orbit.html index 34c8e404c37178..78adc57662b120 100644 --- a/examples/misc_controls_orbit.html +++ b/examples/misc_controls_orbit.html @@ -101,10 +101,12 @@ var light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 1, 1, 1 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); var light = new THREE.DirectionalLight( 0x002288 ); light.position.set( - 1, - 1, - 1 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); var light = new THREE.AmbientLight( 0x222222 ); diff --git a/examples/misc_controls_trackball.html b/examples/misc_controls_trackball.html index 57eeca85b4cd4d..436bb546d69cd3 100644 --- a/examples/misc_controls_trackball.html +++ b/examples/misc_controls_trackball.html @@ -100,10 +100,12 @@ var light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 1, 1, 1 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); var light = new THREE.DirectionalLight( 0x002288 ); light.position.set( -1, -1, -1 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); var light = new THREE.AmbientLight( 0x222222 ); diff --git a/examples/misc_controls_transform.html b/examples/misc_controls_transform.html index 08aecdd951808b..eca29bcc0b8441 100644 --- a/examples/misc_controls_transform.html +++ b/examples/misc_controls_transform.html @@ -58,6 +58,7 @@ var light = new THREE.DirectionalLight( 0xffffff, 2 ); light.position.set( 1, 1, 1 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); var texture = new THREE.TextureLoader().load( 'textures/crate.gif', render ); diff --git a/examples/misc_exporter_gltf.html b/examples/misc_exporter_gltf.html index f4937eb37fb5c6..e00df65c904032 100644 --- a/examples/misc_exporter_gltf.html +++ b/examples/misc_exporter_gltf.html @@ -179,6 +179,7 @@ // --------------------------------------------------------------------- light = new THREE.DirectionalLight( 0xffffff, 1 ); light.position.set( 1, 1, 0 ); + light.lookAt( 0, 0, 0 ); light.name = 'DirectionalLight'; scene1.add( light ); diff --git a/examples/misc_exporter_stl.html b/examples/misc_exporter_stl.html index a7297e1de7df67..f1f822cb8b8c4e 100644 --- a/examples/misc_exporter_stl.html +++ b/examples/misc_exporter_stl.html @@ -66,6 +66,7 @@ var directionalLight = new THREE.DirectionalLight( 0xffffff ); directionalLight.position.set( 0, 200, 100 ); + directionalLight.lookAt( 0, 0, 0 ); directionalLight.castShadow = true; directionalLight.shadow.camera.top = 180; directionalLight.shadow.camera.bottom = - 100; diff --git a/examples/misc_lights_test.html b/examples/misc_lights_test.html index ee0e235e080edb..7a625d0025ceea 100644 --- a/examples/misc_lights_test.html +++ b/examples/misc_lights_test.html @@ -98,6 +98,7 @@ directionalLight = new THREE.DirectionalLight( 0xffffff ); directionalLight.position.set( 0, -70, 100 ).normalize(); + directionalLight.lookAt( 0, 0, 0 ); setTimeout( function () { diff --git a/examples/misc_ubiquity_test.html b/examples/misc_ubiquity_test.html index c22aebf18f86cc..77ee9c33ee1de4 100644 --- a/examples/misc_ubiquity_test.html +++ b/examples/misc_ubiquity_test.html @@ -187,6 +187,7 @@ var directional = new THREE.DirectionalLight( 0xffff00 ); directional.position.set( - 1, 0.5, 0 ); + directional.lookAt( 0, 0, 0 ); scene.add( directional ); canvasRenderer = new THREE.CanvasRenderer(); diff --git a/examples/models/obj/verify/verify.html b/examples/models/obj/verify/verify.html index 0b92513319d412..ce54788ff40e80 100644 --- a/examples/models/obj/verify/verify.html +++ b/examples/models/obj/verify/verify.html @@ -128,6 +128,9 @@ directionalLight1.position.set( -100, -50, 100 ); directionalLight2.position.set( 100, 50, -100 ); + + directionalLight1.lookAt( 0, 0, 0 ); + directionalLight2.lookAt( 0, 0, 0 ); this.scene.add( directionalLight1 ); this.scene.add( directionalLight2 ); diff --git a/examples/svg_sandbox.html b/examples/svg_sandbox.html index 37b0c9f0b6abf8..b7969ad9ef3e8f 100644 --- a/examples/svg_sandbox.html +++ b/examples/svg_sandbox.html @@ -173,6 +173,7 @@ var directional = new THREE.DirectionalLight( 0xffff00 ); directional.position.set( - 1, 0.5, 0 ); + directional.lookAt( 0, 0, 0 ); scene.add( directional ); renderer = new THREE.SVGRenderer(); diff --git a/examples/webaudio_orientation.html b/examples/webaudio_orientation.html index de7426104eb0cf..399a045a654987 100644 --- a/examples/webaudio_orientation.html +++ b/examples/webaudio_orientation.html @@ -129,6 +129,7 @@ light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 0, 200, 100 ); + light.lookAt( 0, 0, 0 ); light.castShadow = true; light.shadow.camera.top = 180; light.shadow.camera.bottom = -100; diff --git a/examples/webaudio_sandbox.html b/examples/webaudio_sandbox.html index f645d0c239216f..26e7076b2b530d 100644 --- a/examples/webaudio_sandbox.html +++ b/examples/webaudio_sandbox.html @@ -118,6 +118,7 @@ light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 0, 0.5, 1 ).normalize(); + light.lookAt( 0, 0, 0 ); scene.add( light ); var sphere = new THREE.SphereBufferGeometry( 20, 32, 16 ); diff --git a/examples/webaudio_timing.html b/examples/webaudio_timing.html index 128b8f5543c913..a07e7838e44d31 100644 --- a/examples/webaudio_timing.html +++ b/examples/webaudio_timing.html @@ -117,6 +117,7 @@ var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.7 ); directionalLight.position.set( 0, 5, 5 ); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); var d = 5; diff --git a/examples/webgl_animation_cloth.html b/examples/webgl_animation_cloth.html index 4ffa3b3a1fd463..0580f44e349e3f 100644 --- a/examples/webgl_animation_cloth.html +++ b/examples/webgl_animation_cloth.html @@ -111,6 +111,7 @@ light = new THREE.DirectionalLight( 0xdfebff, 1 ); light.position.set( 50, 200, 100 ); light.position.multiplyScalar( 1.3 ); + light.lookAt( 0, 0, 0 ); light.castShadow = true; diff --git a/examples/webgl_animation_skinning_morph.html b/examples/webgl_animation_skinning_morph.html index 06caace40f505c..c60f2d83eea8c9 100644 --- a/examples/webgl_animation_skinning_morph.html +++ b/examples/webgl_animation_skinning_morph.html @@ -112,6 +112,7 @@ var light = new THREE.DirectionalLight( 0xebf3ff, 1.5 ); light.position.set( 0, 140, 500 ).multiplyScalar( 1.1 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); light.castShadow = true; diff --git a/examples/webgl_buffergeometry.html b/examples/webgl_buffergeometry.html index 6da5a22e5ab88b..bac2bfe8a63532 100644 --- a/examples/webgl_buffergeometry.html +++ b/examples/webgl_buffergeometry.html @@ -70,10 +70,12 @@ var light1 = new THREE.DirectionalLight( 0xffffff, 0.5 ); light1.position.set( 1, 1, 1 ); + light1.lookAt( 0, 0, 0 ); scene.add( light1 ); var light2 = new THREE.DirectionalLight( 0xffffff, 1.5 ); light2.position.set( 0, -1, 0 ); + light2.lookAt( 0, 0, 0 ); scene.add( light2 ); // diff --git a/examples/webgl_buffergeometry_indexed.html b/examples/webgl_buffergeometry_indexed.html index 2e9f6ac6638e5b..8240b1c0fc8c78 100644 --- a/examples/webgl_buffergeometry_indexed.html +++ b/examples/webgl_buffergeometry_indexed.html @@ -67,10 +67,12 @@ var light1 = new THREE.DirectionalLight( 0xffffff, 0.5 ); light1.position.set( 1, 1, 1 ); + light1.lookAt( 0, 0, 0 ); scene.add( light1 ); var light2 = new THREE.DirectionalLight( 0xffffff, 1 ); light2.position.set( 0, - 1, 0 ); + light2.lookAt( 0, 0, 0 ); scene.add( light2 ); // diff --git a/examples/webgl_buffergeometry_instancing_lambert.html b/examples/webgl_buffergeometry_instancing_lambert.html index 862ec22a2b53bd..e03b3322bc1e5c 100644 --- a/examples/webgl_buffergeometry_instancing_lambert.html +++ b/examples/webgl_buffergeometry_instancing_lambert.html @@ -234,6 +234,7 @@ var light = new THREE.DirectionalLight( 0xffffff, 0.4 ); light.position.set( 50, 40, 0 ); + light.lookAt( 0, 0, 0 ); light.castShadow = true; light.shadow.camera.left = - 40; diff --git a/examples/webgl_buffergeometry_uint.html b/examples/webgl_buffergeometry_uint.html index e431b6f4d9d2ba..0f4e52a4940d4c 100644 --- a/examples/webgl_buffergeometry_uint.html +++ b/examples/webgl_buffergeometry_uint.html @@ -70,10 +70,12 @@ var light1 = new THREE.DirectionalLight( 0xffffff, 0.5 ); light1.position.set( 1, 1, 1 ); + light1.lookAt( 0, 0, 0 ); scene.add( light1 ); var light2 = new THREE.DirectionalLight( 0xffffff, 1.5 ); light2.position.set( 0, -1, 0 ); + light2.lookAt( 0, 0, 0 ); scene.add( light2 ); // diff --git a/examples/webgl_camera_array.html b/examples/webgl_camera_array.html index d4284697ed28a9..6563990e96e848 100644 --- a/examples/webgl_camera_array.html +++ b/examples/webgl_camera_array.html @@ -59,6 +59,7 @@ var light = new THREE.DirectionalLight(); light.position.set( 0.5, 0.5, 1 ); + light.lookAt( 0, 0, 0 ); light.castShadow = true; light.shadow.camera.zoom = 4; // tighter shadow map scene.add( light ); diff --git a/examples/webgl_camera_cinematic.html b/examples/webgl_camera_cinematic.html index 424e96e5d461fd..ce26e6e131ec3f 100644 --- a/examples/webgl_camera_cinematic.html +++ b/examples/webgl_camera_cinematic.html @@ -56,6 +56,7 @@ var light = new THREE.DirectionalLight( 0xffffff, 0.35 ); light.position.set( 1, 1, 1 ).normalize(); + light.lookAt( 0, 0, 0 ); scene.add( light ); var geometry = new THREE.BoxBufferGeometry( 20, 20, 20 ); diff --git a/examples/webgl_camera_logarithmicdepthbuffer.html b/examples/webgl_camera_logarithmicdepthbuffer.html index 565675a3250687..9bca3c4c5540d2 100644 --- a/examples/webgl_camera_logarithmicdepthbuffer.html +++ b/examples/webgl_camera_logarithmicdepthbuffer.html @@ -184,6 +184,7 @@ var light = new THREE.DirectionalLight(0xffffff, 1); light.position.set(100,100,100); + light.lookAt( 0, 0, 0 ); scene.add(light); var materialargs = { diff --git a/examples/webgl_clipping.html b/examples/webgl_clipping.html index aca30d905a5841..8a66de33f68584 100644 --- a/examples/webgl_clipping.html +++ b/examples/webgl_clipping.html @@ -42,6 +42,7 @@ spotLight.angle = Math.PI / 5; spotLight.penumbra = 0.2; spotLight.position.set( 2, 3, 3 ); + spotLight.lookAt( 0, 0, 0 ); spotLight.castShadow = true; spotLight.shadow.camera.near = 3; spotLight.shadow.camera.far = 10; @@ -51,6 +52,7 @@ var dirLight = new THREE.DirectionalLight( 0x55505a, 1 ); dirLight.position.set( 0, 3, 0 ); + dirLight.lookAt( 0, 0, 0 ); dirLight.castShadow = true; dirLight.shadow.camera.near = 1; dirLight.shadow.camera.far = 10; diff --git a/examples/webgl_clipping_advanced.html b/examples/webgl_clipping_advanced.html index c84efddb1c7820..5727bf24c2254d 100644 --- a/examples/webgl_clipping_advanced.html +++ b/examples/webgl_clipping_advanced.html @@ -177,6 +177,7 @@ var dirLight = new THREE.DirectionalLight( 0x55505a, 1 ); dirLight.position.set( 0, 2, 0 ); + dirLight.lookAt( 0, 0, 0 ); dirLight.castShadow = true; dirLight.shadow.camera.near = 1; dirLight.shadow.camera.far = 10; diff --git a/examples/webgl_decals.html b/examples/webgl_decals.html index 189a355fdea87b..98d10eb5d66790 100644 --- a/examples/webgl_decals.html +++ b/examples/webgl_decals.html @@ -118,10 +118,12 @@ var light = new THREE.DirectionalLight( 0xffddcc, 1 ); light.position.set( 1, 0.75, 0.5 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); var light = new THREE.DirectionalLight( 0xccccff, 1 ); light.position.set( -1, 0.75, -0.5 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); var geometry = new THREE.BufferGeometry(); diff --git a/examples/webgl_effects_parallaxbarrier.html b/examples/webgl_effects_parallaxbarrier.html index 20a23c4d6a0f5d..edaf5b27c12182 100644 --- a/examples/webgl_effects_parallaxbarrier.html +++ b/examples/webgl_effects_parallaxbarrier.html @@ -177,10 +177,12 @@ directionalLight = new THREE.DirectionalLight( 0xffffff, 2 ); directionalLight.position.set( 2, 1.2, 10 ).normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); directionalLight = new THREE.DirectionalLight( 0xffffff, 1 ); directionalLight.position.set( - 2, 1.2, -10 ).normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); pointLight = new THREE.PointLight( 0xffaa00, 2 ); diff --git a/examples/webgl_geometry_colors.html b/examples/webgl_geometry_colors.html index d886a71c72cf62..0223c5dda74fdb 100644 --- a/examples/webgl_geometry_colors.html +++ b/examples/webgl_geometry_colors.html @@ -67,6 +67,7 @@ var light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 0, 0, 1 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); // shadow diff --git a/examples/webgl_geometry_colors_lookuptable.html b/examples/webgl_geometry_colors_lookuptable.html index 1b3cec8ef5a4d5..17b16c2ef3ea66 100644 --- a/examples/webgl_geometry_colors_lookuptable.html +++ b/examples/webgl_geometry_colors_lookuptable.html @@ -96,6 +96,7 @@ var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.7 ); directionalLight.position.set( 17, 9, 30 ); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); renderer = new THREE.WebGLRenderer( { antialias: true } ); diff --git a/examples/webgl_geometry_extrude_shapes2.html b/examples/webgl_geometry_extrude_shapes2.html index 1abbbe942d8763..bb56c10fbd6c15 100644 --- a/examples/webgl_geometry_extrude_shapes2.html +++ b/examples/webgl_geometry_extrude_shapes2.html @@ -418,6 +418,7 @@ var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.6 ); directionalLight.position.set( 0.75, 0.75, 1.0 ).normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); var ambientLight = new THREE.AmbientLight( 0xcccccc, 0.2 ); diff --git a/examples/webgl_geometry_extrude_splines.html b/examples/webgl_geometry_extrude_splines.html index ececa0278f52b6..a6c69e31805603 100644 --- a/examples/webgl_geometry_extrude_splines.html +++ b/examples/webgl_geometry_extrude_splines.html @@ -178,6 +178,7 @@ var light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 0, 0, 1 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); // tube diff --git a/examples/webgl_geometry_minecraft.html b/examples/webgl_geometry_minecraft.html index 5a2dd7c8d18ecb..132602ee5f2284 100644 --- a/examples/webgl_geometry_minecraft.html +++ b/examples/webgl_geometry_minecraft.html @@ -188,6 +188,7 @@ var directionalLight = new THREE.DirectionalLight( 0xffffff, 2 ); directionalLight.position.set( 1, 1, 0.5 ).normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); renderer = new THREE.WebGLRenderer( { antialias: true } ); diff --git a/examples/webgl_geometry_minecraft_ao.html b/examples/webgl_geometry_minecraft_ao.html index 98d925db190734..4585988e4e0f88 100644 --- a/examples/webgl_geometry_minecraft_ao.html +++ b/examples/webgl_geometry_minecraft_ao.html @@ -292,6 +292,7 @@ var directionalLight = new THREE.DirectionalLight( 0xffffff, 2 ); directionalLight.position.set( 1, 1, 0.5 ).normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); renderer = new THREE.WebGLRenderer(); diff --git a/examples/webgl_geometry_nurbs.html b/examples/webgl_geometry_nurbs.html index 285726ef35249b..1f2b2304ac5d8e 100644 --- a/examples/webgl_geometry_nurbs.html +++ b/examples/webgl_geometry_nurbs.html @@ -73,6 +73,7 @@ var light = new THREE.DirectionalLight( 0xffffff, 1 ); light.position.set( 1, 1, 1 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); group = new THREE.Group(); diff --git a/examples/webgl_geometry_spline_editor.html b/examples/webgl_geometry_spline_editor.html index 664e4c6e7e0cd5..e7a9a00b1c223e 100644 --- a/examples/webgl_geometry_spline_editor.html +++ b/examples/webgl_geometry_spline_editor.html @@ -94,6 +94,7 @@ scene.add( new THREE.AmbientLight( 0xf0f0f0 ) ); var light = new THREE.SpotLight( 0xffffff, 1.5 ); light.position.set( 0, 1500, 200 ); + light.lookAt( 0, 0, 0 ); light.castShadow = true; light.shadow = new THREE.LightShadow( new THREE.PerspectiveCamera( 70, 1, 200, 2000 ) ); light.shadow.bias = -0.000222; diff --git a/examples/webgl_geometry_text.html b/examples/webgl_geometry_text.html index e7c63ab7f9dea2..6e49a7c51d6581 100644 --- a/examples/webgl_geometry_text.html +++ b/examples/webgl_geometry_text.html @@ -145,6 +145,7 @@ var dirLight = new THREE.DirectionalLight( 0xffffff, 0.125 ); dirLight.position.set( 0, 0, 1 ).normalize(); + dirLight.lookAt( 0, 0, 0 ); scene.add( dirLight ); var pointLight = new THREE.PointLight( 0xffffff, 1.5 ); diff --git a/examples/webgl_gpgpu_water.html b/examples/webgl_gpgpu_water.html index 5f148207805425..769fd57e7d0e2f 100644 --- a/examples/webgl_gpgpu_water.html +++ b/examples/webgl_gpgpu_water.html @@ -263,10 +263,12 @@ var sun = new THREE.DirectionalLight( 0xFFFFFF, 1.0 ); sun.position.set( 300, 400, 175 ); + sun.lookAt( 0, 0, 0 ); scene.add( sun ); var sun2 = new THREE.DirectionalLight( 0x40A040, 0.6 ); sun2.position.set( -100, 350, -200 ); + sun2.lookAt( 0, 0, 0 ); scene.add( sun2 ); renderer = new THREE.WebGLRenderer(); @@ -461,7 +463,7 @@ gpuCompute.doRenderTarget( smoothShader, currentRenderTarget ); } - + } diff --git a/examples/webgl_interactive_buffergeometry.html b/examples/webgl_interactive_buffergeometry.html index 4c14d3973b549b..447ab431f748ff 100644 --- a/examples/webgl_interactive_buffergeometry.html +++ b/examples/webgl_interactive_buffergeometry.html @@ -73,10 +73,12 @@ var light1 = new THREE.DirectionalLight( 0xffffff, 0.5 ); light1.position.set( 1, 1, 1 ); + light1.lookAt( 0, 0, 0 ); scene.add( light1 ); var light2 = new THREE.DirectionalLight( 0xffffff, 1.5 ); light2.position.set( 0, -1, 0 ); + light2.lookAt( 0, 0, 0 ); scene.add( light2 ); // diff --git a/examples/webgl_interactive_cubes.html b/examples/webgl_interactive_cubes.html index 5c922d9ad4e6d9..13ee04d4db0188 100644 --- a/examples/webgl_interactive_cubes.html +++ b/examples/webgl_interactive_cubes.html @@ -50,6 +50,7 @@ var light = new THREE.DirectionalLight( 0xffffff, 1 ); light.position.set( 1, 1, 1 ).normalize(); + light.lookAt( 0, 0, 0 ); scene.add( light ); var geometry = new THREE.BoxBufferGeometry( 20, 20, 20 ); diff --git a/examples/webgl_interactive_cubes_gpu.html b/examples/webgl_interactive_cubes_gpu.html index 1a05fdb1ece4f8..b8596a92048b77 100644 --- a/examples/webgl_interactive_cubes_gpu.html +++ b/examples/webgl_interactive_cubes_gpu.html @@ -81,6 +81,7 @@ var light = new THREE.SpotLight( 0xffffff, 1.5 ); light.position.set( 0, 500, 2000 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); var pickingMaterial = new THREE.MeshBasicMaterial( { vertexColors: THREE.VertexColors } ); diff --git a/examples/webgl_interactive_cubes_ortho.html b/examples/webgl_interactive_cubes_ortho.html index 64c769bdd319ea..7e91111f8e9679 100644 --- a/examples/webgl_interactive_cubes_ortho.html +++ b/examples/webgl_interactive_cubes_ortho.html @@ -52,6 +52,7 @@ var light = new THREE.DirectionalLight( 0xffffff, 1 ); light.position.set( 1, 1, 1 ).normalize(); + light.lookAt( 0, 0, 0 ); scene.add( light ); var geometry = new THREE.BoxBufferGeometry( 20, 20, 20 ); diff --git a/examples/webgl_interactive_draggablecubes.html b/examples/webgl_interactive_draggablecubes.html index b2863be490566e..4d2dc0bc95378d 100644 --- a/examples/webgl_interactive_draggablecubes.html +++ b/examples/webgl_interactive_draggablecubes.html @@ -55,6 +55,7 @@ var light = new THREE.SpotLight( 0xffffff, 1.5 ); light.position.set( 0, 500, 2000 ); + light.lookAt( 0, 0, 0 ); light.angle = Math.PI / 9; light.castShadow = true; diff --git a/examples/webgl_interactive_voxelpainter.html b/examples/webgl_interactive_voxelpainter.html index d9e3493dd4502c..6b0e706ce519e2 100644 --- a/examples/webgl_interactive_voxelpainter.html +++ b/examples/webgl_interactive_voxelpainter.html @@ -101,6 +101,7 @@ var directionalLight = new THREE.DirectionalLight( 0xffffff ); directionalLight.position.set( 1, 0.75, 0.5 ).normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); renderer = new THREE.WebGLRenderer( { antialias: true } ); diff --git a/examples/webgl_lensflares.html b/examples/webgl_lensflares.html index f050df0319a1c0..9ec5fdc3f454d6 100644 --- a/examples/webgl_lensflares.html +++ b/examples/webgl_lensflares.html @@ -113,8 +113,9 @@ // lights var dirLight = new THREE.DirectionalLight( 0xffffff, 0.05 ); - dirLight.position.set( 0, -1, 0 ).normalize(); dirLight.color.setHSL( 0.1, 0.7, 0.5 ); + dirLight.position.set( 0, -1, 0 ).normalize(); + dirLight.lookAt( 0, 0, 0 ); scene.add( dirLight ); // lensflares diff --git a/examples/webgl_lights_hemisphere.html b/examples/webgl_lights_hemisphere.html index 664123dfcc15dc..e11303d5edf39c 100644 --- a/examples/webgl_lights_hemisphere.html +++ b/examples/webgl_lights_hemisphere.html @@ -124,6 +124,7 @@ dirLight.color.setHSL( 0.1, 1, 0.95 ); dirLight.position.set( -1, 1.75, 1 ); dirLight.position.multiplyScalar( 30 ); + dirLight.lookAt( 0, 0, 0 ); scene.add( dirLight ); dirLight.castShadow = true; diff --git a/examples/webgl_lights_pointlights2.html b/examples/webgl_lights_pointlights2.html index 84c626ae3c8887..56d507dde66789 100644 --- a/examples/webgl_lights_pointlights2.html +++ b/examples/webgl_lights_pointlights2.html @@ -169,6 +169,7 @@ var dlight = new THREE.DirectionalLight( 0xffffff, 0.05 ); dlight.position.set( 0.5, 1, 0 ).normalize(); + dlight.lookAt( 0, 0, 0 ); scene.add( dlight ); // RENDERER diff --git a/examples/webgl_lights_spotlight.html b/examples/webgl_lights_spotlight.html index 6c973a7e69abff..5243ccb3f9bde2 100644 --- a/examples/webgl_lights_spotlight.html +++ b/examples/webgl_lights_spotlight.html @@ -82,6 +82,7 @@ spotLight = new THREE.SpotLight( 0xffffff, 1 ); spotLight.position.set( 15, 40, 35 ); + spotLight.lookAt( 0, 0, 0 ); spotLight.angle = Math.PI / 4; spotLight.penumbra = 0.05; spotLight.decay = 2; diff --git a/examples/webgl_lights_spotlights.html b/examples/webgl_lights_spotlights.html index cb011f3ded9f27..95226591ea5257 100644 --- a/examples/webgl_lights_spotlights.html +++ b/examples/webgl_lights_spotlights.html @@ -132,6 +132,8 @@ newObj.shadow.mapSize.width = 1024; newObj.shadow.mapSize.height = 1024; + newObj.targeted = true; + return newObj; } diff --git a/examples/webgl_loader_3ds.html b/examples/webgl_loader_3ds.html index 5bb2bb6f9cde45..0439ee1b30e5ab 100644 --- a/examples/webgl_loader_3ds.html +++ b/examples/webgl_loader_3ds.html @@ -57,6 +57,7 @@ var directionalLight = new THREE.DirectionalLight( 0xffeedd ); directionalLight.position.set( 0, 0, 2 ); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); //3ds files dont store normal maps diff --git a/examples/webgl_loader_assimp.html b/examples/webgl_loader_assimp.html index 0819f552727961..bf42de19701cd6 100644 --- a/examples/webgl_loader_assimp.html +++ b/examples/webgl_loader_assimp.html @@ -80,6 +80,7 @@ var light = new THREE.DirectionalLight( 0xffffff, 1 ); light.position.set( 0, 4, 4 ).normalize(); + light.lookAt( 0, 0, 0 ); scene.add( light ); renderer = new THREE.WebGLRenderer( { antialias: true } ); diff --git a/examples/webgl_loader_assimp2json.html b/examples/webgl_loader_assimp2json.html index 7634f7bb142940..f0e30b63b57db9 100644 --- a/examples/webgl_loader_assimp2json.html +++ b/examples/webgl_loader_assimp2json.html @@ -114,6 +114,7 @@ var directionalLight = new THREE.DirectionalLight( 0xeeeeee ); directionalLight.position.set( 1, 1, - 1 ); directionalLight.position.normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); // diff --git a/examples/webgl_loader_awd.html b/examples/webgl_loader_awd.html index 62acf8cd3ba4e1..529365a239e16b 100644 --- a/examples/webgl_loader_awd.html +++ b/examples/webgl_loader_awd.html @@ -100,6 +100,7 @@ var directionalLight = new THREE.DirectionalLight(/*Math.random() * 0xffffff*/0xeeeeee ); directionalLight.position.set( .2, -1, .2 ); directionalLight.position.normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); pointLight = new THREE.PointLight( 0xffffff, .6 ); diff --git a/examples/webgl_loader_collada.html b/examples/webgl_loader_collada.html index 62b2097142e6d3..05abacc79d9dab 100644 --- a/examples/webgl_loader_collada.html +++ b/examples/webgl_loader_collada.html @@ -88,6 +88,7 @@ var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.8 ); directionalLight.position.set( 1, 1, 0 ).normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); // diff --git a/examples/webgl_loader_collada_skinning.html b/examples/webgl_loader_collada_skinning.html index eab5407b99ec75..154a405ac4215e 100644 --- a/examples/webgl_loader_collada_skinning.html +++ b/examples/webgl_loader_collada_skinning.html @@ -90,6 +90,7 @@ var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.8 ); directionalLight.position.set( 1, 1, - 1 ); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); // diff --git a/examples/webgl_loader_ctm.html b/examples/webgl_loader_ctm.html index 645737e731e060..3dfc68c4f1fef3 100644 --- a/examples/webgl_loader_ctm.html +++ b/examples/webgl_loader_ctm.html @@ -100,6 +100,7 @@ var light = new THREE.SpotLight( 0xffeedd, 1.2, 650, Math.PI / 6 ); light.position.set( 0, -100, 500 ); + light.lookAt( 0, 0, 0 ); light.castShadow = true; light.shadow.mapWidth = 1024; diff --git a/examples/webgl_loader_draco.html b/examples/webgl_loader_draco.html index 712a15ee63aa7e..2330fde7d9b42c 100644 --- a/examples/webgl_loader_draco.html +++ b/examples/webgl_loader_draco.html @@ -78,6 +78,7 @@ light.penumbra = 0.5; light.castShadow = true; light.position.set( - 1, 1, 1 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); dracoLoader.load( 'models/draco/bunny.drc', function ( geometry ) { diff --git a/examples/webgl_loader_fbx.html b/examples/webgl_loader_fbx.html index 2d1983ceeba9cf..6570a9bc7430f3 100644 --- a/examples/webgl_loader_fbx.html +++ b/examples/webgl_loader_fbx.html @@ -80,6 +80,7 @@ light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 0, 200, 100 ); + light.lookAt( 0, 0, 0 ); light.castShadow = true; light.shadow.camera.top = 180; light.shadow.camera.bottom = -100; diff --git a/examples/webgl_loader_fbx_nurbs.html b/examples/webgl_loader_fbx_nurbs.html index 3916362c4b6ae1..75386c91b0a6c5 100644 --- a/examples/webgl_loader_fbx_nurbs.html +++ b/examples/webgl_loader_fbx_nurbs.html @@ -74,6 +74,7 @@ light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 0, 1, 0 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); // grid diff --git a/examples/webgl_loader_gltf_extensions.html b/examples/webgl_loader_gltf_extensions.html index 7eb1fcef031808..0c0fb730dede26 100644 --- a/examples/webgl_loader_gltf_extensions.html +++ b/examples/webgl_loader_gltf_extensions.html @@ -205,10 +205,12 @@ var directionalLight = new THREE.DirectionalLight( 0xdddddd, 4 ); directionalLight.position.set( 0, 0, 1 ).normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); spot1 = new THREE.SpotLight( 0xffffff, 1 ); spot1.position.set( 10, 20, 10 ); + spot1.targeted = true; spot1.angle = 0.25; spot1.penumbra = 0.75; diff --git a/examples/webgl_loader_json_claraio.html b/examples/webgl_loader_json_claraio.html index cecdf98a7714f6..815e77d97e4da4 100644 --- a/examples/webgl_loader_json_claraio.html +++ b/examples/webgl_loader_json_claraio.html @@ -69,6 +69,7 @@ var directionalLight = new THREE.DirectionalLight( 0xffeedd ); directionalLight.position.set( 0, 0, 1 ).normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); // BEGIN Clara.io JSON loader code diff --git a/examples/webgl_loader_json_objconverter.html b/examples/webgl_loader_json_objconverter.html index 9ef12517e8d7cf..26255b6b0707f9 100644 --- a/examples/webgl_loader_json_objconverter.html +++ b/examples/webgl_loader_json_objconverter.html @@ -124,6 +124,7 @@

OBJ to Three.js converter test

var directionalLight = new THREE.DirectionalLight( 0xffeedd, 1.5 ); directionalLight.position.set( 0, -70, 100 ).normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); // RENDERER diff --git a/examples/webgl_loader_kmz.html b/examples/webgl_loader_kmz.html index 388eeb1f3df410..e9a652abf99d3a 100644 --- a/examples/webgl_loader_kmz.html +++ b/examples/webgl_loader_kmz.html @@ -66,6 +66,7 @@ var light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 0.5, 1.0, 0.5 ).normalize(); + light.lookAt( 0, 0, 0 ); scene.add( light ); diff --git a/examples/webgl_loader_md2.html b/examples/webgl_loader_md2.html index 6c165312f4a75f..811f1ae165314d 100644 --- a/examples/webgl_loader_md2.html +++ b/examples/webgl_loader_md2.html @@ -95,6 +95,7 @@ var light = new THREE.SpotLight( 0xffffff, 5, 1000 ); light.position.set( 200, 250, 500 ); + light.lookAt( 0, 0, 0 ); light.angle = 0.5; light.penumbra = 0.5; @@ -107,6 +108,7 @@ var light = new THREE.SpotLight( 0xffffff, 5, 1000 ); light.position.set( -100, 350, 350 ); + light.lookAt( 0, 0, 0 ); light.angle = 0.5; light.penumbra = 0.5; diff --git a/examples/webgl_loader_md2_control.html b/examples/webgl_loader_md2_control.html index ffa31f11c88818..ec50d2c86e3a92 100644 --- a/examples/webgl_loader_md2_control.html +++ b/examples/webgl_loader_md2_control.html @@ -101,6 +101,7 @@ var light = new THREE.DirectionalLight( 0xffffff, 2.25 ); light.position.set( 200, 450, 500 ); + light.targeted = true; light.castShadow = true; diff --git a/examples/webgl_loader_mmd.html b/examples/webgl_loader_mmd.html index 33de2337961737..c1e96960359b5a 100644 --- a/examples/webgl_loader_mmd.html +++ b/examples/webgl_loader_mmd.html @@ -90,6 +90,7 @@ var directionalLight = new THREE.DirectionalLight( 0x887766 ); directionalLight.position.set( - 1, 1, 1 ).normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); // diff --git a/examples/webgl_loader_mmd_audio.html b/examples/webgl_loader_mmd_audio.html index 529ccf2008628c..e7b717b7b05685 100644 --- a/examples/webgl_loader_mmd_audio.html +++ b/examples/webgl_loader_mmd_audio.html @@ -88,6 +88,7 @@ var directionalLight = new THREE.DirectionalLight( 0x887766 ); directionalLight.position.set( - 1, 1, 1 ).normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); // diff --git a/examples/webgl_loader_mmd_pose.html b/examples/webgl_loader_mmd_pose.html index 93cf03bde06d7c..b8d402d8e919ad 100644 --- a/examples/webgl_loader_mmd_pose.html +++ b/examples/webgl_loader_mmd_pose.html @@ -81,6 +81,7 @@ var directionalLight = new THREE.DirectionalLight( 0x887766 ); directionalLight.position.set( - 1, 1, 1 ).normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); // diff --git a/examples/webgl_loader_nodes.html b/examples/webgl_loader_nodes.html index ea748474efa190..e30c76a64cce07 100644 --- a/examples/webgl_loader_nodes.html +++ b/examples/webgl_loader_nodes.html @@ -87,6 +87,7 @@ var light = new THREE.DirectionalLight( 0xccccff, 1 ); light.position.set( - 1, 0.75, - 0.5 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); teapot = new THREE.TeapotBufferGeometry( 15, 18 ); diff --git a/examples/webgl_loader_nrrd.html b/examples/webgl_loader_nrrd.html index e2d4932f839ef0..5447d4c8312aac 100644 --- a/examples/webgl_loader_nrrd.html +++ b/examples/webgl_loader_nrrd.html @@ -98,6 +98,7 @@ dirLight.position.set( 200, 200, 1000 ).normalize(); camera.add( dirLight ); + dirLight.targeted = true; camera.add( dirLight.target ); var loader = new THREE.NRRDLoader(); diff --git a/examples/webgl_loader_obj2.html b/examples/webgl_loader_obj2.html index daf62615df6eb9..a4b2827e81cd4d 100644 --- a/examples/webgl_loader_obj2.html +++ b/examples/webgl_loader_obj2.html @@ -129,6 +129,9 @@ directionalLight1.position.set( -100, -50, 100 ); directionalLight2.position.set( 100, 50, -100 ); + directionalLight1.lookAt( 0, 0, 0 ); + directionalLight2.lookAt( 0, 0, 0 ); + this.scene.add( directionalLight1 ); this.scene.add( directionalLight2 ); this.scene.add( ambientLight ); diff --git a/examples/webgl_loader_obj2_meshspray.html b/examples/webgl_loader_obj2_meshspray.html index 0ad2726f99671d..b42fd2906f5d0c 100644 --- a/examples/webgl_loader_obj2_meshspray.html +++ b/examples/webgl_loader_obj2_meshspray.html @@ -419,6 +419,9 @@ directionalLight1.position.set( -100, -50, 100 ); directionalLight2.position.set( 100, 50, -100 ); + directionalLight1.lookAt( 0, 0, 0 ); + directionalLight2.lookAt( 0, 0, 0 ); + this.scene.add( directionalLight1 ); this.scene.add( directionalLight2 ); this.scene.add( ambientLight ); diff --git a/examples/webgl_loader_obj2_options.html b/examples/webgl_loader_obj2_options.html index de8fc3cf049b9d..075b7d905301e8 100644 --- a/examples/webgl_loader_obj2_options.html +++ b/examples/webgl_loader_obj2_options.html @@ -135,6 +135,9 @@ directionalLight1.position.set( -100, -50, 100 ); directionalLight2.position.set( 100, 50, -100 ); + directionalLight1.lookAt( 0, 0, 0 ); + directionalLight2.lookAt( 0, 0, 0 ); + this.scene.add( directionalLight1 ); this.scene.add( directionalLight2 ); this.scene.add( ambientLight ); diff --git a/examples/webgl_loader_obj2_run_director.html b/examples/webgl_loader_obj2_run_director.html index 72d76098ca6317..81abea640f5a72 100644 --- a/examples/webgl_loader_obj2_run_director.html +++ b/examples/webgl_loader_obj2_run_director.html @@ -147,6 +147,9 @@ var directionalLight1 = new THREE.DirectionalLight( 0xC0C090 ); var directionalLight2 = new THREE.DirectionalLight( 0xC0C090 ); + directionalLight1.lookAt( 0, 0, 0 ); + directionalLight2.lookAt( 0, 0, 0 ); + directionalLight1.position.set( -100, -50, 100 ); directionalLight2.position.set( 100, 50, -100 ); diff --git a/examples/webgl_loader_pdb.html b/examples/webgl_loader_pdb.html index 5af2b9cdb700ca..1df2a161d9074b 100644 --- a/examples/webgl_loader_pdb.html +++ b/examples/webgl_loader_pdb.html @@ -118,10 +118,12 @@ var light = new THREE.DirectionalLight( 0xffffff, 0.8 ); light.position.set( 1, 1, 1 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); var light = new THREE.DirectionalLight( 0xffffff, 0.5 ); light.position.set( -1, -1, 1 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); root = new THREE.Group(); diff --git a/examples/webgl_loader_ply.html b/examples/webgl_loader_ply.html index ce5aab6619e49f..3336314d985957 100644 --- a/examples/webgl_loader_ply.html +++ b/examples/webgl_loader_ply.html @@ -164,6 +164,7 @@ var directionalLight = new THREE.DirectionalLight( color, intensity ); directionalLight.position.set( x, y, z ); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); directionalLight.castShadow = true; diff --git a/examples/webgl_loader_prwm.html b/examples/webgl_loader_prwm.html index 9955e93e90dbaf..f23be2cf9782cf 100644 --- a/examples/webgl_loader_prwm.html +++ b/examples/webgl_loader_prwm.html @@ -109,6 +109,7 @@ var directionalLight = new THREE.DirectionalLight( 0xffeedd ); directionalLight.position.set( 0, 0, 1 ); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); // model diff --git a/examples/webgl_loader_stl.html b/examples/webgl_loader_stl.html index c9eb33b0ba75c9..5d567160ee05d8 100644 --- a/examples/webgl_loader_stl.html +++ b/examples/webgl_loader_stl.html @@ -198,6 +198,7 @@ var directionalLight = new THREE.DirectionalLight( color, intensity ); directionalLight.position.set( x, y, z ); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); directionalLight.castShadow = true; diff --git a/examples/webgl_loader_texture_tga.html b/examples/webgl_loader_texture_tga.html index 2527dcde55d479..8a3b9259f73652 100644 --- a/examples/webgl_loader_texture_tga.html +++ b/examples/webgl_loader_texture_tga.html @@ -90,6 +90,7 @@ var light = new THREE.DirectionalLight( 0xffffff, 1 ); light.position.set( 1, 1, 1 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); // diff --git a/examples/webgl_loader_ttf.html b/examples/webgl_loader_ttf.html index 718c4e65cf0c1c..a918f661271508 100644 --- a/examples/webgl_loader_ttf.html +++ b/examples/webgl_loader_ttf.html @@ -94,6 +94,7 @@ var dirLight = new THREE.DirectionalLight( 0xffffff, 0.125 ); dirLight.position.set( 0, 0, 1 ).normalize(); + dirLight.lookAt( 0, 0, 0 ); scene.add( dirLight ); var pointLight = new THREE.PointLight( 0xffffff, 1.5 ); diff --git a/examples/webgl_loader_vrml.html b/examples/webgl_loader_vrml.html index 97da9834a20730..99b5b9b76d4042 100644 --- a/examples/webgl_loader_vrml.html +++ b/examples/webgl_loader_vrml.html @@ -71,6 +71,7 @@ var dirLight = new THREE.DirectionalLight( 0xffffff ); dirLight.position.set( 200, 200, 1000 ).normalize(); + dirLight.targeted = true; camera.add( dirLight ); camera.add( dirLight.target ); diff --git a/examples/webgl_loader_vtk.html b/examples/webgl_loader_vtk.html index bdcbfa3e582e98..d09ca99037e6bc 100644 --- a/examples/webgl_loader_vtk.html +++ b/examples/webgl_loader_vtk.html @@ -80,6 +80,7 @@ var dirLight = new THREE.DirectionalLight( 0xffffff ); dirLight.position.set( 200, 200, 1000 ).normalize(); + dirLight.targeted = true; camera.add( dirLight ); camera.add( dirLight.target ); diff --git a/examples/webgl_loader_x.html b/examples/webgl_loader_x.html index 0cf0a9c45576a3..63946813ec630a 100644 --- a/examples/webgl_loader_x.html +++ b/examples/webgl_loader_x.html @@ -136,10 +136,12 @@ var light = new THREE.DirectionalLight( 0xffffff, 1 ); light.position.set( 10, 100, - 10 ).normalize(); + light.lookAt( 0, 0, 0 ); scene.add( light ); var light2 = new THREE.DirectionalLight( 0x777666, 1 ); light2.position.set( - 1, - 1, - 1 ).normalize(); + light2.lookAt( 0, 0, 0 ); scene.add( light2 ); window.addEventListener( 'resize', onWindowResize, false ); diff --git a/examples/webgl_lod.html b/examples/webgl_lod.html index 779c729250893e..22296db6e24d7b 100644 --- a/examples/webgl_lod.html +++ b/examples/webgl_lod.html @@ -80,6 +80,7 @@ var light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 0, 0, 1 ).normalize(); + light.lookAt( 0, 0, 0 ); scene.add( light ); var geometry = [ diff --git a/examples/webgl_marchingcubes.html b/examples/webgl_marchingcubes.html index 4df773de76536b..e5f6fdb7b5a51a 100644 --- a/examples/webgl_marchingcubes.html +++ b/examples/webgl_marchingcubes.html @@ -124,6 +124,7 @@ light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 0.5, 0.5, 1 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); pointLight = new THREE.PointLight( 0xff3300 ); diff --git a/examples/webgl_materials.html b/examples/webgl_materials.html index 098c224b082de2..b7f964af0da304 100644 --- a/examples/webgl_materials.html +++ b/examples/webgl_materials.html @@ -107,6 +107,7 @@ directionalLight.position.y = Math.random() - 0.5; directionalLight.position.z = Math.random() - 0.5; directionalLight.position.normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); diff --git a/examples/webgl_materials_bumpmap.html b/examples/webgl_materials_bumpmap.html index d99d2ffb5801ee..1b3d4fad6d9e6a 100644 --- a/examples/webgl_materials_bumpmap.html +++ b/examples/webgl_materials_bumpmap.html @@ -94,6 +94,7 @@ spotLight = new THREE.SpotLight( 0xffffbb, 2 ); spotLight.position.set( 0.5, 0, 1 ); spotLight.position.multiplyScalar( 700 ); + spotLight.lookAt( 0, 0, 0 ); scene.add( spotLight ); spotLight.castShadow = true; diff --git a/examples/webgl_materials_bumpmap_skin.html b/examples/webgl_materials_bumpmap_skin.html index fc7f49e52187bb..9e078848bab8e1 100644 --- a/examples/webgl_materials_bumpmap_skin.html +++ b/examples/webgl_materials_bumpmap_skin.html @@ -105,6 +105,7 @@ directionalLight = new THREE.DirectionalLight( 0xffffff, 1 ); directionalLight.position.set( 500, 0, 500 ); + directionalLight.lookAt( 0, 0, 0 ); directionalLight.castShadow = true; diff --git a/examples/webgl_materials_cars.html b/examples/webgl_materials_cars.html index 92956f5da60b89..b04b6610bdaccb 100644 --- a/examples/webgl_materials_cars.html +++ b/examples/webgl_materials_cars.html @@ -180,10 +180,12 @@ directionalLight = new THREE.DirectionalLight( 0xffffff, 2 ); directionalLight.position.set( 2, 1.2, 10 ).normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); directionalLight = new THREE.DirectionalLight( 0xffffff, 1 ); directionalLight.position.set( -2, 1.2, -10 ).normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); pointLight = new THREE.PointLight( 0xffaa00, 2 ); diff --git a/examples/webgl_materials_compile.html b/examples/webgl_materials_compile.html index f155129843db33..074f4122d9c33c 100644 --- a/examples/webgl_materials_compile.html +++ b/examples/webgl_materials_compile.html @@ -22,7 +22,7 @@ text-align: center; display:block; } - + #waitScreen { color: #000; position: absolute; @@ -33,7 +33,7 @@ width: 100px; height: 100px; } - + .hide { display:none; } @@ -72,7 +72,7 @@ var move = false; var rtTexture, rtMaterial; var meshes = []; - + document.getElementById( "preload" ).addEventListener( 'click', function() { var hash = document.location.hash.substr( 1 ); @@ -82,7 +82,7 @@ } else { window.location.hash = "" } - + location.reload(true); }, false ); @@ -112,10 +112,12 @@ var light = new THREE.DirectionalLight( 0xffddcc, 1 ); light.position.set( 1, 0.75, 0.5 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); var light = new THREE.DirectionalLight( 0xccccff, 1 ); light.position.set( - 1, 0.75, - 0.5 ); + light.lookAt( 0, 0, 0 ); scene.add( light ); teapot = new THREE.TeapotBufferGeometry( 15, 18 ); @@ -123,14 +125,14 @@ var itemsonrow = 10; for (var i = 0 ; i< itemsonrow * itemsonrow; i ++ ){ - + var mesh = new THREE.Mesh( teapot ); - + mesh.position.x = 50 *(i%itemsonrow) -50*itemsonrow/2; - mesh.position.z = 50*Math.floor(i/itemsonrow)-150; + mesh.position.z = 50*Math.floor(i/itemsonrow)-150; updateMaterial(mesh); scene.add( mesh ); - meshes.push(mesh); + meshes.push(mesh); } window.addEventListener( 'resize', onWindowResize, false ); @@ -140,16 +142,16 @@ if ( hash.length === 0 ) { renderer.compile(scene,camera); - + } - + document.getElementById("waitScreen").className = "hide"; - + setTimeout(function() { - + onWindowResize(); animate(); - + }, 1); } @@ -205,8 +207,8 @@ mtl.color = new THREE.ColorNode( 0 ); mtl.emissive = cos; - - + + var transformer = new THREE.ExpressionNode( "position + 0.0 * " + Math.random(), "vec3", [ ]); mtl.transform = transformer; diff --git a/examples/webgl_materials_cubemap_dynamic.html b/examples/webgl_materials_cubemap_dynamic.html index 714511750b206f..d1799f78d4e699 100644 --- a/examples/webgl_materials_cubemap_dynamic.html +++ b/examples/webgl_materials_cubemap_dynamic.html @@ -162,6 +162,7 @@ spotLight = new THREE.SpotLight( 0xffffff, 1, 0, Math.PI/2 ); spotLight.position.set( 0, 1800, 1500 ); + spotLight.targeted = true; spotLight.target.position.set( 0, 0, 0 ); spotLight.castShadow = true; diff --git a/examples/webgl_materials_lightmap.html b/examples/webgl_materials_lightmap.html index a8ad805e67d4d9..9c3f8e68859d5d 100644 --- a/examples/webgl_materials_lightmap.html +++ b/examples/webgl_materials_lightmap.html @@ -98,6 +98,7 @@ light.position.x = 300; light.position.y = 250; light.position.z = -500; + light.lookAt( 0, 0, 0 ); scene.add( light ); // SKYDOME diff --git a/examples/webgl_materials_nodes.html b/examples/webgl_materials_nodes.html index 85dc81a9906cbc..d3959bf993b3aa 100644 --- a/examples/webgl_materials_nodes.html +++ b/examples/webgl_materials_nodes.html @@ -39,7 +39,7 @@ - + - \ No newline at end of file + diff --git a/examples/webgl_postprocessing_outline.html b/examples/webgl_postprocessing_outline.html index b04a3c86927184..78ea6ea7ef0363 100644 --- a/examples/webgl_postprocessing_outline.html +++ b/examples/webgl_postprocessing_outline.html @@ -169,6 +169,7 @@ var light = new THREE.DirectionalLight( 0xddffdd, 0.6 ); light.position.set( 1, 1, 1 ); + light.lookAt( 0, 0, 0 ); light.castShadow = true; diff --git a/examples/webgl_postprocessing_pixel.html b/examples/webgl_postprocessing_pixel.html index b24c1f3b52491c..96e0af4d282bf4 100644 --- a/examples/webgl_postprocessing_pixel.html +++ b/examples/webgl_postprocessing_pixel.html @@ -102,14 +102,17 @@ var dirLight = new THREE.DirectionalLight( 0xffffff, .5 ); dirLight.position.set( 150, 75, 150 ); + dirLight.lookAt( 0, 0, 0 ); scene.add( dirLight ); var dirLight2 = new THREE.DirectionalLight( 0xffffff, .2 ); dirLight2.position.set( - 150, 75, - 150 ); + dirLight2.lookAt( 0, 0, 0 ); scene.add( dirLight2 ); var dirLight3 = new THREE.DirectionalLight( 0xffffff, .1 ); dirLight3.position.set( 0, 125, 0 ); + dirLight3.lookAt( 0, 0, 0 ); scene.add( dirLight3 ); var geometries = [ diff --git a/examples/webgl_read_float_buffer.html b/examples/webgl_read_float_buffer.html index bbbdf9f3683df9..8d737ac25039ce 100644 --- a/examples/webgl_read_float_buffer.html +++ b/examples/webgl_read_float_buffer.html @@ -118,10 +118,12 @@ var light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 0, 0, 1 ).normalize(); + light.lookAt( 0, 0, 0 ); sceneRTT.add( light ); light = new THREE.DirectionalLight( 0xffaaaa, 1.5 ); light.position.set( 0, 0, - 1 ).normalize(); + light.lookAt( 0, 0, 0 ); sceneRTT.add( light ); rtTexture = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, { minFilter: THREE.LinearFilter, magFilter: THREE.NearestFilter, format: THREE.RGBAFormat, type: THREE.FloatType } ); diff --git a/examples/webgl_rtt.html b/examples/webgl_rtt.html index c4f4df867f1299..b6857c91a3ed90 100644 --- a/examples/webgl_rtt.html +++ b/examples/webgl_rtt.html @@ -121,10 +121,12 @@ var light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 0, 0, 1 ).normalize(); + light.lookAt( 0, 0, 0 ); sceneRTT.add( light ); light = new THREE.DirectionalLight( 0xffaaaa, 1.5 ); light.position.set( 0, 0, -1 ).normalize(); + light.lookAt( 0, 0, 0 ); sceneRTT.add( light ); rtTexture = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, { minFilter: THREE.LinearFilter, magFilter: THREE.NearestFilter, format: THREE.RGBFormat } ); diff --git a/examples/webgl_shaders_tonemapping.html b/examples/webgl_shaders_tonemapping.html index fc07d2b21476ac..42f885b80c4987 100644 --- a/examples/webgl_shaders_tonemapping.html +++ b/examples/webgl_shaders_tonemapping.html @@ -128,6 +128,7 @@ directionalLight = new THREE.DirectionalLight( 0xffffff, params.sunLight ); directionalLight.position.set( 2, 0, 10 ).normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); var atmoShader = { diff --git a/examples/webgl_shading_physical.html b/examples/webgl_shading_physical.html index 38812390ca4573..d19f9ba1fbb528 100644 --- a/examples/webgl_shading_physical.html +++ b/examples/webgl_shading_physical.html @@ -244,6 +244,7 @@ sunLight = new THREE.SpotLight( 0xffffff, 0.3, 0, Math.PI/2 ); sunLight.position.set( 1000, 2000, 1000 ); + sunLight.lookAt( 0, 0, 0 ); sunLight.castShadow = true; diff --git a/examples/webgl_shadowmap.html b/examples/webgl_shadowmap.html index b44db405cfb89b..c15cb6c223770b 100644 --- a/examples/webgl_shadowmap.html +++ b/examples/webgl_shadowmap.html @@ -108,7 +108,7 @@ light = new THREE.SpotLight( 0xffffff, 1, 0, Math.PI / 2 ); light.position.set( 0, 1500, 1000 ); - light.target.position.set( 0, 0, 0 ); + light.lookAt( 0, 0, 0 ); light.castShadow = true; diff --git a/examples/webgl_shadowmap_pcss.html b/examples/webgl_shadowmap_pcss.html index df110cb41deb0b..64d711ce37ec5c 100644 --- a/examples/webgl_shadowmap_pcss.html +++ b/examples/webgl_shadowmap_pcss.html @@ -167,6 +167,7 @@ var light = new THREE.DirectionalLight( 0xdfebff, 1.75 ); light.position.set( 2, 8, 4 ); + light.lookAt( 0, 0, 0 ); light.castShadow = true; light.shadow.mapSize.width = 1024; diff --git a/examples/webgl_shadowmap_performance.html b/examples/webgl_shadowmap_performance.html index 1531ef44c6982a..9fcfc0f429822a 100644 --- a/examples/webgl_shadowmap_performance.html +++ b/examples/webgl_shadowmap_performance.html @@ -103,7 +103,7 @@ light = new THREE.SpotLight( 0xffffff, 1, 0, Math.PI/2 ); light.position.set( 0, 1500, 1000 ); - light.target.position.set( 0, 0, 0 ); + light.lookAt( 0, 0, 0 ); light.castShadow = true; diff --git a/examples/webgl_shadowmap_viewer.html b/examples/webgl_shadowmap_viewer.html index 9fdad005223477..35aba263953db9 100644 --- a/examples/webgl_shadowmap_viewer.html +++ b/examples/webgl_shadowmap_viewer.html @@ -43,6 +43,7 @@ var dirLight, spotLight; var torusKnot, cube; var dirLightShadowMapViewer, spotLightShadowMapViewer; + var helpers; init(); animate(); @@ -65,6 +66,8 @@ camera.position.set( 0, 15, 35 ); scene = new THREE.Scene(); + helpers = new THREE.Group(); + scene.add( helpers ); // Lights @@ -74,19 +77,22 @@ spotLight.name = 'Spot Light'; spotLight.angle = Math.PI / 5; spotLight.penumbra = 0.3; - spotLight.position.set( 10, 10, 5 ); + spotLight.position.set( 2, 2, 2 ); + spotLight.lookAt( 0, 0, 0 ); spotLight.castShadow = true; - spotLight.shadow.camera.near = 8; - spotLight.shadow.camera.far = 30; + spotLight.shadow.camera.near = 0.5; + spotLight.shadow.camera.far = 40; spotLight.shadow.mapSize.width = 1024; spotLight.shadow.mapSize.height = 1024; - scene.add( spotLight ); - scene.add( new THREE.CameraHelper( spotLight.shadow.camera ) ); + + helpers.add( new THREE.CameraHelper( spotLight.shadow.camera ) ); + helpers.add( new THREE.SpotLightHelper( spotLight ) ); dirLight = new THREE.DirectionalLight( 0xffffff, 1 ); dirLight.name = 'Dir. Light'; dirLight.position.set( 0, 10, 0 ); + dirLight.lookAt( 0, 0, 0 ); dirLight.castShadow = true; dirLight.shadow.camera.near = 1; dirLight.shadow.camera.far = 10; @@ -98,7 +104,8 @@ dirLight.shadow.mapSize.height = 1024; scene.add( dirLight ); - scene.add( new THREE.CameraHelper( dirLight.shadow.camera ) ); + helpers.add( new THREE.CameraHelper( dirLight.shadow.camera ) ); + helpers.add( new THREE.DirectionalLightHelper( dirLight ) ); // Geometry var geometry = new THREE.TorusKnotBufferGeometry( 25, 8, 75, 20 ); @@ -115,6 +122,7 @@ torusKnot.receiveShadow = true; scene.add( torusKnot ); + var geometry = new THREE.BoxBufferGeometry( 3, 3, 3 ); cube = new THREE.Mesh( geometry, material ); cube.position.set( 8, 3, 8 ); @@ -122,6 +130,18 @@ cube.receiveShadow = true; scene.add( cube ); + var geometry = new THREE.BoxBufferGeometry( 1, 1, 1 ); + target = new THREE.Mesh( geometry, material ); + target.scale.multiplyScalar( 18 ); + target.position.set( 30, 30, 30 ); + target.castShadow = true; + target.receiveShadow = true; + torusKnot.add( target ); + + spotLight.target = target; + spotLight.targeted = true; + cube.add( spotLight ); + var geometry = new THREE.BoxBufferGeometry( 10, 0.15, 10 ); var material = new THREE.MeshPhongMaterial( { color: 0xa0adaf, @@ -196,6 +216,7 @@ function renderScene() { + helpers.traverse( function( helper ) { if ( helper.update ) helper.update(); }); renderer.render( scene, camera ); } @@ -215,8 +236,8 @@ renderShadowMapViewers(); torusKnot.rotation.x += 0.25 * delta; - torusKnot.rotation.y += 2 * delta; - torusKnot.rotation.z += 1 * delta; + torusKnot.rotation.y += 1 * delta; + torusKnot.rotation.z += 2 * delta; cube.rotation.x += 0.25 * delta; cube.rotation.y += 2 * delta; diff --git a/examples/webgl_terrain_dynamic.html b/examples/webgl_terrain_dynamic.html index 7ebc57dcb5e73c..cf76eba042c7af 100644 --- a/examples/webgl_terrain_dynamic.html +++ b/examples/webgl_terrain_dynamic.html @@ -276,6 +276,7 @@ directionalLight = new THREE.DirectionalLight( 0xffffff, 1.15 ); directionalLight.position.set( 500, 2000, 0 ); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); pointLight = new THREE.PointLight( 0xff4400, 1.5 ); diff --git a/examples/webgl_tonemapping.html b/examples/webgl_tonemapping.html index eb7a75e32bc639..149acb4f0010b1 100644 --- a/examples/webgl_tonemapping.html +++ b/examples/webgl_tonemapping.html @@ -179,6 +179,7 @@ var spotLight = new THREE.SpotLight( 0xffffff ); spotLight.position.set( 50, 100, 50 ); + spotLight.lookAt( 0, 0, 0 ); spotLight.angle = Math.PI / 7; spotLight.decay = 2; spotLight.distance = 300; diff --git a/examples/webgl_water.html b/examples/webgl_water.html index 8c093ee8ba9528..0bdad83b17b76e 100644 --- a/examples/webgl_water.html +++ b/examples/webgl_water.html @@ -154,6 +154,7 @@ var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.6 ); directionalLight.position.set( - 1, 1, 1 ); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); // renderer diff --git a/examples/webgldeferred_animation.html b/examples/webgldeferred_animation.html index e1431580b620ef..2ec1a1d41963ca 100644 --- a/examples/webgldeferred_animation.html +++ b/examples/webgldeferred_animation.html @@ -162,10 +162,12 @@ var directionalLight = new THREE.DirectionalLight( 0x101010 ); directionalLight.position.set( -1, 1, 1 ).normalize(); + directionalLight.lookAt( 0, 0, 0 ); scene.add( directionalLight ); var spotLight = new THREE.SpotLight( 0x404040 ); spotLight.position.set( 0, 50, 0 ); + spotLight.lookAt( 0, 0, 0 ); scene.add( spotLight ); } diff --git a/examples/webvr_ballshooter.html b/examples/webvr_ballshooter.html index c6e87a7c05bffa..6edad52d05a6c4 100644 --- a/examples/webvr_ballshooter.html +++ b/examples/webvr_ballshooter.html @@ -72,6 +72,7 @@ var light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 1, 1, 1 ).normalize(); + light.lookAt( 0, 0, 0 ); scene.add( light ); var geometry = new THREE.IcosahedronBufferGeometry( radius, 2 ); diff --git a/examples/webvr_cubes.html b/examples/webvr_cubes.html index 711e6247511acd..432ab4072aa2aa 100644 --- a/examples/webvr_cubes.html +++ b/examples/webvr_cubes.html @@ -86,6 +86,7 @@ var light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 1, 1, 1 ).normalize(); + light.lookAt( 0, 0, 0 ); scene.add( light ); var geometry = new THREE.BoxBufferGeometry( 0.15, 0.15, 0.15 ); diff --git a/examples/webvr_dragging.html b/examples/webvr_dragging.html index b2b561accc5b37..ca08c1f81af70a 100644 --- a/examples/webvr_dragging.html +++ b/examples/webvr_dragging.html @@ -75,6 +75,7 @@ var light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 0, 6, 0 ); + light.lookAt( 0, 0, 0 ); light.castShadow = true; light.shadow.camera.top = 2; light.shadow.camera.bottom = -2; diff --git a/examples/webvr_paint.html b/examples/webvr_paint.html index 187813ece49f00..5a0af470f31eda 100644 --- a/examples/webvr_paint.html +++ b/examples/webvr_paint.html @@ -111,6 +111,7 @@ var light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 0, 6, 0 ); + light.lookAt( 0, 0, 0 ); light.castShadow = true; light.shadow.camera.top = 2; light.shadow.camera.bottom = -2; diff --git a/examples/webvr_sandbox.html b/examples/webvr_sandbox.html index f3414586d0f8df..e53267fb77961e 100644 --- a/examples/webvr_sandbox.html +++ b/examples/webvr_sandbox.html @@ -67,22 +67,20 @@ var light = new THREE.DirectionalLight( 0x8800ff ); light.position.set( - 1, 1.5, - 1.5 ); + light.lookAt( 0, 0, - 2 ); 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, - 2.5 ); + light.lookAt( 0, 0, - 2 ); 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 ); diff --git a/examples/webvr_sculpt.html b/examples/webvr_sculpt.html index 4d7e2a811dfc28..cc92c0dc3700ac 100644 --- a/examples/webvr_sculpt.html +++ b/examples/webvr_sculpt.html @@ -93,6 +93,7 @@ var light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 0, 6, 0 ); + light.lookAt( 0, 0, 0 ); light.castShadow = true; light.shadow.camera.top = 2; light.shadow.camera.bottom = -2; diff --git a/examples/webvr_vive_paint.html b/examples/webvr_vive_paint.html index b947b1d3caab0b..574b562838e8b7 100644 --- a/examples/webvr_vive_paint.html +++ b/examples/webvr_vive_paint.html @@ -114,6 +114,7 @@ var light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 0, 6, 0 ); + light.lookAt( 0, 0, 0 ); light.castShadow = true; light.shadow.camera.top = 2; light.shadow.camera.bottom = -2; diff --git a/examples/webvr_vive_sculpt.html b/examples/webvr_vive_sculpt.html index aa9f65452b6a6a..93ffbe0c83f5b5 100644 --- a/examples/webvr_vive_sculpt.html +++ b/examples/webvr_vive_sculpt.html @@ -95,6 +95,7 @@ var light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 0, 6, 0 ); + light.lookAt( 0, 0, 0 ); light.castShadow = true; light.shadow.camera.top = 2; light.shadow.camera.bottom = -2; diff --git a/src/helpers/DirectionalLightHelper.js b/src/helpers/DirectionalLightHelper.js index e920d5378e0f48..ae6e89462f614e 100644 --- a/src/helpers/DirectionalLightHelper.js +++ b/src/helpers/DirectionalLightHelper.js @@ -4,7 +4,6 @@ * @author WestLangley / http://github.com/WestLangley */ -import { Vector3 } from '../math/Vector3.js'; import { Object3D } from '../core/Object3D.js'; import { Line } from '../objects/Line.js'; import { Float32BufferAttribute } from '../core/BufferAttribute.js'; @@ -18,7 +17,6 @@ function DirectionalLightHelper( light, size, color ) { this.light = light; this.light.updateMatrixWorld(); - this.matrix = light.matrixWorld; this.matrixAutoUpdate = false; this.color = color; @@ -40,7 +38,7 @@ function DirectionalLightHelper( light, size, color ) { this.add( this.lightPlane ); geometry = new BufferGeometry(); - geometry.addAttribute( 'position', new Float32BufferAttribute( [ 0, 0, 0, 0, 0, 1 ], 3 ) ); + geometry.addAttribute( 'position', new Float32BufferAttribute( [ 0, 0, 0, 0, 0, - 1 ], 3 ) ); this.targetLine = new Line( geometry, material ); this.add( this.targetLine ); @@ -63,36 +61,22 @@ DirectionalLightHelper.prototype.dispose = function () { DirectionalLightHelper.prototype.update = function () { - var v1 = new Vector3(); - var v2 = new Vector3(); - var v3 = new Vector3(); + this.matrix.copy( this.light.shadow.camera.matrixWorld ); + this.matrix.multiply( this.light.shadow.camera.projectionMatrixInverse ); - return function update() { + if ( this.color !== undefined ) { - v1.setFromMatrixPosition( this.light.matrixWorld ); - v2.setFromMatrixPosition( this.light.target.matrixWorld ); - v3.subVectors( v2, v1 ); + this.lightPlane.material.color.set( this.color ); + this.targetLine.material.color.set( this.color ); - this.lightPlane.lookAt( v3 ); + } else { - if ( this.color !== undefined ) { + this.lightPlane.material.color.copy( this.light.color ); + this.targetLine.material.color.copy( this.light.color ); - this.lightPlane.material.color.set( this.color ); - this.targetLine.material.color.set( this.color ); + } - } else { - - this.lightPlane.material.color.copy( this.light.color ); - this.targetLine.material.color.copy( this.light.color ); - - } - - this.targetLine.lookAt( v3 ); - this.targetLine.scale.z = v3.length(); - - }; - -}(); +}; export { DirectionalLightHelper }; diff --git a/src/helpers/SpotLightHelper.js b/src/helpers/SpotLightHelper.js index 4d006d88b769d4..844b8f35b25ed4 100644 --- a/src/helpers/SpotLightHelper.js +++ b/src/helpers/SpotLightHelper.js @@ -4,7 +4,6 @@ * @author WestLangley / http://github.com/WestLangley */ -import { Vector3 } from '../math/Vector3.js'; import { Object3D } from '../core/Object3D.js'; import { LineSegments } from '../objects/LineSegments.js'; import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; @@ -18,7 +17,6 @@ function SpotLightHelper( light, color ) { this.light = light; this.light.updateMatrixWorld(); - this.matrix = light.matrixWorld; this.matrixAutoUpdate = false; this.color = color; @@ -26,11 +24,11 @@ function SpotLightHelper( light, color ) { var geometry = new BufferGeometry(); var positions = [ - 0, 0, 0, 0, 0, 1, - 0, 0, 0, 1, 0, 1, - 0, 0, 0, - 1, 0, 1, - 0, 0, 0, 0, 1, 1, - 0, 0, 0, 0, - 1, 1 + 0, 0, 1, 0, 0, - 1, + 1, 0, 1, 1, 0, - 1, + - 1, 0, 1, - 1, 0, - 1, + 0, 1, 1, 0, 1, - 1, + 0, - 1, 1, 0, - 1, - 1 ]; for ( var i = 0, j = 1, l = 32; i < l; i ++, j ++ ) { @@ -39,6 +37,8 @@ function SpotLightHelper( light, color ) { var p2 = ( j / l ) * Math.PI * 2; positions.push( + Math.cos( p1 ), Math.sin( p1 ), - 1, + Math.cos( p2 ), Math.sin( p2 ), - 1, Math.cos( p1 ), Math.sin( p1 ), 1, Math.cos( p2 ), Math.sin( p2 ), 1 ); @@ -68,36 +68,20 @@ SpotLightHelper.prototype.dispose = function () { SpotLightHelper.prototype.update = function () { - var vector = new Vector3(); - var vector2 = new Vector3(); + this.matrix.copy( this.light.shadow.camera.matrixWorld ); + this.matrix.multiply( this.light.shadow.camera.projectionMatrixInverse ); - return function update() { + if ( this.color !== undefined ) { - this.light.updateMatrixWorld(); + this.cone.material.color.set( this.color ); - var coneLength = this.light.distance ? this.light.distance : 1000; - var coneWidth = coneLength * Math.tan( this.light.angle ); + } else { - this.cone.scale.set( coneWidth, coneWidth, coneLength ); + this.cone.material.color.copy( this.light.color ); - vector.setFromMatrixPosition( this.light.matrixWorld ); - vector2.setFromMatrixPosition( this.light.target.matrixWorld ); - - this.cone.lookAt( vector2.sub( vector ) ); - - if ( this.color !== undefined ) { - - this.cone.material.color.set( this.color ); - - } else { - - this.cone.material.color.copy( this.light.color ); - - } - - }; + } -}(); +}; export { SpotLightHelper }; diff --git a/src/lights/DirectionalLight.js b/src/lights/DirectionalLight.js index 396a2a2282cb14..5359531662520a 100644 --- a/src/lights/DirectionalLight.js +++ b/src/lights/DirectionalLight.js @@ -17,6 +17,7 @@ function DirectionalLight( color, intensity ) { this.updateMatrix(); this.target = new Object3D(); + this.targeted = false; this.shadow = new DirectionalLightShadow(); diff --git a/src/lights/SpotLight.js b/src/lights/SpotLight.js index 90d891af10d6aa..15b72a7bf1ca78 100644 --- a/src/lights/SpotLight.js +++ b/src/lights/SpotLight.js @@ -16,6 +16,7 @@ function SpotLight( color, intensity, distance, angle, penumbra, decay ) { this.updateMatrix(); this.target = new Object3D(); + this.targeted = false; Object.defineProperty( this, 'power', { get: function () { diff --git a/src/renderers/webgl/WebGLLights.js b/src/renderers/webgl/WebGLLights.js index 217611d753f6aa..1adc73ea97f942 100644 --- a/src/renderers/webgl/WebGLLights.js +++ b/src/renderers/webgl/WebGLLights.js @@ -135,7 +135,6 @@ function WebGLLights() { }; - var vector3 = new Vector3(); var matrix4 = new Matrix4(); var matrix42 = new Matrix4(); @@ -172,9 +171,8 @@ function WebGLLights() { var uniforms = cache.get( light ); uniforms.color.copy( light.color ).multiplyScalar( light.intensity ); - uniforms.direction.setFromMatrixPosition( light.matrixWorld ); - vector3.setFromMatrixPosition( light.target.matrixWorld ); - uniforms.direction.sub( vector3 ); + uniforms.direction.set( 0, 0, 1 ); + uniforms.direction.transformDirection( light.shadow.camera.matrixWorld ); uniforms.direction.transformDirection( viewMatrix ); uniforms.shadow = light.castShadow; @@ -205,9 +203,8 @@ function WebGLLights() { uniforms.color.copy( color ).multiplyScalar( intensity ); uniforms.distance = distance; - uniforms.direction.setFromMatrixPosition( light.matrixWorld ); - vector3.setFromMatrixPosition( light.target.matrixWorld ); - uniforms.direction.sub( vector3 ); + uniforms.direction.set( 0, 0, 1 ); + uniforms.direction.transformDirection( light.shadow.camera.matrixWorld ); uniforms.direction.transformDirection( viewMatrix ); uniforms.coneCos = Math.cos( light.angle ); diff --git a/src/renderers/webgl/WebGLShadowMap.js b/src/renderers/webgl/WebGLShadowMap.js index 6c144640d854e5..f412d891067ee7 100644 --- a/src/renderers/webgl/WebGLShadowMap.js +++ b/src/renderers/webgl/WebGLShadowMap.js @@ -22,7 +22,6 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { _maxShadowMapSize = new Vector2( maxTextureSize, maxTextureSize ), _lookTarget = new Vector3(), - _lightPositionWorld = new Vector3(), _MorphingFlag = 1, _SkinningFlag = 2, @@ -36,6 +35,8 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { var shadowSide = { 0: BackSide, 1: FrontSide, 2: DoubleSide }; + var cameraConvention = new Vector3( - 1, 1, - 1 ); + var cubeDirections = [ new Vector3( 1, 0, 0 ), new Vector3( - 1, 0, 0 ), new Vector3( 0, 0, 1 ), new Vector3( 0, 0, - 1 ), new Vector3( 0, 1, 0 ), new Vector3( 0, - 1, 0 ) @@ -188,8 +189,7 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { var shadowMap = shadow.map; var shadowMatrix = shadow.matrix; - _lightPositionWorld.setFromMatrixPosition( light.matrixWorld ); - shadowCamera.position.copy( _lightPositionWorld ); + shadowCamera.position.setFromMatrixPosition( light.matrixWorld ); if ( isPointLight ) { @@ -198,15 +198,25 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { // for point lights we set the shadow matrix to be a translation-only matrix // equal to inverse of the light's position - shadowMatrix.makeTranslation( - _lightPositionWorld.x, - _lightPositionWorld.y, - _lightPositionWorld.z ); + shadowMatrix.makeTranslation( - shadowCamera.position.x, - shadowCamera.position.y, - shadowCamera.position.z ); } else { faceCount = 1; - _lookTarget.setFromMatrixPosition( light.target.matrixWorld ); - shadowCamera.lookAt( _lookTarget ); - shadowCamera.updateMatrixWorld(); + if ( light.targeted ) { + + _lookTarget.setFromMatrixPosition( light.target.matrixWorld ); + shadowCamera.lookAt( _lookTarget ); + shadowCamera.updateMatrixWorld(); + + } else if ( shadowCamera.matrixAutoUpdate ) { + + shadowCamera.matrixWorld.copy( light.matrixWorld ).scale( cameraConvention ); + shadowCamera.matrixWorldInverse.getInverse( shadowCamera.matrixWorld ); + shadowCamera.matrixWorldNeedsUpdate = false; + + } // compute shadow matrix @@ -250,7 +260,7 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { // set object matrices & frustum culling - renderObject( scene, camera, shadowCamera, isPointLight ); + renderObject( scene, camera, isPointLight, shadowCamera ); } @@ -260,7 +270,7 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { }; - function getDepthMaterial( object, material, isPointLight, lightPositionWorld, shadowCameraNear, shadowCameraFar ) { + function getDepthMaterial( object, material, isPointLight, shadowCamera ) { var geometry = object.geometry; @@ -360,9 +370,9 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { if ( isPointLight && result.isMeshDistanceMaterial ) { - result.referencePosition.copy( lightPositionWorld ); - result.nearDistance = shadowCameraNear; - result.farDistance = shadowCameraFar; + result.referencePosition.copy( shadowCamera.position ); + result.nearDistance = shadowCamera.near; + result.farDistance = shadowCamera.far; } @@ -370,7 +380,7 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { } - function renderObject( object, camera, shadowCamera, isPointLight ) { + function renderObject( object, camera, isPointLight, shadowCamera ) { if ( object.visible === false ) return; @@ -396,7 +406,7 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { if ( groupMaterial && groupMaterial.visible ) { - var depthMaterial = getDepthMaterial( object, groupMaterial, isPointLight, _lightPositionWorld, shadowCamera.near, shadowCamera.far ); + var depthMaterial = getDepthMaterial( object, groupMaterial, isPointLight, shadowCamera ); _renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group ); } @@ -405,7 +415,7 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { } else if ( material.visible ) { - var depthMaterial = getDepthMaterial( object, material, isPointLight, _lightPositionWorld, shadowCamera.near, shadowCamera.far ); + var depthMaterial = getDepthMaterial( object, material, isPointLight, shadowCamera ); _renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null ); } @@ -418,7 +428,7 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { for ( var i = 0, l = children.length; i < l; i ++ ) { - renderObject( children[ i ], camera, shadowCamera, isPointLight ); + renderObject( children[ i ], camera, isPointLight, shadowCamera ); }