# Highlighting a mesh

**URL:** <https://forum.babylonjs.com/t/highlighting-a-mesh/35147>\
**Category:** Questions\
**Created:** [October 26, 2022, 3:26pm UTC](https://forum.babylonjs.com/t/highlighting-a-mesh/35147 "2022-10-26T15:26:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nuguru](https://avatars.discourse-cdn.com/v4/letter/n/dbc845/32.png) [@nuguru](https://forum.babylonjs.com/u/nuguru)\
**Post date:** [October 26, 2022, 3:26pm UTC](https://forum.babylonjs.com/t/highlighting-a-mesh/35147/1 "2022-10-26T15:26:59Z")

</div>

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

> **[Babylon.js Playground](https://playground.babylonjs.com/#YIU90M%23848)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [October 26, 2022, 3:46pm UTC](https://forum.babylonjs.com/t/highlighting-a-mesh/35147/2 "2022-10-26T15:46:56Z")

</div>

I believe this docs will help a lot - [Highlighting Meshes | Babylon.js Documentation](https://doc.babylonjs.com/features/featuresDeepDive/mesh/highlightLayer)

---

<div class="post-metadata">

**Author:** ![nuguru](https://avatars.discourse-cdn.com/v4/letter/n/dbc845/32.png) [@nuguru](https://forum.babylonjs.com/u/nuguru)\
**Post date:** [October 26, 2022, 3:49pm UTC](https://forum.babylonjs.com/t/highlighting-a-mesh/35147/3 "2022-10-26T15:49:18Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [October 26, 2022, 4:03pm UTC](https://forum.babylonjs.com/t/highlighting-a-mesh/35147/4 "2022-10-26T16:03:32Z")

</div>

> [@nuguru](#):
>
> Is there a way to fill in the color instead of just outlining it?

Just use renderOverlay.

Example - [Babylon.js Playground](https://playground.babylonjs.com/#UYCJT6)

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/9/4/94c519369f84cb76ad18bf2687b5bc459b62aa6a.png)

---

<div class="post-metadata">

**Author:** ![Takemura](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/takemura/32/25836_2.png) [@Takemura](https://forum.babylonjs.com/u/Takemura)\
**Post date:** [October 26, 2022, 4:41pm UTC](https://forum.babylonjs.com/t/highlighting-a-mesh/35147/5 "2022-10-26T16:41:07Z")

</div>

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

> **[Making Meshes Glow | Babylon.js Documentation](https://doc.babylonjs.com/features/featuresDeepDive/mesh/glowLayer)**
>
> Learn all about the glow layer in Babylon.js.

> [@nuguru](#):
>
> … and bring it into focus?

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

> **[ArcRotateCamera | Babylon.js Documentation](https://doc.babylonjs.com/typedoc/classes/BABYLON.ArcRotateCamera#zoomOn)**
>
> This represents an orbital type of camera. \[API\]

---

<div class="post-metadata">

**Author:** ![nuguru](https://avatars.discourse-cdn.com/v4/letter/n/dbc845/32.png) [@nuguru](https://forum.babylonjs.com/u/nuguru)\
**Post date:** [October 27, 2022, 3:19pm UTC](https://forum.babylonjs.com/t/highlighting-a-mesh/35147/6 "2022-10-27T15:19:04Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [October 27, 2022, 3:53pm UTC](https://forum.babylonjs.com/t/highlighting-a-mesh/35147/7 "2022-10-27T15:53:42Z")

</div>

> [@nuguru](#):
>
> if the mesh that needs to be highlighted is on the back,

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 🕶

---

<div class="post-metadata">

**Author:** ![nuguru](https://avatars.discourse-cdn.com/v4/letter/n/dbc845/32.png) [@nuguru](https://forum.babylonjs.com/u/nuguru)\
**Post date:** [October 27, 2022, 4:24pm UTC](https://forum.babylonjs.com/t/highlighting-a-mesh/35147/8 "2022-10-27T16:24:49Z")

</div>

@mawa @labris @Takemura

> **[Babylon.js Playground](https://playground.babylonjs.com/#WLDCUC%23172)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

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
