filter method

  1. @override
MeshGeometry filter(
  1. MeshGeometry mesh
)
override

Returns a copy of the mesh with any filter transforms applied.

Implementation

@override
MeshGeometry filter(MeshGeometry mesh) {
  MeshGeometry output;
  if (mesh.getAttrib('COLOR') == null) {
    final attributes = <VertexAttrib>[
      ...mesh.attribs,
      VertexAttrib('COLOR', 4, 'float'),
    ];
    output = MeshGeometry.resetAttribs(mesh, attributes);
  } else {
    output = MeshGeometry.copy(mesh);
  }

  final colors = output.getViewForAttrib('COLOR');
  if (colors is Vector4List) {
    for (var i = 0; i < colors.length; ++i) {
      colors[i] = color;
    }
    return output;
  } else {
    throw UnimplementedError();
  }
}