pub struct Orbit { /* private fields */ }Expand description
Orbit induced by displacement on screen.
Implements Default and can be created with Orbit::default().
Both its methods must be invoked on matching events fired by your 3D graphics library of choice.
Implementations§
Source§impl Orbit
impl Orbit
Sourcepub fn compute(&mut self, pos: Vec2, max: Vec2) -> Option<Quat>
pub fn compute(&mut self, pos: Vec2, max: Vec2) -> Option<Quat>
Computes rotation between previous and current cursor/finger position.
Trackball point of previous position is cached and has to be discarded on button/finger
release via Self::discard(). Current position pos is clamped between origin and
maximum position max as screen’s width and height.
Maps positions via the exponential map onto a target-centered trackball with radius of maximum of the screen’s width and height divided by π and rotates along the shortest arc between their trackball points so that the trackball’s point under the cursor/finger stays under it. Positions in screen corners beyond the trackball’s border are mapped beyond its equator.
Screen space with origin in top left corner:
- x-axis from left to right,
- y-axis from top to bottom.
Camera space with origin at its target, the trackball’s center:
- x-axis from left to right,
- y-axis from bottom to top,
- z-axis from far to near.
Returns None:
- on first invocation and after
Self::discard()as there is no previous position yet, - for displacements resulting in the same trackball point, e.g., when a position event fires twice.