Clean up some things
This commit is contained in:
@@ -2,6 +2,8 @@ use cgmath::Vector2;
|
||||
use cgmath::Point3;
|
||||
use winit::{dpi::PhysicalPosition, event::*};
|
||||
|
||||
const MOUSE_SLOWDOWN: f32 = 100.0;
|
||||
|
||||
#[derive(Debug)]
|
||||
enum ButtonPress {
|
||||
Up(ElementState),
|
||||
@@ -80,6 +82,7 @@ impl CameraController {
|
||||
/// Vectors are casted from (0, 0, 0) to both the target and the eye
|
||||
pub fn update_camera(&mut self, camera: &mut crate::camera::Camera) {
|
||||
// TODO what about delta time?
|
||||
// TODO this still feels a bit chunky...
|
||||
use cgmath::InnerSpace;
|
||||
// Casted eye -> target
|
||||
let forward = camera.target - camera.eye;
|
||||
@@ -130,9 +133,8 @@ impl CameraController {
|
||||
// mouse movement:
|
||||
// target moves
|
||||
// eye stays in place
|
||||
let decr = 200.0;
|
||||
camera.target.x += (self.mouse_movement.x as f32) / decr;
|
||||
camera.target.y -= (self.mouse_movement.y as f32) / decr;
|
||||
camera.target.x += (self.mouse_movement.x as f32) / MOUSE_SLOWDOWN;
|
||||
camera.target.y -= (self.mouse_movement.y as f32) / MOUSE_SLOWDOWN;
|
||||
self.mouse_movement = Vector2 { x: 0.0, y: 0.0 };
|
||||
|
||||
dbg!(&camera.eye);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use winit::{dpi::PhysicalPosition, event::*, event_loop::{ControlFlow, EventLoop}, window::WindowBuilder};
|
||||
use winit::{event::*, event_loop::{ControlFlow, EventLoop}, window::WindowBuilder};
|
||||
|
||||
mod state;
|
||||
mod vertex;
|
||||
@@ -15,8 +15,8 @@ fn main() {
|
||||
let mut window = WindowBuilder::new()
|
||||
.build(&event_loop)
|
||||
.unwrap();
|
||||
//window.set_cursor_visible(false);
|
||||
//window.set_cursor_grab(true).unwrap();
|
||||
window.set_cursor_visible(false);
|
||||
window.set_cursor_grab(true).unwrap();
|
||||
|
||||
// wait until Future is ready
|
||||
let mut state = pollster::block_on(State::new(&window));
|
||||
|
||||
17
src/state.rs
17
src/state.rs
@@ -324,23 +324,6 @@ impl State {
|
||||
WindowEvent::ScaleFactorChanged {new_inner_size, ..} => {
|
||||
self.resize(**new_inner_size);
|
||||
},
|
||||
// WindowEvent::CursorMoved { position, .. } => {
|
||||
// let x = (position.x as f64) / self.size.width as f64;
|
||||
// let y = (position.y as f64) / self.size.height as f64;
|
||||
// self.clear_color = wgpu::Color { r: x, g: x, b: y, a: 1.0};
|
||||
// true
|
||||
// },
|
||||
// WindowEvent::KeyboardInput {
|
||||
// input: KeyboardInput {
|
||||
// state: ElementState::Pressed,
|
||||
// virtual_keycode: Some(VirtualKeyCode::Space),
|
||||
// ..
|
||||
// },
|
||||
// ..
|
||||
// } => {
|
||||
// self.use_pentagon = !self.use_pentagon;
|
||||
// true
|
||||
// }
|
||||
_ => self.camera_controller.input(event)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user