浏览代码

Ensures loading conflicting ids will resolve to the last one found (better probability to match the searched one)

Sebastien Vandenberghe 8 年之前
父节点
当前提交
35cb3a9b1c
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/Mesh/babylon.mesh.ts

+ 2 - 2
src/Mesh/babylon.mesh.ts

@@ -1287,7 +1287,7 @@
         public setMaterialByID(id: string): Mesh {
         public setMaterialByID(id: string): Mesh {
             var materials = this.getScene().materials;
             var materials = this.getScene().materials;
             var index: number;
             var index: number;
-            for (index = 0; index < materials.length; index++) {
+            for (index = materials.length - 1; index > -1; index--) {
                 if (materials[index].id === id) {
                 if (materials[index].id === id) {
                     this.material = materials[index];
                     this.material = materials[index];
                     return this;
                     return this;
@@ -1296,7 +1296,7 @@
 
 
             // Multi
             // Multi
             var multiMaterials = this.getScene().multiMaterials;
             var multiMaterials = this.getScene().multiMaterials;
-            for (index = 0; index < multiMaterials.length; index++) {
+            for (index = multiMaterials.length - 1; index > -1; index--) {
                 if (multiMaterials[index].id === id) {
                 if (multiMaterials[index].id === id) {
                     this.material = multiMaterials[index];
                     this.material = multiMaterials[index];
                     return this;
                     return this;