mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-25 16:28:42 -06:00
wip camera
This commit is contained in:
parent
e68e0b39e3
commit
3d6988f459
|
@ -1,6 +1,6 @@
|
||||||
use glam::{Mat4, EulerRot, Quat};
|
use glam::{Vec3, Mat4, EulerRot, Quat};
|
||||||
use shipyard::{Component, View, ViewMut, IntoIter, UniqueView};
|
use shipyard::{Component, View, ViewMut, IntoIter, UniqueView};
|
||||||
use crate::{transform::Transform, input::Inputs};
|
use crate::{transform::Transform, input::Inputs, settings::GameSettings};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct FlyController;
|
pub struct FlyController;
|
||||||
|
@ -8,11 +8,13 @@ pub struct FlyController;
|
||||||
pub fn update_controllers(
|
pub fn update_controllers(
|
||||||
controllers: View<FlyController>,
|
controllers: View<FlyController>,
|
||||||
mut transforms: ViewMut<Transform>,
|
mut transforms: ViewMut<Transform>,
|
||||||
inputs: UniqueView<Inputs>
|
inputs: UniqueView<Inputs>,
|
||||||
|
settings: UniqueView<GameSettings>,
|
||||||
) {
|
) {
|
||||||
for (_, mut transform) in (&controllers, &mut transforms).iter() {
|
for (_, mut transform) in (&controllers, &mut transforms).iter() {
|
||||||
let (scale, mut rotation, translation) = transform.0.to_scale_rotation_translation();
|
let (scale, mut rotation, translation) = transform.0.to_scale_rotation_translation();
|
||||||
rotation *= Quat::from_euler(EulerRot::XYZ, 0., 0.001, 0.);
|
let look = inputs.look * settings.mouse_sensitivity * -1.;
|
||||||
|
rotation *= Quat::from_euler(EulerRot::YXZ, look.x, look.y, 0.);
|
||||||
transform.0 = Mat4::from_scale_rotation_translation(scale, rotation, translation);
|
transform.0 = Mat4::from_scale_rotation_translation(scale, rotation, translation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub fn process_events(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DeviceEvent::Button { button, state } => {
|
DeviceEvent::Button { button, state } => {
|
||||||
println!("Button {button} {state:?}");
|
//log::debug!("Button {button} {state:?}");
|
||||||
},
|
},
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,13 @@ use shipyard::Unique;
|
||||||
pub struct GameSettings {
|
pub struct GameSettings {
|
||||||
//there's a 1 chunk border of loaded but invisible around this
|
//there's a 1 chunk border of loaded but invisible around this
|
||||||
pub render_distance: u8,
|
pub render_distance: u8,
|
||||||
|
pub mouse_sensitivity: f32,
|
||||||
}
|
}
|
||||||
impl Default for GameSettings {
|
impl Default for GameSettings {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
render_distance: 2
|
render_distance: 2,
|
||||||
|
mouse_sensitivity: 0.01,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue