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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
//! Camera system for view and projection management.
//!
//! Control how the 3D scene is viewed with cameras and projections:
//!
//! - [`Camera`]: Main camera component with projection settings
//! - [`Projection`]: Perspective or orthographic projection mode
//! - [`PanOrbitCamera`]: Arc-ball style camera controller for editor-like navigation
//! - [`Smoothing`]: Input smoothing parameters for fluid camera movement
//!
//! Both projection types use reverse-Z depth for improved precision at distance.
//!
//! # Creating a Camera
//!
//! ```ignore
//! use nightshade::ecs::camera::{Camera, Projection, PerspectiveCamera};
//! use nightshade::ecs::world::CAMERA;
//!
//! let entity = world.spawn_entities(CAMERA, 1)[0];
//! world.set_camera(entity, Camera {
//! projection: Projection::Perspective(PerspectiveCamera {
//! y_fov_rad: 60.0_f32.to_radians(),
//! aspect_ratio: 16.0 / 9.0,
//! z_near: 0.1,
//! z_far: 1000.0,
//! }),
//! smoothing: None,
//! });
//! world.set_local_transform(entity, LocalTransform {
//! translation: Vec3::new(0.0, 5.0, 10.0),
//! ..Default::default()
//! });
//! world.add_local_transform_dirty(entity);
//! world.resources.active_camera = Some(entity);
//! ```
//!
//! # Pan-Orbit Camera (Editor-Style)
//!
//! The [`PanOrbitCamera`] provides arc-ball navigation around a focus point:
//!
//! ```ignore
//! use nightshade::ecs::camera::{Camera, PanOrbitCamera};
//! use nightshade::ecs::world::PAN_ORBIT_CAMERA;
//!
//! let entity = world.spawn_entities(PAN_ORBIT_CAMERA, 1)[0];
//! world.set_camera(entity, Camera::default());
//! world.set_pan_orbit_camera(entity, PanOrbitCamera::new(
//! Vec3::zeros(), // Focus point
//! 15.0, // Distance from focus
//! )
//! .with_yaw_pitch(0.5, 0.3) // Initial angles in radians
//! .with_zoom_limits(1.0, Some(100.0)) // Min/max zoom
//! .with_smoothness(0.1, 0.02, 0.1) // Orbit, pan, zoom smoothing
//! );
//!
//! world.resources.active_camera = Some(entity);
//! ```
//!
//! # Mouse and Gamepad Controls
//!
//! `PanOrbitCamera` responds to input automatically when using the camera system:
//!
//! | Input | Action |
//! |-------|--------|
//! | Left mouse drag | Orbit around focus |
//! | Right mouse drag | Pan focus point |
//! | Scroll wheel | Zoom in/out |
//! | Gamepad right stick | Orbit |
//! | Gamepad left stick | Pan |
//! | Gamepad triggers | Zoom |
//!
//! # Sensitivity Settings
//!
//! ```ignore
//! let mut pan_orbit = PanOrbitCamera::default();
//! pan_orbit.orbit_sensitivity = 0.5; // Mouse orbit speed
//! pan_orbit.pan_sensitivity = 1.0; // Mouse pan speed
//! pan_orbit.zoom_sensitivity = 0.8; // Scroll zoom speed
//! pan_orbit.gamepad_deadzone = 0.15; // Stick deadzone
//! pan_orbit.orbit_smoothness = 0.1; // Orbit interpolation (0=instant)
//! pan_orbit.pan_smoothness = 0.02; // Pan interpolation (0=instant)
//! pan_orbit.zoom_smoothness = 0.1; // Zoom interpolation (0=instant)
//! ```
//!
//! # Customizing Button Bindings
//!
//! Change which mouse buttons control orbit and pan:
//!
//! ```ignore
//! use nightshade::ecs::camera::{PanOrbitCamera, PanOrbitButton, PanOrbitModifier};
//!
//! // Use middle mouse for orbit, right mouse for pan (like some 3D software)
//! let pan_orbit = PanOrbitCamera::default()
//! .with_buttons(PanOrbitButton::Middle, PanOrbitButton::Right);
//!
//! // Require Shift key for orbit, Ctrl key for pan
//! let pan_orbit = PanOrbitCamera::default()
//! .with_modifiers(Some(PanOrbitModifier::Shift), Some(PanOrbitModifier::Control));
//!
//! // Allow camera to go upside down (pitch beyond ±90°)
//! let pan_orbit = PanOrbitCamera::default()
//! .with_upside_down(true);
//! ```
//!
//! # Touch Controls
//!
//! On touch devices, `PanOrbitCamera` supports:
//!
//! | Gesture | Action |
//! |---------|--------|
//! | Single finger drag | Orbit around focus |
//! | Two finger drag | Pan focus point |
//! | Pinch | Zoom in/out |
//!
//! # Orthographic Camera
//!
//! For 2D games, isometric views, or CAD-style rendering:
//!
//! ```ignore
//! use nightshade::ecs::camera::{Camera, Projection, OrthographicCamera};
//!
//! world.set_camera(entity, Camera {
//! projection: Projection::Orthographic(OrthographicCamera {
//! left: -10.0,
//! right: 10.0,
//! bottom: -10.0,
//! top: 10.0,
//! z_near: 0.1,
//! z_far: 100.0,
//! }),
//! smoothing: None,
//! });
//! ```
//!
//! # Updating FOV at Runtime
//!
//! ```ignore
//! if let Some(camera) = world.get_camera_mut(camera_entity) {
//! if let Projection::Perspective(ref mut perspective) = camera.projection {
//! perspective.y_fov_rad = 90.0_f32.to_radians();
//! }
//! }
//! ```
//!
//! # Setting Focus Point
//!
//! Move the pan-orbit camera to look at a new target:
//!
//! ```ignore
//! if let Some(pan_orbit) = world.get_pan_orbit_camera_mut(camera_entity) {
//! pan_orbit.target_focus = Vec3::new(10.0, 0.0, 5.0);
//! // Camera will smoothly interpolate to new focus
//! }
//! ```
//!
//! [`Camera`]: components::Camera
//! [`Projection`]: components::Projection
//! [`PanOrbitCamera`]: components::PanOrbitCamera
//! [`Smoothing`]: components::Smoothing
pub use *;
pub use *;
pub use *;
pub use *;