# Get boundbox size

**URL:** <https://forum.babylonjs.com/t/get-boundbox-size/45590>\
**Category:** Questions\
**Created:** [November 10, 2023, 1:23am UTC](https://forum.babylonjs.com/t/get-boundbox-size/45590 "2023-11-10T01:23:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lvjing1111122](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lvjing1111122/32/36450_2.png) [@lvjing1111122](https://forum.babylonjs.com/u/lvjing1111122)\
**Post date:** [November 10, 2023, 1:23am UTC](https://forum.babylonjs.com/t/get-boundbox-size/45590/1 "2023-11-10T01:23:18Z")

</div>

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

```auto
    var sphere = BABYLON.MeshBuilder.CreateSphere("sphere", { diameter: 2, segments: 32 }, scene);
    sphere.showBoundingBox = true

    const boundingInfo = sphere.getBoundingInfo()
    const size = boundingInfo.boundingBox.extendSize
    console.log(boundingInfo.boundingBox)

    const { x, y, z } = size
    const box = BABYLON.MeshBuilder.CreateBox('text', { width: x, height: y, depth: z }, scene)

```

I want to create a box with the same size as the bound size  
boundingBox.extendSize & boundingBox.extendSizeWorld, It seems that it does not allow me to accurately obtain the bound size.

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/f/8/f8af4cfa136230a3f2a043f359ced3643ccf9569.png)

I summed up the rule as follows: \*2 based on the original size

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [November 10, 2023, 2:30am UTC](https://forum.babylonjs.com/t/get-boundbox-size/45590/2 "2023-11-10T02:30:14Z")

</div>

```auto
    let sphereMin = sphere.getBoundingInfo().boundingBox.minimum;
    let sphereMax = sphere.getBoundingInfo().boundingBox.maximum;

    // this reports the "size" of the targeted object
    const size = sphereMax.subtract(sphereMin).length()

```

Example - [https://playground.babylonjs.com/#4F33I3#397](https://playground.babylonjs.com/#4F33I3#397)

---

<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:** [November 10, 2023, 2:40am UTC](https://forum.babylonjs.com/t/get-boundbox-size/45590/3 "2023-11-10T02:40:39Z")

</div>

**extendSize** is a vector that defines the amount of additional extension of the bounding box on each axis. Not the actual size, I suggest you use **minimumWorld** and **maximumWorld** to calculate the size

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [November 10, 2023, 3:11am UTC](https://forum.babylonjs.com/t/get-boundbox-size/45590/4 "2023-11-10T03:11:21Z")

</div>

My first answer was incorrect regarding the question.  
Here is much more correct example - [https://playground.babylonjs.com/#4F33I3#718](https://playground.babylonjs.com/#4F33I3#718)

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/a/7/a711b9b228f8a111f43cfc975f096856f2a96309.png)

---

<div class="post-metadata">

**Author:** ![lvjing1111122](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lvjing1111122/32/36450_2.png) [@lvjing1111122](https://forum.babylonjs.com/u/lvjing1111122)\
**Post date:** [November 10, 2023, 8:01am UTC](https://forum.babylonjs.com/t/get-boundbox-size/45590/5 "2023-11-10T08:01:18Z")

</div>

Okay, I’m starting to understand a little bit

---

<div class="post-metadata">

**Author:** ![lvjing1111122](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lvjing1111122/32/36450_2.png) [@lvjing1111122](https://forum.babylonjs.com/u/lvjing1111122)\
**Post date:** [November 10, 2023, 8:14am UTC](https://forum.babylonjs.com/t/get-boundbox-size/45590/6 "2023-11-10T08:14:28Z")

</div>

It seems that this method is also allowed，because of musk`s suggestion

```auto
// Our built-in 'sphere' shape.
    var sphere = BABYLON.MeshBuilder.CreateSphere("sphere", { diameter: 2, segments: 32 }, scene);
    let sphereMin = sphere.getBoundingInfo().boundingBox.minimumWorld;
    let sphereMax = sphere.getBoundingInfo().boundingBox.maximumWorld;

    // this reports the "size" of the targeted object
    // const size = sphereMax.subtract(sphereMin).length()
    const size = BABYLON.Vector3.Zero()
    size.x = sphereMax.x - sphereMin.x
    size.y = sphereMax.y - sphereMin.y
    size.z = sphereMax.z - sphereMin.z

    console.log(size)

```

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [November 11, 2023, 1:34am UTC](https://forum.babylonjs.com/t/get-boundbox-size/45590/7 "2023-11-11T01:34:06Z")

</div>

Updated my previous PG with [https://playground.babylonjs.com/#4F33I3#724](https://playground.babylonjs.com/#4F33I3#724) to consider mesh scaling as well.
