Replies: 2 comments 3 replies
-
I checked the properties the useHelper(dirLight, DirectionalLightHelper, 1, "red"); Upon changing the position of the directional light, the helper responds accordingly. |
Beta Was this translation helpful? Give feedback.
1 reply
-
you can write your Method 1 like this const Light = () => {
const directionalLightRef = useRef()
const [isReady, setIsReady] = useState(false)
useEffect(() => {
if (directionalLightRef.current) {
setIsReady(true)
}
})
return (
<>
<directionalLight
ref={directionalLightRef}
position={[1, 1, 0]}
color={0xffffff}
intensity={10}
/>
{isReady && (
<directionalLightHelper args={[directionalLightRef.current, 2, 0xff0000]} />
)}
</>
)
}
export default Light |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to use the directionalLightHelper in my NexTJS project but am unable to. So far I have tried two methods.
Method 1 -
In this case I am getting the error
TypeError: light is undefined
Method 2 -
I created a
Light
component with theuseHelper
hook and passed that inside the canvas.In this case I am getting a black colored line at the origin. I am confused if the light helper is supposed to look like this or not?
Beta Was this translation helpful? Give feedback.
All reactions