bevy/crates
Sélène Amanita 6c86545736
Fix Plane UVs / texture flip (#8878)
# Objective

Fix https://github.com/bevyengine/bevy/issues/1018 (Textures on the
`Plane` shape appear flipped).

This bug have been around for a very long time apparently, I tested it
was still there (see test code bellow) and sure enough, this image:


![test](https://github.com/bevyengine/bevy/assets/134181069/4cda7cf8-57d9-4677-91f5-02240d1e79b1)

... is flipped vertically when used as a texture on a plane (in main,
0.10.1 and 0.9):

![image](https://github.com/bevyengine/bevy/assets/134181069/0db4f52a-51af-4041-9c45-7bfe1f08b0cc)

I'm pretty confused because this bug is so easy to fix, it has been
around for so long, it is easy to encounter, and PRs touching this code
still didn't fix it: https://github.com/bevyengine/bevy/pull/7546 To the
point where I'm wondering if it's actually intended. If it is, please
explain why and this PR can be changed to "mention that in the doc".

## Solution

Fix the UV mapping on the Plane shape

Here is how it looks after the PR

![image](https://github.com/bevyengine/bevy/assets/134181069/e07ce641-3de8-4da3-a4f3-95a6054c86d7)

## Test code

```rust
use bevy::{
    prelude::*,
};

fn main () {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_startup_system(setup)
        .run();
}

fn setup(
    mut commands: Commands,
    assets: ResMut<AssetServer>,
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<StandardMaterial>>,
) {
    commands.spawn(Camera3dBundle {
        transform: Transform::from_xyz(0., 3., 0.).looking_at(Vec3::ZERO, Vec3::NEG_Z),
        ..default()
    });

    let mesh = meshes.add(Mesh::from(shape::Plane::default()));
    let texture_image = assets.load("test.png");
    let material = materials.add(StandardMaterial { 
        base_color_texture: Some(texture_image),
        ..default()
    });
    commands.spawn(PbrBundle {
        mesh,
        material,
        ..default()
    });
}
```

## Changelog

Fix textures on `Plane` shapes being flipped vertically.

## Migration Guide

Flip the textures you use on `Plane` shapes.
2023-06-18 19:35:46 +00:00
..
bevy_a11y Require #[derive(Event)] on all Events (#7086) 2023-06-06 14:44:32 +00:00
bevy_animation Fixed several missing links in docs. (#8117) 2023-04-23 17:28:36 +00:00
bevy_app Fix documentation of SubApp extract (#8747) 2023-06-12 19:30:04 +00:00
bevy_asset Update notify requirement from 5.0.0 to 6.0.0 (#8757) 2023-06-06 21:05:21 +00:00
bevy_audio reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
bevy_core Add Reflect and FromReflect for AssetPath (#8531) 2023-05-08 19:19:19 +00:00
bevy_core_pipeline Make setup of Opaque3dPrepass and AlphaMask3dPrepass phase items consistent with others (#8408) 2023-06-12 19:15:28 +00:00
bevy_derive bevy_derive: Add #[deref] attribute (#8552) 2023-05-16 18:29:09 +00:00
bevy_diagnostic Initialize DiagnosticStore on register_diagnostic if it does not exist (#8819) 2023-06-12 19:40:09 +00:00
bevy_dylib Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_dynamic_plugin Remove stray boilerplate line in bevy_dynamic_plugin/Cargo.toml (#8830) 2023-06-12 19:10:48 +00:00
bevy_ecs doc: update a reference from add_system to add_systems (#8881) 2023-06-18 17:17:02 +00:00
bevy_ecs_compile_fail_tests Resolve clippy issues for rust 1.70.0 (#8738) 2023-06-01 21:05:05 +00:00
bevy_encase_derive update syn, encase, glam and hexasphere (#8573) 2023-05-16 01:24:17 +00:00
bevy_gilrs Add gamepad rumble support to bevy_input (#8398) 2023-04-24 15:28:53 +00:00
bevy_gizmos Instanced line rendering for gizmos based on bevy_polyline (#8427) 2023-06-13 06:49:47 +00:00
bevy_gltf reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
bevy_hierarchy Rename Command's "write" method to "apply" (#8814) 2023-06-12 17:53:47 +00:00
bevy_input Add window entity to mouse and keyboard events (#8852) 2023-06-16 13:54:06 +00:00
bevy_internal Instanced line rendering for gizmos based on bevy_polyline (#8427) 2023-06-13 06:49:47 +00:00
bevy_log Update android_log-sys requirement from 0.2.0 to 0.3.0 (#7925) 2023-06-01 07:55:33 +00:00
bevy_macro_utils update syn, encase, glam and hexasphere (#8573) 2023-05-16 01:24:17 +00:00
bevy_macros_compile_fail_tests bevy_derive: Add #[deref] attribute (#8552) 2023-05-16 18:29:09 +00:00
bevy_math Add integer equivalents for Rect (#7984) 2023-06-12 19:10:48 +00:00
bevy_mikktspace update syn, encase, glam and hexasphere (#8573) 2023-05-16 01:24:17 +00:00
bevy_pbr Rename Plane struct to HalfSpace (#8744) 2023-06-12 19:27:41 +00:00
bevy_ptr Fixed several missing links in docs. (#8117) 2023-04-23 17:28:36 +00:00
bevy_reflect bevy_reflect: implement Reflect for SmolStr (#8771) 2023-06-08 20:33:21 +00:00
bevy_reflect_compile_fail_tests reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
bevy_render Fix Plane UVs / texture flip (#8878) 2023-06-18 19:35:46 +00:00
bevy_scene Rename Command's "write" method to "apply" (#8814) 2023-06-12 17:53:47 +00:00
bevy_sprite reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
bevy_tasks remove some use of once_cell that can be replace with new std (#8739) 2023-06-01 21:55:18 +00:00
bevy_text reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
bevy_time Hide naga info logs & Derive PartialEq on Timer and Stopwatch (#8664) 2023-05-24 15:16:15 +00:00
bevy_transform Rename Command's "write" method to "apply" (#8814) 2023-06-12 17:53:47 +00:00
bevy_ui Ui Node Borders (#7795) 2023-06-14 22:43:38 +00:00
bevy_utils Fix all_tuples + added docs. (#8743) 2023-06-02 16:05:27 +00:00
bevy_window Register a few missed reflect components (#8807) 2023-06-10 23:19:39 +00:00
bevy_winit Add window entity to mouse and keyboard events (#8852) 2023-06-16 13:54:06 +00:00