Skip to main content

CameraHelper

Struct CameraHelper 

Source
pub struct CameraHelper {
    pub node: ObjectRef,
    /* private fields */
}
Expand description

new CameraHelper( camera ) — a LineSegments of the camera’s frustum, cone, up triangle, target line and cross hairs, in the camera’s local space, drawn with vertex colours.

Three sets this.matrix = camera.matrixWorld — the helper shares the camera’s world matrix object — with matrixAutoUpdate = false, so every updateMatrixWorld() traversal that reaches the helper multiplies in whatever the camera’s world matrix holds at that moment. The port’s Object3D::matrix_alias is that sharing, read at the same point of the traversal; webgpu_camera depends on it, since the helper sits before the camera in the scene and so sees the camera’s matrix from the previous traversal.

A camera with no scene-graph node (the port’s OrthographicCamera) cannot be aliased; its helper takes a copy of the camera’s world matrix instead.

Fields§

§node: ObjectRef

The LineSegments itself.

Implementations§

Source§

impl CameraHelper

Source

pub fn new(camera: &dyn RenderCamera) -> Self

new CameraHelper( camera ).

Three’s constructor calls camera.updateProjectionMatrix() first; both of the port’s cameras compute their projection in new and on every update_projection_matrix(), so the call is already made by the time a helper can be built for them.

Source

pub fn set_colors( &self, frustum: Color, cone: Color, up: Color, target: Color, cross: Color, )

CameraHelper.setColors( frustum, cone, up, target, cross ) — vertices 0–23 frustum, 24–31 cone, 32–37 up, 38–39 target, 40–49 cross (the p–c line included).

Source

pub fn update(&self, camera: &dyn RenderCamera)

CameraHelper.update(): every named point un-projected from NDC through the camera’s projectionMatrixInverse alone (three’s _camera has an identity world matrix — the helper’s own matrix places it).

camera.reversedDepth is never set on the port’s cameras, so the near and far planes are the coordinate system’s: -1/1 under WebGL, 0/1 under WebGPU.

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