Struct moon_engine::camera::Camera
source · [−]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
sourceimpl 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 RefUnwindSafe for Camera
impl Send for Camera
impl Sync for Camera
impl Unpin for Camera
impl UnwindSafe for Camera
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
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 more
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).
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.
fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.