// Class: openfl.geom.PerspectiveProjection

var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this

$global.Object.defineProperty(exports, "__esModule", {value: true});

var __map_reserved = {};

// Imports

var $hxClasses = require("./../../hxClasses_stub").default;
var $import = require("./../../import_stub").default;
function openfl_geom_Matrix3D() {return require("./../../openfl/geom/Matrix3D");}
function openfl_geom_Point() {return require("./../../openfl/geom/Point");}
function openfl_Lib() {return require("./../../openfl/Lib");}

// Constructor

var PerspectiveProjection = function() {
	this.__fieldOfView = 0;
	this.focalLength = 0;
	this.matrix3D = new (openfl_geom_Matrix3D().default)();
	this.projectionCenter = new (openfl_geom_Point().default)((openfl_Lib().default).get_current().stage.stageWidth / 2,(openfl_Lib().default).get_current().stage.stageHeight / 2);
}

// Meta

PerspectiveProjection.__name__ = ["openfl","geom","PerspectiveProjection"];
PerspectiveProjection.prototype = {
	toMatrix3D: function() {
		if(this.projectionCenter == null) {
			return null;
		}
		var _mp = this.matrix3D.rawData;
		_mp.set(0,this.focalLength);
		_mp.set(5,this.focalLength);
		_mp.set(11,1.0);
		_mp.set(15,0);
		return this.matrix3D;
	},
	get_fieldOfView: function() {
		return this.__fieldOfView;
	},
	set_fieldOfView: function(fieldOfView) {
		var p_nFovY = fieldOfView * 0.01745329251994329577;
		this.__fieldOfView = p_nFovY;
		var cotan = 1 / Math.tan(p_nFovY / 2);
		this.focalLength = 250. * cotan;
		return this.__fieldOfView;
	}
};
PerspectiveProjection.prototype.__class__ = $hxClasses["openfl.geom.PerspectiveProjection"] = PerspectiveProjection;

// Init

Object.defineProperty(PerspectiveProjection.prototype,"fieldOfView",{ get : function () { return this.get_fieldOfView (); }, set : function (v) { return this.set_fieldOfView (v); }});

// Statics


PerspectiveProjection.TO_RADIAN = 0.01745329251994329577

// Export

exports.default = PerspectiveProjection;