OnClick event on mesh to detect only one object, not multiple #1010
-
Hello, I read the documentation and found out how to add the onClick event on a mesh and it works fine. However, if I have more objects in a row (so one behind another) and click on the first one, they raycast of the click goes through all of them, so the click is detected by all objects. Is there a way to stop the propagation upon hitting the first object such that I detect that only one object was clicked? Hope the question was concise enough since it's my first time using discussions on Github :) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
e => {
e.stopPropagation()
... that'll do it :-) |
Beta Was this translation helpful? Give feedback.
-
const [hasFocus, setFocus] = useState(false); <mesh // worked for me! |
Beta Was this translation helpful? Give feedback.
that'll do it :-)