Browse Source

Editor: Moved Edit/Convert to Geometry panel.

Mr.doob 11 years ago
parent
commit
09abe9bc3b
2 changed files with 34 additions and 26 deletions
  1. 0 26
      editor/js/Menubar.Edit.js
  2. 34 0
      editor/js/Sidebar.Geometry.Modifiers.js

+ 0 - 26
editor/js/Menubar.Edit.js

@@ -49,32 +49,6 @@ Menubar.Edit = function ( editor ) {
 
 
 	options.add( new UI.HorizontalRule() );
 	options.add( new UI.HorizontalRule() );
 
 
-	// Convert
-
-	var option = new UI.Panel();
-	option.setClass( 'option' );
-	option.setTextContent( 'Convert' );
-	option.onClick( function () {
-
-		// convert to BufferGeometry
-		
-		var object = editor.selected;
-
-		if ( object.geometry instanceof THREE.Geometry ) {
-
-			if ( object.parent === undefined ) return; // avoid flattening the camera or scene
-
-			if ( confirm( 'Convert ' + object.name + ' to BufferGeometry?' ) === false ) return;
-
-			object.geometry = new THREE.BufferGeometry().fromGeometry( object.geometry );
-
-			editor.signals.objectChanged.dispatch( object );
-
-		}
-
-	} );
-	options.add( option );
-
 	// Flatten
 	// Flatten
 
 
 	var option = new UI.Panel();
 	var option = new UI.Panel();

+ 34 - 0
editor/js/Sidebar.Geometry.Modifiers.js

@@ -27,6 +27,40 @@ Sidebar.Geometry.Modifiers = function ( signals, object ) {
 
 
 	container.add( button );
 	container.add( button );
 
 
+	// Convert to Geometry/BufferGeometry
+
+	var isBufferGeometry = geometry instanceof THREE.BufferGeometry;
+
+	if ( geometry instanceof THREE.BufferGeometry ) {
+
+		var button = new UI.Button( 'Convert to Geometry' );
+		button.onClick( function () {
+
+			if ( confirm( 'Are you sure?' ) === false ) return;
+
+			object.geometry = new THREE.Geometry().fromBufferGeometry( object.geometry );
+
+			signals.objectChanged.dispatch( object );
+
+		} );
+		container.add( button );
+
+	} else {
+
+		var button = new UI.Button( 'Convert to BufferGeometry' );
+		button.onClick( function () {
+
+			if ( confirm( 'Are you sure?' ) === false ) return;
+
+			object.geometry = new THREE.BufferGeometry().fromGeometry( object.geometry );
+
+			signals.objectChanged.dispatch( object );
+
+		} );
+		container.add( button );
+
+	}
+
 	//
 	//
 
 
 	return container;
 	return container;