Skip to content

Commit

Permalink
Add pinch handlers on orbit cameras
Browse files Browse the repository at this point in the history
  • Loading branch information
thatcomputerguy0101 committed Sep 14, 2024
1 parent e4261a9 commit fcd01e2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/renderer/control/free_orbit_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ impl FreeOrbitControl {
speed: 0.1,
target,
},
pinch: CameraAction::Zoom {
min: min_distance,
max: max_distance,
speed: 0.1,
target,
},
..Default::default()
},
}
Expand All @@ -41,6 +47,10 @@ impl FreeOrbitControl {
let x = target.distance(*camera.position());
*speed = 0.01 * x + 0.001;
}
if let CameraAction::Zoom { target, speed, ..} = &mut self.control.pinch {
let x = target.distance(*camera.position());
*speed = 0.01 * x + 0.001;
}
self.control.handle_events(camera, events)
}
}
10 changes: 10 additions & 0 deletions src/renderer/control/orbit_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ impl OrbitControl {
speed: 0.1,
target,
},
pinch: CameraAction::Zoom {
min: min_distance,
max: max_distance,
speed: 0.1,
target,
},
..Default::default()
},
}
Expand All @@ -39,6 +45,10 @@ impl OrbitControl {
let x = target.distance(*camera.position());
*speed = 0.01 * x + 0.001;
}
if let CameraAction::Zoom { target, speed, ..} = &mut self.control.pinch {
let x = target.distance(*camera.position());
*speed = 0.01 * x + 0.001;
}
self.control.handle_events(camera, events)
}
}

0 comments on commit fcd01e2

Please sign in to comment.