Aligning the camera so a model fits inside of a box on the screen

I’m trying to make a something that allows you to position the camera so a model fits inside a box on the screen
The only problem is that I can’t figure out how to calculate the CFrame of the Camera. I have tried out a lot of different things but they never deliver the result I want.

The box on the screen is positioned in the middle of the screen and as size it has an X scale of 0.25 and a Y scale of 1 and the frames SizeConstraint is RelativeYY

Here is an example of what I’m trying to accomplish

1 Like

Try to play with Module3D APIs, because earlier i have the same problem but the box was the entire screen, instead of using screen absolutesize, use the box absolutesize. All of the API and how to use it are inside the Module3D with detailed explanation.

Sent from Phone

Okay thanks I will try that out

1 Like

This post might be helpful:

1 Like

I finally was able to get it work! I used a combination of the Module3D API and the AABB algorithm that you can find here:

3 Likes