Browse Source

Fix bug in SpotLightHelper

Same as in DirectionalLightHelper
Oliver Sand 12 years ago
parent
commit
6277839608
1 changed files with 17 additions and 7 deletions
  1. 17 7
      src/extras/helpers/SpotLightHelper.js

+ 17 - 7
src/extras/helpers/SpotLightHelper.js

@@ -91,6 +91,11 @@ THREE.SpotLightHelper = function ( light, sphereSize ) {
 		this.targetLine = new THREE.Line( lineGeometry, lineMaterial );
 		this.targetLine.properties.isGizmo = true;
 
+	}
+	else {
+
+		this.targetSphere = null;
+
 	}
 
 	//
@@ -127,15 +132,20 @@ THREE.SpotLightHelper.prototype.update = function () {
 	this.lightRays.material.color.copy( this.color );
 	this.lightCone.material.color.copy( this.color );
 
-	this.targetSphere.material.color.copy( this.color );
-	this.targetLine.material.color.copy( this.color );
+	// Only update targetSphere and targetLine if available
+	if ( this.targetSphere ) {
 
-	// update target line vertices
+		this.targetSphere.material.color.copy( this.color );
+		this.targetLine.material.color.copy( this.color );
 
-	this.targetLine.geometry.vertices[ 0 ].copy( this.light.position );
-	this.targetLine.geometry.vertices[ 1 ].copy( this.light.target.position );
+		// update target line vertices
 
-	this.targetLine.geometry.computeLineDistances();
-	this.targetLine.geometry.verticesNeedUpdate = true;
+		this.targetLine.geometry.vertices[ 0 ].copy( this.light.position );
+		this.targetLine.geometry.vertices[ 1 ].copy( this.light.target.position );
+
+		this.targetLine.geometry.computeLineDistances();
+		this.targetLine.geometry.verticesNeedUpdate = true;
+	
+	}
 
 };