# SetPivotMatrix with Gizmo

**URL:** <https://forum.babylonjs.com/t/setpivotmatrix-with-gizmo/4403>\
**Category:** Bugs\
**Created:** [July 10, 2019, 2:02pm UTC](https://forum.babylonjs.com/t/setpivotmatrix-with-gizmo/4403 "2019-07-10T14:02:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [July 10, 2019, 2:02pm UTC](https://forum.babylonjs.com/t/setpivotmatrix-with-gizmo/4403/1 "2019-07-10T14:02:11Z")

</div>

Hi,

When I move the pivot point, the gizmo is not correctly positioned.

Here is a PG for better understand: [https://www.babylonjs-playground.com/#1UZM4G#1](https://www.babylonjs-playground.com/#1UZM4G#1)

Edite the value Translation(1, 1, 1) line 28 to see the problem.  
Also edit the position of the box to put it back in the center of the world to see that it works as it should. I noticed that it works well when the box has the position 0,0,0, but not when the box is no longer in the center of the world.

Thanks @trevordev

---

<div class="post-metadata">

**Author:** ![trevordev](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/trevordev/32/16_2.png) [@trevordev](https://forum.babylonjs.com/u/trevordev)\
**Post date:** [July 10, 2019, 6:12pm UTC](https://forum.babylonjs.com/t/setpivotmatrix-with-gizmo/4403/2 "2019-07-10T18:12:26Z")

</div>

@Dad72 If I understand your issue, I think

box.bakeCurrentTransformIntoVertices();

is causing the translation you added to be baked as well. Could you not cache the position, do your changes and then set the position back?

See [https://www.babylonjs-playground.com/#1UZM4G#2](https://www.babylonjs-playground.com/#1UZM4G#2)

---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [July 10, 2019, 6:21pm UTC](https://forum.babylonjs.com/t/setpivotmatrix-with-gizmo/4403/3 "2019-07-10T18:21:26Z")

</div>

Works well. Thank you Trevor

---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [July 10, 2019, 6:59pm UTC](https://forum.babylonjs.com/t/setpivotmatrix-with-gizmo/4403/4 "2019-07-10T18:59:33Z")

</div>

I made a few improvements to make it work perfectly.

I removed :`box.setPivotMatrix(BABYLON.Matrix.Identity());`  
And I added :  
`box.position.set(-box.getPivotMatrix().getTranslation().x, -box.getPivotMatrix().getTranslation().y, -box.getPivotMatrix().getTranslation().z);`  
instead of  
`set(0,0,0)`  
so that I can recover the new pivot transformation with `box.getPivotMatrix().getTranslation()` and reset it to zero or some other value.

[https://www.babylonjs-playground.com/#1UZM4G#4](https://www.babylonjs-playground.com/#1UZM4G#4)
