pub struct Camera3d { /* private fields */ }
Expand description
Represents a camera (“view”) positioned and oriented in a 3D scene with a 3D transformation and a 3D projection.
Implementations§
Source§impl Camera3d
impl Camera3d
Sourcepub fn new(viewport_width: u16, viewport_height: u16) -> Self
pub fn new(viewport_width: u16, viewport_height: u16) -> Self
Create a new camera centered at the origin looking down the positive Y axis with ‘up’ vector aligned with the Z axis.
Sourcepub fn with_pose(
viewport_width: u16,
viewport_height: u16,
pose: Pose3<f32>,
) -> Self
pub fn with_pose( viewport_width: u16, viewport_height: u16, pose: Pose3<f32>, ) -> Self
Create a new 3D camera with the given viewport, position, and 3D pose
pub fn position(&self) -> Point3<f32>
pub fn yaw(&self) -> Rad<f32>
pub fn pitch(&self) -> Rad<f32>
pub fn roll(&self) -> Rad<f32>
pub fn orientation(&self) -> Rotation3<f32>
pub fn transform_mat_world_to_view(&self) -> Matrix4<f32>
pub fn projection(&self) -> &Projection3d
Sourcepub fn set_viewport_dimensions(
&mut self,
viewport_width: u16,
viewport_height: u16,
)
pub fn set_viewport_dimensions( &mut self, viewport_width: u16, viewport_height: u16, )
Should be called when the screen resolution changes.
pub fn set_position(&mut self, position: Point3<f32>)
pub fn set_orientation(&mut self, orientation: Rotation3<f32>)
pub fn scale_fovy_or_zoom(&mut self, scale: f32)
pub fn rotate(&mut self, dyaw: Rad<f32>, dpitch: Rad<f32>, droll: Rad<f32>)
Sourcepub fn move_local_xy(&mut self, dx: f32, dy: f32, dz: f32)
pub fn move_local_xy(&mut self, dx: f32, dy: f32, dz: f32)
Moves the view position relative to the X/Y plane with X and Y direction determined by heading and Z always aligned with the Z axis, i.e. the translated position is only determined by the current yaw not the pitch.
Sourcepub fn look_at(&mut self, target: Point3<f32>)
pub fn look_at(&mut self, target: Point3<f32>)
Updates the camera pose to look at the given point.
If the target point is equal to the camera position, then the identity orientation is used.
Sourcepub fn view_mats(&self) -> ([[f32; 4]; 4], [[f32; 4]; 4])
pub fn view_mats(&self) -> ([[f32; 4]; 4], [[f32; 4]; 4])
Returns the raw world to view transform and view to clip projection matrix data, suitable for use as shader uniforms.
Sourcepub fn to_orthographic(&mut self, zoom: f32)
pub fn to_orthographic(&mut self, zoom: f32)
Modify the projection to orthographic
Sourcepub fn to_perspective(&mut self, fovy: Rad<f32>)
pub fn to_perspective(&mut self, fovy: Rad<f32>)
Modify the projection to perspective
Trait Implementations§
impl StructuralPartialEq for Camera3d
Auto Trait Implementations§
impl Freeze for Camera3d
impl RefUnwindSafe for Camera3d
impl Send for Camera3d
impl Sync for Camera3d
impl Unpin for Camera3d
impl UnwindSafe for Camera3d
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>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 more