Repository: bevyengine/bevy
File: examples/usage/debug_frustum_culling.rs (Rust)

Code before:
//! This example demonstrates how to debug and visualize frustum culling,
//! a process (and Bevy [`system`](bevy::camera::visibility::check_visibility)) that determines
//! which entities are visible and should be rendered within
//! a camera's view. If an entity's [`Aabb`](bevy::camera::primitives::Aabb)
//! (Axis-Aligned Bounding Box) does not intersect with a camera's
//! [`Frustum`](bevy::camera::primitives::Frustum), that entity is said to be "culled"
//! from the camera's view frustum.
//!
//! To debug and visualize frustum culling, this example uses Aabb and Frustum gizmos provided
//! by bevy's [`Gizmo`] library. [`Aabb gizmos`](bevy::gizmos::aabb) are used to visualize the
//! [`Aabb`](bevy::camera::primitives::Aabb) of entities.
//! [`Frustum gizmos`](bevy::gizmos::frustum) are used to visualize the
//! [`Frustum`](bevy::camera::primitives::Frustum) of a camera.
//! Both can be used together to visualize which entities have been culled
//! from a given camera's view, which entities are visible, and when
//! that change happens during an entity's Aabb interaction with a camera's Frustum.
//!
//! This example contains a scene with a camera [`MyCamera`] that has its
//! [`Frustum`](bevy::camera::primitives::Frustum) gizmo visible.
//! A collection of [`MyShape`]s, with their individual
//! [`Aabb`](bevy::camera::primitives::Aabb) gizmos visible, periodically move in and
//! out of the camera's frustum. The [`Aabb`](bevy::camera::primitives::Aabb)
//! gizmos are colored red when they have been culled from [`MyCamera`]'s view.
//! They gizmos change color to green when the shape is considered visible by the
//! camera and would be extracted for rendering.
//!
//! A second active camera, controllable via the [`FreeCameraPlugin`], is used to observe the scene.
//! This second camera's view occupies most of the window. [`MyCamera`]'s view is visible in the
//! bottom right ninth of the screen.

use bevy::{
    camera::{
        visibility::{VisibilitySystems, VisibleEntities},
        Viewport,
    },
    camera_controller::free_camera::{FreeCamera, FreeCameraPlugin, FreeCameraState},
    gizmos::aabb::ShowAabbGizmo,
    input::common_conditions::input_just_pressed,
    prelude::*,
};
use std::f32::consts::PI;

fn main() {
    App::new()
        .add_plugins((
            DefaultPlugins.set(WindowPlugin {
                primary_window: Some(Window {
                    resizable: false,
                    ..default()

Review comment (suggestion):
```suggestion
//! The gizmos change color to green when the shape is considered visible by the
```

Code after:
//! This example demonstrates how to debug and visualize frustum culling,
//! a process (and Bevy [`system`](bevy::camera::visibility::check_visibility)) that determines
//! which entities are visible and should be rendered within
//! a camera's view. If an entity's [`Aabb`](bevy::camera::primitives::Aabb)
//! (Axis-Aligned Bounding Box) does not intersect with a camera's
//! [`Frustum`](bevy::camera::primitives::Frustum), that entity is said to be "culled"
//! from the camera's view frustum.
//!
//! To debug and visualize frustum culling, this example uses Aabb and Frustum gizmos provided
//! by bevy's [`Gizmo`] library. [`Aabb gizmos`](bevy::gizmos::aabb) are used to visualize the
//! [`Aabb`](bevy::camera::primitives::Aabb) of entities.
//! [`Frustum gizmos`](bevy::gizmos::frustum) are used to visualize the
//! [`Frustum`](bevy::camera::primitives::Frustum) of a camera.
//! Both can be used together to visualize which entities have been culled
//! from a given camera's view, which entities are visible, and when
//! that change happens during an entity's Aabb interaction with a camera's Frustum.
//!
//! This example contains a scene with a camera [`MyCamera`] that has its
//! [`Frustum`](bevy::camera::primitives::Frustum) gizmo visible.
//! A collection of [`MyShape`]s, with their individual
//! [`Aabb`](bevy::camera::primitives::Aabb) gizmos visible, periodically move in and
//! out of the camera's frustum. The [`Aabb`](bevy::camera::primitives::Aabb)
//! gizmos are colored red when they have been culled from [`MyCamera`]'s view.
//! The gizmos change color to green when the shape is considered visible by the
//! camera and would be extracted for rendering.
//!
//! A second active camera, controllable via the [`FreeCameraPlugin`], is used to observe the scene.
//! This second camera's view occupies most of the window. [`MyCamera`]'s view is visible in the
//! bottom right ninth of the screen.

use bevy::{
    camera::{
        visibility::{VisibilitySystems, VisibleEntities},
        Viewport,
    },
    camera_controller::free_camera::{FreeCamera, FreeCameraPlugin, FreeCameraState},
    gizmos::aabb::ShowAabbGizmo,
    input::common_conditions::input_just_pressed,
    prelude::*,
};
use std::f32::consts::PI;

fn main() {
    App::new()
        .add_plugins((
            DefaultPlugins.set(WindowPlugin {
                primary_window: Some(Window {
                    resizable: false,
                    ..default()