Skip to content

Gizmo Grid incorrect looking lines #21479

@dpogorzelski

Description

@dpogorzelski

Bevy version and features

0.17.2

[Optional] Relevant system information

`SystemInfo { os: "Windows 11 Pro", kernel: "22631", cpu: "AMD Ryzen 7 3700X 8-Core Processor", core_count: "8", memory: "63.9 GiB" }`

What you did

consider this basic example to draw a gizmo grid:

use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, (setup, spawn_grid))
        .run();
}

fn setup(
    mut commands: Commands,
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<StandardMaterial>>,
) {
    commands.spawn((
        Camera3d::default(),
        Transform::from_xyz(-2.5, 10.0, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
    ));

    commands.spawn((
        Mesh3d(meshes.add(Plane3d::default().mesh().size(10000.0, 10000.0))),
        MeshMaterial3d(materials.add(Color::srgb_u8(60, 65, 92))),
    ));
}

fn spawn_grid(mut commands: Commands, mut gizmo_assets: ResMut<Assets<GizmoAsset>>) {
    let color = Color::Srgba(Srgba::hex("#747a942d").unwrap());
    let mut gizmo = GizmoAsset::default();

    gizmo
        .grid_3d(
            Isometry3d::IDENTITY,
            UVec3::new(500, 0, 500),
            Vec3::splat(2.0),
            color,
        )
        .outer_edges();

    commands.spawn(Gizmo {
        handle: gizmo_assets.add(gizmo),
        ..default()
    });
}

What went wrong

The grid doesn't look correct (thick lines that change based on camera angle/rot):

Image

Same code but bevy 0.16.1:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-GizmosVisual editor and debug gizmosC-BugAn unexpected or incorrect behaviorP-RegressionFunctionality that used to work but no longer does. Add a test for this!

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions