How to rotate mesh by itself with out rotating the camera?

Hey, I am trying to use babylonjs for my project. I can’t implement smooth mesh rotation.
I need to animate picking the model up from the shelf and bring in front of camera, that works :slightly_smiling_face:. And then I want to rotate picked model just like I hold it with my hand, similar to what arcRotate camera does. But the rotation I get is not smooth and doesn’t look real.

I tried to create the model rotation using event listeners - pointerdown, pointermove, pointerup - found the logic from this (https://www.babylonjs-playground.com/#K4UGI8#8) playground but my issue is the intersection point (0,0,0) of xyz axis is not on the center of my model (like on the playground mentioned above - the rotation point is on the center of the box) rather it is on the bottom edge of the model. So that make the rotation weird and unmanageable.

My questions are

  1. How can I change the rotation focal point from the edge to the center of my model? - that might fix my issue.
  2. If there is other better way to do/handle mesh rotation?
  3. how to reset the rotation to the origin/initial point? ( I need this when I return back the model to the shelf, I want to reset as it was before)

Thanks in advance.

This section might help Parents and Pivots | Babylon.js Documentation

@Yofetahe_Habtu
you can move the model to origin (0,0,0) and rotate it.
then move it back to the original position.

Hope this helps.

2 Likes

@gopivell thank you. move back to the origin works.
@JohnK thanks, let me try it and get back to you if I can’t fix my issue.