setSplatData method
Supplies raw splat data (32 bytes per splat) and rebuilds the GPU texture. Returns a future that completes when the initial sort finishes. Throws ArgumentError if the buffer length is not a multiple of 32.
Implementation
Future<void> setSplatData(Uint8List data) async {
if (data.length % GsConst.bytesPerSplat != 0) {
throw ArgumentError.value(
data.length,
'data.length',
'Must be a multiple of 32',
);
}
_splatBuffer = data;
_splatSource.upload(_gl, data);
_splatCount = _splatSource.splatCount;
// Update the draw pass instance count
_splatPass.onSourceChanged();
// Initial unsorted order (sequential), then request an immediate sort.
_orderTexSvc.uploadFull(
_gl,
List<int>.generate(_splatCount, (i) => i),
caps: _caps,
);
if (_camera != null) {
final vp = _projectionMatrix.multiplied(_viewMatrix);
_depthSorter.runSort(vp, data, _splatCount);
// Wait for the first sort to complete
await _depthSorter.firstSortComplete;
}
}