@asset-manager/three
v0.0.6
Published
A singleton for loading and retrieving assets used in your application.
Downloads
5
Maintainers
Readme
@asset-manager/three
This package provides loaders for preloading three.js type assets.
Introduction
Loading and retrieving assets.
import AssetManager from "@asset-manager/core";
import { GLTFLoader, TextureLoader } from "@asset-manager/three";
// Get an instance to the manager and set the loaders
const manager = AssetManager.getInstance();
manager.setLoaders({
gltf: GLTFLoader,
texture: TextureLoader,
});
// Set the assets to load
manager.setAssets([
{
id: "modelName",
type: "gltf",
url: "modelName.gltf",
preload: true,
params: {
dracoCompressed: false,
},
},
{
id: "textureName",
type: "texture",
url: "texureName.png",
preload: true,
params: {},
},
]);
// Elsewhere in your app you can grab assets from the manager
const gltf = AssetManager.getInstance().get<GLTFLoader>("modelName").gltf;
const texture =
AssetManager.getInstance().get<TextureLoader>("textureName").texture;
Installation
Install this package with npm
.
npm i @asset-manager/three
This package does not include the core loader. You will need to install that separately
npm i @asset-manager/core