Skip to content

phantomstudios/asset-manager-core

Repository files navigation

@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