Browse Source

Added overrideColor to RectAreaLightHelper

Lewy Blue 8 years ago
parent
commit
5629e8cac3
1 changed files with 10 additions and 11 deletions
  1. 10 11
      src/helpers/RectAreaLightHelper.js

+ 10 - 11
src/helpers/RectAreaLightHelper.js

@@ -5,13 +5,12 @@
  */
 
 import { Object3D } from '../core/Object3D';
-import { Vector3 } from '../math/Vector3';
 import { Line } from '../objects/Line';
 import { LineBasicMaterial } from '../materials/LineBasicMaterial';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { BufferAttribute } from '../core/BufferAttribute';
 
-function RectAreaLightHelper( light ) {
+function RectAreaLightHelper( light, overrideColor ) {
 
 	Object3D.call( this );
 
@@ -21,13 +20,17 @@ function RectAreaLightHelper( light ) {
 	this.matrix = light.matrixWorld;
 	this.matrixAutoUpdate = false;
 
-	var material = new LineBasicMaterial( { color: light.color } );
+	this.overrideColor = overrideColor;
+
+	var material = new LineBasicMaterial( { fog: false, color: this.overrideColor } );
 
 	var geometry = new BufferGeometry();
 
 	geometry.addAttribute( 'position', new BufferAttribute( new Float32Array( 5 * 3 ), 3 ) );
 
-	this.add( new Line( geometry, material ) );
+	this.line = new Line( geometry, material );
+	this.add( this.line );
+
 
 	this.update();
 
@@ -45,18 +48,12 @@ RectAreaLightHelper.prototype.dispose = function () {
 
 RectAreaLightHelper.prototype.update = function () {
 
-	var line = this.children[ 0 ];
-
-	// update material
-
-	line.material.color.copy( this.light.color );
-
 	// calculate new dimensions of the helper
 
 	var hx = this.light.width * 0.5;
 	var hy = this.light.height * 0.5;
 
-	var position = line.geometry.attributes.position;
+	var position = this.line.geometry.attributes.position;
 	var array = position.array;
 
 	// update vertices
@@ -69,6 +66,8 @@ RectAreaLightHelper.prototype.update = function () {
 
 	position.needsUpdate = true;
 
+	if ( ! this.overrideColor ) this.line.material.color.copy( this.light.color );
+
 };
 
 export { RectAreaLightHelper };