Fix timestep for globe rotation
This commit is contained in:
parent
5a24a885b6
commit
489733bd50
1 changed files with 9 additions and 3 deletions
12
src/main.rs
12
src/main.rs
|
@ -67,6 +67,7 @@ use {
|
||||||
prelude::{Quat, Vec3},
|
prelude::{Quat, Vec3},
|
||||||
render::camera::OrthographicProjection,
|
render::camera::OrthographicProjection,
|
||||||
render::mesh::{shape::UVSphere, Mesh},
|
render::mesh::{shape::UVSphere, Mesh},
|
||||||
|
time::Time,
|
||||||
transform::components::Transform,
|
transform::components::Transform,
|
||||||
},
|
},
|
||||||
std::f32::consts::FRAC_PI_2,
|
std::f32::consts::FRAC_PI_2,
|
||||||
|
@ -105,10 +106,15 @@ fn update_cursor_map_position(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "render", feature = "globe_view"))]
|
#[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"))]
|
#[cfg(all(feature = "render", feature = "globe_view"))]
|
||||||
fn rotate_globe(mut globe_transform: Query<'_, '_, &mut Transform, With<Handle<Mesh>>>) {
|
fn rotate_globe(
|
||||||
globe_transform.single_mut().rotate_y(ROTATION_SPEED);
|
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")]
|
#[cfg(feature = "render")]
|
||||||
|
|
Loading…
Reference in a new issue