소스 검색

Merge pull request #7958 from NasimiAsl/master

fix array loop from for in to for index
David Catuhe 5 년 전
부모
커밋
387e908588
2개의 변경된 파일13개의 추가작업 그리고 13개의 파일을 삭제
  1. 7 7
      materialsLibrary/src/custom/customMaterial.ts
  2. 6 6
      materialsLibrary/src/custom/pbrCustomMaterial.ts

+ 7 - 7
materialsLibrary/src/custom/customMaterial.ts

@@ -62,7 +62,7 @@ export class CustomMaterial extends StandardMaterial {
     public VertexShader: string;
 
     public AttachAfterBind(mesh: Mesh, effect: Effect) {
-        for (var el in this._newUniformInstances) {
+         for (var el in this._newUniformInstances) {
             var ea = el.toString().split('-');
             if (ea[0] == 'vec2') {
                 effect.setVector2(ea[1], this._newUniformInstances[el]);
@@ -90,20 +90,20 @@ export class CustomMaterial extends StandardMaterial {
 
     public ReviewUniform(name: string, arr: string[]): string[] {
         if (name == "uniform") {
-            for (var ind in this._newUniforms) {
-                if (this._customUniform[ind].indexOf('sampler') == -1) {
+            for (var ind = 0;ind < this._newUniforms.length ;ind ++ ) {
+                if (  this._customUniform[ind].indexOf('sampler') == -1) {
                     arr.push(this._newUniforms[ind]);
                 }
             }
         }
         if (name == "sampler") {
-            for (var ind in this._newUniforms) {
-                if (this._customUniform[ind].indexOf('sampler') != -1) {
+            for (var ind = 0;ind < this._newUniforms.length ;ind ++ ) {
+                if ( this._customUniform[ind].indexOf('sampler') != -1) {
                     arr.push(this._newUniforms[ind]);
                 }
             }
         }
-        return arr;
+        return arr; 
     }
 
     public Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]): string {
@@ -268,4 +268,4 @@ export class CustomMaterial extends StandardMaterial {
     }
 }
 
-_TypeStore.RegisteredTypes["BABYLON.CustomMaterial"] = CustomMaterial;
+_TypeStore.RegisteredTypes["BABYLON.CustomMaterial"] = CustomMaterial;

+ 6 - 6
materialsLibrary/src/custom/pbrCustomMaterial.ts

@@ -86,20 +86,20 @@ export class PBRCustomMaterial extends PBRMaterial {
 
     public ReviewUniform(name: string, arr: string[]): string[] {
         if (name == "uniform") {
-            for (var ind in this._newUniforms) {
-                if (this._customUniform[ind].indexOf('sampler') == -1) {
+            for (var ind = 0;ind < this._newUniforms.length ;ind ++ ) {
+                if (  this._customUniform[ind].indexOf('sampler') == -1) {
                     arr.push(this._newUniforms[ind]);
                 }
             }
         }
         if (name == "sampler") {
-            for (var ind in this._newUniforms) {
-                if (this._customUniform[ind].indexOf('sampler') != -1) {
+            for (var ind = 0;ind < this._newUniforms.length ;ind ++ ) {
+                if ( this._customUniform[ind].indexOf('sampler') != -1) {
                     arr.push(this._newUniforms[ind]);
                 }
             }
         }
-        return arr;
+        return arr; 
     }
 
     public Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]): string {
@@ -276,4 +276,4 @@ export class PBRCustomMaterial extends PBRMaterial {
     }
 }
 
-_TypeStore.RegisteredTypes["BABYLON.PBRCustomMaterial"] = PBRCustomMaterial;
+_TypeStore.RegisteredTypes["BABYLON.PBRCustomMaterial"] = PBRCustomMaterial;