Skip to content

Mesh picking offset when the camera's viewport physical_position is non-zero #18856

Closed
@Henauxg

Description

@Henauxg

Bevy version

0.16 (commit 199c978)

What you did

Raised by Krzysiu on Discord

Modify the simple_picking example to add a Viewport with an offset:

  • Add the following import use bevy_render::camera::Viewport;
  • Add the window_query: Query<&Window> parameter to the setup_scene system
  • Replace
    commands.spawn((
        Camera3d::default(),
        Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
    ));

with

    let window = window_query.single().unwrap();
    commands.spawn((
        Camera {
            viewport: Some(Viewport {
                physical_position: UVec2::new(250, 0),
                physical_size: window.physical_size(),
                ..default()
            }),
            ..default()
        },
        Camera3d::default(),
        Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
    ));

What went wrong

  • Picking on the text works as expected to spawn cubes
  • Picking the cubes to rotate them is broken. The user needs to pick 250 px to the right of the cubes.

Additional information

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-PickingPointing at and selecting objects of all sortsC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions