Sebastien Vandenberghe пре 7 година
родитељ
комит
7ed9da29ce

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

@@ -2039,7 +2039,7 @@ vColor=color;\n\
             
 
             var fn_afterBind = this._afterBind;
-            this._afterBind = function(m,e){ 
+            this._afterBind = function(this: any, m,e){ 
                 this.AttachAfterBind(m,e);
                 try{fn_afterBind(m,e);}catch(e){};
             } ;

+ 2 - 2
src/Engine/babylon.engine.ts

@@ -2307,9 +2307,9 @@
             }
         }
 
-        public _deleteProgram(program) {
+        public _deleteProgram(program: WebGLProgram): void {
             if (program) {
-                program[Effect.rebuildProgramFunctionName] = null;
+                program.__SPECTOR_rebuildProgram = null;
                 this._gl.deleteProgram(program);
             }
         }

+ 3 - 1
src/Engine/babylon.nullEngine.ts

@@ -107,7 +107,9 @@
         }
 
         public createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram {
-            return {};
+            return {
+                __SPECTOR_rebuildProgram: undefined,
+            };
         }
 
         public getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[] {

+ 2 - 3
src/Materials/babylon.effect.ts

@@ -89,7 +89,6 @@
     }
 
     export class Effect {
-        public static rebuildProgramFunctionName = "__SPECTOR_rebuildProgram";
         public name: any;
         public defines: string;
         public onCompiled: (effect: Effect) => void;
@@ -519,7 +518,7 @@
             return source;
         }
 
-        public _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (WebGLProgram) => void, onError: (message: string) => void) {
+        public _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) {
             this._isReady = false;
 
             this._vertexSourceCodeOverride = vertexSourceCode;
@@ -560,7 +559,7 @@
                 else {
                     this._program = engine.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines);
                 }
-                this._program[Effect.rebuildProgramFunctionName] = this._rebuildProgram.bind(this);
+                this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
 
                 if (engine.webGLVersion > 1) {
                     for (var name in this._uniformBuffersNames) {

+ 2 - 2
src/Tools/babylon.decorators.ts

@@ -114,10 +114,10 @@
         return (target: any, propertyKey: string) => {
             var key = targetKey || ("_" + propertyKey);
             Object.defineProperty(target, propertyKey, {
-                get: function () {
+                get: function (this: any) {
                     return this[key];
                 },
-                set: function (value) {
+                set: function (this: any, value) {
                     if (this[key] === value) {
                         return;
                     }

+ 4 - 0
src/babylon.mixins.ts

@@ -118,6 +118,10 @@ interface WebGLBuffer {
     is32Bits: boolean;
 }
 
+interface WebGLProgram {
+    __SPECTOR_rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
+}
+
 interface MouseEvent {
     mozMovementX: number;
     mozMovementY: number;