mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-12 19:04:03 +08:00
Fix viewer slider stepping past min/max limits (#693)
Fix viewer stepping past min/max limits
This commit is contained in:
1 parent
739e8dcff3
commit
5ec8797b16
1 file changed
+6
-5
@@ -230,13 +230,14 @@ export default function CameraPanel(props) {
|
||||
const [ui_seconds, setUISeconds] = React.useState(seconds);
|
||||
const [ui_fps, setUIfps] = React.useState(fps);
|
||||
|
||||
const total_num_steps = seconds * fps;
|
||||
const step_size = (cameras.length - 1) / total_num_steps;
|
||||
|
||||
// nonlinear render option
|
||||
const slider_min = 0;
|
||||
const slider_max = Math.max(0, cameras.length - 1);
|
||||
|
||||
// animation constants
|
||||
const total_num_steps = seconds * fps;
|
||||
const step_size = slider_max / total_num_steps;
|
||||
|
||||
const reset_slider_render_on_add = (new_camera_list) => {
|
||||
// set slider and render camera back to 0
|
||||
if (new_camera_list.length >= 1) {
|
||||
@@ -623,7 +624,7 @@ export default function CameraPanel(props) {
|
||||
<Button
|
||||
size="small"
|
||||
variant="outlined"
|
||||
onClick={() => set_slider_value(slider_value - step_size)}
|
||||
onClick={() => set_slider_value(Math.max(0.0, slider_value - step_size))}
|
||||
>
|
||||
<ArrowBackIosNewIcon />
|
||||
</Button>
|
||||
@@ -664,7 +665,7 @@ export default function CameraPanel(props) {
|
||||
<Button
|
||||
size="small"
|
||||
variant="outlined"
|
||||
onClick={() => set_slider_value(slider_value + step_size)}
|
||||
onClick={() => set_slider_value(Math.min(slider_max, slider_value + step_size))}
|
||||
>
|
||||
<ArrowForwardIosIcon />
|
||||
</Button>
|
||||
|
||||
Reference in new issue
Block a user