-
Notifications
You must be signed in to change notification settings - Fork 27
Controls
Controls are used to handle user events, such as mouse move, keyboards events, and make needed operation with a controlled object.
All controls are inherited from the abstract Controls class, which has the following constructor:
public Controls(Object3D object, Widget widget);Where:
- object -
Object3Dwhich 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();
}
}There are implemented the following:
- Disabled context menu for the
widget. - Mouse:
- Mouse move - rotate the
object. - Mouse down - translate the
objectforward. - Mouse up - translate the
objectbackward.
- Mouse move - rotate the
- Keyboard:
- [W or up] - translate the
objectforward. - [S or down] - translate the
objectbackward. - [A or left] - translate the
objectto the left. - [D or right] - translate the
objectto the right. - [R] - translate the
objectup. - [F] - translate the
objectdown. - [Q] - freez the
object
- [W or up] - translate the
Methods:
setMovementSpeed()setLookSpeed()
- Disabled context menu for the
widget. - Mouse:
- Mouse up/down or [up/down] - pitch the
objectup or down. - Mouse left/right or [left/right] - yaw the
objectleft or right.
- Mouse up/down or [up/down] - pitch the
- Keyboard:
- [W] - translate the
objectforward. - [S] - translate the
objectbackward. - [A] - translate the
objectto the left. - [D] - translate the
objectto the right. - [R] - translate the
objectup. - [F] - translate the
objectdown. - [Q] - rotate the
objectleft. - [E] - rotate the
objectright.
- [W] - translate the
Methods:
setMovementSpeed()setRollSpeed()
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(),setKeyPanSets keys to handle keyboard events. By default they are
A,S,D. -
setStaticMoving()Enables/disables static moving. By default it is
true. If it isfalsethen enabled dynamic moving and can be configuredsetDynamicDampingFactor(). -
setMinDistance(),setMaxDistance()Sets min and max distances to the object. By default
0andInf.