loadImageSource method
dynamic
loadImageSource(
- dynamic sourceIndex,
- dynamic loader
Implementation
loadImageSource(sourceIndex, loader) async {
var parser = this;
var json = this.json;
var options = this.options;
var texture;
if (sourceCache[sourceIndex] != null) {
texture = sourceCache[sourceIndex];
return texture.clone();
}
Map sourceDef = json["images"][sourceIndex];
// var URL = self.URL || self.webkitURL;
var sourceURI = sourceDef["uri"] ?? '';
// var isObjectURL = false;
print("loader: $loader ");
if (sourceDef["bufferView"] != null) {
// Load binary image data from bufferView, if provided.
var bufferView = await parser.getDependency('bufferView', sourceDef["bufferView"]);
// isObjectURL = true;
var blob = Blob(bufferView.asUint8List(), {"type": sourceDef["mimeType"]});
// sourceURI = URL.createObjectURL( blob );
texture = await loader.loadAsync(blob, null);
} else if (sourceDef["uri"] != null) {
texture = await loader.loadAsync(LoaderUtils.resolveURL(sourceURI, options["path"]), null);
} else if (sourceDef["uri"] == null) {
throw ('THREE.GLTFLoader: Image $sourceIndex is missing URI and bufferView');
}
sourceCache[sourceIndex] = texture;
return texture;
}