|
@@ -1,6 +1,27 @@
|
|
|
module BABYLON {
|
|
|
+ /**
|
|
|
+ * Raw texture can help creating a texture directly from an array of data.
|
|
|
+ * This can be super useful if you either get the data from an uncompressed source or
|
|
|
+ * if you wish to create your texture pixel by pixel.
|
|
|
+ */
|
|
|
export class RawTexture extends Texture {
|
|
|
private _engine: Engine;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Instantiates a new RawTexture.
|
|
|
+ * Raw texture can help creating a texture directly from an array of data.
|
|
|
+ * This can be super useful if you either get the data from an uncompressed source or
|
|
|
+ * if you wish to create your texture pixel by pixel.
|
|
|
+ * @param data define the array of data to use to create the texture
|
|
|
+ * @param width define the width of the texture
|
|
|
+ * @param height define the height of the texture
|
|
|
+ * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
|
|
|
+ * @param scene define the scene the texture belongs to
|
|
|
+ * @param generateMipMaps define whether mip maps should be generated or not
|
|
|
+ * @param invertY define if the data should be flipped on Y when uploaded to the GPU
|
|
|
+ * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
|
|
|
+ * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
|
|
|
+ */
|
|
|
constructor(data: ArrayBufferView, width: number, height: number, public format: number, scene: Scene, generateMipMaps: boolean = true, invertY: boolean = false, samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE, type: number = Engine.TEXTURETYPE_UNSIGNED_INT) {
|
|
|
super(null, scene, !generateMipMaps, invertY);
|
|
|
this._engine = scene.getEngine();
|
|
@@ -10,33 +31,102 @@
|
|
|
this.wrapV = Texture.CLAMP_ADDRESSMODE;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Updates the texture underlying data.
|
|
|
+ * @param data Define the new data of the texture
|
|
|
+ */
|
|
|
public update(data: ArrayBufferView): void {
|
|
|
this._engine.updateRawTexture(this._texture, data, this._texture!.format, this._texture!.invertY, undefined, this._texture!.type);
|
|
|
}
|
|
|
|
|
|
- // Statics
|
|
|
+ /**
|
|
|
+ * Creates a luminance texture from some data.
|
|
|
+ * @param data Define the texture data
|
|
|
+ * @param width Define the width of the texture
|
|
|
+ * @param height Define the height of the texture
|
|
|
+ * @param scene Define the scene the texture belongs to
|
|
|
+ * @param generateMipMaps Define whether or not to create mip maps for the texture
|
|
|
+ * @param invertY define if the data should be flipped on Y when uploaded to the GPU
|
|
|
+ * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
|
|
|
+ * @returns the luminance texture
|
|
|
+ */
|
|
|
public static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps: boolean = true, invertY: boolean = false, samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE): RawTexture {
|
|
|
return new RawTexture(data, width, height, Engine.TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Creates a luminance alpha texture from some data.
|
|
|
+ * @param data Define the texture data
|
|
|
+ * @param width Define the width of the texture
|
|
|
+ * @param height Define the height of the texture
|
|
|
+ * @param scene Define the scene the texture belongs to
|
|
|
+ * @param generateMipMaps Define whether or not to create mip maps for the texture
|
|
|
+ * @param invertY define if the data should be flipped on Y when uploaded to the GPU
|
|
|
+ * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
|
|
|
+ * @returns the luminance alpha texture
|
|
|
+ */
|
|
|
public static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps: boolean = true, invertY: boolean = false, samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE): RawTexture {
|
|
|
return new RawTexture(data, width, height, Engine.TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Creates an alpha texture from some data.
|
|
|
+ * @param data Define the texture data
|
|
|
+ * @param width Define the width of the texture
|
|
|
+ * @param height Define the height of the texture
|
|
|
+ * @param scene Define the scene the texture belongs to
|
|
|
+ * @param generateMipMaps Define whether or not to create mip maps for the texture
|
|
|
+ * @param invertY define if the data should be flipped on Y when uploaded to the GPU
|
|
|
+ * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
|
|
|
+ * @returns the alpha texture
|
|
|
+ */
|
|
|
public static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps: boolean = true, invertY: boolean = false, samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE): RawTexture {
|
|
|
return new RawTexture(data, width, height, Engine.TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Creates a RGB texture from some data.
|
|
|
+ * @param data Define the texture data
|
|
|
+ * @param width Define the width of the texture
|
|
|
+ * @param height Define the height of the texture
|
|
|
+ * @param scene Define the scene the texture belongs to
|
|
|
+ * @param generateMipMaps Define whether or not to create mip maps for the texture
|
|
|
+ * @param invertY define if the data should be flipped on Y when uploaded to the GPU
|
|
|
+ * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
|
|
|
+ * @returns the RGB alpha texture
|
|
|
+ */
|
|
|
public static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps: boolean = true, invertY: boolean = false, samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE, type: number = Engine.TEXTURETYPE_UNSIGNED_INT): RawTexture {
|
|
|
return new RawTexture(data, width, height, Engine.TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Creates a RGBA texture from some data.
|
|
|
+ * @param data Define the texture data
|
|
|
+ * @param width Define the width of the texture
|
|
|
+ * @param height Define the height of the texture
|
|
|
+ * @param scene Define the scene the texture belongs to
|
|
|
+ * @param generateMipMaps Define whether or not to create mip maps for the texture
|
|
|
+ * @param invertY define if the data should be flipped on Y when uploaded to the GPU
|
|
|
+ * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
|
|
|
+ * @returns the RGBA texture
|
|
|
+ */
|
|
|
public static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps: boolean = true, invertY: boolean = false, samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE, type: number = Engine.TEXTURETYPE_UNSIGNED_INT): RawTexture {
|
|
|
return new RawTexture(data, width, height, Engine.TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Creates a R texture from some data.
|
|
|
+ * @param data Define the texture data
|
|
|
+ * @param width Define the width of the texture
|
|
|
+ * @param height Define the height of the texture
|
|
|
+ * @param scene Define the scene the texture belongs to
|
|
|
+ * @param generateMipMaps Define whether or not to create mip maps for the texture
|
|
|
+ * @param invertY define if the data should be flipped on Y when uploaded to the GPU
|
|
|
+ * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
|
|
|
+ * @returns the R texture
|
|
|
+ */
|
|
|
public static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps: boolean = true, invertY: boolean = false, samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE, type: number = Engine.TEXTURETYPE_FLOAT): RawTexture {
|
|
|
return new RawTexture(data, width, height, Engine.TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
}
|