Function setParser

  • specify a parser/preload function for the given asset type

    Parameters

    • type: string

      asset type

    • parserFn: Function

      parser function

    Returns void

    loader

    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);