processPlyBuffer method

Uint8List processPlyBuffer(
  1. Uint8List inputBuffer
)

Processes a PLY buffer into the binary format expected by the renderer.

This method:

  1. Parses the PLY header to extract property definitions
  2. Calculates importance scores for each vertex (size × opacity)
  3. Sorts vertices by importance for optimal rendering
  4. 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,
  );
}