uploadVertexData method

void uploadVertexData(
  1. ByteData vertices,
  2. int vertexCount,
  3. ByteData? indices, {
  4. IndexType indexType = gpu.IndexType.int16,
})

Allocates a gpu.DeviceBuffer and uploads vertices (and optional indices) into it in one step.

The vertices must match this geometry subclass's expected interleaved layout (48 bytes per vertex for UnskinnedGeometry, 80 bytes for SkinnedGeometry). The subclass may split the interleaved bytes into several tightly packed streams (see _vertexStreamBytes); the streams and any indices are packed back-to-back into one buffer, the streams bound via setVertexStreams and the indices via setIndices.

Implementation

void uploadVertexData(
  ByteData vertices,
  int vertexCount,
  ByteData? indices, {
  gpu.IndexType indexType = gpu.IndexType.int16,
}) {
  _cpuVertices = vertices;
  _cpuIndices = indices;

  _uploadStreams(
    _vertexStreamBytes(vertices, vertexCount),
    vertexCount,
    indices,
    indexType,
  );

  if (_localBounds == null && vertexCount > 0 && _autoScanBoundsOnUpload) {
    _scanLocalBoundsFromVertices(vertices, vertexCount);
  }
}