|  |  |  | 
|---|
|  |  |  | import React, { useRef } from 'react'; | 
|---|
|  |  |  | import { SpotLight, useDepthBuffer, useHelper } from '@react-three/drei'; | 
|---|
|  |  |  | import { SpotLightHelper } from 'three'; | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | useHelper(spotLightRef, SpotLightHelper, 'teal'); | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | ref={spotLightRef} | 
|---|
|  |  |  | intensity={DEBUG ? 10 : 6} | 
|---|
|  |  |  | color="#ffffff" | 
|---|
|  |  |  | position={[3, 700, 2]} | 
|---|
|  |  |  | position={[3, DEBUG ? 5000 : 2000, 2]} | 
|---|
|  |  |  | castShadow | 
|---|
|  |  |  | penumbra={2} | 
|---|
|  |  |  | distance={6000} | 
|---|
|  |  |  | distance={DEBUG ? 10000 : 6000} | 
|---|
|  |  |  | angle={Math.PI * 0.6} | 
|---|
|  |  |  | attenuation={5} | 
|---|
|  |  |  | anglePower={Math.PI / 2} | 
|---|
|  |  |  | intensity={6} | 
|---|
|  |  |  | shadow-mapSize={[1024, 1024]} | 
|---|
|  |  |  | shadow-camera-near={200} | 
|---|
|  |  |  | shadow-camera-far={2000} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <directionalLight | 
|---|
|  |  |  | position={[0, -100, 0]} | 
|---|
|  |  |  | color="#ffffff" | 
|---|
|  |  |  | intensity={.6} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </> | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | }; | 
|---|