Class TextureCache

A caching texture manager It is instantiated with a WebGL context and then used to load and cache textures

Constructors

Properties

cache: Map<string, WebGLTexture>
defaultRand: WebGLTexture
defaultWhite: WebGLTexture
gl: WebGL2RenderingContext
_instance: TextureCache
initialized: boolean = false

Accessors

  • get defaultRand(): WebGLTexture
  • Return the default random RGB texture

    Returns WebGLTexture

  • get defaultWhite(): WebGLTexture
  • Return the default white 1x1 texture

    Returns WebGLTexture

  • get size(): number
  • Return the number of textures in the cache

    Returns number

Methods

  • Add a texture to the cache

    Parameters

    • key: string

      Key of texture, this is usually the URL or filename path

    • texture: WebGLTexture

      WebGL texture

    Returns void

  • Return a texture from the cache by name

    Parameters

    • key: string

      Key of texture, this is usually the URL or filename path

    Returns undefined | WebGLTexture

  • Create or return a texture from the cache by name

    Parameters

    • src: string | ArrayBufferView

      URL or filename path of texture image, or ArrayBufferView holding texture

    • filter: boolean = true

      Enable texture filtering and mipmaps (default true)

    • flipY: boolean = false

      Flip the texture vertically (default true)

    • textureKey: string = ''

      Unique key, only used for ArrayBuffer textures

    • extraOptions: TextureOptions = {}

      Extra options to pass to twgl.createTexture, see https://twgljs.org/docs/module-twgl.html#.TextureOptions

    Returns undefined | WebGLTexture

  • Parameters

    • gl: WebGL2RenderingContext
    • randSize: number = 512

    Returns void

Generated using TypeDoc