A library to handle assets loading.
npm i @solaldr/loader
import AssetsLoader from '@solaldr/loader'
import { ThreeLoader } from '@solaldr/loader/dist/index.esm'
const assetsLoader = new AssetsLoader([
{
test: /\.(?:png|jpe?g)/,
loader: new ThreeLoader(new THREE.TextureLoader())
},
{
test: /\.(?:glb|gltf)/,
loader: new ThreeLoader(new THREE.GLTFLoader())
}
])
assetsLoader.load('/test.glb').then((gltfScene) => {
console.log(gltfScene);
})
With array definition
const g = assetsLoader.addGroup([
"./object.gltf",
{ name: 'test', path: './test.gltf' }
])
With object definition
const g = assetsLoader.addGroup({
name: 'global',
baseUrl: './public/',
files: [ "object.gltf", "object2.gltf" ]
})
Inside another group
group.addGroup({
name: 'subGroup',
baseUrl: './public/',
files: [ "object3.gltf", "object4.gltf" ]
})
From an existent group
group.load();
Directly during création
const results = await assetsLoader.loadGroup({
name: 'global',
baseUrl: './public/',
files: [ "object.gltf", "object2.gltf" ]
})
From string definition
const file = assetsLoader.addFile("test.png")
From object definition
const file = assetsLoader.addFile({
name: "test",
path: "./test.png"
})
const result = await file.load()
const group = assetsManager.get('global')
event | description | compat |
---|---|---|
load |
Triggered when the ressource is fully loaded | File |Group |Manager |
progress |
Wrapper for the ProgressEvent |
File |Group |Manager |
file:load |
Triggered when a file is loaded inside a group | Group |
MIT.