Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions examples/gizmos/2d_gizmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ fn setup(mut commands: Commands) {
Hold 'Up' or 'Down' to change the line width of round gizmos\n\
Press '1' / '2' to toggle the visibility of straight / round gizmos\n\
Press 'U' / 'I' to cycle through line styles\n\
Press 'J' / 'K' to cycle through line joins",
Press 'J' / 'K' to cycle through line joins\n\
Press 'Spacebar' to toggle pause",
),
Node {
position_type: PositionType::Absolute,
Expand Down Expand Up @@ -125,15 +126,16 @@ fn draw_example_collection(
fn update_config(
mut config_store: ResMut<GizmoConfigStore>,
keyboard: Res<ButtonInput<KeyCode>>,
time: Res<Time>,
real_time: Res<Time<Real>>,
mut virtual_time: ResMut<Time<Virtual>>,
) {
let (config, _) = config_store.config_mut::<DefaultGizmoConfigGroup>();
if keyboard.pressed(KeyCode::ArrowRight) {
config.line.width += 5. * time.delta_secs();
config.line.width += 5. * real_time.delta_secs();
config.line.width = config.line.width.clamp(0., 50.);
}
if keyboard.pressed(KeyCode::ArrowLeft) {
config.line.width -= 5. * time.delta_secs();
config.line.width -= 5. * real_time.delta_secs();
config.line.width = config.line.width.clamp(0., 50.);
}
if keyboard.just_pressed(KeyCode::Digit1) {
Expand Down Expand Up @@ -179,11 +181,11 @@ fn update_config(

let (my_config, _) = config_store.config_mut::<MyRoundGizmos>();
if keyboard.pressed(KeyCode::ArrowUp) {
my_config.line.width += 5. * time.delta_secs();
my_config.line.width += 5. * real_time.delta_secs();
my_config.line.width = my_config.line.width.clamp(0., 50.);
}
if keyboard.pressed(KeyCode::ArrowDown) {
my_config.line.width -= 5. * time.delta_secs();
my_config.line.width -= 5. * real_time.delta_secs();
my_config.line.width = my_config.line.width.clamp(0., 50.);
}
if keyboard.just_pressed(KeyCode::Digit2) {
Expand All @@ -207,4 +209,11 @@ fn update_config(
GizmoLineJoint::None => GizmoLineJoint::Bevel,
};
}
if keyboard.just_pressed(KeyCode::Space) {
if virtual_time.is_paused() {
virtual_time.unpause();
} else {
virtual_time.pause();
}
}
}
21 changes: 15 additions & 6 deletions examples/gizmos/3d_gizmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ fn setup(
Press '1' or '2' to toggle the visibility of straight gizmos or round gizmos\n\
Press 'B' to show all AABB boxes\n\
Press 'U' or 'I' to cycle through line styles for straight or round gizmos\n\
Press 'J' or 'K' to cycle through line joins for straight or round gizmos",
Press 'J' or 'K' to cycle through line joins for straight or round gizmos\n\
Press 'Spacebar' to toggle pause",
),
Node {
position_type: PositionType::Absolute,
Expand Down Expand Up @@ -206,7 +207,8 @@ fn draw_example_collection(
fn update_config(
mut config_store: ResMut<GizmoConfigStore>,
keyboard: Res<ButtonInput<KeyCode>>,
time: Res<Time>,
real_time: Res<Time<Real>>,
mut virtual_time: ResMut<Time<Virtual>>,
) {
if keyboard.just_pressed(KeyCode::KeyT) {
for (_, config, _) in config_store.iter_mut() {
Expand All @@ -224,11 +226,11 @@ fn update_config(

let (config, _) = config_store.config_mut::<DefaultGizmoConfigGroup>();
if keyboard.pressed(KeyCode::ArrowRight) {
config.line.width += 5. * time.delta_secs();
config.line.width += 5. * real_time.delta_secs();
config.line.width = config.line.width.clamp(0., 50.);
}
if keyboard.pressed(KeyCode::ArrowLeft) {
config.line.width -= 5. * time.delta_secs();
config.line.width -= 5. * real_time.delta_secs();
config.line.width = config.line.width.clamp(0., 50.);
}
if keyboard.just_pressed(KeyCode::Digit1) {
Expand All @@ -255,11 +257,11 @@ fn update_config(

let (my_config, _) = config_store.config_mut::<MyRoundGizmos>();
if keyboard.pressed(KeyCode::ArrowUp) {
my_config.line.width += 5. * time.delta_secs();
my_config.line.width += 5. * real_time.delta_secs();
my_config.line.width = my_config.line.width.clamp(0., 50.);
}
if keyboard.pressed(KeyCode::ArrowDown) {
my_config.line.width -= 5. * time.delta_secs();
my_config.line.width -= 5. * real_time.delta_secs();
my_config.line.width = my_config.line.width.clamp(0., 50.);
}
if keyboard.just_pressed(KeyCode::Digit2) {
Expand Down Expand Up @@ -289,4 +291,11 @@ fn update_config(
// We can change this behavior in the configuration of AabbGizmoGroup
config_store.config_mut::<AabbGizmoConfigGroup>().1.draw_all ^= true;
}
if keyboard.just_pressed(KeyCode::Space) {
if virtual_time.is_paused() {
virtual_time.unpause();
} else {
virtual_time.pause();
}
}
}