Browse Source

Editor: Reworking lights clone/delete. Added clone to PointLight.

Mr.doob 12 years ago
parent
commit
ebd1d9f4b1
2 changed files with 26 additions and 65 deletions
  1. 13 65
      editor/js/ui/Viewport.js
  2. 13 0
      src/lights/PointLight.js

+ 13 - 65
editor/js/ui/Viewport.js

@@ -377,50 +377,29 @@ var Viewport = function ( signals ) {
 
 
 		var name = selected.name ?  '"' + selected.name + '"': "selected object";
 		var name = selected.name ?  '"' + selected.name + '"': "selected object";
 
 
-		if ( ! confirm( 'Delete ' + name + '?' ) ) {
+		if ( confirm( 'Delete ' + name + '?' ) === false ) return;
 
 
-			return;
-
-		}
-
-		// remove proxies from picking list
-
-		var toRemove = {};
-
-		var proxyObject = selected.userData.pickingProxy ? selected.userData.pickingProxy : selected;
-
-		proxyObject.traverse( function ( child ) {
-
-			toRemove[ child.id ] = true;
-
-		} );
+		var object = selected;
 
 
-		// remove eventual pure Object3D target proxies from picking list
+		if ( selected instanceof THREE.Light ) {
 
 
-		if ( selected.target && !selected.target.geometry ) {
+			var helper = objectsToHelpers[ object.id ];
 
 
-			toRemove[ selected.target.userData.pickingProxy.id ] = true;
+			objects.splice( objects.indexOf( helper ), 1 );
 
 
-		}
-
-		//
-
-		var newObjects = [];
-
-		for ( var i = 0; i < objects.length; i ++ ) {
+			helper.parent.remove( helper );
+			object.parent.remove( object );
 
 
-			var object = objects[ i ];
+			delete objectsToHelpers[ object.id ];
+			delete helpersToObjects[ helper.id ];
 
 
-			if ( ! ( object.id in toRemove ) ) {
+		} else {
 
 
-				newObjects.push( object );
-
-			}
+			object.parent.remove( object );
+			objects.splice( objects.indexOf( object ), 1 );
 
 
 		}
 		}
 
 
-		objects = newObjects;
-
 		// clean selection highlight
 		// clean selection highlight
 
 
 		selectionBox.visible = false;
 		selectionBox.visible = false;
@@ -428,39 +407,8 @@ var Viewport = function ( signals ) {
 
 
 		// remove selected object from the scene
 		// remove selected object from the scene
 
 
-		selected.parent.remove( selected );
 
 
-		// remove eventual pure Object3D targets from the scene
-
-		if ( selected.target && !selected.target.geometry ) {
-
-			selected.target.parent.remove( selected.target );
-
-		}
-
-		// remove eventual helpers for the object from helpers scene
-
-		var helpersToRemove = [];
-
-		if ( selected.userData.helper ) {
-
-			helpersToRemove.push( selected.userData.helper );
-
-			if ( selected.userData.helper.targetLine ) helpersToRemove.push( selected.userData.helper.targetLine );
-			if ( selected.target && !selected.target.geometry ) helpersToRemove.push( selected.userData.helper.targetSphere );
-
-
-		}
-
-		for ( var i = 0; i < helpersToRemove.length; i ++ ) {
-
-			var helper = helpersToRemove[ i ];
-
-			helper.parent.remove( helper );
-
-		}
-
-		if ( selected instanceof THREE.Light )  {
+		if ( object instanceof THREE.Light )  {
 
 
 			updateMaterials( scene );
 			updateMaterials( scene );
 
 

+ 13 - 0
src/lights/PointLight.js

@@ -13,3 +13,16 @@ THREE.PointLight = function ( hex, intensity, distance ) {
 };
 };
 
 
 THREE.PointLight.prototype = Object.create( THREE.Light.prototype );
 THREE.PointLight.prototype = Object.create( THREE.Light.prototype );
+
+THREE.PointLight.prototype.clone = function () {
+
+	var light = new THREE.PointLight();
+
+	light.color.copy( this.color );
+	light.position.copy( this.position );
+	light.intensity = this.intensity;
+	light.distance = this.distance;
+
+	return light;
+
+};