|
@@ -96,11 +96,6 @@
|
|
|
this._format = format;
|
|
|
|
|
|
scene = this.getScene();
|
|
|
- if (!url) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- this._texture = this._getFromCache(url, noMipmap, samplingMode);
|
|
|
|
|
|
let load = () => {
|
|
|
if (this._onLoadObservarble && this._onLoadObservarble.hasObservers()) {
|
|
@@ -115,6 +110,14 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (!url) {
|
|
|
+ this._delayedOnLoad = load;
|
|
|
+ this._delayedOnError = onError;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this._texture = this._getFromCache(url, noMipmap, samplingMode);
|
|
|
+
|
|
|
if (!this._texture) {
|
|
|
if (!scene.useDelayedTextureLoading) {
|
|
|
this._texture = scene.getEngine().createTexture(url, noMipmap, invertY, scene, this._samplingMode, load, onError, this._buffer, null, this._format);
|
|
@@ -136,6 +139,12 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public updateURL(url: string): void {
|
|
|
+ this.url = url;
|
|
|
+ this.delayLoadState = Engine.DELAYLOADSTATE_NOTLOADED;
|
|
|
+ this.delayLoad();
|
|
|
+ }
|
|
|
+
|
|
|
public delayLoad(): void {
|
|
|
if (this.delayLoadState !== Engine.DELAYLOADSTATE_NOTLOADED) {
|
|
|
return;
|
|
@@ -149,6 +158,12 @@
|
|
|
if (this._deleteBuffer) {
|
|
|
delete this._buffer;
|
|
|
}
|
|
|
+ } else {
|
|
|
+ if (this._texture.isReady) {
|
|
|
+ Tools.SetImmediate(() => this._delayedOnLoad());
|
|
|
+ } else {
|
|
|
+ this._texture.onLoadedCallbacks.push(this._delayedOnLoad);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|