Not really sure how to use BILLBOARDMODE_USE_POSITION properly

Hey,

I’m struggling to get my head around the BILLBOARDMODE_USE_POSITION. I was initally thinking of posting this in the Bugs section but figured I might misunderstand it so gonna post it here instead.

I was working on some planes using billboarding using the Y axis in WebXR, when I came across a situation where the plane was still visible in the corner of my eye, but as it was using the camera’s direction instead of position, reading anything from the plane (its displaying some text and small graphics for me) felt annoying. Anything where my direction wasn’t straight at the plane felt a bit off, so I figured I could fix this by having the billboard work based on the camera’s position and not its direction. Now while writing this out, I kinda get why this happens, but am wondering if it’s intended as when I add the BILLBOARDMODE_USE_POSITION flag to the billboardMode, the plane “flips”, making me see the backside of the plane.

I get that the this.lookAt(camera.position); will point in the opposite direction as the camera direction when looking at the billboarded objects, but this feels counter intuitive to me. I could just flip the texture or my uvs or whatnot, but I’m just wondering if this is intended behaviour.

I’ve made a playground example demonstrating this https://www.babylonjs-playground.com/#H7DRX6#2
Also note that plane 3 is basically invisible as it’s not doublesided

1 Like

Hello ! This was added specifically for the use case you mention. By default the system uses camera rotation but with this flag it only uses the position (so you can rotate your camera with no changes which is useful in vr where we have 2 cameras with slightly different rotations)

With use position we will simply ignore the mesh rotation and we will rotate it to face the camera.

Without we will take in account the rotation and add an additional rotation on top of the current one to cancel the camera rotation

Hi, so it kinda works the way I’d expect it to. But to me now it seems like the plane’s facing away from me if I only want the billboarding to work on Y axis (with BILLBOARDMODE_Y | BILLBOARDMODE_USE_POSITION flag). Is this intended? This is “visible” with plane 3 in the example as you can’t see it. If you enable double sidedness for the plane, you can see its backside

Yeah this should be only a problem with plane

the way we create them is a bit backward but we can’t change it now.

I suggest simply rotating it beforehand:
https://www.babylonjs-playground.com/#H7DRX6#3

3 Likes

Ah that explains it, I had a bit different approach at first baking the rotation to the vertices should work better, thanks :slight_smile:

1 Like