소스 검색

Editor: Fix addMaterial()/removeMaterial for multiple materials.

Mugen87 5 년 전
부모
커밋
89518aa159
1개의 변경된 파일29개의 추가작업 그리고 3개의 파일을 삭제
  1. 29 3
      editor/js/Editor.js

+ 29 - 3
editor/js/Editor.js

@@ -231,16 +231,42 @@ Editor.prototype = {
 
 	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();
 
 	},
 
 	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();
 
 	},