Skip to content

Commit ec40a68

Browse files
committed
Reduced computer size on mobile
1 parent 67d413f commit ec40a68

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/components/canvas/Computers.jsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ const Computers = ({ isMobile }) => {
2121
<pointLight intensity={1} />
2222
<primitive
2323
object={computer.scene}
24-
scale={isMobile ? 0.7 : 0.75}
25-
position={isMobile ? [0, -3, -2.2] : [0, -3.25, -1.5]}
24+
// Reduce scale on mobile so the model fits the viewport
25+
scale={isMobile ? 0.5 : 0.75}
26+
position={isMobile ? [0, -3.5, -3] : [0, -3.25, -1.5]}
2627
rotation={[-0.01, -0.2, -0.1]}
2728
/>
2829
</mesh>
@@ -34,7 +35,8 @@ const ComputersCanvas = () => {
3435

3536
useEffect(() => {
3637
// Add a listener for changes to the screen size
37-
const mediaQuery = window.matchMedia("(max-width: 500px)");
38+
// Use a wider breakpoint so most phones count as mobile
39+
const mediaQuery = window.matchMedia("(max-width: 768px)");
3840

3941
// Set the initial value of the `isMobile` state variable
4042
setIsMobile(mediaQuery.matches);
@@ -64,11 +66,12 @@ const ComputersCanvas = () => {
6466

6567
return (
6668
<Canvas
67-
className="w-full"
69+
className="w-full h-full"
6870
frameloop='demand'
6971
shadows={!isMobile}
7072
dpr={isMobile ? 1 : [1, 2]}
71-
camera={{ position: isMobile ? [20, 2, 5] : [20, 3, 5], fov: 25 }}
73+
// Move the camera further back on mobile to show more of the model
74+
camera={{ position: isMobile ? [20, 2, 10] : [20, 3, 5], fov: 25 }}
7275
gl={{ preserveDrawingBuffer: true }}
7376
>
7477
<Suspense fallback={<CanvasLoader />}>

0 commit comments

Comments
 (0)