瀏覽代碼

Merge pull request #2327 from NasimiAsl/master

attach condition for create one time
David Catuhe 8 年之前
父節點
當前提交
5dc512cc4c
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      materialsLibrary/src/custom/babylon.customMaterial.ts

+ 8 - 1
materialsLibrary/src/custom/babylon.customMaterial.ts

@@ -556,6 +556,8 @@ vColor=color;\n\
          public static ShaderIndexer = 1;
          public CustomParts :  ShaderSpecialParts;
          public ShaderVersion : CustomShaderStructure ;
+         _isCreatedShader : bool;
+         _createdShaderName : string;
          _customUniform : string[];
          _newUniforms : string[];
          _newUniformInstances : any[];
@@ -597,7 +599,9 @@ vColor=color;\n\
          }
          public Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) : string {
             
-           
+            if(this._isCreatedShader) return this._createdShaderName;
+              this._isCreatedShader  = false;
+            
             CustomMaterial.ShaderIndexer++;
             var name = name+"custom_"+CustomMaterial.ShaderIndexer;
 
@@ -626,6 +630,9 @@ vColor=color;\n\
             .replace('#[Fragment_Custom_Alpha]',(this.CustomParts.Fragment_Custom_Alpha ? this.CustomParts.Fragment_Custom_Alpha : ""))
             .replace('#[Fragment_Before_FragColor]',(this.CustomParts.Fragment_Before_FragColor ? this.CustomParts.Fragment_Before_FragColor : "")) ;
  
+             this._isCreatedShader  = true;
+              this._createdShaderName = name;
+           
              return name ;
          }