AnimationBakeLoader
new AnimationBakeLoader(manager : THREE.LoadingManager)Loader for baked animation textures (VAT/OAT). Given a base URL (or a URL ending with .exr or .json), it loads the EXR texture and its paired JSON metadata, then constructs and returns an initialized AnimationBakeMixer.
URL resolution rules:
- If the URL ends with .exr, the JSON URL is derived by replacing with .json.
- If the URL ends with .json, the EXR URL is derived by replacing with .exr.
- Otherwise, "
.exr" and " .json" are used.
Constructor Parameters
manageroptionalTHREE.LoadingManagerSee also
Example
import { AnimationBakeLoader } from '@three-blocks/core';
const loader = new AnimationBakeLoader();
loader.load('/files/baked_vat', (mixers, meta) => {
const clips = Array.isArray(mixers) ? mixers : [ mixers ];
const metaList = Array.isArray(meta) ? meta : [ meta ];
clips.forEach((mixer, index) => {
const info = metaList[ index ] ?? {};
const instanceCount = info.instances?.length ?? info.idCount ?? 0;
console.log('Instances in clip', index, instanceCount);
mixer.play();
});
});
// or use the async variant
const clipMixers = await loader.loadAsync('/files/baked_vat');
const mixers = Array.isArray(clipMixers) ? clipMixers : [ clipMixers ];
mixers.forEach((mixer) => mixer.setConfig({ loop: false }).play());
Methods
load#
load(url : string, onLoad : function, onProgress : function, onError : function)Load an EXR and its paired JSON metadata and return an initialized AnimationBakeMixer.
Parameters
urlstringBase URL or .exr/.json URL.
onLoadoptionalfunctionCallback fired after the EXR and metadata are loaded.
onProgressoptionalfunctionProgress callback invoked with loader events.
onErroroptionalfunctionError callback invoked when load fails.
loadAsync#
loadAsync(url : string, onProgress : function) : Promise<AnimationBakeMixer>Promise-based variant of load.
Parameters
urlstringonProgressoptionalfunctionOptional progress callback invoked with loader events.
Returns
Promise<AnimationBakeMixer> — Promise that resolves with the initialized mixer.