Packagealternativa.engine3d.controllers
Classpublic class SimpleObjectController
InheritanceSimpleObjectController Inheritance Object

Controller for Object3D. Allow to handle the object with a keyboard and mouse.

See also

alternativa.engine3d.core.Object3D


Public Properties
 PropertyDefined By
  maxPitch : Number = 1e+22
The maximal slope in the vertical plane in radians.
SimpleObjectController
  minPitch : Number = -1e+22
The minimal slope in the vertical plane in radians.
SimpleObjectController
  mouseSensitivity : Number
Mouse sensitivity.
SimpleObjectController
  object : Object3D
Target of handling.
SimpleObjectController
  speed : Number
Speed.
SimpleObjectController
  speedMultiplier : Number
Speed multiplier for acceleration mode.
SimpleObjectController
Protected Properties
 PropertyDefined By
  keyBindings : Object
The hash for binding key codes and action names.
SimpleObjectController
Public Methods
 MethodDefined By
  
SimpleObjectController(eventSource:InteractiveObject, object:Object3D, speed:Number, speedMultiplier:Number = 3, mouseSensitivity:Number = 1)
Creates a SimpleObjectController object.
SimpleObjectController
  
accelerate(value:Boolean):void
Switches acceleration mode.
SimpleObjectController
  
bindKey(keyCode:uint, action:String):void
Binds key and action.
SimpleObjectController
  
bindKeys(bindings:Array):void
Binds keys and actions.
SimpleObjectController
  
disable():void
Disables the controller.
SimpleObjectController
  
enable():void
Enables the controler.
SimpleObjectController
  
lookAt(point:Vector3D):void
Sets direction of Z-axis of handled object to pointed at given place.
SimpleObjectController
  
lookAtXYZ(x:Number, y:Number, z:Number):void
Sets direction of Z-axis of handled object to pointed at given place.
SimpleObjectController
  
moveBack(value:Boolean):void
Starts and stops move backward according to true or false was passed.
SimpleObjectController
  
moveDown(value:Boolean):void
Starts and stops move down according to true or false was passed.
SimpleObjectController
  
moveForward(value:Boolean):void
Starts and stops move forward according to true or false was passed.
SimpleObjectController
  
moveLeft(value:Boolean):void
Starts and stops move to left according to true or false was passed.
SimpleObjectController
  
moveRight(value:Boolean):void
Starts and stops move to right according to true or false was passed.
SimpleObjectController
  
moveUp(value:Boolean):void
Starts and stops move up according to true or false was passed.
SimpleObjectController
  
Sets default binding.
SimpleObjectController
  
setObjectPos(pos:Vector3D):void
Sets object at given position.
SimpleObjectController
  
setObjectPosXYZ(x:Number, y:Number, z:Number):void
Sets object at given position.
SimpleObjectController
  
Enables mouse look mode.
SimpleObjectController
  
Disables mouse look mode.
SimpleObjectController
  
unbindAll():void
Clear binding of all keys.
SimpleObjectController
  
unbindKey(keyCode:uint):void
Clear binding for given keyCode.
SimpleObjectController
  
update():void
Calculates and sets new object position.
SimpleObjectController
  
Refreshes controller state from state of handled object.
SimpleObjectController
Public Constants
 ConstantDefined By
  ACTION_ACCELERATE : String = ACTION_ACCELERATE
[static] Name of action for binding "accelerate" action.
SimpleObjectController
  ACTION_BACK : String = ACTION_BACK
[static] Name of action for binding "back" action.
SimpleObjectController
  ACTION_DOWN : String = ACTION_DOWN
[static] Name of action for binding "down" action.
SimpleObjectController
  ACTION_FORWARD : String = ACTION_FORWARD
[static] Name of action for binding "forward" action.
SimpleObjectController
  ACTION_LEFT : String = ACTION_LEFT
[static] Name of action for binding "left" action.
SimpleObjectController
  ACTION_MOUSE_LOOK : String = ACTION_MOUSE_LOOK
[static] ИName of action for binding "mouse look" action.
SimpleObjectController
  ACTION_PITCH_DOWN : String = ACTION_PITCH_DOWN
[static] Name of action for binding "pitch down" action.
SimpleObjectController
  ACTION_PITCH_UP : String = ACTION_PITCH_UP
[static] Name of action for binding "pitch up" action.
SimpleObjectController
  ACTION_RIGHT : String = ACTION_RIGHT
[static] Name of action for binding "right" action.
SimpleObjectController
  ACTION_UP : String = ACTION_UP
[static] Name of action for binding "up" action.
SimpleObjectController
  ACTION_YAW_LEFT : String = ACTION_YAW_LEFT
[static] Name of action for binding "yaw left" action.
SimpleObjectController
  ACTION_YAW_RIGHT : String = ACTION_YAW_RIGHT
[static] Name of action for binding "yaw right" action.
SimpleObjectController
Property Detail
keyBindingsproperty
protected var keyBindings:Object

The hash for binding key codes and action names.

maxPitchproperty 
public var maxPitch:Number = 1e+22

The maximal slope in the vertical plane in radians.

minPitchproperty 
public var minPitch:Number = -1e+22

The minimal slope in the vertical plane in radians.

mouseSensitivityproperty 
public var mouseSensitivity:Number

Mouse sensitivity.

objectproperty 
object:Object3D

Target of handling.


Implementation
    public function get object():Object3D
    public function set object(value:Object3D):void
speedproperty 
public var speed:Number

Speed.

speedMultiplierproperty 
public var speedMultiplier:Number

Speed multiplier for acceleration mode.

Constructor Detail
SimpleObjectController()Constructor
public function SimpleObjectController(eventSource:InteractiveObject, object:Object3D, speed:Number, speedMultiplier:Number = 3, mouseSensitivity:Number = 1)

Creates a SimpleObjectController object.

Parameters
eventSource:InteractiveObject — Source for event listening.
 
object:Object3D — Speed of movement.
 
speed:Number — Mouse sensitivity, i.e. number of degrees per each pixel of mouse movement.
 
speedMultiplier:Number (default = 3)
 
mouseSensitivity:Number (default = 1)
Method Detail
accelerate()method
public function accelerate(value:Boolean):void

Switches acceleration mode.

Parameters

value:Booleantrue turns acceleration on, false turns off.

bindKey()method 
public function bindKey(keyCode:uint, action:String):void

Binds key and action. Only one action can be assigned to one key.

Parameters

keyCode:uint — Key code.
 
action:String — Action name.

See also

bindKeys()method 
public function bindKeys(bindings:Array):void

Binds keys and actions. Only one action can be assigned to one key.

Parameters

bindings:Array — Array which consists of sequence of couples of key code and action. An example are follows: [ keyCode1, action1, keyCode2, action2 ] .

disable()method 
public function disable():void

Disables the controller.

enable()method 
public function enable():void

Enables the controler.

lookAt()method 
public function lookAt(point:Vector3D):void

Sets direction of Z-axis of handled object to pointed at given place. If object is a camera, it will look to this direction.

Parameters

point:Vector3D — Point to look at.

lookAtXYZ()method 
public function lookAtXYZ(x:Number, y:Number, z:Number):void

Sets direction of Z-axis of handled object to pointed at given place. If object is a camera, it will look to this direction.

Parameters

x:Number — X.
 
y:Number — Y.
 
z:Number — Z.

moveBack()method 
public function moveBack(value:Boolean):void

Starts and stops move backward according to true or false was passed.

Parameters

value:Boolean — Action switcher.

moveDown()method 
public function moveDown(value:Boolean):void

Starts and stops move down according to true or false was passed.

Parameters

value:Boolean — Action switcher.

moveForward()method 
public function moveForward(value:Boolean):void

Starts and stops move forward according to true or false was passed.

Parameters

value:Boolean — Action switcher.

moveLeft()method 
public function moveLeft(value:Boolean):void

Starts and stops move to left according to true or false was passed.

Parameters

value:Boolean — Action switcher.

moveRight()method 
public function moveRight(value:Boolean):void

Starts and stops move to right according to true or false was passed.

Parameters

value:Boolean — Action switcher.

moveUp()method 
public function moveUp(value:Boolean):void

Starts and stops move up according to true or false was passed.

Parameters

value:Boolean — Action switcher.

setDefaultBindings()method 
public function setDefaultBindings():void

Sets default binding.

See also

setObjectPos()method 
public function setObjectPos(pos:Vector3D):void

Sets object at given position.

Parameters

pos:Vector3D — The position.

setObjectPosXYZ()method 
public function setObjectPosXYZ(x:Number, y:Number, z:Number):void

Sets object at given position.

Parameters

x:Number — X.
 
y:Number — Y.
 
z:Number — Z.

startMouseLook()method 
public function startMouseLook():void

Enables mouse look mode.

stopMouseLook()method 
public function stopMouseLook():void

Disables mouse look mode.

unbindAll()method 
public function unbindAll():void

Clear binding of all keys.

See also

unbindKey()method 
public function unbindKey(keyCode:uint):void

Clear binding for given keyCode.

Parameters

keyCode:uint — Key code.

See also

update()method 
public function update():void

Calculates and sets new object position.

updateObjectTransform()method 
public function updateObjectTransform():void

Refreshes controller state from state of handled object. Should be called if object was moved without the controller (i.e. object.x = 100;).

Constant Detail
ACTION_ACCELERATEConstant
public static const ACTION_ACCELERATE:String = ACTION_ACCELERATE

Name of action for binding "accelerate" action.

ACTION_BACKConstant 
public static const ACTION_BACK:String = ACTION_BACK

Name of action for binding "back" action.

ACTION_DOWNConstant 
public static const ACTION_DOWN:String = ACTION_DOWN

Name of action for binding "down" action.

ACTION_FORWARDConstant 
public static const ACTION_FORWARD:String = ACTION_FORWARD

Name of action for binding "forward" action.

ACTION_LEFTConstant 
public static const ACTION_LEFT:String = ACTION_LEFT

Name of action for binding "left" action.

ACTION_MOUSE_LOOKConstant 
public static const ACTION_MOUSE_LOOK:String = ACTION_MOUSE_LOOK

ИName of action for binding "mouse look" action.

ACTION_PITCH_DOWNConstant 
public static const ACTION_PITCH_DOWN:String = ACTION_PITCH_DOWN

Name of action for binding "pitch down" action.

ACTION_PITCH_UPConstant 
public static const ACTION_PITCH_UP:String = ACTION_PITCH_UP

Name of action for binding "pitch up" action.

ACTION_RIGHTConstant 
public static const ACTION_RIGHT:String = ACTION_RIGHT

Name of action for binding "right" action.

ACTION_UPConstant 
public static const ACTION_UP:String = ACTION_UP

Name of action for binding "up" action.

ACTION_YAW_LEFTConstant 
public static const ACTION_YAW_LEFT:String = ACTION_YAW_LEFT

Name of action for binding "yaw left" action.

ACTION_YAW_RIGHTConstant 
public static const ACTION_YAW_RIGHT:String = ACTION_YAW_RIGHT

Name of action for binding "yaw right" action.