pub struct Camera {
pub view: Mat4,
pub focal_length: f32,
}Expand description
A pinhole camera that shows a 3D scene in a composable’s bounds.
The camera looks along its own z axis with its x to the right and y down.
A point at (x, y, z) in the camera’s frame shows at
center + (x, y) * focal_length / z, where center is the middle of the
bounds.
Fields§
§view: Mat4Maps scene space into the camera’s frame.
focal_length: f32The distance from the eye to the image, in logical pixels: the distance at which one scene unit shows as one pixel.
Implementations§
Source§impl Camera
impl Camera
Sourcepub fn look_at(eye: Vec3, target: Vec3, down: Vec3, focal_length: f32) -> Camera
pub fn look_at(eye: Vec3, target: Vec3, down: Vec3, focal_length: f32) -> Camera
A camera at eye that looks at target. down is the scene
direction that shows as down; it need not be square to the view.
Sourcepub fn focal_length_for(height: f32, vertical_fov: f32) -> f32
pub fn focal_length_for(height: f32, vertical_fov: f32) -> f32
The focal length that shows vertical_fov radians across height
pixels.
Sourcepub fn project(&self, point: Vec3, size: Size) -> Option<Point>
pub fn project(&self, point: Vec3, size: Size) -> Option<Point>
Where point shows in bounds of size; None when it lies nearer
than Self::near or behind the eye.
Sourcepub fn doorway(&self, window: Rect) -> Mat4
pub fn doorway(&self, window: Rect) -> Mat4
The map from the scene this camera sees into the frame in which
window, a rect on the frame’s plane, is a doorway into the scene:
the camera stands in the doorway’s middle, looking along the frame’s
z, with its x and y along the frame’s, a scene unit to a frame unit.
What the camera sees lies behind the doorway.
Trait Implementations§
impl Copy for Camera
impl StructuralPartialEq for Camera
Auto Trait Implementations§
impl Freeze for Camera
impl RefUnwindSafe for Camera
impl Send for Camera
impl Sync for Camera
impl Unpin for Camera
impl UnsafeUnpin 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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