Open-Source Wikis

/

Bevy

/

Packages

/

bevy_camera

bevyengine/bevy

bevy_camera

The data-only crate for cameras and visibility. Holds Camera, Projection, Viewport, RenderLayers, and the visibility components without taking a dependency on the renderer. The renderer reads from these types each frame.

Purpose

Splitting cameras out of bevy_render lets users compose game-logic-only apps (or alternative renderers) that still want a Camera component for picking/raycasting without the wgpu dependency.

The crate provides:

  • Camera — the canonical camera component.
  • Projection typesPerspectiveProjection, OrthographicProjection.
  • VisibilityVisibility, InheritedVisibility, ViewVisibility, RenderLayers.
  • Frustum culling primitivesFrustum, Aabb, CubemapFrusta.
  • Sub-camera support via viewport rectangles.
  • ClearColor resource and ClearColorConfig per-camera.

Directory layout

crates/bevy_camera/src/
├── lib.rs            # CameraPlugin (registers components)
├── camera.rs         # Camera component, RenderTarget enum, Viewport
├── projection.rs     # Projection trait, perspective, orthographic
├── visibility/       # Visibility components, RenderLayers, ViewVisibility
├── primitives.rs     # Frustum, Aabb, CubemapFrusta
└── clear_color.rs    # ClearColor resource

Key abstractions

Type File Description
Camera crates/bevy_camera/src/camera.rs The canonical camera component.
Projection crates/bevy_camera/src/projection.rs Enum: Perspective / Orthographic / custom.
Viewport crates/bevy_camera/src/camera.rs Sub-rectangle of the render target.
RenderLayers crates/bevy_camera/src/visibility/render_layers.rs Bitmask filter for which entities a camera renders.
Visibility / InheritedVisibility / ViewVisibility crates/bevy_camera/src/visibility/ Per-entity visibility flags.
Frustum crates/bevy_camera/src/primitives.rs Six-plane frustum for culling.
ClearColor crates/bevy_camera/src/clear_color.rs Default clear color resource.

How it works

A Camera component plus a Transform plus a Projection is enough for the renderer to compute view and projection matrices. bevy_render::camera (in the renderer crate) extracts these into the render world and produces ViewUniform data each frame.

Visibility is the user-facing toggle. InheritedVisibility propagates parent visibility down the hierarchy. ViewVisibility is the per-camera flag that frustum culling and RenderLayers filter set in PostUpdate. The renderer only extracts entities with ViewVisibility::TRUE.

Integration points

  • Depends on: bevy_app, bevy_ecs, bevy_math, bevy_color, bevy_transform, bevy_image (for RenderTarget::Image), bevy_window.
  • Depended on by: bevy_render, bevy_pbr, bevy_picking, bevy_camera_controller, bevy_gizmos, anything that does ray casting.

Entry points for modification

  • New projection type: add a variant to Projection in projection.rs and implement the matrix code.
  • New visibility filter: see RenderLayers for the pattern.
  • Sub-camera ergonomics: Camera::sub_camera_view. Used for split-screen.

See also

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

bevy_camera – Bevy wiki | Factory