pub struct Scope { /* private fields */ }Expand description
Scope defining enclosing viewing frustum.
Implements Default and can be created with Scope::default().
Implementations§
Source§impl Scope
impl Scope
Sourcepub const fn fov(&self) -> Fixed
pub const fn fov(&self) -> Fixed
Fixed quantity wrt field of view, see Self::set_fov().
Sourcepub fn set_fov(&mut self, fov: impl Into<Fixed>)
pub fn set_fov(&mut self, fov: impl Into<Fixed>)
Sets fixed quantity wrt field of view.
Default is fixed vertical field of view of π/4.
use trackball::{Scope, glam::Vec2};
// Current screen size.
let max = Vec2::new(800.0, 600.0);
// Default scope with fixed vertical field of view of π/4:
//
// * Increasing width increases horizontal field of view (more can be seen).
// * Increasing height scales scope zooming in as vertical field of view is fixed.
let mut scope = Scope::default();
// Unfix vertical field of view by fixing current unit per pixel on focus plane at distance
// from eye of one, that is effectively `upp` divided by `zat` to make it scale-independant:
//
// * Increasing width increases horizontal field of view (more can be seen).
// * Increasing height increases vertical field of view (more can be seen).
scope.set_fov(scope.fov().to_upp(max));Sourcepub fn clip_planes(&self, zat: f32) -> (f32, f32)
pub fn clip_planes(&self, zat: f32) -> (f32, f32)
Clip plane distances from eye regardless of Self::inspect() wrt to distance between eye
and target.
Default is (1e-1, 1e+3) measured from eye.
Sourcepub const fn set_clip_planes(&mut self, znear: f32, zfar: f32)
pub const fn set_clip_planes(&mut self, znear: f32, zfar: f32)
Sets clip plane distances from target or eye whether Self::inspect().
Default is (1e-1, 1e+3) measured from eye.
Sourcepub const fn inspect(&self) -> bool
pub const fn inspect(&self) -> bool
Object inspection mode.
Scales clip plane distances by measuring from target instead of eye. Default is false.
Sourcepub const fn set_inspect(&mut self, oim: bool)
pub const fn set_inspect(&mut self, oim: bool)
Sets object inspection mode.
Scales clip plane distances by measuring from target instead of eye. Default is false.
Sourcepub const fn ortho(&self) -> bool
pub const fn ortho(&self) -> bool
Orthographic projection mode.
Computes scale-identical orthographic instead of perspective projection. Default is false.