浏览代码

better color parameter check

Lewy Blue 8 年之前
父节点
当前提交
6c4344c54c

+ 12 - 4
src/helpers/DirectionalLightHelper.js

@@ -74,13 +74,21 @@ DirectionalLightHelper.prototype.update = function () {
 		v3.subVectors( v2, v1 );
 
 		this.lightPlane.lookAt( v3 );
-		if ( ! this.color ) this.lightPlane.material.color.copy( this.light.color );
-		else this.lightPlane.material.color.set( this.color );
+
+		if ( this.color !== undefined ) {
+
+			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();
-		if ( ! this.color ) this.targetLine.material.color.copy( this.light.color );
-		else this.targetLine.material.color.set( this.color );
 
 	};
 

+ 2 - 2
src/helpers/HemisphereLightHelper.js

@@ -29,7 +29,7 @@ function HemisphereLightHelper( light, size, color ) {
 	geometry.rotateY( Math.PI * 0.5 );
 
 	this.material = new MeshBasicMaterial( { wireframe: true, fog: false, color: this.color } );
-	if ( ! color ) this.material.vertexColors = VertexColors;
+	if ( this.color === undefined ) this.material.vertexColors = VertexColors;
 
 	var position = geometry.getAttribute( 'position' );
 	var colors = new Float32Array( position.count * 3 );
@@ -63,7 +63,7 @@ HemisphereLightHelper.prototype.update = function () {
 
 		var mesh = this.children[ 0 ];
 
-		if ( this.color ) {
+		if ( this.color !== undefined ) {
 
 			this.material.color.set( this.color );
 

+ 9 - 2
src/helpers/PointLightHelper.js

@@ -61,8 +61,15 @@ PointLightHelper.prototype.dispose = function () {
 
 PointLightHelper.prototype.update = function () {
 
-	if ( ! this.color ) this.material.color.copy( this.light.color );
-	else this.material.color.set( this.color );
+	if ( this.color !== undefined ) {
+
+		this.material.color.set( this.color );
+
+	} else {
+
+		this.material.color.copy( this.light.color );
+
+	}
 
 	/*
 	var d = this.light.distance;

+ 9 - 2
src/helpers/RectAreaLightHelper.js

@@ -66,8 +66,15 @@ RectAreaLightHelper.prototype.update = function () {
 
 	position.needsUpdate = true;
 
-	if ( ! this.color ) this.line.material.color.copy( this.light.color );
-	else this.line.material.color.set( this.color );
+	if ( this.color !== undefined ) {
+
+		this.line.material.color.set( this.color );
+
+	} else {
+
+		this.line.material.color.copy( this.light.color );
+
+	}
 
 };
 

+ 9 - 2
src/helpers/SpotLightHelper.js

@@ -85,8 +85,15 @@ SpotLightHelper.prototype.update = function () {
 
 		this.cone.lookAt( vector2.sub( vector ) );
 
-		if ( ! this.color ) this.cone.material.color.copy( this.light.color );
-		else this.cone.material.color.set( this.color );
+		if ( this.color !== undefined ) {
+
+			this.cone.material.color.set( this.color );
+
+		} else {
+
+			this.cone.material.color.copy( this.light.color );
+
+		}
 
 	};