Skip to content

Commit

Permalink
Merge remote branch 'ChrisDenham/patch-2'
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-bateman committed Jan 24, 2014
2 parents 5ba1fbc + 4436ba2 commit 320c1cf
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/away3d/cameras/lenses/PerspectiveLens.as
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ package away3d.cameras.lenses
private var _focalLengthInv:Number;
private var _yMax:Number;
private var _xMax:Number;
private var _coordinateSystem:int;

public static const COORDINATE_SYSTEM_LEFT_HANDED:int = 1;
public static const COORDINATE_SYSTEM_RIGHT_HANDED:int = -1;

/**
* Creates a new PerspectiveLens object.
*
Expand All @@ -23,6 +27,7 @@ package away3d.cameras.lenses
public function PerspectiveLens(fieldOfView:Number = 60)
{
super();
this.coordinateSystem = COORDINATE_SYSTEM_LEFT_HANDED;
this.fieldOfView = fieldOfView;
}

Expand Down Expand Up @@ -102,9 +107,26 @@ package away3d.cameras.lenses
clone._near = _near;
clone._far = _far;
clone._aspectRatio = _aspectRatio;
clone._coordinateSystem = _coordinateSystem;
return clone;
}

/**
* The handedness of the coordinate system projection.
* The default is COORDINATE_SYSTEM_LEFT_HANDED.
*/
public function get coordinateSystem():int
{
return _coordinateSystem;
}

public function set coordinateSystem(value:int):void
{
if (value == _coordinateSystem) return;
_coordinateSystem = value;
invalidateMatrix();
}

/**
* @inheritDoc
*/
Expand Down Expand Up @@ -155,6 +177,12 @@ package away3d.cameras.lenses
raw[uint(14)] = -2*_far*_near/(_far - _near);
}

if (_coordinateSystem == COORDINATE_SYSTEM_RIGHT_HANDED)
{
// Switch projection transform from left to right handed.
raw[uint(5)] = -raw[uint(5)];
}

_matrix.copyRawDataFrom(raw);

var yMaxFar:Number = _far*_focalLengthInv;
Expand Down

0 comments on commit 320c1cf

Please sign in to comment.