@@ -5,14 +5,9 @@ use crate::{
5
5
use bevy_ecs:: prelude:: * ;
6
6
use bevy_reflect:: { std_traits:: ReflectDefault , Reflect } ;
7
7
use bevy_render:: {
8
- camera:: {
9
- Camera , CameraMainTextureUsages , CameraProjection , CameraRenderGraph ,
10
- OrthographicProjection , Projection ,
11
- } ,
8
+ camera:: { Camera , CameraProjection , CameraRenderGraph , OrthographicProjection , Projection } ,
12
9
extract_component:: ExtractComponent ,
13
10
primitives:: Frustum ,
14
- sync_world:: SyncToRenderWorld ,
15
- view:: { Msaa , VisibleEntities } ,
16
11
} ;
17
12
use bevy_transform:: prelude:: { GlobalTransform , Transform } ;
18
13
@@ -29,78 +24,3 @@ use bevy_transform::prelude::{GlobalTransform, Transform};
29
24
Tonemapping ( || Tonemapping :: None ) ,
30
25
) ]
31
26
pub struct Camera2d ;
32
-
33
- #[ derive( Bundle , Clone ) ]
34
- pub struct Camera2dBundle {
35
- pub camera : Camera ,
36
- pub camera_render_graph : CameraRenderGraph ,
37
- pub projection : Projection ,
38
- pub visible_entities : VisibleEntities ,
39
- pub frustum : Frustum ,
40
- pub transform : Transform ,
41
- pub global_transform : GlobalTransform ,
42
- pub camera_2d : Camera2d ,
43
- pub tonemapping : Tonemapping ,
44
- pub deband_dither : DebandDither ,
45
- pub main_texture_usages : CameraMainTextureUsages ,
46
- pub msaa : Msaa ,
47
- /// Marker component that indicates that its entity needs to be synchronized to the render world
48
- pub sync : SyncToRenderWorld ,
49
- }
50
-
51
- impl Default for Camera2dBundle {
52
- fn default ( ) -> Self {
53
- let projection = Projection :: Orthographic ( OrthographicProjection :: default_2d ( ) ) ;
54
- let transform = Transform :: default ( ) ;
55
- let frustum = projection. compute_frustum ( & GlobalTransform :: from ( transform) ) ;
56
- Self {
57
- camera_render_graph : CameraRenderGraph :: new ( Core2d ) ,
58
- projection,
59
- visible_entities : VisibleEntities :: default ( ) ,
60
- frustum,
61
- transform,
62
- global_transform : Default :: default ( ) ,
63
- camera : Camera :: default ( ) ,
64
- camera_2d : Camera2d ,
65
- tonemapping : Tonemapping :: None ,
66
- deband_dither : DebandDither :: Disabled ,
67
- main_texture_usages : Default :: default ( ) ,
68
- msaa : Default :: default ( ) ,
69
- sync : Default :: default ( ) ,
70
- }
71
- }
72
- }
73
-
74
- impl Camera2dBundle {
75
- /// Create an orthographic projection camera with a custom `Z` position.
76
- ///
77
- /// The camera is placed at `Z=far-0.1`, looking toward the world origin `(0,0,0)`.
78
- /// Its orthographic projection extends from `0.0` to `-far` in camera view space,
79
- /// corresponding to `Z=far-0.1` (closest to camera) to `Z=-0.1` (furthest away from
80
- /// camera) in world space.
81
- pub fn new_with_far ( far : f32 ) -> Self {
82
- // we want 0 to be "closest" and +far to be "farthest" in 2d, so we offset
83
- // the camera's translation by far and use a right handed coordinate system
84
- let projection = Projection :: Orthographic ( OrthographicProjection {
85
- far,
86
- ..OrthographicProjection :: default_2d ( )
87
- } ) ;
88
- let transform = Transform :: from_xyz ( 0.0 , 0.0 , far - 0.1 ) ;
89
- let frustum = projection. compute_frustum ( & GlobalTransform :: from ( transform) ) ;
90
- Self {
91
- camera_render_graph : CameraRenderGraph :: new ( Core2d ) ,
92
- projection,
93
- visible_entities : VisibleEntities :: default ( ) ,
94
- frustum,
95
- transform,
96
- global_transform : Default :: default ( ) ,
97
- camera : Camera :: default ( ) ,
98
- camera_2d : Camera2d ,
99
- tonemapping : Tonemapping :: None ,
100
- deband_dither : DebandDither :: Disabled ,
101
- main_texture_usages : Default :: default ( ) ,
102
- msaa : Default :: default ( ) ,
103
- sync : Default :: default ( ) ,
104
- }
105
- }
106
- }
0 commit comments