API

Function loadKtxTexture2D

  • Load a texture with KTX compressed format auto-selection and fallback.

    Tries each suffix in priority order, picks the first whose compressed format the GPU supports, fetches and parses the KTX1 file, and uploads it as a compressed GPU texture. Falls back to the base URL (loaded as a regular image) if no suffix is supported or loading fails.

    Parameters

    • engine: EngineContext

      The engine context (device must have compressed texture features enabled).

    • baseUrl: string

      The fallback image URL (e.g. "textures/grid.png").

    • suffixes: string[]

      KTX suffixes to try in priority order (e.g. ["-astc.ktx", "-dxt.ktx", "-etc2.ktx"]).

    • opts: Texture2DOptions = {}

      Texture options (sampler, address mode, etc.). mipMaps is ignored — KTX mips are used as-is.

    Returns Promise<Texture2D>

    A Texture2D (same interface whether compressed or fallback).