pub struct Camera {
pub position: Vec3,
pub target: Vec3,
pub up: Vec3,
pub resolution: Vec2,
pub projection: Projection,
pub near: f32,
pub far: f32,
pub view_data: Mat4,
pub uniform_data: BindGroup,
/* private fields */
}Expand description
Container for the camera feature. The settings here are needed for algebra equations needed for camera vision and movement. Please leave it to the renderer to handle
Fields§
§position: Vec3The position of the camera in 3D space
target: Vec3The target at which the camera should be looking
up: Vec3The up vector of the camera. This defines the elevation of the camera
resolution: Vec2The resolution of the camera view
projection: ProjectionThe projection of the camera
near: f32The closest view of camera
far: f32The furthest view of camera
view_data: Mat4The final data that will be sent to GPU
uniform_data: BindGroupThe uniform data of the camera to be sent to the gpu
Implementations§
Source§impl Camera
impl Camera
Sourcepub fn new(window_size: (u32, u32), renderer: &mut Renderer) -> Camera
pub fn new(window_size: (u32, u32), renderer: &mut Renderer) -> Camera
Creates a new camera. this should’ve been automatically done at the time of creating an engine
Sourcepub fn build_view_matrix(&self) -> Mat4
pub fn build_view_matrix(&self) -> Mat4
Builds a view matrix for camera projection
Sourcepub fn build_projection_matrix(&self) -> Mat4
pub fn build_projection_matrix(&self) -> Mat4
Builds a projection matrix for camera
Sourcepub fn build_view_projection_matrix(&mut self)
pub fn build_view_projection_matrix(&mut self)
Updates the view uniform matrix that decides how camera works
Sourcepub fn build_view_orthographic_matrix(&mut self)
pub fn build_view_orthographic_matrix(&mut self)
Updates the view uniform matrix that decides how camera works
Sourcepub fn update_view_projection(&mut self, renderer: &mut Renderer)
pub fn update_view_projection(&mut self, renderer: &mut Renderer)
This builds a uniform buffer data from camera view data that is sent to the GPU in next frame
Sourcepub fn update_view_projection_and_return(
&mut self,
renderer: &mut Renderer,
) -> BindGroup
pub fn update_view_projection_and_return( &mut self, renderer: &mut Renderer, ) -> BindGroup
This builds a uniform buffer data from camera view data that is sent to the GPU in next frame, and returns the bindgroup
Sourcepub fn camera_uniform_buffer(&self) -> Mat4
pub fn camera_uniform_buffer(&self) -> Mat4
Returns a matrix uniform buffer from camera data that can be sent to GPU
Sourcepub fn set_position(&mut self, new_pos: impl Into<Vec3>)
pub fn set_position(&mut self, new_pos: impl Into<Vec3>)
Sets the position of camera
Sourcepub fn set_target(&mut self, target_pos: impl Into<Vec3>)
pub fn set_target(&mut self, target_pos: impl Into<Vec3>)
Sets the target of camera
Sourcepub fn set_resolution(&mut self, window_size: (u32, u32))
pub fn set_resolution(&mut self, window_size: (u32, u32))
Sets the aspect ratio of the camera
Sourcepub fn set_projection(&mut self, projection: Projection)
pub fn set_projection(&mut self, projection: Projection)
Sets the projection of the camera
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Camera
impl !RefUnwindSafe 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
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