-
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 -
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();
}
}
There are implemented the following:
- Disabled context menu for the
widget
. - Mouse:
- Mouse move - rotate the
object
. - Mouse down - translate the
object
forward. - Mouse up - translate the
object
backward.
- Mouse move - rotate the
- Keyboard:
- [W or up] - translate the
object
forward. - [S or down] - translate the
object
backward. - [A or left] - translate the
object
to the left. - [D or right] - translate the
object
to the right. - [R] - translate the
object
up. - [F] - translate the
object
down. - [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
object
up or down. - Mouse left/right or [left/right] - yaw the
object
left or right.
- Mouse up/down or [up/down] - pitch the
- Keyboard:
- [W] - translate the
object
forward. - [S] - translate the
object
backward. - [A] - translate the
object
to the left. - [D] - translate the
object
to the right. - [R] - translate the
object
up. - [F] - translate the
object
down. - [Q] - rotate the
object
left. - [E] - rotate the
object
right.
- [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()
,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 isfalse
then enabled dynamic moving and can be configuredsetDynamicDampingFactor()
. -
setMinDistance()
,setMaxDistance()
Sets min and max distances to the object. By default
0
andInf
.