pub struct Rig3 {
pub shake: CameraShake,
/* private fields */
}Expand description
Copyable complete presentation state; update errors preserve it unchanged.
Fields§
§shake: CameraShakeImplementations§
Source§impl Rig3
impl Rig3
pub fn new(settings: Settings3) -> Result<Rig3, CameraError>
pub fn settings(&self) -> Settings3
pub fn set_settings(&mut self, settings: Settings3) -> Result<(), CameraError>
Sourcepub fn pose(&self) -> Option<Pose3>
pub fn pose(&self) -> Option<Pose3>
Last successful pose, or None before initialization or after Self::reset.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Forget the pose, damping, orbit and obstruction history, retaining settings.
Clears active shake without replacing its configured seed or sequence. The next valid update initializes directly, even with zero elapsed time. Shake queued after resetting belongs to the new scene and is retained.
use ferravex_play::camera::Rig3;
let mut camera = Rig3::default();
let tuning = camera.settings();
camera.reset(); // The restarted scene has not supplied its spawn yet.
assert_eq!(camera.pose(), None);
assert_eq!(camera.settings(), tuning);Sourcepub fn cut(&mut self)
pub fn cut(&mut self)
Cut on the next valid update and discard current presentation shake. The last pose remains available; shake queued after this call is retained.
Sourcepub fn snap(
&mut self,
input: Input3,
collision: &(impl CollisionQuery + ?Sized),
) -> Result<Frame3, CameraError>
pub fn snap( &mut self, input: Input3, collision: &(impl CollisionQuery + ?Sized), ) -> Result<Frame3, CameraError>
Immediately initialize or relocate the camera, clearing current shake.
Position, look target, FOV and orbit state snap to input; obstruction
still constrains the boom, without sweeping from the old scene’s pose.
Subsequent updates smooth from the new state with the same settings.
Input or collision errors preserve the complete previous camera state,
including shake and pending cuts. Queue new-scene shake after this call.
use ferravex_math::Vec3;
use ferravex_play::camera::{Input3, Mode3, NoObstructions, Rig3, Target3};
let mut camera = Rig3::default();
let frame = camera.snap(Input3 {
target: Target3::at(Vec3::X * 100.),
mode: Mode3::Follow {
eye_offset: Vec3::Z * 10., look_offset: Vec3::ZERO,
},
fov_y: 1.,
}, &NoObstructions)?;
assert!(frame.cut);
assert_eq!(frame.pose.position, Vec3::new(100., 0., 10.));Sourcepub fn update(
&mut self,
dt: f32,
input: Input3,
collision: &(impl CollisionQuery + ?Sized),
) -> Result<Frame3, CameraError>
pub fn update( &mut self, dt: f32, input: Input3, collision: &(impl CollisionQuery + ?Sized), ) -> Result<Frame3, CameraError>
Advance presentation with elapsed seconds in 0..=0.25.
Invalid or larger timesteps return CameraError::InvalidInput and leave
all state unchanged. Use Self::snap after a long host suspension if an
immediate view of the current target is desired. Zero time freezes damping
and shake time; initialization, cuts, first-person aim and collision still
apply. Automatic teleports and mode changes cut and clear old shake.