mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-22 11:58:21 -06:00
upd camera
This commit is contained in:
parent
3d6988f459
commit
29166c3b95
|
@ -1,7 +1,7 @@
|
|||
use glam::{Mat4, Vec3};
|
||||
use shipyard::{Component, ViewMut, View, IntoIter, Workload, IntoWorkload};
|
||||
use std::f32::consts::PI;
|
||||
use crate::transform::Transform;
|
||||
use crate::{transform::Transform, events::WindowResizedEvent};
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct Camera {
|
||||
|
@ -46,14 +46,17 @@ fn update_view_matrix(
|
|||
}
|
||||
|
||||
fn update_perspective_matrix(
|
||||
mut vm_camera: ViewMut<Camera>
|
||||
mut vm_camera: ViewMut<Camera>,
|
||||
resize: View<WindowResizedEvent>,
|
||||
) {
|
||||
//todo compute this on win resize!
|
||||
const ASPECT_RATIO: f32 = 16. / 9.;
|
||||
//TODO update on launch
|
||||
let Some(&size) = resize.iter().next() else {
|
||||
return
|
||||
};
|
||||
for camera in (&mut vm_camera).iter() {
|
||||
camera.perspective_matrix = Mat4::perspective_rh_gl(
|
||||
camera.fov,
|
||||
ASPECT_RATIO,
|
||||
size.0.x as f32 / size.0.y as f32,
|
||||
camera.z_near,
|
||||
camera.z_far,
|
||||
)
|
||||
|
|
|
@ -15,7 +15,7 @@ pub struct InputDeviceEvent{
|
|||
}
|
||||
|
||||
#[derive(Component, Clone, Copy, Debug, Default)]
|
||||
pub struct WindowResizedEvent(UVec2);
|
||||
pub struct WindowResizedEvent(pub UVec2);
|
||||
|
||||
pub fn process_glutin_events(world: &mut World, event: &Event<'_, ()>) {
|
||||
#[allow(clippy::collapsible_match, clippy::single_match)]
|
||||
|
|
Loading…
Reference in a new issue