# solved Make a Perfect Plane to Fit Frustum

## Recommended Posts

So, I can definitely figure this math out but I was looking to see if there is a quick trick anyone can think of to make a plane fit exactly into the camera's frustum.

IE if I have a camera at (0,0,-10) and a view port that is 1:1 or even 1:1.5 ratio what size would a plane need to be to cover the whole viewport...  (I know I know simple math), I was hoping for a quick method if anyone has one though, no rush its not anything I actively need but would be useful for a side projects I am doing.

*EDIT*
Ill prolly just use this https://docs.unity3d.com/Manual/FrustumSizeAtDistance.html

##### Share on other sites

well, assuming that d is the distance from the camera to your plane, fov the camera fov angle and y the plane half height (and assuming that the frustum cam.minZ is still 1), then

y = d * tan(fov / 2)

and if x the half the plane width

x = y * camera.aspectRatio

if I remember well

##### Share on other sites

Unless, you do not want to care.  Switch to orthogonal camera an distance as long as z is neg.  Would not plane be, wait I'll check.

##### Share on other sites

window.innerWidth & window.innerHeight

##### Share on other sites

@JCPalmer is that to get the aspectRatio?  That's what I am assuming but was wondering about your input.

##### Share on other sites

@jerome, @JCPalmer : Thanks guys! https://playground.babylonjs.com/#UJWGY4

Your math off the top of you head was close homie!  not halfsizing the fov was the only change.

##### Share on other sites

18 hours ago, Pryme8 said:

@JCPalmer is that to get the aspectRatio?  That's what I am assuming but was wondering about your input.

No simpler than that.  From a lack of math standpoint, I win!!!  I did switch to asking engine for the width, but no fov, tangent() calls, & my camera distance must only be less than the max z

##### Share on other sites

That's awesome! Way Clean!

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.