Inconsistent billboard/parenting 4.21 vs 5.27

repro: https://playground.babylonjs.com/#92Y727#292

comment/uncomment line 39 which is the offset. Switch to 4.21, you’ll notice that
a) the axes have changed !
b) no worries, simply edit line 39 to AIlabel.position.z = 0.4*100; Now, you’ll notice the motion of the AILabel is different from 5.27 !

First noted in 5.23 and then 5.27 is still showing the same inconsistency. I can live with the axes change since its a small edit in my codes but the seasickness is making me dizzy. Was something new introduced to billboard/parenting that I missed ?

repro: https://playground.babylonjs.com/#NRNBMM#533

Switch between 4.21 and latest. It seems that parenting and billboard mode has changed between 4.21 and 5.27. I guess the question is: what if I don’t want my child to be affected by the parent’s rotation while the child is in billboard mode? Is there a switch to turn it off ?

My approach would be, to create a TransformNode inbetween (because you want offset and rotation), then set node as parent of small1. At last set node.position to absolutePosition of box. This might give results you want?

PG:

Edit: It would even work without TransformNode, but you will have to update the position manually, because of offset:

2 Likes

Thanks, there are indeed many workarounds/hacks. I dimly recall that when billboard mode was created, it was intentionally made to exclude some parent transforms. I fail to understand the application for the billboard in its current incarnation (other than some fringe use cases). Regardless, my reason for this thread is that 5.27 broke back compat. There must be a reason the team made the decision, I want to understand what it is.

It is not difficult for me to submit a PR, but I would not know why. Pls help me understand the reason.

This seems to be the reason:

1 Like

I see now. I think there wasn’t a bug, @brightMoon use case could simply be implemented using an intermediate transform node: https://playground.babylonjs.com/#NRNBMM#534

@cedric I presume its too late to revert the PR ? Can we have a programmatic switch to bypass/turn off whatever was added ? Do we open any can of worms if we do so ?

@Takemura Thanks for the follow-up ! On a weekend, no less !

1 Like

Adding a transform can also solve the problem. However, for my demonstration, parent scaling is just a bug for billboard.

5.27 Did fix the bug.

After 5.24, the bug appeared
https://github.com/BabylonJS/Babylon.js/releases/tag/5.24.0
https://github.com/BabylonJS/Babylon.js/pull/12984

Therefore, it needs to be maintained by the official. It needs to be compatible with your and our cases at the same time

Lemme get your application right, you want to
a) parent a plane to a cylinder,
b) have the plane face the camera
c) have the plane maintain its position and size when you scale the cylinder
d) have the plane rotate around the y-axis when you rotate the cylinder and still face the camera ?

1 Like

no, Cylinder and icon plane have the same parent, they are a whole.

Keep it always facing the camera

ok, so a picture is worth a thousand words:
a) parent a plane to a transform node, parent a cylinder to same transform node?
b) have the plane face the camera
c) have the plane maintain its position and size when you scale the cylinder
d) have the plane rotate around the y-axis when you rotate the cylinder and still face the camera ?

red dot is the transform node, blue cylinder and orange plane are parented to red dot. theta is rotation about y-axis wrt red dot ?

1 Like

The cylinder does not rotate. The position of the cylinder does not change, but when the camera rotates, the plane always faces the camera

Like this? https://playground.babylonjs.com/#NRNBMM#535

1 Like

Yes, but I don’t think it should be assigned in real time in onAfterRenderObservable

That is only for demonstration purposes. If you remove it, just add
small1.position = cylinder.position.add(group.position); anywhere in your main code or after you scale yr cylinder in a callback to update the new position. You’ll also realize that even if you switch to 4.21, the codes still work. Hope it helps.

1 Like

I believe @Cedric made some changes (but I might be mistaken). I hope he has some input about this.

Before my change, only the position was forwarded from the parent to the child. An oriented parent with a billboard child could result in the child to not appear as a billboard.
To me, billboard affect the end result. If something is billboard, then whatever his parent hierarchy is, it should appear as a billboard.
Now with Phaselock’s PG https://playground.babylonjs.com/#92Y727#292
I understand it can break back compat.
To fix it for everyone, I can add a static flag in TransformNode to apply Rotation . Default would be off for back compat.

4 Likes

Awesome, thanks for all the hard work! Looking forward to the fix ! :slight_smile:

My turn to hit the sack… Cheers !

New flag added so @brightMoon , you have to add this line:

BABYLON.TransformNode.BillboardUseParentOrientation = true;
5 Likes

Yes, it seems to have no effect

I just checked and it works for me. Do you have more details?

2 Likes