South pole camera flippage

Hello,

I’ve been trying to put together a bare-bones planet hopping simulation. I’m definitely not up to date on best practices and am very open to all kinds of nitpicks/optimizations/suggestions. The short-term goal is just to add more planets and be able to move from one to another.

Playground link
controls: WASD, spacebar, V, shift, C, F, escape, F1

The issue I’m currently trying to deal with seems to about rotation (what a surprise), specifically messing with the cameras’ up vectors and going all the way upside down. Getting too close to the south pole makes the ArcRotateCamera’s keyboard controls misbehave (as well as suddenly change its own position) and the UniversalCamera flip up/down and left/right on the mouse.

The up vector is at 124, the forward and left vectors and camera are from 145 to 152, and the keyboard controls start at 229. Any help would be greatly appreciated.

There is a setting on ArcRotateCamera which turns of the zoom to far behavior.

camera.allowUpsideDown = false

Does that help?

1 Like

No, changing allowUpsideDown doesn’t affect anything here as far as I can tell

Hello and welcome to the Babylon community! @PolygonalSun our camera expert might have some tips on how to deal with inversing the up vector

2 Likes

Hey, so I’m currently taking a look at the PG to see what’s going on. It looks like when I get to the south pole, it’s hopping back and forth around it. When I have more of an idea of what’s going on, I’ll let you know.

2 Likes

Sorry about the delay on this. I’ve been thinking about this one a bit and I believe that a way to avoid any issues with the poles might be by doing something like making the cameras children of the player. You should be able to get the upVector by using the position of the closest planet and the position of the player (this.body.subtract(somePlanetMesh.position).normalize(), I think). You might need to do a bit of translation for the cameras from local space to world space (getAbsolutePosition()) I think that might work.

3 Likes