Unproject vector from one viewPort to another

Hey,

I have a small question, I think it is not too complicated but I gave up :smile:
So I have a map with a minimap attached. I want to be able to click on map to go to a specific position and the same functionality should have the minimap. I know there is an option with picking but I think there should be another option with Unproject ( I’m doing this on pointerMove because of this I want to avoid pickRay), but somehow I don’t use it corectly.

Here is a very simplified version of my problem.

When you click on the minimap I expect to move the camera at the clicked position in the main viewport, but for some reasons this is not happening. Any insights are welcome! :hugs:
Meanwhile I’m trying to create a better version because in my project this is almost working but the pickedPoint has an offset which I don’t know from where it comes yet :roll_eyes:

The minimap is rotated by 90° with respect to the main view. This can be remedied by defining a vector up for the pip camera.

You should also take into account that the minimap is not displayed at 1:1 scale but is smaller on the screen, so the picking coordinates should be inflated accordingly.

Finally, the coordinates you use for “unproject” must be relative to the minimap window, not the pointerX/pointerY values of the scene.

PG:

You will see that the camera is going up: this is because you are passing z = 0 to unproject, so the point is on the near plane of the camera (the far plane is when z=1). Try 0.0018 to stay at about the same level as the initial camera position.

3 Likes

Hi, thank you! I was able to fix it in my project as well! :beers:

1 Like