# Why mesh.materials is not a thing?

**URL:** <https://forum.babylonjs.com/t/why-mesh-materials-is-not-a-thing/46942>\
**Category:** Questions\
**Tags:** material, mesh\
**Created:** [January 4, 2024, 1:50pm UTC](https://forum.babylonjs.com/t/why-mesh-materials-is-not-a-thing/46942 "2024-01-04T13:50:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lauris47](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@lauris47](https://forum.babylonjs.com/u/lauris47)\
**Post date:** [January 4, 2024, 1:50pm UTC](https://forum.babylonjs.com/t/why-mesh-materials-is-not-a-thing/46942/1 "2024-01-04T13:50:36Z")

</div>

Good day,

I have a mesh with many materials.  
Why Babylon.Mesh or Babylon.AbstractMesh does not give access to all materials? There is only an option to access a material.

I can use

```auto
const sceneMesh = scene.getMeshByName(mesh.name);
sceneMesh.material.subMaterials

```

but it is always null.

I am probably missing some fundamentals. However, any other engine, as Unity or Unreal, always give an option to grab materials from any type of mesh.

Thank you.

---

<div class="post-metadata">

**Author:** ![Amarth2Estel](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/amarth2estel/32/14588_2.png) [@Amarth2Estel](https://forum.babylonjs.com/u/Amarth2Estel)\
**Post date:** [January 4, 2024, 4:36pm UTC](https://forum.babylonjs.com/t/why-mesh-materials-is-not-a-thing/46942/2 "2024-01-04T16:36:28Z")

</div>

Hi Lauris47 !

Actually, you can apply only one single Material to a Mesh.  
However, this material may be an instance of the class MultiMaterial. It allows to apply different materials to different parts of the same mesh.

Read more here :

> **[Multi-Materials | Babylon.js Documentation](https://doc.babylonjs.com/features/featuresDeepDive/materials/using/multiMaterials)**
>
> Learn how to use Babylon.js Multi-Materials.

Then you could access to all subMaterials using the subMaterials attribute which is specific to this class.  
See log line 40.

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

---

<div class="post-metadata">

**Author:** ![lauris47](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@lauris47](https://forum.babylonjs.com/u/lauris47)\
**Post date:** [January 4, 2024, 5:01pm UTC](https://forum.babylonjs.com/t/why-mesh-materials-is-not-a-thing/46942/3 "2024-01-04T17:01:58Z")

</div>

Thank you for the info.  
What happens if merged mesh, that has many materials is exported to GLB for Babylon, does it get split based on the amount of materials it has?  
(Assuming this, sine you state that mesh has only one material)

---

<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:** [January 4, 2024, 5:10pm UTC](https://forum.babylonjs.com/t/why-mesh-materials-is-not-a-thing/46942/4 "2024-01-04T17:10:40Z")

</div>

cc @bghgary for the exporter.

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [January 4, 2024, 5:41pm UTC](https://forum.babylonjs.com/t/why-mesh-materials-is-not-a-thing/46942/5 "2024-01-04T17:41:58Z")

</div>

A mesh with multiple submeshes using a `MultiMaterial` will be written to a gltf/glb as a single glTF mesh with multiple glTF primitives pointing to different glTF materials.
