Spotlight helper works but spotlight itself doesn't shine any light

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} />
        </>
    )
}

lights have slightly changed in threejs, they have decay now. try decay=0 to get the old behaviour (non physical lights).

1 Like

Also note that distance is an override for creative control, and can only reduce the range of the light. If decay is set so that the light is basically invisible at 1000m distance, setting range to 3000m will do nothing. Higher intensity will of course increase the range, or setting decay to 0 or 1 can make things easier to manage as drcmda mentions.

1 Like