added keyboard binding to simulate viewer movement

This commit is contained in:
Hartmut Seichter 2022-12-19 10:09:15 +01:00
parent fda3502870
commit 736e1c46a3
2 changed files with 9 additions and 5 deletions

View file

@ -55,8 +55,8 @@ fn main() {
.add_startup_system(setup_threaded_tracker)
.add_plugin(CameraProjectionPlugin::<OffAxisProjection>::default())
.add_system(simulate_viewer_with_circle)
// .add_system(simulate_viewer_with_keyboard)
// .add_system(simulate_viewer_with_circle)
.add_system(simulate_viewer_with_keyboard)
.add_system(apply_viewer_to_projections)
.add_system(toggle_fullscreeen)
.run();

View file

@ -81,14 +81,18 @@ pub fn simulate_viewer_with_keyboard(
input: Res<Input<KeyCode>>,
time: Res<Time>,
) {
let offset = Vec3::new(0.0,0.0,8f32);
for mut viewer in query.iter_mut() {
if input.pressed(KeyCode::W) {
viewer.position += Vec3::Z * time.delta_seconds();
} else if (input.pressed(KeyCode::S)) {
viewer.position -= Vec3::Z * time.delta_seconds();
} else if input.pressed(KeyCode::A) {
viewer.position -= Vec3::X * time.delta_seconds();
} else if input.pressed(KeyCode::D) {
viewer.position += Vec3::X * time.delta_seconds();
}
}
}