Fix timestep for globe rotation

This commit is contained in:
Tobias Berger 2022-11-06 12:10:55 +01:00
parent 5a24a885b6
commit 489733bd50
Signed by: toby
GPG key ID: 2D05EFAB764D6A88

View file

@ -67,6 +67,7 @@ use {
prelude::{Quat, Vec3},
render::camera::OrthographicProjection,
render::mesh::{shape::UVSphere, Mesh},
time::Time,
transform::components::Transform,
},
std::f32::consts::FRAC_PI_2,
@ -105,10 +106,15 @@ fn update_cursor_map_position(
}
#[cfg(all(feature = "render", feature = "globe_view"))]
const ROTATION_SPEED: f32 = 0.002;
const GLOBE_ROTATIONS_PER_SECOND: f32 = std::f32::consts::TAU / 15.0;
#[cfg(all(feature = "render", feature = "globe_view"))]
fn rotate_globe(mut globe_transform: Query<'_, '_, &mut Transform, With<Handle<Mesh>>>) {
globe_transform.single_mut().rotate_y(ROTATION_SPEED);
fn rotate_globe(
mut globe_transform: Query<'_, '_, &mut Transform, With<Handle<Mesh>>>,
time: Res<Time>,
) {
globe_transform
.single_mut()
.rotate_y(GLOBE_ROTATIONS_PER_SECOND * time.delta_seconds());
}
#[cfg(feature = "render")]