The graphics device used to manage this texture.
Optional
options: { addressU?: number; addressV?: number; addressW?: number; anisotropy?: number; compareFunc?: number; compareOnRead?: boolean; cubemap?: boolean; depth?: number; fixCubemapSeams?: boolean; flipY?: boolean; format?: number; height?: number; levels?: Uint8Array[]; magFilter?: number; minFilter?: number; mipmaps?: boolean; name?: string; premultiplyAlpha?: boolean; projection?: string; type?: string; volume?: boolean; width?: number }Object for passing optional arguments.
Optional
addressU?: numberThe repeat mode to use in the U direction. Defaults to ADDRESS_REPEAT.
Optional
addressV?: numberThe repeat mode to use in the V direction. Defaults to ADDRESS_REPEAT.
Optional
addressW?: numberThe repeat mode to use in the W direction. Defaults to ADDRESS_REPEAT.
Optional
anisotropy?: numberThe level of anisotropic filtering to use. Defaults to 1.
Optional
compareComparison function when compareOnRead is enabled (WebGL2 only). Can be:
Defaults to FUNC_LESS.
Optional
compareWhen enabled, and if texture format is PIXELFORMAT_DEPTH or PIXELFORMAT_DEPTHSTENCIL, hardware PCF is enabled for this texture, and you can get filtered results of comparison using texture() in your shader (WebGL2 only). Defaults to false.
Optional
cubemap?: booleanSpecifies whether the texture is to be a cubemap. Defaults to false.
Optional
depth?: numberThe number of depth slices in a 3D texture (WebGL2 only). Defaults to 1 (single 2D image).
Optional
fixSpecifies whether this cubemap texture requires special seam fixing shader code to look right. Defaults to false.
Optional
flipY?: booleanSpecifies whether the texture should be flipped in the Y-direction. Only affects textures with a source that is an image, canvas or video element. Does not affect cubemaps, compressed textures or textures set from raw pixel data. Defaults to false.
Optional
format?: numberThe pixel format of the texture. Can be:
Defaults to PIXELFORMAT_R8_G8_B8_A8.
Optional
height?: numberThe height of the texture in pixels. Defaults to 4.
Optional
levels?: Uint8Array[]Array of Uint8Array.
Optional
magThe magnification filter type to use. Defaults to FILTER_LINEAR.
Optional
minThe minification filter type to use. Defaults to FILTER_LINEAR_MIPMAP_LINEAR.
Optional
mipmaps?: booleanWhen enabled try to generate or use mipmaps for this texture. Default is true.
Optional
name?: stringThe name of the texture.
Optional
premultiplyIf true, the alpha channel of the texture (if present) is multiplied into the color channels. Defaults to false.
Optional
projection?: stringThe projection type of the texture, used when the texture represents an environment. Can be:
Defaults to TEXTUREPROJECTION_CUBE if options.cubemap is specified, otherwise TEXTUREPROJECTION_NONE.
Optional
type?: stringSpecifies the image type, see TEXTURETYPE_DEFAULT.
Optional
volume?: booleanSpecifies whether the texture is to be a 3D volume (WebGL2 only). Defaults to false.
Optional
width?: numberThe width of the texture in pixels. Defaults to 4.
Private
_pixelThe name of the texture. Defaults to null.
The addressing mode to be applied to the texture horizontally. Can be:
The addressing mode to be applied to the texture vertically. Can be:
The addressing mode to be applied to the 3D texture depth (WebGL2 only). Can be:
Integer value specifying the level of anisotropic to apply to the texture ranging from 1 (no anisotropic filtering) to the GraphicsDevice property maxAnisotropy.
Comparison function when compareOnRead is enabled (WebGL2 only). Possible values:
When enabled, and if texture format is PIXELFORMAT_DEPTH or PIXELFORMAT_DEPTHSTENCIL, hardware PCF is enabled for this texture, and you can get filtered results of comparison using texture() in your shader (WebGL2 only).
Returns true if this texture is a cube map and false otherwise.
The number of depth slices in a 3D texture (WebGL2 only).
Specifies whether the texture should be flipped in the Y-direction. Only affects textures with a source that is an image, canvas or video element. Does not affect cubemaps, compressed textures or textures set from raw pixel data. Defaults to true.
The pixel format of the texture. Can be:
The height of the texture in pixels.
The magnification filter to be applied to the texture. Can be:
The minification filter to be applied to the texture. Can be:
Defines if texture should generate/upload mipmaps if possible.
该贴图的像素数据
Returns true if all dimensions of the texture are power of two, and false otherwise.
Returns true if this texture is a 3D volume and false otherwise.
The width of the texture in pixels.
Get the pixel data of the texture. If this is a cubemap then an array of 6 images will be returned otherwise a single image.
The source image of this texture. Can be null if source not assigned for specific image level.
Optional
mipLevel: numberA non-negative integer specifying the image level of detail. Defaults to 0, which represents the base image source. A level value of N, that is greater than 0, represents the image source for the Nth mipmap reduction level.
Locks a miplevel of the texture, returning a typed array to be filled with pixel data.
A typed array containing the pixel data of the locked mip level.
Optional
options: { face?: number; level?: number; mode?: number }Optional options object. Valid properties are as follows:
Optional
face?: numberIf the texture is a cubemap, this is the index of the face to lock.
Optional
level?: numberThe mip level to lock with 0 being the top level. Defaults to 0.
Optional
mode?: numberThe lock mode. Can be:
Set the pixel data of the texture from a canvas, image, video DOM element. If the texture is a cubemap, the supplied source must be an array of 6 canvases, images or videos.
A canvas, image or video element, or an array of 6 canvas, image or video elements.
Optional
mipLevel: numberA non-negative integer specifying the image level of detail. Defaults to 0, which represents the base image source. A level value of N, that is greater than 0, represents the image source for the Nth mipmap reduction level.
Forces a reupload of the textures pixel data to graphics memory. Ordinarily, this function is called by internally by Texture#setSource and Texture#unlock. However, it still needs to be called explicitly in the case where an HTMLVideoElement is set as the source of the texture. Normally, this is done once every frame before video textured geometry is rendered.
Create a new Texture instance.
Example