浏览代码

Introducing InternalTexture to help recreating webGLcontext when context lost

David Catuhe 8 年之前
父节点
当前提交
5a857e3c70

+ 1 - 0
Tools/Gulp/config.json

@@ -68,6 +68,7 @@
                 "../../src/babylon.scene.js",
                 "../../src/Mesh/babylon.buffer.js",
                 "../../src/Mesh/babylon.vertexBuffer.js",
+                "../../src/Materials/Textures/babylon.internalTexture.js",
                 "../../src/Materials/Textures/babylon.baseTexture.js",
                 "../../src/Materials/Textures/babylon.texture.js",
                 "../../src/Mesh/babylon.mesh.js",

文件差异内容过多而无法显示
+ 3694 - 3674
dist/preview release/babylon.d.ts


文件差异内容过多而无法显示
+ 3694 - 3674
dist/preview release/babylon.module.d.ts


+ 1 - 1
src/Materials/Textures/Procedurals/babylon.proceduralTexture.ts

@@ -113,7 +113,7 @@
 
                     if (this._fallbackTexture) {
                         this._texture = this._fallbackTexture._texture;
-                        this._texture.references++;
+                        this._texture.incrementReferences();
                     }
 
                     this._fallbackTextureUsed = true;

+ 9 - 9
src/Materials/Textures/babylon.baseTexture.ts

@@ -106,7 +106,7 @@
         public _cachedAnisotropicFilteringLevel: number;
 
         private _scene: Scene;
-        public _texture: WebGLTexture;
+        public _texture: InternalTexture;
         private _uid: string;
 
         public get isBlocking(): boolean {
@@ -131,7 +131,7 @@
             return null;
         }
 
-        public getInternalTexture(): WebGLTexture {
+        public getInternalTexture(): InternalTexture {
             return this._texture;
         }
 
@@ -153,8 +153,8 @@
         }
 
         public getSize(): ISize {
-            if (this._texture._width) {
-                return new Size(this._texture._width, this._texture._height);
+            if (this._texture.width) {
+                return new Size(this._texture.width, this._texture.height);
             }
 
             if (this._texture._size) {
@@ -172,7 +172,7 @@
                 return new Size(this._texture._size, this._texture._size);
             }
 
-            return new Size(this._texture._baseWidth, this._texture._baseHeight);
+            return new Size(this._texture.baseWidth, this._texture.baseHeight);
         }
 
         public scale(ratio: number): void {
@@ -194,14 +194,14 @@
             }
         }
 
-        public _getFromCache(url: string, noMipmap: boolean, sampling?: number): WebGLTexture {
+        public _getFromCache(url: string, noMipmap: boolean, sampling?: number): InternalTexture {
             var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
             for (var index = 0; index < texturesCache.length; index++) {
                 var texturesCacheEntry = texturesCache[index];
 
                 if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
                     if (!sampling || sampling === texturesCacheEntry.samplingMode) {
-                        texturesCacheEntry.references++;
+                        texturesCacheEntry.incrementReferences();
                         return texturesCacheEntry;
                     }
                 }
@@ -250,8 +250,8 @@
 
         public releaseInternalTexture(): void {
             if (this._texture) {
-                this._scene.getEngine().releaseInternalTexture(this._texture);
-                delete this._texture;
+                this._texture.dispose();
+                this._texture = null;
             }
         }
 

+ 1 - 1
src/Materials/Textures/babylon.colorGradingTexture.ts

@@ -145,7 +145,7 @@ module BABYLON {
                     }
                 }
 
-                this.getScene().getEngine().updateTextureSize(texture, size * size, size);
+                texture.updateSize(size * size, size);
                 this.getScene().getEngine().updateRawTexture(texture, data, BABYLON.Engine.TEXTUREFORMAT_RGBA, false);
             }
 

+ 1 - 1
src/Materials/Textures/babylon.cubeTexture.ts

@@ -71,7 +71,7 @@
                 if (this._texture.isReady) {
                     Tools.SetImmediate(() => onLoad());
                 } else {
-                    this._texture.onLoadedCallbacks.push(onLoad);
+                    this._texture.onLoadedObservable.add(onLoad);
                 }
             }
         }

+ 1 - 1
src/Materials/Textures/babylon.hdrCubeTexture.ts

@@ -153,7 +153,7 @@ module BABYLON {
                 this._size = intArrayView[1]; // CubeMap max mip face size.
 
                 // Update Texture Information.
-                this.getScene().getEngine().updateTextureSize(this._texture, this._size, this._size);
+                this._texture.updateSize(this._size, this._size);
 
                 // Fill polynomial information.
                 var sphericalPolynomial = new SphericalPolynomial();

+ 84 - 0
src/Materials/Textures/babylon.internalTexture.ts

@@ -0,0 +1,84 @@
+module BABYLON {
+    export class InternalTexture {
+        public isReady: boolean;
+        public isCube: boolean;
+        public url: string;
+        public samplingMode: number;
+        public generateMipMaps: boolean;
+        public samples: number;
+        public type: number;
+        public format: number;
+        public onLoadedObservable = new Observable<InternalTexture>();
+        public width: number;
+        public height: number;
+        public baseWidth: number;
+        public baseHeight: number;
+
+        // Private
+        public _size: number;
+        public _workingCanvas: HTMLCanvasElement;
+        public _workingContext: CanvasRenderingContext2D;
+        public _framebuffer: WebGLFramebuffer;
+        public _depthStencilBuffer: WebGLRenderbuffer;
+        public _MSAAFramebuffer: WebGLFramebuffer;
+        public _MSAARenderBuffer: WebGLRenderbuffer;
+        public _cachedCoordinatesMode: number;
+        public _cachedWrapU: number;
+        public _cachedWrapV: number;
+        public _isDisabled: boolean;
+        public _generateStencilBuffer: boolean;
+        public _generateDepthBuffer: boolean;
+        public _sphericalPolynomial: BABYLON.SphericalPolynomial;
+        // The following three fields helps sharing generated fixed LODs for texture filtering
+        // In environment not supporting the textureLOD extension like EDGE. They are for internal use only.
+        // They are at the level of the gl texture to benefit from the cache.
+        public _lodTextureHigh: BABYLON.BaseTexture;
+        public _lodTextureMid: BABYLON.BaseTexture;
+        public _lodTextureLow: BABYLON.BaseTexture;
+        
+        public _webGLTexture: WebGLTexture;
+        public _references: number = 1;
+        private _engine: Engine;
+
+        constructor(engine: Engine, texture?: WebGLTexture) {
+            this._engine = engine;
+
+            if (texture) {
+                this._webGLTexture = texture;               
+            } else {
+                this._webGLTexture = engine._createTexture();
+            }
+        }
+
+        public incrementReferences() {
+            this._references++;
+        }
+
+        public updateSize(width: number, height: number) {
+            this.width = width;
+            this.height = height;
+            this._size = width * height;
+            this.baseWidth = width;
+            this.baseHeight = height;
+        }
+        
+        public dispose(): void {
+            if (!this._webGLTexture) {
+                return;
+            }
+
+            this._references--;
+            if (this._references === 0) {
+                var texturesCache = this._engine.getLoadedTexturesCache();
+                var index = texturesCache.indexOf(this);
+
+                if (index > -1) {
+                    texturesCache.splice(index, 1);
+                }
+
+                this._engine._releaseTexture(this);
+                this._webGLTexture = null;
+            }
+        }
+    }
+}

+ 13 - 13
src/Materials/Textures/babylon.multiRenderTarget.ts

@@ -10,7 +10,7 @@ module BABYLON {
     };
     export class MultiRenderTarget extends RenderTargetTexture {
 
-        private _webGLTextures: WebGLTexture[];
+        private _internalTextures: InternalTexture[];
         private _textures: Texture[];
         private _count: number;
 
@@ -75,21 +75,21 @@ module BABYLON {
                 textureCount: count
             };
 
-            this._webGLTextures = scene.getEngine().createMultipleRenderTarget(size, this._multiRenderTargetOptions);
+            this._internalTextures = scene.getEngine().createMultipleRenderTarget(size, this._multiRenderTargetOptions);
 
             this._createInternalTextures();
         }
 
         private _createInternalTextures(): void {
             this._textures = [];
-            for (var i = 0; i < this._webGLTextures.length; i++) {
+            for (var i = 0; i < this._internalTextures.length; i++) {
                 var texture = new BABYLON.Texture(null, this.getScene());
-                texture._texture = this._webGLTextures[i];
+                texture._texture = this._internalTextures[i];
                 this._textures.push(texture);
             }
 
             // Keeps references to frame buffer and stencil/depth buffer
-            this._texture = this._webGLTextures[0];
+            this._texture = this._internalTextures[0];
         }
 
         public get samples(): number {
@@ -101,14 +101,14 @@ module BABYLON {
                 return;
             }
             
-            for (var i = 0 ; i < this._webGLTextures.length; i++) {
-                this._samples = this.getScene().getEngine().updateRenderTargetTextureSampleCount(this._webGLTextures[i], value);
+            for (var i = 0 ; i < this._internalTextures.length; i++) {
+                this._samples = this.getScene().getEngine().updateRenderTargetTextureSampleCount(this._internalTextures[i], value);
             }
         }
 
         public resize(size: any) {
             this.releaseInternalTextures();
-            this._webGLTextures = this.getScene().getEngine().createMultipleRenderTarget(size, this._multiRenderTargetOptions);
+            this._internalTextures = this.getScene().getEngine().createMultipleRenderTarget(size, this._multiRenderTargetOptions);
             this._createInternalTextures();
         }
 
@@ -119,14 +119,14 @@ module BABYLON {
         }
 
         public releaseInternalTextures(): void {
-            if (!this._webGLTextures) {
+            if (!this._internalTextures) {
                 return;
             }
 
-            for (var i = this._webGLTextures.length - 1; i >= 0; i--) {
-                if (this._webGLTextures[i] !== undefined) {
-                    this.getScene().getEngine().releaseInternalTexture(this._webGLTextures[i]);
-                    this._webGLTextures.splice(i, 1);
+            for (var i = this._internalTextures.length - 1; i >= 0; i--) {
+                if (this._internalTextures[i] !== undefined) {
+                    this._internalTextures[i].dispose();
+                    this._internalTextures.splice(i, 1);
                 }
             }
         }

+ 2 - 2
src/Materials/Textures/babylon.texture.ts

@@ -154,7 +154,7 @@
                 if (this._texture.isReady) {
                     Tools.SetImmediate(() => load());
                 } else {
-                    this._texture.onLoadedCallbacks.push(load);
+                    this._texture.onLoadedObservable.add(load);
                 }
             }
         }
@@ -182,7 +182,7 @@
                 if (this._texture.isReady) {
                     Tools.SetImmediate(() => this._delayedOnLoad());
                 } else {
-                    this._texture.onLoadedCallbacks.push(this._delayedOnLoad);
+                    this._texture.onLoadedObservable.add(this._delayedOnLoad);
                 }
             }
         }

+ 24 - 14
src/Materials/babylon.effect.ts

@@ -108,9 +108,11 @@
         public _key: string;
         private _indexParameters: any;
         private _fallbacks: EffectFallbacks;
+        private _vertexSourceCode: string;
+        private _fragmentSourceCode: string;
 
         private _program: WebGLProgram;
-        private _valueCache: { [key: string]: any } = {};
+        private _valueCache: { [key: string]: any };
         private static _baseCache: { [key: number]: WebGLBuffer } = {};
 
         constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], engine?: Engine, defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any) {
@@ -179,7 +181,14 @@
                         this._loadFragmentShader(fragmentSource, (fragmentCode) => {
                             this._processIncludes(fragmentCode, fragmentCodeWithIncludes => {
                                 this._processShaderConversion(fragmentCodeWithIncludes, true, migratedFragmentCode => {
-                                    this._prepareEffect(migratedVertexCode, migratedFragmentCode, this._attributesNames, this.defines, this._fallbacks, baseName);
+                                    if (baseName) {
+                                        this._vertexSourceCode = "#define SHADER_NAME vertex:" + baseName + "\n" + migratedVertexCode;
+                                        this._fragmentSourceCode = "#define SHADER_NAME fragment:" + baseName + "\n" + migratedFragmentCode;
+                                    } else {
+                                        this._vertexSourceCode = migratedVertexCode;
+                                        this._fragmentSourceCode = migratedFragmentCode;
+                                    }
+                                    this._prepareEffect();
                                 });
                             });
                         });
@@ -492,15 +501,15 @@
             return source;
         }
 
-        private _prepareEffect(vertexSourceCode: string, fragmentSourceCode: string, attributesNames: string[], defines: string, fallbacks?: EffectFallbacks, baseName?: string): void {
+        public _prepareEffect() {
+            let attributesNames = this._attributesNames;
+            let defines = this.defines;
+            let fallbacks = this._fallbacks;
+            this._valueCache = {};
+
             try {
                 var engine = this._engine;
-                if (baseName) {
-                    vertexSourceCode = "#define SHADER_NAME vertex:" + baseName + "\n" + vertexSourceCode;
-                    fragmentSourceCode = "#define SHADER_NAME fragment:" + baseName + "\n" + fragmentSourceCode;
-                }
-
-                this._program = engine.createShaderProgram(vertexSourceCode, fragmentSourceCode, defines);
+                this._program = engine.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines);
 
                 if (engine.webGLVersion > 1) {
                     for (var name in this._uniformBuffersNames) {
@@ -541,28 +550,29 @@
                 BABYLON.Tools.Error("Attributes: " + attributesNames.map(function(attribute) {
                     return " " + attribute;
                 }));
-                this._dumpShadersSource(vertexSourceCode, fragmentSourceCode, defines);
+                this._dumpShadersSource(this._vertexSourceCode, this._fragmentSourceCode, defines);
                 Tools.Error("Error: " + this._compilationError);
 
                 if (fallbacks && fallbacks.isMoreFallbacks) {
                     Tools.Error("Trying next fallback.");
-                    defines = fallbacks.reduce(defines);
-                    this._prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks);
+                    this.defines = fallbacks.reduce(this.defines);
+                    this._prepareEffect();
                 } else { // Sorry we did everything we can
 
                     if (this.onError) {
                         this.onError(this, this._compilationError);
                     }
                     this.onErrorObservable.notifyObservers(this);
+                    this.onErrorObservable.clear();
                 }
-            }
+            }            
         }
 
         public get isSupported(): boolean {
             return this._compilationError === "";
         }
 
-        public _bindTexture(channel: string, texture: WebGLTexture): void {
+        public _bindTexture(channel: string, texture: InternalTexture): void {
             this._engine._bindTexture(this._samplers.indexOf(channel), texture);
         }
 

+ 23 - 3
src/Materials/babylon.uniformBuffer.ts

@@ -144,6 +144,8 @@ module BABYLON {
                 this.updateColor3 = this._updateColor3ForEffect;
                 this.updateColor4 = this._updateColor4ForEffect;
             } else {
+                this._engine._uniformBuffers.push(this);
+                
                 this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
                 this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
                 this.updateFloat = this._updateFloatForUniform;
@@ -371,14 +373,22 @@ module BABYLON {
             this._fillAlignment(4);
             this._bufferData = new Float32Array(this._data);
 
+            this._rebuild();
+
+            this._needSync = true;
+        }
+        
+        public _rebuild(): void {
+            if (this._noUBO) {
+                return;
+            }
+
             if (this._dynamic) {
                 this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
             } else {
                 this._buffer = this._engine.createUniformBuffer(this._bufferData);
             }
-
-            this._needSync = true;
-        } 
+        }
 
         /**
          * Updates the WebGL Uniform Buffer on the GPU.
@@ -603,6 +613,16 @@ module BABYLON {
          * Disposes the uniform buffer.
          */
         public dispose(): void {
+            if (this._noUBO) {
+                return;
+            }
+
+            let index = this._engine._uniformBuffers.indexOf(this);
+
+            if (index !== -1) {
+                this._engine._uniformBuffers.splice(index, 1);
+            }
+
             if (!this._buffer) {
                 return;
             }

+ 1 - 1
src/Math/babylon.math.ts

@@ -4387,7 +4387,7 @@
         }
 
         public toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport {
-            if ((<Engine>renderWidthOrEngine)._gl) {
+            if ((<Engine>renderWidthOrEngine).getRenderWidth) {
                 var engine = (<Engine>renderWidthOrEngine);
                 return this.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
             }

+ 5 - 0
src/Mesh/babylon.buffer.ts

@@ -90,6 +90,11 @@
             }
         }
 
+        public _rebuild(): void {
+            this._buffer = null;
+            this.create(this._data);
+        }
+
         public update(data: number[] | Float32Array): void {
             this.create(data);
         }

+ 17 - 0
src/Mesh/babylon.geometry.ts

@@ -106,6 +106,23 @@
             return true;
         }
 
+        public _rebuild(): void {
+            if (this._vertexArrayObjects) {
+                this._vertexArrayObjects = {};
+            }
+
+            // Index buffer
+            if (this._meshes.length !== 0 && this._indices) {
+                this._indexBuffer = this._engine.createIndexBuffer(this._indices);
+            }
+
+            // Vertex buffers
+            for (var key in this._vertexBuffers) {
+                let vertexBuffer = <VertexBuffer>this._vertexBuffers[key];
+                vertexBuffer._rebuild();
+            }
+        }
+
         public setAllVerticesData(vertexData: VertexData, updatable?: boolean): void {
             vertexData.applyToGeometry(this, updatable);
             this.notifyUpdate();

+ 8 - 0
src/Mesh/babylon.vertexBuffer.ts

@@ -60,6 +60,14 @@
             this._kind = kind;
         }
 
+        public _rebuild(): void {
+            if (!this._buffer) {
+                return;
+            }
+
+            this._buffer._rebuild();
+        }
+
         /**
          * Returns the kind of the VertexBuffer (string).  
          */

+ 13 - 13
src/PostProcess/babylon.postProcess.ts

@@ -27,7 +27,7 @@
         private _options: number | PostProcessOptions;
         private _reusable = false;
         private _textureType: number;
-        public _textures = new SmartArray<WebGLTexture>(2);
+        public _textures = new SmartArray<InternalTexture>(2);
         public _currentRenderTextureInd = 0;
         private _effect: Effect;
         private _samplers: string[];
@@ -38,7 +38,7 @@
         protected _indexParameters: any;
         private _shareOutputWithPostProcess: PostProcess;
         private _texelSize = Vector2.Zero();
-        private _forcedOutputTexture: WebGLTexture;
+        private _forcedOutputTexture: InternalTexture;
        
         // Events
 
@@ -112,11 +112,11 @@
             this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
         }
 
-        public get outputTexture(): WebGLTexture {
+        public get outputTexture(): InternalTexture {
             return this._textures.data[this._currentRenderTextureInd];
         }   
 
-        public set outputTexture(value: WebGLTexture) {
+        public set outputTexture(value: InternalTexture) {
             this._forcedOutputTexture = value;
         }   
 
@@ -130,7 +130,7 @@
             }
 
             if (this._forcedOutputTexture) {
-                this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture._width, 1.0 / this._forcedOutputTexture._height);
+                this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
             }
 
             return this._texelSize;
@@ -207,7 +207,7 @@
             this.width = -1;
         }
 
-        public activate(camera: Camera, sourceTexture?: WebGLTexture, forceDepthStencil?: boolean): void {            
+        public activate(camera: Camera, sourceTexture?: InternalTexture, forceDepthStencil?: boolean): void {            
             if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
                 camera = camera || this._camera;
 
@@ -215,8 +215,8 @@
                 var engine = scene.getEngine();
                 var maxSize = engine.getCaps().maxTextureSize;
 
-                var requiredWidth = ((sourceTexture ? sourceTexture._width : this._engine.getRenderingCanvas().width) * <number>this._options) | 0;
-                var requiredHeight = ((sourceTexture ? sourceTexture._height : this._engine.getRenderingCanvas().height) * <number>this._options) | 0;
+                var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderingCanvas().width) * <number>this._options) | 0;
+                var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderingCanvas().height) * <number>this._options) | 0;
 
                 var desiredWidth = (<PostProcessOptions>this._options).width || requiredWidth;
                 var desiredHeight = (<PostProcessOptions>this._options).height || requiredHeight;
@@ -268,15 +268,15 @@
                 });
             }
 
-            var target: WebGLTexture;
+            var target: InternalTexture;
                         
             if (this._shareOutputWithPostProcess) {
                 target = this._shareOutputWithPostProcess.outputTexture;
             } else if (this._forcedOutputTexture) {
                 target = this._forcedOutputTexture;
 
-                this.width = this._forcedOutputTexture._width;
-                this.height = this._forcedOutputTexture._height;
+                this.width = this._forcedOutputTexture.width;
+                this.height = this._forcedOutputTexture.height;
             } else {
                 target = this.outputTexture;
             }
@@ -312,7 +312,7 @@
             }
 
             if (this._forcedOutputTexture) {
-                var size = this._forcedOutputTexture._width / this._forcedOutputTexture._height;
+                var size = this._forcedOutputTexture.width / this._forcedOutputTexture.height;
             }
 
             return this.width / this.height;
@@ -336,7 +336,7 @@
             }            
 
             // Texture            
-            var source: WebGLTexture;                        
+            var source: InternalTexture;                        
             if (this._shareOutputWithPostProcess) {
                 source = this._shareOutputWithPostProcess.outputTexture;
             } else if (this._forcedOutputTexture) {

+ 3 - 3
src/PostProcess/babylon.postProcessManager.ts

@@ -36,7 +36,7 @@
         }
 
         // Methods
-        public _prepareFrame(sourceTexture?: WebGLTexture, postProcesses?: PostProcess[]): boolean {
+        public _prepareFrame(sourceTexture?: InternalTexture, postProcesses?: PostProcess[]): boolean {
             var postProcesses = postProcesses || this._scene.activeCamera._postProcesses;
 
             if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
@@ -47,7 +47,7 @@
             return true;
         }
 
-        public directRender(postProcesses: PostProcess[], targetTexture?: WebGLTexture): void {
+        public directRender(postProcesses: PostProcess[], targetTexture?: InternalTexture): void {
             var engine = this._scene.getEngine();
 
             for (var index = 0; index < postProcesses.length; index++) {
@@ -83,7 +83,7 @@
             engine.setDepthWrite(true);
         }
 
-        public _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture, faceIndex?: number, postProcesses?: PostProcess[]): void {
+        public _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: PostProcess[]): void {
             postProcesses = postProcesses || this._scene.activeCamera._postProcesses;
             if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
                 return;

+ 1 - 2
src/Tools/babylon.dds.ts

@@ -359,8 +359,7 @@
             return byteArray;
         }
 
-        public static UploadDDSLevels(engine: Engine, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex = -1): void {
-            var gl = engine._gl;
+        public static UploadDDSLevels(engine: Engine, gl:WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex = -1): void {
             var ext = engine.getCaps().s3tc;
 
             var header = new Int32Array(arrayBuffer, 0, headerLengthInt),

文件差异内容过多而无法显示
+ 252 - 239
src/babylon.engine.ts


+ 0 - 37
src/babylon.mixins.ts

@@ -112,43 +112,6 @@ interface CanvasRenderingContext2D {
     msImageSmoothingEnabled: boolean;
 }
 
-interface WebGLTexture {
-    isReady: boolean;
-    isCube: boolean;
-    url: string;
-    samplingMode: number;
-    references: number;
-    generateMipMaps: boolean;
-    samples: number;
-    type: number;
-    format: number;
-    onLoadedCallbacks: Array<Function>;
-    _size: number;
-    _baseWidth: number;
-    _baseHeight: number;
-    _width: number;
-    _height: number;
-    _workingCanvas: HTMLCanvasElement;
-    _workingContext: CanvasRenderingContext2D;
-    _framebuffer: WebGLFramebuffer;
-    _depthStencilBuffer: WebGLRenderbuffer;
-    _MSAAFramebuffer: WebGLFramebuffer;
-    _MSAARenderBuffer: WebGLRenderbuffer;
-    _cachedCoordinatesMode: number;
-    _cachedWrapU: number;
-    _cachedWrapV: number;
-    _isDisabled: boolean;
-    _generateStencilBuffer: boolean;
-    _generateDepthBuffer: boolean;
-    _sphericalPolynomial: BABYLON.SphericalPolynomial;
-    // The following three fields helps sharing generated fixed LODs for texture filtering
-    // In environment not supporting the textureLOD extension like EDGE. They are for internal use only.
-    // They are at the level of the gl texture to benefit from the cache.
-    _lodTextureHigh: BABYLON.BaseTexture;
-    _lodTextureMid: BABYLON.BaseTexture;
-    _lodTextureLow: BABYLON.BaseTexture;
-}
-
 interface WebGLBuffer {
     references: number;
     capacity: number;

+ 6 - 0
src/babylon.scene.ts

@@ -3833,6 +3833,12 @@
         }
 
         // Misc.
+        public _rebuildGeometries(): void {
+            for (var geometry of this._geometries) {
+                geometry._rebuild();
+            }
+        }
+
         public createDefaultCameraOrLight(createArcRotateCamera = false, replace = false, attachCameraControls = false) {
             // Dispose existing camera or light in replace mode.
             if (replace) {