# Create VerticesData and Indices of Bounding Box without creating a mesh

**URL:** <https://forum.babylonjs.com/t/create-verticesdata-and-indices-of-bounding-box-without-creating-a-mesh/47423>\
**Category:** Questions\
**Tags:** mesh\
**Created:** [January 22, 2024, 9:53am UTC](https://forum.babylonjs.com/t/create-verticesdata-and-indices-of-bounding-box-without-creating-a-mesh/47423 "2024-01-22T09:53:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DukeVen](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dukeven/32/34217_2.png) [@DukeVen](https://forum.babylonjs.com/u/DukeVen)\
**Post date:** [January 22, 2024, 9:53am UTC](https://forum.babylonjs.com/t/create-verticesdata-and-indices-of-bounding-box-without-creating-a-mesh/47423/1 "2024-01-22T09:53:21Z")

</div>

Hello,

I have meshes I want to get the bounding box of, and then get VerticesData and IndicesData of said bounding box without actually having to create a helper mesh to fetch the info from, for performance reasons.

I am aware that there is boundingInfo.vectorsWorld data, but I’m not sure how I would be able to convert that into vertices data along with the according indices data.

Any help would be appreciated, thanks!  
(Preferably a performant way to do this, as it’s going to be executed for every mesh in the scene at once)

---

<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:** [January 22, 2024, 10:35am UTC](https://forum.babylonjs.com/t/create-verticesdata-and-indices-of-bounding-box-without-creating-a-mesh/47423/2 "2024-01-22T10:35:34Z")

</div>

> [@DukeVen](#):
>
> I have meshes I want to get the bounding box of

So, you can do `mesh.getBoundingInfo().boundingBox`?

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/5/0/50435f52367337f4d7f22c26ae766b02245ef855.png)

---

<div class="post-metadata">

**Author:** ![DukeVen](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dukeven/32/34217_2.png) [@DukeVen](https://forum.babylonjs.com/u/DukeVen)\
**Post date:** [January 22, 2024, 10:50am UTC](https://forum.babylonjs.com/t/create-verticesdata-and-indices-of-bounding-box-without-creating-a-mesh/47423/4 "2024-01-22T10:50:06Z")

</div>

I am aware of that but I want to get Indices Data and Vertices Data for a bounding box of a mesh, without having to create a mesh to apply the bounding box data to.  
My current way of doing it is like so:

```auto
let boundingInfo = mesh.getBoundingInfo().boundingBox;
var width = boundingInfo.maximum.x - boundingInfo.minimum.x;
var height = boundingInfo.maximum.y - boundingInfo.minimum.y;
var depth = boundingInfo.maximum.z - boundingInfo.minimum.z;
var newscale = new BABYLON.Vector3(width, height, depth);

var box = BABYLON.MeshBuilder.CreateBox("group", { size: 1 }, scene);
box.scaling = newscale.clone();
box.position = mesh.position.clone();

var vertData = object.getVerticesData(BABYLON.VertexBuffer.PositionKind);
var indicesData = object.getIndices();

```

but since this method creates a mesh it isn’t very performant, for my case, where i need to be doing this to every mesh in the scene at once.

---

<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:** [January 22, 2024, 11:52am UTC](https://forum.babylonjs.com/t/create-verticesdata-and-indices-of-bounding-box-without-creating-a-mesh/47423/5 "2024-01-22T11:52:36Z")

</div>

You can create a mesh from scratch (so, no need to create a mesh box). See:

> **[Create Custom Meshes From Scratch | Babylon.js Documentation](https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/custom/custom)**
>
> Learn how to create custom meshes in Babylon.js.

---

<div class="post-metadata">

**Author:** ![DukeVen](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dukeven/32/34217_2.png) [@DukeVen](https://forum.babylonjs.com/u/DukeVen)\
**Post date:** [January 22, 2024, 12:29pm UTC](https://forum.babylonjs.com/t/create-verticesdata-and-indices-of-bounding-box-without-creating-a-mesh/47423/6 "2024-01-22T12:29:15Z")

</div>

Thank you for your help, though in my case, using this function achieved what I wanted in the end, in case anyone else is interested:

```auto
function getBoundingBoxVertData(mesh) {

  mesh.refreshBoundingInfo();

  let boundingInfo = mesh.getBoundingInfo().boundingBox;

  var min = boundingInfo.minimumWorld;
  var max = boundingInfo.maximumWorld;

  var vertices = [
    min.x, min.y, min.z, // Vertex 0
    max.x, min.y, min.z, // Vertex 1
    max.x, max.y, min.z, // Vertex 2
    min.x, max.y, min.z, // Vertex 3
    min.x, min.y, max.z, // Vertex 4
    max.x, min.y, max.z, // Vertex 5
    max.x, max.y, max.z, // Vertex 6
    min.x, max.y, max.z // Vertex 7
  ];

  var indices = [
    0, 1, 2, // Face 1
    0, 2, 3, // Face 2
    4, 6, 5, // Face 3
    4, 7, 6, // Face 4
    0, 5, 1, // Face 5
    0, 4, 5, // Face 6
    2, 6, 7, // Face 7
    2, 7, 3, // Face 8
    0, 3, 7, // Face 9
    0, 7, 4, // Face 10
    1, 5, 6, // Face 11
    1, 6, 2 // Face 12
  ];

}

```
