Skip to content

Instantly share code, notes, and snippets.

@dghez
Last active February 1, 2023 10:15
Show Gist options
  • Select an option

  • Save dghez/30c9d4821c5b61c8cee558e85bf24a5d to your computer and use it in GitHub Desktop.

Select an option

Save dghez/30c9d4821c5b61c8cee558e85bf24a5d to your computer and use it in GitHub Desktop.
Visible Portion of some element at certain distance, plane.
import {MathUtils} from "three";
// this gives the "visible" plane sizes that is visible from the camera at a certain distance
export default function(distance, camera) {
const vFOV = MathUtils.degToRad(camera.fov);
const height = 2 * Math.tan(vFOV / 2) * distance;
const width = height * camera.aspect;
return { width, height };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment