pub struct Camera {
pub position: Point3<f32>,
pub target: Point3<f32>,
pub up: Vector3<f32>,
pub fov: f32,
pub fovy_degrees: f32,
pub aspect_ratio: f32,
pub near: f32,
pub far: f32,
pub radius: f32,
pub theta: f32,
pub phi: f32,
/* private fields */
}Expand description
A 3D camera for viewing point clouds and meshes
Fields§
§position: Point3<f32>§target: Point3<f32>§up: Vector3<f32>§fov: f32§fovy_degrees: f32§aspect_ratio: f32§near: f32§far: f32§radius: f32§theta: f32§phi: f32Implementations§
Source§impl Camera
impl Camera
Sourcepub fn new(
position: Point3<f32>,
target: Point3<f32>,
up: Vector3<f32>,
fovy_degrees: f32,
aspect_ratio: f32,
near: f32,
far: f32,
) -> Self
pub fn new( position: Point3<f32>, target: Point3<f32>, up: Vector3<f32>, fovy_degrees: f32, aspect_ratio: f32, near: f32, far: f32, ) -> Self
Create a new camera
Sourcepub fn view_matrix(&self) -> Matrix4<f32>
pub fn view_matrix(&self) -> Matrix4<f32>
Get the view matrix
Sourcepub fn projection_matrix(&self) -> Matrix4<f32>
pub fn projection_matrix(&self) -> Matrix4<f32>
Get the projection matrix
Sourcepub fn move_forward(&mut self, distance: f32)
pub fn move_forward(&mut self, distance: f32)
Move the camera forward/backward
Sourcepub fn orbit(&mut self, delta_theta: f32, delta_phi: f32)
pub fn orbit(&mut self, delta_theta: f32, delta_phi: f32)
Rotate the camera around the target (orbit control)
Sourcepub fn pan(&mut self, delta_x: f32, delta_y: f32)
pub fn pan(&mut self, delta_x: f32, delta_y: f32)
Pan the camera (translate both position and target)
Sourcepub fn reset_to_target(&mut self, target: Point3<f32>, radius: f32)
pub fn reset_to_target(&mut self, target: Point3<f32>, radius: f32)
Reset camera to default position looking at target
Sourcepub fn set_aspect_ratio(&mut self, aspect_ratio: f32)
pub fn set_aspect_ratio(&mut self, aspect_ratio: f32)
Set aspect ratio
Sourcepub fn distance_to_target(&self) -> f32
pub fn distance_to_target(&self) -> f32
Get camera distance from target
Sourcepub fn set_fov_degrees(&mut self, fovy_degrees: f32)
pub fn set_fov_degrees(&mut self, fovy_degrees: f32)
Set field of view in degrees
Sourcepub fn fov_degrees(&self) -> f32
pub fn fov_degrees(&self) -> f32
Get field of view in degrees
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Camera
impl RefUnwindSafe for Camera
impl Send for Camera
impl Sync for Camera
impl Unpin for Camera
impl UnwindSafe for Camera
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.