浏览代码

Clean up.

Mr.doob 9 年之前
父节点
当前提交
814586a906
共有 1 个文件被更改,包括 25 次插入20 次删除
  1. 25 20
      editor/js/Sidebar.Material.js

+ 25 - 20
editor/js/Sidebar.Material.js

@@ -10,35 +10,40 @@ Sidebar.Material = function ( editor ) {
 	var container = new UI.Panel();
 	var container = new UI.Panel();
 	container.setBorderTop( '0' );
 	container.setBorderTop( '0' );
 	container.setPaddingTop( '20px' );
 	container.setPaddingTop( '20px' );
-	
+
+	// New / Copy / Paste
+
 	var copiedMaterial;
 	var copiedMaterial;
+	var managerRow = new UI.Row();
 
 
-	//Copy / Paste/ new material
+	managerRow.add( new UI.Text( '' ).setWidth( '90px' ) );
+	managerRow.add( new UI.Button( 'New' ).onClick( function () {
 
 
-	var materialCPCRow = new UI.Row();
-	materialCPCRow.add( new UI.Text( '' ).setWidth( '90px' ) );
-	var materialCPCRenew = new UI.Button( 'New' ).setMarginLeft( '7px' ).onClick( function () {
-		var material;
-		material = new THREE[ materialClass.getValue() ]();
+		var material = new THREE[ materialClass.getValue() ]();
 		editor.execute( new SetMaterialCommand( currentObject, material ), 'New Material: ' + materialClass.getValue() );
 		editor.execute( new SetMaterialCommand( currentObject, material ), 'New Material: ' + materialClass.getValue() );
 		update();
 		update();
-	} );
-	var materialCPCRcopy = new UI.Button( 'Copy' ).onClick( function () {
+
+	} ) );
+
+	managerRow.add( new UI.Button( 'Copy' ).onClick( function () {
+
 		copiedMaterial = currentObject.material;
 		copiedMaterial = currentObject.material;
-		materialCPCRpaste.dom.disabled = false;
-	} );
-	var materialCPCRpaste = new UI.Button( 'Paste' ).setMarginLeft( '7px' ).onClick( function () {
-		if(copiedMaterial)editor.execute( new SetMaterialCommand( currentObject, copiedMaterial ), 'Pasted Material: ' + materialClass.getValue() );
+
+	} ) );
+
+	managerRow.add( new UI.Button( 'Paste' ).onClick( function () {
+
+		if ( copiedMaterial === undefined ) return;
+
+		editor.execute( new SetMaterialCommand( currentObject, copiedMaterial ), 'Pasted Material: ' + materialClass.getValue() );
 		refreshUI();
 		refreshUI();
 		update();
 		update();
-	} );
-	materialCPCRpaste.dom.disabled = true;
-	materialCPCRow.add( materialCPCRcopy );
-	materialCPCRow.add( materialCPCRpaste );
-	materialCPCRow.add( materialCPCRenew );
 
 
-	container.add( materialCPCRow );	
-	
+	} ) );
+
+	container.add( managerRow );
+
+
 	// type
 	// type
 
 
 	var materialClassRow = new UI.Row();
 	var materialClassRow = new UI.Row();