-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Description
Description
Looking to PR a new PerspectiveCamera helper method .getMarginAt(distance) which returns the height, width and Vector3s for the corners of the camera's viewable area at the input arg distance.
A PerspectiveCamera's viewable margins at an arbitrary distance is a foundational piece of info you can build a lot of clean experiences from. It enables consistent position and scale for 3D designs and is practical for devices or UX with a variable aspect ratio that must be accounted for.
Some common use-cases include:
Solution
Took a function I've been copying around for years and modified it to be a helper method like so.
Alternatives
Wanted some takes on how to best return the result, currently returns the info in a JSON obj like this:
{
topLeft:<Vector3>,
topRight:<Vector3>,
bottomRight:<Vector3>,
bottomLeft:<Vector3>,
height:<float>,
width:<float>
}I can't think of any methods that return JSON like this but perhaps it's okay? I also couldn't find any native THREE class that contains all of the above in an easily accessible way. If we don't want to just return JSON obj like this perhaps there's an opportunity to extend an existing class or create a new one for this use-case.