processPlyBuffer method
Processes a PLY buffer into the binary format expected by the renderer.
This method:
- Parses the PLY header to extract property definitions
- Calculates importance scores for each vertex (size × opacity)
- Sorts vertices by importance for optimal rendering
- Converts vertex data to the packed binary format
Parameters:
inputBuffer
: Raw PLY file data
Returns processed binary data ready for GPU upload. Throws Exception if the PLY file cannot be parsed.
Implementation
Uint8List processPlyBuffer(Uint8List inputBuffer) {
final headerInfo = _parseHeader(inputBuffer);
final vertexCount = headerInfo['vertexCount'] as int;
final offsets = headerInfo['offsets'] as Map<String, int>;
final types = headerInfo['types'] as Map<String, String>;
final rowSize = headerInfo['rowSize'] as int;
final dataStart = headerInfo['dataStart'] as int;
_validateRequiredProperties(offsets);
final inputData = ByteData.view(inputBuffer.buffer, dataStart);
final sortedIndices = _calculateImportanceSort(
inputData,
vertexCount,
rowSize,
offsets,
types,
);
return _convertVertexData(
inputData,
vertexCount,
rowSize,
offsets,
types,
sortedIndices,
);
}