mipmaps method
Implementation
List mipmaps(bool loadMipmaps ) {
const mipmaps = [];
// initialize width & height for level 1
int dataOffset = HEADER_LEN + bytesOfKeyValueData;
int width = pixelWidth;
int height = pixelHeight;
final mipmapCount = loadMipmaps ? numberOfMipmapLevels : 1;
for ( int level = 0; level < mipmapCount; level ++ ) {
final imageSize = arrayBuffer.asInt32List(dataOffset, 1)[0];// Int32Array(arrayBuffer, )[ 0 ]; // size per face, since not supporting array cubemaps
dataOffset += 4; // size of the image + 4 for the imageSize field
for ( int face = 0; face < numberOfFaces; face ++ ) {
final byteArray = arrayBuffer.asUint8List().sublist(dataOffset, imageSize);//Uint8Array(arrayBuffer, dataOffset, imageSize );
mipmaps.add( { 'data': byteArray, 'width': width, 'height': height } );
dataOffset += imageSize;
dataOffset += 3 - ( ( imageSize + 3 ) % 4 ); // add padding for odd sized image
}
width = math.max( 1.0, width * 0.5 ).toInt();
height = math.max( 1.0, height * 0.5 ).toInt();
}
return mipmaps;
}