pub struct Camera {
pub transform: Transform,
/* private fields */
}
Expand description
A Camera
represents a Virtual Camera, that has a view and Orthographic projection matrices
Fields§
§transform: Transform
Transform
for the Camera
Implementations§
Source§impl Camera
impl Camera
Sourcepub fn with_position(position: Vec3) -> Self
pub fn with_position(position: Vec3) -> Self
Create a new Camera
with an initial position.
Sourcepub fn with_transform(transform: Transform) -> Self
pub fn with_transform(transform: Transform) -> Self
Create a new Camera
with an initial transform.
Sourcepub fn with_width_and_height(width: f32, height: f32) -> Self
pub fn with_width_and_height(width: f32, height: f32) -> Self
Create a new Camera
with an initial width and height.
Sourcepub fn set_width_and_height(&mut self, width: f32, height: f32)
pub fn set_width_and_height(&mut self, width: f32, height: f32)
Set the width and height of the camera plane, and update the Projection Matrix to match.
Sourcepub fn projection(&self) -> &[f32]
pub fn projection(&self) -> &[f32]
Return the Projection Matrix of the Camera
as a slice of f32
so it can be used by WebGL.
Sourcepub fn view_projection_matrix(&self) -> Mat4
pub fn view_projection_matrix(&self) -> Mat4
Return the calculated and combined view-projection matrix as a Mat4
.
Sourcepub fn screen_to_world_coordinates(
&self,
screen_x: f32,
screen_y: f32,
) -> (f32, f32)
pub fn screen_to_world_coordinates( &self, screen_x: f32, screen_y: f32, ) -> (f32, f32)
Get a position in screen co-ordinates to a range within the world.
This works by first converting it into a -1.0 to 1.0
range, and then multiplying its components by the FIXED_WIDTH
and FIXED_HEIGHT
.
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<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.