Looking down with ArcRotateCamera is weird

Hi community. We love the ArcRotateCamera in our project, but often the users look ‘down’ on our models and this is, where it gets difficult.

When you look at this:

Now, start to rotate the scene with small mouse movements and the rotation very often gets weird and changes direction as long as we keep on looking down.

What would be a good way to improve this experience? Do I have to write a new camera or are these simply the mathematical limits of this camera type?

I think you need to avoid Math.PI to target with the camera. I sort of remember something around this.
I suppose a tiny-offset on the cam position and target should make things better (if I understand your problem correctly)

Edit: yes, just found it. There it is in the doc

Setting beta to 0 or PI can, for technical reasons, cause problems, so in this situation, beta is offset by 0.1 radians (about 0.6 degrees).

1 Like

I assume you mean the flip in rotation when crossing the horizon line to keep the camera rotation in the direction of the mouse?

This is how the camera is implemented and is by design. It might be a little “odd” when you rotate in both (pointer) axes, i agree.

Instead of implementing a new camera, you can implement a new ArcRotateCameraPointersInput that will work as you expect it to. @PolygonalSun just extended the great article about it for the docs: Customizing Camera Inputs | Babylon.js Documentation (babylonjs.com)

1 Like

exactly, the users are not happy with the flip in rotation.

Oh, nice. :smiley: Didn’t see this one. Thx and have a great day :sunglasses:

1 Like

So, you suggest to control the values given to the beta property and avoid 0 in a new ArcRotateCameraPointersInput?

Your playground isn’t working for me. It says https://snippet.babylonjs.com/SRZRWV/1771 not found.

My suggestion is to change the implementation of the onTouch function to take the camera’s beta into account when changing the alpha. So if you are flipped, also flip the value that is added to the alpha offset.

Ok, thanks. I will try that.

Apologies. A delay in saving. Edited to:

Edit: With that said, I would still recom the above solution on pointers…despite the (little) additional effort :grin:

You commented out the beta limits, but we need to set them to null.
So, I have to go with the pointers. Thanks.

I commented only for testing. You can reinstate them and then, you can also lower the values of offset to make it more of a top-down view… but then, as I said, I believe the change on pointer is still cleaner for a fix. Your choice :sweat_smile:

Edit: Did you say ‘null’, didn’t realize that sorry. What does this stand for?

Thinking about it a little more - you don’t want to always switch when flipped, just when you are flipping DURING a movement. So you shoud:

  1. detect when a camera orientation event started
  2. Track the changes in beta
  3. during this mode, the onTouch function should flip its behavior ONLY when dragging moved from one mode to the other (happens in beta = 0 and beta = Math.PI).

That’s roughly what I would first try :slight_smile:

camera.lowerBetaLimit = null;
camera.upperBetaLimit = null;

that means, you allow to rotate over the top.

Sounds just right. Thx

1 Like

Sure. But I also saw it on the alpha and in this case, I don’t know what it does. May be you do?

I saw no effect an alpha, I was just testing stuff.

1 Like

Hi again, I just learned, that turning off the inertia in the onTouch pointer, the flipping does no longer occur - rotations above the zenith work smoothly. You can see that clearly in this playground:

Change the comments from line 198 and following. Does that mean, I have to implement my own inertia methods?

To provoke the flipping just rotate with the mouse by moving diagonally over the scene, so that the beta changes from one side to the other. w/o inertia the rotation is fine.

1 Like

Interesting finding. :open_mouth: GJ,

Sounds a bit odd. May be worth calling-in @PolygonalSun at this point. 'see what he would say about this?

BTW, just turning off inertia with the normal arcRotateCamera does NOT help:

This just adds to my confusion…