Highlight Layer issues

I’m trying to add/remove a mesh to/from a highlight layer when it is clicked. The cubes work fine, as intended, but imported meshes do not work correctly. After doing some digging, selecting a child mesh appears to work partially, though still not as intended. How can I have the entire mesh be added to the highlight layer? Here is a PG:
Controls:
Shift: Select/deselect multiple meshes
Ctrl: Selects the first child mesh of the object, or the main mesh if there is not one
Alt: Selects all child meshes, or the main mesh if there are none (this is close to what I want though not the correct way)

You need to add all the meshes part of the object you are trying to select. Can you take a screenshot of what does not work in the alt case ? just to help me understand the issue better ?

1 Like

The alt cause is visually correct, though does not select the main mesh (the container / parent). I’m trying to add the main mesh to the highlight layer, which doesn’t work. I need clicking on the space ship (without Ctrl or Alt) to highlight the whole mesh.

It’s because in the imported mesh case, the container doesn’t have any of the vertices, it’s the children that have it.

If you want to highlight all of the vertices, you’ll have to highlight all of the children: Highlight | Babylon.js Playground (babylonjs.com)

3 Likes

Hello just checking in if you’d like any more help on this issue @Vortex

1 Like

Sorry for the late reply - I don’t, thanks for asking. Now I’m working on pathfinding (A*).

1 Like

The extension to this question. This highlight pass is highlighting the object as a whole. What if i want to create animation where a line is traveling around the edges ? How can i do that ?
CC : @sebavan @carolhmj (Sorry don’t know whom to tag)
Shared the example :

I would not use an highlight layer for it. I would probably do it from within the mesh itself.

Hi,

Thanks for the reply!

Yeah, I tried the mesh approach too - having separate meshes with lines traveling through them. But that means our 3D artists have to create individual highlight meshes for every single object, which just isn’t practical for us.

Fortunately, I found a solution by tweaking the post-processing outline shader instead. I modified the edge detection fragment shader to create animated dot patterns. Basically, I take the screen coordinates, add some animated offset based on time, and use modulo operations to create a repeating dot grid that moves across the detected edges. The dots are created using distance calculations and smoothstep functions to get clean circular shapes. It’s not following the exact edge topology like A→B→C→D, but it gives a nice animated dotted outline effect that moves consistently across all edges without needing extra geometry from the art team.

Works pretty well for our use case!

Here’s the result :

nice !!!

1 Like