@asset-manager/core

A singleton for loading and retrieving assets used in your application.


Keywords
javascript, loader, singleton, assets
License
MIT
Install
npm install @asset-manager/core@0.0.5

Documentation

@asset-manager/core

NPM version Actions Status PR Welcome

This package provides a simple solution for preloading various type of assets and fetching them through a singleton class.

Introduction

Loading and retrieving assets.

import AssetManager from "@asset-manager/core";
import { AudioPlayer } from "@asset-manager/tone";

// Get an instance to the manager and set the loaders
const manager = AssetManager.getInstance();
manager.setLoaders({
  audio: AudioPlayer,
});

// Set the assets to load
manager.setAssets([
  {
    id: "splash",
    type: "audio",
    url: "splash.mp3",
    preload: true,
  },
]);

// Elsewhere in your app you can grab assets from the manager
const player = AssetManager.getInstance().get<AudioPlayer>("splash");

Installation

Install this package with npm.

npm i @asset-manager/core

The core asset manager does not include any 'loaders'. You may want to load an official loader or create your own.

npm i @asset-manager/three