|
@@ -10,12 +10,18 @@ import { _TypeStore } from '../../Misc/typeStore';
|
|
|
|
|
|
import "../../Engines/Extensions/engine.cubeTexture";
|
|
|
import { StringTools } from '../../Misc/stringTools';
|
|
|
+import { Observable } from '../../Misc/observable';
|
|
|
|
|
|
/**
|
|
|
* Class for creating a cube texture
|
|
|
*/
|
|
|
export class CubeTexture extends BaseTexture {
|
|
|
private _delayedOnLoad: Nullable<() => void>;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Observable triggered once the texture has been loaded.
|
|
|
+ */
|
|
|
+ public onLoadObservable: Observable<CubeTexture> = new Observable<CubeTexture>();
|
|
|
|
|
|
/**
|
|
|
* The url of the texture
|
|
@@ -212,6 +218,13 @@ export class CubeTexture extends BaseTexture {
|
|
|
|
|
|
this._files = files;
|
|
|
|
|
|
+ let onLoadProcessing = () => {
|
|
|
+ this.onLoadObservable.notifyObservers(this);
|
|
|
+ if (onLoad) {
|
|
|
+ onLoad();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (!this._texture) {
|
|
|
if (!scene.useDelayedTextureLoading) {
|
|
|
if (prefiltered) {
|
|
@@ -220,14 +233,16 @@ export class CubeTexture extends BaseTexture {
|
|
|
else {
|
|
|
this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, this._format, forcedExtension, false, lodScale, lodOffset);
|
|
|
}
|
|
|
+ this._texture.onLoadedObservable.add(() => this.onLoadObservable.notifyObservers(this));
|
|
|
+
|
|
|
} else {
|
|
|
this.delayLoadState = Constants.DELAYLOADSTATE_NOTLOADED;
|
|
|
}
|
|
|
- } else if (onLoad) {
|
|
|
+ } else {
|
|
|
if (this._texture.isReady) {
|
|
|
- Tools.SetImmediate(() => onLoad());
|
|
|
+ Tools.SetImmediate(() => onLoadProcessing());
|
|
|
} else {
|
|
|
- this._texture.onLoadedObservable.add(onLoad);
|
|
|
+ this._texture.onLoadedObservable.add(() => onLoadProcessing());
|
|
|
}
|
|
|
}
|
|
|
}
|