Skip to content

Commit

Permalink
Camera Label Hiding (nerfstudio-project#1031)
Browse files Browse the repository at this point in the history
* ThreeJS group traversal

* Isolated hiding to camera labels

* Logic for hide scene addeD
  • Loading branch information
mcallisterdavid authored Nov 28, 2022
1 parent 38479c6 commit 96c4567
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 96c4567

Please sign in to comment.