Browse Source

HemisphereLight clone(). PointLight and DirectionalLight clean up.

Mr.doob 12 years ago
parent
commit
baff3bd388
3 changed files with 16 additions and 6 deletions
  1. 1 1
      src/lights/DirectionalLight.js
  2. 15 3
      src/lights/HemisphereLight.js
  3. 0 2
      src/lights/PointLight.js

+ 1 - 1
src/lights/DirectionalLight.js

@@ -7,7 +7,7 @@ THREE.DirectionalLight = function ( hex, intensity ) {
 
 
 	THREE.Light.call( this, hex );
 	THREE.Light.call( this, hex );
 
 
-	this.position = new THREE.Vector3( 0, 1, 0 );
+	this.position.set( 0, 1, 0 );
 	this.target = new THREE.Object3D();
 	this.target = new THREE.Object3D();
 
 
 	this.intensity = ( intensity !== undefined ) ? intensity : 1;
 	this.intensity = ( intensity !== undefined ) ? intensity : 1;

+ 15 - 3
src/lights/HemisphereLight.js

@@ -6,12 +6,24 @@ THREE.HemisphereLight = function ( skyColorHex, groundColorHex, intensity ) {
 
 
 	THREE.Light.call( this, skyColorHex );
 	THREE.Light.call( this, skyColorHex );
 
 
-	this.groundColor = new THREE.Color( groundColorHex );
-
-	this.position = new THREE.Vector3( 0, 100, 0 );
+	this.position.set( 0, 100, 0 );
 
 
+	this.groundColor = new THREE.Color( groundColorHex );
 	this.intensity = ( intensity !== undefined ) ? intensity : 1;
 	this.intensity = ( intensity !== undefined ) ? intensity : 1;
 
 
 };
 };
 
 
 THREE.HemisphereLight.prototype = Object.create( THREE.Light.prototype );
 THREE.HemisphereLight.prototype = Object.create( THREE.Light.prototype );
+
+THREE.HemisphereLight.prototype.clone = function () {
+
+	var light = new THREE.PointLight();
+
+	THREE.Light.prototype.clone.call( this, light );
+
+	light.groundColor.copy( this.groundColor );
+	light.intensity = this.intensity;
+
+	return light;
+
+};

+ 0 - 2
src/lights/PointLight.js

@@ -6,7 +6,6 @@ THREE.PointLight = function ( hex, intensity, distance ) {
 
 
 	THREE.Light.call( this, hex );
 	THREE.Light.call( this, hex );
 
 
-	this.position = new THREE.Vector3( 0, 0, 0 );
 	this.intensity = ( intensity !== undefined ) ? intensity : 1;
 	this.intensity = ( intensity !== undefined ) ? intensity : 1;
 	this.distance = ( distance !== undefined ) ? distance : 0;
 	this.distance = ( distance !== undefined ) ? distance : 0;
 
 
@@ -20,7 +19,6 @@ THREE.PointLight.prototype.clone = function () {
 
 
 	THREE.Light.prototype.clone.call( this, light );
 	THREE.Light.prototype.clone.call( this, light );
 
 
-	light.position.copy( this.position );
 	light.intensity = this.intensity;
 	light.intensity = this.intensity;
 	light.distance = this.distance;
 	light.distance = this.distance;