Shadow Camera Helper?

I’m writing wrapper modules in react-three-fiber & drei. Currently, I create lights with their helpers.

As far as I can see Drei’s useHelper does not support shadow cameras in lights, only shows the diamond shapes (light position/color + direction if supported by light).

What is the correct way to add these shadow camera helpers?

Thank you in advance…

(PS: I can do it in vanilla threejs by adding it to the scene etc, I want to know a compatible react way)

Hi, I suppose you found a solution for your issue by then, but I still paste what I got from Drei here for those who are struggling with the same problem :

import { useHelper } from '@react-three/drei'
import { useRef } from 'react'
import { CameraHelper, OrthographicCamera } from 'three'

export default function Component() {
	const shadowCamera = useRef<OrthographicCamera>(null!)
	useHelper(shadowCamera, CameraHelper)

	return <>
		<directionalLight castShadow>
			<orthographicCamera ref={shadowCamera} attach='shadow-camera' />
		</directionalLight>
	</>
}

EDIT : or another solution, arguably easier :

import { Helper } from '@react-three/drei'
import { CameraHelper } from 'three'

export default function Component() {
	return <>
		<directionalLight castShadow>
			<orthographicCamera attach='shadow-camera'>
				<Helper type={CameraHelper} />
			</orthographicCamera>
		</directionalLight>
	</>
}
1 Like
useHelper(dirLight, DirectionalLightHelper, 1, "red");