File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 11import React , { Suspense , useEffect , useState } from "react" ;
2- import { Canvas } from "@react-three/fiber" ;
2+ import { Canvas , useThree } from "@react-three/fiber" ;
33import { OrbitControls , Preload , useGLTF } from "@react-three/drei" ;
44
55import CanvasLoader from "../Loader" ;
66
77const Computers = ( { isMobile } ) => {
88 const computer = useGLTF ( "./desktop_pc/scene.gltf" ) ;
99
10+ // Ensure the scene renders once the model finishes loading (fixes first-load blank on some mobiles)
11+ const { invalidate } = useThree ( ) ;
12+ useEffect ( ( ) => {
13+ invalidate ( ) ;
14+ } , [ computer , invalidate ] ) ;
15+
1016 return (
11- < mesh >
17+ < mesh >
1218 { /* Make the model visible on darker mobile displays by increasing ambient lighting */ }
1319 < hemisphereLight intensity = { isMobile ? 0.35 : 0.15 } groundColor = 'black' />
1420 < ambientLight intensity = { isMobile ? 0.6 : 0.3 } />
@@ -69,7 +75,7 @@ const ComputersCanvas = () => {
6975 return (
7076 < Canvas
7177 className = "w-full h-full"
72- frameloop = ' demand'
78+ frameloop = { isMobile ? 'always' : ' demand'}
7379 shadows = { ! isMobile }
7480 dpr = { isMobile ? 1 : [ 1 , 2 ] }
7581 // Move the camera further back on mobile to show more of the model
You can’t perform that action at this time.
0 commit comments