Browse Source

Editor: Wired up selected to Config.

Mr.doob 11 years ago
parent
commit
d97892e134
2 changed files with 26 additions and 3 deletions
  1. 18 3
      editor/js/Editor.js
  2. 8 0
      editor/js/Loader.js

+ 18 - 3
editor/js/Editor.js

@@ -291,25 +291,40 @@ Editor.prototype = {
 	select: function ( object ) {
 	select: function ( object ) {
 
 
 		this.selected = object;
 		this.selected = object;
+		this.config.setKey( 'selected', object.uuid );
 		this.signals.objectSelected.dispatch( object );
 		this.signals.objectSelected.dispatch( object );
 
 
 	},
 	},
 
 
 	selectById: function ( id ) {
 	selectById: function ( id ) {
 
 
-		var object = null;
+		var scope = this;
 
 
 		this.scene.traverse( function ( child ) {
 		this.scene.traverse( function ( child ) {
 
 
 			if ( child.id === id ) {
 			if ( child.id === id ) {
 
 
-				object = child;
+				scope.select( child );
 
 
 			}
 			}
 
 
 		} );
 		} );
 
 
-		this.select( object );
+	},
+
+	selectByUuid: function ( uuid ) {
+
+		var scope = this;
+
+		this.scene.traverse( function ( child ) {
+
+			if ( child.uuid === uuid ) {
+
+				scope.select( child );
+
+			}
+
+		} );
 
 
 	},
 	},
 
 

+ 8 - 0
editor/js/Loader.js

@@ -16,6 +16,14 @@ var Loader = function ( editor ) {
 
 
 		}
 		}
 
 
+		var selected = editor.config.getKey( 'selected' );
+
+		if ( selected !== undefined ) {
+
+			editor.selectByUuid( selected );
+
+		}
+
 	};
 	};
 
 
 	var exporter = new THREE.ObjectExporter();
 	var exporter = new THREE.ObjectExporter();