mwg API
    Preparing search index...

    Function setAssetMap

    The file:// story, split by how renderer-specific each piece is.

    paths.ts resolves an asset path against the compiled data: URI map (or the dev server) and needs no renderer at all; binary.ts caches raw bytes the same renderer-free way, for anything (three-d's VOX loader, most directly) that wants an ArrayBuffer rather than a decoded texture; loader.ts fetches and decodes textures through Pixi specifically. This barrel exposes all three, so import { load, resolve } from '@datamoc/mw_games/assets' is unchanged - but a game rendering through something else imports @datamoc/mw_games/assets/paths or @datamoc/mw_games/assets/binary instead and pays nothing for Pixi.

    • Hands resolve/has/paths a game's own path-to-URI map, in place of tools/compile-resources's window.__MWG_ASSETS__ convention.

      A game bundled by its own tool (Vite, say) that compiles its assets into data: URIs a different way still wants resolve's single lookup and isCompiled's dev/build branch, without also adopting window.__MWG_ASSETS__ as the wire format. Passing the map here makes this file agnostic to how the map was built, only to its shape - { path: uri }, the same shape window.__MWG_ASSETS__ already is. undefined reverts to reading window.__MWG_ASSETS__ (or dev-server mode, if that is unset too).

      Parameters

      • map: Record<string, string> | undefined

      Returns void

      import { setAssetMap, isCompiled, resolve } from '@datamoc/mw_games/assets/paths';

      setAssetMap({ 'tiles.png': 'data:image/png;base64,...' });
      console.log(isCompiled()); // true
      console.log(resolve('tiles.png')); // the data: URI handed in above

      setAssetMap(undefined); // back to window.__MWG_ASSETS__ / dev-server mode