Skip to content

Commit

Permalink
feat: use full space for threejs canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
seasick committed Dec 30, 2023
1 parent 7dd8da6 commit 087ced7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 30 deletions.
13 changes: 11 additions & 2 deletions src/components/PermanentDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as React from 'react';
import config from '../etc/config.json';

const drawerWidth = 340;
const toolbarHeight = 64; // TODO Will this work everywhere?

type Props = {
menu?: React.ReactNode;
Expand Down Expand Up @@ -51,9 +52,17 @@ export default function PermanentDrawer({ menu, title, children }: Props) {
<Box sx={{ overflow: 'auto' }}>{menu}</Box>
</Drawer>
)}
<Box component="main" sx={{ flexGrow: 1, p: 3 }}>
<Box component="main" sx={{ flexGrow: 1, pt: 0 }}>
<Toolbar />
{children}
<Box
sx={{
width: `calc(100vw - ${menu ? drawerWidth : 0}px)`,
height: `calc(100vh - ${toolbarHeight}px)`,
overflow: 'auto',
}}
>
{children}
</Box>
</Box>
</Box>
);
Expand Down
54 changes: 26 additions & 28 deletions src/components/threeJs/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,31 @@ type Props = JSX.IntrinsicElements['group'] & {

export default function ThreeJsCanvas({ geometry, onSelect }: Props) {
return (
<div style={{ height: '80vh' }}>
<Canvas
shadows
camera={{
fov: 35,
zoom: 1.3,
near: 0.1,
far: 1000,
position: [6, 6, 6],
}}
>
<ContactShadows frames={1} />
<CameraControls />
<Environment />
<Center>
<Model
geometry={geometry}
onClick={(e) => {
onSelect(e);
e.stopPropagation();
}}
/>
</Center>
<GizmoHelper alignment="bottom-right" margin={[80, 80]}>
<GizmoViewcube />
</GizmoHelper>
</Canvas>
</div>
<Canvas
shadows
camera={{
fov: 35,
zoom: 1.3,
near: 0.1,
far: 1000,
position: [6, 6, 6],
}}
>
<ContactShadows frames={1} />
<CameraControls />
<Environment />
<Center>
<Model
geometry={geometry}
onClick={(e) => {
onSelect(e);
e.stopPropagation();
}}
/>
</Center>
<GizmoHelper alignment="bottom-right" margin={[80, 80]}>
<GizmoViewcube />
</GizmoHelper>
</Canvas>
);
}

0 comments on commit 087ced7

Please sign in to comment.