loadBuffer method
Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views @param {number} bufferIndex @return {Promise
Implementation
loadBuffer(int bufferIndex) async {
Map<String, dynamic> bufferDef = json["buffers"][bufferIndex];
final loader = fileLoader;
if (bufferDef["type"] != null && bufferDef["type"] != 'arraybuffer') {
throw ('GLTFLoader: ${bufferDef["type"]} buffer type is not supported.');
}
// If present, GLB container is required to be the first buffer.
if (bufferDef["uri"] == null && bufferIndex == 0) {
return extensions[gltfExtensions["KHR_BINARY_GLTF"]].body;
}
final options = this.options;
if(bufferDef["uri"] != null && options["path"] != null){
final url = LoaderUtils.resolveURL(bufferDef["uri"], options["path"]);
final res = await loader.unknown(url);
return res?.data;
}
return null;
}