Packagealternativa.engine3d.controllers
Classpublic class CameraController

Camera controller. Controller provides camera movement and rotation control using keyboard and mouse. It also provides simple collision detection between camera and scene objects.



Public Properties
 PropertyDefined by
  camera : Camera3D
Currently controlled camera.
CameraController
  checkCollisions : Boolean
Enable collision detection mode.
CameraController
  collisionIgnoreSet : Set
[read-only] Objects set to be exluded from collision detection.
CameraController
  collisionRadius : Number
Collision detection sphere radius.
CameraController
  controlsEnabled : Boolean
Camera control activity.
CameraController
  eventsSource : DisplayObject
The sourse of keyboard and mouse events.
CameraController
  fovStep : Number
Base step to use in field of view (FOV) changes, in radians.
CameraController
  mousePitch : Number
Radians per pixel mouse PITCH speed.
CameraController
  mouseSensitivity : Number
Mouse sensivity.
CameraController
  mouseYaw : Number
Radians per pixel mouse YAW speed.
CameraController
  moveLocal : Boolean
Mouse move mode.
CameraController
  onStartMoving : Function
Callback
CameraController
  onStopMoving : Function
Callback function to be called when camera stops moving.
CameraController
  pitchSpeed : Number
Pitch angle speed when controlling from keyboard (radians per second).
CameraController
  speed : Number
Speed value (units per second).
CameraController
  speedMultiplier : Number
Speed multiplier on acceleration.
CameraController
  yawSpeed : Number
Yaw angle speed when controlling from keyboard (radians per second).
CameraController
  zoomMultiplier : Number
Zoom acceleration coefficient.
CameraController
Public Methods
 MethodDefined by
  
CameraController(eventsSourceObject:DisplayObject)
Create a class instance.
CameraController
  
accelerate(value:Boolean):void
Activate of accelerated speed mode.
CameraController
  
back(value:Boolean):void
Activate camera back movement.
CameraController
  
bindKey(keyCode:uint, action:String):void
Connect button with action
CameraController
  
down(value:Boolean):void
Activate camera down movement.
CameraController
  
forward(value:Boolean):void
Activate camera forward movement.
CameraController
  
left(value:Boolean):void
Activate camera left movement.
CameraController
  
lookAt(point:Point3D):void
Targeting camera to the given point.
CameraController
  
pitchDown(value:Boolean):void
Activate camera pitch down.
CameraController
  
pitchUp(value:Boolean):void
Activate camera pitch up.
CameraController
  
processInput():void
Input processing.
CameraController
  
right(value:Boolean):void
Activate camera right movement.
CameraController
  
Set default key bindings.
CameraController
  
unbindAll():void
Clear all key bindings.
CameraController
  
unbindKey(keyCode:uint):void
Clear key binding.
CameraController
  
up(value:Boolean):void
Activate camera up movement.
CameraController
  
yawLeft(value:Boolean):void
Activate camera yaw left.
CameraController
  
yawRight(value:Boolean):void
Activate camera yaw right.
CameraController
Public Constants
 ConstantDefined by
  ACTION_ACCELERATE : String = "ACTION_ACCELERATE"
[static] Action name for binding ACCELERATE button.
CameraController
  ACTION_BACK : String = "ACTION_BACK"
[static] Action name for binding BACK movement button.
CameraController
  ACTION_DOWN : String = "ACTION_DOWN"
[static] Action name for binding DOWN movement button.
CameraController
  ACTION_FORWARD : String = "ACTION_FORWARD"
[static] Action name for binding FORWARD movement button.
CameraController
  ACTION_LEFT : String = "ACTION_LEFT"
[static] Action name for binding LEFT movement button.
CameraController
  ACTION_PITCH_DOWN : String = "ACTION_PITCH_DOWN"
[static] Action name for binding PITCH DOWN movement button.
CameraController
  ACTION_PITCH_UP : String = "ACTION_PITCH_UP"
[static] Action name for binding PITCH UP movement button.
CameraController
  ACTION_RIGHT : String = "ACTION_RIGHT"
[static] Action name for binding RIGHT movement button.
CameraController
  ACTION_UP : String = "ACTION_UP"
[static] Action name for binding UP movement button.
CameraController
  ACTION_YAW_LEFT : String = "ACTION_YAW_LEFT"
[static] Action name for binding YAW LEFT movement angle (rotate left) button.
CameraController
  ACTION_YAW_RIGHT : String = "ACTION_YAW_RIGHT"
[static] Action name for binding YAW RIGHT movement angle (rotate right) button.
CameraController
Property detail
cameraproperty
camera:Camera3D  [read-write]

Currently controlled camera.

Implementation
    public function get camera():Camera3D
    public function set camera(value:Camera3D):void
checkCollisionsproperty 
checkCollisions:Boolean  [read-write]

Enable collision detection mode. The property is not set until camera is placed on scene.

Implementation
    public function get checkCollisions():Boolean
    public function set checkCollisions(value:Boolean):void
collisionIgnoreSetproperty 
collisionIgnoreSet:Set  [read-only]

Objects set to be exluded from collision detection.

Implementation
    public function get collisionIgnoreSet():Set
collisionRadiusproperty 
collisionRadius:Number  [read-write]

Collision detection sphere radius.

The default value is 0.

Implementation
    public function get collisionRadius():Number
    public function set collisionRadius(value:Number):void
controlsEnabledproperty 
controlsEnabled:Boolean  [read-write]

Camera control activity.

The default value is false.

Implementation
    public function get controlsEnabled():Boolean
    public function set controlsEnabled(value:Boolean):void
eventsSourceproperty 
eventsSource:DisplayObject  [read-write]

The sourse of keyboard and mouse events.

Implementation
    public function get eventsSource():DisplayObject
    public function set eventsSource(value:DisplayObject):void

Throws
ArgumentError — throws if specified value is null
fovStepproperty 
fovStep:Number  [read-write]

Base step to use in field of view (FOV) changes, in radians. Real step is being calculated by multiplying this value on MouseEvent.delta.

The default value is Math.PI / 180.

Implementation
    public function get fovStep():Number
    public function set fovStep(value:Number):void
mousePitchproperty 
mousePitch:Number  [read-write]

Radians per pixel mouse PITCH speed.

The default value is Math.PI / 360.

Implementation
    public function get mousePitch():Number
    public function set mousePitch(value:Number):void
mouseSensitivityproperty 
mouseSensitivity:Number  [read-write]

Mouse sensivity.

The default value is 1.

Implementation
    public function get mouseSensitivity():Number
    public function set mouseSensitivity(value:Number):void

See also

mouseYawproperty 
mouseYaw:Number  [read-write]

Radians per pixel mouse YAW speed.

The default value is Math.PI / 360.

Implementation
    public function get mouseYaw():Number
    public function set mouseYaw(value:Number):void
moveLocalproperty 
moveLocal:Boolean  [read-write]

Mouse move mode. If true, uses local coordinates, otherwise uses global coordinates system.

The default value is true.

Implementation
    public function get moveLocal():Boolean
    public function set moveLocal(value:Boolean):void
onStartMovingproperty 
onStartMoving:Function  [read-write]

Callback

Implementation
    public function get onStartMoving():Function
    public function set onStartMoving(value:Function):void
onStopMovingproperty 
onStopMoving:Function  [read-write]

Callback function to be called when camera stops moving.

Implementation
    public function get onStopMoving():Function
    public function set onStopMoving(value:Function):void
pitchSpeedproperty 
pitchSpeed:Number  [read-write]

Pitch angle speed when controlling from keyboard (radians per second).

The default value is 1.

Implementation
    public function get pitchSpeed():Number
    public function set pitchSpeed(value:Number):void
speedproperty 
speed:Number  [read-write]

Speed value (units per second).

Implementation
    public function get speed():Number
    public function set speed(value:Number):void
speedMultiplierproperty 
speedMultiplier:Number  [read-write]

Speed multiplier on acceleration.

The default value is 2.

Implementation
    public function get speedMultiplier():Number
    public function set speedMultiplier(value:Number):void
yawSpeedproperty 
yawSpeed:Number  [read-write]

Yaw angle speed when controlling from keyboard (radians per second).

The default value is 1.

Implementation
    public function get yawSpeed():Number
    public function set yawSpeed(value:Number):void
zoomMultiplierproperty 
zoomMultiplier:Number  [read-write]

Zoom acceleration coefficient.

The default value is 0.1.

Implementation
    public function get zoomMultiplier():Number
    public function set zoomMultiplier(value:Number):void
Constructor detail
CameraController()constructor
public function CameraController(eventsSourceObject:DisplayObject)

Create a class instance.

Parameters
eventsSourceObject:DisplayObjectobject that is being used for mouse and keyboard events

Throws
ArgumentError — throws if eventsSourceObject is null
Method detail
accelerate()method
public function accelerate(value:Boolean):void

Activate of accelerated speed mode.

Parameters
value:Booleantrue to turn on accelerated mode, false to turn it off
back()method 
public function back(value:Boolean):void

Activate camera back movement.

Parameters
value:Booleantrue to start movement, false to stop movement
bindKey()method 
public function bindKey(keyCode:uint, action:String):void

Connect button with action

Parameters
keyCode:uintkey code
 
action:Stringaction name
down()method 
public function down(value:Boolean):void

Activate camera down movement.

Parameters
value:Booleantrue to start movement, false to stop movement
forward()method 
public function forward(value:Boolean):void

Activate camera forward movement.

Parameters
value:Booleantrue to start movement, false to stop movement
left()method 
public function left(value:Boolean):void

Activate camera left movement.

Parameters
value:Booleantrue to start movement, false to stop movement
lookAt()method 
public function lookAt(point:Point3D):void

Targeting camera to the given point.

Parameters
point:Point3Dcamera target point
pitchDown()method 
public function pitchDown(value:Boolean):void

Activate camera pitch down.

Parameters
value:Booleantrue to start movement, false to stop movement
pitchUp()method 
public function pitchUp(value:Boolean):void

Activate camera pitch up.

Parameters
value:Booleantrue to start movement, false to stop movement
processInput()method 
public function processInput():void

Input processing. Method must be used every frame before calling Scene3D.calculate().

See also

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

Activate camera right movement.

Parameters
value:Booleantrue to start movement, false to stop movement
setDefaultBindings()method 
public function setDefaultBindings():void

Set default key bindings. This method clears previous bindings and sets following:

unbindAll()method 
public function unbindAll():void

Clear all key bindings.

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

Clear key binding.

Parameters
keyCode:uintkey code
up()method 
public function up(value:Boolean):void

Activate camera up movement.

Parameters
value:Booleantrue to start movement, false to stop movement
yawLeft()method 
public function yawLeft(value:Boolean):void

Activate camera yaw left.

Parameters
value:Booleantrue to start movement, false to stop movement
yawRight()method 
public function yawRight(value:Boolean):void

Activate camera yaw right.

Parameters
value:Booleantrue to start movement, false to stop movement
Constant detail
ACTION_ACCELERATEconstant
public static const ACTION_ACCELERATE:String = "ACTION_ACCELERATE"

Action name for binding ACCELERATE button.

ACTION_BACKconstant 
public static const ACTION_BACK:String = "ACTION_BACK"

Action name for binding BACK movement button.

ACTION_DOWNconstant 
public static const ACTION_DOWN:String = "ACTION_DOWN"

Action name for binding DOWN movement button.

ACTION_FORWARDconstant 
public static const ACTION_FORWARD:String = "ACTION_FORWARD"

Action name for binding FORWARD movement button.

ACTION_LEFTconstant 
public static const ACTION_LEFT:String = "ACTION_LEFT"

Action name for binding LEFT movement button.

ACTION_PITCH_DOWNconstant 
public static const ACTION_PITCH_DOWN:String = "ACTION_PITCH_DOWN"

Action name for binding PITCH DOWN movement button.

ACTION_PITCH_UPconstant 
public static const ACTION_PITCH_UP:String = "ACTION_PITCH_UP"

Action name for binding PITCH UP movement button.

ACTION_RIGHTconstant 
public static const ACTION_RIGHT:String = "ACTION_RIGHT"

Action name for binding RIGHT movement button.

ACTION_UPconstant 
public static const ACTION_UP:String = "ACTION_UP"

Action name for binding UP movement button.

ACTION_YAW_LEFTconstant 
public static const ACTION_YAW_LEFT:String = "ACTION_YAW_LEFT"

Action name for binding YAW LEFT movement angle (rotate left) button.

ACTION_YAW_RIGHTconstant 
public static const ACTION_YAW_RIGHT:String = "ACTION_YAW_RIGHT"

Action name for binding YAW RIGHT movement angle (rotate right) button.