setPivotPoint/setPivotMatrix, don't affect the mesh

Hi guys.

I need your help. Here is playground for my issue

https://www.babylonjs-playground.com/#4UR12G#6

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

image

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

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

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

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.

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

1 Like

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.

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.

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