|
@@ -30143,15 +30143,15 @@ _Engines_thinEngine__WEBPACK_IMPORTED_MODULE_1__["ThinEngine"].prototype._cascad
|
|
this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
|
|
this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
-_Engines_thinEngine__WEBPACK_IMPORTED_MODULE_1__["ThinEngine"].prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
|
|
|
|
|
|
+_Engines_thinEngine__WEBPACK_IMPORTED_MODULE_1__["ThinEngine"].prototype._cascadeLoadImgs = function (scene, onfinish, files, onError, mimeType) {
|
|
if (onError === void 0) { onError = null; }
|
|
if (onError === void 0) { onError = null; }
|
|
var loadedImages = [];
|
|
var loadedImages = [];
|
|
loadedImages._internalCount = 0;
|
|
loadedImages._internalCount = 0;
|
|
for (var index = 0; index < 6; index++) {
|
|
for (var index = 0; index < 6; index++) {
|
|
- this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
|
|
|
|
|
|
+ this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError, mimeType);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
-_Engines_thinEngine__WEBPACK_IMPORTED_MODULE_1__["ThinEngine"].prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
|
|
|
|
|
|
+_Engines_thinEngine__WEBPACK_IMPORTED_MODULE_1__["ThinEngine"].prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack, mimeType) {
|
|
if (onErrorCallBack === void 0) { onErrorCallBack = null; }
|
|
if (onErrorCallBack === void 0) { onErrorCallBack = null; }
|
|
var img;
|
|
var img;
|
|
var onload = function () {
|
|
var onload = function () {
|
|
@@ -30172,7 +30172,7 @@ _Engines_thinEngine__WEBPACK_IMPORTED_MODULE_1__["ThinEngine"].prototype._partia
|
|
onErrorCallBack(message, exception);
|
|
onErrorCallBack(message, exception);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
- img = _Misc_fileTools__WEBPACK_IMPORTED_MODULE_4__["FileTools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
|
|
|
|
|
|
+ img = _Misc_fileTools__WEBPACK_IMPORTED_MODULE_4__["FileTools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null, mimeType);
|
|
if (scene) {
|
|
if (scene) {
|
|
scene._addPendingData(img);
|
|
scene._addPendingData(img);
|
|
}
|
|
}
|
|
@@ -39447,9 +39447,10 @@ var ThinEngine = /** @class */ (function () {
|
|
* @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
|
|
* @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
|
|
* @param forcedExtension defines the extension to use to pick the right loader
|
|
* @param forcedExtension defines the extension to use to pick the right loader
|
|
* @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
|
|
* @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
|
|
|
|
+ * @param mimeType defines an optional mime type
|
|
* @returns a InternalTexture for assignment back into BABYLON.Texture
|
|
* @returns a InternalTexture for assignment back into BABYLON.Texture
|
|
*/
|
|
*/
|
|
- ThinEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
|
|
|
|
|
|
+ ThinEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders, mimeType) {
|
|
var _this = this;
|
|
var _this = this;
|
|
if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
|
|
if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
|
|
if (onLoad === void 0) { onLoad = null; }
|
|
if (onLoad === void 0) { onLoad = null; }
|
|
@@ -39604,11 +39605,11 @@ var ThinEngine = /** @class */ (function () {
|
|
onload(buffer);
|
|
onload(buffer);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- _Misc_fileTools__WEBPACK_IMPORTED_MODULE_16__["FileTools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
|
|
|
|
|
|
+ _Misc_fileTools__WEBPACK_IMPORTED_MODULE_16__["FileTools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null, mimeType);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || ArrayBuffer.isView(buffer) || buffer instanceof Blob) {
|
|
else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || ArrayBuffer.isView(buffer) || buffer instanceof Blob) {
|
|
- _Misc_fileTools__WEBPACK_IMPORTED_MODULE_16__["FileTools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
|
|
|
|
|
|
+ _Misc_fileTools__WEBPACK_IMPORTED_MODULE_16__["FileTools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null, mimeType);
|
|
}
|
|
}
|
|
else if (buffer) {
|
|
else if (buffer) {
|
|
onload(buffer);
|
|
onload(buffer);
|
|
@@ -82557,18 +82558,19 @@ var Texture = /** @class */ (function (_super) {
|
|
* Instantiates a new texture.
|
|
* Instantiates a new texture.
|
|
* This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
|
|
* This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
|
|
* @see http://doc.babylonjs.com/babylon101/materials#texture
|
|
* @see http://doc.babylonjs.com/babylon101/materials#texture
|
|
- * @param url define the url of the picture to load as a texture
|
|
|
|
- * @param scene define the scene or engine the texture will belong to
|
|
|
|
- * @param noMipmap define if the texture will require mip maps or not
|
|
|
|
- * @param invertY define if the texture needs to be inverted on the y axis during loading
|
|
|
|
- * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
|
|
|
|
- * @param onLoad define a callback triggered when the texture has been loaded
|
|
|
|
- * @param onError define a callback triggered when an error occurred during the loading session
|
|
|
|
- * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
|
|
|
|
- * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
|
|
|
|
- * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
|
|
|
|
- */
|
|
|
|
- function Texture(url, sceneOrEngine, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
|
|
|
|
|
|
+ * @param url defines the url of the picture to load as a texture
|
|
|
|
+ * @param scene defines the scene or engine the texture will belong to
|
|
|
|
+ * @param noMipmap defines if the texture will require mip maps or not
|
|
|
|
+ * @param invertY defines if the texture needs to be inverted on the y axis during loading
|
|
|
|
+ * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
|
|
|
|
+ * @param onLoad defines a callback triggered when the texture has been loaded
|
|
|
|
+ * @param onError defines a callback triggered when an error occurred during the loading session
|
|
|
|
+ * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
|
|
|
|
+ * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
|
|
|
|
+ * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
|
|
|
|
+ * @param mimeType defines an optional mime type information
|
|
|
|
+ */
|
|
|
|
+ function Texture(url, sceneOrEngine, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format, mimeType) {
|
|
if (noMipmap === void 0) { noMipmap = false; }
|
|
if (noMipmap === void 0) { noMipmap = false; }
|
|
if (invertY === void 0) { invertY = true; }
|
|
if (invertY === void 0) { invertY = true; }
|
|
if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
|
|
if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
|
|
@@ -82671,6 +82673,7 @@ var Texture = /** @class */ (function (_super) {
|
|
_this._initialSamplingMode = samplingMode;
|
|
_this._initialSamplingMode = samplingMode;
|
|
_this._buffer = buffer;
|
|
_this._buffer = buffer;
|
|
_this._deleteBuffer = deleteBuffer;
|
|
_this._deleteBuffer = deleteBuffer;
|
|
|
|
+ _this._mimeType = mimeType;
|
|
if (format) {
|
|
if (format) {
|
|
_this._format = format;
|
|
_this._format = format;
|
|
}
|
|
}
|
|
@@ -82718,7 +82721,7 @@ var Texture = /** @class */ (function (_super) {
|
|
_this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode, invertY);
|
|
_this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode, invertY);
|
|
if (!_this._texture) {
|
|
if (!_this._texture) {
|
|
if (!scene || !scene.useDelayedTextureLoading) {
|
|
if (!scene || !scene.useDelayedTextureLoading) {
|
|
- _this._texture = engine.createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
|
|
|
|
|
|
+ _this._texture = engine.createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format, null, undefined, mimeType);
|
|
if (deleteBuffer) {
|
|
if (deleteBuffer) {
|
|
delete _this._buffer;
|
|
delete _this._buffer;
|
|
}
|
|
}
|
|
@@ -82822,7 +82825,7 @@ var Texture = /** @class */ (function (_super) {
|
|
this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].DELAYLOADSTATE_LOADED;
|
|
this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].DELAYLOADSTATE_LOADED;
|
|
this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY);
|
|
this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY);
|
|
if (!this._texture) {
|
|
if (!this._texture) {
|
|
- this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
|
|
|
|
|
|
+ this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format, null, undefined, this._mimeType);
|
|
if (this._deleteBuffer) {
|
|
if (this._deleteBuffer) {
|
|
delete this._buffer;
|
|
delete this._buffer;
|
|
}
|
|
}
|
|
@@ -121322,11 +121325,12 @@ var AssetsManager = /** @class */ (function () {
|
|
}
|
|
}
|
|
if (this._waitingTasksCount === 0) {
|
|
if (this._waitingTasksCount === 0) {
|
|
try {
|
|
try {
|
|
|
|
+ var currentTasks = this._tasks.slice();
|
|
if (this.onFinish) {
|
|
if (this.onFinish) {
|
|
- this.onFinish(this._tasks);
|
|
|
|
|
|
+ // Calling onFinish with immutable array of tasks
|
|
|
|
+ this.onFinish(currentTasks);
|
|
}
|
|
}
|
|
// Let's remove successfull tasks
|
|
// Let's remove successfull tasks
|
|
- var currentTasks = this._tasks.slice();
|
|
|
|
for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
|
|
for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
|
|
var task = currentTasks_1[_i];
|
|
var task = currentTasks_1[_i];
|
|
if (task.taskState === AssetTaskState.DONE) {
|
|
if (task.taskState === AssetTaskState.DONE) {
|
|
@@ -123768,14 +123772,20 @@ var FileTools = /** @class */ (function () {
|
|
* @param onLoad callback called when the image successfully loads
|
|
* @param onLoad callback called when the image successfully loads
|
|
* @param onError callback called when the image fails to load
|
|
* @param onError callback called when the image fails to load
|
|
* @param offlineProvider offline provider for caching
|
|
* @param offlineProvider offline provider for caching
|
|
|
|
+ * @param mimeType optional mime type
|
|
* @returns the HTMLImageElement of the loaded image
|
|
* @returns the HTMLImageElement of the loaded image
|
|
*/
|
|
*/
|
|
- FileTools.LoadImage = function (input, onLoad, onError, offlineProvider) {
|
|
|
|
|
|
+ FileTools.LoadImage = function (input, onLoad, onError, offlineProvider, mimeType) {
|
|
var url;
|
|
var url;
|
|
var usingObjectURL = false;
|
|
var usingObjectURL = false;
|
|
if (input instanceof ArrayBuffer || ArrayBuffer.isView(input)) {
|
|
if (input instanceof ArrayBuffer || ArrayBuffer.isView(input)) {
|
|
- url = URL.createObjectURL(new Blob([input]));
|
|
|
|
- usingObjectURL = true;
|
|
|
|
|
|
+ if (typeof Blob !== 'undefined') {
|
|
|
|
+ url = URL.createObjectURL(new Blob([input]));
|
|
|
|
+ usingObjectURL = true;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ url = "data:" + (mimeType || "image/jpg") + ";base64," + btoa(String.fromCharCode.apply(null, input));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else if (input instanceof Blob) {
|
|
else if (input instanceof Blob) {
|
|
url = URL.createObjectURL(input);
|
|
url = URL.createObjectURL(input);
|
|
@@ -129323,10 +129333,11 @@ var Tools = /** @class */ (function () {
|
|
* @param onLoad callback called when the image successfully loads
|
|
* @param onLoad callback called when the image successfully loads
|
|
* @param onError callback called when the image fails to load
|
|
* @param onError callback called when the image fails to load
|
|
* @param offlineProvider offline provider for caching
|
|
* @param offlineProvider offline provider for caching
|
|
|
|
+ * @param mimeType optional mime type
|
|
* @returns the HTMLImageElement of the loaded image
|
|
* @returns the HTMLImageElement of the loaded image
|
|
*/
|
|
*/
|
|
- Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
|
|
|
|
- return _fileTools__WEBPACK_IMPORTED_MODULE_8__["FileTools"].LoadImage(input, onLoad, onError, offlineProvider);
|
|
|
|
|
|
+ Tools.LoadImage = function (input, onLoad, onError, offlineProvider, mimeType) {
|
|
|
|
+ return _fileTools__WEBPACK_IMPORTED_MODULE_8__["FileTools"].LoadImage(input, onLoad, onError, offlineProvider, mimeType);
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
* Loads a file
|
|
* Loads a file
|