Преглед на файлове

Fix bug in DirectionalLightHelper

If light.target.properties.targetInverse is false, no targetLine and
targetSphere is created, we can't update their values on update()!
Oliver Sand преди 12 години
родител
ревизия
82dd6c5a23
променени са 1 файла, в които са добавени 17 реда и са изтрити 7 реда
  1. 17 7
      src/extras/helpers/DirectionalLightHelper.js

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

@@ -72,6 +72,11 @@ THREE.DirectionalLightHelper = function ( light, sphereSize ) {
 		this.targetLine = new THREE.Line( lineGeometry, lineMaterial );
 		this.targetLine.properties.isGizmo = true;
 
+	}
+	else {
+
+		this.targetSphere = null;
+
 	}
 
 	//
@@ -99,16 +104,21 @@ THREE.DirectionalLightHelper.prototype.update = function () {
 	this.lightSphere.material.color.copy( this.color );
 	this.lightRays.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;
+
+	}
 
 }