load method

  1. @override
dynamic load(
  1. dynamic url,
  2. Function onLoad, [
  3. Function? onProgress,
  4. Function? onError,
])
override

Implementation

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

  var resourcePath;

  if (this.resourcePath != '') {
    resourcePath = this.resourcePath;
  } else if (path != '') {
    resourcePath = path;
  } else {
    resourcePath = LoaderUtils.extractUrlBase(url);
  }

  // Tells the LoadingManager to track an extra item, which resolves after
  // the model is fully loaded. This means the count of items loaded will
  // be incorrect, but ensures manager.onLoad() does not fire early.
  manager.itemStart(url);

  // onError(e) {
  //   if (onError != null) {
  //     onError(e);
  //   } else {
  //     print(e);
  //   }

  //   scope.manager.itemError(url);
  //   scope.manager.itemEnd(url);
  // }

  var loader = FileLoader(manager);

  loader.setPath(path);
  loader.setResponseType('arraybuffer');
  loader.setRequestHeader(requestHeader);
  loader.setWithCredentials(withCredentials);

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

    scope.parse(data, resourcePath, (gltf) {
      onLoad(gltf);

      scope.manager.itemEnd(url);
    }, onError);

    // } catch ( e ) {

    //   _onError( e );

    // }
  }, onProgress, onError);
}