Struct re_space_view_spatial::eye::ViewEye
source · pub struct ViewEye {
mode: EyeMode,
center: Vec3,
orbit_radius: f32,
world_from_view_rot: Quat,
fov_y: f32,
eye_up: Vec3,
velocity: Vec3,
}
Expand description
An eye (camera) in 3D space, controlled by the user.
This is either a first person camera or an orbital camera,
controlled by EyeMode
.
We combine these two modes in one struct because they share a lot of state and logic.
Note: we use “eye” so we don’t confuse this with logged camera.
Fields§
§mode: EyeMode
First person or orbital?
center: Vec3
Center of orbit, or camera position in first person mode.
orbit_radius: f32
Ignored for EyeMode::FirstPerson
,
but kept for if/when the user switches to orbital mode.
world_from_view_rot: Quat
Rotate to world-space from view-space (RUB).
fov_y: f32
Vertical field of view in radians.
eye_up: Vec3
The up-axis of the eye itself, in world-space.
Initially, the up-axis of the eye will be the same as the up-axis of the scene (or +Z if the scene has no up axis defined). Rolling the camera (e.g. middle-click) will permanently modify the eye’s up axis, until the next reset.
A value of Vec3::ZERO
is valid and will result in 3 degrees of freedom, although we never
use it at the moment.
velocity: Vec3
For controlling the eye with WSAD in a smooth way.
Implementations§
source§impl ViewEye
impl ViewEye
pub fn new_orbital( orbit_center: Vec3, orbit_radius: f32, world_from_view_rot: Quat, eye_up: Vec3 ) -> Self
pub fn mode(&self) -> EyeMode
pub fn set_mode(&mut self, new_mode: EyeMode)
sourcepub fn orbit_center(&self) -> Option<Vec3>
pub fn orbit_center(&self) -> Option<Vec3>
If in orbit mode, what are we orbiting around?
sourcepub fn orbit_radius(&self) -> Option<f32>
pub fn orbit_radius(&self) -> Option<f32>
If in orbit mode, how far from the orbit center are we?
sourcepub fn set_orbit_center_and_radius(
&mut self,
orbit_center: Vec3,
orbit_radius: f32
)
pub fn set_orbit_center_and_radius( &mut self, orbit_center: Vec3, orbit_radius: f32 )
Set what we orbit around, and at what distance.
If we are not in orbit mode, the state will still be set and used if the user switches to orbit mode.
pub fn to_eye(self) -> Eye
sourcepub fn copy_from_eye(&mut self, eye: &Eye)
pub fn copy_from_eye(&mut self, eye: &Eye)
pub fn lerp(&self, other: &Self, t: f32) -> Self
sourcepub fn update(
&mut self,
response: &Response,
drag_threshold: f32,
bounding_boxes: &SceneBoundingBoxes
) -> bool
pub fn update( &mut self, response: &Response, drag_threshold: f32, bounding_boxes: &SceneBoundingBoxes ) -> bool
Returns true
if interaction occurred.
I.e. the camera changed via user input.
Listen to WSAD and QE to move the eye.
Returns true
if we did anything.
Trait Implementations§
source§impl<'de> Deserialize<'de> for ViewEye
impl<'de> Deserialize<'de> for ViewEye
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for ViewEye
impl PartialEq for ViewEye
impl Copy for ViewEye
impl StructuralPartialEq for ViewEye
Auto Trait Implementations§
impl Freeze for ViewEye
impl RefUnwindSafe for ViewEye
impl Send for ViewEye
impl Sync for ViewEye
impl Unpin for ViewEye
impl UnwindSafe for ViewEye
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
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request