From 2ea35a330f85af0dfb8bc52aa1cf7628f3f11d89 Mon Sep 17 00:00:00 2001 From: Simonas Karuzas Date: Fri, 15 Dec 2023 11:02:35 +0200 Subject: [PATCH] fix: touch sensitivity --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/touch.rs | 14 ++++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 001ef12..77c1e40 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2095,7 +2095,7 @@ dependencies = [ [[package]] name = "graph-view" -version = "0.1.18" +version = "0.1.19" dependencies = [ "bevy", "bevy-inspector-egui", diff --git a/Cargo.toml b/Cargo.toml index 5129ef0..e12244f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "graph-view" -version = "0.1.18" +version = "0.1.19" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/touch.rs b/src/touch.rs index 95a130e..ca589e6 100644 --- a/src/touch.rs +++ b/src/touch.rs @@ -36,8 +36,8 @@ pub struct TouchCameraConfig { impl Default for TouchCameraConfig { fn default() -> Self { Self { - drag_sensitivity: 1., - zoom_sensitivity: 0.005, + drag_sensitivity: 0.002, + zoom_sensitivity: 0.1, touch_time_min: 0.01, opposites_tolerance: 0., } @@ -143,8 +143,14 @@ fn touch_pan_zoom( return; } - camera.target_alpha += touches[0].distance().y.to_radians(); - camera.target_beta += touches[0].distance().x.to_radians(); + let Some(radius) = camera.radius else { + return; + }; + + camera.target_alpha += + (-touches[0].distance().x * config.drag_sensitivity * radius).to_radians(); + camera.target_beta += + (touches[0].distance().y * config.drag_sensitivity * radius).to_radians(); // let distance = Vec3::new(touches[0].distance().x, -touches[0].distance().y, 0.); // let Some(radius) = camera.radius else {