Skip to main content

Camera

Struct Camera 

Source
pub struct Camera {
    pub pan_x: f32,
    pub pan_y: f32,
    pub zoom: f32,
    pub target: V3,
    pub azimuth: f32,
    pub elevation: f32,
    pub distance: f32,
    pub fov_y: f32,
    pub feel: InputFeel,
}
Expand description

The shared camera — the superset of the 2D pan/zoom and 3D orbit cameras.

In 2D mode (the graph board) a world point projects as center + pan + p * zoom, exactly as facett-graphview::model::Camera.

In 3D mode (the orbit map) the eye sits on a sphere of distance around target at (azimuth, elevation), and view_space / project_view / view_proj reproduce facett-map3d::camera::OrbitCamera’s math (the camera_seam test goldens this).

The skins keep their own concrete camera types this milestone; Camera is the additive seam a future renderer drives both domains through.

Fields§

§pan_x: f32§pan_y: f32§zoom: f32§target: V3

Point the camera orbits / looks at.

§azimuth: f32

Turntable yaw about +Y.

§elevation: f32

Polar lift; +PI/2 looks straight down, 0 is level.

§distance: f32

Eye-to-target distance (the dolly radius).

§fov_y: f32

Vertical field of view (radians).

§feel: InputFeel

Per-OS input feel (shared FEEL).

Implementations§

Source§

impl Camera

Source

pub const NEAR_PLANE: f32 = 0.02

The view-space near plane (camera-space depth, design units). Identical to facett-map3d::camera::OrbitCamera::NEAR_PLANE — geometry with cz <= NEAR_PLANE sits on or behind the eye and must be clipped before the perspective divide.

Source

pub fn project2d(&self, p: Pos) -> (f32, f32)

Project a 2D world point to screen pixels (pan/zoom affine), the graph board’s transform. p * zoom + pancenter is folded into pan by the caller (matching graphview), so this is the raw affine.

Source

pub fn far_plane(&self) -> f32

The bounded far plane — mirrors OrbitCamera::far_plane (distance + 4).

Source

pub fn eye(&self) -> V3

The eye position, derived from target + spherical offset.

Source

pub fn basis(&self) -> (V3, V3, V3)

Forward (eye → target), right, and up basis vectors of the view.

Source

pub fn view_space(&self, p: V3) -> V3

A world point transformed into view space (x=right, y=up, z=forward, relative to the eye). The near-plane clip operates here, before projection.

Source

pub fn project_view(&self, c: V3, center: (f32, f32), half_h: f32) -> Projected

Project an already-view-space point to screen pixels with perspective.

Source

pub fn project_view_world( &self, p: V3, center: (f32, f32), half_h: f32, ) -> Projected

Project a world point to screen pixels with perspective (3D orbit).

Source

pub fn view_proj(&self, aspect: f32) -> [f32; 16]

The view-projection matrix for the GPU depth-tested path — the same look-at + perspective as view_space/project_view, as a column-major [f32; 16] for a wgpu uniform. Mirrors OrbitCamera::view_proj.

Trait Implementations§

Source§

impl Clone for Camera

Source§

fn clone(&self) -> Camera

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Camera

Source§

impl Debug for Camera

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Camera

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.