Constructor

@:value({ rightHanded : false, zFar : 4000., zNear : 0.02, screenRatio : 1.333333, zoom : 1., fovY : 25. })new(fovY:Float = 25., zoom:Float = 1., screenRatio:Float = 1.333333, zNear:Float = 0.02, zFar:Float = 4000., rightHanded:Bool = false)

Variables

follow:{target:Object, pos:Object}

fovY:Float

The vertical FieldOfView, in degrees. Usually cameras are using an horizontal FOV, but the value will change depending on the screen ratio. For instance a 4:3 screen will have a lower horizontal FOV than a 16:9 one, however the vertical FOV remains constant. Use setFovX to initialize fovY based on an horizontal FOV and an initial screen ratio.

read onlyfrustum:Frustum

@:value(0.)jitterOffsetX:Float = 0.

@:value(0.)jitterOffsetY:Float = 0.

orthoBounds:Bounds

Set orthographic bounds.

screenRatio:Float

The screenRatio represents the W/H screen ratio.

up:Vector

up is used for the lookAt matrix. it is not the actual up axis of the camera. use getUp instead.

@:value(0.)viewX:Float = 0.

@:value(0.)viewY:Float = 0.

zFar:Float

zNear:Float

zoom:Float

Methods

@:value({ speed : 1. })backward(speed:Float = 1.):Void

depthToDistance(depth:Float):Float

distanceToDepth(dist:Float):Float

@:value({ speed : 1. })forward(speed:Float = 1.):Void

inlinegetForward():Vector

Returns the forward of the camera. Cache the result until the next update().

getFovX():Float

Calculate the current horizontal fov (in degrees).

@:value({ zMin : 0., zMax : 1. })getFrustumCorners(zMax:Float = 1., zMin:Float = 0.):Array<Vector>

getInverseProj():Matrix

Returns the inverse of the camera matrix projection. Cache the result until the next update().

getInverseView():Matrix

Returns the inverse of the camera matrix view only. Cache the result until the next update().

getInverseViewProj():Matrix

Returns the inverse of the camera matrix view and projection. Cache the result until the next update().

inlinegetRight():Vector

Returns the right of the camera. Cache the result until the next update().

inlinegetUp():Vector

Returns the up of the camera. Cache the result until the next update().

@:value({ dz : 0. })getViewDirection(dx:Float, dy:Float, dz:Float = 0.):Vector

load(cam:Camera):Void

lostUp():Bool

@:value({ dz : 0. })movePosAxis(dx:Float, dy:Float, dz:Float = 0.):Void

@:value({ dz : 0. })moveTargetAxis(dx:Float, dy:Float, dz:Float = 0.):Void

@:value({ snapToPixel : true })project(x:Float, y:Float, z:Float, screenWidth:Float, screenHeight:Float, snapToPixel:Bool = true, ?p:Vector):Null<Vector>

@:value({ snapToPixel : true })inlineprojectInline(x:Float, y:Float, z:Float, screenWidth:Float, screenHeight:Float, snapToPixel:Bool = true):Vector

Project a 3D point into the 2D screen. Make sure to update() the camera if it's been moved before using that.

@:value({ sceneHeight : -1, sceneWidth : -1 })rayFromScreen(pixelX:Float, pixelY:Float, sceneWidth:Int = -1, sceneHeight:Int = -1):Ray

setCubeMap(face:Int, ?position:Vector):Void

Setup camera for cubemap rendering on the given face.

setFovX(fovX:Float, withRatio:Float):Void

Set the vertical fov based on a given horizontal fov (in degrees) for a specified screen ratio.

unproject(screenX:Float, screenY:Float, camZ:Float):Vector

Transforms a 2D screen position into the 3D one according to the current camera. The screenX and screenY values must be in the [-1,1] range. The camZ value represents the normalized z in the frustum in the [0,1] range. [unproject] can be used to get the ray from the camera position to a given screen position by using two different camZ values. For instance the 3D ray between unproject(0,0,0) and unproject(0,0,1) is the center axis of the 3D frustum.

update():Void