Texture consisting of an image loaded from a URL

The ImageTexture's ImageTextureProps.src prop defines the image URL to be downloaded.

By default, the texture's alpha values will be premultiplied into its color values which is generally the desired setting before they are sent to the texture's associated Shader. However, in special cases you may want the Shader to receive straight (non-premultiplied) values. In that case you can disable the default behavior by setting the ImageTextureProps.premultiplyAlpha prop to false.

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
props: Required<ImageTextureProps>
renderable: boolean = false
renderableOwners: Set<unknown> = ...
state: TextureState = 'freed'
type: TextureType = TextureType.image
z$__type__Props: ImageTextureProps

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

  • Parameters

    • blob: Blob
    • premultiplyAlpha: null | boolean
    • sx: null | number
    • sy: null | number
    • sw: null | number
    • sh: null | number

    Returns Promise<{
        data: ImageBitmap | HTMLImageElement;
        premultiplyAlpha: boolean;
    }>

  • Parameters

    • src: string
    • hasAlpha: boolean

    Returns Promise<{
        data: HTMLImageElement;
        premultiplyAlpha: boolean;
    }>

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

  • Generates a cache key for the ImageTexture based on the provided props.

    Parameters

    • props: ImageTextureProps

      The props used to generate the cache key.

    Returns string | false

    The cache key as a string, or false if the key cannot be generated.

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

    Parameters

    • props: ImageTextureProps

    Returns Required<ImageTextureProps>

    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.