decodeSplatPage function

SplatCloud decodeSplatPage(
  1. Uint8List bytes,
  2. int count
)

One node's page, count splats, as a cloud.

Implementation

SplatCloud decodeSplatPage(Uint8List bytes, int count) {
  if (bytes.length < count * kSplatPageBytesPerSplat) {
    throw SplatOctreeException(
      'a page of $count splats is ${count * kSplatPageBytesPerSplat} bytes; '
      'got ${bytes.length}',
    );
  }
  final data = ByteData.sublistView(bytes);
  var at = 0;
  Float32List read(int length) {
    final out = Float32List(length);
    for (var i = 0; i < length; i++, at += 4) {
      out[i] = data.getFloat32(at, Endian.little);
    }
    return out;
  }

  return SplatCloud(
    centres: read(count * 3),
    colours: read(count * 4),
    scales: read(count * 3),
    rotations: read(count * 4),
  );
}