I want to add click event to my meshes (there are 40 meshes or groups actually). is there a way to add pointer events to the group objects like that in for loop?
object.setAttribute("onClick","console.log(hello);")
instead of adding them onClick attribute one by one
<group onClick={()=>console.log("hello")}> <mesh/> <mesh/> </group>
Asked
Active
Viewed 245 times
0

Berkay Çırak
- 3
- 2
1 Answers
0
you can use pointer events for groups and meshes like this :
onPointerEnter={() => {
console.log("Clicked")
}}
onPointerOver={() => {
console.log("hovered")
}}
onPointerOut={() => {
console.log("hover released")
}}

hamza khazri
- 16
- 1