# Remove mesh from highlight layer

**URL:** <https://forum.babylonjs.com/t/remove-mesh-from-highlight-layer/11370>\
**Category:** Questions\
**Created:** [June 2, 2020, 3:57pm UTC](https://forum.babylonjs.com/t/remove-mesh-from-highlight-layer/11370 "2020-06-02T15:57:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ueli](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ueli/32/2466_2.png) [@ueli](https://forum.babylonjs.com/u/ueli)\
**Post date:** [June 2, 2020, 3:57pm UTC](https://forum.babylonjs.com/t/remove-mesh-from-highlight-layer/11370/1 "2020-06-02T15:57:57Z")

</div>

Dear Forum

I’ve added a highlight layer, but i can’t remove any meshes from it after adding them.  
The playground is from somebody else, who did a “hili.\_meshes = [];” at the end to remove the highlights. But i can’t use that, as the materials are all black afterwards.

Playground: (click on the ground should make the highlights disapear)  
[https://playground.babylonjs.com/#129LNB#19](https://playground.babylonjs.com/#129LNB#19)

Thank you!

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 2, 2020, 4:42pm UTC](https://forum.babylonjs.com/t/remove-mesh-from-highlight-layer/11370/2 "2020-06-02T16:42:53Z")

</div>

`removeIncludedMesh` does not exist, you had some errors in the console log:

[https://playground.babylonjs.com/#129LNB#21](https://playground.babylonjs.com/#129LNB#21)

---

<div class="post-metadata">

**Author:** ![ueli](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ueli/32/2466_2.png) [@ueli](https://forum.babylonjs.com/u/ueli)\
**Post date:** [June 2, 2020, 4:43pm UTC](https://forum.babylonjs.com/t/remove-mesh-from-highlight-layer/11370/3 "2020-06-02T16:43:31Z")

</div>

yes thank you sorry

[https://playground.babylonjs.com/#129LNB#20](https://playground.babylonjs.com/#129LNB#20)

so it works like this. In my use case the actual problem seems to be the **root** parent from the gltf import. **root**.getChildren() ist not working - i have to search for some other ways to adress the meshes within the **root** parent

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 2, 2020, 4:45pm UTC](https://forum.babylonjs.com/t/remove-mesh-from-highlight-layer/11370/4 "2020-06-02T16:45:43Z")

</div>

I think the PG you linked is ok?

---

<div class="post-metadata">

**Author:** ![ueli](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ueli/32/2466_2.png) [@ueli](https://forum.babylonjs.com/u/ueli)\
**Post date:** [June 2, 2020, 6:32pm UTC](https://forum.babylonjs.com/t/remove-mesh-from-highlight-layer/11370/5 "2020-06-02T18:32:03Z")

</div>

here’s a repo of the problem:

[https://www.babylonjs-playground.com/#WGZLGJ#1577](https://www.babylonjs-playground.com/#WGZLGJ#1577)  
&  
[https://www.babylonjs-playground.com/#WGZLGJ#1578](https://www.babylonjs-playground.com/#WGZLGJ#1578)

Why does it work here?:  
[https://www.babylonjs-playground.com/#1KUJ0A#102](https://www.babylonjs-playground.com/#1KUJ0A#102)

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 2, 2020, 7:09pm UTC](https://forum.babylonjs.com/t/remove-mesh-from-highlight-layer/11370/6 "2020-06-02T19:09:59Z")

</div>

Don’t call `removeMesh` with a string but with an actual pointer to the mesh:

[https://www.babylonjs-playground.com/#WGZLGJ#1579](https://www.babylonjs-playground.com/#WGZLGJ#1579)

---

<div class="post-metadata">

**Author:** ![ueli](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ueli/32/2466_2.png) [@ueli](https://forum.babylonjs.com/u/ueli)\
**Post date:** [June 3, 2020, 7:11am UTC](https://forum.babylonjs.com/t/remove-mesh-from-highlight-layer/11370/7 "2020-06-03T07:11:23Z")

</div>

thank you - great!

Ps: removing all meshes from the highlight layer at once don’t seems to be possible so far:

> [@HighlightLayer: Clear meshes functionality](https://forum.babylonjs.com/t/highlightlayer-clear-meshes-functionality/6854):
>
> I have a highlight layer to which I add meshes. But more often I want to reset/delete the list of added meshes. But don’t find any functionality for it at the moment. A function like clear(); or removeAllMeshes(); The only solution would be to just do that about dispose();? That would be a nice addition for the Highlightlayer. slight_smile Thank you!

so i did it like that:

> for (var i=0;i\<scene.meshes.length;i++) {  
> var mesh = scene.meshes[i];  
> highlightsLayer.removeMesh(mesh);  
> }

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 3, 2020, 12:44pm UTC](https://forum.babylonjs.com/t/remove-mesh-from-highlight-layer/11370/8 "2020-06-03T12:44:50Z")

</div>

You can use removeAllMeshes() we added for this.
