pub trait CameraProjection {
// Required methods
fn get_clip_from_view(&self) -> Mat4;
fn get_clip_from_view_for_sub(&self, sub_view: &SubCameraView) -> Mat4;
fn update(&mut self, width: f32, height: f32);
fn far(&self) -> f32;
fn get_frustum_corners(&self, z_near: f32, z_far: f32) -> [Vec3A; 8];
// Provided method
fn compute_frustum(&self, camera_transform: &GlobalTransform) -> Frustum { ... }
}
Expand description
Describes a type that can generate a projection matrix, allowing it to be added to a
Camera
’s Projection
component.
Once implemented, the projection can be added to a camera using Projection::custom
.
The projection will be automatically updated as the render area is resized. This is useful when,
for example, a projection type has a field like fov
that should change when the window width
is changed but not when the height changes.
This trait is implemented by bevy’s built-in projections PerspectiveProjection
and
OrthographicProjection
.
Required Methods§
Sourcefn get_clip_from_view(&self) -> Mat4
fn get_clip_from_view(&self) -> Mat4
Generate the projection matrix.
Sourcefn get_clip_from_view_for_sub(&self, sub_view: &SubCameraView) -> Mat4
fn get_clip_from_view_for_sub(&self, sub_view: &SubCameraView) -> Mat4
Generate the projection matrix for a SubCameraView
.
Sourcefn update(&mut self, width: f32, height: f32)
fn update(&mut self, width: f32, height: f32)
When the area this camera renders to changes dimensions, this method will be automatically called. Use this to update any projection properties that depend on the aspect ratio or dimensions of the render area.
Sourcefn get_frustum_corners(&self, z_near: f32, z_far: f32) -> [Vec3A; 8]
fn get_frustum_corners(&self, z_near: f32, z_far: f32) -> [Vec3A; 8]
The eight corners of the camera frustum, as defined by this projection.
The corners should be provided in the following order: first the bottom right, top right, top left, bottom left for the near plane, then similar for the far plane.
Provided Methods§
Sourcefn compute_frustum(&self, camera_transform: &GlobalTransform) -> Frustum
fn compute_frustum(&self, camera_transform: &GlobalTransform) -> Frustum
Compute camera frustum for camera with given projection and transform.
This code is called by update_frusta
system
for each camera to update its frustum.