Skip to content

Commit

Permalink
Add first person view and clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
n3vu0r committed Apr 28, 2021
1 parent 5fd08d6 commit 48ab61a
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 79 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kiss3d-trackball"
version = "0.2.0"
version = "0.3.0"
authors = ["Rouven Spreckels <[email protected]>"]
edition = "2018"
description = "Virtual Trackball Camera Mode for Kiss3D"
Expand Down Expand Up @@ -32,7 +32,7 @@ travis-ci = { repository = "qu1x/kiss3d-trackball" }
[dependencies]
kiss3d = "0.31"
nalgebra = "0.26"
trackball = "0.3"
trackball = "0.5"

[features]
cc = ["trackball/cc"]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ This license is designed to provide:

* a simple permissive license,
* that is compatible with the [`GPL-2.0-or-later`], and
* which also has an express patent grant included.
* which also has an express patent grant included, but
* unlike the [`Apache-2.0`] without patent retaliation.

[`BSD-2-Clause-Patent`]: https://spdx.org/licenses/BSD-2-Clause-Patent.html
[`GPL-2.0-or-later`]: https://spdx.org/licenses/GPL-2.0-or-later.html
[`Apache-2.0`]: https://spdx.org/licenses/Apache-2.0.html

## Contribution

Expand Down
6 changes: 6 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Version 0.3.0 (2021-04-28)

* Add first person view.
* Use move semantics whenever otherwise cloning borrowed method arguments.
* Reorder arguments of `Trackball::new()` and `Trackball::new_with_frustum()`.

# Version 0.2.0 (2021-04-13)

* Use `Fixed` quantity wrt field of view.
Expand Down
20 changes: 16 additions & 4 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::marker::PhantomData;
#[derive(Debug, Clone)]
pub struct Input<N: RealField> {
phantom_data: PhantomData<N>,
first_key: Option<Key>,
ortho_key: Option<Key>,
reset_key: Option<Key>,
orbit_button: Option<MouseButton>,
Expand All @@ -18,6 +19,7 @@ impl<N: RealField> Default for Input<N> {
fn default() -> Self {
Self {
phantom_data: PhantomData,
first_key: Some(Key::LShift),
ortho_key: Some(Key::O),
reset_key: Some(Key::Return),
orbit_button: Some(MouseButton::Button1),
Expand All @@ -29,13 +31,23 @@ impl<N: RealField> Default for Input<N> {
}

impl<N: RealField> Input<N> {
/// Key used to enable first person view as long as being pressed.
pub fn first_key(&self) -> Option<Key> {
self.first_key
}
/// Sets key used to enable first person view as long as being pressed.
///
/// Use `None` to disable key.
pub fn rebind_first_key(&mut self, key: Option<Key>) {
self.first_key = key;
}
/// Key used to switch between orthographic and perspective projection.
pub fn ortho_key(&self) -> Option<Key> {
self.ortho_key
}
/// Sets key used to switch between orthographic and perspective projection.
///
/// Use `None` to disable switch.
/// Use `None` to disable key.
pub fn rebind_ortho_key(&mut self, key: Option<Key>) {
self.ortho_key = key;
}
Expand All @@ -45,7 +57,7 @@ impl<N: RealField> Input<N> {
}
/// Sets key used to reset camera.
///
/// Use `None` to disable reset.
/// Use `None` to disable key.
pub fn rebind_reset_key(&mut self, key: Option<Key>) {
self.reset_key = key;
}
Expand All @@ -55,7 +67,7 @@ impl<N: RealField> Input<N> {
}
/// Sets button used to orbit camera.
///
/// Use `None` to disable rotation.
/// Use `None` to disable button.
pub fn rebind_orbit_button(&mut self, button: Option<MouseButton>) {
self.orbit_button = button;
}
Expand All @@ -78,7 +90,7 @@ impl<N: RealField> Input<N> {
}
/// Sets button used to slide camera.
///
/// Use `None` to disable slide.
/// Use `None` to disable button.
pub fn rebind_slide_button(&mut self, button: Option<MouseButton>) {
self.slide_button = button;
}
Expand Down
Loading

0 comments on commit 48ab61a

Please sign in to comment.