Closed Mugen87 closed 8 months ago
I have changed my mind. I think we can support lazy loading when SequenceManager.playSequence()
is called. But we must ensure to avoid duplicate track parsing logic if possible.
Such an approach should better match to developer's expectations than a loadExternalSequences
flag.
const filename = this.filename;
const resourcePath = this.resourcePath;
const sequenceId = id.toString().padStart( 4, '0' );
const subSequenceId = variationIndex.toString().padStart( 2, '0' );
const path = resourcePath + filename + sequenceId + '-' + subSequenceId + '.anim';
fetch( path ).then( ( response ) => {
if ( response.ok === false ) {
throw new Error( `Unable to load animation file. HTTP error, response status = ${response.status}` );
}
return response.arrayBuffer();
} ).then( ( buffer ) => {
console.log( buffer );
} );
The above code shows how the path for an external animation file is build and how the loading process looks like. However, I'm not sure yet how to update the existing keyframes with these new track data.
Fixed via 53749a395a6c61bea4700e422af1c8a436557a9a.
Low priority sequences (like emotes) are not embedded in M2 files but located in separate files with
.anim
extensions. There is such a file for each low priority sequence and it can be identified via the sequence and subsequence id.Each sequence that does not hold the
0x20
value in its flag is a called external sequence and must be processed in a separate code path.I think it's best to introduce an option (
loadExternalSequences
) that can be passed to theload()
method. It's default value would befalse
. When set totrue
, the loader automatically loads all external.anim
files. Their content is stored as array buffers internally and used when parsing tracks.