Browse Source

Improved PointLight clone.

Mr.doob 12 years ago
parent
commit
efa4d964c6
3 changed files with 18 additions and 2 deletions
  1. 4 1
      editor/js/ui/Viewport.js
  2. 12 0
      src/lights/Light.js
  3. 2 1
      src/lights/PointLight.js

+ 4 - 1
editor/js/ui/Viewport.js

@@ -367,7 +367,10 @@ var Viewport = function ( signals ) {
 
 		if ( selected === camera ) return;
 
-		signals.objectAdded.dispatch( selected.clone() );
+		var object = selected.clone();
+
+		signals.objectAdded.dispatch( object );
+		signals.objectSelected.dispatch( object );
 
 	} );
 

+ 12 - 0
src/lights/Light.js

@@ -12,3 +12,15 @@ THREE.Light = function ( hex ) {
 };
 
 THREE.Light.prototype = Object.create( THREE.Object3D.prototype );
+
+THREE.Light.prototype.clone = function ( light ) {
+
+	if ( light === undefined ) light = new THREE.Light();
+
+	THREE.Object3D.prototype.clone.call( this, light );
+
+	light.color.copy( this.color );
+
+	return light;
+
+};

+ 2 - 1
src/lights/PointLight.js

@@ -18,7 +18,8 @@ THREE.PointLight.prototype.clone = function () {
 
 	var light = new THREE.PointLight();
 
-	light.color.copy( this.color );
+	THREE.Light.prototype.clone.call( this, light );
+
 	light.position.copy( this.position );
 	light.intensity = this.intensity;
 	light.distance = this.distance;