Nano WebGPU API - v0.11.0
    Preparing search index...

    Class Texture

    Texture is a high-level wrapper around the native WebGPU GPUTexture. Handles asynchronous background texture fetching and allocation while immediately supplying lightweight fallback pixel placeholders (solid white or flat normal vectors) to avoid blocking rendering pipelines during network transfers.

    Implements

    • ITexture
    Index

    Constructors

    Methods

    • Releases texture resources from GPU memory and unregisters entries from the VRAM tracker.

      Parameters

      Returns void

    • Registers a callback routine invoked when the asynchronous texture load successfully completes. Returns an unsubscribe function to safely detach the callback and prevent memory leaks.

      Parameters

      • cb: () => void

        The update callback function.

      Returns () => void

      A function to unsubscribe this callback.

    • Resolves a global, cached 1x1 solid black pixel placeholder texture. Reuses the same instance across the entire context lifetime to optimize memory.

      Parameters

      Returns Texture

      The black placeholder Texture.

    • Resolves a global, cached 1x1 neutral normal map texture. Returns a straight-up vector (128, 128, 255, 255) representing (0, 0, 1) tangent coordinates. Reuses the same instance across the entire context lifetime.

      Parameters

      Returns Texture

      The flat normal map fallback Texture.

    • Resolves a global, cached 1x1 solid white pixel placeholder texture. Reuses the same instance across the entire context lifetime to optimize memory.

      Parameters

      Returns Texture

      The white placeholder Texture.

    • Spawns a Texture loading sequence in the background, immediately returning a container holding a 1x1 solid white pixel. Replaces the placeholder texture in-place once loading finishes, triggering all update listeners. Revokes Blob URLs automatically to prevent memory leaks.

      Parameters

      • ctx: Context

        Active context.

      • url: string

        Source address of the texture image.

      • options: { format?: GPUTextureFormat } = {}

        Custom format configurations.

      Returns Texture

      The newly allocated Texture instance.

    Properties

    gpuTexture: GPUTexture

    Active native WebGPU GPUTexture resource.

    isLoaded: boolean = false

    Flag indicating whether the real image asset has successfully finished loading.

    url: string = ""

    Source web address or file path of the image asset.