scene.useRightHandedSystem = true and billboard mode

Hi!

I’ve been trying to convert an old project from a-frame into babylon to get more knowledge of what needs to be done.

I’m a bit confused as to what is the best practice around new projects and scene.useRightHandedSystem

Since gltf is right handed, should i prefer setting the scene to right handed?

When setting to right handed, what problems should I be on the lookout for?

So far I think I found a problem with billboardMode where if in right handed mode, the face is always facing away from the camera
https://www.babylonjs-playground.com/index.html#BJR0F7

Hey!

babylon.js is by default left handed and thus mostly tested in that mode.

glTF loader will take care of everything for you so no need to use scene.userRightHandedSystem unless you want to.

i will make sure to fix the billboard issue you found for the next commit (in a couple of hours)

I have vector3s that are stored in a DB in right handed.

Is there an easy way to convert between the two?

convertRight2Left(v){
return new BABYLON.Vector3(v.x, v.z, v.y)
}

I believe?

then a quad if you run into it I think is:

convertRight2Left(q){
return new BABYLON.Quaternion(-q.x, -q.z, -q.y, q.w)
}

I’m not 100% on that, but I think that sounds familiar from math class decades ago… o_O… But I think this is assuming z is up (Unity coordinate system)… so It might actually be wrong… Actually thinking about this a little harder, this script would need to change because we use y as up not z.

The easiest way is to create a root TransformNode with scaling set to 1,1,-1 and everything will work :slight_smile:

1 Like

that’s a cool trick

Hello. I was searching and found this old topic. The problem shown in the initial message is still happening. Check the playground above. If useRightHandedSystem is set to true, the disc seems to face away if billboardMode != 0

I kind of have to use useRightHandedSystem=true in my project but its making my billboards face away. I could set the face doublesided but I’d rather not. Any ideas?

cc @Evgeni_Popov

Here’s the fix:

2 Likes

Hello,

I bounced on this old issue too. With right-hand system the mesh is facing the camera as expected… but the textures are mirrored too. See https://www.babylonjs-playground.com/index.html#BJR0F7#19
Is there any fix or workaround?

Thanks

Hello,

There’s the same issue with Sprites too.
If you add scene.useRightHandedSystem = true; to this doc playground, the sprite direction is mirrored.
Is it a bug or am I missing something?

please bear with us while @Evgeni_Popov is on a break as it is always amazingly tricky dealing with handedness

It would be awesome to have “native” right-handed support. Sure, converting vectors between two conventions is trivial but it’s a big source of error (especially when the project incorporates external data with a different convention). What is the state of right-handedness in babylon now? I’m thinking of porting my threeJS project to babylonJS (mostly because of compute shaders and physics support), but the handedness is a big deal to me.

You should be able to simply set 'scene.useRightHandedSystem = true` and it should work :wink:

Sounds good. I know this is a bit vague, but does anyone have an impression on how difficult it is to port from ThreeJS to babylon? My project is only some 3000 lines (typescript), where maybe 500 touch the threeJS API. If anyone’s come across any major roadblocks in this kind of port, such cases would be helpful to know about.

Edit: it uses electron+vite, by the way. Not sure if that matters, it’s my first time touching web.

Ported in 2 days! No hard problems, the part that took the longest (not very long) was porting the custom shaders and getting my pointcloud rendering to work.

1 Like

Congrats!! can we see it now? :slight_smile: