David Catuhe 7 سال پیش
والد
کامیت
e71118261b

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 8371 - 8358
Playground/babylon.d.txt


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 8380 - 8367
dist/preview release/babylon.d.ts


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 49 - 49
dist/preview release/babylon.js


+ 51 - 12
dist/preview release/babylon.max.js

@@ -8915,25 +8915,48 @@ var BABYLON;
             url = url.replace(/#/mg, "%23");
             return url;
         };
-        Tools.LoadImage = function (url, onLoad, onError, database) {
-            if (url instanceof ArrayBuffer) {
-                url = Tools.EncodeArrayBufferTobase64(url);
+        /**
+         * Loads an image as an HTMLImageElement.
+         * @param input url string, ArrayBuffer, or Blob to load
+         * @param onLoad callback called when the image successfully loads
+         * @param onError callback called when the image fails to load
+         * @param database database for caching
+         * @returns the HTMLImageElement of the loaded image
+         */
+        Tools.LoadImage = function (input, onLoad, onError, database) {
+            var url;
+            var usingObjectURL = false;
+            if (input instanceof ArrayBuffer) {
+                url = URL.createObjectURL(new Blob([input]));
+                usingObjectURL = true;
+            }
+            else if (input instanceof Blob) {
+                url = URL.createObjectURL(input);
+                usingObjectURL = true;
+            }
+            else {
+                url = Tools.CleanUrl(input);
+                url = Tools.PreprocessUrl(input);
             }
-            url = Tools.CleanUrl(url);
-            url = Tools.PreprocessUrl(url);
             var img = new Image();
             Tools.SetCorsBehavior(url, img);
             var loadHandler = function () {
+                if (usingObjectURL && img.src) {
+                    URL.revokeObjectURL(img.src);
+                }
                 img.removeEventListener("load", loadHandler);
                 img.removeEventListener("error", errorHandler);
                 onLoad(img);
             };
             var errorHandler = function (err) {
+                if (usingObjectURL && img.src) {
+                    URL.revokeObjectURL(img.src);
+                }
                 img.removeEventListener("load", loadHandler);
                 img.removeEventListener("error", errorHandler);
-                Tools.Error("Error while trying to load image: " + url);
+                Tools.Error("Error while trying to load image: " + input);
                 if (onError) {
-                    onError("Error while trying to load image: " + url, err);
+                    onError("Error while trying to load image: " + input, err);
                 }
             };
             img.addEventListener("load", loadHandler);
@@ -8964,6 +8987,7 @@ var BABYLON;
                                 blobURL = URL.createObjectURL(BABYLON.FilesInput.FilesToLoad[textureName]);
                             }
                             img.src = blobURL;
+                            usingObjectURL = true;
                         }
                         catch (e) {
                             img.src = "";
@@ -14544,7 +14568,7 @@ var BABYLON;
          * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
          * @param onLoad optional callback to be called upon successful completion
          * @param onError optional callback to be called upon failure
-         * @param buffer a source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
+         * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
          * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
          * @param format internal format.  Default: RGB when extension is '.jpg' else RGBA.  Ignored for compressed textures
          * @returns a InternalTexture for assignment back into BABYLON.Texture
@@ -14687,17 +14711,20 @@ var BABYLON;
                         return true;
                     }, samplingMode);
                 };
-                if (!fromData || isBase64)
+                if (!fromData || isBase64) {
                     if (buffer instanceof HTMLImageElement) {
                         onload(buffer);
                     }
                     else {
                         BABYLON.Tools.LoadImage(url, onload, onerror, scene ? scene.database : null);
                     }
-                else if (buffer instanceof Array || typeof buffer === "string" || buffer instanceof ArrayBuffer)
+                }
+                else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
                     BABYLON.Tools.LoadImage(buffer, onload, onerror, scene ? scene.database : null);
-                else
+                }
+                else {
                     onload(buffer);
+                }
             }
             return texture;
         };
@@ -30718,8 +30745,18 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
-        Texture.prototype.updateURL = function (url) {
+        /**
+         * Update the url (and optional buffer) of this texture if url was null during construction.
+         * @param url the url of the texture
+         * @param buffer the buffer of the texture (defaults to null)
+         */
+        Texture.prototype.updateURL = function (url, buffer) {
+            if (buffer === void 0) { buffer = null; }
+            if (this.url) {
+                throw new Error("URL is already set");
+            }
             this.url = url;
+            this._buffer = buffer;
             this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NOTLOADED;
             this.delayLoad();
         };
@@ -96130,6 +96167,7 @@ var BABYLON;
             if (onLoad) {
                 onLoad();
             }
+            this._internalTexturesCache.push(texture);
             return texture;
         };
         NullEngine.prototype.createRenderTargetTexture = function (size, options) {
@@ -96164,6 +96202,7 @@ var BABYLON;
             texture.type = fullOptions.type;
             texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
             texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
+            this._internalTexturesCache.push(texture);
             return texture;
         };
         NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {

+ 51 - 12
dist/preview release/babylon.no-module.max.js

@@ -8882,25 +8882,48 @@ var BABYLON;
             url = url.replace(/#/mg, "%23");
             return url;
         };
-        Tools.LoadImage = function (url, onLoad, onError, database) {
-            if (url instanceof ArrayBuffer) {
-                url = Tools.EncodeArrayBufferTobase64(url);
+        /**
+         * Loads an image as an HTMLImageElement.
+         * @param input url string, ArrayBuffer, or Blob to load
+         * @param onLoad callback called when the image successfully loads
+         * @param onError callback called when the image fails to load
+         * @param database database for caching
+         * @returns the HTMLImageElement of the loaded image
+         */
+        Tools.LoadImage = function (input, onLoad, onError, database) {
+            var url;
+            var usingObjectURL = false;
+            if (input instanceof ArrayBuffer) {
+                url = URL.createObjectURL(new Blob([input]));
+                usingObjectURL = true;
+            }
+            else if (input instanceof Blob) {
+                url = URL.createObjectURL(input);
+                usingObjectURL = true;
+            }
+            else {
+                url = Tools.CleanUrl(input);
+                url = Tools.PreprocessUrl(input);
             }
-            url = Tools.CleanUrl(url);
-            url = Tools.PreprocessUrl(url);
             var img = new Image();
             Tools.SetCorsBehavior(url, img);
             var loadHandler = function () {
+                if (usingObjectURL && img.src) {
+                    URL.revokeObjectURL(img.src);
+                }
                 img.removeEventListener("load", loadHandler);
                 img.removeEventListener("error", errorHandler);
                 onLoad(img);
             };
             var errorHandler = function (err) {
+                if (usingObjectURL && img.src) {
+                    URL.revokeObjectURL(img.src);
+                }
                 img.removeEventListener("load", loadHandler);
                 img.removeEventListener("error", errorHandler);
-                Tools.Error("Error while trying to load image: " + url);
+                Tools.Error("Error while trying to load image: " + input);
                 if (onError) {
-                    onError("Error while trying to load image: " + url, err);
+                    onError("Error while trying to load image: " + input, err);
                 }
             };
             img.addEventListener("load", loadHandler);
@@ -8931,6 +8954,7 @@ var BABYLON;
                                 blobURL = URL.createObjectURL(BABYLON.FilesInput.FilesToLoad[textureName]);
                             }
                             img.src = blobURL;
+                            usingObjectURL = true;
                         }
                         catch (e) {
                             img.src = "";
@@ -14511,7 +14535,7 @@ var BABYLON;
          * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
          * @param onLoad optional callback to be called upon successful completion
          * @param onError optional callback to be called upon failure
-         * @param buffer a source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
+         * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
          * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
          * @param format internal format.  Default: RGB when extension is '.jpg' else RGBA.  Ignored for compressed textures
          * @returns a InternalTexture for assignment back into BABYLON.Texture
@@ -14654,17 +14678,20 @@ var BABYLON;
                         return true;
                     }, samplingMode);
                 };
-                if (!fromData || isBase64)
+                if (!fromData || isBase64) {
                     if (buffer instanceof HTMLImageElement) {
                         onload(buffer);
                     }
                     else {
                         BABYLON.Tools.LoadImage(url, onload, onerror, scene ? scene.database : null);
                     }
-                else if (buffer instanceof Array || typeof buffer === "string" || buffer instanceof ArrayBuffer)
+                }
+                else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
                     BABYLON.Tools.LoadImage(buffer, onload, onerror, scene ? scene.database : null);
-                else
+                }
+                else {
                     onload(buffer);
+                }
             }
             return texture;
         };
@@ -30685,8 +30712,18 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
-        Texture.prototype.updateURL = function (url) {
+        /**
+         * Update the url (and optional buffer) of this texture if url was null during construction.
+         * @param url the url of the texture
+         * @param buffer the buffer of the texture (defaults to null)
+         */
+        Texture.prototype.updateURL = function (url, buffer) {
+            if (buffer === void 0) { buffer = null; }
+            if (this.url) {
+                throw new Error("URL is already set");
+            }
             this.url = url;
+            this._buffer = buffer;
             this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NOTLOADED;
             this.delayLoad();
         };
@@ -96097,6 +96134,7 @@ var BABYLON;
             if (onLoad) {
                 onLoad();
             }
+            this._internalTexturesCache.push(texture);
             return texture;
         };
         NullEngine.prototype.createRenderTargetTexture = function (size, options) {
@@ -96131,6 +96169,7 @@ var BABYLON;
             texture.type = fullOptions.type;
             texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
             texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
+            this._internalTexturesCache.push(texture);
             return texture;
         };
         NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 49 - 49
dist/preview release/babylon.worker.js


+ 51 - 12
dist/preview release/es6.js

@@ -8882,25 +8882,48 @@ var BABYLON;
             url = url.replace(/#/mg, "%23");
             return url;
         };
-        Tools.LoadImage = function (url, onLoad, onError, database) {
-            if (url instanceof ArrayBuffer) {
-                url = Tools.EncodeArrayBufferTobase64(url);
+        /**
+         * Loads an image as an HTMLImageElement.
+         * @param input url string, ArrayBuffer, or Blob to load
+         * @param onLoad callback called when the image successfully loads
+         * @param onError callback called when the image fails to load
+         * @param database database for caching
+         * @returns the HTMLImageElement of the loaded image
+         */
+        Tools.LoadImage = function (input, onLoad, onError, database) {
+            var url;
+            var usingObjectURL = false;
+            if (input instanceof ArrayBuffer) {
+                url = URL.createObjectURL(new Blob([input]));
+                usingObjectURL = true;
+            }
+            else if (input instanceof Blob) {
+                url = URL.createObjectURL(input);
+                usingObjectURL = true;
+            }
+            else {
+                url = Tools.CleanUrl(input);
+                url = Tools.PreprocessUrl(input);
             }
-            url = Tools.CleanUrl(url);
-            url = Tools.PreprocessUrl(url);
             var img = new Image();
             Tools.SetCorsBehavior(url, img);
             var loadHandler = function () {
+                if (usingObjectURL && img.src) {
+                    URL.revokeObjectURL(img.src);
+                }
                 img.removeEventListener("load", loadHandler);
                 img.removeEventListener("error", errorHandler);
                 onLoad(img);
             };
             var errorHandler = function (err) {
+                if (usingObjectURL && img.src) {
+                    URL.revokeObjectURL(img.src);
+                }
                 img.removeEventListener("load", loadHandler);
                 img.removeEventListener("error", errorHandler);
-                Tools.Error("Error while trying to load image: " + url);
+                Tools.Error("Error while trying to load image: " + input);
                 if (onError) {
-                    onError("Error while trying to load image: " + url, err);
+                    onError("Error while trying to load image: " + input, err);
                 }
             };
             img.addEventListener("load", loadHandler);
@@ -8931,6 +8954,7 @@ var BABYLON;
                                 blobURL = URL.createObjectURL(BABYLON.FilesInput.FilesToLoad[textureName]);
                             }
                             img.src = blobURL;
+                            usingObjectURL = true;
                         }
                         catch (e) {
                             img.src = "";
@@ -14511,7 +14535,7 @@ var BABYLON;
          * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
          * @param onLoad optional callback to be called upon successful completion
          * @param onError optional callback to be called upon failure
-         * @param buffer a source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
+         * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
          * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
          * @param format internal format.  Default: RGB when extension is '.jpg' else RGBA.  Ignored for compressed textures
          * @returns a InternalTexture for assignment back into BABYLON.Texture
@@ -14654,17 +14678,20 @@ var BABYLON;
                         return true;
                     }, samplingMode);
                 };
-                if (!fromData || isBase64)
+                if (!fromData || isBase64) {
                     if (buffer instanceof HTMLImageElement) {
                         onload(buffer);
                     }
                     else {
                         BABYLON.Tools.LoadImage(url, onload, onerror, scene ? scene.database : null);
                     }
-                else if (buffer instanceof Array || typeof buffer === "string" || buffer instanceof ArrayBuffer)
+                }
+                else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
                     BABYLON.Tools.LoadImage(buffer, onload, onerror, scene ? scene.database : null);
-                else
+                }
+                else {
                     onload(buffer);
+                }
             }
             return texture;
         };
@@ -30685,8 +30712,18 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
-        Texture.prototype.updateURL = function (url) {
+        /**
+         * Update the url (and optional buffer) of this texture if url was null during construction.
+         * @param url the url of the texture
+         * @param buffer the buffer of the texture (defaults to null)
+         */
+        Texture.prototype.updateURL = function (url, buffer) {
+            if (buffer === void 0) { buffer = null; }
+            if (this.url) {
+                throw new Error("URL is already set");
+            }
             this.url = url;
+            this._buffer = buffer;
             this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NOTLOADED;
             this.delayLoad();
         };
@@ -96097,6 +96134,7 @@ var BABYLON;
             if (onLoad) {
                 onLoad();
             }
+            this._internalTexturesCache.push(texture);
             return texture;
         };
         NullEngine.prototype.createRenderTargetTexture = function (size, options) {
@@ -96131,6 +96169,7 @@ var BABYLON;
             texture.type = fullOptions.type;
             texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
             texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
+            this._internalTexturesCache.push(texture);
             return texture;
         };
         NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {

+ 1 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.d.ts

@@ -423,7 +423,7 @@ declare module BABYLON.GLTF2 {
     }
     /** @hidden */
     interface _ILoaderImage extends IImage, _IArrayItem {
-        _objectURL?: Promise<string>;
+        _blob?: Promise<Blob>;
     }
     /** @hidden */
     interface _ILoaderMaterial extends IMaterial, _IArrayItem {

+ 8 - 18
dist/preview release/loaders/babylon.glTF2FileLoader.js

@@ -1886,8 +1886,9 @@ var BABYLON;
                 babylonTexture.wrapV = samplerData.wrapV;
                 babylonTexture.coordinatesIndex = textureInfo.texCoord || 0;
                 var image = GLTFLoader._GetProperty(context + "/source", this._gltf.images, texture.source);
-                promises.push(this._loadImageAsync("#/images/" + image._index, image).then(function (objectURL) {
-                    babylonTexture.updateURL(objectURL);
+                promises.push(this._loadImageAsync("#/images/" + image._index, image).then(function (blob) {
+                    var dataUrl = "data:" + _this._rootUrl + (image.uri || "image" + image._index);
+                    babylonTexture.updateURL(dataUrl, blob);
                 }));
                 assign(babylonTexture);
                 this.onTextureLoadedObservable.notifyObservers(babylonTexture);
@@ -1906,8 +1907,8 @@ var BABYLON;
                 return sampler._data;
             };
             GLTFLoader.prototype._loadImageAsync = function (context, image) {
-                if (image._objectURL) {
-                    return image._objectURL;
+                if (image._blob) {
+                    return image._blob;
                 }
                 var promise;
                 if (image.uri) {
@@ -1917,10 +1918,10 @@ var BABYLON;
                     var bufferView = GLTFLoader._GetProperty(context + "/bufferView", this._gltf.bufferViews, image.bufferView);
                     promise = this._loadBufferViewAsync("#/bufferViews/" + bufferView._index, bufferView);
                 }
-                image._objectURL = promise.then(function (data) {
-                    return URL.createObjectURL(new Blob([data], { type: image.mimeType }));
+                image._blob = promise.then(function (data) {
+                    return new Blob([data], { type: image.mimeType });
                 });
-                return image._objectURL;
+                return image._blob;
             };
             /** @hidden */
             GLTFLoader.prototype._loadUriAsync = function (context, uri) {
@@ -2127,17 +2128,6 @@ var BABYLON;
                     request.abort();
                 }
                 this._requests.length = 0;
-                if (this._gltf && this._gltf.images) {
-                    for (var _b = 0, _c = this._gltf.images; _b < _c.length; _b++) {
-                        var image = _c[_b];
-                        if (image._objectURL) {
-                            image._objectURL.then(function (value) {
-                                URL.revokeObjectURL(value);
-                            });
-                            image._objectURL = undefined;
-                        }
-                    }
-                }
                 delete this._gltf;
                 delete this._babylonScene;
                 this._completePromises.length = 0;

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


+ 1 - 1
dist/preview release/loaders/babylon.glTFFileLoader.d.ts

@@ -1000,7 +1000,7 @@ declare module BABYLON.GLTF2 {
     }
     /** @hidden */
     interface _ILoaderImage extends IImage, _IArrayItem {
-        _objectURL?: Promise<string>;
+        _blob?: Promise<Blob>;
     }
     /** @hidden */
     interface _ILoaderMaterial extends IMaterial, _IArrayItem {

+ 8 - 18
dist/preview release/loaders/babylon.glTFFileLoader.js

@@ -4102,8 +4102,9 @@ var BABYLON;
                 babylonTexture.wrapV = samplerData.wrapV;
                 babylonTexture.coordinatesIndex = textureInfo.texCoord || 0;
                 var image = GLTFLoader._GetProperty(context + "/source", this._gltf.images, texture.source);
-                promises.push(this._loadImageAsync("#/images/" + image._index, image).then(function (objectURL) {
-                    babylonTexture.updateURL(objectURL);
+                promises.push(this._loadImageAsync("#/images/" + image._index, image).then(function (blob) {
+                    var dataUrl = "data:" + _this._rootUrl + (image.uri || "image" + image._index);
+                    babylonTexture.updateURL(dataUrl, blob);
                 }));
                 assign(babylonTexture);
                 this.onTextureLoadedObservable.notifyObservers(babylonTexture);
@@ -4122,8 +4123,8 @@ var BABYLON;
                 return sampler._data;
             };
             GLTFLoader.prototype._loadImageAsync = function (context, image) {
-                if (image._objectURL) {
-                    return image._objectURL;
+                if (image._blob) {
+                    return image._blob;
                 }
                 var promise;
                 if (image.uri) {
@@ -4133,10 +4134,10 @@ var BABYLON;
                     var bufferView = GLTFLoader._GetProperty(context + "/bufferView", this._gltf.bufferViews, image.bufferView);
                     promise = this._loadBufferViewAsync("#/bufferViews/" + bufferView._index, bufferView);
                 }
-                image._objectURL = promise.then(function (data) {
-                    return URL.createObjectURL(new Blob([data], { type: image.mimeType }));
+                image._blob = promise.then(function (data) {
+                    return new Blob([data], { type: image.mimeType });
                 });
-                return image._objectURL;
+                return image._blob;
             };
             /** @hidden */
             GLTFLoader.prototype._loadUriAsync = function (context, uri) {
@@ -4343,17 +4344,6 @@ var BABYLON;
                     request.abort();
                 }
                 this._requests.length = 0;
-                if (this._gltf && this._gltf.images) {
-                    for (var _b = 0, _c = this._gltf.images; _b < _c.length; _b++) {
-                        var image = _c[_b];
-                        if (image._objectURL) {
-                            image._objectURL.then(function (value) {
-                                URL.revokeObjectURL(value);
-                            });
-                            image._objectURL = undefined;
-                        }
-                    }
-                }
                 delete this._gltf;
                 delete this._babylonScene;
                 this._completePromises.length = 0;

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 3 - 3
dist/preview release/loaders/babylon.glTFFileLoader.min.js


+ 1 - 1
dist/preview release/loaders/babylonjs.loaders.d.ts

@@ -1096,7 +1096,7 @@ declare module BABYLON.GLTF2 {
     }
     /** @hidden */
     interface _ILoaderImage extends IImage, _IArrayItem {
-        _objectURL?: Promise<string>;
+        _blob?: Promise<Blob>;
     }
     /** @hidden */
     interface _ILoaderMaterial extends IMaterial, _IArrayItem {

+ 8 - 18
dist/preview release/loaders/babylonjs.loaders.js

@@ -5084,8 +5084,9 @@ var BABYLON;
                 babylonTexture.wrapV = samplerData.wrapV;
                 babylonTexture.coordinatesIndex = textureInfo.texCoord || 0;
                 var image = GLTFLoader._GetProperty(context + "/source", this._gltf.images, texture.source);
-                promises.push(this._loadImageAsync("#/images/" + image._index, image).then(function (objectURL) {
-                    babylonTexture.updateURL(objectURL);
+                promises.push(this._loadImageAsync("#/images/" + image._index, image).then(function (blob) {
+                    var dataUrl = "data:" + _this._rootUrl + (image.uri || "image" + image._index);
+                    babylonTexture.updateURL(dataUrl, blob);
                 }));
                 assign(babylonTexture);
                 this.onTextureLoadedObservable.notifyObservers(babylonTexture);
@@ -5104,8 +5105,8 @@ var BABYLON;
                 return sampler._data;
             };
             GLTFLoader.prototype._loadImageAsync = function (context, image) {
-                if (image._objectURL) {
-                    return image._objectURL;
+                if (image._blob) {
+                    return image._blob;
                 }
                 var promise;
                 if (image.uri) {
@@ -5115,10 +5116,10 @@ var BABYLON;
                     var bufferView = GLTFLoader._GetProperty(context + "/bufferView", this._gltf.bufferViews, image.bufferView);
                     promise = this._loadBufferViewAsync("#/bufferViews/" + bufferView._index, bufferView);
                 }
-                image._objectURL = promise.then(function (data) {
-                    return URL.createObjectURL(new Blob([data], { type: image.mimeType }));
+                image._blob = promise.then(function (data) {
+                    return new Blob([data], { type: image.mimeType });
                 });
-                return image._objectURL;
+                return image._blob;
             };
             /** @hidden */
             GLTFLoader.prototype._loadUriAsync = function (context, uri) {
@@ -5325,17 +5326,6 @@ var BABYLON;
                     request.abort();
                 }
                 this._requests.length = 0;
-                if (this._gltf && this._gltf.images) {
-                    for (var _b = 0, _c = this._gltf.images; _b < _c.length; _b++) {
-                        var image = _c[_b];
-                        if (image._objectURL) {
-                            image._objectURL.then(function (value) {
-                                URL.revokeObjectURL(value);
-                            });
-                            image._objectURL = undefined;
-                        }
-                    }
-                }
                 delete this._gltf;
                 delete this._babylonScene;
                 this._completePromises.length = 0;

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 4 - 4
dist/preview release/loaders/babylonjs.loaders.min.js


+ 1 - 1
dist/preview release/loaders/babylonjs.loaders.module.d.ts

@@ -1103,7 +1103,7 @@ declare module BABYLON.GLTF2 {
     }
     /** @hidden */
     interface _ILoaderImage extends IImage, _IArrayItem {
-        _objectURL?: Promise<string>;
+        _blob?: Promise<Blob>;
     }
     /** @hidden */
     interface _ILoaderMaterial extends IMaterial, _IArrayItem {

+ 2 - 41
dist/preview release/typedocValidationBaseline.json

@@ -1,7 +1,7 @@
 {
-  "errors": 4320,
+  "errors": 4313,
   "babylon.typedoc.json": {
-    "errors": 4320,
+    "errors": 4313,
     "Animatable": {
       "Class": {
         "Comments": {
@@ -19279,18 +19279,6 @@
             }
           }
         },
-        "updateURL": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "url": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
         "CreateFromBase64String": {
           "Comments": {
             "MissingText": true
@@ -20067,33 +20055,6 @@
             }
           }
         },
-        "LoadImage": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "url": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "onLoad": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "onError": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "database": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
         "LoadScript": {
           "Parameter": {
             "scriptUrl": {

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 17 - 17
dist/preview release/viewer/babylon.viewer.js


+ 51 - 12
dist/preview release/viewer/babylon.viewer.max.js

@@ -9003,25 +9003,48 @@ var BABYLON;
             url = url.replace(/#/mg, "%23");
             return url;
         };
-        Tools.LoadImage = function (url, onLoad, onError, database) {
-            if (url instanceof ArrayBuffer) {
-                url = Tools.EncodeArrayBufferTobase64(url);
+        /**
+         * Loads an image as an HTMLImageElement.
+         * @param input url string, ArrayBuffer, or Blob to load
+         * @param onLoad callback called when the image successfully loads
+         * @param onError callback called when the image fails to load
+         * @param database database for caching
+         * @returns the HTMLImageElement of the loaded image
+         */
+        Tools.LoadImage = function (input, onLoad, onError, database) {
+            var url;
+            var usingObjectURL = false;
+            if (input instanceof ArrayBuffer) {
+                url = URL.createObjectURL(new Blob([input]));
+                usingObjectURL = true;
+            }
+            else if (input instanceof Blob) {
+                url = URL.createObjectURL(input);
+                usingObjectURL = true;
+            }
+            else {
+                url = Tools.CleanUrl(input);
+                url = Tools.PreprocessUrl(input);
             }
-            url = Tools.CleanUrl(url);
-            url = Tools.PreprocessUrl(url);
             var img = new Image();
             Tools.SetCorsBehavior(url, img);
             var loadHandler = function () {
+                if (usingObjectURL && img.src) {
+                    URL.revokeObjectURL(img.src);
+                }
                 img.removeEventListener("load", loadHandler);
                 img.removeEventListener("error", errorHandler);
                 onLoad(img);
             };
             var errorHandler = function (err) {
+                if (usingObjectURL && img.src) {
+                    URL.revokeObjectURL(img.src);
+                }
                 img.removeEventListener("load", loadHandler);
                 img.removeEventListener("error", errorHandler);
-                Tools.Error("Error while trying to load image: " + url);
+                Tools.Error("Error while trying to load image: " + input);
                 if (onError) {
-                    onError("Error while trying to load image: " + url, err);
+                    onError("Error while trying to load image: " + input, err);
                 }
             };
             img.addEventListener("load", loadHandler);
@@ -9052,6 +9075,7 @@ var BABYLON;
                                 blobURL = URL.createObjectURL(BABYLON.FilesInput.FilesToLoad[textureName]);
                             }
                             img.src = blobURL;
+                            usingObjectURL = true;
                         }
                         catch (e) {
                             img.src = "";
@@ -14632,7 +14656,7 @@ var BABYLON;
          * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
          * @param onLoad optional callback to be called upon successful completion
          * @param onError optional callback to be called upon failure
-         * @param buffer a source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
+         * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
          * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
          * @param format internal format.  Default: RGB when extension is '.jpg' else RGBA.  Ignored for compressed textures
          * @returns a InternalTexture for assignment back into BABYLON.Texture
@@ -14775,17 +14799,20 @@ var BABYLON;
                         return true;
                     }, samplingMode);
                 };
-                if (!fromData || isBase64)
+                if (!fromData || isBase64) {
                     if (buffer instanceof HTMLImageElement) {
                         onload(buffer);
                     }
                     else {
                         BABYLON.Tools.LoadImage(url, onload, onerror, scene ? scene.database : null);
                     }
-                else if (buffer instanceof Array || typeof buffer === "string" || buffer instanceof ArrayBuffer)
+                }
+                else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
                     BABYLON.Tools.LoadImage(buffer, onload, onerror, scene ? scene.database : null);
-                else
+                }
+                else {
                     onload(buffer);
+                }
             }
             return texture;
         };
@@ -30806,8 +30833,18 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
-        Texture.prototype.updateURL = function (url) {
+        /**
+         * Update the url (and optional buffer) of this texture if url was null during construction.
+         * @param url the url of the texture
+         * @param buffer the buffer of the texture (defaults to null)
+         */
+        Texture.prototype.updateURL = function (url, buffer) {
+            if (buffer === void 0) { buffer = null; }
+            if (this.url) {
+                throw new Error("URL is already set");
+            }
             this.url = url;
+            this._buffer = buffer;
             this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NOTLOADED;
             this.delayLoad();
         };
@@ -96218,6 +96255,7 @@ var BABYLON;
             if (onLoad) {
                 onLoad();
             }
+            this._internalTexturesCache.push(texture);
             return texture;
         };
         NullEngine.prototype.createRenderTargetTexture = function (size, options) {
@@ -96252,6 +96290,7 @@ var BABYLON;
             texture.type = fullOptions.type;
             texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
             texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
+            this._internalTexturesCache.push(texture);
             return texture;
         };
         NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {