--- name: bevy-cameras description: Reference for cameras in Bevy — Camera2d, Camera3d, viewports, projection, render layers, mouse-to-world, and free camera controllers. metadata: crate: bevy_camera bevy: "0.19" --- ## Creating cameras ```rust commands.spawn(Camera2d); commands.spawn(Camera3d); ``` Mark a main camera with a marker component for querying: ```rust #[derive(Component)] #[require(Camera2d)] struct MainCamera; ``` ## Camera = render target + projection + position Each `Camera` defines: 1. A `RenderTarget` (Window, Image, TextureView, or None) 2. A `Projection` (orthographic for 2D, perspective for 3D) 3. Position via `Transform` ## Viewports Multiple cameras can render to the same window via viewports (split-screen, minimap): ```rust commands.spawn((Camera2d, Camera { viewport: Some(Viewport { .. }), ..default() })); ``` ## Coordinate system Right-handed: X→right, Y→up, Z→coming out of the screen toward the viewer ("forward" is -Z). Default screen center is (0,0). ## 2D camera movement ```rust fn move_camera(time: Res