Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace CameraUtils

Index

Functions

convertScreenToWorldSize

  • convertScreenToWorldSize(focalLength: number, distance: number, screenSize: number): number
  • Calculates object's world size based on the focal length and it's camera distance.

    beta

    Parameters

    • focalLength: number

      Focal length in pixels (see setVerticalFov)

    • distance: number

      Object distance in world space.

    • screenSize: number

      Object size in screen space.

    Returns number

    object size in world space.

convertWorldToScreenSize

  • convertWorldToScreenSize(focalLength: number, distance: number, worldSize: number): number
  • Calculates object's screen size based on the focal length and it's camera distance.

    beta

    Parameters

    • focalLength: number

      Focal length in pixels (see setVerticalFov)

    • distance: number

      Object distance in world space.

    • worldSize: number

      Object size in world space.

    Returns number

    object size in screen space.

getBottomFov

  • getBottomFov(camera: PerspectiveCamera): number

getFocalLength

  • getFocalLength(camera: PerspectiveCamera): number | undefined
  • Returns the camera's focal length.

    beta

    Parameters

    • camera: PerspectiveCamera

      The camera.

    Returns number | undefined

    The focal length in pixels or undefined if not set.

getHorizontalFov

  • getHorizontalFov(camera: PerspectiveCamera): number

getLeftFov

  • getLeftFov(camera: PerspectiveCamera): number

getPrincipalPoint

  • Returns the camera's principal point (intersection of principal ray and image plane) in NDC coordinates.

    beta
    see

    https://en.wikipedia.org/wiki/Pinhole_camera_model

    remarks

    This point coincides with the principal vanishing point. By default it's located at the image center (NDC coords [0,0]), and the resulting projection is centered or symmetric. But it may be offset (@see THREE.PerspectiveCamera.setViewOffset) for some use cases such as multiview setups (e.g. stereoscopic rendering), resulting in an asymmetric perspective projection.

    Parameters

    • camera: PerspectiveCamera

      The camera.

    • Default value result: Vector2Like = new THREE.Vector2()

      Optional vector where the principal point coordinates will be copied.

    Returns Vector2Like

    A vector containing the principal point NDC coordinates.

getRightFov

  • getRightFov(camera: PerspectiveCamera): number

getTopFov

  • getTopFov(camera: PerspectiveCamera): number
  • Returns top fov angle for a given perspective camera.

    beta
    remarks

    In symmetric projections, the principal point coincides with the image center, and the vertical and horizontal FOVs are each split at that point in two equal halves. However, in asymmetric projections the principal point is not at the image center, and thus each fov is split unevenly in two parts:

    Symmetric projection Asymmetric projection


    | ^ | | ^ | | | | | |tFov | | |tFov | | lFov v rFov | | | | |<----->x<-------------->| | lFov v rFov | | ppal ^ point | |<--------->x<--------->| | | o | | ppal point=img center | | | img center | | ^ | | | | | |bFov | | |bFov | | | | | | | | v | | v |


    Parameters

    • camera: PerspectiveCamera

      The camera.

    Returns number

    The top fov angle in radians.

getVerticalFov

  • getVerticalFov(camera: PerspectiveCamera): number

setFocalLength

  • setFocalLength(camera: PerspectiveCamera, focalLength: number, viewportHeight: number): number
  • Sets a camera's focal length.

    remarks

    The camera's vertical fov will be updated to achieve the given viewport height.

    beta

    Parameters

    • camera: PerspectiveCamera
    • focalLength: number

      Focal length in pixels. It must be larger than 0.

    • viewportHeight: number

      Viewport height in pixels, used to compute vertical fov.

    Returns number

    The new camera's focal length in pixels.

setPrincipalPoint

  • setPrincipalPoint(camera: PerspectiveCamera, ndcCoords: Vector2Like): void
  • Sets the camera's principal point (intersection of principal ray and image plane) in NDC coordinates.

    beta
    see

    getPrincipalPoint

    Parameters

    • camera: PerspectiveCamera

      The camera.

    • ndcCoords: Vector2Like

      The principal point's NDC coordinates, each coordinate can have values in the open interval (-1,1).

    Returns void

setVerticalFov

  • setVerticalFov(camera: PerspectiveCamera, verticalFov: number, viewportHeight: number): number
  • Sets a camera's vertical fov.

    remarks

    The camera's focal length will be updated to achieve the given viewport height.

    beta

    Parameters

    • camera: PerspectiveCamera
    • verticalFov: number

      Vertical field of view in radians. It'll be clamped to [MIN_FOV_RAD, MAX_FOV_RAD].

    • viewportHeight: number

      Viewport height in pixels, used to compute focal length.

    Returns number

    The new camera's vertical fov in radians.

Generated using TypeDoc