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
sourceimpl Camera
impl Camera
sourcepub fn create(name: &str) -> Self
pub fn create(name: &str) -> Self
Creates a camera entity.
name
- Just a name, to keep track of the entity during development.
sourcepub fn local_origin(&self) -> ValueAccessorReadWriteAnimate<Vec3>
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.
sourcepub fn local_forward_vector(&self) -> ValueAccessorReadWriteAnimate<Vec3>
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.
sourcepub fn local_up_vector(&self) -> ValueAccessorReadWriteAnimate<Vec3>
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.
sourcepub fn field_of_view(&self) -> ValueAccessorReadWriteAnimate<f32>
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.
sourcepub fn focal_point(&self) -> ValueAccessorReadWriteAnimate<f32>
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.
sourcepub fn focal_point_smoothing(&self) -> ValueAccessorReadWriteAnimate<f32>
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.
sourcepub fn f_stop(&self) -> ValueAccessorReadWriteAnimate<f32>
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
sourcepub fn screen_space_offset(&self) -> ValueAccessorReadWriteAnimate<Vec2>
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.
sourcepub fn set_camera_projection_mode(&self, mode: CameraProjectionMode)
pub fn set_camera_projection_mode(&self, mode: CameraProjectionMode)
Currently unimplemented
Sets the projection mode of the camera (Perspective/Orthographic).
Default is Perspective.
sourcepub fn set_look_at(&self, look_at: &LookAt)
👎Deprecated: Position the Transform
component instead, e.g. with camera.transform().set_world_to_entity(Affine3A::look_at_rh(…))
pub fn set_look_at(&self, look_at: &LookAt)
Position the Transform
component instead, e.g. with camera.transform().set_world_to_entity(Affine3A::look_at_rh(…))
Sets the look at camera properties using a struct.
sourcepub fn set_active(&self)
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.
sourcepub fn set_active_for_player(&self, player_id: PlayerId)
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
sourceimpl ComponentTrait for Camera
impl ComponentTrait for Camera
sourcefn get_type() -> ComponentType
fn get_type() -> ComponentType
The type of the component, as a ComponentType
enum.
sourcefn from_entity(handle: Entity) -> Self
fn from_entity(handle: Entity) -> Self
Adopt an Entity
, wrap in a component struct.
Auto Trait Implementations
impl RefUnwindSafe for Camera
impl Send for Camera
impl Sync for Camera
impl Unpin for Camera
impl UnwindSafe for Camera
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more