Link Offset in Mesh Coordinates

Hello,

I’m trying to control where my line points to with a linked label.

For example, see the label for Sphere 7 in this playground:

https://playground.babylonjs.com/#CMFBI9#2

I see that I can use Link Offset X/Y and Also in Pixels but I want to offset by the diameter of the Sphere so as to point to the edge of it and not the center of it.

What’s the best way to go about doing this? I’ll want it to point to the edge of the mesh even when the view is zoomed in or out.

The best option I’ve found so far is to create an invisible plane located with its center where I want the line to point to and have its parent be the visible mesh.

cc @DarraghBurke

I added my current method of doing this (with two plane meshes created from an abstract plan):

I’m open to suggestions on how to better accomplish this.

It’s likely obvious but I’m new to JS and BabylonJS.

The best way I can think of would be to use a TransformNode, parent it to your target mesh, and then link with that: GUI Demo | Babylon.js Playground (babylonjs.com)

It doesn’t add any geometry to the scene. If you transform the parent mesh, the transform node will move/rotate with it. I think this will probably be the cleanest approach.

Oh yes! Great suggestion, thank you!

1 Like

Updated playground with @DarraghBurke suggestion:

2 Likes