Add GUI Control linkWithMesh to link with TransformNode

Hello,

I am attempting to have better control over where my labels go. My method so far has been to create empty’s in blender and then when exporting, they are imported into the scene as Transform Nodes. I can get them to link with GUI controls as demonstrated here (https://www.babylonjs-playground.com/#XCPP9Y#1046).
However, this is kind of messy and as you can see, the only thing that needs to be added is that a TransformNode needs bounding info, specifically it’s center.

I have tried to use linkOffsetX/Y but just don’t really like how they work when zooming in/out, especially a lot. Is there a way to add this in to the beta, and if not, perhaps a better way than what I am currently doing to just add on to the transform node that property?

Thanks,
Devin

it will be fixed in next nightly. You will be able to directly use transformNode directly :slight_smile:

Thanks!

@Deltakosh

I just got around to testing this and found a bug I think.
https://www.babylonjs-playground.com/#973W0S

It seems that when linking with a Transform Node, the text ends up about double off from where I would expect it to be.

let me check!

Ok bug found…will be fix in next nightly:)

Another bug found, I write it here at first, so I avoid opening new topic.

If you take original PG: https://www.babylonjs-playground.com/#XCPP9Y#1046, and add one line.
Just move sphere for that much, so it is off screen (depends on your canvas size), and it crashes (nothing is rendered, error is visible in console).

Edited playground: https://www.babylonjs-playground.com/#XCPP9Y#13718
Line that I added:
sphere.position.x = 25;

Update:

If you comment line 48 on my edited PG ( // rect1.cornerRadius = 20;) it works.
No err in console, rendered as expected (without corner radius).

Can somebody check this? :pray:

Pretty weird it crashes like this :frowning: @RaananW can you have a look ?

2 Likes

Problem solved, thank you for quick response!! :muscle:

1 Like

The same problem still occurs, if you set your label.fontSize. I guess it cant calculate cornerRadius properly. So you have to set rect1.fontSize .

PLAYGROUND: https://www.babylonjs-playground.com/#XCPP9Y#13890
uncomment line 56, and comment line 61 and it works.

Yeah, I see. It is the same issue. Call order seems to be off. I’ll fix it soon, thanks for letting us know!!

PR was already submitted:

[GUI] Lines array is generated later by RaananW · Pull Request #12670 · BabylonJS/Babylon.js (github.com)

And merged :wink:

1 Like