Jump to content

Issue with highlighting instances


oemike
 Share

Recommended Posts

Hi,

I'm fairly new to babylonjs, but think I have a somewhat solid grip on it. I'm loading in a single glb as the only component in my scene. ~30 megs before compression. When I load the glb, I iterate over the meshes and add metadata when applicable to each mesh based on a variety of factors. When the user hovers a mesh, all the meshes with the same metadata need to highlight. To accomplish this, I'm adding a function to scene.onPointerObservable that picks the mesh they're hovering, then using the metadata attached to it, iterating over and adding all the meshes with similar metadata to a HighlightLayer. Checks are in place to not do this more than needed, so I'm not iterating over all the meshes every time they move the mouse.

This all works great. The issue, is that a new glb I'm working with uses instanced meshes. When I plug this glb into the existing logic, the instances each get different metadata at load, which is desired. However, When adding the meshes to the highlight layer, it seems to be all or nothing. I've done some googling, and it looks like the highlight layer can not highlight specific instances only. 

My scene is not so complex as to need the optimization of instancing to be within my performance requirements. However, it might be a pain to ensure all models I use in the future don't use instancing. 

Does anyone know of a better solution than de-instancing these meshes? And if not, is there a better way of de-instancing the meshes than creating a new mesh and copying the geometry, materials, metadata, etc then disposing of the old instance?

Thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...