The glb model consists of many meshes,but i want to add mouseenter or mouseleave events to the entire model. I think wrapping the model in a BoundingBoxGizmo is not a good idea because the box area is quite larger thant the whole mesh area, which means it is not accurate. Do you have any idea about it?
Hi Loukai1991,
I can think of quite a few things you could try, but how viable each option is will likely depend on your scenario. The best two options I can think of are the following:
- If you have control of the model’s creation process (or at least have the opportunity to make your own modifications/additions afterward), probably the most straightforward approach would be to make a single simple but tight-fitting “hull” mesh that doesn’t get rendered but is used for picking. This is the same sort of approach you might use to create a custom collider mesh.
- If your model is the only thing in the scene, you could sample the depth buffer at the mouse position and determine you’re hovering over the model if the sample isn’t clip depth, but that’s not viable if there’s anything else in the scene that’s writing to the depth buffer.
Of these two, I’d definitely recommend the first if you can make it work as it’ll give you the most control over the process with the least complexity. Hope this helps, and best of luck!
Hello just checking in, was your question answered? @Loukai1991