fn find_mouse_position(
    ev: &CursorMoved,
    wnds: &Res<Windows>,
    camera_transform: &Transform,
) -> Vec4 {
    // get the size of the window that the event is for
    let wnd = wnds.get(ev.id).unwrap();
    let size = Vec2::new(wnd.width() as f32, wnd.height() as f32);

    // the default orthographic projection is in pixels from the center;
    // just undo the translation
    let p = ev.position - size / 2.0;

    // apply the camera transform
    camera_transform.compute_matrix() * p.extend(0.0).extend(1.0)
}
// see [Convert screen coordinates to world coordinates](https://github.com/jamadazi/bevy-cookbook/blob/master/bevy-cookbook.md#convert-screen-coordinates-to-world-coordinates)
see [Convert screen coordinates to world coordinates]
see [ Convert screen coordinates to world coordinates ]
fn find_mouse_position(
    ev: &CursorMoved,
    wnds: &Res<Windows>,
    camera_transform: &Transform,
) -> Vec4 {
    // get the size of the window that the event is for
    let wnd = wnds.get(ev.id).unwrap();
    let size = Vec2::new(wnd.width() as f32, wnd.height() as f32);
    // the default orthographic projection is in pixels from the center;
    // just undo the translation
    let p = ev.position - size / 2.0;
    // apply the camera transform
    camera_transform.compute_matrix() * p.extend(0.0).extend(1.0)
}
fn find_mouse_position ( ev : & CursorMoved , wnds : & Res < Windows > , camera_transform : & Transform , ) -> Vec4 { // get the size of the window that the event is for let wnd = wnds . get ( ev . id ) . unwrap ( ) ; let size = Vec2 :: new ( wnd . width ( ) as f32 , wnd . height ( ) as f32 ) ; // the default orthographic projection is in pixels from the center; // just undo the translation let p = ev . position - size / 2.0 ; // apply the camera transform camera_transform . compute_matrix ( ) * p . extend ( 0.0 ) . extend ( 1.0 ) }
see [Convert screen coordinates to world coordinates](https://github.com/jamadazi/bevy-cookbook/blob/master/bevy-cookbook.md#convert-screen-coordinates-to-world-coordinates)
see [ Convert screen coordinates to world coordinates ] ( https : // github . com / jamadazi / bevy - cookbook / blob / master / bevy - cookbook . md#convert - screen - coordinates - to - world - coordinates )
ev
&CursorMoved
wnds
&Res<Windows>
camera_transform
&Transform
ev
&CursorMoved
wnds
&Res<Windows>
camera_transform
&Transform