Billboard issue when using attachToBone and positional offset

This demo will toggle billboard mode on and off on the floating text:

https://babylonjs-playground.com/#11BH6Z#614

As you can see, the position of the text is reset when billboard mode is enabled.

With billboard mode on, I want the mesh position to stay where it is as seen with billboard mode off.

Am I missing something about how billboard works or is this a bug?

I think it’s the expected behaviour: when rotating a mesh, the text won’t change position in billboard mode “all” as the text is expected to always stay perpendicular to the camera view direction. And because you set an offset of -200 it is a bit far from the model. If you set -20, I think you can see the result is what you would expect.

Isn’t billboarding based on rotation, not position? :thinking:

What I’m trying to achieve is to have some billboard text positioned to my character’s left. In the PG, you can see it stay to the character’s left, until billboard is enabled where it is no longer at the character’s left.

Hey @JacobF Have been struggling with billboard position myself.

Couple of things.

First, looks like attaching mesh to a bone will adjust its transforms to match bone transforms, which makes perfect sense if you want your dude carry a sword.

There are some lines of code that didn’t make sense to me. Commented them out with question marks.
Eg., I don’t think calculating text ratio from height of the mesh vs font size makes sense. :wink:

From what I understood you want your player to carry balloon like billboard. I would suggest using a mesh attached to a bone that then has a child plane set as billboard.

So… character moves around dragging and rotating pivot with child billboard plane fixed in place.

Take a look.
https://www.babylonjs-playground.com/#11BH6Z#615

Hope it helps.

1 Like

@MarkBevels

“mesh attached to a bone that then has a child plane set as billboard”

is exactly the behavior I want, thank you! :slight_smile:

https://www.babylonjs-playground.com/#11BH6Z#616

So now, no matter what direction my NPC is facing, when the player walks up to them the text is on the right side of the NPC (NPC’s left.)

1 Like