# Object bounds not updated with animation

**URL:** <https://discourse.threejs.org/t/object-bounds-not-updated-with-animation/3749>\
**Category:** Questions\
**Tags:** animation\
**Created:** [August 10, 2018, 6:25pm UTC](https://discourse.threejs.org/t/object-bounds-not-updated-with-animation/3749 "2018-08-10T18:25:08Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![fuzzy\_wobble](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/fuzzy_wobble/32/2413_2.png) [@fuzzy\_wobble](https://discourse.threejs.org/u/fuzzy_wobble)\
**Post date:** [August 19, 2018, 2:42pm UTC](https://discourse.threejs.org/t/object-bounds-not-updated-with-animation/3749/8 "2018-08-19T14:42:41Z")

</div>

@Mugen87 sent me here from another thread.

I was able to solve this for dddance.party with some help from the illustrious Vince Mckelvie. I remember it being an extremely annoying challenge to solve…

I am using animated DAE files but hopefully it will work for any format? Depends on the SkeletonHelper?

Here is the code from when the animated DAE (object) is loaded:

```
	var avatar = object.scene;
mixer = new THREE.AnimationMixer(avatar);
mixer.clipAction(animations[0]).play();
scene.add(avatar);
var skeleton = new THREE.SkeletonHelper(avatar); 
var box_helper = new THREE.BoxHelper( skeleton, 0xffffff ); //box_helper is just lines
box_helper.material.visible = false;
box_helper.update();
scene.add(box_helper);
var geo = new THREE.BoxBufferGeometry( 1, 1, 1 );
var mat = new THREE.MeshBasicMaterial( { color: 0xeeeeee } ); 
var box_mesh = new THREE.Mesh( geo, mat ); //box_mesh is a transparent box
box_mesh.material.visible = false;
box_mesh.material.transparent = true;
box_mesh.visible = true;

```

Here is the code running every animation loop:

```
for(d=0;d<dancers.length;d++){
		dancers[d].box_helper.update();
		cc = getCenterPoint(dancers[d].box_helper);
		ww = Math.abs(dancers[d].box_helper.geometry.boundingBox.min.x - dancers[d].box_helper.geometry.boundingBox.max.x);
		hh = Math.abs(dancers[d].box_helper.geometry.boundingBox.min.y - dancers[d].box_helper.geometry.boundingBox.max.y);
		dd = Math.abs(dancers[d].box_helper.geometry.boundingBox.min.z - dancers[d].box_helper.geometry.boundingBox.max.z);
		dancers[d].box_mesh.position.set(cc.x,cc.y,cc.z);
		dancers[d].box_mesh.scale.x = ww;
		dancers[d].box_mesh.scale.y = hh;
		dancers[d].box_mesh.scale.z = dd;
}

```

The get center function:

```
function getCenterPoint(mesh) {
var geometry = mesh.geometry;
geometry.computeBoundingBox();
center = geometry.boundingBox.getCenter();
mesh.localToWorld( center );
return center; }

```

I hope this helps :)))

---

_[View the full topic](https://discourse.threejs.org/t/object-bounds-not-updated-with-animation/3749)._
