Skip to main content

ViewCamera

Struct ViewCamera 

Source
pub struct ViewCamera {
    pub eye: [f64; 3],
    pub target: [f64; 3],
    pub up: [f64; 3],
    pub projection: Projection,
    pub width: f64,
    pub height: f64,
    pub near: f64,
    pub far: f64,
}

Fields§

§eye: [f64; 3]§target: [f64; 3]§up: [f64; 3]§projection: Projection§width: f64

Viewport CSS size.

§height: f64§near: f64

View-space depth window (positive distances along the view direction); maintained by ViewCamera::fit_depth_range. Ortho near may go negative (scene behind the eye plane is still projectable).

§far: f64

Implementations§

Source§

impl ViewCamera

Source

pub fn aspect(&self) -> f64

Source

pub fn basis(&self) -> ([f64; 3], [f64; 3], [f64; 3])

Camera basis: (right, true-up, forward) with forward pointing INTO the scene (eye → target).

Source

pub fn distance(&self) -> f64

Source

pub fn world_per_pixel(&self) -> f64

World units per CSS pixel at the target plane (R21/R25 — the query the pickers, gizmos and sketch glyph sizing key off).

Source

pub fn view_proj_cols(&self) -> [[f64; 4]; 4]

The world→clip view-projection as column-major [col][row] in f64. This is the exact matrix [resolve] feeds the GPU, kept in f64 so the CSS-pixel projection the host overlays derive from it matches [project] to sub-pixel precision. wgpu clip space: x,y in −1..1, z in 0..1.

Source

pub fn resolve(&self) -> Camera

Resolve to the GPU camera (column-major view-proj, f32).

Source

pub fn view_proj_flat(&self) -> [f64; 16]

The view-projection flattened column-major (index = col*4 + row) — the world→clip matrix for the host overlays’ per-frame world→screen hot path (dimensions + sketch), letting them drop the compat mirror camera. Pair with the CSS viewport for NDC→pixel.

Source

pub fn view_proj_inverse_flat(&self) -> [f64; 16]

Inverse of [view_proj_flat] (clip→world), column-major, for the host overlays’ screen→world / screen→ray path. Falls back to the identity if the matrix is singular (never in practice for a valid camera).

Source

pub fn project(&self, world: [f64; 3]) -> (f64, f64, f64)

Project a world point to CSS-pixel screen coordinates (origin top-left, y down). Returns (x, y, view_depth); view_depth is the distance along the view direction (positive in front of the eye plane).

Source

pub fn pick_ray(&self, x: f64, y: f64) -> Ray

A world-space picking ray through CSS-pixel (x, y). Ortho rays start far behind the eye plane so huge scenes are always in front (the retired picker pushed its ray origin back the same way).

Source

pub fn fit_depth_range(&mut self, bbox: &Aabb)

Fit the depth window to the scene (the _updateDepthRange port): the whole bbox lands inside [near, far] with generous padding.

Source

pub fn zoom_to_fit(&mut self, bbox: &Aabb, margin: f64)

Zoom-to-fit (R21): recenters the target on the bbox and scales the frustum/distance so the whole bbox fits with margin, preserving the view direction (the ArcballControls focus behavior).

Source

pub fn toggle_projection(&mut self) -> &'static str

Toggle ortho ↔ perspective preserving the apparent size at the target plane (the toggleCameraProjection port). Returns the new kind name.

Source

pub fn standard_view(&mut self, name: &str) -> bool

Snap to a standard view (future ViewCube seam), preserving distance and frustum scale. Directions are world-axis views with sensible ups.

Source

pub fn state_json(&self) -> String

Serialize the full camera state (R3: the host holds plain JSON only).

Source

pub fn apply_state_json(&mut self, json: &str) -> Result<(), String>

Restore from ViewCamera::state_json output (viewport size is NOT restored — it belongs to the canvas).

Trait Implementations§

Source§

impl Clone for ViewCamera

Source§

fn clone(&self) -> ViewCamera

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 Debug for ViewCamera

Source§

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

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

impl Default for ViewCamera

Source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> 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 = !

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

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,