Browse Source

Revert back to using `copy` to actually copy in attributes for Lights

This is instead of applying the attributes directly to the constructor in `clone`, like I briefly had.
Daniel Hritzkiv 10 years ago
parent
commit
d19b117ce7

+ 2 - 8
src/lights/AreaLight.js

@@ -27,17 +27,11 @@ THREE.AreaLight = function ( color, intensity ) {
 THREE.AreaLight.prototype = Object.create( THREE.Light.prototype );
 THREE.AreaLight.prototype.constructor = THREE.AreaLight;
 
-THREE.PointLight.prototype.clone = function () {
-
-	var light = new this.constructor( this.color, this.intensity );
-	return light.copy( this );
-
-};
-
 THREE.AreaLight.prototype.copy = function ( source ) {
 
-	THREE.Object3D.prototype.copy.call( this, source );
+	THREE.Light.prototype.copy.call( this, source );
 
+	this.intensity = source.intensity;
 	this.normal.copy( source.normal );
 	this.right.copy( source.right );
 	this.width = source.width;

+ 2 - 7
src/lights/DirectionalLight.js

@@ -45,16 +45,11 @@ THREE.DirectionalLight = function ( color, intensity ) {
 THREE.DirectionalLight.prototype = Object.create( THREE.Light.prototype );
 THREE.DirectionalLight.prototype.constructor = THREE.DirectionalLight;
 
-THREE.DirectionalLight.prototype.clone = function() {
-	
-	var light = new this.constructor( this.color, this.intensity );
-	return light.copy( this );
-}
-
 THREE.DirectionalLight.prototype.copy = function ( source ) {
 
-	THREE.Object3D.prototype.copy.call( this, source );
+	THREE.Light.prototype.copy.call( this, source );
 
+	this.intensity = source.intensity;
 	this.target = source.target.clone();
 
 	this.castShadow = source.castShadow;

+ 7 - 3
src/lights/HemisphereLight.js

@@ -19,10 +19,14 @@ THREE.HemisphereLight = function ( skyColor, groundColor, intensity ) {
 THREE.HemisphereLight.prototype = Object.create( THREE.Light.prototype );
 THREE.HemisphereLight.prototype.constructor = THREE.HemisphereLight;
 
-THREE.HemisphereLight.prototype.clone = function () {
+THREE.HemisphereLight.prototype.copy = function ( source ) {
 
-	var light = new this.constructor( this.color, this.groundColor, this.intensity );
-	return light.copy(this);
+	THREE.Light.prototype.copy.call( this, source );
+
+	this.groundColor.copy( source.groundColor );
+	this.intensity = source.intensity;
+
+	return this;
 
 };
 

+ 6 - 3
src/lights/Light.js

@@ -16,9 +16,12 @@ THREE.Light = function ( color ) {
 THREE.Light.prototype = Object.create( THREE.Object3D.prototype );
 THREE.Light.prototype.constructor = THREE.Light;
 
-THREE.Light.prototype.clone = function () {
+THREE.Light.prototype.copy = function ( source ) {
 	
-	var light = new this.constructor( this.color );
-	return light.copy( this );
+	THREE.Object3D.prototype.copy.call( this, source );
+	
+	this.color.copy( source.color );
+	
+	return this;
 
 };

+ 8 - 3
src/lights/PointLight.js

@@ -17,10 +17,15 @@ THREE.PointLight = function ( color, intensity, distance, decay ) {
 THREE.PointLight.prototype = Object.create( THREE.Light.prototype );
 THREE.PointLight.prototype.constructor = THREE.PointLight;
 
-THREE.PointLight.prototype.clone = function () {
+THREE.PointLight.prototype.copy = function ( source ) {
 
-	var light = new this.constructor( this.color, this.intensity, this.distance, this.decay );
-	return light.copy( this );
+	THREE.Light.prototype.copy.call( this, source );
+
+	this.intensity = source.intensity;
+	this.distance = source.distance;
+	this.decay = source.decay;
+
+	return this;
 
 };
 

+ 6 - 8
src/lights/SpotLight.js

@@ -44,16 +44,14 @@ THREE.SpotLight = function ( color, intensity, distance, angle, exponent, decay
 THREE.SpotLight.prototype = Object.create( THREE.Light.prototype );
 THREE.SpotLight.prototype.constructor = THREE.SpotLight;
 
-THREE.SpotLight.prototype.clone = function () {
-
-	var light = new this.constructor( this.color, this.intensity, this.distance, this.angle, this.exponent, this.decay );
-	return light.copy( this );
-
-};
-
 THREE.SpotLight.prototype.copy = function ( source ) {
 	
-	THREE.Object3D.prototype.copy.call( this, source );
+	THREE.Light.prototype.copy.call( this, source );
+	
+	this.intensity = source.intensity;
+	this.distance = source.distance;
+	this.angle = source.angle;
+	this.decay = source.decay;
 	
 	this.target = source.target.clone();