| Package | alternativa.engine3d.controllers |
| Class | public class WalkController |
| Inheritance | WalkController ObjectController |
The are two control modes: walk mode with gravity imitation and fly mode in which gravity isn't taken into account. If collision detection is disabled, then the gravity also ignored in walk mode. In this case the controlled object gets an ability to move along vertical axis.
For objects that are not of class Camera3D the "forward" direction mathes the direction of local Y axis, the "up" direction matches the direction of Z axis. For objects of class Camera3D the "forwrad" direction matches the direction of local Z axis and the "up" direction is opposite to the direction of local Y axis.
Regardless, whether collision detection is enabled or not, coordinates are calculated for an ellipsoid, which parameters are set via collider property. The controlled object's coordinates are calculated depending on the ellipsoid's center position and the object's position on the vertical axis of the ellipsoid, determined by objectZPosition parameter.
The ACTION_UP command in walk mode with non-zero gravity makes a jump, in other cases it starts upward movement.
| Property | Defined by | ||
|---|---|---|---|
![]() | accelerated : Boolean The accelerated speed mode flag.
| ObjectController | |
| airControlCoefficient : Number Coefficient of efficiency of the movement controls in walk mode while in the air.
| WalkController | ||
![]() | checkCollisions : Boolean Enabling and disabling collision detection mode.
| ObjectController | |
![]() | collider : EllipsoidCollider
EllipsoidCollider object.
| ObjectController | |
![]() | coords : Point3D
Coordinates of the controller.
| ObjectController | |
| currentSpeed : Number [read-only] The current speed.
| WalkController | ||
| enabled : Boolean [write-only]
| WalkController | ||
| flyMode : Boolean Enabling and disabling fly mode.
| WalkController | ||
| gravity : Number = 0 Acceleration of gravity.
| WalkController | ||
| groundMesh : Mesh
[read-only] If the gravity isn't zero, this property references the object, on which the ellipsoid stands.
| WalkController | ||
| jumpSpeed : Number = 0 Vertical speed in the moment of jump.
| WalkController | ||
![]() | keyboardEnabled : Boolean Enabling and disabling processing of keyboard events.
| ObjectController | |
| maxGroundAngle : Number Maximum angle of surface inclination in radians, by which jumps are still possible and the object remains motionless without controller's influence.
| WalkController | ||
| maxPitch : Number maximum pitch angle in radians
| WalkController | ||
| minPitch : Number minimum pitch angle in radians
| WalkController | ||
![]() | mouseEnabled : Boolean Enabling and disabling processing of mouse events.
| ObjectController | |
![]() | mouseSensitivity : Number Mouse sensitivity — multiplication coefficient of
mouseSensitivityX and mouseSensitivityY. | ObjectController | |
![]() | mouseSensitivityX : Number Horizontal mouse sensitivity.
| ObjectController | |
![]() | mouseSensitivityY : Number Vertical mouse sensitivity.
| ObjectController | |
![]() | object : Object3D
Controlled object.
| ObjectController | |
| objectZPosition : Number Position of the controlled object on Z axis of the ellipsoid.
| WalkController | ||
| onGround : Boolean [read-only] In the walk mode this property shows if the ellipsoid is on a ground.
| WalkController | ||
![]() | onStartMoving : Function Function defined as
function():void, which is called when the controlled object starts to move. | ObjectController | |
![]() | onStopMoving : Function Function defined as
function():void, which is called when the controlled object stops moving. | ObjectController | |
![]() | pitchSpeed : Number Pitch angular speed (radians per second).
| ObjectController | |
![]() | speed : Number Speed of the controlled object in units per second.
| ObjectController | |
![]() | speedMultiplier : Number Speed multiplier on acceleration.
| ObjectController | |
| speedThreshold : Number = 1 Speed measurement threshold.
| WalkController | ||
![]() | yawSpeed : Number Yaw angular speed (radians per second).
| ObjectController | |
| Method | Defined by | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
WalkController(eventSourceObject:DisplayObject, object:Object3D = null)
Creates a new instance of controller.
| WalkController | ||||||||||||||||||||||||||||
![]() |
accelerate(value:Boolean):void
Activation of accelerated speed mode.
| ObjectController | |||||||||||||||||||||||||||
![]() |
bindKey(keyCode:uint, action:String):void
The method binds a key to an action.
| ObjectController | |||||||||||||||||||||||||||
|
Aiming object to the point.
| WalkController | ||||||||||||||||||||||||||||
![]() |
moveBack(value:Boolean):void
Activation of back movement.
| ObjectController | |||||||||||||||||||||||||||
![]() |
moveDown(value:Boolean):void
Activation of down movement.
| ObjectController | |||||||||||||||||||||||||||
![]() |
moveForward(value:Boolean):void
Activation of forward movement.
| ObjectController | |||||||||||||||||||||||||||
![]() |
moveLeft(value:Boolean):void
Activation of left movement.
| ObjectController | |||||||||||||||||||||||||||
![]() |
moveRight(value:Boolean):void
Activation of right movement.
| ObjectController | |||||||||||||||||||||||||||
|
moveUp(value:Boolean):void
Activation of up movement.
| WalkController | ||||||||||||||||||||||||||||
![]() |
pitchDown(value:Boolean):void
Activation of pitching down.
| ObjectController | |||||||||||||||||||||||||||
![]() |
pitchUp(value:Boolean):void
Activation of pitching up.
| ObjectController | |||||||||||||||||||||||||||
![]() |
processInput():void
The method processes all control influences.
| ObjectController | |||||||||||||||||||||||||||
![]() |
readCoords(point:Point3D):void
The method stores controller's coordinates in the given variable.
| ObjectController | |||||||||||||||||||||||||||
|
setDefaultBindings():void
The method clears all keys' bindings and sets the default bindings:
| WalkController | ||||||||||||||||||||||||||||
![]() |
setMouseLook(value:Boolean):void
The method enables and disables mouse look mode.
| ObjectController | |||||||||||||||||||||||||||
![]() |
unbindAll():void
Clear all key bindings.
| ObjectController | |||||||||||||||||||||||||||
![]() |
unbindKey(keyCode:uint):void
Clear key binding.
| ObjectController | |||||||||||||||||||||||||||
![]() |
yawLeft(value:Boolean):void
Activation of yawing left.
| ObjectController | |||||||||||||||||||||||||||
![]() |
yawRight(value:Boolean):void
Activation of yawing right.
| ObjectController | |||||||||||||||||||||||||||
| Method | Defined by | ||
|---|---|---|---|
|
applyDisplacement(frameTime:Number, displacement:Point3D):void
The method applies specified displacement vector to ellipsoid considering collision detection if needed.
| WalkController | ||
![]() |
clearCommandFlags():void
The method resets active commands' flags.
| ObjectController | |
|
getDisplacement(frameTime:Number, displacement:Point3D):void
The method calculates potential displacement of the ellipsoid, taking into account control mode, movement commands and gravity.
| WalkController | ||
![]() |
registerKeyboardListeners():void
The method registers necessary keyboard listeners.
| ObjectController | |
![]() |
registerMouseListeners():void
The method registers necessary mouse listeners.
| ObjectController | |
|
rotateObject(frameTime:Number):void
The method rotates the controlled object.
| WalkController | ||
|
setObjectCoords():void
The method sets the controlled object's coordinates depending on value of
objectZPosition property. | WalkController | ||
|
startMouseLook():void
The method performs necessary actions when mouse is enabled.
| WalkController | ||
![]() |
stopMouseLook():void
The method performs the necessary actions when mouse look mode is deactivated.
| ObjectController | |
![]() |
unregisterKeyboardListeners():void
The method removes keyboard listeners when keyboard is deactivated.
| ObjectController | |
![]() |
unregisterMouseListeners():void
The method removes mouse listeners when mouse is deactivated.
| ObjectController | |
| airControlCoefficient | property |
airControlCoefficient:Number [read-write]Coefficient of efficiency of the movement controls in walk mode while in the air. Zero means the controls are completely disabled, 1 means that the controls are so efficient as if the object would be on a ground.
The default value is 1.
public function get airControlCoefficient():Number
public function set airControlCoefficient(value:Number):void
| currentSpeed | property |
currentSpeed:Number [read-only]The current speed.
Implementation public function get currentSpeed():Number
| enabled | property |
enabled:Boolean [write-only]Implementation
public function set enabled(value:Boolean):void
| flyMode | property |
flyMode:Boolean [read-write]Enabling and disabling fly mode.
The default value is false.
public function get flyMode():Boolean
public function set flyMode(value:Boolean):void
| gravity | property |
public var gravity:Number = 0Acceleration of gravity. Positive value means the gravity force is directed opposite to the global Z axis.
| groundMesh | property |
groundMesh:Mesh [read-only]If the gravity isn't zero, this property references the object, on which the ellipsoid stands. If this property is null, then the ellipsod is in the air.
public function get groundMesh():Mesh
| jumpSpeed | property |
public var jumpSpeed:Number = 0Vertical speed in the moment of jump.
| maxGroundAngle | property |
maxGroundAngle:Number [read-write]Maximum angle of surface inclination in radians, by which jumps are still possible and the object remains motionless without controller's influence. If the inclination angle is greater than given maximum, the onGround property will be set to false.
public function get maxGroundAngle():Number
public function set maxGroundAngle(value:Number):void
See also
| maxPitch | property |
public var maxPitch:Numbermaximum pitch angle in radians
The default value is Math.PI / 2.
See also
| minPitch | property |
public var minPitch:Numberminimum pitch angle in radians
The default value is -Math.PI / 2.
See also
| objectZPosition | property |
objectZPosition:Number [read-write]Position of the controlled object on Z axis of the ellipsoid. Value of zero means that the object is at the lowest point of the ellipsoid, 1 means that the object is at the highest point of the ellipsoid.
Implementation public function get objectZPosition():Number
public function set objectZPosition(value:Number):void
| onGround | property |
onGround:Boolean [read-only]In the walk mode this property shows if the ellipsoid is on a ground. The ellipsoid is on a ground when angle of inclination of the surface beneath the ellipsoid is less than value of the maxGroundAngle property.
public function get onGround():Boolean
See also
| speedThreshold | property |
public var speedThreshold:Number = 1Speed measurement threshold. In fly mode or in walk mode when the ellipsoid is on the ground, velocity is set to zero if it's magnitude doesn't exceed given threshold.
| WalkController | () | constructor |
public function WalkController(eventSourceObject:DisplayObject, object:Object3D = null)Creates a new instance of controller.
ParameterseventSourceObject:DisplayObject — Mouse and keyboard events' source. |
|
object:Object3D (default = null) — controlled object |
ArgumentError — throws if eventsSourceObject is null |
| applyDisplacement | () | method |
protected override function applyDisplacement(frameTime:Number, displacement:Point3D):voidThe method applies specified displacement vector to ellipsoid considering collision detection if needed.
ParametersframeTime:Number — frame length given in seconds |
|
displacement:Point3D — the ellipsoid's displacement vector |
| getDisplacement | () | method |
protected override function getDisplacement(frameTime:Number, displacement:Point3D):voidThe method calculates potential displacement of the ellipsoid, taking into account control mode, movement commands and gravity.
ParametersframeTime:Number — frame length given in seconds |
|
displacement:Point3D — calculated displacement is stored in this parameter |
| lookAt | () | method |
public function lookAt(point:Point3D):voidAiming 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.
Parameterspoint:Point3D — coordinates of the target point |
| moveUp | () | method |
public override function moveUp(value:Boolean):voidActivation of up movement.
Parametersvalue:Boolean — true to start movement, false to stop movement |
| rotateObject | () | method |
protected override function rotateObject(frameTime:Number):voidThe method rotates the controlled object. Pitch angle is restricted to interval [-90, 90] in degrees.
ParametersframeTime:Number — frame length given in seconds |
See also
| setDefaultBindings | () | method |
public override function setDefaultBindings():voidThe method clears all keys' bindings and sets the default bindings:
| Клавиша | Действие |
|---|---|
| W | ACTION_FORWARD |
| S | ACTION_BACK |
| A | ACTION_LEFT |
| D | ACTION_RIGHT |
| SPACE | ACTION_UP |
| Z | ACTION_DOWN |
| SHIFT | ACTION_ACCELERATE |
| UP | ACTION_PITCH_UP |
| DOWN | ACTION_PITCH_DOWN |
| LEFT | ACTION_YAW_LEFT |
| RIGHT | ACTION_YAW_RIGHT |
| M | ACTION_MOUSE_LOOK |
| setObjectCoords | () | method |
protected override function setObjectCoords():voidThe method sets the controlled object's coordinates depending on value of objectZPosition property.
See also
| startMouseLook | () | method |
protected override function startMouseLook():voidThe method performs necessary actions when mouse is enabled.