pub struct Camera {
pub view_projection: Mat4,
pub position: Vec3,
pub clip_depth: ClipDepth,
}Fields§
§view_projection: Mat4§position: Vec3§clip_depth: ClipDepthImplementations§
Source§impl Camera
impl Camera
pub fn perspective( eye: Vec3, target: Vec3, up: Vec3, fov_y: f32, aspect: f32, near: f32, far: f32, ) -> Camera
pub fn frustum(self) -> Option<Frustum>
Sourcepub fn prepare_projector(
self,
viewport: Viewport,
y_axis: ScreenYAxis,
far_plane: FarPlane,
) -> Result<PreparedProjector3D, ProjectionError>
pub fn prepare_projector( self, viewport: Viewport, y_axis: ScreenYAxis, far_plane: FarPlane, ) -> Result<PreparedProjector3D, ProjectionError>
Cache projection and picking using this camera’s actual clip-depth convention.
Coordinates share the viewport’s units (normally logical pixels). Rays start at the near plane; callers declare finite/infinite far intent because it cannot reliably be recovered from the composed matrix. Infinite far is currently rejected. Camera position and rendering remain unchanged.
use ferravex_graphics::{Camera, Vec3, vec2, vec3};
use ferravex_math::projection::{FarPlane, ScreenYAxis, Viewport};
let camera = Camera::perspective(
vec3(0., 0., 5.), Vec3::ZERO, Vec3::Y, 1., 2., 0.5, 50.,
);
let projector = camera.prepare_projector(
Viewport { origin: vec2(20., 80.), size: vec2(800., 400.) },
ScreenYAxis::Down, FarPlane::Finite,
)?;
let anchor = projector.project(Vec3::ZERO)?;
assert!(anchor.screen.abs_diff_eq(vec2(420., 280.), 0.001));
let ray = projector.pick_ray(anchor.screen)?;
assert!(ray.origin.abs_diff_eq(vec3(0., 0., 4.5), 0.001));
assert!(ray.direction.abs_diff_eq(Vec3::NEG_Z, 0.001));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