Surface constructor
Surface({})
Base surface Resource, it describes a single surface to be rendered.
Implementation
Surface({
required List<Vertex> vertices,
required List<int> indices,
Material? material,
this.jointMap,
/**
* If `true`, the normals will be calculated if they are not provided.
*/
bool calculateNormals = true,
}) : material = material ?? Material.defaultMaterial {
final normalizedVertices = _normalize(
vertices: vertices,
indices: indices,
calculateNormals: calculateNormals,
);
// `TODO`(bdero): This should have an attribute map instead and be fully SoA
// but vertex attributes in Impeller aren't flexible enough yet.
// See also https://github.com/flutter/flutter/issues/116168.
_vertices = Float32List.fromList(
normalizedVertices.fold([], (p, v) => p..addAll(v.storage)),
).buffer;
_vertexCount = normalizedVertices.length;
_indices = Uint16List.fromList(indices).buffer;
_indexCount = indices.length;
_calculateAabb(normalizedVertices);
}