Packagealternativa.engine3d.controllers
Classpublic class FlyController
InheritanceFlyController Inheritance ObjectController

Class provides aircraft-like control of an object in the scene's root object's coordinate system. Rotation of the controlled object is performed around its local axes.

Local axes settings for objects that are not Camera3D:

AxisDirectionRotation
XRightPitch
YForwardRoll
ZUpYaw

Local axes settings for objects that are Camera3D:

AxisDirectionRotation
XRightPitch
YDownYaw
ZForwardRoll
Rotation with the mouse works the next way: when mouse look mode is activated, current mouse position becomes a point from which further cursor's displacements are measured. These displacements, multiplied on corresponding mouse's sensitivity coefficients, determine angular velocity along pitch and roll axis of the controlled object.



Public Properties
 PropertyDefined by
 Inheritedaccelerated : Boolean
The accelerated speed mode flag.
ObjectController
  acceleration : Number = 1000
Acceleration magnitude.
FlyController
 InheritedcheckCollisions : Boolean
Enabling and disabling collision detection mode.
ObjectController
 Inheritedcollider : EllipsoidCollider
EllipsoidCollider object.
ObjectController
 Inheritedcoords : Point3D
Coordinates of the controller.
ObjectController
  currentSpeed : Number
[read-only] Current speed.
FlyController
  deceleration : Number = 50
Deceleration magnitude.
FlyController
  enabled : Boolean
[write-only]
FlyController
  inertialMode : Boolean
Inertial mode toggle.
FlyController
 InheritedkeyboardEnabled : Boolean
Enabling and disabling processing of keyboard events.
ObjectController
 InheritedmouseEnabled : Boolean
Enabling and disabling processing of mouse events.
ObjectController
 InheritedmouseSensitivity : Number
Mouse sensitivity — multiplication coefficient of mouseSensitivityX and mouseSensitivityY.
ObjectController
 InheritedmouseSensitivityX : Number
Horizontal mouse sensitivity.
ObjectController
 InheritedmouseSensitivityY : Number
Vertical mouse sensitivity.
ObjectController
 Inheritedobject : Object3D
Controlled object.
ObjectController
 InheritedonStartMoving : Function
Function defined as function():void, which is called when the controlled object starts to move.
ObjectController
 InheritedonStopMoving : Function
Function defined as function():void, which is called when the controlled object stops moving.
ObjectController
 InheritedpitchSpeed : Number
Pitch angular speed (radians per second).
ObjectController
 Inheritedspeed : Number
Speed of the controlled object in units per second.
ObjectController
 InheritedspeedMultiplier : Number
Speed multiplier on acceleration.
ObjectController
  speedThreshold : Number = 1
If speed is below given threshold, it is set to zero.
FlyController
 InheritedyawSpeed : Number
Yaw angular speed (radians per second).
ObjectController
Protected Properties
 PropertyDefined by
 Inherited_accelerate : Boolean
Accelerated mode flag.
ObjectController
 InheritedactionBindings : Map
Map which binds actions' names and actions' handlers.
ObjectController
 Inherited_back : Boolean
Back movement flag.
ObjectController
 Inherited_collider : EllipsoidCollider
EllipsoidCollider for collision detection.
ObjectController
 Inherited_coords : Point3D
Controller's current coordinates.
ObjectController
 Inherited_down : Boolean
Down movement flag.
ObjectController
 Inherited_enabled : Boolean = true
Controller's activity flag.
ObjectController
 Inherited_eventsSource : DisplayObject
Keyboard and mouse events' source.
ObjectController
 Inherited_forward : Boolean
Forward movement flag.
ObjectController
 Inherited_isMoving : Boolean
The flag shows if the controlled object moved in the current frame.
ObjectController
 InheritedkeyBindings : Map
Map which binds key codes with actions' names.
ObjectController
 Inherited_keyboardEnabled : Boolean
The flag shows if keyboard is enabled.
ObjectController
 InheritedlastFrameTime : uint
The time that passed since the last call of the processInput() method.
ObjectController
 Inherited_left : Boolean
Left movement flag.
ObjectController
 Inherited_mouseCoefficientX : Number
Resulting horizontal mouse sensitivity.
ObjectController
 Inherited_mouseCoefficientY : Number
Resulting vertical mouse sensitivity.
ObjectController
 Inherited_mouseEnabled : Boolean
Mouse activity flag.
ObjectController
 Inherited_mouseLookActive : Boolean
Mouse look mode activity flag.
ObjectController
 Inherited_mouseSensitivity : Number = 1
Mouse sensitivity — multiplication coefficient for horizontal and vertical sensitivities.
ObjectController
 Inherited_mouseSensitivityX : Number
Horizontal mouse sensitivity.
ObjectController
 Inherited_mouseSensitivityY : Number
Vertical mouse sensitivity.
ObjectController
 Inherited_object : Object3D
Controlled object.
ObjectController
 Inherited_pitchDown : Boolean
pitch down flag
ObjectController
 Inherited_pitchSpeed : Number = 1
Angular speed of revolution around pitch axis.
ObjectController
 Inherited_pitchUp : Boolean
Pitch up flag.
ObjectController
 Inherited_right : Boolean
Right movement flag.
ObjectController
 Inherited_speed : Number = 100
Speed of controller.
ObjectController
 Inherited_speedMultiplier : Number = 2
Speed multiplication coefficient in accelerated mode.
ObjectController
 InheritedstartMouseCoords : Point3D
Starting coordinates of the mouse cursor in mouse look mode.
ObjectController
 Inherited_up : Boolean
Up movement flag.
ObjectController
 Inherited_yawLeft : Boolean
Yaw left flag.
ObjectController
 Inherited_yawRight : Boolean
Yaw right flag.
ObjectController
 Inherited_yawSpeed : Number = 1
Angular speed of revolution around yaw axis.
ObjectController
Public Methods
 MethodDefined by
  
FlyController(eventsSourceObject:DisplayObject)
Creates a new instance of controller.
FlyController
 Inherited
accelerate(value:Boolean):void
Activation of accelerated speed mode.
ObjectController
 Inherited
bindKey(keyCode:uint, action:String):void
The method binds a key to an action.
ObjectController
  
lookAt(point:Point3D):void
Aiming object to the point.
FlyController
 Inherited
moveBack(value:Boolean):void
Activation of back movement.
ObjectController
 Inherited
moveDown(value:Boolean):void
Activation of down movement.
ObjectController
 Inherited
moveForward(value:Boolean):void
Activation of forward movement.
ObjectController
 Inherited
moveLeft(value:Boolean):void
Activation of left movement.
ObjectController
 Inherited
moveRight(value:Boolean):void
Activation of right movement.
ObjectController
 Inherited
moveUp(value:Boolean):void
Activation of up movement.
ObjectController
 Inherited
pitchDown(value:Boolean):void
Activation of pitching down.
ObjectController
 Inherited
pitchUp(value:Boolean):void
Activation of pitching up.
ObjectController
 Inherited
processInput():void
The method processes all control influences.
ObjectController
 Inherited
readCoords(point:Point3D):void
The method stores controller's coordinates in the given variable.
ObjectController
  
rollLeft(value:Boolean):void
activating roll left
FlyController
  
rollRight(value:Boolean):void
activating roll right
FlyController
  
The method clears all previous keys' bindings and sets the default bindings:
KeyAction
WACTION_FORWARD
SACTION_BACK
AACTION_LEFT
DACTION_RIGHT
SPACEACTION_UP
ZACTION_DOWN
UPACTION_PITCH_UP
DOWNACTION_PITCH_DOWN
LEFTACTION_ROLL_LEFT
RIGHTACTION_ROLL_RIGHT
QACTION_YAW_LEFT
EACTION_YAW_RIGHT
MACTION_MOUSE_LOOK
FlyController
 Inherited
setMouseLook(value:Boolean):void
The method enables and disables mouse look mode.
ObjectController
 Inherited
unbindAll():void
Clear all key bindings.
ObjectController
 Inherited
unbindKey(keyCode:uint):void
Clear key binding.
ObjectController
 Inherited
yawLeft(value:Boolean):void
Activation of yawing left.
ObjectController
 Inherited
yawRight(value:Boolean):void
Activation of yawing right.
ObjectController
Protected Methods
 MethodDefined by
  
applyDisplacement(frameTime:Number, displacement:Point3D):void
The method applies specified displacement vector to ellipsoid considering collision detection if needed.
FlyController
  
The method resets active commands' flags.
FlyController
  
getDisplacement(frameTime:Number, displacement:Point3D):void
The method calculates displacement vector of ellipsoid
FlyController
 Inherited
The method registers necessary keyboard listeners.
ObjectController
 Inherited
The method registers necessary mouse listeners.
ObjectController
  
rotateObject(frameTime:Number):void
The method rotates controlled object around it's local axes.
FlyController
 Inherited
The method sets coordinates of the controlled object depending on the controller's coordinates.
ObjectController
 Inherited
The method performs the necessary actions when mouse look mode is activated.
ObjectController
 Inherited
The method performs the necessary actions when mouse look mode is deactivated.
ObjectController
 Inherited
The method removes keyboard listeners when keyboard is deactivated.
ObjectController
 Inherited
The method removes mouse listeners when mouse is deactivated.
ObjectController
Public Constants
 ConstantDefined by
 InheritedACTION_ACCELERATE : String = "ACTION_ACCELERATE"
[static] Action name for binding ACCELERATE button.
ObjectController
 InheritedACTION_BACK : String = "ACTION_BACK"
[static] Action name for binding BACK movement button.
ObjectController
 InheritedACTION_DOWN : String = "ACTION_DOWN"
[static] Action name for binding DOWN movement button.
ObjectController
 InheritedACTION_FORWARD : String = "ACTION_FORWARD"
[static] Action name for binding FORWARD movement button.
ObjectController
 InheritedACTION_LEFT : String = "ACTION_LEFT"
[static] Action name for binding LEFT movement button.
ObjectController
 InheritedACTION_MOUSE_LOOK : String = "ACTION_MOUSE_LOOK"
[static] Action name for binding MOUSE_LOOK button.
ObjectController
 InheritedACTION_PITCH_DOWN : String = "ACTION_PITCH_DOWN"
[static] Action name for binding PITCH_DOWN button.
ObjectController
 InheritedACTION_PITCH_UP : String = "ACTION_PITCH_UP"
[static] Action name for binding PITCH_UP button.
ObjectController
 InheritedACTION_RIGHT : String = "ACTION_RIGHT"
[static] Action name for binding RIGHT movement button.
ObjectController
  ACTION_ROLL_LEFT : String = "ACTION_ROLL_LEFT"
[static] Action name for binding ROLL_LEFT button.
FlyController
  ACTION_ROLL_RIGHT : String = "ACTION_ROLL_RIGHT"
[static] Action name for binding ROLL_RIGHT button.
FlyController
 InheritedACTION_UP : String = "ACTION_UP"
[static] Action name for binding UP movement button.
ObjectController
 InheritedACTION_YAW_LEFT : String = "ACTION_YAW_LEFT"
[static] Action name for binding YAW_LEFT button.
ObjectController
 InheritedACTION_YAW_RIGHT : String = "ACTION_YAW_RIGHT"
[static] Action name for binding YAW_RIGHT button.
ObjectController
Property detail
accelerationproperty
public var acceleration:Number = 1000

Acceleration magnitude.

currentSpeedproperty 
currentSpeed:Number  [read-only]

Current speed.

Implementation
    public function get currentSpeed():Number
decelerationproperty 
public var deceleration:Number = 50

Deceleration magnitude.

enabledproperty 
enabled:Boolean  [write-only]

Implementation
    public function set enabled(value:Boolean):void
inertialModeproperty 
public var inertialMode:Boolean

Inertial mode toggle. In inertial mode deceleration doesn't exist, therefore object's velocity vector remains unchanged without control influences. When inertial mode is turned off, a deceleration is applied to the controlled object.

speedThresholdproperty 
public var speedThreshold:Number = 1

If speed is below given threshold, it is set to zero.

Constructor detail
FlyController()constructor
public function FlyController(eventsSourceObject:DisplayObject)

Creates a new instance of controller.

Parameters
eventsSourceObject:DisplayObjectMouse and keyboard events' source.

Throws
ArgumentError — throws if eventsSourceObject is null
Method detail
applyDisplacement()method
protected override function applyDisplacement(frameTime:Number, displacement:Point3D):void

The method applies specified displacement vector to ellipsoid considering collision detection if needed.

Parameters
frameTime:Numberframe length given in seconds
 
displacement:Point3Dthe ellipsoid's displacement vector
clearCommandFlags()method 
protected override function clearCommandFlags():void

The method resets active commands' flags.

getDisplacement()method 
protected override function getDisplacement(frameTime:Number, displacement:Point3D):void

The method calculates displacement vector of ellipsoid

Parameters
frameTime:Numberframe length given in seconds
 
displacement:Point3Dcalculated displacement is stored in this parameter
lookAt()method 
public function lookAt(point:Point3D):void

Aiming object to the point. The "forward" axis of the object becomes directed to the specified point. Angle of rotation around "forward" axis is set to zero.

Parameters
point:Point3Dcoordinates of the target point
rollLeft()method 
public function rollLeft(value:Boolean):void

activating roll left

Parameters
value:Boolean
rollRight()method 
public function rollRight(value:Boolean):void

activating roll right

Parameters
value:Boolean
rotateObject()method 
protected override function rotateObject(frameTime:Number):void

The method rotates controlled object around it's local axes.

Parameters
frameTime:Numberframe length given in seconds
setDefaultBindings()method 
public override function setDefaultBindings():void

The method clears all previous keys' bindings and sets the default bindings:

KeyAction
WACTION_FORWARD
SACTION_BACK
AACTION_LEFT
DACTION_RIGHT
SPACEACTION_UP
ZACTION_DOWN
UPACTION_PITCH_UP
DOWNACTION_PITCH_DOWN
LEFTACTION_ROLL_LEFT
RIGHTACTION_ROLL_RIGHT
QACTION_YAW_LEFT
EACTION_YAW_RIGHT
MACTION_MOUSE_LOOK

Constant detail
ACTION_ROLL_LEFTconstant
public static const ACTION_ROLL_LEFT:String = "ACTION_ROLL_LEFT"

Action name for binding ROLL_LEFT button.

ACTION_ROLL_RIGHTconstant 
public static const ACTION_ROLL_RIGHT:String = "ACTION_ROLL_RIGHT"

Action name for binding ROLL_RIGHT button.