How to obtain the distance ratio from the camera to the node

I encountered a problem where I generated a div near a node. I wanted the div to also shrink with the distance of the camera. How can I control the scale of the transform in stlye? I tried using Vector3. Distance (camera. position, node. position), but I felt that the scaling of the div was incorrect with the rotation of the camera

My partial code is:

const zoom = oldDistance / Vector3.Distance(camera.position, node.position);
element.style.transform += scale(${zoom});

If you can use a plane in the scene itself, you get the shrinking for “free” :slight_smile:

2 Likes

This is a great suggestion, but the problem I am currently facing is that I have to use div to achieve this effect. I have been confused about this issue for a long time

The problem has been resolved. I need to use the absolutePosition attribute of the node instead of the position, which is my oversight as the node may be a transformer node