# Why does resetting the pivot point change the position of the box?

**URL:** <https://forum.babylonjs.com/t/why-does-resetting-the-pivot-point-change-the-position-of-the-box/31201>\
**Category:** Questions\
**Created:** [June 9, 2022, 9:56am UTC](https://forum.babylonjs.com/t/why-does-resetting-the-pivot-point-change-the-position-of-the-box/31201 "2022-06-09T09:56:38Z")\
**Posts on this page:** 15\
**Page:** 2

<div class="post-metadata">

**Author:** ![ZoeLeee](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/zoeleee/32/20340_2.png) [@ZoeLeee](https://forum.babylonjs.com/u/ZoeLeee)\
**Post date:** [June 22, 2022, 3:29pm UTC](https://forum.babylonjs.com/t/why-does-resetting-the-pivot-point-change-the-position-of-the-box/31201/24 "2022-06-22T15:29:10Z")

</div>

😃I think there should be a better way without resetting the rotation and scaling.

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [June 22, 2022, 3:31pm UTC](https://forum.babylonjs.com/t/why-does-resetting-the-pivot-point-change-the-position-of-the-box/31201/25 "2022-06-22T15:31:10Z")

</div>

> [@ZoeLeee](#):
>
> a better way without resetting the rotation and scaling

investigating… (thanks for your patience)

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [June 22, 2022, 3:44pm UTC](https://forum.babylonjs.com/t/why-does-resetting-the-pivot-point-change-the-position-of-the-box/31201/27 "2022-06-22T15:44:28Z")

</div>

> [@Blake](#):
>
> But could bake the rotation into the vertices before resetting it thou, that I think would preserve both.

Yes, but doesn’t this sound all a bit complicated to you Guys? May be should find a way to record and keep/freeze the mesh position while dragging the pivot to another position? Just a thought of mine… What are your thoughts?

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [June 22, 2022, 3:49pm UTC](https://forum.babylonjs.com/t/why-does-resetting-the-pivot-point-change-the-position-of-the-box/31201/28 "2022-06-22T15:49:21Z")

</div>

> [@mawa](#):
>
> May be should find a way to record and keep/freeze the mesh position

That’s what I did by caching and maintaining the absolute position in the PG I posted… And I also tried my other idea of baking you quoted but it didn’t work and got edited out.

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [June 22, 2022, 3:56pm UTC](https://forum.babylonjs.com/t/why-does-resetting-the-pivot-point-change-the-position-of-the-box/31201/29 "2022-06-22T15:56:47Z")

</div>

I know you did. Not what I’m saying and (on behalf of the poster) thx for your efforts.  
It’s just that we have been struggling with this for a while (when I say ‘We’, it’s actually mostly @JohnK and I believe he knows his business 😃 so since this has been going on for a while, there might be something (just something) to be done/improved in the method of how we parent (and eventually delay) to a new pivot?

Edit: I hope I am not offending anyone with my broken english, am I? It just feels to me that some sort of improvement could may be be found for the method. Not speaking about the contribution of you Guys trying to find a solution. I hope this is clear for everyone. Meanwhile, have a great day 😃

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 22, 2022, 4:41pm UTC](https://forum.babylonjs.com/t/why-does-resetting-the-pivot-point-change-the-position-of-the-box/31201/30 "2022-06-22T16:41:54Z")

</div>

why not using a parent instead of a pivot here ? so you could rely on setParent which does the job for you ?

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [June 22, 2022, 5:24pm UTC](https://forum.babylonjs.com/t/why-does-resetting-the-pivot-point-change-the-position-of-the-box/31201/32 "2022-06-22T17:24:01Z")

</div>

Also here’s a way to maintain the position and rotation when changing the pivot point. Although I’m not for sure I think it’s what you’re after… 🙂

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

---

<div class="post-metadata">

**Author:** ![ZoeLeee](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/zoeleee/32/20340_2.png) [@ZoeLeee](https://forum.babylonjs.com/u/ZoeLeee)\
**Post date:** [June 23, 2022, 1:01am UTC](https://forum.babylonjs.com/t/why-does-resetting-the-pivot-point-change-the-position-of-the-box/31201/34 "2022-06-23T01:01:55Z")

</div>

Thank you for your answer,the result of setting the axis point should be wrong,by commenting on the 50th line of code, you can find that the axis point is not set correctly.

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [June 23, 2022, 1:21am UTC](https://forum.babylonjs.com/t/why-does-resetting-the-pivot-point-change-the-position-of-the-box/31201/35 "2022-06-23T01:21:29Z")

</div>

I tried commenting out line 50 like you said but it seems to be working as far as I can tell. Maybe you could explain more which parts aren’t working how you want and how you would want it to work?

---

<div class="post-metadata">

**Author:** ![ZoeLeee](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/zoeleee/32/20340_2.png) [@ZoeLeee](https://forum.babylonjs.com/u/ZoeLeee)\
**Post date:** [June 23, 2022, 1:25am UTC](https://forum.babylonjs.com/t/why-does-resetting-the-pivot-point-change-the-position-of-the-box/31201/36 "2022-06-23T01:25:26Z")

</div>

![123](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/1/d/1db6384f14ce2e7f6a03799f48bc7ce99c0e02ff.gif)

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [June 23, 2022, 1:51am UTC](https://forum.babylonjs.com/t/why-does-resetting-the-pivot-point-change-the-position-of-the-box/31201/37 "2022-06-23T01:51:39Z")

</div>

Hmm, if call setPivotPoint like below then is it rotating how you wanted? 🤔

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

---

<div class="post-metadata">

**Author:** ![ZoeLeee](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/zoeleee/32/20340_2.png) [@ZoeLeee](https://forum.babylonjs.com/u/ZoeLeee)\
**Post date:** [June 23, 2022, 2:14am UTC](https://forum.babylonjs.com/t/why-does-resetting-the-pivot-point-change-the-position-of-the-box/31201/38 "2022-06-23T02:14:17Z")

</div>

Okay, my English is not good, I try to express it clearly.  
There are 2 functions in my project that need to modify the pivot point.

1. Objects in the scene may be bound with multiple animations. The pivot point needs to be switched between each animation. The position of the object cannot be changed when switching.
2. Based on Babylonjs RotationGizmo, I developed a gizmo tool that rotates multiple objects together. When I select multiple objects, the gizmo position is in the center of the bounding box of multiple objects. When rotating, it rotates around this center. At the end, it is necessary to To restore the center of rotation, I modified the center of rotation by modifying the pivot point, but it doesn’t seem to work at the moment.Like this,  
 ![123](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/0/4/0451c6adeea9fd8c2e9d7467a06ec3cf9c47d30a.gif)

---

<div class="post-metadata">

**Author:** ![ZoeLeee](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/zoeleee/32/20340_2.png) [@ZoeLeee](https://forum.babylonjs.com/u/ZoeLeee)\
**Post date:** [June 23, 2022, 2:27am UTC](https://forum.babylonjs.com/t/why-does-resetting-the-pivot-point-change-the-position-of-the-box/31201/39 "2022-06-23T02:27:41Z")

</div>

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

It doesn’t work when restoring the axis point, it should be something I wrote wrong

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [June 23, 2022, 5:50am UTC](https://forum.babylonjs.com/t/why-does-resetting-the-pivot-point-change-the-position-of-the-box/31201/41 "2022-06-23T05:50:45Z")

</div>

Actually it looks like when changing the pivot to the identity matrix then can just cache and set the absolute position like in the second time out below. 🙂

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

---

<div class="post-metadata">

**Author:** ![ZoeLeee](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/zoeleee/32/20340_2.png) [@ZoeLeee](https://forum.babylonjs.com/u/ZoeLeee)\
**Post date:** [June 27, 2022, 3:52am UTC](https://forum.babylonjs.com/t/why-does-resetting-the-pivot-point-change-the-position-of-the-box/31201/42 "2022-06-27T03:52:11Z")

</div>

Thanks, this is the best solution for me so far.  
Best wishes

[Previous page](https://forum.babylonjs.com/t/why-does-resetting-the-pivot-point-change-the-position-of-the-box/31201.md?page=1)
