Skip to content

Commit 8f8047e

Browse files
committed
fix: require refresh to display computer
1 parent f5bacf2 commit 8f8047e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/components/canvas/Computers.jsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import React, { Suspense, useEffect, useState } from "react";
2-
import { Canvas } from "@react-three/fiber";
2+
import { Canvas, useThree } from "@react-three/fiber";
33
import { OrbitControls, Preload, useGLTF } from "@react-three/drei";
44

55
import CanvasLoader from "../Loader";
66

77
const 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

0 commit comments

Comments
 (0)