import { GLEnum } from './core/type'; export type TextureImageSource = HTMLImageElement | HTMLCanvasElement | HTMLVideoElement; export type TexturePixelSource = { data: Uint8Array | Float32Array | Int32Array; width: number; height: number; depth?: number; }; export type TextureSource = TextureImageSource | TexturePixelSource; export declare function isPixelSource(source: TextureSource | undefined | null): source is TexturePixelSource; export declare function getPossiblelInternalFormat(format: number, type: number): number; export declare function getDefaultTextureFormatBySource(source?: TextureSource): number; export declare function getDefaultTypeBySource(source?: TextureSource): 5121 | 5124 | 5125 | 5126 | 5131; export interface TextureOpts { /** * Source */ source: TSource; /** * Texture width, readonly when the texture source is image */ width: number; /** * Texture height, readonly when the texture source is image */ height: number; /** * Texel data type. * Possible values: * + {@link clay.constants.UNSIGNED_BYTE} * + {@link clay.constants.HALF_FLOAT} * + {@link clay.constants.FLOAT} * + {@link clay.constants.UNSIGNED_INT_24_8_WEBGL} * + {@link clay.constants.UNSIGNED_INT} */ type: GLEnum; /** * Format of texel data * Possible values: * + {@link clay.constants.RGBA} * + {@link clay.constants.DEPTH_COMPONENT} * + {@link clay.constants.DEPTH_STENCIL} */ format: GLEnum; /** * Format of internal storage */ internalFormat: GLEnum; /** * Texture wrap. Default to be REPEAT. * Possible values: * + {@link clay.constants.CLAMP_TO_EDGE} * + {@link clay.constants.REPEAT} * + {@link clay.constants.MIRRORED_REPEAT} */ wrapS: GLEnum; /** * Texture wrap. Default to be REPEAT. * Possible values: * + {@link clay.constants.CLAMP_TO_EDGE} * + {@link clay.constants.REPEAT} * + {@link clay.constants.MIRRORED_REPEAT} */ wrapT: GLEnum; /** * Possible values: * + {@link clay.constants.NEAREST} * + {@link clay.constants.LINEAR} * + {@link clay.constants.NEAREST_MIPMAP_NEAREST} * + {@link clay.constants.LINEAR_MIPMAP_NEAREST} * + {@link clay.constants.NEAREST_MIPMAP_LINEAR} * + {@link clay.constants.LINEAR_MIPMAP_LINEAR} */ minFilter: GLEnum; /** * Possible values: * + {@link clay.constants.NEAREST} * + {@link clay.constants.LINEAR} */ magFilter: GLEnum; /** * If enable mimap. */ useMipmap: boolean; /** * Anisotropic filtering, enabled if value is larger than 1 * @see https://developer.mozilla.org/en-US/docs/Web/API/EXT_texture_filter_anisotropic */ anisotropic: number; /** * If flip in y axis for given image source */ flipY: boolean; /** * A flag to indicate if texture source is sRGB */ sRGB: boolean; /** * Unpack alignment */ unpackAlignment: 4; /** * Premultiply alpha */ premultiplyAlpha: boolean; /** * Dynamic option for texture like video */ dynamic: boolean; } interface Texture extends Omit { } declare abstract class Texture { protected _width?: number; protected _height?: number; textureType: string; private _source?; private _loadingPromise?; private _format?; private _type?; private _internalFormat?; __version: number; constructor(opts?: Partial); get source(): TSource | undefined; set source(val: TSource | undefined); get width(): number; set width(value: number); get height(): number; set height(value: number); get type(): GLEnum; set type(type: GLEnum); get format(): GLEnum; set format(format: GLEnum); get internalFormat(): GLEnum; set internalFormat(internalFormat: GLEnum); protected _defaultFormat(): number; protected _defaultType(): number; /** * Mark texture is dirty and update in the next frame */ dirty(): void; nextHighestPowerOfTwo(x: number): number; resize(width: number, height: number): void; /** * Test if image of texture is valid and loaded. */ abstract isRenderable(): boolean; /** * Remove a promise that will be resolved if texture is ready. * Will return undefined if there is not any loading actions. * PENDING Should always return a promise? */ checkReady(): Promise | undefined; startLoading(doLoading: (resolve: () => void, reject: () => void) => void): Promise; /** * Test if texture size is power of two * @return {boolean} */ isPowerOfTwo(): boolean; } export default Texture;