logo
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

Creates a camera entity.

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

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.

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.

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.

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

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

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.

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.

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

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.

Currently unimplemented

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

Default is Perspective.

Accessor for the Transform component, if it exists.

👎Deprecated:

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.

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.

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

The type of the component, as a ComponentType enum.

Adopt an Entity, wrap in a component struct.

Get the entity that the component belongs to.

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.