所以我习惯这样设置帮助程序:
useHelper(sLightRef, THREE.SpotLightHelper);
return <spotLight
castShadow
ref={sLightRef}
position={[0, 2, 2]}
args={["#fff", 0.4, 10, Math.PI * 0.3]}
></spotLight>
这将在SpotLight对象上创建一个助手。
我不明白的是如何在SpotLight的阴影相机上创建一个助手。(spotlight.shadow.camera) 我们无法给它赋值 ref(),因为它不在我的return语句中。它是在SpotLight组件内部创建的。
在普通的Three.js中,这很容易实现:
const helper = new THREE.CameraHelper(spotlight.shadow.camera);
scene.add(helper);
我该如何在react-three-fiber中处理这个问题?我是否忽略了什么显而易见的东西?谢谢。