dacha
    Preparing search index...

    Class MediaAsset<R>Abstract

    Base class for asset kinds backed by a file, such as a texture or a sound.

    A kind implements MediaAsset.fetchResource and, if the resource needs cleanup, MediaAsset.disposeResource. The engine loads every media asset that the configuration references in an asset field before the scene starts. Code that takes an asset by id on its own loads it through Assets: Assets.acquire to wait until it is ready, or Assets.ensure to start loading it when it is needed.

    const texture = this.assets.get(Texture, id);
    texture?.resource; // the loaded resource, or undefined

    Type Parameters

    • R = unknown

    Hierarchy (View Summary)

    Index
    id: string

    Unique identifier of the asset

    name: string

    Name of the asset

    • get resource(): R | undefined

      The loaded resource, or undefined while it is not loaded.

      Returns R | undefined

    • Frees what the resource holds, such as GPU memory. Optional.

      Parameters

      • resource: R

      Returns void

    • Fetches the file and returns the resource.

      Returns Promise<R>