Browse Source

Editor: Update object sorting hierarchy. Fixes #4508.

Mr.doob 11 years ago
parent
commit
bef3f414cf
2 changed files with 16 additions and 16 deletions
  1. 6 6
      editor/js/Sidebar.Scene.js
  2. 10 10
      editor/js/libs/ui.js

+ 6 - 6
editor/js/Sidebar.Scene.js

@@ -123,9 +123,9 @@ Sidebar.Scene = function ( editor ) {
 		var scene = editor.scene;
 		var sceneType = editor.getObjectType( scene );
 
-		var options = {};
+		var options = [];
 
-		options[ scene.id ] = '<span class="type ' + sceneType + '"></span> ' + scene.name;
+		options.push( { value: scene.id, html: '<span class="type ' + sceneType + '"></span> ' + scene.name } );
 
 		( function addObjects( objects, pad ) {
 
@@ -134,7 +134,7 @@ Sidebar.Scene = function ( editor ) {
 				var object = objects[ i ];
 				var objectType = editor.getObjectType( object );
 
-				var option = pad + '<span class="type ' + objectType + '"></span> ' + object.name;
+				var html = pad + '<span class="type ' + objectType + '"></span> ' + object.name;
 
 				if ( object instanceof THREE.Mesh ) {
 
@@ -144,12 +144,12 @@ Sidebar.Scene = function ( editor ) {
 					var geometryType = editor.getGeometryType( geometry );
 					var materialType = editor.getMaterialType( material );
 
-					option += ' <span class="type ' + geometryType + '"></span> ' + geometry.name;
-					option += ' <span class="type ' + materialType + '"></span> ' + material.name;
+					html += ' <span class="type ' + geometryType + '"></span> ' + geometry.name;
+					html += ' <span class="type ' + materialType + '"></span> ' + material.name;
 
 				}
 
-				options[ object.id ] = option;
+				options.push( { value: object.id, html: html } );
 
 				addObjects( object.children, pad + '&nbsp;&nbsp;&nbsp;' );
 

+ 10 - 10
editor/js/libs/ui.js

@@ -403,17 +403,19 @@ UI.FancySelect.prototype.setOptions = function ( options ) {
 
 	scope.options = [];
 
-	for ( var key in options ) {
+	for ( var i = 0; i < options.length; i ++ ) {
 
-		var option = document.createElement('div');
-		option.className = 'option';
-		option.innerHTML = options[ key ];
-		option.value = key;
-		scope.dom.appendChild( option );
+		var option = options[ i ];
 
-		scope.options.push( option );
+		var div = document.createElement( 'div' );
+		div.className = 'option';
+		div.innerHTML = option.html;
+		div.value = option.value;
+		scope.dom.appendChild( div );
 
-		option.addEventListener( 'click', function ( event ) {
+		scope.options.push( div );
+
+		div.addEventListener( 'click', function ( event ) {
 
 			scope.setValue( this.value );
 			scope.dom.dispatchEvent( changeEvent );
@@ -434,8 +436,6 @@ UI.FancySelect.prototype.getValue = function () {
 
 UI.FancySelect.prototype.setValue = function ( value ) {
 
-	if ( typeof value === 'number' ) value = value.toString();
-
 	for ( var i = 0; i < this.options.length; i ++ ) {
 
 		var element = this.options[ i ];