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

  • get flipY(): boolean
  • Returns boolean

  • set flipY(flipY): void
  • 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.

    Parameters

    • flipY: boolean

    Returns void

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

    • Optional mipLevel: 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

    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