Connecting a text-2D container to a 3D rotating object with a fixed line motion following

I am trying to have a spinning globe, which upon clicking of a particular label will display a respective container with data passed via an object - userData , however, the idea is to have the spinning clicked label have a line be connected to a 2D static object with respective to the cotnainer, and have the line always be fixed between the 2D-text-label and the selected-label, like this:

image

and when the label is changed position, maintain always the link between both 2D-3D points via the red line… is it possible ?

Here is the current state of the code, with the line going all over the place, despite me trying to link up the Bye! container position, and removing + adding the red line into the scene with a different end-position each time.

You need to zoom-in and click on the half-circle white object to see the results…

Somehow I am unable to link them up so that they stay fixed to each other…

Stuck on line 430 - updatePositionOfLine method

Solved it!

just had to add the following line…

points[1] = info_container.position.unproject(camera).normalize()

that updates the end of the line with the new 2nd point, which keeps the line static relative to a hidden canvas element that is set to have the scene as the parent…

ezgif.com-gif-maker

1 Like