|
@@ -9,6 +9,7 @@ import { BaseTexture } from "../Materials/Textures/baseTexture";
|
|
|
import { Texture } from "../Materials/Textures/texture";
|
|
|
import { CubeTexture } from "../Materials/Textures/cubeTexture";
|
|
|
import { HDRCubeTexture } from "../Materials/Textures/hdrCubeTexture";
|
|
|
+import { EquiRectangularCubeTexture } from "../Materials/Textures/equiRectangularCubeTexture";
|
|
|
import { Logger } from "../Misc/logger";
|
|
|
import { AnimationGroup } from '../Animations/animationGroup';
|
|
|
|
|
@@ -687,6 +688,80 @@ export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextu
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Define a task used by AssetsManager to load Equirectangular cube textures
|
|
|
+ */
|
|
|
+export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
|
|
|
+ /**
|
|
|
+ * Gets the loaded texture
|
|
|
+ */
|
|
|
+ public texture: EquiRectangularCubeTexture;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Callback called when the task is successful
|
|
|
+ */
|
|
|
+ public onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
|
|
|
+ /**
|
|
|
+ * Callback called when the task is successful
|
|
|
+ */
|
|
|
+ public onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Creates a new EquiRectangularCubeTextureAssetTask object
|
|
|
+ * @param name defines the name of the task
|
|
|
+ * @param url defines the location of the file to load
|
|
|
+ * @param size defines the desired size (the more it increases the longer the generation will be)
|
|
|
+ * If the size is omitted this implies you are using a preprocessed cubemap.
|
|
|
+ * @param noMipmap defines if mipmaps should not be generated (default is false)
|
|
|
+ * @param gammaSpace specifies if the texture will be used in gamma or linear space
|
|
|
+ * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
|
|
|
+ * (default is true)
|
|
|
+ */
|
|
|
+ constructor(
|
|
|
+ /**
|
|
|
+ * Defines the name of the task
|
|
|
+ */
|
|
|
+ public name: string,
|
|
|
+ /**
|
|
|
+ * Defines the location of the file to load
|
|
|
+ */
|
|
|
+ public url: string,
|
|
|
+ /**
|
|
|
+ * Defines the desired size (the more it increases the longer the generation will be)
|
|
|
+ */
|
|
|
+ public size: number,
|
|
|
+ /**
|
|
|
+ * Defines if mipmaps should not be generated (default is false)
|
|
|
+ */
|
|
|
+ public noMipmap: boolean = false,
|
|
|
+ /**
|
|
|
+ * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
|
|
|
+ * but the standard material would require them in Gamma space) (default is true)
|
|
|
+ */
|
|
|
+ public gammaSpace: boolean = true) {
|
|
|
+ super(name);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Execute the current task
|
|
|
+ * @param scene defines the scene where you want your assets to be loaded
|
|
|
+ * @param onSuccess is a callback called when the task is successfully executed
|
|
|
+ * @param onError is a callback called if an error occurs
|
|
|
+ */
|
|
|
+ public runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void {
|
|
|
+
|
|
|
+ const onload = () => {
|
|
|
+ onSuccess();
|
|
|
+ };
|
|
|
+
|
|
|
+ const onerror = (message?: string, exception?: any) => {
|
|
|
+ onError(message, exception);
|
|
|
+ };
|
|
|
+
|
|
|
+ this.texture = new EquiRectangularCubeTexture(this.url, scene, this.size, this.noMipmap, this.gammaSpace, onload, onerror);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
* This class can be used to easily import assets into a scene
|
|
|
* @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
|
|
|
*/
|
|
@@ -858,6 +933,24 @@ export class AssetsManager {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ *
|
|
|
+ * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
|
|
|
+ * @param taskName defines the name of the new task
|
|
|
+ * @param url defines the url of the file to load
|
|
|
+ * @param size defines the size you want for the cubemap (can be null)
|
|
|
+ * @param noMipmap defines if the texture must not receive mipmaps (false by default)
|
|
|
+ * @param gammaSpace Specifies if the texture will be used in gamma or linear space
|
|
|
+ * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
|
|
|
+ * @returns a new EquiRectangularCubeTextureAssetTask object
|
|
|
+ */
|
|
|
+ public addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap = false, gammaSpace = true): EquiRectangularCubeTextureAssetTask {
|
|
|
+ const task = new EquiRectangularCubeTextureAssetTask(taskName, url, size, noMipmap, gammaSpace);
|
|
|
+ this._tasks.push(task);
|
|
|
+
|
|
|
+ return task;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Remove a task from the assets manager.
|
|
|
* @param task the task to remove
|
|
|
*/
|