11import React , { Suspense , useEffect , useState } from "react" ;
22import { Canvas } from "@react-three/fiber" ;
33import { OrbitControls , Preload , useGLTF } from "@react-three/drei" ;
4-
54import CanvasLoader from "../Loader" ;
65
76const Computers = ( { isMobile } ) => {
@@ -21,8 +20,8 @@ const Computers = ({ isMobile }) => {
2120 < pointLight intensity = { 1 } />
2221 < primitive
2322 object = { computer . scene }
24- scale = { isMobile ? 0.7 : 0.75 }
25- position = { isMobile ? [ 0 , - 3 , - 2.2 ] : [ 0 , - 3.25 , - 1.5 ] }
23+ scale = { isMobile ? 0.5 : 0.75 } // Adjust scale more aggressively
24+ position = { isMobile ? [ 0 , - 3 , - 2.5 ] : [ 0 , - 3.25 , - 1.5 ] } // Adjust position
2625 rotation = { [ - 0.01 , - 0.2 , - 0.1 ] }
2726 />
2827 </ mesh >
@@ -33,21 +32,14 @@ const ComputersCanvas = () => {
3332 const [ isMobile , setIsMobile ] = useState ( false ) ;
3433
3534 useEffect ( ( ) => {
36- // Add a listener for changes to the screen size
37- const mediaQuery = window . matchMedia ( "(max-width: 500px)" ) ;
38-
39- // Set the initial value of the `isMobile` state variable
35+ const mediaQuery = window . matchMedia ( "(max-width: 768px)" ) ; // Adjust to 768px for broader coverage
4036 setIsMobile ( mediaQuery . matches ) ;
4137
42- // Define a callback function to handle changes to the media query
4338 const handleMediaQueryChange = ( event ) => {
4439 setIsMobile ( event . matches ) ;
4540 } ;
4641
47- // Add the callback function as a listener for changes to the media query
4842 mediaQuery . addEventListener ( "change" , handleMediaQueryChange ) ;
49-
50- // Remove the listener when the component is unmounted
5143 return ( ) => {
5244 mediaQuery . removeEventListener ( "change" , handleMediaQueryChange ) ;
5345 } ;
@@ -57,13 +49,13 @@ const ComputersCanvas = () => {
5749 < Canvas
5850 frameloop = 'demand'
5951 shadows
60- dpr = { [ 1 , 2 ] }
61- camera = { { position : [ 20 , 3 , 5 ] , fov : 25 } }
52+ dpr = { isMobile ? [ 1 , 1.5 ] : [ 1 , 2 ] } // Adjust DPR for mobile
53+ camera = { { position : isMobile ? [ 15 , 3 , 5 ] : [ 20 , 3 , 5 ] , fov : 25 } } // Dynamic camera position
6254 gl = { { preserveDrawingBuffer : true } }
6355 >
6456 < Suspense fallback = { < CanvasLoader /> } >
6557 < OrbitControls
66- enableZoom = { false }
58+ enableZoom = { ! isMobile } // Enable zoom for mobile
6759 maxPolarAngle = { Math . PI / 2 }
6860 minPolarAngle = { Math . PI / 2 }
6961 />
0 commit comments