12
12
13
13
use bevy:: {
14
14
color:: palettes:: {
15
- css:: { ORANGE , RED , WHITE } ,
15
+ css:: WHITE ,
16
16
tailwind:: { CYAN_400 , RED_400 } ,
17
17
} ,
18
18
ecs:: schedule:: ScheduleLabel ,
@@ -59,8 +59,6 @@ fn main() {
59
59
interpolation_plugin,
60
60
) ) ;
61
61
62
- // Set the fixed timestep to just 5 Hz for demonstration purposes.
63
-
64
62
// Setup the scene and UI, and update text in `Update`.
65
63
app. add_systems ( Startup , ( setup, setup_text) ) . add_systems (
66
64
bevy:: app:: prelude:: RunFixedMainLoop ,
@@ -71,8 +69,6 @@ fn main() {
71
69
) ,
72
70
) ;
73
71
74
- // This runs every frame to poll if our task was done.
75
-
76
72
app. add_systems (
77
73
bevy:: app:: prelude:: RunFixedMainLoop ,
78
74
( ease_translation_lerp, ease_rotation_slerp, ease_scale_lerp)
@@ -82,6 +78,7 @@ fn main() {
82
78
// Run the app.
83
79
app. run ( ) ;
84
80
}
81
+
85
82
/// Eases the translations of entities with linear interpolation.
86
83
fn ease_translation_lerp (
87
84
mut query : Query < ( & mut Transform , & TranslationEasingState ) > ,
@@ -147,8 +144,8 @@ fn setup(
147
144
let mesh = meshes. add ( Rectangle :: from_length ( 60.0 ) ) ;
148
145
149
146
commands. spawn ( (
150
- TaskToRenderTime :: default ( ) ,
151
147
Timestep {
148
+ // Set the fixed timestep to just 5 Hz for demonstration purposes.
152
149
timestep : Duration :: from_secs_f32 ( 0.5 ) ,
153
150
} ,
154
151
TaskResults :: < TaskWorkerTraitImpl > :: default ( ) ,
@@ -293,7 +290,6 @@ pub mod task_user {
293
290
294
291
use bevy:: prelude:: * ;
295
292
use bevy_transform_interpolation:: background_fixed_schedule:: TaskWorkerTrait ;
296
- use rand:: { thread_rng, Rng } ;
297
293
298
294
#[ derive( Debug , Clone , Default ) ]
299
295
pub struct TaskWorkerTraitImpl ;
@@ -309,9 +305,8 @@ pub mod task_user {
309
305
substep_count : u32 ,
310
306
) -> Vec < ( Entity , Transform , LinearVelocity , AngularVelocity ) > {
311
307
let simulated_time = timestep * substep_count;
312
- let to_simulate = simulated_time. as_millis ( ) as u64 ;
313
308
// Simulate an expensive task
314
- std:: thread:: sleep ( Duration :: from_millis ( thread_rng ( ) . gen_range ( 200 .. 201 ) ) ) ;
309
+ std:: thread:: sleep ( Duration :: from_millis ( 200 ) ) ;
315
310
316
311
// Move entities in a fixed amount of time. The movement should appear smooth for interpolated entities.
317
312
flip_movement_direction (
0 commit comments