three-cad-viewer
    Preparing search index...

    Class CameraInternal

    Manages orthographic and perspective cameras for the viewer.

    Camera wraps both camera types and provides:

    • Seamless switching between orthographic and perspective
    • Preset positions (iso, front, top, etc.)
    • Support for Y-up and Z-up coordinate systems
    • Synchronized position/zoom across camera types

    Supports three modes via up parameter:

    • "Y": Y-up (Fusion 360 compatible)

    • "Z": Z-up (FreeCAD, OnShape compatible)

    • Legacy Z-up mode

    • This is an internal class used by Viewer

    Index

    Constructors

    • Create a combined camera (orthographic and perspective).

      Parameters

      • width: number

        canvas width.

      • height: number

        canvas height.

      • distance: number

        distance from the lookAt point.

      • target: Vector3Tuple

        target (Vector3) to look at.

      • ortho: boolean

        flag whether the initial camera should be orthographic.

      • up: UpDirection

        Z or Y to define whether Z or Y direction is camera up.

      Returns Camera

    Properties

    camera: OrthographicCamera | PerspectiveCamera
    camera_distance: number
    oCamera: OrthographicCamera
    ortho: boolean
    pCamera: PerspectiveCamera
    target: Vector3
    up: UpMode
    yaxis: Vector3
    zaxis: Vector3

    Methods

    • Update camera dimensions when viewport size changes.

      Parameters

      • distance: number

        Distance used for orthographic frustum calculation.

      • width: number

        New viewport width in pixels.

      • height: number

        New viewport height in pixels.

      Returns void

    • Get the current camera.

      Returns OrthographicCamera | PerspectiveCamera

      Camera object.

    • Get the current camera position.

      Returns Vector3

      camera position.

    • Get the current camera quaternion.

      Returns Quaternion

      camera quaternion.

    • Get the visible area dimensions at the target plane.

      Returns { height: number; width: number }

      The visible width and height.

    • Set the lookAt point for the camera to the provided target.

      Returns void

    • Calculate projected size for orthographic camera.

      Parameters

      • frustum: number

        View frustum size.

      • aspect: number

        Viewer aspect ratio (width / height).

      Returns [number, number]

      Width and height [w, h] for the orthographic camera.

    • Set camera position.

      Parameters

      • position: Vector3Tuple | Vector3

        position as 3 dim Array [x,y,z] or as Vector3.

      • relative: boolean

        flag whether the position is a relative (e.g. [1,1,1] for iso) or absolute point.

      Returns void

    • Setup the current camera.

      Parameters

      • relative: boolean

        flag whether the position is a relative (e.g. [1,1,1] for iso) or absolute point.

      • position: Vector3 | null = null

        the camera position (relative or absolute).

      • quaternion: Quaternion | null = null

        the camera rotation expressed by a quaternion.

      • zoom: number | null = null

        zoom value.

      Returns void

    • Set zoom value.

      Parameters

      • val: number

        float zoom value.

      Returns void

    • Switch between orthographic and perspective camera.

      Parameters

      • ortho_flag: boolean

        true for orthographic camera, else perspective camera.

      Returns void

    • Recalculate camera_distance from a new bounding radius. Uses the same factor as the constructor so that zoom 1.0 frames the scene.

      Parameters

      • distance: number

        The new bounding radius (bb_radius).

      Returns void

    • Update the near/far clipping planes for both cameras.

      Parameters

      • distance: number

        The new bounding radius to base the clipping planes on.

      Returns void

    • Update current camera's projection matrix.

      Returns void