# Placing decals on freshly instantiated meshes

**URL:** <https://forum.babylonjs.com/t/placing-decals-on-freshly-instantiated-meshes/44972>\
**Category:** Questions\
**Tags:** decals\
**Created:** [October 17, 2023, 8:31am UTC](https://forum.babylonjs.com/t/placing-decals-on-freshly-instantiated-meshes/44972 "2023-10-17T08:31:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![waclawi](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/waclawi/32/35297_2.png) [@waclawi](https://forum.babylonjs.com/u/waclawi)\
**Post date:** [October 17, 2023, 8:31am UTC](https://forum.babylonjs.com/t/placing-decals-on-freshly-instantiated-meshes/44972/1 "2023-10-17T08:31:51Z")

</div>

Hello again!

After a while I came back to my small project with an idea to place an image on top of every block.  
I tried to use decals for it but I don’t really know what is wrong. Every example I checked was using casting to place a decal on top of the mesh and I would like to do it instantly when I initialize the block.

Here’s slightly modified example:

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

I don’t know why I am getting only a black rectangle or a square instead of an image that I got from this example: [https://playground.babylonjs.com/#1BAPRM#73](https://playground.babylonjs.com/#1BAPRM#73)

Also when I am trying to do the same thing on my main project where blocks are **InstanceMesh** ’es from .gltf file, I kinda see decals as “inverted”? I can somehow see them when I look at the blocks from the bottom - reversed situation of when you look at the ground from the bottom and it is invisible. Pretty hard to explain 😅

Cheers!

---

<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:** [October 17, 2023, 11:10am UTC](https://forum.babylonjs.com/t/placing-decals-on-freshly-instantiated-meshes/44972/2 "2023-10-17T11:10:26Z")

</div>

The position used to project the decal should not be right on the mesh you project onto, it should be a little further, else the algorithm won’t work well:

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

Regarding your other problem, try to set `scene.useRightHandedSystem = true` just after creating the scene and see if this fixes it.

---

<div class="post-metadata">

**Author:** ![waclawi](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/waclawi/32/35297_2.png) [@waclawi](https://forum.babylonjs.com/u/waclawi)\
**Post date:** [October 17, 2023, 5:18pm UTC](https://forum.babylonjs.com/t/placing-decals-on-freshly-instantiated-meshes/44972/3 "2023-10-17T17:18:56Z")

</div>

Thanks!

First problem was indeed fixed.  
I can see in my project that it is also working if am using a simple `MeshBuilder.CreateBox()` to create my blocks. Sadly, problem when using imported mesh still persists even with setting `useRightHandedSystem ` as you suggested. Here’s a screenshot of what I am seeing. Decal settings are left untouched (the ones working with simple meshes from builder)

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/2/c/2c4100e45aa9c757b7c715ae4148559cb530b080.jpeg)

---

<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:** [October 17, 2023, 6:07pm UTC](https://forum.babylonjs.com/t/placing-decals-on-freshly-instantiated-meshes/44972/4 "2023-10-17T18:07:12Z")

</div>

Can you reproduce the problem in the playground? I think it will be difficult to help you otherwise.

---

<div class="post-metadata">

**Author:** ![waclawi](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/waclawi/32/35297_2.png) [@waclawi](https://forum.babylonjs.com/u/waclawi)\
**Post date:** [October 19, 2023, 6:07pm UTC](https://forum.babylonjs.com/t/placing-decals-on-freshly-instantiated-meshes/44972/5 "2023-10-19T18:07:55Z")

</div>

Hey @Evgeni_Popov ! Sorry for the delay, I had some problems with importing my custom mesh to the Playground. Luckily, I managed to reproduce exactly my problem. You can see it here:

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

I increased decal’s size so it would be “visible”.

Thank you for your interest in my problem!

---

<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:** [October 20, 2023, 11:32am UTC](https://forum.babylonjs.com/t/placing-decals-on-freshly-instantiated-meshes/44972/6 "2023-10-20T11:32:46Z")

</div>

Because you load the base mesh from a glTF, you must update the `sideOrientation` property of the decal material to account for the different handedness between glTF and Babylon (see line 102):

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

---

<div class="post-metadata">

**Author:** ![waclawi](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/waclawi/32/35297_2.png) [@waclawi](https://forum.babylonjs.com/u/waclawi)\
**Post date:** [October 21, 2023, 12:09pm UTC](https://forum.babylonjs.com/t/placing-decals-on-freshly-instantiated-meshes/44972/7 "2023-10-21T12:09:32Z")

</div>

Hey Evgeni! Damn, such simple fix, thanks for that!  
I am marking your post as a solution.

Have a great day!
