Unexpected behavior for z-up right-handed coordinate system

I currently try to understand how right-handed z-up works in Babylon as almost all of our 3d-data works in that coordinate system due to the fact that we have to synchronize it between multiple renderers. I noticed a few inconsistencies while playing around but maybe that’s just missing understanding of the internals.

Observations (while using z-up and right-handed):

  • Camera position/target needs to be provided in Y-Up?
  • Mesh position coordinates will be handled in Z-Up?
  • Mesh.CreateGround works in Y-Up

Info:

  • Bug repro on: https://playground.babylonjs.com/#YUT9UZ#2
  • Expected result: After changing to right-handed and z-up I expect everything to work with the z-up coordinate space
  • Current result: it’s a mix of both modes

Babylon.js is inherently and deeply left handed with Y up.
We offer an alternative with the scene.useRightHandedSystem but this is not the main mode. And even in this mode the system is still Y up (but with right handed mode).

By setting the camera upVector to 0, 0,1 you are actually rotating the camera but all the maths will still be done in a Y up system

That’s my understanding, however doesn’t explain the different outcomes I see in my playground example. It seems that some methods handle right-handed mode and the camera up-vector (0,0,1) correctly and some other don’t.
What’s the proposed way for the described scenario? Stay with Y-Up left-handed and transform all input and output vectors and models into the correct coordinate system or using scene.useRightHandedSystem and camera.upVector (0,0,1)?

Well some functions may not yet support correctly the righHandedMode for sure as we added it on a per ask basis
Can you isolate function that is not working well?

As a overall advice, I would stay: stick with left handed :slight_smile:

There are several applications that utilize a z-axis up scene orientation. As @Deltakosh mentions that babylon.js is y-axis scene oriented. As this topic has come up for several years on the forum, my best answer has always been to export from your application or re-export your scene from another application in a y-axis up orientation. Otherwise you’ll be constantly coding around this. If applicable, the free FBX importer and exporter often works well.

Galen

2 Likes

A left-handed system is unappropriated as you want your system used by scientists. Everything your learn in math and scientific education works in right-handed systems. I’d love to use Babylon, but in a left-handed system simple things are a giant brain fuck. If you need some basics functions to copy watch for numpy and python stuff out there. Like @Galen mentioned before, please don’t let us code around this. Please stick to physics and its conventions.

1 Like

Unfortunately this is wrong. DirectX for instance is left handed. Maya as well
They are conventions. Left or right re both ok and an engine has to stick with a convention.
So no this is NOT unappropriated. This is a convention.

And get ready for more. Even though we were right handed by default, should we pick Y up or Z up? because Max is Y but unreal is Z.

Maya and Unity are different as well.

There is NO truth but only conventions

But for your convenience, as I mentioned earlier, you can still force Babylon.js to be right handed:

scene.useRightHandedSystem = true;
3 Likes

It’s also just not that hard to deal with if you code some transform utilities. Our project involves rendering solar panels on roof tops and those panels are initially placed by AI. The AI gives us Z-UP right-handed coordinates. We just run everything through some conversion utilities, set the camera up vector to (0, 0, 1) and it’s working great. However, I will say that I do with there was a way to set scene.upVector = new Vector3(0, 0, 1) as it would make jumping between coordinate systems a lot easier. Especially in our case where we can’t change the source data at the source so it would have been nice if we could have just configured our scene coordinate system to match. That said, transforming things as they come in and back again as they go out really isn’t that big of a deal. You literally just flip-flop Y and Z values coming in and undo that on the way out. The ability to change the handedness of the scene gets rid of the extra complications.