[SOLVED] Unexpected light gizmo on right hand system

Hello, I’m new bee of this framework. I met some problem about this:
https://playground.babylonjs.com/#Z4ZGAY#3

you can find the question when you rotate the gzimo about directional light. The direction is obviously wrong in right hand system.

Hey!
The vector3 in the light constructor is a direction. It cannot be (0, 0, 0):
https://playground.babylonjs.com/#Z4ZGAY#4

OK. I will fixed it in my code. But you can see that the direction is different between left hand system & right hand system.
You can try to disable the comment of ‘scene.useRightHandSystem’, then observe the gizmo’s direction.

Oh yeah…unfortunately gizmos are not designed for right handed
Pinging @Cedric to see if he can have a look:)

I’m taking a look.

Actually, I’m wondering if the issue is with the gizmo.
1st screen: Left Hand coordinates. Sphere.position.x = -1 is on the left.Light vector is (1.,0,0). Light comes from the left goes to right. Sphere lighting and lightmesh orientation are fine.

Coordinates changed to right hand.


And now we have the issue. Sphere is now on the right. Light mesh gizmo goes for the right to the left but the sphere directional lighting is the same as before.

So, this looks like the gizmo is fine but the directional light is wrong. Can you confim @Deltakosh ?

oh right!! This is a light issue
Good catch! Can you have a look at it?

Sure! I’m on it

1 Like

And the corresponding PR Fix Right Hand coordinates with directional lights and shadows by CedricGuillemet · Pull Request #6712 · BabylonJS/Babylon.js · GitHub

Thx @Cedric & @Deltakosh.
Hope new version will finish as soon as possible.

Hi, @Cedric & @Deltakosh.
The spot light has the same question.

Argh! I didn’t forget to check the shadow but I forgot to test the spotlight.

1 Like

@Cedric

when you attach the light Gizmo, the light’s direction will be set to negative.
I found solution as following:

public set light(light: Nullable<Light>) {
    if ((light as any).direction) {
        const direction = (light as any).direction.clone() as Vector3;
        if (this.light.getScene().useRightHandedSystem) {
            direction.x = -direction.x;
            direction.y = -direction.y;
            direction.z = -direction.z;
        }
        this.attachedMesh!.setDirection(direction);
    }
}

It is already fixed in the preview branch

1 Like

Thx!!!