Skip to content

Commit

Permalink
Fix unable to set camera spinning until camera has moved (#2990)
Browse files Browse the repository at this point in the history
Fixes #2892

Thought this was related to blueprint system overwriting, but it was
something else entirely actually: The "interpolate to"-method would set
spin to false and we would interpolate to whatever the latest default
position of the camera is until it is moved first.

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2990) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/2990)
- [Docs
preview](https://rerun.io/preview/pr%3Aandreas%2Ffix-non-sticky-spinbox/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Aandreas%2Ffix-non-sticky-spinbox/examples)
  • Loading branch information
Wumpf authored Aug 15, 2023
1 parent 67ba639 commit 1339fdd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 5 additions & 2 deletions crates/re_space_view_spatial/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,11 @@ impl SpatialSpaceViewState {
{
self.state_3d.reset_camera(&self.scene_bbox_accum, &view_coordinates);
}
re_ui.checkbox(ui, &mut self.state_3d.spin, "Spin")
.on_hover_text("Spin camera around the orbit center");
let mut spin = self.state_3d.spin();
if re_ui.checkbox(ui, &mut spin, "Spin")
.on_hover_text("Spin camera around the orbit center").changed() {
self.state_3d.set_spin(spin);
}
}
});
ui.end_row();
Expand Down
11 changes: 10 additions & 1 deletion crates/re_space_view_spatial/src/ui_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub struct View3DState {
eye_interpolation: Option<EyeInterpolation>,

// options:
pub spin: bool,
spin: bool,
pub show_axes: bool,
pub show_bbox: bool,
pub show_accumulated_bbox: bool,
Expand Down Expand Up @@ -205,6 +205,15 @@ impl View3DState {
self.orbit_eye = Some(target);
}
}

pub fn spin(&self) -> bool {
self.spin
}

pub fn set_spin(&mut self, spin: bool) {
self.spin = spin;
self.did_interact_with_eye = true;
}
}

#[derive(Clone, PartialEq)]
Expand Down

0 comments on commit 1339fdd

Please sign in to comment.