|
@@ -34,8 +34,12 @@ module BABYLON {
|
|
this._photoTexture.wrapV = Texture.CLAMP_ADDRESSMODE;
|
|
this._photoTexture.wrapV = Texture.CLAMP_ADDRESSMODE;
|
|
this._material.reflectionTexture = this._photoTexture;
|
|
this._material.reflectionTexture = this._photoTexture;
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Observable raised when an error occured while loading the 360 image
|
|
|
|
+ */
|
|
|
|
+ public onLoadErrorObservable = new Observable<string>();
|
|
|
|
|
|
/**
|
|
/**
|
|
* The skybox material
|
|
* The skybox material
|
|
@@ -61,14 +65,15 @@ module BABYLON {
|
|
/**
|
|
/**
|
|
* Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
|
|
* Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
|
|
* @param name Element's name, child elements will append suffixes for their own names.
|
|
* @param name Element's name, child elements will append suffixes for their own names.
|
|
- * @param urlsOfPhoto define the url of the photo to display
|
|
|
|
- * @param options An object containing optional or exposed sub element properties
|
|
|
|
|
|
+ * @param urlsOfPhoto defines the url of the photo to display
|
|
|
|
+ * @param options defines an object containing optional or exposed sub element properties
|
|
|
|
+ * @param onError defines a callback called when an error occured while loading the texture
|
|
*/
|
|
*/
|
|
constructor(name: string, urlOfPhoto: string, options: {
|
|
constructor(name: string, urlOfPhoto: string, options: {
|
|
resolution?: number,
|
|
resolution?: number,
|
|
size?: number,
|
|
size?: number,
|
|
useDirectMapping?: boolean
|
|
useDirectMapping?: boolean
|
|
- }, scene: Scene) {
|
|
|
|
|
|
+ }, scene: Scene, onError: Nullable<(message?: string, exception?: any) => void> = null) {
|
|
super(name, scene);
|
|
super(name, scene);
|
|
|
|
|
|
// set defaults and manage values
|
|
// set defaults and manage values
|
|
@@ -93,7 +98,13 @@ module BABYLON {
|
|
material.useEquirectangularFOV = true;
|
|
material.useEquirectangularFOV = true;
|
|
material.fovMultiplier = 1.0;
|
|
material.fovMultiplier = 1.0;
|
|
|
|
|
|
- this.photoTexture = new Texture(urlOfPhoto, scene, true, !this._useDirectMapping);
|
|
|
|
|
|
+ this.photoTexture = new Texture(urlOfPhoto, scene, true, !this._useDirectMapping, undefined, undefined, (message, exception) => {
|
|
|
|
+ this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
|
|
|
|
+
|
|
|
|
+ if (onError) {
|
|
|
|
+ onError(message, exception);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
|
|
this.photoTexture.onLoadObservable.addOnce(()=> {
|
|
this.photoTexture.onLoadObservable.addOnce(()=> {
|
|
this._setReady(true);
|
|
this._setReady(true);
|
|
@@ -114,6 +125,8 @@ module BABYLON {
|
|
this._mesh.dispose();
|
|
this._mesh.dispose();
|
|
this._material.dispose();
|
|
this._material.dispose();
|
|
|
|
|
|
|
|
+ this.onLoadErrorObservable.clear();
|
|
|
|
+
|
|
super.dispose(doNotRecurse, disposeMaterialAndTextures);
|
|
super.dispose(doNotRecurse, disposeMaterialAndTextures);
|
|
}
|
|
}
|
|
}
|
|
}
|