Mouse and touch controller for a Viewer's Camera.

See @xeokit/sdk/cameracontrol for usage.

Hierarchy (View Summary)

Properties

destroyed: boolean

True once this Component has been destroyed.

Don't use this Component if this is true.

dirty: boolean
id: string

Unique ID of this Component.

view: View
AXIS_VIEW_BACK: number = 13

Positions the Camera to view the back side of the entire extents of the View.

AXIS_VIEW_BOTTOM: number = 17

Positions the Camera to look upward from below at the entire extents of the View.

AXIS_VIEW_FRONT: number = 15

Positions the Camera to view the front side of the entire extents of the View.

AXIS_VIEW_LEFT: number = 14

Positions the Camera to view the left side of the entire extents of the View.

AXIS_VIEW_RIGHT: number = 12

Positions the Camera to view the right side of the entire extents of the View.

AXIS_VIEW_TOP: number = 16

Positions the Camera to look downward at the entire extents of the View.

DOLLY_BACKWARDS: number = 11

Moves the camera backward (dolly out).

DOLLY_FORWARDS: number = 10

Moves the camera forward (dolly in).

PAN_BACKWARDS: number = 5

Represents a backward panning action.

PAN_DOWN: number = 3

Represents a downward panning action.

PAN_FORWARDS: number = 4

Represents a forward panning action.

PAN_LEFT: number = 0

Represents a leftward panning action.

PAN_RIGHT: number = 1

Represents a rightward panning action.

PAN_UP: number = 2

Represents an upward panning action.

ROTATE_X_NEG: number = 7

Rotates the view counterclockwise around the X-axis.

ROTATE_X_POS: number = 6

Rotates the view clockwise around the X-axis.

ROTATE_Y_NEG: number = 9

Rotates the view counterclockwise around the Y-axis.

ROTATE_Y_POS: number = 8

Rotates the view clockwise around the Y-axis.

Accessors

  • get active(): boolean
  • Gets if this CameraControl is active or not.

    When inactive, the CameraControl will not react to input.

    Default is true.

    Returns boolean

    Returns true if this CameraControl is active.

  • set active(value: boolean): void
  • Sets if this CameraControl is active or not.

    When inactive, the CameraControl will not react to input.

    Default is true.

    Parameters

    • value: boolean

    Returns void

  • get dollyInertia(): number
  • Gets the dolly inertia factor.

    Default is 0.

    Returns number

    The current dolly inertia factor.

  • set dollyInertia(dollyInertia: number): void
  • Sets the dolly inertia factor.

    This factor configures how much the viewer!Camera keeps moving after you finish dollying it.

    This factor is a value in range [0..1]. A value of 0.0 causes dollying to immediately stop, 0.5 causes dollying to decay 50% on each animation frame, while 1.0 causes no decay, which allows dollying to continue until further input stops it.

    You might set dollyInertia to zero when you want be able to precisely position or rotate the Camera, without interference from inertia. This also means that xeokit renders less frames while dollying the Camera, which can improve rendering performance.

    Default is 0.

    Parameters

    • dollyInertia: number

      New dolly inertia factor.

    Returns void

  • get dollyProximityThreshold(): number
  • Gets the proximity to the closest object below which dolly speed decreases, and above which dolly speed increases.

    Default is 35.0.

    Returns number

    The current dolly proximity threshold.

  • set dollyProximityThreshold(dollyProximityThreshold: number): void
  • Sets the proximity to the closest object below which dolly speed decreases, and above which dolly speed increases.

    Default is 35.0.

    Parameters

    • dollyProximityThreshold: number

      New dolly proximity threshold.

    Returns void

  • get doubleClickTimeFrame(): number
  • Gets the double click time frame length in milliseconds.

    Default is 250

    Returns number

    Current double click time frame.

  • set doubleClickTimeFrame(value: number): void
  • Sets the double click time frame length in milliseconds.

    If two mouse click events occur within this time frame, it is considered a double click.

    Default is 250

    Parameters

    • value: number

      New double click time frame.

    Returns void

  • get dragRotationRate(): number
  • Gets the current drag rotation rate.

    Default is 360.0.

    Returns number

    The current drag rotation rate.

  • set dragRotationRate(dragRotationRate: number): void
  • Sets the current drag rotation rate.

    This configures how many degrees the viewer!Camera rotates/orbits for a full sweep of the canvas by mouse or touch dragging.

    For example, a value of 360.0 indicates that the Camera rotates/orbits 360.0 degrees horizontally when we sweep the entire width of the canvas.

    CameraControl makes vertical rotation half as sensitive as horizontal rotation, so that we don't tend to flip upside-down. Therefore, a value of 360.0 rotates/orbits the Camera through 180.0 degrees vertically when we sweep the entire height of the canvas.

    Default is 360.0.

    Parameters

    • dragRotationRate: number

      The new drag rotation rate.

    Returns void

  • get followPointer(): boolean
  • Sets whether the viewer!Camera follows the mouse/touch pointer.

    In orbiting mode, the Camera will orbit about the pointer, and will dolly to and from the pointer.

    In fly-to mode, the Camera will dolly to and from the pointer, however the World will always rotate about the Camera position.

    In plan-view mode, the Camera will dolly to and from the pointer, however the Camera will not rotate.

    Default is true.

    See class comments for more info.

    Returns boolean

    Returns true if the Camera follows the pointer.

  • set followPointer(value: boolean): void
  • Sets whether the viewer!Camera follows the mouse/touch pointer.

    In orbiting mode, the Camera will orbit about the pointer, and will dolly to and from the pointer.

    In fly-to mode, the Camera will dolly to and from the pointer, however the World will always rotate about the Camera position.

    In plan-view mode, the Camera will dolly to and from the pointer, however the Camera will not rotate.

    Default is true.

    See class comments for more info.

    Parameters

    • value: boolean

      Set true to enable the Camera to follow the pointer.

    Returns void

  • get keyboardPanRate(): number
  • Gets how much the viewer!Camera pans each second with keyboard input.

    Default is 5.0.

    Returns number

    The current keyboard pan rate.

  • set keyboardPanRate(keyboardPanRate: number): void
  • Sets how much the viewer!Camera pans each second with keyboard input.

    Default is 5.0, to pan the Camera 5.0 World-space units every second that a panning key is depressed. See the CameraControl class documentation for which keys control panning.

    Panning direction is aligned to our Camera's orientation. When we pan horizontally, we pan to our left and right, when we pan vertically, we pan upwards and downwards, and when we pan forwards and backwards, we pan along the direction the Camera is pointing.

    Unlike dollying when followPointer is true, panning does not follow the pointer.

    Parameters

    • keyboardPanRate: number

      The new keyboard pan rate.

    Returns void

  • get keyboardRotationRate(): number
  • Sets how many degrees per second the viewer!Camera rotates/orbits with keyboard input.

    Default is 90.0.

    Returns number

    The current keyboard rotation rate.

  • set keyboardRotationRate(keyboardRotationRate: number): void
  • Sets how many degrees per second the viewer!Camera rotates/orbits with keyboard input.

    Default is 90.0, to rotate/orbit the Camera 90.0 degrees every second that a rotation key is depressed. See the CameraControl class documentation for which keys control rotation/orbit.

    Parameters

    • keyboardRotationRate: number

      The new keyboard rotation rate.

    Returns void

  • get keyMap(): number | { Number: Number }
  • Gets custom mappings of keys to CameraControl actions.

    Returns number | { Number: Number }

  • set keyMap(value: number | { Number: Number }): void
  • Sets custom mappings of keys to CameraControl actions.

    See class docs for usage.

    Parameters

    • value: number | { Number: Number }

      Either a set of new key mappings, or a string to select a keyboard layout, which causes CameraControl to use the default key mappings for that layout.

    Returns void

  • get panInertia(): number
  • Gets the pan inertia factor.

    Default is 0.5.

    Returns number

    The current pan inertia factor.

  • set panInertia(panInertia: number): void
  • Sets the pan inertia factor.

    This factor configures how much the viewer!Camera keeps moving after you finish panning it.

    This factor is a value in range [0..1]. A value of 0.0 causes panning to immediately stop, 0.5 causes panning to decay 50% on each animation frame, while 1.0 causes no decay, which allows panning to continue until further input stops it.

    You might set panInertia to zero when you want be able to precisely position or rotate the Camera, without interference from inertia. This also means that xeokit renders less frames while panning the Camera, wich can improve rendering performance.

    Default is 0.5.

    Parameters

    • panInertia: number

      New pan inertia factor.

    Returns void

  • get pointerEnabled(): boolean
  • Gets whether mouse and touch input is enabled.

    Default is true.

    Disabling mouse and touch input on CameraControl is desirable when we want to temporarily use mouse or touch input to interact with some other 3D control, without interfering with the viewer!Camera.

    Returns boolean

    Returns true if mouse and touch input is enabled.

  • set pointerEnabled(value: boolean): void
  • Sets whether mouse and touch input is enabled.

    Default is true.

    Disabling mouse and touch input on CameraControl is useful when we want to temporarily use mouse or touch input to interact with some other 3D control, without disturbing the viewer!Camera.

    Parameters

    • value: boolean

      Set true to enable mouse and touch input.

    Returns void

  • get rotationInertia(): number
  • Gets the rotation inertia factor.

    Default is 0.0.

    Does not apply when CameraControl#navMode is "planView", which disallows rotation.

    Returns number

    The inertia factor.

  • set rotationInertia(rotationInertia: number): void
  • Sets a factor in range [0..1] indicating how much the viewer!Camera keeps moving after you finish rotating it.

    A value of 0.0 causes it to immediately stop, 0.5 causes its movement to decay 50% on each tick, while 1.0 causes no decay, allowing it continue moving, by the current rate of rotation.

    You may choose an inertia of zero when you want be able to precisely rotate the Camera, without interference from inertia. Zero inertia can also mean that less frames are rendered while you are rotating the Camera.

    Default is 0.0.

    Does not apply when CameraControl#navMode is "planView", which disallows rotation.

    Parameters

    • rotationInertia: number

      New inertial factor.

    Returns void

Methods

  • Protected

    Logs an error for this component to the JavaScript console.

    The console message will have this format: [ERROR] [<component type> =<component id>: <message>

    Parameters

    • message: string

      The error message to log

    Returns void

  • Protected

    Logs a message for this component.

    The message will have this format: [LOG] [<component type> <component id>: <message>

    Parameters

    • message: string

      The message to log

    Returns void

  • Protected

    Logs a warning for this component to the JavaScript console.

    The console message will have this format: [WARN] [<component type> =<component id>: <message>

    Parameters

    • message: string

      The warning message to log

    Returns void

Events

onDestroyed: EventEmitter<Component, null>

Emits an event when the Component has been destroyed.

Event fired when a ViewObject is double-picked.

onDoublePickedNothing: EventEmitter<CameraControl, PickResult>

Event fired when empty space is double-picked.

onDoublePickedSurface: EventEmitter<CameraControl, PickResult>

Event fired when a surface is double-picked.

onHover: EventEmitter<CameraControl, HoverEvent>

Event fired when the pointer moves while over a viewer!ViewObject.

onHoverEnter: EventEmitter<CameraControl, HoverEvent>

Event fired when the pointer moves onto a viewer!ViewObject.

onHoverOff: EventEmitter<CameraControl, HoverEvent>

Event fired when the pointer moves while over empty space.

onHoverOut: EventEmitter<CameraControl, HoverEvent>

Event fired when the pointer moves off a viewer!ViewObject.

onHoverSnapOrSurface: EventEmitter<CameraControl, any>

Event fired when snapping onto a surface, vertex, or edge.

onHoverSnapOrSurfaceOff: EventEmitter<CameraControl, any>

Event fired when snapping off a surface, vertex, or edge.

onHoverSurface: EventEmitter<CameraControl, HoverEvent>

Event fired when the pointer moves while over a viewer!ViewObject.

Event fired when a viewer!ViewObject is picked.

onPickedNothing: EventEmitter<CameraControl, null>

Event fired when empty space is picked.

Event fired when empty space is picked.

onRayMove: EventEmitter<CameraControl, any>

Event fired when ray moves.

onRightClick: EventEmitter<CameraControl, any>

Event fired when we right-click.