linkOffset scale by zoom & zoomed camera to not cut in mesh

Hello together,

I have another idea of extending my project and have new questions:

    1. How to keep linkOffset of GUI control top right corner relative to zoom/distance to meshes?
    1. How to limit camera zoom on different mesh sizes, so that the camera is not cutting into the mesh? Even better would be to make sphere surface zoomable, but I am not sure if this is even possible?

I am trying to use onBeforeCameraRenderObservable to observe camera.inertialRadiusOffset changing like mentioned in GUI Control linkOffset issue

Also I found Zooming to 100% model surface - #5 by EvilTwinsNiceBrother for #2?

Here is my related playground:

Edit: My newer adding #2 is even worse:

What about collision in my PG, can it do part of the job? I am asking, because the collision I setted up (engine,camera,meshes) do not work.

Lemme take a look and make sure that I’m understanding what’s going on.

Sorry about the delay in response. If I’m understanding what you’re trying to do correctly, for #1, you’re trying to get it so that your GUI Rectangle keeps a scaling and position relative to its related mesh. While I’m not sure about the best approach, you might be able to use the position and attributes (like width) of your mesh and use Vector3.Unproject to get its screen space height/width and create a scale of change to apply to your Rectangle. You’ll probably have to compare this to some reference to get a proper scale. You can then apply that to your offsets and it should scale accordingly. For #2, since you are using an ArcRotateCamera, you could probably take the width/diameter of your target mesh and set that as your camera’s lowerRadiusLimit. That should prevent you from zooming into a mesh. You would need to update this as your camera’s target changes though.

For #1 I will try your approach.
Edit: There is still an issue with #1, that it does not consider camera view (position and direction) instead the tooltip sticks to a fix 3D sphere position (min- & maximumWorld) which is unwanted. How to set it up relative to camera? Current #1 PG:

For #2 I have ArcRotate- and UniversalCamera (switchable, see in below PG-part), I found an acceptable way for ArcRotate but none for Universal. How can you make UniversalCamera like a 3rd-person shooter where you cant fly through planet with your space ship. Currently when you “fly” into a tunnel, then the walls right and/or left are cut through. How can i avoid my camera to cut into mesh, when I enter a “room” smaller than my camera? Hopefully i could explain it correctly.

Edit2: The #2 is working just needs some tweaking, check my PG:

Edit3: I tried the new idea out but I don’t know how to move Vector3 around a sphere influenced by direction of ArcRotateCamera. Here is my new PG:

Or how about this idea: To set camera direction onto transformNode in center of tooltiped mesh? Just how do I set transformNode rotation to direction of camera?
idea tooltipoffset

pinging @PolygonalSun

ping again @PolygonalSun

Could be nice feature, if linkOffset scales with accounting size&distance of mesh in current ArcCamera view. I tried to illustrate what I mean:

I found an acceptable solution:

1 Like

That’s a pretty clever solution! Now, I noticed when trying it out that if you rotated the camera, while highlighting the mesh, the connection point of your UI window would move as well (not staying in the relative same place). I’m not sure if that’s what you’re going for, but I figured that it’d be good to bring to your attention as it may require either updating that alignment with each render frame or possibly doing something to make it rotate with the camera.

You mean the linkWithMesh-point of my Tooltip changes? If so that is exactly what i wanted. It only needs updating its position of sphere when mesh is hovered. You might be confused by my red box mesh on sphere, that was only to make it visible what happens, so i was able to adjust everything, but a transformNode is what i actually wanted. Here is my newest version:

1 Like