load method
Implementation
load(url, Function onLoad, [Function? onProgress, Function? onError]) {
var scope = this;
var resourcePath;
if (this.resourcePath != '') {
resourcePath = this.resourcePath;
} else if (this.path != '') {
resourcePath = this.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.
this.manager.itemStart(url);
Function _onError = (e) {
if (onError != null) {
onError(e);
} else {
print(e);
}
scope.manager.itemError(url);
scope.manager.itemEnd(url);
};
var loader = FileLoader(this.manager);
loader.setPath(this.path);
loader.setResponseType('arraybuffer');
loader.setRequestHeader(this.requestHeader);
loader.setWithCredentials(this.withCredentials);
loader.load(url, (data) {
// try {
scope.parse(data, resourcePath, (gltf) {
onLoad(gltf);
scope.manager.itemEnd(url);
}, _onError);
// } catch ( e ) {
// _onError( e );
// }
}, onProgress, _onError);
}