Is it possible to have a click event listeners to each of these meshe? I’d like to trigger something when Model is clciked and when ModelPlank is clicked.
what i have so far, though i just keep getting no plank
So does the raycaster only work on threejs mesh? I’m working with AFrame as well. The newElement in my OP is an AFrame entity which has the main model. And I got the the other meshes in the main model by name. Now I need to have the plank have the ability to be clicked. I’ve seen numerous example of using the Raycaster but they’ve all used a mesh/model that was created using threejs, so I’m confused how to apply it to this model that i have.
It is appropriate to indicate keywords that match the question. The problem seems to be AFrame. This was not obvious. Please add it so that future viewers know what it is about and can also find it in the forum search.
Hi. Yes, I’ve seen the AFrame documentation but am somehow unable to get the mesh. As in OP, I have 1 3d object and accessing and customising the different meshes in the model. Now, I’m trying to figure out if each of those meshes can be clicked/raycast somehow. Have not been successfull.
since you already use threejs declaratively is switching to react a possibility? in three three-fiber this would be absolutely trivial since you have real pointer events, bubbling, stopPropagation, events on groups, etc.
<group onClick={(e) => {
// e.object is the clicked mesh, no matter how deeply nested
// e.eventObject is the source (the group)
// e.stopPropagation() would stop bubbling (nearest object wins)
}}>
<group>
<mesh ... />
</group>
<mesh ... />
<mesh ... />
<mesh ... />
</group>
bruno simon has a complete tutorial on this as well: Three.js Journey — Mouse Events with R3F in the middle of that course he does exactly what you want with a hamburger model (distributing events between top bun, cheese, burger, bottom bun).
Will have to look into it, have not personally used React. Would i need to change everything that i’ve done? As this is a webar project using 8thwall, aframe, threejs.
it depends. it might make sense since 8thwall has a lot of fiber components and integrations, i think many people use it with react. but if the project is too large perhaps you’re better off implementing the event handler you need.