I need help positioning a div so that it is always at the highest point of an object, slightly offset to the left and up from the vertex. You can check out the example here. If the jsfiddle link is not working, refer to the working with no scene rotation snippet below. It works remarkably well.
However, for a work project, I have to rotate the scene itself. This seems to affect the conversion to 2D screen coordinates. You can see the issue here. Also, take a look at the not working with scene rotation snippet below. As you can observe, the label doesn't update correctly in the y-direction when rotating the scene but does so horizontally. To achieve the desired effect, I need to rotate the entire scene.
If someone could provide guidance or create an example on any of the html/js/css snippet sites (like jsfiddle), they would be a lifesaver!
side-note: I attempted, albeit unsuccessfully, to adjust the x- and y-coordinates of each vertex by multiplying them with
sin(sceneRotation)
andcos(sceneRotation)
, but it only made matters worse.side-note 2: I also spent an hour rotating each object in the scene, but since the objects are stored in
THREE.Group
s, it had the same undesirable effect.
working with no scene rotation
click run snippet below
// JS code for working snippet...
// CSS code for working snippet...
// HTML content for working snippet...
not working with scene rotation
click run snippet below
// JS code for non-working snippet...
// CSS code for non-working snippet...
// HTML content for non-working snippet...