Browse Source

Editor: Trying to get helpers to work.

Mr.doob 12 years ago
parent
commit
542ee96053
2 changed files with 9 additions and 9 deletions
  1. 7 4
      editor/js/Editor.js
  2. 2 5
      editor/js/Viewport.js

+ 7 - 4
editor/js/Editor.js

@@ -20,6 +20,7 @@ var Editor = function () {
 		objectRemoved: new SIGNALS.Signal(),
 
 		helperAdded: new SIGNALS.Signal(),
+		helperRemoved: new SIGNALS.Signal(),
 
 		materialChanged: new SIGNALS.Signal(),
 		clearColorChanged: new SIGNALS.Signal(),
@@ -115,8 +116,8 @@ Editor.prototype = {
 			var helper = new THREE.PointLightHelper( object, 10 );
 			helper.lightSphere.id = object.id;
 			this.sceneHelpers.add( helper );
-
 			this.helpers[ object.id ] = helper;
+
 			this.signals.helperAdded.dispatch( helper );
 
 		} else if ( object instanceof THREE.DirectionalLight ) {
@@ -124,8 +125,8 @@ Editor.prototype = {
 			var helper = new THREE.DirectionalLightHelper( object, 10 );
 			helper.lightSphere.id = object.id;
 			this.sceneHelpers.add( helper );
-
 			this.helpers[ object.id ] = helper;
+
 			this.signals.helperAdded.dispatch( helper );
 
 		} else if ( object instanceof THREE.SpotLight ) {
@@ -133,8 +134,8 @@ Editor.prototype = {
 			var helper = new THREE.SpotLightHelper( object, 10 );
 			helper.lightSphere.id = object.id;
 			this.sceneHelpers.add( helper );
-
 			this.helpers[ object.id ] = helper;
+
 			this.signals.helperAdded.dispatch( helper );
 
 		} else if ( object instanceof THREE.HemisphereLight ) {
@@ -142,8 +143,8 @@ Editor.prototype = {
 			var helper = new THREE.HemisphereLightHelper( object, 10 );
 			helper.lightSphere.id = object.id;
 			this.sceneHelpers.add( helper );
-
 			this.helpers[ object.id ] = helper;
+
 			this.signals.helperAdded.dispatch( helper );
 
 		}
@@ -157,6 +158,8 @@ Editor.prototype = {
 			this.helpers[ object.id ].parent.remove( this.helpers[ object.id ] );
 			delete this.helpers[ object.id ];
 
+			this.signals.helperRemoved.dispatch( helper );
+
 		}
 
 	},

+ 2 - 5
editor/js/Viewport.js

@@ -22,9 +22,6 @@ var Viewport = function ( editor ) {
 
 	// helpers
 
-	var helpersToObjects = {};
-	var objectsToHelpers = {};
-
 	var grid = new THREE.GridHelper( 500, 25 );
 	sceneHelpers.add( grid );
 
@@ -258,9 +255,9 @@ var Viewport = function ( editor ) {
 
 		}
 
-		if ( objectsToHelpers[ object.id ] !== undefined ) {
+		if ( editor.helpers[ object.id ] !== undefined ) {
 
-			objectsToHelpers[ object.id ].update();
+			editor.helpers[ object.id ].update();
 
 		}