@lightningjs/renderer
    Preparing search index...

    Class ImageTexture

    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 Summary)

    Index

    Constructors

    Properties

    cacheKey: null | string = null

    Cache key assigned by CoreTextureManager when this texture is stored in the key cache. null when the texture is not cached.

    ctxTexture: undefined | CoreContextTexture
    maxRetryCount: number
    memUsed: number = 0
    preventCleanup: boolean = false
    props: Required<ImageTextureProps>
    renderable: boolean = false
    renderableOwners: Set<string | number> = ...
    retryCount: number = 0

    Memory used by this texture in bytes

    This is tracked by the TextureMemoryManager and updated when the texture is loaded/freed. Set to 0 when texture is not loaded.

    state: TextureState = 'initial'
    textureData: null | TextureData = null
    type: TextureType = TextureType.image
    z$__type__Props: ImageTextureProps

    Accessors

    Methods

    • Clear all listeners for the given event names by setting their array length to 0, WITHOUT deleting the keys. This keeps the eventListeners object in V8's fast-properties mode and avoids re-allocating the arrays on the next on() call. Use this for objects with a known fixed set of event names (e.g. CoreAnimation, CoreAnimationController).

      Only writes arr.length = 0 when the array is non-empty -- skips the write (and the write barrier on old-gen objects) when already empty, which is the common case after unregisterAnimation() has removed all listeners.

      Parameters

      • events: readonly string[]

      Returns void

    • Returns
          | Promise<ImageResponse>
          | { data: null; premultiplyAlpha?: undefined }
          | {
              data: null | ImageBitmap | HTMLCanvasElement | ImageData;
              premultiplyAlpha: null | boolean;
          }

    • Free the source texture data for this Texture.

      Returns void

      The texture data is the source data that is used to populate the CoreContextTexture. e.g. ImageData that is downloaded from a URL.

    • Check whether this emitter has any listeners registered.

      Parameters

      • Optionalevent: string

        Optional event name. When provided, checks only that event. When omitted, checks all events.

      Returns boolean

      true if at least one listener is registered.

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

    • Release the texture data and core context texture for this Texture without changing state.

      Returns void

      The ctxTexture is created by the renderer and lives on the GPU.

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

      Parameters

      • owner: string | number
      • 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.