threepipe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

util.ts 415B

123456789
  1. import {MathUtils, Vector2} from 'threepipe'
  2. export const computeFocalLengths = (width: number, height: number, fov: number, aspect: number, dpr: number) => {
  3. const fovRad = MathUtils.degToRad(fov)
  4. const fovXRad = 2 * Math.atan(Math.tan(fovRad / 2) * aspect)
  5. const fy = dpr * height / (2 * Math.tan(fovRad / 2))
  6. const fx = dpr * width / (2 * Math.tan(fovXRad / 2))
  7. return new Vector2(fx, fy)
  8. }