MeshGeometry.resetAttribs constructor
MeshGeometry.resetAttribs(
- MeshGeometry inputMesh,
- List<
VertexAttrib> attributes
Implementation
factory MeshGeometry.resetAttribs(MeshGeometry inputMesh, List<VertexAttrib> attributes) {
final mesh = MeshGeometry(inputMesh.length, attributes)..indices = inputMesh.indices;
// Copy over the attributes that were specified
for (final VertexAttrib attrib in mesh.attribs) {
final VertexAttrib? inputAttrib = inputMesh.getAttrib(attrib.name);
if (inputAttrib != null) {
if (inputAttrib.size != attrib.size || inputAttrib.type != attrib.type) {
throw Exception('Attributes size or type is mismatched: ${attrib.name}');
}
final VectorList<Vector> inputView = inputAttrib.getView(inputMesh.buffer);
// Copy [inputView] to a view from attrib
attrib.getView(mesh.buffer).copy(inputView);
}
}
return mesh;
}