Change in TransformNode.lookAt() from 3.3 -> 4.x

I am converting GUI code to latest version. Here is an old playground of mine that looks right in v3.3:
https://www.babylonjs-playground.com/#Q81PBV#1

In latest versions (besides % warnings and other oddities) the mesh plane no longer faces the camera. I think it may be in a stored translation/billboard - was already digging a bit… I will be checking it out fully this weekend to PR, but just wanted to share here in case anybody had any thoughts.

I tried simple 180 degree correction lookAt(camera.position, Math.PI / 2), but it’s not just because it’s the backface :slight_smile:

Why dont you use the billboard mode?
https://www.babylonjs-playground.com/#Q81PBV#12

1 Like

But that didnt answer your question :slight_smile:
I honestly have no idea why it happened, I can only assume that it was something repaired in the math or the actual lookAt function.

I remember @Deltakosh saying that they changed lookAt so that it uses the positive z axis instead of the negative z. Something like that. This should have been added to the breaking changes section of the release notes. I wasn’t able to find it there, though.

2 Likes

Yep it was actually a bug in the look at function

1 Like

It seems less intuitive that I have to have a plane with GUI attached to look away from the camera to see the “front” face (while BILLBOARDMODE_ALL shows correctly facing). I will do more investigation - Thanks for the feedback and tips :slight_smile:
ie: this has the GUI not mirrored:
plane.lookAt(camera.position.add(camera.getForwardRay().direction.scale(50)))

this should work as well: https://www.babylonjs-playground.com/#Q81PBV#13

1 Like