The X Toolkit API

X.camera2D

/**
* Create a 2D camera.
*
* @constructor
* @param {number} width The width of the camera's viewport.
* @param {number} height The height of the camera's viewport.
* @extends X.camera
*/
var c = new X.camera2D();
/**
* The className of this class.
*
* @type {string}
* @protected
*/
c._classname = $_CLASSNAME;
/**
* The 'dirty' flag of this object.
*
* @type {boolean}
* @protected
*/
c._dirty = $_DIRTY;
/**
* The focus point of this camera, by default 0, 0, 0.
*
* @type {!X.vector}
* @protected
*/
c._focus = $_FOCUS;
/**
* The uniqueId of this instance. Each class instance in XTK has a uniqueId.
*
* @type {number}
* @protected
*/
c._id = $_ID;
/**
* The position of this camera, by default 0, 0, 100.
*
* @type {!X.vector}
* @protected
*/
c._position = $_POSITION;
/**
* The unit vector pointing to the top of the three-dimensional space.
*
* @type {!X.vector}
* @protected
*/
c._up = $_UP;
/**
* The view matrix.
*
* @type {!Float32Array}
* @protected
*/
c._view = $_VIEW;
/**
* Get the className of this object.
*
* @return {string} The className of this object.
* @public
*/
var _classname = c.classname;
/**
* Get the focus (target point) of this camera.
*
* @return {!Array} The focus as an array [X,Y,Z].
*/
var _focus = c.focus;
/**
* Set the focus (target point) of this camera. This forces a re-calculation of
* the view matrix. This action _does not_ force an immediate render event
* automatically.
*
* @param {!Array} focus The X,Y,Z components of the focus as an array.
* @throws {Error} An error, if the focus was invalid.
* @public
*/
c.focus = $FOCUS;
/**
* Get the id of this instance.
*
* @return {string} The className of this object.
* @public
*/
var _id = c.id;
/**
* Get the position of this camera.
*
* @return {!Array} The position as an array [X,Y,Z].
*/
var _position = c.position;
/**
* Set the position of this camera. This forces a re-calculation of the view
* matrix. This action _does not_ force an immediate render event automatically.
*
* @param {!Array} position The X,Y,Z components of the position as an array.
* @throws {Error} An error, if the position was invalid.
* @public
*/
c.position = $POSITION;
/**
* Get the up-vector of this camera.
*
* @return {!Array} The up-vector as an array [X,Y,Z].
*/
var _up = c.up;
/**
* Set the up-vector of this camera. This forces a re-calculation of the view
* matrix. This action _does not_ force an immediate render event automatically.
*
* @param {!Array} up The up vector as an array.
* @throws {Error} An error, if the up vector was invalid.
* @public
*/
c.up = $UP;
/**
* Get the view matrix for the three-dimensional space.
*
* @return {!Float32Array} The view matrix.
*/
var _view = c.view;
/**
* Set the view matrix for the three-dimensional space.
*
* @param {!Float32Array} view The view matrix.
* @throws {Error} An exception if the view matrix is invalid.
* @public
*/
c.view = $VIEW;
/**
* Calculate a view matrix by using the camera position and a focus point.
*
* @param {!X.vector} cameraPosition The camera position.
* @param {!X.vector} targetPoint The focus (target) point.
* @return {!Float32Array} The view matrix.
* @throws {Error} If the given arguments are invalid.
* @protected
*/
var lookAt_ = c.lookAt_($CAMERAPOSITION, $TARGETPOINT);
/**
* Configures observers for a given interactor. The method sets up listeners for
* PAN and ZOOM events.
*
* @param {!X.interactor} interactor The interactor which should be observed.
*/
c.observe($INTERACTOR);
/**
* The callback for a PAN event.
*
* @param {!X.event.PanEvent} event The event.
* @throws {Error} An exception if the event is invalid.
* @protected
*/
c.onPan_($EVENT);
/**
* The callback for a ROTATE event.
*
* @param {!X.event.RotateEvent} event The event.
* @throws {Error} An exception if the event is invalid.
* @protected
*/
c.onRotate_($EVENT);
/**
* The callback for a ZOOM event.
*
* @param {!X.event.ZoomEvent} event The event.
* @throws {Error} An exception if the event is invalid.
* @protected
*/
c.onZoom_($EVENT);
/**
* Perform a pan operation.
*
* @param {!X.vector|!Array} distance The distance of the panning in respect of
*          the last camera position.
* @public
*/
c.pan($DISTANCE);
/**
* Reset the camera according to its configured position and focus.
*/
c.reset();
/**
* Perform a rotate operation.
*
* @param {!X.vector|!Array} distance The distance of the rotation in
*          respect of the last camera position as either a 2D Array or a
*          X.vector containing the X and Y distances for the rotation.
* @public
*/
c.rotate($DISTANCE);
/**
* Perform a zoom in operation.
*
* @param {boolean} fast Enables/disables the fast mode which zooms much
*          quicker.
* @public
*/
c.zoomIn($FAST);
/**
* Perform a zoom out operation.
*
* @param {boolean} fast Enables/disables the fast mode which zooms much
*          quicker.
* @public
*/
c.zoomOut($FAST);


CONSTRUCTORS
X.camera2D

PROPERTIES
_classname
_dirty
_focus
_id
_position
_up
_view

GETTERS/SETTERS
classname
focus
id
position
up
view

FUNCTIONS
lookAt_
observe
onPan_
onRotate_
onZoom_
pan
reset
rotate
zoomIn
zoomOut

STATIC



SOURCECODE