mwg API
    Preparing search index...

    Interface LoadBinaryOptions

    Raw asset bytes, cached and progress-reported the same way loader.ts's texture cache is - but renderer-free, so a Babylon-only game (or anything else that just wants an ArrayBuffer) gets the same load/isLoaded/release shape a 2D game's textures already have, without pulling Pixi in. Vox.parseVox is the direct beneficiary: it takes an ArrayBuffer a game previously had to fetch and cache by hand.

    Kept out of loader.ts itself for the same reason paths.ts is its own file: loader.ts is allowed to know about Pixi, three-d is allowed to know about Babylon, but neither should have to import the other's renderer just to share a byte cache.

    import { loadBinary, getBinary } from '@datamoc/mw_games/assets';
    import { parseVox, createVoxModel3D } from '@datamoc/mw_games/3d';

    await loadBinary(['models/rock.vox']);
    const model = parseVox(getBinary('models/rock.vox'));
    interface LoadBinaryOptions {
        fetch?: {
            (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
            (input: string | URL | Request, init?: RequestInit): Promise<Response>;
        };
    }
    Index
    fetch?: {
        (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
        (input: string | URL | Request, init?: RequestInit): Promise<Response>;
    }

    overrides the fetch used to load bytes; defaults to globalThis.fetch

    Type Declaration

      • (input: URL | RequestInfo, init?: RequestInit): Promise<Response>
      • Parameters

        • input: URL | RequestInfo
        • Optionalinit: RequestInit

        Returns Promise<Response>

      • (input: string | URL | Request, init?: RequestInit): Promise<Response>
      • Parameters

        • input: string | URL | Request
        • Optionalinit: RequestInit

        Returns Promise<Response>