load method

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

Implementation

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

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

  var loader = FileLoader(manager);
  loader.setPath(this.path);
  loader.setRequestHeader(requestHeader);
  loader.setWithCredentials(withCredentials);
  loader.load(url, (text) {
    var json;

    try {
      json = convert.jsonDecode(text);
    } catch (error) {
      if (onError != null) onError(error);

      print('THREE:ObjectLoader: Can\'t parse $url $error');

      return;
    }

    var metadata = json.metadata;

    if (metadata == null || metadata.type == null || metadata.type.toLowerCase() == 'geometry') {
      print('three.ObjectLoader: Can\'t load $url');
      return;
    }

    scope.parse(json, null, onLoad);
  }, onProgress, onError);
}