'Can't find proper way to flip horizontally custom 2D mesh with Bevy

I've created mesh for part of my game character with MaterialMesh2dBundle:

fn create_2d_mesh(points: Vec<[f32; 3]>, indices: Vec<u32>) -> Mesh {
    let mut mesh = Mesh::new(PrimitiveTopology::TriangleList);

    mesh.set_indices(Some(Indices::U32(indices)));

    let normals = points
        .iter()
        .map(|_v| [0.0, 0.0, 1.0])
        .collect::<Vec<[f32; 3]>>();
    mesh.insert_attribute(Mesh::ATTRIBUTE_NORMAL, normals);

    let uvs = points
        .iter()
        .map(|_v| [0.0, 0.0])
        .collect::<Vec<[f32; 2]>>();
    mesh.insert_attribute(Mesh::ATTRIBUTE_UV_0, uvs);

    let mesh_points = points
        .iter()
        .map(|v| [v[0], v[1], 0f32])
        .collect::<Vec<[f32; 3]>>();
    mesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, mesh_points);

    mesh
}

................................................................................

let robot_base_points = vec![
    [0.0, 0.0, 0.0],
    [1.0, 0.0, 0.0],
    [0.0, 1.0, 0.0],
];

let robot_base_indices = vec![0, 1, 2];

commands
    .spawn_bundle(MaterialMesh2dBundle {
        mesh: meshes
            .add(create_2d_mesh(robot_base_points, robot_base_indices))
            .into(),
        transform: Transform {
            translation: Vec3::new(0.0, 0.0, 1.0),
            ..Default::default()
        },
        material: materials.add(ColorMaterial::from(Color::DARK_GRAY)),
        ..Default::default()
    })

It's rendering on screen and everything is fine, but when I try to flip it via y-axis rotation it disappears.

transform.rotation = Quat::from_rotation_y(std::f32::consts::PI);

Of course it's because of backface culling and other cool stuff related to 3D meshes and materials but I can't find any way to make my 2D mesh double-sided. There's no such options like double_sided or cull_mode for 2D material as they present in StandardMaterial struct.

I've tried to make meshes double sided by duplicating points and inverting normals of duplicated part but it gave me nothing

Please, help.



Solution 1:[1]

Imo, ssh-keyscan connects once for every key type it supports, trying to agree on that key. If that succeeds, it prints the key, if not, it proceeds with another.


What makes the code complicated is that it does all the connections in paralel in a single thread. If you implement it sequentially, it will be way more simpler.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Martin Prikryl