load method

dynamic load(
  1. dynamic url,
  2. Function onLoad, [
  3. Function? onProgress,
  4. Function? onError,
])
override
  • Loads and parses a MTL asset from a URL. *
    • @param {String} url - URL to the MTL file.
      • @param {Function} onLoad - Callback invoked with the loaded object.
      • @param {Function} onProgress - Callback for download progress.
      • @param {Function} onError - Callback for download errors.
      • @see setPath setResourcePath
      • @note In order for relative texture references to resolve correctly
      • you must call setResourcePath() explicitly prior to load.

Implementation

load(url, onLoad, [onProgress, onError]) {
  var scope = this;

  var path = (this.path == '') ? LoaderUtils.extractUrlBase(url) : this.path;

  var loader = new FileLoader(this.manager);
  loader.setPath(this.path);
  loader.setRequestHeader(this.requestHeader);
  loader.setWithCredentials(this.withCredentials);

  loader.load(url, (text) {
    // try {

    if (onLoad != null) onLoad(scope.parse(text, path));

    // } catch ( e ) {

    // 	if ( onError != null ) {

    // 		onError( e );

    // 	} else {

    // 		print( e );

    // 	}

    // 	scope.manager.itemError( url );

    // }
  }, onProgress, onError);
}