[SOLVED] How to use "BABYLON.Mesh.BILLBOARDMODE_ALL" properly

Hi,
I have the following example and try to use “BABYLON.Mesh.BILLBOARDMODE_ALL” to orient the x,y, and z characters to the camera. If I commented lines 88-90 out, the x,y and z letters were located properly. However, when lines 88-90 are activated, the x,y and z letters are not rotated properly. Can someone help look at this and see what went wrong here?

https://playground.babylonjs.com/#3D2GX1#1

Thanks!

Sorry, i might be missing something, but it seems like it is working?
Want to explain exactly what you are trying to achieve?

Hi, @RaananW, Thanks for responding. If you look at the playground I posted, at the location with a small ball, the y and z letters are not in the right positions. If “billboardmode_all” is turned off by commenting out lines 88-90, the “y” and “z” letters are in the right positions; but those letters will not face the camera. I intended to use " billboardmode_all", but couldn’t get those letters in the right locations. Thanks again for looking into this.

They are not in the correct positions because of lines 100 - 102 where you change the direction of the axes. The labels are not parented to the axis so they remain in the same position when the axes rotate.

Have moved the camera position so that it is easier to see both sets of axes. Your PG made it difficult because the camera was not focused on the axes your were talking about.
https://playground.babylonjs.com/#3D2GX1#1

Hi, @JohnK,

Thanks for responding. As shown in the playground Lines 92-94, I did assign the axis as the parent of each label. The issue is with “Billboardmode_all”. When it is not used by commenting out Lines 88-90, each label will be positioned correctly. Can you take a second look at this? Thanks again.

Sorry, don’t know how I missed that. Moral - don’t try to answer questions when you are pushed for time.

Here is a simplified PG to show your issue https://playground.babylonjs.com/#3D2GX1#2

Comment or not on line 40 to see the difference. At the moment I haven’t got time(or the brains) to work out why. However @Deltakosh has done some work about this in this thread in the old forum Billboard mode (solved) - Questions & Answers - HTML5 Game Devs Forum

the post in the above link contains a PG showing the effect of the different billboard modes.

Sorry not to have been more help.

Thanks. @JohnK.

I take a look at the previous post and made a minor modification to the playground you referred to as follows.
https://www.babylonjs-playground.com/#UJEIL#19
You can see that when the parent rotates, the child with the “Billboard” on will stay in the same place and the left child without the “Billboard” on will rotate properly. Hopefully someone can help resolve this issue.

Unfortunately this is a known limitation. You cannot rotate a billboard parent

To some extends, if the mesh has no translation, you can set

m.preserveParentRotationForBillboard = true

This is because of the math involved to compute the billboarding. I always recommend not to parent billboards if parent contains rotation.

Hi, @Deltakosh,

Thanks for the response. You also cannot rotate a billboard around an axis, such as a line, correct?

billboard cannot be rotated because they are billboards :slight_smile: The system will compute the correct rotation for you

Thanks! @Deltakosh This answered my question. I will try to work around it. It would be nice to have a feature to update the position of the billboards to account for a global rotation (around a parent or an axis) and at the same time to rotate the billboards mesh itself around its local axis to face the camera.

you can still change the billboard position at your will.
The idea could be to have something that run per frame which sync your billboard position with a dummy (not visible)

1 Like

Thanks! @Deltakosh
It is a great suggestion. It should work.