loadBufferView2 method
dynamic
loadBufferView2(
- dynamic bufferViewIndex
Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views @param {number} bufferViewIndex @return {Promise
Implementation
loadBufferView2(bufferViewIndex) async {
var bufferViewDef = this.json["bufferViews"][bufferViewIndex];
var buffer = await this.getDependency('buffer', bufferViewDef["buffer"]);
var byteLength = bufferViewDef["byteLength"] ?? 0;
var byteOffset = bufferViewDef["byteOffset"] ?? 0;
// use sublist(0) clone new list, if not when load texture decode image will fail ? and with no error, return null image
var _buffer;
if (buffer is Uint8List) {
_buffer = Uint8List.view(buffer.buffer, byteOffset, byteLength)
.sublist(0)
.buffer;
} else {
_buffer =
Uint8List.view(buffer, byteOffset, byteLength).sublist(0).buffer;
}
return _buffer;
}