11import React , { Suspense , useEffect , useState } from "react" ;
22import { Canvas } from "@react-three/fiber" ;
33import { OrbitControls , Preload , useGLTF } from "@react-three/drei" ;
4+
45import CanvasLoader from "../Loader" ;
56
67const Computers = ( { isMobile } ) => {
@@ -20,8 +21,8 @@ const Computers = ({ isMobile }) => {
2021 < pointLight intensity = { 1 } />
2122 < primitive
2223 object = { computer . scene }
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
24+ scale = { isMobile ? 0.7 : 0.75 }
25+ position = { isMobile ? [ 0 , - 3 , - 2.2 ] : [ 0 , - 3.25 , - 1.5 ] }
2526 rotation = { [ - 0.01 , - 0.2 , - 0.1 ] }
2627 />
2728 </ mesh >
@@ -32,30 +33,37 @@ const ComputersCanvas = () => {
3233 const [ isMobile , setIsMobile ] = useState ( false ) ;
3334
3435 useEffect ( ( ) => {
35- const mediaQuery = window . matchMedia ( "(max-width: 768px)" ) ; // Adjust to 768px for broader coverage
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
3640 setIsMobile ( mediaQuery . matches ) ;
3741
42+ // Define a callback function to handle changes to the media query
3843 const handleMediaQueryChange = ( event ) => {
3944 setIsMobile ( event . matches ) ;
4045 } ;
4146
47+ // Add the callback function as a listener for changes to the media query
4248 mediaQuery . addEventListener ( "change" , handleMediaQueryChange ) ;
49+
50+ // Remove the listener when the component is unmounted
4351 return ( ) => {
4452 mediaQuery . removeEventListener ( "change" , handleMediaQueryChange ) ;
4553 } ;
4654 } , [ ] ) ;
4755
4856 return (
49- < Canvas className = ' sm:block hidden'
57+ < Canvas className = " sm:block hidden"
5058 frameloop = 'demand'
5159 shadows
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
60+ dpr = { [ 1 , 2 ] }
61+ camera = { { position : [ 20 , 3 , 5 ] , fov : 25 } }
5462 gl = { { preserveDrawingBuffer : true } }
5563 >
5664 < Suspense fallback = { < CanvasLoader /> } >
5765 < OrbitControls
58- enableZoom = { ! isMobile } // Enable zoom for mobile
66+ enableZoom = { false }
5967 maxPolarAngle = { Math . PI / 2 }
6068 minPolarAngle = { Math . PI / 2 }
6169 />
0 commit comments