A texture is a container for texel data that can be utilized in a fragment shader. Typically, the texel data represents an image that is mapped over geometry.

Constructors

Properties

_invalid: boolean = false
_lockedLevel: number = -1
_lockedMode: number = TEXTURELOCK_NONE
_storage: boolean = false
id: number = ...
name: string

The name of the texture.

Accessors

Methods

  • 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.

    Parameters

    • OptionalmipLevel: number = 0

      A 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.

    Returns HTMLImageElement

    The source image of this texture. Can be null if source not assigned for specific image level.

  • 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.

    Parameters

    • source:
          | HTMLCanvasElement
          | HTMLImageElement
          | HTMLVideoElement
          | HTMLCanvasElement[]
          | HTMLImageElement[]
          | HTMLVideoElement[]

      A canvas, image or video element, or an array of 6 canvas, image or video elements.

    • OptionalmipLevel: number = 0

      A 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.

    Returns void

  • 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.

    Returns void