From 8ca2da07b4535a78a4a807ef8fed69117e9aff4b Mon Sep 17 00:00:00 2001 From: Nicolas Sarlin Date: Sat, 26 Feb 2022 21:29:23 +0100 Subject: [PATCH] Add the possibility to create custom 2d orthographic cameras --- crates/bevy_render/src/camera/bundle.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/bevy_render/src/camera/bundle.rs b/crates/bevy_render/src/camera/bundle.rs index 920a12bb353359..68616d5deaca64 100644 --- a/crates/bevy_render/src/camera/bundle.rs +++ b/crates/bevy_render/src/camera/bundle.rs @@ -93,11 +93,16 @@ impl OrthographicCameraBundle { /// corresponding to `Z=+999.9` (closest to camera) to `Z=-0.1` (furthest away from /// camera) in world space. pub fn new_2d() -> Self { + Self::custom_2d(1000.0, 1.0) + } + + /// Create an orthographic projection camera with a custom Z position and scale. + pub fn custom_2d(far: f32, scale: f32) -> Self { // we want 0 to be "closest" and +far to be "farthest" in 2d, so we offset // the camera's translation by far and use a right handed coordinate system - let far = 1000.0; let orthographic_projection = OrthographicProjection { far, + scale, depth_calculation: DepthCalculation::ZDifference, ..Default::default() };