wde_camera_controller/lib.rs
1//! A collection of camera controllers for Bevy.
2//!
3//! This crate provides a set of camera controllers that can be easily integrated the applications.
4//! It includes a:
5//! - [`FreeCameraController`](free_camera_controller::FreeCameraController) for first-person navigation.
6//! - [`ThirdPersonController`](third_person_controller::ThirdPersonController) for third-person perspectives.
7//!
8//! To use the camera controllers, simply add the corresponding controller component to your camera entity.
9//! For example, to use the [`ThirdPersonController`](third_person_controller::ThirdPersonController), you can spawn a camera entity like this:
10//!
11//! ```rust
12//! commands.spawn((
13//! Transform::from_xyz(0.0, 2.0, 6.0).looking_at(Vec3::ZERO, Vec3::Y),
14//! ActiveCamera,
15//! ThirdPersonController::default(),
16//! ));
17//!```
18
19use bevy::prelude::*;
20
21#[cfg(debug_assertions)]
22use crate::editor::CameraPropertiesEditor;
23use crate::{
24 free_camera_controller::FreeCameraControllerPlugin,
25 third_person_controller::ThirdPersonControllerPlugin
26};
27
28#[doc(hidden)]
29pub mod prelude {
30 pub use crate::free_camera_controller::FreeCameraController;
31 pub use crate::third_person_controller::ThirdPersonController;
32}
33
34mod editor;
35mod free_camera_controller;
36mod third_person_controller;
37
38pub struct CameraControllerPlugin;
39impl Plugin for CameraControllerPlugin {
40 fn build(&self, app: &mut App) {
41 app.add_plugins((FreeCameraControllerPlugin, ThirdPersonControllerPlugin));
42
43 #[cfg(debug_assertions)]
44 app.add_plugins(CameraPropertiesEditor);
45 }
46}