From 96c45675d3e4edb59c83e7259b778c2d036e3e32 Mon Sep 17 00:00:00 2001 From: David McAllister Date: Sun, 27 Nov 2022 22:46:10 -0800 Subject: [PATCH] Camera Label Hiding (#1031) * ThreeJS group traversal * Isolated hiding to camera labels * Logic for hide scene addeD --- .../src/modules/SidePanel/CameraPanel/CameraPanel.jsx | 1 + .../src/modules/SidePanel/ScenePanel/ScenePanel.jsx | 8 ++++++++ .../src/modules/SidePanel/StatusPanel/StatusPanel.jsx | 11 +++++++++++ 3 files changed, 20 insertions(+) diff --git a/nerfstudio/viewer/app/src/modules/SidePanel/CameraPanel/CameraPanel.jsx b/nerfstudio/viewer/app/src/modules/SidePanel/CameraPanel/CameraPanel.jsx index dbabf0f3d0..b71266d4a4 100644 --- a/nerfstudio/viewer/app/src/modules/SidePanel/CameraPanel/CameraPanel.jsx +++ b/nerfstudio/viewer/app/src/modules/SidePanel/CameraPanel/CameraPanel.jsx @@ -631,6 +631,7 @@ export default function CameraPanel(props) { labelDiv.style.borderRadius = '6px'; labelDiv.style.visibility = 'visible'; const camera_label = new CSS2DObject(labelDiv); + camera_label.name = 'CAMERA_LABEL'; camera_label.position.set(0, -0.1, -0.1); camera_helper.add(camera_label); camera_label.layers.set(0); diff --git a/nerfstudio/viewer/app/src/modules/SidePanel/ScenePanel/ScenePanel.jsx b/nerfstudio/viewer/app/src/modules/SidePanel/ScenePanel/ScenePanel.jsx index b65d4d420d..2335201256 100644 --- a/nerfstudio/viewer/app/src/modules/SidePanel/ScenePanel/ScenePanel.jsx +++ b/nerfstudio/viewer/app/src/modules/SidePanel/ScenePanel/ScenePanel.jsx @@ -77,6 +77,14 @@ function MenuItems(props: ListItemProps) { const toggleVisible = (e) => { e.stopPropagation(); setVisible(!visible); + scene_node.object.traverse( + (obj) => { + if (obj.name === 'CAMERA_LABEL') { + // eslint-disable-next-line no-param-reassign + obj.visible = !visible; + } + } + ); }; React.useEffect(() => { diff --git a/nerfstudio/viewer/app/src/modules/SidePanel/StatusPanel/StatusPanel.jsx b/nerfstudio/viewer/app/src/modules/SidePanel/StatusPanel/StatusPanel.jsx index 972b865182..8db09c71f6 100644 --- a/nerfstudio/viewer/app/src/modules/SidePanel/StatusPanel/StatusPanel.jsx +++ b/nerfstudio/viewer/app/src/modules/SidePanel/StatusPanel/StatusPanel.jsx @@ -43,6 +43,17 @@ export default function StatusPanel(props: StatusPanelProps) { is_images_visible; } + React.useEffect(() => { + sceneTree.object.traverse( + (obj) => { + if (obj.name === 'CAMERA_LABEL') { + // eslint-disable-next-line no-param-reassign + obj.visible = is_scene_visible; + } + } + ); + }, [is_scene_visible]); + const handlePlayChange = () => { dispatch({ type: 'write',