Browse Source

Incomplete .clone() to DirectionalLight and SpotLight.

Mr.doob 12 years ago
parent
commit
7ef46e27d6
2 changed files with 38 additions and 1 deletions
  1. 17 0
      src/lights/DirectionalLight.js
  2. 21 1
      src/lights/SpotLight.js

+ 17 - 0
src/lights/DirectionalLight.js

@@ -59,3 +59,20 @@ THREE.DirectionalLight = function ( hex, intensity ) {
 };
 };
 
 
 THREE.DirectionalLight.prototype = Object.create( THREE.Light.prototype );
 THREE.DirectionalLight.prototype = Object.create( THREE.Light.prototype );
+
+THREE.DirectionalLight.prototype.clone = function () {
+
+	var light = new THREE.DirectionalLight();
+
+	THREE.Light.prototype.clone.call( this, light );
+
+	light.target = this.target.clone();
+
+	light.intensity = this.intensity;
+
+	light.castShadow = this.castShadow;
+	light.onlyShadow = this.onlyShadow;
+
+	return light;
+
+};

+ 21 - 1
src/lights/SpotLight.js

@@ -6,7 +6,7 @@ THREE.SpotLight = function ( hex, intensity, distance, angle, exponent ) {
 
 
 	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;
@@ -41,3 +41,23 @@ THREE.SpotLight = function ( hex, intensity, distance, angle, exponent ) {
 };
 };
 
 
 THREE.SpotLight.prototype = Object.create( THREE.Light.prototype );
 THREE.SpotLight.prototype = Object.create( THREE.Light.prototype );
+
+THREE.SpotLight.prototype.clone = function () {
+
+	var light = new THREE.SpotLight();
+
+	THREE.Light.prototype.clone.call( this, light );
+
+	light.target = this.target.clone();
+
+	light.intensity = this.intensity;
+	light.distance = this.distance;
+	light.angle = this.angle;
+	light.exponent = this.exponent;
+
+	light.castShadow = this.castShadow;
+	light.onlyShadow = this.onlyShadow;
+
+	return light;
+
+};