# BoundingBox wrong calculation with Skinned Meshes?

**URL:** <https://discourse.threejs.org/t/boundingbox-wrong-calculation-with-skinned-meshes/48204>\
**Category:** Questions\
**Tags:** skinned-mesh, bounding-box, mesh, geometry\
**Created:** [February 18, 2023, 9:51pm UTC](https://discourse.threejs.org/t/boundingbox-wrong-calculation-with-skinned-meshes/48204 "2023-02-18T21:51:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cabada](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/cabada/32/38883_2.png) [@cabada](https://discourse.threejs.org/u/cabada)\
**Post date:** [February 18, 2023, 9:51pm UTC](https://discourse.threejs.org/t/boundingbox-wrong-calculation-with-skinned-meshes/48204/1 "2023-02-18T21:51:40Z")

</div>

I’m trying to find the bbox of a skinned mesh, but it’s giving weird results.

Bbox is not correctly calculated:

![Screenshot 2023-02-18 at 15.11.38](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/d/1/d127b9af6bb36a67684daaf6b62b1abd1478c34d.png)

So I went thru the mesh, debugged it with it’s children… and all the inner bboxes looked like this:

![Screenshot 2023-02-18 at 15.15.15](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/e/8/e885df6b41fb2fb9581748cb9e501158383f85b7.png)

There is **no** bbox calculation that counts for the head. I traversed thru all the children, looked for the mesh that corresponds to the head and computed it’s bounding box.

And voila, it looked like this:

![Screenshot 2023-02-18 at 15.31.06](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/7/1/71e1b87fa95bb1c0571835d75d93c4df1c361c18.png)

This small blue cube is the `bbox` calculation resulted from the head of the avatar.

**What is it doing down there? Why does it get that calculation?**

I went deeper into the problem, and I found that the head is children of the Armature, and… the Armature has a scale of `(0.25, 0.25, 0.25)`

**But, why doesn’t the computation takes that into consideration?**

I can scale other types of objects, and the scale wouldn’t make the calculations go nuts.

Seems to only happen when it’s a parent of bones, and this same parent has Skinned meshes as children?

Has anyone encountered with this before?

I tried also to search for `Armatures`, scale them to `(1,1,1)`, compute the `bbox` (which is the way I’ve seen it working), and return Armatures to their original scale… but now I see I’m getting the t-pose of the avatar, you can clearly see the arms opened:

![Screenshot 2023-02-18 at 15.48.33](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/3/3/33ec3e3296e0a34d43fb96715a174b1710ddbe18.png)

Any ideas to achieve a good `bbox` for skinned meshes?

---

<div class="post-metadata">

**Author:** ![seanwasere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/seanwasere/32/20864_2.png) [@seanwasere](https://discourse.threejs.org/u/seanwasere)\
**Post date:** [February 19, 2023, 11:41am UTC](https://discourse.threejs.org/t/boundingbox-wrong-calculation-with-skinned-meshes/48204/2 "2023-02-19T11:41:27Z")

</div>

What is the purpose of culculating the bounding box?

is it for collisions?

There are many options other than trying to calculate bounding boxes for complicated morphing skinned meshes.

A method I sometimes use is to create a sphere collider where I need some boundary.

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/a/e/ae6ccd4e37a4ca43d7d02712ef7b36dc0be6b359.jpeg)

This is fast and serves the purpose well enough in my case.

[![test](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/e/5/e5f396f5f8489b402be1c22450a1ec86662cb774.gif)](https://w7l8ee.csb.app/)

---

<div class="post-metadata">

**Author:** ![donmccurdy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/donmccurdy/32/33209_2.png) [@donmccurdy](https://discourse.threejs.org/u/donmccurdy)\
**Post date:** [February 19, 2023, 8:37pm UTC](https://discourse.threejs.org/t/boundingbox-wrong-calculation-with-skinned-meshes/48204/3 "2023-02-19T20:37:06Z")

</div>

You can compute a perfect bounding box manually if you want:

> [@Accurate GLTF bounding box](https://discourse.threejs.org/t/accurate-gltf-bounding-box/45410/5):
>
> Here’s code for accurately fitting a THREE.Box3 to a THREE.SkinnedMesh — const vector = new THREE.Vector3(); const box = new THREE.Box3().makeEmpty(); const position = mesh.geometry.attributes.position; for ( let i = 0, il = position.count; i \< il; i ++ ) { vector.fromBufferAttribute( position, i ); mesh.boneTransform( i, vector ); mesh.localToWorld( vector ); box.expandByPoint( vector ); } The code above computes the bounding box in world space; omit localToWorld if you prefer local sp…

But usually it’s too expensive to do that every frame as a character moves, and so the default bounding box computation doesn’t try to take armatures into account.

---

<div class="post-metadata">

**Author:** ![cabada](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/cabada/32/38883_2.png) [@cabada](https://discourse.threejs.org/u/cabada)\
**Post date:** [February 19, 2023, 9:22pm UTC](https://discourse.threejs.org/t/boundingbox-wrong-calculation-with-skinned-meshes/48204/4 "2023-02-19T21:22:17Z")

</div>

This worked perfectly! I don’t really need to compute it every frame, only at “charactare load”. Thank you! @donmccurdy

And @seanwasere thanks for the tip, will look into it for collisions! In my case… I’m not computing it it for collisions, it’s only to understand the “true” dimensions of a character so I can add some UI around the itself.
