# Mesh subdivisions in a grid-like style partitions

**URL:** <https://forum.babylonjs.com/t/mesh-subdivisions-in-a-grid-like-style-partitions/9437>\
**Category:** Feature requests\
**Created:** [March 24, 2020, 5:10pm UTC](https://forum.babylonjs.com/t/mesh-subdivisions-in-a-grid-like-style-partitions/9437 "2020-03-24T17:10:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Danim](https://avatars.discourse-cdn.com/v4/letter/d/c57346/32.png) [@Danim](https://forum.babylonjs.com/u/Danim)\
**Post date:** [March 24, 2020, 5:10pm UTC](https://forum.babylonjs.com/t/mesh-subdivisions-in-a-grid-like-style-partitions/9437/1 "2020-03-24T17:10:48Z")

</div>

Hi all,

These days I’ve been trying to build a simple project in BabylonJS that involved a bit of vertex painting and moving vertices around from a very high poligon meshes and I’ve faced some performance issues that I’m slowly addressing (thanks to the supportive community I’ve found at the forums, that pointed me into the right way to get better performance).

One of the things that helped with that was the **mesh.subdivide** and **mesh.createOrUpdateSubmeshesOctree()** but then I’ve found a limitation of the subdivision system as it is based on a start index and an index count and not on a custom group of indices. In most cases, the meshes modeled in other software don’t have a very nice order in their vertices, so the subdivisions are a bit messy.

Then I found the grid-likee partitions that **mesh.updateFacetData()** provides and I managed to get the bounding boxes and vertex group for those partitions. The thing with that is that these partitions can not be threated as submeshes (I think) thus not getting the picking performance that you get with subdivisions and octrees.

Here you have a playground to show the visual representation of these partitions vs the submeshes:

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

And the explanation of the thing in this post:

> [@Optimize mesh partitions for picking and selections](https://forum.babylonjs.com/t/optimize-mesh-partitions-for-picking-and-selections/9273):
>
> Hi, I’m working on a project that needes improved performance when picking a certain area of the mesh and then selecting some surrounding vertices. I’ve got a boost of performance adding subdivisions and octree to the mesh with model.subdivide() and mesh.createOrUpdateSubmeshesOctree(), and then using BABYLON.BoundingBox.IntersectsSphere with the submeshes bounding box. But as the meshes I need to work on have a very high polygon count, this is still not quite efficient with the mesh partition…

So, after this introduction, the suggestion I have is that may be interesting if the submeshes could be created natively (as an option to not break backward compatibility) using the partitions that the **mesh.updateFacetData()** provides. I’m very new to Babylon, webgl and all of this, so I’m not sure if that is even possible or if it will benefit in other use case scenarios.

Anyway, thank you to make 3D web programing accesible to the mass with this intuitive framework!

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [March 24, 2020, 5:23pm UTC](https://forum.babylonjs.com/t/mesh-subdivisions-in-a-grid-like-style-partitions/9437/2 "2020-03-24T17:23:02Z")

</div>

Adding @jerome to get his thoughts

---

<div class="post-metadata">

**Author:** ![jerome](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jerome/32/22_2.png) [@jerome](https://forum.babylonjs.com/u/jerome)\
**Post date:** [March 28, 2020, 8:26am UTC](https://forum.babylonjs.com/t/mesh-subdivisions-in-a-grid-like-style-partitions/9437/3 "2020-03-28T08:26:31Z")

</div>

I’m blocked at home for a while still and, here, I don’t have much time to code with BJS. So please, do every improvement that you find pertinent 🙂

---

<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:** [March 30, 2020, 4:58pm UTC](https://forum.babylonjs.com/t/mesh-subdivisions-in-a-grid-like-style-partitions/9437/4 "2020-03-30T16:58:11Z")

</div>

Having a play at localising regions on a mesh. Still needs a lot of work but you may find it useful [Babylon.js Playground](https://www.babylonjs-playground.com/#3BA7UL)

```auto
graph.color(856, 4, BABYLON.Color3.Red()); // facet number, depth, color

```

depth 0, just facet, 1 facet plus ones that share a vertex with the given facet, 2 facet, plus adjacent facets and the facets adjacent to the adjacent facets
