Skip to content

Commit

Permalink
Rename + show if logging camera
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Jan 4, 2025
1 parent 3d69f24 commit d49af89
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/viser/client/src/CameraControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,24 @@ import { computeT_threeworld_world } from "./WorldTransformUtils";
import { useThrottledMessageSender } from "./WebsocketFunctions";
import { Grid, PivotControls } from "@react-three/drei";

function CameraOrientationTool({
function OrbitOriginTool({
forceShow,
pivotRef,
onPivotChange,
update,
}: {
forceShow: boolean;
pivotRef: React.RefObject<THREE.Group>;
onPivotChange: (matrix: THREE.Matrix4) => void;
update: () => void;
}) {
const viewer = useContext(ViewerContext)!;
const showCameraControls = viewer.useGui(
(state) => state.showCameraControlsTool,
(state) => state.showOrbitOriginTool,
);
React.useEffect(update, [showCameraControls]);

if (!showCameraControls) return null;
if (!showCameraControls && !forceShow) return null;

return (
<PivotControls
Expand Down Expand Up @@ -496,7 +498,8 @@ export function SynchronizedCameraControls() {
onChange={sendCamera}
makeDefault
/>
<CameraOrientationTool
<OrbitOriginTool
forceShow={logCamera !== null /* Always show if logging camera */}
pivotRef={pivotRef}
onPivotChange={(matrix) => {
updateCameraLookAtAndUpFromPivotControl(matrix);
Expand Down
4 changes: 2 additions & 2 deletions src/viser/client/src/ControlPanel/GuiState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface GuiState {
shareUrl: string | null;
websocketConnected: boolean;
backgroundAvailable: boolean;
showCameraControlsTool: boolean;
showOrbitOriginTool: boolean;
guiUuidSetFromContainerUuid: {
[containerUuid: string]: { [uuid: string]: true } | undefined;
};
Expand Down Expand Up @@ -66,7 +66,7 @@ const cleanGuiState: GuiState = {
shareUrl: null,
websocketConnected: false,
backgroundAvailable: false,
showCameraControlsTool: false,
showOrbitOriginTool: false,
guiUuidSetFromContainerUuid: {},
modals: [],
guiOrderFromUuid: {},
Expand Down
4 changes: 2 additions & 2 deletions src/viser/client/src/ControlPanel/ServerControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ export default function ServerControls() {
>
<Switch
radius="sm"
label="Camera Orientation Tool"
label="Orbit Origin Tool"
onChange={(event) => {
viewer.useGui.setState({
showCameraControlsTool: event.currentTarget.checked,
showOrbitOriginTool: event.currentTarget.checked,
});
}}
size="sm"
Expand Down

0 comments on commit d49af89

Please sign in to comment.