Highlighting a mesh

I am importing a mesh using SceneLoader.ImportMesh. I want to highlight a single mesh so I am looping through each mesh and compare the mesh name to find the match. Once I find the mesh how do I highlight it in red and bring it into focus? I tried using layerMask

I was able to highlight mesh on pointover using this code

theMeshes[i].actionManager!.registerAction(
new ExecuteCodeAction(ActionManager.OnPointerOverTrigger,
function (evt: any) {
mesh = evt.meshUnderPointer;
mesh.material.diffuseColor = Color3.Red();
mesh.material.freeze = true;
}))

I want to be able to highlight the mesh on load and not just on hover.

Below is just an example with playground. This is not the mesh I use

I believe this docs will help a lot - Highlighting Meshes | Babylon.js Documentation

yes. I was just about to update the post. Thanks for the link. I was able to highlight or outline the mesh using the highlight layer. Is there a way to fill in the color instead of just outlining it?

Just use renderOverlay.

Example - Babylon.js Playground

3 Likes

Maybe you also want to consider a glow layer (innerGlow or outerGlow)?

By focus, you mean to make mesh(es) to fill camera view? If so you can use zoomOn()-function of arc rotate camera:

3 Likes

@Takemura @labris
The solutions provided work perfectly but I am using a human body and if the mesh that needs to be highlighted is on the back, how do I rotate it and bring it into view. The mesh is currently getting highlighted and zoomOn() is bringing it into focus but the I would have to manually rotate the body to see the highlighted mesh

Thanks

Can you be more explicit? Do you have a PG (playground) example with this mesh you are using?
I guess the answer sort of depends on how far behind (and behind what) your mesh is.
A PG would definitely help (if you can make this effort).
Thanks and meanwhile, have a great day :sunglasses:

1 Like

@mawa @labris @Takemura

Using the dude example, lets say I want the eyes highlighted I am able to loop through all the meshes, find the mesh of interest and apply an overlay color. On page load dude is facing backwards and hence we can’t see the highlighted eyes until we turn him around.

In my example its not always going to be eyes. It can be a body part in the front of the body or it could be a part in the back. I want to dynamically rotate the body so that the mesh for which the overlay color was applied to is always in view. Any suggestions?

Thanks