Browse Source

Merge pull request #18461 from Mugen87/dev11

Editor: Fix addMaterial()/removeMaterial() for multiple materials.
Mr.doob 5 years ago
parent
commit
8725b7b6dc
1 changed files with 29 additions and 3 deletions
  1. 29 3
      editor/js/Editor.js

+ 29 - 3
editor/js/Editor.js

@@ -240,16 +240,42 @@ Editor.prototype = {
 
 
 	addMaterial: function ( material ) {
 	addMaterial: function ( material ) {
 
 
-		if ( material.uuid in this.materials ) return;
+		if ( Array.isArray( material ) ) {
+
+			for ( var i = 0, l = material.length; i < l; i ++ ) {
+
+				if ( material[ i ].uuid in this.materials ) return;
+				this.materials[ material[ i ].uuid ] = material[ i ];
+
+			}
+
+		} else {
+
+			if ( material.uuid in this.materials ) return;
+			this.materials[ material.uuid ] = material;
+
+		}
 
 
-		this.materials[ material.uuid ] = material;
 		this.signals.materialAdded.dispatch();
 		this.signals.materialAdded.dispatch();
 
 
 	},
 	},
 
 
 	removeMaterial: function ( material ) {
 	removeMaterial: function ( material ) {
 
 
-		delete this.materials[ material.uuid ];
+		if ( Array.isArray( material ) ) {
+
+			for ( var i = 0, l = material.length; i < l; i ++ ) {
+
+				delete this.materials[ material[ i ].uuid ];
+
+			}
+
+		} else {
+
+			delete this.materials[ material.uuid ];
+
+		}
+
 		this.signals.materialRemoved.dispatch();
 		this.signals.materialRemoved.dispatch();
 
 
 	},
 	},