Browse Source

Fix occlusion queries dispose

David Catuhe 8 years ago
parent
commit
2d883bca41

File diff suppressed because it is too large
+ 676 - 671
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 39 - 39
dist/preview release/babylon.js


+ 94 - 41
dist/preview release/babylon.max.js

@@ -7412,6 +7412,15 @@ var BABYLON;
     }());
     }());
     BABYLON.InstancingAttributeInfo = InstancingAttributeInfo;
     BABYLON.InstancingAttributeInfo = InstancingAttributeInfo;
     /**
     /**
+     * Define options used to create a render target texture
+     */
+    var RenderTargetCreationOptions = (function () {
+        function RenderTargetCreationOptions() {
+        }
+        return RenderTargetCreationOptions;
+    }());
+    BABYLON.RenderTargetCreationOptions = RenderTargetCreationOptions;
+    /**
      * Regroup several parameters relative to the browser in use
      * Regroup several parameters relative to the browser in use
      */
      */
     var EngineCapabilities = (function () {
     var EngineCapabilities = (function () {
@@ -7601,7 +7610,6 @@ var BABYLON;
                     BABYLON.Tools.Warn("WebGL context lost.");
                     BABYLON.Tools.Warn("WebGL context lost.");
                 };
                 };
                 this._onContextRestored = function (evt) {
                 this._onContextRestored = function (evt) {
-                    _this._contextWasLost = false;
                     // Rebuild gl context
                     // Rebuild gl context
                     _this._initGLContext();
                     _this._initGLContext();
                     // Rebuild effects
                     // Rebuild effects
@@ -7612,9 +7620,8 @@ var BABYLON;
                     _this._rebuildBuffers();
                     _this._rebuildBuffers();
                     // Cache
                     // Cache
                     _this.wipeCaches(true);
                     _this.wipeCaches(true);
-                    // Restart render loop
-                    _this._renderLoop();
                     BABYLON.Tools.Warn("WebGL context successfully restored.");
                     BABYLON.Tools.Warn("WebGL context successfully restored.");
+                    _this._contextWasLost = false;
                 };
                 };
                 canvas.addEventListener("webglcontextlost", this._onContextLost, false);
                 canvas.addEventListener("webglcontextlost", this._onContextLost, false);
                 canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
                 canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
@@ -9726,6 +9733,12 @@ var BABYLON;
             var internalFormat = this._getInternalFormat(format);
             var internalFormat = this._getInternalFormat(format);
             this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
             this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
             this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, invertY === undefined ? 1 : (invertY ? 1 : 0));
             this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, invertY === undefined ? 1 : (invertY ? 1 : 0));
+            if (!this._doNotHandleContextLost) {
+                texture._bufferView = data;
+                texture.format = format;
+                texture.invertY = invertY;
+                texture._compression = compression;
+            }
             if (texture.width % 4 !== 0) {
             if (texture.width % 4 !== 0) {
                 this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
                 this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
             }
             }
@@ -9749,6 +9762,14 @@ var BABYLON;
             texture.baseHeight = height;
             texture.baseHeight = height;
             texture.width = width;
             texture.width = width;
             texture.height = height;
             texture.height = height;
+            texture.format = format;
+            texture.generateMipMaps = generateMipMaps;
+            texture.samplingMode = samplingMode;
+            texture.invertY = invertY;
+            texture._compression = compression;
+            if (!this._doNotHandleContextLost) {
+                texture._bufferView = data;
+            }
             this.updateRawTexture(texture, data, format, invertY, compression);
             this.updateRawTexture(texture, data, format, invertY, compression);
             this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
             this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
             // Filters
             // Filters
@@ -9759,7 +9780,6 @@ var BABYLON;
                 this._gl.generateMipmap(this._gl.TEXTURE_2D);
                 this._gl.generateMipmap(this._gl.TEXTURE_2D);
             }
             }
             this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
             this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
-            texture.samplingMode = samplingMode;
             this._internalTexturesCache.push(texture);
             this._internalTexturesCache.push(texture);
             return texture;
             return texture;
         };
         };
@@ -9861,52 +9881,50 @@ var BABYLON;
             }
             }
         };
         };
         Engine.prototype.createRenderTargetTexture = function (size, options) {
         Engine.prototype.createRenderTargetTexture = function (size, options) {
-            // old version had a "generateMipMaps" arg instead of options.
-            // if options.generateMipMaps is undefined, consider that options itself if the generateMipmaps value
-            // in the same way, generateDepthBuffer is defaulted to true
-            var generateMipMaps = false;
-            var generateDepthBuffer = true;
-            var generateStencilBuffer = false;
-            var type = Engine.TEXTURETYPE_UNSIGNED_INT;
-            var samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE;
-            if (options !== undefined) {
-                generateMipMaps = options.generateMipMaps === undefined ? options : options.generateMipMaps;
-                generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
-                generateStencilBuffer = generateDepthBuffer && options.generateStencilBuffer;
-                type = options.type === undefined ? type : options.type;
-                if (options.samplingMode !== undefined) {
-                    samplingMode = options.samplingMode;
-                }
-                if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
-                    // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
-                    samplingMode = BABYLON.Texture.NEAREST_SAMPLINGMODE;
-                }
-                else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
-                    // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
-                    samplingMode = BABYLON.Texture.NEAREST_SAMPLINGMODE;
-                }
+            var fullOptions = new RenderTargetCreationOptions();
+            if (options !== undefined && typeof options === "object") {
+                fullOptions.generateMipMaps = options.generateMipMaps;
+                fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
+                fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
+                fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
+                fullOptions.samplingMode = options.samplingMode === undefined ? BABYLON.Texture.TRILINEAR_SAMPLINGMODE : options.samplingMode;
+            }
+            else {
+                fullOptions.generateMipMaps = options;
+                fullOptions.generateDepthBuffer = true;
+                fullOptions.generateStencilBuffer = false;
+                fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
+                fullOptions.samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE;
+            }
+            if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
+                // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
+                fullOptions.samplingMode = BABYLON.Texture.NEAREST_SAMPLINGMODE;
+            }
+            else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
+                // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
+                fullOptions.samplingMode = BABYLON.Texture.NEAREST_SAMPLINGMODE;
             }
             }
             var gl = this._gl;
             var gl = this._gl;
             var texture = new BABYLON.InternalTexture(this, BABYLON.InternalTexture.DATASOURCE_RENDERTARGET);
             var texture = new BABYLON.InternalTexture(this, BABYLON.InternalTexture.DATASOURCE_RENDERTARGET);
             this._bindTextureDirectly(gl.TEXTURE_2D, texture);
             this._bindTextureDirectly(gl.TEXTURE_2D, texture);
             var width = size.width || size;
             var width = size.width || size;
             var height = size.height || size;
             var height = size.height || size;
-            var filters = getSamplingParameters(samplingMode, generateMipMaps, gl);
-            if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
-                type = Engine.TEXTURETYPE_UNSIGNED_INT;
+            var filters = getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps, gl);
+            if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
+                fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
                 BABYLON.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
                 BABYLON.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
             }
             }
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
-            gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
+            gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type), width, height, 0, gl.RGBA, this._getWebGLTextureType(fullOptions.type), null);
             // Create the framebuffer
             // Create the framebuffer
             var framebuffer = gl.createFramebuffer();
             var framebuffer = gl.createFramebuffer();
             this.bindUnboundFramebuffer(framebuffer);
             this.bindUnboundFramebuffer(framebuffer);
             gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
             gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
-            texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
-            if (generateMipMaps) {
+            texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, width, height);
+            if (fullOptions.generateMipMaps) {
                 this._gl.generateMipmap(this._gl.TEXTURE_2D);
                 this._gl.generateMipmap(this._gl.TEXTURE_2D);
             }
             }
             // Unbind
             // Unbind
@@ -9920,11 +9938,11 @@ var BABYLON;
             texture.height = height;
             texture.height = height;
             texture.isReady = true;
             texture.isReady = true;
             texture.samples = 1;
             texture.samples = 1;
-            texture.generateMipMaps = generateMipMaps;
-            texture.samplingMode = samplingMode;
-            texture.type = type;
-            texture._generateDepthBuffer = generateDepthBuffer;
-            texture._generateStencilBuffer = generateStencilBuffer;
+            texture.generateMipMaps = fullOptions.generateMipMaps;
+            texture.samplingMode = fullOptions.samplingMode;
+            texture.type = fullOptions.type;
+            texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
+            texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
             this.resetTextureCache();
             this.resetTextureCache();
             this._internalTexturesCache.push(texture);
             this._internalTexturesCache.push(texture);
             return texture;
             return texture;
@@ -10119,7 +10137,7 @@ var BABYLON;
             var generateStencilBuffer = false;
             var generateStencilBuffer = false;
             var samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE;
             var samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE;
             if (options !== undefined) {
             if (options !== undefined) {
-                generateMipMaps = options.generateMipMaps === undefined ? options : options.generateMipMaps;
+                generateMipMaps = options.generateMipMaps === undefined ? true : options.generateMipMaps;
                 generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
                 generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
                 generateStencilBuffer = generateDepthBuffer && options.generateStencilBuffer;
                 generateStencilBuffer = generateDepthBuffer && options.generateStencilBuffer;
                 if (options.samplingMode !== undefined) {
                 if (options.samplingMode !== undefined) {
@@ -11075,7 +11093,7 @@ var BABYLON;
             return this._gl.createQuery();
             return this._gl.createQuery();
         };
         };
         Engine.prototype.deleteQuery = function (query) {
         Engine.prototype.deleteQuery = function (query) {
-            this.deleteQuery(query);
+            this._gl.deleteQuery(query);
             return this;
             return this;
         };
         };
         Engine.prototype.isQueryResultAvailable = function (query) {
         Engine.prototype.isQueryResultAvailable = function (query) {
@@ -12342,6 +12360,9 @@ var BABYLON;
             return ret;
             return ret;
         };
         };
         AbstractMesh.prototype._rebuild = function () {
         AbstractMesh.prototype._rebuild = function () {
+            if (this._occlusionQuery) {
+                this._occlusionQuery = null;
+            }
             if (!this.subMeshes) {
             if (!this.subMeshes) {
                 return;
                 return;
             }
             }
@@ -13559,6 +13580,7 @@ var BABYLON;
             // Query
             // Query
             var engine = this.getScene().getEngine();
             var engine = this.getScene().getEngine();
             if (this._occlusionQuery) {
             if (this._occlusionQuery) {
+                this._isOcclusionQueryInProgress = false;
                 engine.deleteQuery(this._occlusionQuery);
                 engine.deleteQuery(this._occlusionQuery);
                 this._occlusionQuery = null;
                 this._occlusionQuery = null;
             }
             }
@@ -19971,11 +19993,36 @@ var BABYLON;
                     }, null, this._buffer, null, this.format);
                     }, null, this._buffer, null, this.format);
                     proxy._swapAndDie(this);
                     proxy._swapAndDie(this);
                     return;
                     return;
+                case InternalTexture.DATASOURCE_RAW:
+                    proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
+                    proxy._swapAndDie(this);
+                    this.isReady = true;
+                    return;
                 case InternalTexture.DATASOURCE_DYNAMIC:
                 case InternalTexture.DATASOURCE_DYNAMIC:
                     proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
                     proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
                     proxy._swapAndDie(this);
                     proxy._swapAndDie(this);
                     // The engine will make sure to update content so no need to flag it as isReady = true
                     // The engine will make sure to update content so no need to flag it as isReady = true
                     return;
                     return;
+                case InternalTexture.DATASOURCE_RENDERTARGET:
+                    var options = new BABYLON.RenderTargetCreationOptions();
+                    options.generateDepthBuffer = this._generateDepthBuffer;
+                    options.generateMipMaps = this.generateMipMaps;
+                    options.generateStencilBuffer = this._generateStencilBuffer;
+                    options.samplingMode = this.samplingMode;
+                    options.type = this.type;
+                    if (this.isCube) {
+                        proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
+                    }
+                    else {
+                        var size = {
+                            width: this.width,
+                            height: this.height
+                        };
+                        proxy = this._engine.createRenderTargetTexture(size, options);
+                    }
+                    proxy._swapAndDie(this);
+                    this.isReady = true;
+                    return;
                 case InternalTexture.DATASOURCE_CUBE:
                 case InternalTexture.DATASOURCE_CUBE:
                     proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
                     proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
                         _this.isReady = true;
                         _this.isReady = true;
@@ -19992,6 +20039,12 @@ var BABYLON;
         };
         };
         InternalTexture.prototype._swapAndDie = function (target) {
         InternalTexture.prototype._swapAndDie = function (target) {
             target._webGLTexture = this._webGLTexture;
             target._webGLTexture = this._webGLTexture;
+            if (this._framebuffer) {
+                target._framebuffer = this._framebuffer;
+            }
+            if (this._depthStencilBuffer) {
+                target._depthStencilBuffer = this._depthStencilBuffer;
+            }
             if (this._lodTextureHigh) {
             if (this._lodTextureHigh) {
                 if (target._lodTextureHigh) {
                 if (target._lodTextureHigh) {
                     target._lodTextureHigh.dispose();
                     target._lodTextureHigh.dispose();

File diff suppressed because it is too large
+ 676 - 671
dist/preview release/babylon.module.d.ts


File diff suppressed because it is too large
+ 39 - 39
dist/preview release/babylon.worker.js


File diff suppressed because it is too large
+ 1550 - 1545
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


File diff suppressed because it is too large
+ 25 - 25
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 94 - 41
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -7412,6 +7412,15 @@ var BABYLON;
     }());
     }());
     BABYLON.InstancingAttributeInfo = InstancingAttributeInfo;
     BABYLON.InstancingAttributeInfo = InstancingAttributeInfo;
     /**
     /**
+     * Define options used to create a render target texture
+     */
+    var RenderTargetCreationOptions = (function () {
+        function RenderTargetCreationOptions() {
+        }
+        return RenderTargetCreationOptions;
+    }());
+    BABYLON.RenderTargetCreationOptions = RenderTargetCreationOptions;
+    /**
      * Regroup several parameters relative to the browser in use
      * Regroup several parameters relative to the browser in use
      */
      */
     var EngineCapabilities = (function () {
     var EngineCapabilities = (function () {
@@ -7601,7 +7610,6 @@ var BABYLON;
                     BABYLON.Tools.Warn("WebGL context lost.");
                     BABYLON.Tools.Warn("WebGL context lost.");
                 };
                 };
                 this._onContextRestored = function (evt) {
                 this._onContextRestored = function (evt) {
-                    _this._contextWasLost = false;
                     // Rebuild gl context
                     // Rebuild gl context
                     _this._initGLContext();
                     _this._initGLContext();
                     // Rebuild effects
                     // Rebuild effects
@@ -7612,9 +7620,8 @@ var BABYLON;
                     _this._rebuildBuffers();
                     _this._rebuildBuffers();
                     // Cache
                     // Cache
                     _this.wipeCaches(true);
                     _this.wipeCaches(true);
-                    // Restart render loop
-                    _this._renderLoop();
                     BABYLON.Tools.Warn("WebGL context successfully restored.");
                     BABYLON.Tools.Warn("WebGL context successfully restored.");
+                    _this._contextWasLost = false;
                 };
                 };
                 canvas.addEventListener("webglcontextlost", this._onContextLost, false);
                 canvas.addEventListener("webglcontextlost", this._onContextLost, false);
                 canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
                 canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
@@ -9726,6 +9733,12 @@ var BABYLON;
             var internalFormat = this._getInternalFormat(format);
             var internalFormat = this._getInternalFormat(format);
             this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
             this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
             this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, invertY === undefined ? 1 : (invertY ? 1 : 0));
             this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, invertY === undefined ? 1 : (invertY ? 1 : 0));
+            if (!this._doNotHandleContextLost) {
+                texture._bufferView = data;
+                texture.format = format;
+                texture.invertY = invertY;
+                texture._compression = compression;
+            }
             if (texture.width % 4 !== 0) {
             if (texture.width % 4 !== 0) {
                 this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
                 this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
             }
             }
@@ -9749,6 +9762,14 @@ var BABYLON;
             texture.baseHeight = height;
             texture.baseHeight = height;
             texture.width = width;
             texture.width = width;
             texture.height = height;
             texture.height = height;
+            texture.format = format;
+            texture.generateMipMaps = generateMipMaps;
+            texture.samplingMode = samplingMode;
+            texture.invertY = invertY;
+            texture._compression = compression;
+            if (!this._doNotHandleContextLost) {
+                texture._bufferView = data;
+            }
             this.updateRawTexture(texture, data, format, invertY, compression);
             this.updateRawTexture(texture, data, format, invertY, compression);
             this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
             this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
             // Filters
             // Filters
@@ -9759,7 +9780,6 @@ var BABYLON;
                 this._gl.generateMipmap(this._gl.TEXTURE_2D);
                 this._gl.generateMipmap(this._gl.TEXTURE_2D);
             }
             }
             this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
             this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
-            texture.samplingMode = samplingMode;
             this._internalTexturesCache.push(texture);
             this._internalTexturesCache.push(texture);
             return texture;
             return texture;
         };
         };
@@ -9861,52 +9881,50 @@ var BABYLON;
             }
             }
         };
         };
         Engine.prototype.createRenderTargetTexture = function (size, options) {
         Engine.prototype.createRenderTargetTexture = function (size, options) {
-            // old version had a "generateMipMaps" arg instead of options.
-            // if options.generateMipMaps is undefined, consider that options itself if the generateMipmaps value
-            // in the same way, generateDepthBuffer is defaulted to true
-            var generateMipMaps = false;
-            var generateDepthBuffer = true;
-            var generateStencilBuffer = false;
-            var type = Engine.TEXTURETYPE_UNSIGNED_INT;
-            var samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE;
-            if (options !== undefined) {
-                generateMipMaps = options.generateMipMaps === undefined ? options : options.generateMipMaps;
-                generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
-                generateStencilBuffer = generateDepthBuffer && options.generateStencilBuffer;
-                type = options.type === undefined ? type : options.type;
-                if (options.samplingMode !== undefined) {
-                    samplingMode = options.samplingMode;
-                }
-                if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
-                    // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
-                    samplingMode = BABYLON.Texture.NEAREST_SAMPLINGMODE;
-                }
-                else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
-                    // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
-                    samplingMode = BABYLON.Texture.NEAREST_SAMPLINGMODE;
-                }
+            var fullOptions = new RenderTargetCreationOptions();
+            if (options !== undefined && typeof options === "object") {
+                fullOptions.generateMipMaps = options.generateMipMaps;
+                fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
+                fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
+                fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
+                fullOptions.samplingMode = options.samplingMode === undefined ? BABYLON.Texture.TRILINEAR_SAMPLINGMODE : options.samplingMode;
+            }
+            else {
+                fullOptions.generateMipMaps = options;
+                fullOptions.generateDepthBuffer = true;
+                fullOptions.generateStencilBuffer = false;
+                fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
+                fullOptions.samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE;
+            }
+            if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
+                // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
+                fullOptions.samplingMode = BABYLON.Texture.NEAREST_SAMPLINGMODE;
+            }
+            else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
+                // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
+                fullOptions.samplingMode = BABYLON.Texture.NEAREST_SAMPLINGMODE;
             }
             }
             var gl = this._gl;
             var gl = this._gl;
             var texture = new BABYLON.InternalTexture(this, BABYLON.InternalTexture.DATASOURCE_RENDERTARGET);
             var texture = new BABYLON.InternalTexture(this, BABYLON.InternalTexture.DATASOURCE_RENDERTARGET);
             this._bindTextureDirectly(gl.TEXTURE_2D, texture);
             this._bindTextureDirectly(gl.TEXTURE_2D, texture);
             var width = size.width || size;
             var width = size.width || size;
             var height = size.height || size;
             var height = size.height || size;
-            var filters = getSamplingParameters(samplingMode, generateMipMaps, gl);
-            if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
-                type = Engine.TEXTURETYPE_UNSIGNED_INT;
+            var filters = getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps, gl);
+            if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
+                fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
                 BABYLON.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
                 BABYLON.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
             }
             }
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
-            gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
+            gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type), width, height, 0, gl.RGBA, this._getWebGLTextureType(fullOptions.type), null);
             // Create the framebuffer
             // Create the framebuffer
             var framebuffer = gl.createFramebuffer();
             var framebuffer = gl.createFramebuffer();
             this.bindUnboundFramebuffer(framebuffer);
             this.bindUnboundFramebuffer(framebuffer);
             gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
             gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
-            texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
-            if (generateMipMaps) {
+            texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, width, height);
+            if (fullOptions.generateMipMaps) {
                 this._gl.generateMipmap(this._gl.TEXTURE_2D);
                 this._gl.generateMipmap(this._gl.TEXTURE_2D);
             }
             }
             // Unbind
             // Unbind
@@ -9920,11 +9938,11 @@ var BABYLON;
             texture.height = height;
             texture.height = height;
             texture.isReady = true;
             texture.isReady = true;
             texture.samples = 1;
             texture.samples = 1;
-            texture.generateMipMaps = generateMipMaps;
-            texture.samplingMode = samplingMode;
-            texture.type = type;
-            texture._generateDepthBuffer = generateDepthBuffer;
-            texture._generateStencilBuffer = generateStencilBuffer;
+            texture.generateMipMaps = fullOptions.generateMipMaps;
+            texture.samplingMode = fullOptions.samplingMode;
+            texture.type = fullOptions.type;
+            texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
+            texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
             this.resetTextureCache();
             this.resetTextureCache();
             this._internalTexturesCache.push(texture);
             this._internalTexturesCache.push(texture);
             return texture;
             return texture;
@@ -10119,7 +10137,7 @@ var BABYLON;
             var generateStencilBuffer = false;
             var generateStencilBuffer = false;
             var samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE;
             var samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE;
             if (options !== undefined) {
             if (options !== undefined) {
-                generateMipMaps = options.generateMipMaps === undefined ? options : options.generateMipMaps;
+                generateMipMaps = options.generateMipMaps === undefined ? true : options.generateMipMaps;
                 generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
                 generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
                 generateStencilBuffer = generateDepthBuffer && options.generateStencilBuffer;
                 generateStencilBuffer = generateDepthBuffer && options.generateStencilBuffer;
                 if (options.samplingMode !== undefined) {
                 if (options.samplingMode !== undefined) {
@@ -11075,7 +11093,7 @@ var BABYLON;
             return this._gl.createQuery();
             return this._gl.createQuery();
         };
         };
         Engine.prototype.deleteQuery = function (query) {
         Engine.prototype.deleteQuery = function (query) {
-            this.deleteQuery(query);
+            this._gl.deleteQuery(query);
             return this;
             return this;
         };
         };
         Engine.prototype.isQueryResultAvailable = function (query) {
         Engine.prototype.isQueryResultAvailable = function (query) {
@@ -12342,6 +12360,9 @@ var BABYLON;
             return ret;
             return ret;
         };
         };
         AbstractMesh.prototype._rebuild = function () {
         AbstractMesh.prototype._rebuild = function () {
+            if (this._occlusionQuery) {
+                this._occlusionQuery = null;
+            }
             if (!this.subMeshes) {
             if (!this.subMeshes) {
                 return;
                 return;
             }
             }
@@ -13559,6 +13580,7 @@ var BABYLON;
             // Query
             // Query
             var engine = this.getScene().getEngine();
             var engine = this.getScene().getEngine();
             if (this._occlusionQuery) {
             if (this._occlusionQuery) {
+                this._isOcclusionQueryInProgress = false;
                 engine.deleteQuery(this._occlusionQuery);
                 engine.deleteQuery(this._occlusionQuery);
                 this._occlusionQuery = null;
                 this._occlusionQuery = null;
             }
             }
@@ -19971,11 +19993,36 @@ var BABYLON;
                     }, null, this._buffer, null, this.format);
                     }, null, this._buffer, null, this.format);
                     proxy._swapAndDie(this);
                     proxy._swapAndDie(this);
                     return;
                     return;
+                case InternalTexture.DATASOURCE_RAW:
+                    proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
+                    proxy._swapAndDie(this);
+                    this.isReady = true;
+                    return;
                 case InternalTexture.DATASOURCE_DYNAMIC:
                 case InternalTexture.DATASOURCE_DYNAMIC:
                     proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
                     proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
                     proxy._swapAndDie(this);
                     proxy._swapAndDie(this);
                     // The engine will make sure to update content so no need to flag it as isReady = true
                     // The engine will make sure to update content so no need to flag it as isReady = true
                     return;
                     return;
+                case InternalTexture.DATASOURCE_RENDERTARGET:
+                    var options = new BABYLON.RenderTargetCreationOptions();
+                    options.generateDepthBuffer = this._generateDepthBuffer;
+                    options.generateMipMaps = this.generateMipMaps;
+                    options.generateStencilBuffer = this._generateStencilBuffer;
+                    options.samplingMode = this.samplingMode;
+                    options.type = this.type;
+                    if (this.isCube) {
+                        proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
+                    }
+                    else {
+                        var size = {
+                            width: this.width,
+                            height: this.height
+                        };
+                        proxy = this._engine.createRenderTargetTexture(size, options);
+                    }
+                    proxy._swapAndDie(this);
+                    this.isReady = true;
+                    return;
                 case InternalTexture.DATASOURCE_CUBE:
                 case InternalTexture.DATASOURCE_CUBE:
                     proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
                     proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
                         _this.isReady = true;
                         _this.isReady = true;
@@ -19992,6 +20039,12 @@ var BABYLON;
         };
         };
         InternalTexture.prototype._swapAndDie = function (target) {
         InternalTexture.prototype._swapAndDie = function (target) {
             target._webGLTexture = this._webGLTexture;
             target._webGLTexture = this._webGLTexture;
+            if (this._framebuffer) {
+                target._framebuffer = this._framebuffer;
+            }
+            if (this._depthStencilBuffer) {
+                target._depthStencilBuffer = this._depthStencilBuffer;
+            }
             if (this._lodTextureHigh) {
             if (this._lodTextureHigh) {
                 if (target._lodTextureHigh) {
                 if (target._lodTextureHigh) {
                     target._lodTextureHigh.dispose();
                     target._lodTextureHigh.dispose();

File diff suppressed because it is too large
+ 1550 - 1545
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


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

@@ -30,6 +30,7 @@ module BABYLON {
         // Private
         // Private
         public _dataSource = InternalTexture.DATASOURCE_UNKNOWN;
         public _dataSource = InternalTexture.DATASOURCE_UNKNOWN;
         public _buffer: ArrayBuffer | HTMLImageElement;
         public _buffer: ArrayBuffer | HTMLImageElement;
+        public _bufferView: ArrayBufferView;
         public _size: number;
         public _size: number;
         public _extension: string;
         public _extension: string;
         public _files: string[];
         public _files: string[];
@@ -44,6 +45,7 @@ module BABYLON {
         public _cachedWrapV: number;
         public _cachedWrapV: number;
         public _cachedAnisotropicFilteringLevel: number;
         public _cachedAnisotropicFilteringLevel: number;
         public _isDisabled: boolean;
         public _isDisabled: boolean;
+        public _compression: string;
         public _generateStencilBuffer: boolean;
         public _generateStencilBuffer: boolean;
         public _generateDepthBuffer: boolean;
         public _generateDepthBuffer: boolean;
         public _sphericalPolynomial: BABYLON.SphericalPolynomial;
         public _sphericalPolynomial: BABYLON.SphericalPolynomial;
@@ -101,6 +103,14 @@ module BABYLON {
                     }, null, this._buffer, null, this.format); 
                     }, null, this._buffer, null, this.format); 
                     proxy._swapAndDie(this);
                     proxy._swapAndDie(this);
                     return;
                     return;
+
+                case InternalTexture.DATASOURCE_RAW:
+                    proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, 
+                                                            this.invertY, this.samplingMode, this._compression); 
+                    proxy._swapAndDie(this);
+
+                    this.isReady = true;
+                return;                    
                 
                 
                 case InternalTexture.DATASOURCE_DYNAMIC:
                 case InternalTexture.DATASOURCE_DYNAMIC:
                     proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode); 
                     proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode); 
@@ -109,6 +119,29 @@ module BABYLON {
                     // The engine will make sure to update content so no need to flag it as isReady = true
                     // The engine will make sure to update content so no need to flag it as isReady = true
                 return;
                 return;
 
 
+                case InternalTexture.DATASOURCE_RENDERTARGET:
+                    let options = new RenderTargetCreationOptions();
+                    options.generateDepthBuffer = this._generateDepthBuffer;
+                    options.generateMipMaps = this.generateMipMaps;
+                    options.generateStencilBuffer = this._generateStencilBuffer;
+                    options.samplingMode = this.samplingMode;
+                    options.type = this.type;
+
+                    if (this.isCube) {
+                        proxy = this._engine.createRenderTargetCubeTexture(this.width, options); 
+                    } else {
+                        let size = {
+                            width: this.width,
+                            height: this.height
+                        }
+
+                        proxy = this._engine.createRenderTargetTexture(size, options); 
+                    }
+                    proxy._swapAndDie(this);
+
+                    this.isReady = true;
+                return;                
+
                 case InternalTexture.DATASOURCE_CUBE:
                 case InternalTexture.DATASOURCE_CUBE:
                     proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, () => {
                     proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, () => {
                         this.isReady = true;
                         this.isReady = true;
@@ -129,6 +162,14 @@ module BABYLON {
         private _swapAndDie(target: InternalTexture): void {
         private _swapAndDie(target: InternalTexture): void {
             target._webGLTexture = this._webGLTexture;
             target._webGLTexture = this._webGLTexture;
 
 
+            if (this._framebuffer) {
+                target._framebuffer = this._framebuffer;
+            }
+
+            if (this._depthStencilBuffer) {
+                target._depthStencilBuffer = this._depthStencilBuffer;
+            }
+
             if (this._lodTextureHigh) {
             if (this._lodTextureHigh) {
                 if (target._lodTextureHigh) {
                 if (target._lodTextureHigh) {
                     target._lodTextureHigh.dispose();
                     target._lodTextureHigh.dispose();

+ 2 - 10
src/Materials/Textures/babylon.renderTargetTexture.ts

@@ -1,12 +1,4 @@
 module BABYLON {
 module BABYLON {
-    export interface IRenderTargetOptions {
-        generateMipMaps: boolean,
-        type: number,
-        samplingMode: number,
-        generateDepthBuffer: boolean,
-        generateStencilBuffer: boolean
-    }
-
     export class RenderTargetTexture extends Texture {
     export class RenderTargetTexture extends Texture {
         public static _REFRESHRATE_RENDER_ONCE: number = 0;
         public static _REFRESHRATE_RENDER_ONCE: number = 0;
         public static _REFRESHRATE_RENDER_ONEVERYFRAME: number = 1;
         public static _REFRESHRATE_RENDER_ONEVERYFRAME: number = 1;
@@ -119,8 +111,8 @@
         protected _refreshRate = 1;
         protected _refreshRate = 1;
         protected _textureMatrix: Matrix;
         protected _textureMatrix: Matrix;
         protected _samples = 1;
         protected _samples = 1;
-        protected _renderTargetOptions: IRenderTargetOptions;
-        public get renderTargetOptions(): IRenderTargetOptions {
+        protected _renderTargetOptions: RenderTargetCreationOptions;
+        public get renderTargetOptions(): RenderTargetCreationOptions {
             return this._renderTargetOptions;
             return this._renderTargetOptions;
         }
         }
 
 

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

@@ -473,6 +473,10 @@
         }
         }
 
 
         public _rebuild(): void {
         public _rebuild(): void {
+            if (this._occlusionQuery) {
+                this._occlusionQuery = null;
+            }
+
             if (!this.subMeshes) {
             if (!this.subMeshes) {
                 return;
                 return;
             }
             }
@@ -1836,6 +1840,7 @@
             // Query
             // Query
             let engine = this.getScene().getEngine();
             let engine = this.getScene().getEngine();
             if (this._occlusionQuery) {
             if (this._occlusionQuery) {
+                this._isOcclusionQueryInProgress = false;
                 engine.deleteQuery(this._occlusionQuery);
                 engine.deleteQuery(this._occlusionQuery);
                 this._occlusionQuery = null;
                 this._occlusionQuery = null;
             }
             }

+ 67 - 47
src/babylon.engine.ts

@@ -194,6 +194,17 @@
     }
     }
 
 
     /**
     /**
+     * Define options used to create a render target texture
+     */
+    export class RenderTargetCreationOptions {
+        generateMipMaps?: boolean;
+        generateDepthBuffer?: boolean;
+        generateStencilBuffer?: boolean;
+        type?: number;
+        samplingMode?: number;
+    }
+
+    /**
      * Regroup several parameters relative to the browser in use
      * Regroup several parameters relative to the browser in use
      */
      */
     export class EngineCapabilities {
     export class EngineCapabilities {
@@ -801,12 +812,10 @@
                 this._onContextLost = (evt: Event) => {
                 this._onContextLost = (evt: Event) => {
                     evt.preventDefault();
                     evt.preventDefault();
                     this._contextWasLost = true;
                     this._contextWasLost = true;
-                    Tools.Warn("WebGL context lost.")
+                    Tools.Warn("WebGL context lost.");
                 };
                 };
 
 
                 this._onContextRestored = (evt: Event) => {
                 this._onContextRestored = (evt: Event) => {
-                    this._contextWasLost = false;
-
                     // Rebuild gl context
                     // Rebuild gl context
                     this._initGLContext();
                     this._initGLContext();
 
 
@@ -822,10 +831,9 @@
                     // Cache
                     // Cache
                     this.wipeCaches(true);
                     this.wipeCaches(true);
 
 
-                    // Restart render loop
-                    this._renderLoop();
-
-                    Tools.Warn("WebGL context successfully restored.")
+                    Tools.Warn("WebGL context successfully restored.");
+                
+                    this._contextWasLost = false;
                 };
                 };
 
 
                 canvas.addEventListener("webglcontextlost", this._onContextLost, false);
                 canvas.addEventListener("webglcontextlost", this._onContextLost, false);
@@ -2851,6 +2859,13 @@
             this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
             this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
             this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, invertY === undefined ? 1 : (invertY ? 1 : 0));
             this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, invertY === undefined ? 1 : (invertY ? 1 : 0));
 
 
+            if (!this._doNotHandleContextLost) {
+                texture._bufferView = data;
+                texture.format = format;
+                texture.invertY = invertY;
+                texture._compression = compression;
+            }
+
             if (texture.width % 4 !== 0) {
             if (texture.width % 4 !== 0) {
                 this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
                 this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
             }
             }
@@ -2875,6 +2890,15 @@
             texture.baseHeight = height;
             texture.baseHeight = height;
             texture.width = width;
             texture.width = width;
             texture.height = height;
             texture.height = height;
+            texture.format = format;
+            texture.generateMipMaps = generateMipMaps;
+            texture.samplingMode = samplingMode;
+            texture.invertY = invertY;
+            texture._compression = compression;
+            
+            if (!this._doNotHandleContextLost) {
+                texture._bufferView = data;
+            }
 
 
             this.updateRawTexture(texture, data, format, invertY, compression);
             this.updateRawTexture(texture, data, format, invertY, compression);
             this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
             this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
@@ -2891,7 +2915,6 @@
 
 
             this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
             this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
 
 
-            texture.samplingMode = samplingMode;
 
 
             this._internalTexturesCache.push(texture);
             this._internalTexturesCache.push(texture);
 
 
@@ -3012,33 +3035,30 @@
             }
             }
         }
         }
 
 
-        public createRenderTargetTexture(size: any, options): InternalTexture {
-            // old version had a "generateMipMaps" arg instead of options.
-            // if options.generateMipMaps is undefined, consider that options itself if the generateMipmaps value
-            // in the same way, generateDepthBuffer is defaulted to true
-            var generateMipMaps = false;
-            var generateDepthBuffer = true;
-            var generateStencilBuffer = false;
+        public createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture {
+            let fullOptions = new RenderTargetCreationOptions();
 
 
-            var type = Engine.TEXTURETYPE_UNSIGNED_INT;
-            var samplingMode = Texture.TRILINEAR_SAMPLINGMODE;
-            if (options !== undefined) {
-                generateMipMaps = options.generateMipMaps === undefined ? options : options.generateMipMaps;
-                generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
-                generateStencilBuffer = generateDepthBuffer && options.generateStencilBuffer;
+            if (options !== undefined && typeof options === "object") {
+                fullOptions.generateMipMaps = options.generateMipMaps;
+                fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
+                fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
+                fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type ;
+                fullOptions.samplingMode = options.samplingMode === undefined ? Texture.TRILINEAR_SAMPLINGMODE : options.samplingMode;
+            } else {
+                fullOptions.generateMipMaps = <boolean>options;
+                fullOptions.generateDepthBuffer = true;
+                fullOptions.generateStencilBuffer = false;
+                fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
+                fullOptions.samplingMode = Texture.TRILINEAR_SAMPLINGMODE;
+            }
 
 
-                type = options.type === undefined ? type : options.type;
-                if (options.samplingMode !== undefined) {
-                    samplingMode = options.samplingMode;
-                }
-                if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
-                    // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
-                    samplingMode = Texture.NEAREST_SAMPLINGMODE;
-                }
-                else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
-                    // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
-                    samplingMode = Texture.NEAREST_SAMPLINGMODE;
-                }
+            if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
+                // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
+                fullOptions.samplingMode = Texture.NEAREST_SAMPLINGMODE;
+            }
+            else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
+                // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
+                fullOptions.samplingMode = Texture.NEAREST_SAMPLINGMODE;
             }
             }
             var gl = this._gl;
             var gl = this._gl;
 
 
@@ -3048,10 +3068,10 @@
             var width = size.width || size;
             var width = size.width || size;
             var height = size.height || size;
             var height = size.height || size;
 
 
-            var filters = getSamplingParameters(samplingMode, generateMipMaps, gl);
+            var filters = getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps, gl);
 
 
-            if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
-                type = Engine.TEXTURETYPE_UNSIGNED_INT;
+            if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
+                fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
                 Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
                 Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
             }
             }
 
 
@@ -3060,16 +3080,16 @@
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
 
 
-            gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
+            gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type), width, height, 0, gl.RGBA, this._getWebGLTextureType(fullOptions.type), null);
 
 
             // Create the framebuffer
             // Create the framebuffer
             var framebuffer = gl.createFramebuffer();
             var framebuffer = gl.createFramebuffer();
             this.bindUnboundFramebuffer(framebuffer);
             this.bindUnboundFramebuffer(framebuffer);
             gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
             gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
 
 
-            texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
+            texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, width, height);
 
 
-            if (generateMipMaps) {
+            if (fullOptions.generateMipMaps) {
                 this._gl.generateMipmap(this._gl.TEXTURE_2D);
                 this._gl.generateMipmap(this._gl.TEXTURE_2D);
             }
             }
 
 
@@ -3085,11 +3105,11 @@
             texture.height = height;
             texture.height = height;
             texture.isReady = true;
             texture.isReady = true;
             texture.samples = 1;
             texture.samples = 1;
-            texture.generateMipMaps = generateMipMaps;
-            texture.samplingMode = samplingMode;
-            texture.type = type;
-            texture._generateDepthBuffer = generateDepthBuffer;
-            texture._generateStencilBuffer = generateStencilBuffer;
+            texture.generateMipMaps = fullOptions.generateMipMaps;
+            texture.samplingMode = fullOptions.samplingMode;
+            texture.type = fullOptions.type;
+            texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
+            texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
 
 
             this.resetTextureCache();
             this.resetTextureCache();
 
 
@@ -3344,7 +3364,7 @@
             this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
             this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
         }
         }
 
 
-        public createRenderTargetCubeTexture(size: number, options?: any): InternalTexture {
+        public createRenderTargetCubeTexture(size: number, options?: RenderTargetCreationOptions): InternalTexture {
             var gl = this._gl;
             var gl = this._gl;
 
 
             var texture = new InternalTexture(this, InternalTexture.DATASOURCE_RENDERTARGET);
             var texture = new InternalTexture(this, InternalTexture.DATASOURCE_RENDERTARGET);
@@ -3355,7 +3375,7 @@
 
 
             var samplingMode = Texture.TRILINEAR_SAMPLINGMODE;
             var samplingMode = Texture.TRILINEAR_SAMPLINGMODE;
             if (options !== undefined) {
             if (options !== undefined) {
-                generateMipMaps = options.generateMipMaps === undefined ? options : options.generateMipMaps;
+                generateMipMaps = options.generateMipMaps === undefined ? true : options.generateMipMaps;
                 generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
                 generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
                 generateStencilBuffer = generateDepthBuffer && options.generateStencilBuffer;
                 generateStencilBuffer = generateDepthBuffer && options.generateStencilBuffer;
 
 
@@ -4511,7 +4531,7 @@
         }
         }
 
 
         public deleteQuery(query: WebGLQuery): Engine {
         public deleteQuery(query: WebGLQuery): Engine {
-            this.deleteQuery(query);
+            this._gl.deleteQuery(query);
 
 
             return this;
             return this;
         }
         }

BIN
tests/validation/LogoV3.jpg


BIN
tests/validation/LogoV3.png


+ 1 - 1
tests/validation/index.css

@@ -4,7 +4,7 @@
     padding: 0;
     padding: 0;
     margin: 0;
     margin: 0;
     background-color: white;
     background-color: white;
-    background: url("LogoV3.jpg");
+    background: url("LogoV3.png");
     background-position: center center;
     background-position: center center;
     background-repeat: no-repeat;
     background-repeat: no-repeat;
 }
 }