mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-04 14:58:55 +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_seconds, setUISeconds] = React.useState(seconds);
|
||||||
const [ui_fps, setUIfps] = React.useState(fps);
|
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
|
// nonlinear render option
|
||||||
const slider_min = 0;
|
const slider_min = 0;
|
||||||
const slider_max = Math.max(0, cameras.length - 1);
|
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) => {
|
const reset_slider_render_on_add = (new_camera_list) => {
|
||||||
// set slider and render camera back to 0
|
// set slider and render camera back to 0
|
||||||
if (new_camera_list.length >= 1) {
|
if (new_camera_list.length >= 1) {
|
||||||
@@ -623,7 +624,7 @@ export default function CameraPanel(props) {
|
|||||||
<Button
|
<Button
|
||||||
size="small"
|
size="small"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onClick={() => set_slider_value(slider_value - step_size)}
|
onClick={() => set_slider_value(Math.max(0.0, slider_value - step_size))}
|
||||||
>
|
>
|
||||||
<ArrowBackIosNewIcon />
|
<ArrowBackIosNewIcon />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -664,7 +665,7 @@ export default function CameraPanel(props) {
|
|||||||
<Button
|
<Button
|
||||||
size="small"
|
size="small"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onClick={() => set_slider_value(slider_value + step_size)}
|
onClick={() => set_slider_value(Math.min(slider_max, slider_value + step_size))}
|
||||||
>
|
>
|
||||||
<ArrowForwardIosIcon />
|
<ArrowForwardIosIcon />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Reference in new issue
Block a user