浏览代码

SpotLight.angle and SpotlightHelper cone size bug fixes

WestLangley 12 年之前
父节点
当前提交
46a2244660

+ 2 - 2
docs/api/lights/SpotLight.html

@@ -67,8 +67,8 @@ scene.add( spotLight );</code>
 	
 		<h3>.[page:Float angle]</h3>
 		<div>
-			Maximum extent of the spotlight, in radians, from its direction.<br />
-			Default — *Math.PI/2*.
+			Maximum extent of the spotlight, in radians, from its direction. Should be no more than *Math.PI/2*.<br />
+			Default — *Math.PI/3*.
 		</div>
 	
 		<h3>.[page:Float exponent]</h3>

+ 1 - 1
examples/webgl_loader_ctm.html

@@ -99,7 +99,7 @@
 				var ambient = new THREE.AmbientLight( 0x080808 );
 				//scene.add( ambient );
 
-				var light = new THREE.SpotLight( 0xffeedd, 1.2, 650, 2.5, 3 );
+				var light = new THREE.SpotLight( 0xffeedd, 1.2, 650, Math.PI/2, 3 );
 				light.position.set( 0, -100, 500 );
 
 				light.castShadow = true;

+ 1 - 1
examples/webgl_materials_cubemap_dynamic.html

@@ -170,7 +170,7 @@
 				ambientLight = new THREE.AmbientLight( 0x555555 );
 				scene.add( ambientLight );
 
-				spotLight = new THREE.SpotLight( 0xffffff, 1, 0, Math.PI, 1 );
+				spotLight = new THREE.SpotLight( 0xffffff, 1, 0, Math.PI/2, 1 );
 				spotLight.position.set( 0, 1800, 1500 );
 				spotLight.target.position.set( 0, 0, 0 );
 				spotLight.castShadow = true;

+ 1 - 1
examples/webgl_shading_physical.html

@@ -316,7 +316,7 @@
 				pointLight.position.set( 0, 0, 0 );
 				scene.add( pointLight );
 
-				sunLight = new THREE.SpotLight( 0xffffff, sunIntensity, 0, Math.PI, 1 );
+				sunLight = new THREE.SpotLight( 0xffffff, sunIntensity, 0, Math.PI/2, 1 );
 				sunLight.position.set( 1000, 2000, 1000 );
 
 				sunLight.castShadow = true;

+ 1 - 1
examples/webgl_shadowmap_performance.html

@@ -103,7 +103,7 @@
 				var ambient = new THREE.AmbientLight( 0x444444 );
 				scene.add( ambient );
 
-				light = new THREE.SpotLight( 0xffffff, 1, 0, Math.PI, 1 );
+				light = new THREE.SpotLight( 0xffffff, 1, 0, Math.PI/2, 1 );
 				light.position.set( 0, 1500, 1000 );
 				light.target.position.set( 0, 0, 0 );
 

+ 4 - 3
src/extras/helpers/SpotLightHelper.js

@@ -1,7 +1,8 @@
 /**
  * @author alteredq / http://alteredqualia.com/
  * @author mrdoob / http://mrdoob.com/
- */
+ * @author WestLangley / http://github.com/WestLangley
+*/
 
 THREE.SpotLightHelper = function ( light, sphereSize ) {
 
@@ -31,7 +32,7 @@ THREE.SpotLightHelper = function ( light, sphereSize ) {
 	this.lightCone.position = this.light.position;
 
 	var coneLength = light.distance ? light.distance : 10000;
-	var coneWidth = coneLength * Math.tan( light.angle * 0.5 ) * 2;
+	var coneWidth = coneLength * Math.tan( light.angle );
 
 	this.lightCone.scale.set( coneWidth, coneWidth, coneLength );
 	this.lightCone.lookAt( this.light.target.position );
@@ -45,7 +46,7 @@ THREE.SpotLightHelper.prototype = Object.create( THREE.Object3D.prototype );
 THREE.SpotLightHelper.prototype.update = function () {
 
 	var coneLength = this.light.distance ? this.light.distance : 10000;
-	var coneWidth = coneLength * Math.tan( this.light.angle * 0.5 ) * 2;
+	var coneWidth = coneLength * Math.tan( this.light.angle );
 
 	this.lightCone.scale.set( coneWidth, coneWidth, coneLength );
 	this.lightCone.lookAt( this.light.target.position );

+ 1 - 1
src/lights/SpotLight.js

@@ -11,7 +11,7 @@ THREE.SpotLight = function ( hex, intensity, distance, angle, exponent ) {
 
 	this.intensity = ( intensity !== undefined ) ? intensity : 1;
 	this.distance = ( distance !== undefined ) ? distance : 0;
-	this.angle = ( angle !== undefined ) ? angle : Math.PI / 2;
+	this.angle = ( angle !== undefined ) ? angle : Math.PI / 3;
 	this.exponent = ( exponent !== undefined ) ? exponent : 10;
 
 	this.castShadow = false;