@@ -270,6 +270,10 @@ pub struct PanOrbitCamera {
270270 /// up direction. The default up is Y, but if you want the camera rotated.
271271 /// The axis can be switched. Default is [Vec3::X, Vec3::Y, Vec3::Z]
272272 pub axis : [ Vec3 ; 3 ] ,
273+ /// Use real time instead of virtual time. Set this to `true` if you want to pause virtual
274+ /// time without affecting the camera, for example in a game.
275+ /// Defaults to `false`.
276+ pub use_real_time : bool ,
273277}
274278
275279impl Default for PanOrbitCamera {
@@ -313,6 +317,7 @@ impl Default for PanOrbitCamera {
313317 zoom_lower_limit : 0.05 ,
314318 force_update : false ,
315319 axis : [ Vec3 :: X , Vec3 :: Y , Vec3 :: Z ] ,
320+ use_real_time : false ,
316321 }
317322 }
318323}
@@ -484,7 +489,8 @@ fn pan_orbit_camera(
484489 mouse_key_tracker : Res < MouseKeyTracker > ,
485490 touch_tracker : Res < TouchTracker > ,
486491 mut orbit_cameras : Query < ( Entity , & mut PanOrbitCamera , & mut Transform , & mut Projection ) > ,
487- time : Res < Time > ,
492+ time_real : Res < Time < Real > > ,
493+ time_virt : Res < Time < Virtual > > ,
488494) {
489495 for ( entity, mut pan_orbit, mut transform, mut projection) in orbit_cameras. iter_mut ( ) {
490496 // Closures that apply limits to the yaw, pitch, and zoom values
@@ -704,6 +710,12 @@ fn pan_orbit_camera(
704710
705711 // 4 - Update the camera's transform based on current values
706712
713+ let delta = if pan_orbit. use_real_time {
714+ time_real. delta_secs ( )
715+ } else {
716+ time_virt. delta_secs ( )
717+ } ;
718+
707719 if let ( Some ( yaw) , Some ( pitch) , Some ( radius) ) =
708720 ( pan_orbit. yaw , pan_orbit. pitch , pan_orbit. radius )
709721 {
@@ -723,25 +735,25 @@ fn pan_orbit_camera(
723735 yaw,
724736 pan_orbit. target_yaw ,
725737 pan_orbit. orbit_smoothness ,
726- time . delta_secs ( ) ,
738+ delta ,
727739 ) ;
728740 let new_pitch = util:: lerp_and_snap_f32 (
729741 pitch,
730742 pan_orbit. target_pitch ,
731743 pan_orbit. orbit_smoothness ,
732- time . delta_secs ( ) ,
744+ delta ,
733745 ) ;
734746 let new_radius = util:: lerp_and_snap_f32 (
735747 radius,
736748 pan_orbit. target_radius ,
737749 pan_orbit. zoom_smoothness ,
738- time . delta_secs ( ) ,
750+ delta ,
739751 ) ;
740752 let new_focus = util:: lerp_and_snap_vec3 (
741753 pan_orbit. focus ,
742754 pan_orbit. target_focus ,
743755 pan_orbit. pan_smoothness ,
744- time . delta_secs ( ) ,
756+ delta ,
745757 ) ;
746758
747759 util:: update_orbit_transform (
0 commit comments