this is the code which I used for my 3d portfolio website using JavaScript Mastery Youtube video:
import React from "react";
import { Suspense, useState, useEffect } from "react";
import { Canvas } from "@react-three/fiber";
import { OrbitControls, Preload, useGLTF } from "@react-three/drei";
import CanvasLoader from "../Loader";
const Computers = () => {
const computer = useGLTF("./desktop_pc/scene.gltf");
return (
<mesh>
<hemisphereLight intensity={1} position={[0, 1, 0]} groundColor="black" />
<spotLight
angle={0.12}
penumbra={1}
intensity={1}
castShadow
shadow-mapSize={1024}
/>
<pointLight intensity={1} />
<primitive
object={computer.scene}
scale={0.75}
position={[0, -3.25, -1.5]}
rotation={[-0.01, -0.2, -0.1]}
/>
</mesh>
);
};
const ComputersCanvas = () => {
return (
<Canvas
frameloop="demand"
shadows
camera={{ position: [20, 3, 5], fov: 25 }}
gl={{ preserveDrawingBuffer: true }}
>
<Suspense fallback={<CanvasLoader />}>
<OrbitControls
enableZoom={false}
maxPolarAngle={Math.PI / 2}
minPolarAngle={Math.PI / 2}
/>
<Computers />
</Suspense>
<Preload all />
</Canvas>
);
};
export default ComputersCanvas;
In The Above Code the hemisphere Light and Point Light are working absolutely fine but the spotlight is Not reflecting on the object which is "computer.scene".
I Placed the object at a certain position and adjusted the lights with the proper configuration to show the results but hemisphere light is not working to its full extent as in the youtube video and spotlight isn't working at all.