# setPivotPoint/setPivotMatrix, don't affect the mesh

**URL:** <https://forum.babylonjs.com/t/setpivotpoint-setpivotmatrix-dont-affect-the-mesh/14578>\
**Category:** Questions\
**Created:** [October 1, 2020, 10:03am UTC](https://forum.babylonjs.com/t/setpivotpoint-setpivotmatrix-dont-affect-the-mesh/14578 "2020-10-01T10:03:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nogalo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nogalo/32/120_2.png) [@nogalo](https://forum.babylonjs.com/u/nogalo)\
**Post date:** [October 1, 2020, 10:03am UTC](https://forum.babylonjs.com/t/setpivotpoint-setpivotmatrix-dont-affect-the-mesh/14578/1 "2020-10-01T10:03:56Z")

</div>

Hi guys.

I need your help. Here is playground for my issue

[https://www.babylonjs-playground.com/#4UR12G#6](https://www.babylonjs-playground.com/#4UR12G#6)

So at the start I have pivot (redSphere) in the sphere origin.

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

Now I want to move pivot somewhere else (only enabled Z axis in the playground)

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

And I can rotate the mesh and it rotates around the new pivot point position

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

Now I want to change pivot position again, but I want mesh to stay at the same position, and after I rotate it again it will then rotate around newly defined pivot point position.

At the moment If I change the pivot point, the mesh will follow

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

I understand that this is supposed to happen, as I change pivot position and that same rotation is still applied to the sphere, but now around new pivot position.

So I am kinda aware that I have to reset rotation before changing the pivot again, but I tried some things and I couldn’t figure out how to do it properly.

I appreciate any help.

Thanks.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [October 1, 2020, 3:58pm UTC](https://forum.babylonjs.com/t/setpivotpoint-setpivotmatrix-dont-affect-the-mesh/14578/2 "2020-10-01T15:58:35Z")

</div>

pinging @JohnK who wrote a lot of great doc about pivots

---

<div class="post-metadata">

**Author:** ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)\
**Post date:** [October 1, 2020, 7:11pm UTC](https://forum.babylonjs.com/t/setpivotpoint-setpivotmatrix-dont-affect-the-mesh/14578/3 "2020-10-01T19:11:09Z")

</div>

Pivots and rotations are very tricky to get your head around. Its been quite a while since I wrote the docs on pivots and used pivots. I think I understand what you need which is.

set a pivot point  
rotate about pivot point  
set a new pivot point that leaves the mesh in the same position and rotation

rotate about new pivot point.

I am quite busy at the moment but will see if I have some time tomorrow to think about it.

---

<div class="post-metadata">

**Author:** ![nogalo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nogalo/32/120_2.png) [@nogalo](https://forum.babylonjs.com/u/nogalo)\
**Post date:** [October 1, 2020, 7:29pm UTC](https://forum.babylonjs.com/t/setpivotpoint-setpivotmatrix-dont-affect-the-mesh/14578/4 "2020-10-01T19:29:19Z")

</div>

Yes. That’s correct. That’s what I am aiming for. I tried several things to achieve that, but no luck so far. I will keep trying as well. Thank you for the answer. I appreciate it.

---

<div class="post-metadata">

**Author:** ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)\
**Post date:** [October 2, 2020, 11:04am UTC](https://forum.babylonjs.com/t/setpivotpoint-setpivotmatrix-dont-affect-the-mesh/14578/5 "2020-10-02T11:04:06Z")

</div>

Haven’t solved the pivot problem.Perhaps in a week or so I will have time for another look. In the meantime I have set up two functions to set position and rotation of a mesh relative to a point. Probably not exactly what you want but hope they help for the moment.

positionMeshRelToPoint

rotateMeshAboutPoint

[https://playground.babylonjs.com/#1MKHR9#72](https://playground.babylonjs.com/#1MKHR9#72)
