three-cad-viewer
    Preparing search index...

    Class ControlsInternal

    Unified camera controls supporting both orbit and trackball modes.

    Controls wraps CADOrbitControls and CADTrackballControls, providing:

    • Consistent API regardless of control type
    • Normalized speed settings (1.0 = default experience)
    • State saving/restoring for reset functionality
    • Camera switching support
    • "orbit": OrbitControls - familiar Google Maps style rotation
    • "trackball": TrackballControls - unrestricted rotation with optional Holroyd mode

    When enabled for trackball controls, prevents tumbling by keeping the up vector stable. This provides a more intuitive CAD experience.

    • This is an internal class used by Viewer
    Index

    Constructors

    • Create Camera Controls.

      Parameters

      • type: ControlType

        Type of controls: "orbit", "trackball".

      • camera: Camera

        The camera object.

      • target: Vector3

        The lookAt target for the camera.

      • domElement: HTMLElement

        The dom element of the rendering canvas.

      • rotateSpeed: number = 1.0

        Speed for rotating.

      • zoomSpeed: number = 1.0

        Speed for zooming.

      • panSpeed: number = 1.0

        Speed for panning.

      • holroyd: boolean = true

        Enable holroyd (non-tumbling) mode for trackball.

      Returns Controls

    Properties

    camera: Camera
    controls: ControlsInstance
    currentUpdateCallback: (() => void) | null
    domElement: HTMLElement
    holroyd: boolean
    panSpeed: number
    rotateSpeed: number
    target: Vector3
    target0: Vector3
    zoomSpeed: number

    Methods

    • Add an event listener callback for the "change" event.

      Parameters

      • callback: () => void

        the callback function.

      Returns void

    • Get reset location value.

      Returns { position0: Vector3; quaternion0: Quaternion; target0: Vector3; zoom0: number }

      target, position, quaternion, zoom as object.

    • Update screen dimensions after canvas resize. Only applies to TrackballControls which caches screen dimensions.

      Returns void

    • Initialize Trackball Controls.

      Parameters

      • holroyd: boolean = true

        enable holroyd (non tumbling) mode.

      Returns void

    • Check if the user is currently interacting with the controls (rotating, panning, zooming).

      Returns boolean

      true if user is dragging/interacting, false otherwise.

    • Remove the event listener callback for the "change" event.

      Returns void

    • Reset camera to initial (automatically saved) state of position, up, quaternion and zoom.

      Returns void

    • Rotate camera left (OrbitControls only)

      Parameters

      • angle: number

        the angle to rotate.

      Returns void

    • Rotate camera up (OrbitControls only)

      Parameters

      • angle: number

        the angle to rotate.

      Returns void

    • Rotate camera around x-axis (TrackballControls only)

      Parameters

      • angle: number

        the angle to rotate.

      Returns void

    • Rotate camera around y-axis (TrackballControls only)

      Parameters

      • angle: number

        the angle to rotate.

      Returns void

    • Rotate camera around z-axis (TrackballControls only)

      Parameters

      • angle: number

        the angle to rotate.

      Returns void

    • Set the camera to be controlled.

      Parameters

      • camera: Camera

        a threejs Camera object.

      Returns void

    • Change the trackball holroyd (non tumbling) flag.

      Parameters

      • flag: boolean

        holroyd mode enabled.

      Returns void

    • Set the pan speed.

      Parameters

      • val: number

        the speed value (1.0 = default).

      Returns void

    • Set reset location value.

      Parameters

      • target: Vector3

        camera target as THREE.Vector3.

      • position: Vector3

        camera position as THREE.Vector3.

      • quaternion: Quaternion

        camera rotation as THREE.Quaternion.

      • zoom: number

        camera zoom value.

      Returns void

    • Set the rotate speed.

      Parameters

      • val: number

        the speed value (1.0 = default).

      Returns void

    • Set the lookAt target of the camera.

      Parameters

      • target: Vector3

        camera target as THREE.Vector3.

      Returns void

    • Set the zoom speed.

      Parameters

      • val: number

        the speed value (1.0 = default).

      Returns void

    • Update controls after camera position, zoom or quaternion changes.

      Returns void