Skip to content
thothbot edited this page Oct 22, 2012 · 15 revisions

Controls

Controls are used to handle user events, such as mouse move, keyboards events, and make needed operation with a controlled object.

Description

All controls are inherited from the abstract Controls class, which has the following constructor:

    public Controls(Object3D object, Widget widget);

Where:

  • object - Object3D which will be controlled, for example Cameras objects.
  • widget - Widget where control commands are listened. Basically here should be Canvas3d widget.

All controls has the common initialization. The following controls on an example of control from a first person:

class MyScene extends AnimatedScene 
{
    FirstPersonControls controls;
    
    @Override
    protected void onStart()
    {
        this.controls = new FirstPersonControls( camera, getCanvas() );
    }

    @Override
    protected void onUpdate(double duration)
    {
        this.controls.update();
    }
}

Detailed topics

Control from a first person

Fly controls

Trackball Controls

There are implemented the following:

  • Disabled context menu for the widget.
  • Object rotation: [left mouse button] or [A] + mouse drag
  • Object zooming: [center mouse button] or [S] + mouse drag
  • Object moving or pan: [right mouse button] or [D] + mouse drag

Methods:

  • setEnabled()

    Disables/enables the controlls. By default it is true.

  • setRotate(), setZoom(), setPan()

    Enables/Disables rotation, zoom, pan respectively. By default they are true.

  • setRotateSpeed(), setZoomSpeed(), setPanSpeed()

    Sets the rotation, zoom, pan speed respectively.

  • setKeyRotate() , setKeyZoom(), setKeyPan

    Sets keys to handle keyboard events. By default they are A, S, D .

  • setStaticMoving()

    Enables/disables static moving. By default it is true. If it is false then enabled dynamic moving and can be configured setDynamicDampingFactor().

  • setMinDistance(), setMaxDistance()

    Sets min and max distances to the object. By default 0 and Inf.

Clone this wiki locally