Skip to content

Commit 8ca2da0

Browse files
committed
Add the possibility to create custom 2d orthographic cameras
1 parent b697e73 commit 8ca2da0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

crates/bevy_render/src/camera/bundle.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,16 @@ impl OrthographicCameraBundle {
9393
/// corresponding to `Z=+999.9` (closest to camera) to `Z=-0.1` (furthest away from
9494
/// camera) in world space.
9595
pub fn new_2d() -> Self {
96+
Self::custom_2d(1000.0, 1.0)
97+
}
98+
99+
/// Create an orthographic projection camera with a custom Z position and scale.
100+
pub fn custom_2d(far: f32, scale: f32) -> Self {
96101
// we want 0 to be "closest" and +far to be "farthest" in 2d, so we offset
97102
// the camera's translation by far and use a right handed coordinate system
98-
let far = 1000.0;
99103
let orthographic_projection = OrthographicProjection {
100104
far,
105+
scale,
101106
depth_calculation: DepthCalculation::ZDifference,
102107
..Default::default()
103108
};

0 commit comments

Comments
 (0)