|
1 | 1 | use bevy::prelude::*;
|
2 |
| - |
3 |
| -mod rig; |
| 2 | +use dolly::prelude::*; |
4 | 3 |
|
5 | 4 | mod commands;
|
6 | 5 | pub use commands::OgleCommandExt;
|
@@ -28,14 +27,76 @@ pub enum OgleMode {
|
28 | 27 | Frozen,
|
29 | 28 | /// The camera should exponentially follow its target.
|
30 | 29 | Following,
|
31 |
| - /// The camera is being choreographed and should mirror its target position exactly. |
32 |
| - /// |
33 |
| - /// This is useful when the camera follows a spline, or you don't want loose following behavior. |
34 |
| - Choreographed, |
35 | 30 | /// The camera is in a detached pancam mode.
|
36 | 31 | Pancam,
|
37 | 32 | }
|
38 | 33 |
|
| 34 | +#[derive(Resource, Deref, DerefMut)] |
| 35 | +pub struct OgleRig(CameraRig); |
| 36 | + |
| 37 | +impl Default for OgleRig { |
| 38 | + fn default() -> Self { |
| 39 | + let pos = mint::Point3 { |
| 40 | + x: 0.0, |
| 41 | + y: 0.0, |
| 42 | + z: 1.0, |
| 43 | + }; |
| 44 | + Self( |
| 45 | + CameraRig::builder() |
| 46 | + .with(Position::new(pos)) |
| 47 | + .with(Arm::new(pos)) |
| 48 | + .with(Smooth::new_position(1.5).predictive(false)) |
| 49 | + .build(), |
| 50 | + ) |
| 51 | + } |
| 52 | +} |
| 53 | + |
| 54 | +#[derive(Resource, Debug, Clone, Copy, PartialEq)] |
| 55 | +pub struct OgleSettings { |
| 56 | + /// The minimum scale for the camera |
| 57 | + /// |
| 58 | + /// The orthographic projection's scale will be clamped at this value when zooming in |
| 59 | + pub min_scale: f32, |
| 60 | + /// The maximum scale for the camera |
| 61 | + /// |
| 62 | + /// If present, the orthographic projection's scale will be clamped at |
| 63 | + /// this value when zooming out. |
| 64 | + pub max_scale: Option<f32>, |
| 65 | + /// The minimum x position of the camera window |
| 66 | + /// |
| 67 | + /// If present, the orthographic projection will be clamped to this boundary both |
| 68 | + /// when dragging the window, and zooming out. |
| 69 | + pub min_x: Option<f32>, |
| 70 | + /// The maximum x position of the camera window |
| 71 | + /// |
| 72 | + /// If present, the orthographic projection will be clamped to this boundary both |
| 73 | + /// when dragging the window, and zooming out. |
| 74 | + pub max_x: Option<f32>, |
| 75 | + /// The minimum y position of the camera window |
| 76 | + /// |
| 77 | + /// If present, the orthographic projection will be clamped to this boundary both |
| 78 | + /// when dragging the window, and zooming out. |
| 79 | + pub min_y: Option<f32>, |
| 80 | + /// The maximum y position of the camera window |
| 81 | + /// |
| 82 | + /// If present, the orthographic projection will be clamped to this boundary both |
| 83 | + /// when dragging the window, and zooming out. |
| 84 | + pub max_y: Option<f32>, |
| 85 | +} |
| 86 | + |
| 87 | +impl Default for OgleSettings { |
| 88 | + fn default() -> Self { |
| 89 | + Self { |
| 90 | + min_scale: -(1.0 - 0.00001), |
| 91 | + max_scale: None, |
| 92 | + min_x: None, |
| 93 | + max_x: None, |
| 94 | + min_y: None, |
| 95 | + max_y: None, |
| 96 | + } |
| 97 | + } |
| 98 | +} |
| 99 | + |
39 | 100 | pub mod prelude {
|
40 |
| - pub use super::{OgleCommandExt, OgleMode, OgleTarget}; |
| 101 | + pub use super::{OgleCommandExt, OgleMode, OgleRig, OgleSettings, OgleTarget}; |
41 | 102 | }
|
0 commit comments