# Return to Rest not Behaving as Expected?

**URL:** <https://forum.babylonjs.com/t/return-to-rest-not-behaving-as-expected/12570>\
**Category:** Questions\
**Created:** [July 16, 2020, 10:56pm UTC](https://forum.babylonjs.com/t/return-to-rest-not-behaving-as-expected/12570 "2020-07-16T22:56:41Z")\
**Posts on this page:** 1\
**Showing post:** 58

<div class="post-metadata">

**Author:** ![Drigax](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/drigax/32/16585_2.png) [@Drigax](https://forum.babylonjs.com/u/Drigax)\
**Post date:** [July 23, 2020, 4:57pm UTC](https://forum.babylonjs.com/t/return-to-rest-not-behaving-as-expected/12570/58 "2020-07-23T16:57:22Z")

</div>

Checked @Evgeni_Popov’s changes over the current proposed fix. Looks great! we’re finally properly updating our linked transforms off of `skeleton.returnToRest()`

I noticed that it broke the latest iteration of the playground, however but it appeard to be caused by some of our logic we use to scale our skeleton debug meshes (@L332-336):

```auto
                            if(bone.getParent()){
                                let distanceFromParent = BABYLON.Vector3.Distance(bone.getParent().getPosition(BABYLON.Space.WORLD, this.mesh), bone.getPosition(BABYLON.Space.WORLD, this.mesh))
                                let factor = (distanceFromParent/(longestBoneLength*this.options.displayOptions.sphereFactor))
                                scale*=factor 
                            }

```

resulted in the meshes being far too large, since we’re using the posed mesh absolute positions…

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/d/d50d9a8d6c52859428ee3afe8a793c8d2fbc4734.png)

changing this logic to instead use the local bindPose offset gave us a better result:

```auto
                            if(bone.getParent()){
                                let restPosePosition = new BABYLON.Vector3();
                                bone.getParent().getRestPose().decompose(null, null, restPosePosition);
                                let distanceFromParent = restPosePosition.length();
                                let factor = (distanceFromParent/(longestBoneLength*this.options.displayOptions.sphereFactor))
                                scale*=factor 
                            }

```

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/3/36077a7316cd3168ff1809d8cc76df9353acf313.png)

[https://playground.babylonjs.com/#ZJIBBU#38](https://playground.babylonjs.com/#ZJIBBU#38)

Ok! I think that settles it! I’ll update the PR with the additions. Thanks again!

---

_[View the full topic](https://forum.babylonjs.com/t/return-to-rest-not-behaving-as-expected/12570)._
