Skip to content
Discussion options

You must be logged in to vote

In case anyone bumps into this: it is also necessary to enable the layers in the raycaster object, since it will only consider layer one as default. Just change this in the sandbox code above:

const { camera, raycaster } = useThree()
useEffect(() => {
    if (layerEnabled) { 
         camera.layers.enable(layerId)
         raycaster.layers.enable(layerId)
    }
    else { 
         camera.layers.disable(layerId)
         raycaster.layers.disable(layerId)
   }
  }, [layerEnabled, layerId, camera.layers, raycaster])

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by vicrsp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant