|
@@ -6140,7 +6140,7 @@ var BABYLON;
|
|
|
mag: magFilter
|
|
|
};
|
|
|
};
|
|
|
- var prepareWebGLTexture = function (texture, gl, scene, width, height, invertY, noMipmap, isCompressed, processFunction, onLoad, samplingMode) {
|
|
|
+ var prepareWebGLTexture = function (texture, gl, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
|
|
|
if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
|
|
|
var engine = scene.getEngine();
|
|
|
var potWidth = BABYLON.Tools.GetExponentOfTwo(width, engine.getCaps().maxTextureSize);
|
|
@@ -6162,9 +6162,10 @@ var BABYLON;
|
|
|
engine._bindTextureDirectly(gl.TEXTURE_2D, null);
|
|
|
engine.resetTextureCache();
|
|
|
scene._removePendingData(texture);
|
|
|
- if (onLoad) {
|
|
|
- onLoad();
|
|
|
- }
|
|
|
+ texture.onLoadedCallbacks.forEach(function (callback) {
|
|
|
+ callback();
|
|
|
+ });
|
|
|
+ texture.onLoadedCallbacks = [];
|
|
|
};
|
|
|
var partialLoad = function (url, index, loadedImages, scene, onfinish) {
|
|
|
var img;
|
|
@@ -7601,6 +7602,7 @@ var BABYLON;
|
|
|
texture.noMipmap = noMipmap;
|
|
|
texture.references = 1;
|
|
|
texture.samplingMode = samplingMode;
|
|
|
+ texture.onLoadedCallbacks = [onLoad];
|
|
|
this._loadedTexturesCache.push(texture);
|
|
|
var onerror = function () {
|
|
|
scene._removePendingData(texture);
|
|
@@ -7615,7 +7617,7 @@ var BABYLON;
|
|
|
var header = BABYLON.Internals.TGATools.GetTGAHeader(data);
|
|
|
prepareWebGLTexture(texture, _this._gl, scene, header.width, header.height, invertY, noMipmap, false, function () {
|
|
|
BABYLON.Internals.TGATools.UploadContent(_this._gl, data);
|
|
|
- }, onLoad, samplingMode);
|
|
|
+ }, samplingMode);
|
|
|
};
|
|
|
if (!(fromData instanceof Array))
|
|
|
BABYLON.Tools.LoadFile(url, function (arrayBuffer) {
|
|
@@ -7630,7 +7632,7 @@ var BABYLON;
|
|
|
var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && !noMipmap && ((info.width >> (info.mipmapCount - 1)) === 1);
|
|
|
prepareWebGLTexture(texture, _this._gl, scene, info.width, info.height, invertY, !loadMipmap, info.isFourCC, function () {
|
|
|
BABYLON.Internals.DDSTools.UploadDDSLevels(_this._gl, _this.getCaps().s3tc, data, info, loadMipmap, 1);
|
|
|
- }, onLoad, samplingMode);
|
|
|
+ }, samplingMode);
|
|
|
};
|
|
|
if (!(fromData instanceof Array))
|
|
|
BABYLON.Tools.LoadFile(url, function (data) {
|
|
@@ -7664,7 +7666,7 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
_this._gl.texImage2D(_this._gl.TEXTURE_2D, 0, _this._gl.RGBA, _this._gl.RGBA, _this._gl.UNSIGNED_BYTE, isPot ? img : _this._workingCanvas);
|
|
|
- }, onLoad, samplingMode);
|
|
|
+ }, samplingMode);
|
|
|
};
|
|
|
if (!(fromData instanceof Array))
|
|
|
BABYLON.Tools.LoadImage(url, onload, onerror, scene.database);
|
|
@@ -22459,7 +22461,12 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- BABYLON.Tools.SetImmediate(function () { return load(); });
|
|
|
+ if (this._texture.isReady) {
|
|
|
+ BABYLON.Tools.SetImmediate(function () { return load(); });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this._texture.onLoadedCallbacks.push(load);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
Object.defineProperty(Texture.prototype, "noMipmap", {
|