diff --git a/src/away3d/cameras/lenses/OrthographicLens.as b/src/away3d/cameras/lenses/OrthographicLens.as index 26d905637..e292c04bf 100644 --- a/src/away3d/cameras/lenses/OrthographicLens.as +++ b/src/away3d/cameras/lenses/OrthographicLens.as @@ -54,7 +54,7 @@ package away3d.cameras.lenses var translation:Vector3D = Matrix3DUtils.CALCULATION_VECTOR3D; matrix.copyColumnTo(3, translation); v.x = nX + translation.x; - v.y = nX + translation.y; + v.y = -nY + translation.y; v.z = sZ; v.w = 1; diff --git a/src/away3d/cameras/lenses/PerspectiveLens.as b/src/away3d/cameras/lenses/PerspectiveLens.as index 8652801a4..f8cfc82c3 100644 --- a/src/away3d/cameras/lenses/PerspectiveLens.as +++ b/src/away3d/cameras/lenses/PerspectiveLens.as @@ -21,7 +21,7 @@ package away3d.cameras.lenses * * @param fieldOfView The vertical field of view of the projection. */ - public function PerspectiveLens(fieldOfView:Number = 60, coordinateSystem = CoordinateSystem.LEFT_HANDED) + public function PerspectiveLens(fieldOfView:Number = 60, coordinateSystem:uint = 0) { super(); diff --git a/src/away3d/tools/utils/Drag3D.as b/src/away3d/tools/utils/Drag3D.as index 3f9354bdf..3c0242230 100644 --- a/src/away3d/tools/utils/Drag3D.as +++ b/src/away3d/tools/utils/Drag3D.as @@ -380,16 +380,20 @@ package away3d.tools.utils private function intersect(x:Number = NaN, y:Number = NaN):void { - var pMouse:Vector3D = (isNaN(x) && isNaN(y))? _view.unproject(_view.mouseX, _view.mouseY, 1, Matrix3DUtils.CALCULATION_VECTOR3D) : _view.unproject(x, y, 1, Matrix3DUtils.CALCULATION_VECTOR3D); + var rayPosition:Vector3D = (isNaN(x) && isNaN(y))? _view.unproject(_view.mouseX, _view.mouseY, 0) : _view.unproject(x, y, 0); + var rayDirection:Vector3D = (isNaN(x) && isNaN(y))? _view.unproject(_view.mouseX, _view.mouseY, 1) : _view.unproject(x, y, 1); - var cam:Vector3D = _view.camera.position; - var d0:Number = _np.x*cam.x + _np.y*cam.y + _np.z*cam.z - _d; - var d1:Number = _np.x*pMouse.x + _np.y*pMouse.y + _np.z*pMouse.z - _d; - var m:Number = d1/( d1 - d0 ); + rayDirection.x = rayDirection.x - rayPosition.x; + rayDirection.y = rayDirection.y - rayPosition.y; + rayDirection.z = rayDirection.z - rayPosition.z; - _intersect.x = pMouse.x + ( cam.x - pMouse.x )*m; - _intersect.y = pMouse.y + ( cam.y - pMouse.y )*m; - _intersect.z = pMouse.z + ( cam.z - pMouse.z )*m; + var nDotV:Number = _np.x * rayDirection.x + _np.y * +rayDirection.y + _np.z * rayDirection.z; + var disToPlane:Number = -( _np.x * rayPosition.x + _np.y * rayPosition.y + _np.z * rayPosition.z + _d ); + var t:Number = disToPlane / nDotV; + + _intersect.x = rayPosition.x + t * rayDirection.x; + _intersect.y = rayPosition.y + t * rayDirection.y; + _intersect.z = rayPosition.z + t * rayDirection.z; if (_bSetOffset) { _bSetOffset = false;