Documentation
    Preparing search index...

    Interface AssetLoader<T>

    A decoder: bytes in, an asset out.

    Loaders are values, so the set of formats an application supports is the set of loaders it imports — no registry, no side-effectful registration, no bundle weight for formats nobody loads. name is diagnostics only; cache identity is the loader object, see the module comment.

    interface AssetLoader<T> {
        name: string;
        load(
            response: FetchResponse,
            url: string,
            context?: AssetLoadContext,
        ): Promise<T>;
        loadStream?(
            chunks: AsyncIterable<Uint8Array<ArrayBufferLike>>,
            url: string,
        ): Promise<T>;
    }

    Type Parameters

    • T
    Index
    name: string

    A short identifier used in error context (e.g. "json").

    • Decodes one response body.

      Parameters

      • response: FetchResponse

        The response the manager fetched; already checked ok.

      • url: string

        The URL it came from, for error messages and (once glTF lands) for resolving relative dependencies.

      • Optionalcontext: AssetLoadContext

      Returns Promise<T>

    • Optional chunked decode (§76 streaming).

      When present, AssetManager.load passes an async iterable of body chunks instead of a FetchResponse — but only when the load did not already consume the body for hashing or worker decoding. A loader that only implements AssetLoader.load is unchanged.

      Parameters

      • chunks: AsyncIterable<Uint8Array<ArrayBufferLike>>
      • url: string

      Returns Promise<T>