pub struct Camera {
pub intrinsic: Projection,
pub extrinsic: CameraExtrinsic,
}Expand description
Combination of camera projection and extrinsic pose. Port of Camera.
Fields§
§intrinsic: Projection§extrinsic: CameraExtrinsicImplementations§
Source§impl Camera
impl Camera
Sourcepub fn new(
fovy: f32,
near: f32,
far: f32,
size: (f32, f32),
position: Vec3,
direction: Vec3,
up: Vec3,
) -> Self
pub fn new( fovy: f32, near: f32, far: f32, size: (f32, f32), position: Vec3, direction: Vec3, up: Vec3, ) -> Self
A perspective camera, matching silx Camera defaults (fovy 30°).
Sourcepub fn set_size(&mut self, size: (f32, f32))
pub fn set_size(&mut self, size: (f32, f32))
Update the viewport size used for the projection aspect ratio.
Sourcepub fn reset_camera(&mut self, bounds: (Vec3, Vec3))
pub fn reset_camera(&mut self, bounds: (Vec3, Vec3))
Position the camera so the axes-aligned bounds fit the frustum, and set
the near/far depth extent to bracket them. Sight direction and up are
preserved. Port of Camera.resetCamera.
Sourcepub fn pan(&mut self, from_ndc: Vec3, to_ndc: Vec3)
pub fn pan(&mut self, from_ndc: Vec3, to_ndc: Vec3)
Pan: translate the camera so the scene point under from_ndc moves to
to_ndc, both NDC positions sharing a fixed z (the pan plane). Port of
CameraSelectPan.drag — un-projects both NDC points to scene space
through the inverse camera matrix and shifts the camera by their
difference. A no-op if the camera matrix is singular.
Sourcepub fn zoom_at(&mut self, ndc: (f32, f32), ndc_z: f32, zoom_in: bool)
pub fn zoom_at(&mut self, ndc: (f32, f32), ndc_z: f32, zoom_in: bool)
Zoom keeping the point under the cursor invariant. Port of
CameraWheel._zoomToPosition: for a perspective camera, move the camera
toward/away from the un-projected cursor point; for orthographic, widen or
narrow the clip rectangle around the cursor. ndc is the cursor in NDC,
ndc_z the cursor’s pan-plane depth (perspective only), zoom_in true to
move closer.
Sourcepub fn adjust_depth_extent(&mut self, bounds: (Vec3, Vec3))
pub fn adjust_depth_extent(&mut self, bounds: (Vec3, Vec3))
Update only the near/far depth extent so axis-aligned bounds stay inside
the frustum. Port of Viewport.adjustCameraDepthExtent: transform the
eight box corners into camera space and bracket their z-range. Sight
direction, up and position are unchanged.
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 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
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.