loader.setParser

setParser(type: string, parserFn: Function) → {}

specify a parser/preload function for the given asset type

// specify a custom function for "abc" format
function customAbcParser(data, onload, onerror) {
   // preload and do something with the data
   let parsedData = doSomething(data);
   // when done, call the onload callback with the parsed data
   onload(parsedData);
   // in case of error, call the onerror callback
   onerror();
   // return the amount of asset parsed
   return 1
}
// set the parser for the custom format
loader.setParser("abc", customAbcParser);
See: Asset.type
Parameters:
Name Type Description
type string

asset type

parserFn Function

parser function

Returns:
Type Description
Powered by webdoc!