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: f64Viewport CSS size.
height: f64§near: f64View-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: f64Implementations§
Source§impl ViewCamera
impl ViewCamera
pub fn aspect(&self) -> f64
Sourcepub fn basis(&self) -> ([f64; 3], [f64; 3], [f64; 3])
pub fn basis(&self) -> ([f64; 3], [f64; 3], [f64; 3])
Camera basis: (right, true-up, forward) with forward pointing INTO the scene (eye → target).
pub fn distance(&self) -> f64
Sourcepub fn world_per_pixel(&self) -> f64
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).
Sourcepub fn view_proj_cols(&self) -> [[f64; 4]; 4]
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.
Sourcepub fn view_proj_flat(&self) -> [f64; 16]
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.
Sourcepub fn view_proj_inverse_flat(&self) -> [f64; 16]
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).
Sourcepub fn project(&self, world: [f64; 3]) -> (f64, f64, f64)
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).
Sourcepub fn pick_ray(&self, x: f64, y: f64) -> Ray
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).
Sourcepub fn fit_depth_range(&mut self, bbox: &Aabb)
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.
Sourcepub fn zoom_to_fit(&mut self, bbox: &Aabb, margin: f64)
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).
Sourcepub fn toggle_projection(&mut self) -> &'static str
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.
Sourcepub fn standard_view(&mut self, name: &str) -> bool
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.
Sourcepub fn state_json(&self) -> String
pub fn state_json(&self) -> String
Serialize the full camera state (R3: the host holds plain JSON only).
Sourcepub fn apply_state_json(&mut self, json: &str) -> Result<(), String>
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
impl Clone for ViewCamera
Source§fn clone(&self) -> ViewCamera
fn clone(&self) -> ViewCamera
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ViewCamera
impl Debug for ViewCamera
Auto Trait Implementations§
impl Freeze for ViewCamera
impl RefUnwindSafe for ViewCamera
impl Send for ViewCamera
impl Sync for ViewCamera
impl Unpin for ViewCamera
impl UnsafeUnpin for ViewCamera
impl UnwindSafe for ViewCamera
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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