Fixes
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Has been cancelled

This commit is contained in:
Florian RICHER 2025-05-28 13:41:13 +02:00
parent 09bfe6fb48
commit fbb1493b45
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
5 changed files with 68 additions and 76 deletions

View file

@ -61,7 +61,7 @@ impl Scene for MainScene {
Vertex2D::create_buffer(Vec::from_iter(VERTICES), render_context.memory_allocator())
.unwrap();
let mut camera = Camera::new(
let camera = Camera::new(
Mat4::look_at_rh(
Vec3::new(0.3, 0.3, 1.0),
Vec3::new(0.0, 0.0, 0.0),
@ -74,7 +74,6 @@ impl Scene for MainScene {
100.0,
),
);
camera.set_position(Vec3::new(-10.0, 0.0, -10.0));
let mut uploads = AutoCommandBufferBuilder::primary(
render_context.command_buffer_allocator().clone(),
@ -113,43 +112,7 @@ impl Scene for MainScene {
timer: &Timer,
) {
let state = self.state.as_mut().unwrap();
state.speed += input_manager.get_virtual_input_state("mouse_wheel") * 10.0;
let speed = state.speed * timer.delta_time();
state.camera.rotate(Vec3::new(
(input_manager.get_virtual_input_state("mouse_y") * 50.0 * timer.delta_time())
.to_radians(),
(input_manager.get_virtual_input_state("mouse_x") * 50.0 * timer.delta_time())
.to_radians(),
0.0,
));
if state.camera.get_rotation().x > 89.0 {
state
.camera
.set_rotation(Vec3::new(89.0, state.camera.get_rotation().y, 0.0));
}
if state.camera.get_rotation().x < -89.0 {
state
.camera
.set_rotation(Vec3::new(-89.0, state.camera.get_rotation().y, 0.0));
}
let rotation = state.camera.get_rotation();
let mut translation = Vec3::ZERO;
let tx = input_manager.get_virtual_input_state("move_right") * timer.delta_time() * speed;
translation.x += tx * (rotation.y).to_radians().cos();
translation.z += tx * (rotation.y).to_radians().sin();
let ty = input_manager.get_virtual_input_state("move_forward") * timer.delta_time() * speed;
translation.x += ty * (rotation.y + 90.0).to_radians().cos();
translation.z += ty * (rotation.y + 90.0).to_radians().sin();
state.camera.translate(translation);
state.camera.update(input_manager, timer, state.speed, 10.0);
state.camera.set_projection(Mat4::perspective_rh_gl(
std::f32::consts::FRAC_PI_2,