#
luxiaotao1123
2024-04-26 73e5e4f17c23a7f4832ea2bb36e1bd3799ab9ad9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React, { useRef, useEffect } from 'react';
import { SpotLight, useHelper } from '@react-three/drei';
import { DEBUG } from '../config/setting';
import { SpotLightHelper, DirectionalLightHelper } from 'three';
 
const Lights = () => {
    const spotLightRef = useRef();
    const directionalLightRef = useRef();
 
    if (DEBUG) {
        useHelper(spotLightRef, SpotLightHelper, 'teal');
        useHelper(directionalLightRef, DirectionalLightHelper, 'teal');
    }
 
    return (
        <>
            <ambientLight intensity={0.5} />
            <directionalLight color={0xffffff} intensity={3} position={[10, 10, 0]} />
            <SpotLight
                intensity={DEBUG ? 10 : 6}
                color="#ffffff"
                position={[3, DEBUG ? 5000 : 2000, 2]}
                castShadow
                penumbra={2}
                distance={DEBUG ? 10000 : 6000}
                angle={Math.PI * 0.6}
                attenuation={5}
                anglePower={Math.PI / 2}
                shadow-mapSize={[1024, 1024]}
                shadow-camera-near={200}
                shadow-camera-far={2000}
            />
            <directionalLight
                position={[0, -100, 0]}
                color="#ffffff"
                intensity={.6}
            />
        </>
    );
};
 
export default Lights;