Add imgui slider command to the debug ui buffer implementation

This commit is contained in:
reo 2025-09-25 13:01:02 +03:00
parent 84ab3a26b1
commit f34a9b01a0
2 changed files with 17 additions and 2 deletions

View file

@ -34,10 +34,14 @@ impl System for UpdateAspectRatioSystem {
}
#[derive(Default)]
struct RenderingTestSystem;
struct RenderingTestSystem {
rotation_speed: std::rc::Rc<std::cell::RefCell<f32>>,
}
impl System for RenderingTestSystem {
fn load_world(&mut self, ctx: &mut SystemContext) {
self.rotation_speed = std::rc::Rc::new(std::cell::RefCell::new(5.0));
ctx.scene.world.spawn((Camera {
eye: Vec3::new(0.0, 0.0, 2.0),
center: Vec3::ZERO,
@ -67,11 +71,12 @@ impl System for RenderingTestSystem {
dbg_ui.text("Hello World!".to_owned());
dbg_ui.text(format!("Frame Delta: {}", ctx.platform_context.time_ctx.frame_dt));
dbg_ui.text(format!("Fixed Delta: {}", ctx.platform_context.time_ctx.fixed_dt));
dbg_ui.slider_f32("Rotation Speed", -10.0, 10.0, self.rotation_speed.clone());
}
fn fixed_update(&mut self, ctx: &mut SystemContext) {
ctx.scene.world.query_mut::<(&mut Transform, &ModelHandle)>().into_iter().for_each(|(_, (t, _))| {
t.rotation *= Quat::from_rotation_y(10.0 * ctx.platform_context.time_ctx.fixed_dt);
t.rotation *= Quat::from_rotation_y(*self.rotation_speed.borrow() * ctx.platform_context.time_ctx.fixed_dt);
});
}