Class TrackballControls

Allows a camera to be manipulated using mouse controls.

// The trackball controls a view implementation such as a camera.
const camera = new EIGHT.PerspectiveCamera()

// Create TrackballControls anytime.
const controls = new EIGHT.TrackballControls(camera)

// Subscribe to mouse events, usually in the window.onload function.
controls.subscribe(canvas)

// Update the camera position, usually in the animate function.
controls.update()

// Stop listening to mouse events.
controls.unsubscribe()

// Inform the controls they are no longer needed, usually in the window.onunload function.
controls.release()

You may decide to update directional lighting to synchronize with the camera.

Hierarchy

  • ViewControls
    • TrackballControls

Constructors

Properties

enabled: boolean = true
true
eyeMinusLook: Vector3 = ...
look: Vector3 = ...
maxDistance: number = Infinity
Infinity
minDistance: number = 0
0
moveCurr: Vector2 = ...
movePrev: Vector2 = ...
noPan: boolean = false
false
noRotate: boolean = false
false
noZoom: boolean = false
false
panEnd: Vector2 = ...
panSpeed: number = 1
1
panStart: Vector2 = ...
rotateSpeed: number = 1
1
up: Vector3 = ...
zoomEnd: Vector2 = ...
zoomSpeed: number = 1
1
zoomStart: Vector2 = ...

Methods

  • Notifies this instance that something is referencing it.

    Returns number

    The new value of the reference count.

  • Returns the name that was assigned by the call to the setLoggingName method.

    Returns string

  • An object is a zombie if it has been released by all who have held references. In some cases it may be possible to recycle a zombie.

    Returns boolean

  • Simulates a movement of the mouse in coordinates -1 to +1 in both directions.

    Parameters

    • x: number
    • y: number

    Returns void

  • Notifies this instance that something is dereferencing it.

    Returns number

    The new value of the reference count.

  • This method is for use within constructors.

    Immediately after a call to the super class constructor, make a call to setLoggingName. This will have the effect of refining the name used for reporting reference counts.

    This method has the secondary purpose of enabling a tally of the number of classes in the constructor chain. This enables the runtime architecture to verify that destructor chains are consistent with constructor chains, which is a good practice for cleaning up resources.

    Notice that this method is intentionally protected to discourage it from being called outside of the constructor.

    Parameters

    • name: string

      This will usually be set to the name of the class.

    Returns void

  • This should be called inside the animation frame to update the camera location. Notice that the movement of the mouse controls is decoupled from the effect. We also want to avoid temporary object creation in this and called methods by recycling variables.

    Returns void