# ArcRotateCamera shifts axis at beta 0 or PI

Hi guys,
is there a workaround for the shifting axis at the point of beta = 0 or beta = PI? This happens for me in case i define a camera where the upper and lower limit of beta is not defined. In the following example the camera movement shifts at rotating around the Y-Axis. How can i deal with this so that the camera always follows the cursor?

ArcRotateCamera playground

Bernhard

Hi @Bernhard and welcome to the forum !

I am having trouble to fully understand the question. Maybe @JohnK or @Wingnut have some amazing tricks in their sleeves for you

I thought my english would improve but I am still lost in translation after this time

1 Like

Iâ€™m wondering heâ€™s asking about the 0.1 offset applied at either of those values to avoid a race condition. If so, donâ€™t believe thereâ€™s a workaround.

â€śSetting beta to 0 or PI can, for technical reasons, cause problems and in this situation beta is offset by 0.1 radians (about 0.6 degrees).â€ť
https://doc.babylonjs.com/babylon101/cameras

1 Like

Welcome Bernhard, and hi to others, too.

Sebavan: â€ślost in translationâ€ť (hey, thatâ€™s what the camera/axis is doing, too! haha)

The camera â€śflip-overâ€ť at the polesâ€¦ is not easy to describe, NOR easy to understand someoneâ€™s description. When I first â€śdealt-withâ€ť arc-cam polar issues, and whined to DK about itâ€¦ he thought I was speaking Swahili. (it was back before I knew what an UP-vector was) (I still donâ€™t)

We should give this common arc-cam issueâ€¦ a â€ścuteâ€ť nameâ€¦ perhaps â€śpolar bearingâ€ť. When standing on the north pole, ALL compass directions are south. (err something like that). Thus we need an epsilonâ€¦ something to prevent the pivot on the compass needleâ€¦ from sitting perfectly atop the north or south poles. (phew)

Needless to say, Iâ€™m no expert at arcCamera â€śtrouble at the polesâ€ť, butâ€¦ there are 2 or 3 â€śpolar behavior propertiesâ€ť on ArcCam classâ€¦ https://www.babylonjs-playground.com/#ESNNAN#2 - lines 21-23.

No promisesâ€¦ but maybe thereâ€™s something useful, there.

Yeah, thatâ€™s involved, for sure. yep, yep, yep. Some people call that â€śmicro valueâ€ťâ€¦ an â€śEpsilonâ€ť. Babylon.js/math.constants.ts at master Â· BabylonJS/Babylon.js Â· GitHub (line 15)

â€śrace conditionâ€ť? I like that term (but not racing - Wingy not a competer). Is race conditionâ€¦ the same as a divide-by-zero condition? shrug. Maybe they are relatives.

All in allâ€¦ yeahâ€¦ thereâ€™s interesting things that happen at the poles of an arc-cam â€śorbitâ€ť, and some work-arounds are active and perhaps adjustable. Polar bearings.

2 Likes

Loooks more and more like the issue is about gimbal lock if you want to look it up and unfortunately besides @Wingnut answer, I am not seeing a lot of possibilities here.

1 Like

Hi @Bernhard and welcome from me. As @Wingnut described there are problems at the poles. (It is to do with a division by sin(angle) which is 0 at angle = 0 and PI)

If you particularly wanted an ariel view in your project as in https://www.babylonjs-playground.com/#ESNNAN#4 then you could change you point of view by rotating the ground and camera direction by pi/ 2 changing vertical to horizontal as in https://www.babylonjs-playground.com/#ESNNAN#5

You will have to remember axis directions have changed.

2 Likes

@JohnK you are my hero

2 Likes

Hi guys! Thanks for this incredible response and special thanks to @JohnK for this smooth and easy solution. I think it would be be its worth to put this solution into documentation close to the point of the pole issue.

https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera