Skip to content

Commit 320c1cf

Browse files
committed
Merge remote branch 'ChrisDenham/patch-2'
2 parents 5ba1fbc + 4436ba2 commit 320c1cf

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/away3d/cameras/lenses/PerspectiveLens.as

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ package away3d.cameras.lenses
1414
private var _focalLengthInv:Number;
1515
private var _yMax:Number;
1616
private var _xMax:Number;
17+
private var _coordinateSystem:int;
1718

19+
public static const COORDINATE_SYSTEM_LEFT_HANDED:int = 1;
20+
public static const COORDINATE_SYSTEM_RIGHT_HANDED:int = -1;
21+
1822
/**
1923
* Creates a new PerspectiveLens object.
2024
*
@@ -23,6 +27,7 @@ package away3d.cameras.lenses
2327
public function PerspectiveLens(fieldOfView:Number = 60)
2428
{
2529
super();
30+
this.coordinateSystem = COORDINATE_SYSTEM_LEFT_HANDED;
2631
this.fieldOfView = fieldOfView;
2732
}
2833

@@ -102,9 +107,26 @@ package away3d.cameras.lenses
102107
clone._near = _near;
103108
clone._far = _far;
104109
clone._aspectRatio = _aspectRatio;
110+
clone._coordinateSystem = _coordinateSystem;
105111
return clone;
106112
}
107113

114+
/**
115+
* The handedness of the coordinate system projection.
116+
* The default is COORDINATE_SYSTEM_LEFT_HANDED.
117+
*/
118+
public function get coordinateSystem():int
119+
{
120+
return _coordinateSystem;
121+
}
122+
123+
public function set coordinateSystem(value:int):void
124+
{
125+
if (value == _coordinateSystem) return;
126+
_coordinateSystem = value;
127+
invalidateMatrix();
128+
}
129+
108130
/**
109131
* @inheritDoc
110132
*/
@@ -155,6 +177,12 @@ package away3d.cameras.lenses
155177
raw[uint(14)] = -2*_far*_near/(_far - _near);
156178
}
157179

180+
if (_coordinateSystem == COORDINATE_SYSTEM_RIGHT_HANDED)
181+
{
182+
// Switch projection transform from left to right handed.
183+
raw[uint(5)] = -raw[uint(5)];
184+
}
185+
158186
_matrix.copyRawDataFrom(raw);
159187

160188
var yMaxFar:Number = _far*_focalLengthInv;

0 commit comments

Comments
 (0)