Represents a source of texture data for a CoreContextTexture.

Texture sources are used to populate a CoreContextTexture when that texture is loaded. Texture data retrieved by the CoreContextTexture by the getTextureData method. It's the responsibility of the concerete Texture subclass to implement this method appropriately.

Hierarchy (view full)

Constructors

Properties

dimensions: null | Readonly<Dimensions> = null

The dimensions of the texture

Until the texture data is loaded for the first time the value will be null.

error: null | Error = null
lastRenderableChangeTime = 0
preventCleanup: boolean = false
renderable: boolean = false
renderableOwners: Set<unknown> = ...
state: TextureState = 'freed'
type: TextureType = TextureType.generic

Accessors

  • get ctxTexture(): CoreContextTexture
  • Get the CoreContextTexture for this Texture

    Returns CoreContextTexture

    Each Texture has a corresponding CoreContextTexture that is used to manage the texture's native data depending on the renderer's mode (WebGL, Canvas, etc).

    The Texture and CoreContextTexture are always linked together in a 1:1 relationship.

Methods

  • Get the texture data for this texture.

    Returns Promise<TextureData>

    The texture data for this texture.

    This method is called by the CoreContextTexture when the texture is loaded. The texture data is then used to populate the CoreContextTexture.

  • Parameters

    • event: string
    • Optionallistener: ((target: any, data: any) => void)
        • (target, data): void
        • Parameters

          • target: any
          • data: any

          Returns void

    Returns void

  • Parameters

    • event: string
    • listener: ((target: any, data: any) => void)
        • (target, data): void
        • Parameters

          • target: any
          • data: any

          Returns void

    Returns void

  • Parameters

    • event: string
    • listener: ((target: any, data: any) => void)
        • (target, data): void
        • Parameters

          • target: any
          • data: any

          Returns void

    Returns void

  • Event called when the Texture becomes renderable or unrenderable.

    Parameters

    • isRenderable: boolean

      true if this Texture has renderable owners.

    Returns void

    Used by subclasses like SubTexture propogate then renderability of the Texture to other referenced Textures.

  • Add/remove an owner to/from the Texture based on its renderability.

    Parameters

    • owner: unknown
    • renderable: boolean

    Returns void

    Any object can own a texture, be it a CoreNode or even the state object from a Text Renderer.

    When the reference to the texture that an owner object holds is replaced or cleared it must call this with renderable=false to release the owner association.

  • Make a cache key for this texture.

    Parameters

    • props: unknown

    Returns string | false

    A cache key for this texture or false if the texture type does not support caching.

    Each concrete Texture subclass must implement this method to provide an appropriate cache key for the texture type including the texture's properties that uniquely identify a copy of the texture. If the texture type does not support caching, then this method should return false.

  • Resolve the default values for the texture's properties.

    Parameters

    • props: unknown

    Returns Record<string, unknown>

    The default values for the texture's properties.

    Each concrete Texture subclass must implement this method to provide default values for the texture's optional properties.