loadBufferView2 method

dynamic loadBufferView2(
  1. dynamic bufferViewIndex
)

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;
}