# Creating button in world space from screen space

**URL:** <https://forum.babylonjs.com/t/creating-button-in-world-space-from-screen-space/15419>\
**Category:** Questions\
**Created:** [November 4, 2020, 10:30am UTC](https://forum.babylonjs.com/t/creating-button-in-world-space-from-screen-space/15419 "2020-11-04T10:30:02Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![John.Kress](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@John.Kress](https://forum.babylonjs.com/u/John.Kress)\
**Post date:** [November 4, 2020, 10:30am UTC](https://forum.babylonjs.com/t/creating-button-in-world-space-from-screen-space/15419/1 "2020-11-04T10:30:02Z")

</div>

I am trying to figure out how to create this button from image onto the world space. That is it should be fixed to a point in space. I have tried creating a 3D button but it is not exactly the way I wanted. That is, it looks very different from my GUI button. How do I achieve this? Please help

[https://www.babylonjs-playground.com/#XCPP9Y#4433](https://www.babylonjs-playground.com/#XCPP9Y#4433)

---

<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:** [November 4, 2020, 11:06am UTC](https://forum.babylonjs.com/t/creating-button-in-world-space-from-screen-space/15419/2 "2020-11-04T11:06:26Z")

</div>

Welcome aboard!

I don’t really understand. The 2D GUI button does stay fixed in screen space, as in your PG. Do you want your 3D button to stay fixed instead?

---

<div class="post-metadata">

**Author:** ![John.Kress](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@John.Kress](https://forum.babylonjs.com/u/John.Kress)\
**Post date:** [November 4, 2020, 11:08am UTC](https://forum.babylonjs.com/t/creating-button-in-world-space-from-screen-space/15419/3 "2020-11-04T11:08:17Z")

</div>

Yes I want the 3D button to be fixed in the scene. For example around a mesh (fixed on top of a model). How do I create the exact 2D button in the PG as 3D?

---

<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:** [November 4, 2020, 11:43am UTC](https://forum.babylonjs.com/t/creating-button-in-world-space-from-screen-space/15419/4 "2020-11-04T11:43:41Z")

</div>

You can parent the 3D button to the mesh you want it to move along: [Use a Parent - Babylon.js Documentation](https://doc.babylonjs.com/how_to/parenting)

Note that when I uncomment the 3D button I can’t see anything.

To have a 2D GUI element be applied to 3D meshes you can use `CreateForMesh` method of the `AdvancedDynamicTexture` class: [Use the Babylon GUI - Babylon.js Documentation](https://doc.babylonjs.com/how_to/gui#advanceddynamictexture)

---

<div class="post-metadata">

**Author:** ![John.Kress](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@John.Kress](https://forum.babylonjs.com/u/John.Kress)\
**Post date:** [November 4, 2020, 12:00pm UTC](https://forum.babylonjs.com/t/creating-button-in-world-space-from-screen-space/15419/5 "2020-11-04T12:00:36Z")

</div>

[https://www.babylonjs-playground.com/#XCPP9Y#4434](https://www.babylonjs-playground.com/#XCPP9Y#4434)

Here I have added the 3D button. Can you see the shape of this button and how it looks. Very different from the 2D button.

---

<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:** [November 4, 2020, 12:56pm UTC](https://forum.babylonjs.com/t/creating-button-in-world-space-from-screen-space/15419/6 "2020-11-04T12:56:43Z")

</div>

You can set the diffuse color of the button material to black so that the lighting does not affect the button:

[https://www.babylonjs-playground.com/#XCPP9Y#4436](https://www.babylonjs-playground.com/#XCPP9Y#4436)

Or you can remove the light from the utility layer scene created by the 3D manager:

[https://www.babylonjs-playground.com/#XCPP9Y#4437](https://www.babylonjs-playground.com/#XCPP9Y#4437)

---

<div class="post-metadata">

**Author:** ![John.Kress](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@John.Kress](https://forum.babylonjs.com/u/John.Kress)\
**Post date:** [November 4, 2020, 1:08pm UTC](https://forum.babylonjs.com/t/creating-button-in-world-space-from-screen-space/15419/7 "2020-11-04T13:08:50Z")

</div>

Thank you @Evgeni_Popov but my issue is not with the light. You see the 3D button that is created is that of a square and the one I need is of a different shape. Close to a circle. How can I get this?

---

<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:** [November 4, 2020, 1:13pm UTC](https://forum.babylonjs.com/t/creating-button-in-world-space-from-screen-space/15419/8 "2020-11-04T13:13:26Z")

</div>

Maybe you can use `MeshButton3D` instead and make a sphere / disc mesh? To create a disc: [Create Set Shapes - Babylon.js Documentation](https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon)

---

<div class="post-metadata">

**Author:** ![John.Kress](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@John.Kress](https://forum.babylonjs.com/u/John.Kress)\
**Post date:** [November 4, 2020, 1:15pm UTC](https://forum.babylonjs.com/t/creating-button-in-world-space-from-screen-space/15419/9 "2020-11-04T13:15:22Z")

</div>

Oh I was avoiding to use a mesh 😕 But if the default way to create a button is only using square, guess i have no other option.

---

<div class="post-metadata">

**Author:** ![John.Kress](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@John.Kress](https://forum.babylonjs.com/u/John.Kress)\
**Post date:** [November 4, 2020, 1:20pm UTC](https://forum.babylonjs.com/t/creating-button-in-world-space-from-screen-space/15419/10 "2020-11-04T13:20:16Z")

</div>

Instead can I upload image itself as button? Such that I can upload it as sprite and add button to it?

---

<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:** [November 4, 2020, 2:06pm UTC](https://forum.babylonjs.com/t/creating-button-in-world-space-from-screen-space/15419/11 "2020-11-04T14:06:26Z")

</div>

A sprite is simply a plane, so it would not be different from a 3D button (but you can’t use a sprite in a 3D gui scenario as sprites are not meshes).

Note that everything in 3D GUI is a mesh underneath.
