fn cam_events_from_kb(
        time: &Time,
        keyboard: &Input<KeyCode>,
        cam_inputs: &mut EventWriter<'_, '_, CameraInputEvent>,
        ctx: &CtxRef,
    ) -> (f32, f32) {
        // TODO: make the spin rate modifiable in preferences.
        const SPIN_RATE: f32 = std::f32::consts::TAU / 5.0;
        const ROLL: CameraInputEvent = CameraInputEvent::Roll(SPIN_RATE);

        let real_scale = time.delta_seconds();
        let scale = if keyboard.pressed(KeyCode::LControl) | keyboard.pressed(KeyCode::RControl) {
            real_scale * 3.0
        } else {
            real_scale
        };

        let fb = Self::Translate(Vec3::Z);
        let lr = Self::Translate(Vec3::X);
        let ud = Self::Translate(Vec3::Y);

        if !ctx.wants_keyboard_input() {
            for keycode in keyboard.get_pressed() {
                cam_inputs.send(match keycode {
                    KeyCode::W | KeyCode::Up => -scale * fb,
                    KeyCode::S | KeyCode::Down => scale * fb,
                    KeyCode::D | KeyCode::Right => scale * lr,
                    KeyCode::A | KeyCode::Left => -scale * lr,
                    KeyCode::Space => scale * ud,
                    KeyCode::LShift | KeyCode::RShift => -scale * ud,
                    KeyCode::Q => real_scale * ROLL,
                    KeyCode::E => -real_scale * ROLL,
                    KeyCode::R => Self::Reset,
                    _ => continue,
                })
            }
        }

        (real_scale, scale)
    }
/// Processes camera events coming from the keyboard.
Processes camera events coming from the keyboard.
Processes camera events coming from the keyboard .
fn cam_events_from_kb(
        time: &Time,
        keyboard: &Input<KeyCode>,
        cam_inputs: &mut EventWriter<'_, '_, CameraInputEvent>,
        ctx: &CtxRef,
    ) -> (f32, f32) {
        // TODO: make the spin rate modifiable in preferences.
        const SPIN_RATE: f32 = std::f32::consts::TAU / 5.0;
        const ROLL: CameraInputEvent = CameraInputEvent::Roll(SPIN_RATE);
        let real_scale = time.delta_seconds();
        let scale = if keyboard.pressed(KeyCode::LControl) | keyboard.pressed(KeyCode::RControl) {
            real_scale * 3.0
        } else {
            real_scale
        };
        let fb = Self::Translate(Vec3::Z);
        let lr = Self::Translate(Vec3::X);
        let ud = Self::Translate(Vec3::Y);
        if !ctx.wants_keyboard_input() {
            for keycode in keyboard.get_pressed() {
                cam_inputs.send(match keycode {
                    KeyCode::W | KeyCode::Up => -scale * fb,
                    KeyCode::S | KeyCode::Down => scale * fb,
                    KeyCode::D | KeyCode::Right => scale * lr,
                    KeyCode::A | KeyCode::Left => -scale * lr,
                    KeyCode::Space => scale * ud,
                    KeyCode::LShift | KeyCode::RShift => -scale * ud,
                    KeyCode::Q => real_scale * ROLL,
                    KeyCode::E => -real_scale * ROLL,
                    KeyCode::R => Self::Reset,
                    _ => continue,
                })
            }
        }
        (real_scale, scale)
    }
fn cam_events_from_kb ( time : & Time , keyboard : & Input < KeyCode > , cam_inputs : & mut EventWriter < ' _ , ' _ , CameraInputEvent > , ctx : & CtxRef , ) -> ( f32 , f32 ) { // TODO: make the spin rate modifiable in preferences. const SPIN_RATE : f32 = std :: f32 :: consts :: TAU / 5.0 ; const ROLL : CameraInputEvent = CameraInputEvent :: Roll ( SPIN_RATE ) ; let real_scale = time . delta_seconds ( ) ; let scale = if keyboard . pressed ( KeyCode :: LControl ) | keyboard . pressed ( KeyCode :: RControl ) { real_scale * 3.0 } else { real_scale } ; let fb = Self :: Translate ( Vec3 :: Z ) ; let lr = Self :: Translate ( Vec3 :: X ) ; let ud = Self :: Translate ( Vec3 :: Y ) ; if ! ctx . wants_keyboard_input ( ) { for keycode in keyboard . get_pressed ( ) { cam_inputs . send ( match keycode { KeyCode :: W | KeyCode :: Up => - scale * fb , KeyCode :: S | KeyCode :: Down => scale * fb , KeyCode :: D | KeyCode :: Right => scale * lr , KeyCode :: A | KeyCode :: Left => - scale * lr , KeyCode :: Space => scale * ud , KeyCode :: LShift | KeyCode :: RShift => - scale * ud , KeyCode :: Q => real_scale * ROLL , KeyCode :: E => - real_scale * ROLL , KeyCode :: R => Self :: Reset , _ => continue , } ) } } ( real_scale , scale ) }
Processes camera events coming from the keyboard.
Processes camera events coming from the keyboard .
time
&Time
keyboard
&Input<KeyCode>
cam_inputs
&mut EventWriter<'_, '_, CameraInputEvent>
ctx
&CtxRef
time
&Time
keyboard
&Input<KeyCode>
cam_inputs
&mut EventWriter<'_, '_, CameraInputEvent>
ctx
&CtxRef