Struct ark_api::world::Camera

source ·
pub struct Camera { /* private fields */ }
Expand description

Camera component accessor.

A camera is represented by an entity with the Camera component.

It lets you control the local origin and target of the camera and set the perspective mode and fov.

Call set_active or set_active_for_player to make the camera the active one.

An entity with a Camera component is special in that the rotation of its [Transform] component will be controlled directly by the client of the active player. That is, if you call Self::set_active_for_player or Self::set_active the camera will start acting like a first-person camera controlled by mouse movements of the player. If you do not want the player to control the camera rotation, then you need to call camera_entity.transform().rotation().set(…) each frame.

Implementations§

source§

impl Camera

source

pub fn create(name: &str) -> Self

Creates a camera entity.

  • name - Just a name, to keep track of the entity during development.
source

pub fn local_origin(&self) -> ValueAccessorReadWriteAnimate<Vec3>

Returns a ValueAccessor for the local position of the camera.

The default is Vec3::ZERO.

The Transform component of the entity will be used to compute the world-space camera position.

source

pub fn local_forward_vector(&self) -> ValueAccessorReadWriteAnimate<Vec3>

Returns a ValueAccessor for the local forward-vector of the camera.

The default is -Vec3::Z.

The Transform component of the entity will be used to compute the world-space forward vector.

source

pub fn local_up_vector(&self) -> ValueAccessorReadWriteAnimate<Vec3>

Returns a ValueAccessor for the local up vector of the camera.

The default is Vec3::Y.

The Transform component of the entity will be used to compute the world-space up vector.

source

pub fn field_of_view(&self) -> ValueAccessorReadWriteAnimate<f32>

Returns a ValueAccessor for the field of view of the camera.

Sets/gets the vertical field of view in degrees. Defaults to 60 degrees.

source

pub fn focal_point(&self) -> ValueAccessorReadWriteAnimate<f32>

Returns a ValueAccessor for the focal point of the camera.

Sets/gets the focal point of the camera in normalized distance units. Set this to 0.0 for automatic focusing. Defaults to 0.0 / automatic focusing.

note: That this will only have an effect if f-number is also set to >0.

source

pub fn focal_point_smoothing(&self) -> ValueAccessorReadWriteAnimate<f32>

Returns a ValueAccessor for the focal point of the camera.

Sets/gets the focal point smoothing value of the camera which controls the amount of smoothing to apply to focal point changes. Where 0.0 is no smoothing and 1.0 is the maximum amount of smoothing. Defaults to 0.5.

note: That this will only have an effect if f-number is also set to >0.

source

pub fn f_stop(&self) -> ValueAccessorReadWriteAnimate<f32>

Returns a ValueAccessor for the f-number of the camera.

Sets/gets the scale of the area that is in focus (cone of confusion). Defaults to 0.0 which means depth of field is disabled

Note: This parameter will likely change and be replaced with something that is more physical and non-resolution dependent

source

pub fn screen_space_offset(&self) -> ValueAccessorReadWriteAnimate<Vec2>

Returns a ValueAccessor for the screen space 2D offset of the camera.

Sets/gets an offset in 2D pixel coordinates to shift the viewport by. Useful for centering things under sidebars without viewports.

source

pub fn set_camera_projection_mode(&self, mode: CameraProjectionMode)

Currently unimplemented

Sets the projection mode of the camera (Perspective/Orthographic).

Default is Perspective.

source

pub fn transform(&self) -> Transform

Accessor for the Transform component, if it exists.

source

pub fn set_look_at(&self, look_at: &LookAt)

👎Deprecated: Position the Transform component instead, e.g. with camera.transform().set_world_to_entity(Conformal3::look_at_rh(…))

Sets the look at camera properties using a struct.

source

pub fn set_active(&self)

Makes this the active camera.

Simplified wrapper for EntityMessenger::set_active.

In a multiplayer environment, set_active will activate the camera for the host player. Use set_active_for_player for activating a camera for a specific player.

source

pub fn set_active_for_player(&self, player_id: PlayerId)

Makes this the active camera for a specific player.

Simplified wrapper for EntityMessenger::set_active_for_player.

  • player_id: this identifier can be retrieved through the Applet API.

Trait Implementations§

source§

impl ComponentTrait for Camera

source§

fn get_type() -> ComponentType

The type of the component, as a ComponentType enum.
source§

fn from_entity(handle: Entity) -> Self

Adopt an Entity, wrap in a component struct.
source§

fn entity(&self) -> Entity

Get the entity that the component belongs to.
source§

impl Debug for Camera

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.