Keeping viewport/cube in same position regardless of screen size

Hey everyone,

I’ve run into a bit of an interesting situation. I’m creating a view cube that is positioned on top of my main scene using a viewport and an arcRotateCamera. I have the view cube working properly, but what’s happening when the window is resized, the cube ‘position’ doesn’t maintain a fixed distance from the edges of the screen.

I’m trying to keep the cube about 10px from the bottom and from the right.

Here’s a very simple PG demonstrating this issue: https://playground.babylonjs.com/#6FBD14#2973

As you move the screen horizontally, the cube moves into/out of view. I’m also having an issue with the viewcube shrinking when I shrink the screen vertically, but one issue at a time.

Not sure if this is a FOV issue or something else. I’ve tried adjusting the height/width of the viewport to no avail. Any help is MUCH appreciated. Thanks!!

1 Like

This is an unusual scenario. Can you explain why you want to do this? Maybe there is a different approach to the problem.

Thanks for the reply Gary. Here’s an example of what it looks like in our UI. When resizing the window, the buttons to the left of the view cube make the left+right view cube movement really obvious. If there’s another approach to a view cube (must use a separate camera), I’ll down to try it!

You could use the same trick than here:

Or:

Ah these are both great, let me implement and get back. I’ll provide an updated PG if it works, thanks!