MeshData constructor
MeshData({
- required VertexLayout layout,
- required Float32List vertices,
- required Uint32List indices,
- List<
MorphTarget> morphTargets = const <MorphTarget>[],
Implementation
MeshData({
required this.layout,
required this.vertices,
required this.indices,
List<MorphTarget> morphTargets = const <MorphTarget>[],
}) : morphTargets = List<MorphTarget>.unmodifiable(morphTargets) {
final stride = layout.floatsPerVertex;
if (vertices.length % stride != 0) {
throw ArgumentError(
'vertices length (${vertices.length}) is not a multiple of the vertex '
'size ($stride floats); layout and data disagree.',
);
}
if (indices.length % 3 != 0) {
throw ArgumentError(
'indices length (${indices.length}) is not a multiple of 3, so these '
'are not triangles.',
);
}
for (final target in this.morphTargets) {
if (target.vertexCount != vertexCount) {
throw ArgumentError(
'a morph target covers ${target.vertexCount} vertices and the mesh '
'has $vertexCount. A target that does not cover the mesh would '
'blend part of it and leave the rest where it was, which draws as a '
'model torn in half.',
);
}
}
}