# How to lay the floor with hexagon?

**URL:** <https://forum.babylonjs.com/t/how-to-lay-the-floor-with-hexagon/24823>\
**Category:** Questions\
**Created:** [October 26, 2021, 10:18am UTC](https://forum.babylonjs.com/t/how-to-lay-the-floor-with-hexagon/24823 "2021-10-26T10:18:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![musk](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/musk/32/17156_2.png) [@musk](https://forum.babylonjs.com/u/musk)\
**Post date:** [October 26, 2021, 10:18am UTC](https://forum.babylonjs.com/t/how-to-lay-the-floor-with-hexagon/24823/1 "2021-10-26T10:18:35Z")

</div>

Hey~All. I want to know how to tile a small hexagon into a large hexagon. It’s a pity that my math scores are really poor. Hoping that someone would give me a lift . This is the result I expect:

 ![20211026181105](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/c/9/c9cb72c3a1dd3f276aa536edbb3c5eb8cdd4b3d2.jpeg)

[https://playground.babylonjs.com/#QANVC6#2145](https://playground.babylonjs.com/#QANVC6#2145)

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [October 26, 2021, 11:07am UTC](https://forum.babylonjs.com/t/how-to-lay-the-floor-with-hexagon/24823/2 "2021-10-26T11:07:26Z")

</div>

Hello! I’m going to see if I can play around with your playground, but to get things started let me share some resources that may help: 😃

> **[Red Blob Games: Hexagonal Grids](https://www.redblobgames.com/grids/hexagons/)**
>
> Amit's guide to math, algorithms, and code for hexagonal grids in games

[![](https://img.youtube.com/vi/VmrIDyYiJBA/maxresdefault.jpg "Hexagonal Tiling Explained!") ](https://www.youtube.com/watch?v=VmrIDyYiJBA)

---

<div class="post-metadata">

**Author:** ![msDestiny14](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/msdestiny14/32/9572_2.png) [@msDestiny14](https://forum.babylonjs.com/u/msDestiny14)\
**Post date:** [October 26, 2021, 11:28am UTC](https://forum.babylonjs.com/t/how-to-lay-the-floor-with-hexagon/24823/3 "2021-10-26T11:28:12Z")

</div>

Hey there! We actually have this really cool hex tile demo our own @PirateJC made for a YouTube series.

[https://playground.babylonjs.com/#XEP0ZD#6](https://playground.babylonjs.com/#XEP0ZD#6)

The video you probably would like to watch in the series is [Interactive Hex Tiles: Part 3 - Building the Hex Grid - YouTube](https://www.youtube.com/watch?v=xOw31J8JFqA) part 3 where he explains his version of the algorithm. ​If you are just looking at the code the main function for the grid is createHexGrid (line 160)

Here is a second version I made using your demo.[https://playground.babylonjs.com/#QANVC6#214](https://playground.babylonjs.com/#QANVC6#214) High level summary of the algorithm I tried. We want to walk up the hexagon by increasing the number. to do the first half, then do it in reverse for the second half. So on the way up we want to have 3 in the row, then 4, then 5 for the first half and then have 5,4,3 on the second half. Also the distance from the center to the edge was was not 1 but 0.6 😉

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [October 26, 2021, 12:44pm UTC](https://forum.babylonjs.com/t/how-to-lay-the-floor-with-hexagon/24823/4 "2021-10-26T12:44:35Z")

</div>

Woah, I hadn’t seen that demo before, it’s SO COOL! 🤩

---

<div class="post-metadata">

**Author:** ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)\
**Post date:** [October 27, 2021, 8:59am UTC](https://forum.babylonjs.com/t/how-to-lay-the-floor-with-hexagon/24823/5 "2021-10-27T08:59:38Z")

</div>

Because I enjoy this sort of thing I had a go

As a wall [https://playground.babylonjs.com/#QANVC6#2147](https://playground.babylonjs.com/#QANVC6#2147)

As a floor [https://playground.babylonjs.com/#QANVC6#2148](https://playground.babylonjs.com/#QANVC6#2148) and with addition of gapping between tiles.

---

<div class="post-metadata">

**Author:** ![Raggar](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raggar/32/20672_2.png) [@Raggar](https://forum.babylonjs.com/u/Raggar)\
**Post date:** [October 27, 2021, 12:04pm UTC](https://forum.babylonjs.com/t/how-to-lay-the-floor-with-hexagon/24823/6 "2021-10-27T12:04:28Z")

</div>

[https://playground.babylonjs.com/#QWYGJQ](https://playground.babylonjs.com/#QWYGJQ)

---

<div class="post-metadata">

**Author:** ![PolygonalSun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/polygonalsun/32/2704_2.png) [@PolygonalSun](https://forum.babylonjs.com/u/PolygonalSun)\
**Post date:** [October 28, 2021, 12:18am UTC](https://forum.babylonjs.com/t/how-to-lay-the-floor-with-hexagon/24823/7 "2021-10-28T00:18:51Z")

</div>

> [@msDestiny14](#):
>
> [https://playground.babylonjs.com/#XEP0ZD#6](https://playground.babylonjs.com/#XEP0ZD#6)

That’s pretty cool. I completely forgot about this demo!

---

<div class="post-metadata">

**Author:** ![brianzinn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/brianzinn/32/28013_2.png) [@brianzinn](https://forum.babylonjs.com/u/brianzinn)\
**Post date:** [October 28, 2021, 12:36am UTC](https://forum.babylonjs.com/t/how-to-lay-the-floor-with-hexagon/24823/8 "2021-10-28T00:36:43Z")

</div>

There’s a hex library called `honeycomb-grid` if you want to see more math - it’s used in this demo (the demo is a grid) - the library supports hex shapes of hexes:  
[Babylon Basic - Instances ⋅ Storybook (brianzinn.github.io)](https://brianzinn.github.io/react-babylonjs/?path=/story/babylon-basic--instances)
