Skip to main content

ArrayCamera

Struct ArrayCamera 

Source
pub struct ArrayCamera {
    pub camera: PerspectiveCamera,
    pub cameras: Vec<PerspectiveCamera>,
}
Expand description

ArrayCamera — a PerspectiveCamera holding sub-cameras that one render() call draws the scene through, each into its own viewport.

three.js’ ArrayCamera extends PerspectiveCamera; the port derefs to the base camera, which is what the render list’s sort and the frustum array’s fallback read. The sub-cameras are not its children: their matrices are the application’s to update, as webgpu_camera_array does with subcamera.updateMatrixWorld().

isMultiViewCamera (WebXR’s OVR_multiview2) is not ported.

Fields§

§camera: PerspectiveCamera

The base camera: ArrayCamera extends PerspectiveCamera, held by value since Rust has no inheritance.

§cameras: Vec<PerspectiveCamera>

camera.cameras.

Implementations§

Source§

impl ArrayCamera

Source

pub fn new(cameras: Vec<PerspectiveCamera>) -> Self

new ArrayCamera( array ) — the base camera is new PerspectiveCamera()’s defaults.

Methods from Deref<Target = PerspectiveCamera>§

Source

pub fn set_focal_length(&mut self, focal_length: f64)

PerspectiveCamera.setFocalLength().

Source

pub fn get_focal_length(&self) -> f64

PerspectiveCamera.getFocalLength().

Source

pub fn get_effective_fov(&self) -> f64

PerspectiveCamera.getEffectiveFOV().

Source

pub fn get_film_width(&self) -> f64

PerspectiveCamera.getFilmWidth().

Source

pub fn get_film_height(&self) -> f64

PerspectiveCamera.getFilmHeight().

Source

pub fn get_view_bounds( &self, distance: f64, min_target: &mut Vector2, max_target: &mut Vector2, )

PerspectiveCamera.getViewBounds().

Source

pub fn get_view_size(&self, distance: f64) -> Vector2

PerspectiveCamera.getViewSize().

Source

pub fn set_view_offset( &mut self, full_width: f64, full_height: f64, x: f64, y: f64, width: f64, height: f64, )

PerspectiveCamera.setViewOffset().

Source

pub fn clear_view_offset(&mut self)

PerspectiveCamera.clearViewOffset().

Source

pub fn update_projection_matrix(&mut self)

PerspectiveCamera.updateProjectionMatrix().

Source

pub fn fit(&mut self, box_: &Box3, margin: f64)

Move the camera along the direction it already looks in, until box_ fills the frame with margin of it left as slack (0.0 is tight, 0.1 leaves 10 % of the half-frame free on the tightest side). Not a three.js method — see issue #51.

The view direction is the camera’s own, taken from matrix_world; only the position moves, along that direction, and near/far are set to the box’s extent along it. fov, aspect and zoom are read, not written, so the caller’s framing choices survive the fit.

The distance is the one that actually frames the box: a bounding sphere wastes the corners, and so does taking the eight corners’ lateral extent, because a corner nearer the camera needs more distance than a far one at the same offset. For each corner this asks what distance d puts it exactly on a frustum plane — |x| / tan_h - depth horizontally, |y| / tan_v - depth vertically, with depth the corner’s offset along the view direction from the box centre — and takes the largest of the sixteen answers.

A view offset (set_view_offset) is ignored; the fit is to the full frustum.

Source

pub fn look_at(&mut self, target: &Vector3)

Object3D.lookAt() for a camera: the matrix looks from the camera position at the target.

Source

pub fn update_matrix_world(&mut self)

Camera.updateMatrixWorld().

Trait Implementations§

Source§

impl Clone for ArrayCamera

Source§

fn clone(&self) -> Self

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 Deref for ArrayCamera

Source§

type Target = PerspectiveCamera

The resulting type after dereferencing.
Source§

fn deref(&self) -> &PerspectiveCamera

Dereferences the value.
Source§

impl DerefMut for ArrayCamera

Source§

fn deref_mut(&mut self) -> &mut PerspectiveCamera

Mutably dereferences the value.
Source§

impl RenderCamera for ArrayCamera

Source§

fn set_view_offset( &mut self, full_width: f64, full_height: f64, x: f64, y: f64, width: f64, height: f64, )

ArrayCamera inherits PerspectiveCamera.setViewOffset, so the offset lands on the outer camera; three’s sub-cameras keep their own projections, and so do these.

Source§

fn far(&self) -> f64

camera.far — the sort key scale BatchedMesh’ custom sort uses.
Source§

fn near(&self) -> f64

camera.near — LineSegments2’ screen-space raycast clips to it.
Source§

fn is_perspective_camera(&self) -> bool

camera.isPerspectiveCamera.
Source§

fn update_matrix_world(&mut self)

camera.updateMatrixWorld(), which also refreshes matrixWorldInverse.
Source§

fn clear_view_offset(&mut self)

camera.clearViewOffset().
Source§

fn projection_matrix(&self) -> Matrix4

camera.projectionMatrix.
Source§

fn projection_matrix_inverse(&self) -> Matrix4

camera.projectionMatrixInverse, kept current by update_projection_matrix() on both cameras.
Source§

fn matrix_world_inverse(&self) -> Matrix4

camera.matrixWorldInverse — the view matrix.
Source§

fn coordinate_system(&self) -> CoordinateSystem

camera.coordinateSystem.
Source§

fn matrix_world(&self) -> Matrix4

camera.matrixWorld.
Source§

fn layers(&self) -> Layers

camera.layers.
Source§

fn id(&self) -> u32

camera.id — the key ReflectorBaseNode’s virtualCameras map is held on.
Source§

fn sub_cameras(&self) -> &[PerspectiveCamera]

camera.isArrayCamera ? camera.cameras : [] — the sub-cameras one render draws through, each into its own viewport. Empty for every camera but an ArrayCamera.
Source§

fn is_orthographic_camera(&self) -> bool

camera.isOrthographicCamera.
Source§

fn node(&self) -> Option<&ObjectRef>

The camera as a scene-graph object — Camera extends Object3D — for what needs the object itself rather than a copy of its matrices (CameraHelper’s this.matrix = camera.matrixWorld). None for a camera the port keeps outside the graph (OrthographicCamera).

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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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, !>

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.