1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use *;
use crate::;
/// Add this plugin, add a RatatuiCamera component to your camera, and then a RatatuiCameraWidget
/// component will be made available in your camera entity. Use the RatatuiContext provided by
/// bevy_ratatui and this widget to draw the camera's rendered output to the terminal.
///
/// # Example:
///
/// ```no_run
/// # use std::time::Duration;
/// # use bevy::app::ScheduleRunnerPlugin;
/// # use bevy::winit::WinitPlugin;
/// # use bevy::prelude::*;
/// # use bevy::log::LogPlugin;
/// # use bevy_ratatui::RatatuiPlugins;
/// # use bevy_ratatui::RatatuiContext;
/// # use bevy_ratatui_camera::{RatatuiCamera, RatatuiCameraPlugin, RatatuiCameraWidget};
/// # use ratatui::prelude::Widget;
/// #
/// fn main() {
/// App::new()
/// .add_plugins((
/// // disable WinitPlugin as it panics in environments without a display server.
/// // disable LogPlugin as it interferes with terminal output.
/// DefaultPlugins.build()
/// .disable::<WinitPlugin>()
/// .disable::<LogPlugin>(),
///
/// // create windowless loop and set its frame rate.
/// ScheduleRunnerPlugin::run_loop(Duration::from_secs_f64(1. / 60.)),
///
/// // set up the Ratatui context and forward terminal input events.
/// RatatuiPlugins::default(),
///
/// // add the ratatui camera plugin.
/// RatatuiCameraPlugin,
/// ))
/// .add_systems(Startup, setup_scene_system)
/// .add_systems(PostUpdate, draw_scene_system);
/// }
///
/// // add RatatuiCamera to your scene's camera.
/// fn setup_scene_system(mut commands: Commands) {
/// commands.spawn((
/// Camera3d::default(),
/// RatatuiCamera::default(),
/// ));
/// }
///
/// // a RatatuiCameraWidget component will be available in your camera entity.
/// fn draw_scene_system(
/// mut ratatui: ResMut<RatatuiContext>,
/// mut camera_widget: Single<&mut RatatuiCameraWidget>,
/// ) -> Result {
/// ratatui.draw(|frame| {
/// camera_widget.render(frame.area(), frame.buffer_mut());
/// })?;
///
/// Ok(())
/// }
/// ```
///
;