uploadVertexData method
void
uploadVertexData(})
inherited
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 (72 bytes per vertex for UnskinnedGeometry, 104 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
@override
void uploadVertexData(
ByteData vertices,
int vertexCount,
ByteData? indices, {
gpu.IndexType indexType = gpu.IndexType.int16,
}) {
if (!_uploadingBlend) {
if (vertexCount != _morphData.vertexCount) {
throw ArgumentError(
'Morphed geometry uploaded $vertexCount vertices, but its morph '
'targets cover ${_morphData.vertexCount}',
);
}
_baseVertexFloats = Float32List.fromList(
Float32List.sublistView(vertices),
);
_baseVertexCount = vertexCount;
_baseIndices = indices;
_baseIndexType = indexType;
_appliedWeights = null;
}
super.uploadVertexData(
vertices,
vertexCount,
indices,
indexType: indexType,
);
if (!_uploadingBlend) _expandBoundsForMorphRange();
}