pub struct Camera3D {
pub position: Vector3D,
pub target: Vector3D,
pub up: Vector3D,
pub fov: f64,
pub near: f64,
pub far: f64,
/* private fields */
}Expand description
A 3D camera that defines the viewport into a 3D world using perspective or orthographic projection.
Fields§
§position: Vector3DThe world-space position of the camera (eye).
target: Vector3DThe point the camera is looking at (target).
up: Vector3DThe up direction for the camera.
fov: f64The vertical field of view in radians.
near: f64The near clipping plane distance.
far: f64The far clipping plane distance.
Implementations§
Source§impl Camera3D
Implements 3D camera transformation and projection methods for Camera3D.
impl Camera3D
Implements 3D camera transformation and projection methods for Camera3D.
Sourcepub fn create(
position: Vector3D,
target: Vector3D,
viewport_width: f64,
viewport_height: f64,
) -> Camera3D
pub fn create( position: Vector3D, target: Vector3D, viewport_width: f64, viewport_height: f64, ) -> Camera3D
Sourcepub fn forward(&self) -> Vector3D
pub fn forward(&self) -> Vector3D
Returns the forward direction (from position to target, normalized).
§Returns
Vector3D- The forward direction.
Sourcepub fn right(&self) -> Vector3D
pub fn right(&self) -> Vector3D
Returns the right direction (cross product of forward and up).
§Returns
Vector3D- The right direction.
Sourcepub fn view_matrix(&self) -> Matrix4x4
pub fn view_matrix(&self) -> Matrix4x4
Sourcepub fn view_proj_matrix(&self) -> Matrix4x4
pub fn view_proj_matrix(&self) -> Matrix4x4
Sourcepub fn world_to_screen(&self, world: Vector3D) -> Vector3D
pub fn world_to_screen(&self, world: Vector3D) -> Vector3D
Sourcepub fn in_frustum(&self, world: Vector3D) -> bool
pub fn in_frustum(&self, world: Vector3D) -> bool
Sourcepub fn translate(&mut self, offset: Vector3D)
pub fn translate(&mut self, offset: Vector3D)
Moves the camera position by the given offset, keeping the target offset by the same amount.
§Arguments
Vector3D- The translation offset.
Source§impl Camera3D
impl Camera3D
pub fn get_position(&self) -> Vector3D
pub fn set_position(&mut self, val: Vector3D) -> &mut Self
pub fn get_target(&self) -> Vector3D
pub fn set_target(&mut self, val: Vector3D) -> &mut Self
pub fn get_up(&self) -> Vector3D
pub fn set_up(&mut self, val: Vector3D) -> &mut Self
pub fn get_fov(&self) -> f64
pub fn set_fov(&mut self, val: f64) -> &mut Self
pub fn get_near(&self) -> f64
pub fn set_near(&mut self, val: f64) -> &mut Self
pub fn get_far(&self) -> f64
pub fn set_far(&mut self, val: f64) -> &mut Self
Trait Implementations§
impl Copy for Camera3D
Source§impl Default for Camera3D
Implements Default for Camera3D as a camera at (0, 0, 5) looking at the origin.
impl Default for Camera3D
Implements Default for Camera3D as a camera at (0, 0, 5) looking at the origin.
Source§impl PartialOrd for Camera3D
impl PartialOrd for Camera3D
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 UnsafeUnpin 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
Mutably borrows from an owned value. Read more