Hello,
I’m trying to setup a spotlight in react three fiber but no matter what I do I can’t seem to get the light to actually show up. I’ve tried using other lights like directional, point, ambient, and hemisphere which have all worked, and I’ve also even setup a spotlight helper which is also functioning correctly with leva controls. However, no matter how I adjust the parameters on my spotlight, it doesn’t causing any lighting changes whatsoever. I’ve also tried adding additional arguments like castShadow, penumbra, attenuation, etc., but since the lighting isn’t occurring this doesn’t seem to have any effect. Any ideas on why this might be the case?
Here’s the code for my lighting:
export default function LightScene() {
const { x, y, z, intensity, distance, angle } = useControls({
x: { value: 1, min: 0, max: 3000 },
y: { value: 1, min: 0, max: 3000 },
z: { value: 1, min: 0, max: 7000 },
intensity: { value: 0.5, min: 0, max: 3000 },
distance: { value: 500, min: 0, max: 3000 },
angle: { value: Math.PI / 4, min: 0, max: Math.PI / 2 }
});
/* const dirLight = useRef();
useHelper(dirLight, DirectionalLightHelper, 500, 'red'); */
const spotLight = useRef();
useHelper(spotLight, SpotLightHelper, 'green');
return (
<>
<ambientLight color='#efddb4' intensity = {0.1}/>
<directionalLight
position={[0, 2500, 0]}
intensity={0.30}
color='#efddb4'
/*ref={dirLight}*/
/>
<spotLight
position={[x, y, z]}
intensity={intensity}
distance={distance}
angle={angle}
ref={spotLight}
/>
<hemisphereLight color = '#FFD700' groundColor = {'#000000'} intensity = {0.1} />
</>
)
}