Browse Source

Editor: Post-release fixes.

Mr.doob 8 years ago
parent
commit
dc85c1bf6d

+ 3 - 1
editor/css/dark.css

@@ -110,11 +110,13 @@ select {
 		}
 
 		#menubar .menu .options {
-			position: absolute;
+			position: fixed;
 			display: none;
 			padding: 5px 0;
 			background: #111;
 			width: 150px;
+			max-height: calc(100% - 80px);
+			overflow: auto;
 		}
 
 		#menubar .menu:hover .options {

+ 3 - 1
editor/css/light.css

@@ -106,11 +106,13 @@ select {
 		}
 
 		#menubar .menu .options {
-			position: absolute;
+			position: fixed;
 			display: none;
 			padding: 5px 0;
 			background: #eee;
 			width: 150px;
+			max-height: calc(100% - 80px);
+			overflow: auto;
 		}
 
 		#menubar .menu:hover .options {

+ 6 - 0
editor/js/Menubar.File.js

@@ -48,13 +48,19 @@ Menubar.File = function ( editor ) {
 
 	// Import
 
+	var form = document.createElement( 'form' );
+	form.style.display = 'none';
+	document.body.appendChild( form );
+
 	var fileInput = document.createElement( 'input' );
 	fileInput.type = 'file';
 	fileInput.addEventListener( 'change', function ( event ) {
 
 		editor.loader.loadFile( fileInput.files[ 0 ] );
+		form.reset();
 
 	} );
+	form.appendChild( fileInput );
 
 	var option = new UI.Row();
 	option.setClass( 'option' );

+ 13 - 13
editor/js/commands/SetMaterialColorCommand.js

@@ -10,7 +10,7 @@
  * @constructor
  */
 
-var SetMaterialColorCommand = function ( object, attributeName, newValue, slot ) {
+var SetMaterialColorCommand = function ( object, attributeName, newValue, materialSlot ) {
 
 	Command.call( this );
 
@@ -19,30 +19,30 @@ var SetMaterialColorCommand = function ( object, attributeName, newValue, slot )
 	this.updatable = true;
 
 	this.object = object;
-	this.attributeName = attributeName;
-	this.slot = slot;
-
-	var material = this.editor.getObjectMaterial( this.object, this.slot );
+	this.material = this.editor.getObjectMaterial( object, materialSlot );
 
-	this.oldValue = ( material !== undefined ) ? material[ this.attributeName ].getHex() : undefined;
+	this.oldValue = ( this.material !== undefined ) ? this.material[ attributeName ].getHex() : undefined;
 	this.newValue = newValue;
-	
+
+	this.attributeName = attributeName;
+
 };
 
 SetMaterialColorCommand.prototype = {
 
 	execute: function () {
-		var material = this.editor.getObjectMaterial( this.object, this.slot )
-		material[ this.attributeName ].setHex( this.newValue );
-		this.editor.signals.materialChanged.dispatch( material );
+
+		this.material[ this.attributeName ].setHex( this.newValue );
+
+		this.editor.signals.materialChanged.dispatch( this.material );
 
 	},
 
 	undo: function () {
-		var material = this.editor.getObjectMaterial( this.object, this.slot )
 
-		material[ this.attributeName ].setHex( this.oldValue );
-		this.editor.signals.materialChanged.dispatch( material );
+		this.material[ this.attributeName ].setHex( this.oldValue );
+
+		this.editor.signals.materialChanged.dispatch( this.material );
 
 	},
 

+ 6 - 13
editor/js/commands/SetMaterialCommand.js

@@ -10,7 +10,7 @@
  */
 
 
-var SetMaterialCommand = function ( object, newMaterial , slot) {
+var SetMaterialCommand = function ( object, newMaterial, materialSlot ) {
 
 	Command.call( this );
 
@@ -18,31 +18,25 @@ var SetMaterialCommand = function ( object, newMaterial , slot) {
 	this.name = 'New Material';
 
 	this.object = object;
+	this.materialSlot = materialSlot;
 
-	this.slot = slot;
-
-	var material = this.editor.getObjectMaterial( this.object, this.slot );
-
-	this.oldMaterial = material;
-
+	this.oldMaterial = this.editor.getObjectMaterial( object, materialSlot );
 	this.newMaterial = newMaterial;
-	
+
 };
 
 SetMaterialCommand.prototype = {
 
 	execute: function () {
-		
-		this.editor.setObjectMaterial( this.object, this.slot, this.newMaterial );
 
+		this.editor.setObjectMaterial( this.object, this.materialSlot, this.newMaterial );
 		this.editor.signals.materialChanged.dispatch( this.newMaterial );
 
 	},
 
 	undo: function () {
-		
-		this.editor.setObjectMaterial( this.object, this.slot, this.oldMaterial );
 
+		this.editor.setObjectMaterial( this.object, this.materialSlot, this.oldMaterial );
 		this.editor.signals.materialChanged.dispatch( this.oldMaterial );
 
 	},
@@ -67,7 +61,6 @@ SetMaterialCommand.prototype = {
 		this.oldMaterial = parseMaterial( json.oldMaterial );
 		this.newMaterial = parseMaterial( json.newMaterial );
 
-
 		function parseMaterial ( json ) {
 
 			var loader = new THREE.ObjectLoader();

+ 15 - 9
editor/js/commands/SetMaterialMapCommand.js

@@ -10,34 +10,40 @@
  * @constructor
  */
 
-var SetMaterialMapCommand = function ( object, mapName, newMap ) {
+var SetMaterialMapCommand = function ( object, mapName, newMap, materialSlot ) {
 
 	Command.call( this );
+
 	this.type = 'SetMaterialMapCommand';
 	this.name = 'Set Material.' + mapName;
 
 	this.object = object;
-	this.mapName = mapName;
-	this.oldMap = ( object !== undefined ) ? object.material[ mapName ] : undefined;
+	this.material = this.editor.getObjectMaterial( object, materialSlot );
+
+	this.oldMap = ( object !== undefined ) ? this.material[ mapName ] : undefined;
 	this.newMap = newMap;
 
+	this.mapName = mapName;
+
 };
 
 SetMaterialMapCommand.prototype = {
 
 	execute: function () {
 
-		this.object.material[ this.mapName ] = this.newMap;
-		this.object.material.needsUpdate = true;
-		this.editor.signals.materialChanged.dispatch( this.object.material );
+		this.material[ this.mapName ] = this.newMap;
+		this.material.needsUpdate = true;
+
+		this.editor.signals.materialChanged.dispatch( this.material );
 
 	},
 
 	undo: function () {
 
-		this.object.material[ this.mapName ] = this.oldMap;
-		this.object.material.needsUpdate = true;
-		this.editor.signals.materialChanged.dispatch( this.object.material );
+		this.material[ this.mapName ] = this.oldMap;
+		this.material.needsUpdate = true;
+
+		this.editor.signals.materialChanged.dispatch( this.material );
 
 	},
 

+ 13 - 13
editor/js/commands/SetMaterialValueCommand.js

@@ -10,21 +10,20 @@
  * @constructor
  */
 
-var SetMaterialValueCommand = function ( object, attributeName, newValue, slot ) {
+var SetMaterialValueCommand = function ( object, attributeName, newValue, materialSlot ) {
 
 	Command.call( this );
 
 	this.type = 'SetMaterialValueCommand';
 	this.name = 'Set Material.' + attributeName;
 	this.updatable = true;
-	this.slot = slot;
 
 	this.object = object;
+	this.material = this.editor.getObjectMaterial( object, materialSlot );
 
-	var material = this.editor.getObjectMaterial( this.object, this.slot );
-	
-	this.oldValue = ( material !== undefined ) ? material[ attributeName ] : undefined;
+	this.oldValue = ( this.material !== undefined ) ? this.material[ attributeName ] : undefined;
 	this.newValue = newValue;
+
 	this.attributeName = attributeName;
 
 };
@@ -32,21 +31,22 @@ var SetMaterialValueCommand = function ( object, attributeName, newValue, slot )
 SetMaterialValueCommand.prototype = {
 
 	execute: function () {
-		var material = this.editor.getObjectMaterial( this.object, this.slot );
-		material[ this.attributeName ] = this.newValue;
-		material.needsUpdate = true;
+
+		this.material[ this.attributeName ] = this.newValue;
+		this.material.needsUpdate = true;
+
 		this.editor.signals.objectChanged.dispatch( this.object );
-		this.editor.signals.materialChanged.dispatch( material );
+		this.editor.signals.materialChanged.dispatch( this.material );
 
 	},
 
 	undo: function () {
-		var material = this.editor.getObjectMaterial( this.object, this.slot );
 
-		material[ this.attributeName ] = this.oldValue;
-		material.needsUpdate = true;
+		this.material[ this.attributeName ] = this.oldValue;
+		this.material.needsUpdate = true;
+
 		this.editor.signals.objectChanged.dispatch( this.object );
-		this.editor.signals.materialChanged.dispatch( material );
+		this.editor.signals.materialChanged.dispatch( this.material );
 
 	},