Class: Camera

og/camera/Camera~Camera

Camera class.

new Camera(renderer, options)

Name Type Description
renderer og.Renderer optional Renderer uses the camera instance.
options Object optional Camera options:
Name Type Default Description
name Object optional Camera name.
viewAngle number 30 optional Camera angle of view. Default is 30.0
near number 1 optional Camera near plane distance. Default is 1.0
far number og.math.MAX optional Camera far plane distance. Deafult is og.math.MAX
eye og.Vec3 [0,0,0] optional Camera eye position. Default (0,0,0)
look og.Vec3 [0,0,0] optional Camera look position. Default (0,0,0)
up og.Vec3 [0,1,0] optional Camera eye position. Default (0,1,0)
Fires:

Members

protected_aspectNumber

Aspect ratio.

protected_farDistNumber

Camera far distance.

protected_inverseProjectionViewMatrixog.Mat4

Inverse projectionView Matrix.

protected_nog.Vec3

Camera forward vector.

protected_nearDistNumber

Camera near distance.

protected_normalMatrixog.Mat3

Camera normal matrix.

protected_projectionMatrixog.Mat4

Camera projection matrix.

protected_projectionMatrixPreciseog.Mat4

Camera projection matrix for small near and far distances.

protected_projectionViewMatrixog.Mat4

Product of projection and view matrices.

protected_uog.Vec3

Camera right vector.

protected_vog.Vec3

Camera up vector.

protected_viewAngleNumber

Camera view angle in degrees.

protected_viewMatrixog.Mat4

Camera view matrix.

eventsog.Events

Camera events handler.

eyeog.Vec3

Camera position.

frustumog.Frustum

Camera frustum.

rendererog.Renderer

Assigned renderer.

Methods

_initialize(renderer, options)

Camera initialization.
Name Type Description
renderer og.Renderer OpenGlobus renderer object.
options Object optional Camera options:
Name Type Description
viewAngle number optional Camera angle of view. Default is 30.0
near number optional Camera near plane distance. Default is 1.0
far number optional Camera far plane distance. Deafult is og.math.MAX
eye og.Vec3 optional Camera eye position. Default (0,0,0)
look og.Vec3 optional Camera look position. Default (0,0,0)
up og.Vec3 optional Camera eye position. Default (0,1,0)

protected_setViewMatrix()

Updates model view matrix.
Clone camera instance to another one.
Returns:
Type Description
og.Camera - Cloned camera instance.

getAspectRatio(){number}

Returns aspect ratio.
Returns:
Type Description
number - Aspect ratio.

getFar(){number}

Gets far distance.
Returns:
Type Description
number - Far plane distance.

getInverseProjecttionViewMatrix(){og.Mat4}

Returns inverse projection and model matrix product.
Returns:
Type Description
og.Mat4 - Inversed projection-view matrix.

getNear(){number}

Gets near distance.
Returns:
Type Description
number - Near plane distance.

getNormalMatrix(){og.Mat3}

Returns normal matrix.
Returns:
Type Description
og.Mat3 - Normal matrix.

getProjectionMatrix(){og.Mat4}

Returns projection matrix.
Returns:
Type Description
og.Mat4 - Projection matrix.

getProjectionViewMatrix(){og.Mat4}

Returns projection and model matrix product.
Returns:
Type Description
og.Mat4 - Projection-view matrix.

getViewMatrix(){og.Mat4}

Returns model matrix.
Returns:
Type Description
og.Mat4 - View matrix.

look(look, up)

Sets camera look point.
Name Type Description
look og.Vec3 Look point.
up og.Vec3 optional Camera up vector otherwise camera current up vector(this._v)
Pitch the camera to the angle in degrees.
Name Type Description
angle number Delta pitch angle in degrees.

project(v){og.Vec2}

Gets projected 3d point to the 2d screen coordiantes.
Name Type Description
v og.Vec3 Cartesian 3d coordiantes.
Returns:
Type Description
og.Vec2 - Screen point coordinates.

projectedSize(p, r){number}

Gets 3d size factor. Uses in LOD distance calculation.
Name Type Description
p og.Vec3 Far point.
r og.Vec3 Far point.
Returns:
Type Description
number - Size factor.
Refresh camera matrices.
Roll the camera to the angle in degrees.
Name Type Description
angle number Delta roll angle in degrees.

rotateAround(angle, isArc, center, up)

Rotates camera around center point.
Name Type Description
angle number Rotation angle in radians.
isArc boolaen If true camera up vector gets from current up vector every frame, otherwise up is always input parameter.
center og.Vec3 Point that the camera rotates around.
up og.math.Vecto3 optional Camera up vector.

rotateHorizontal(angle, isArc, center, up)

Rotates camera around center point by horizontal.
Name Type Description
angle number Rotation angle in radians.
isArc boolaen If true camera up vector gets from current up vector every frame, otherwise up is always input parameter.
center og.Vec3 Point that the camera rotates around.
up og.Vec3 optional Camera up vector.

rotateVertical(angle, center)

Rotates camera around center point by vecrtical.
Name Type Description
angle number Rotation angle in radians.
center og.Vec3 Point that the camera rotates around.

set(eye, look, up){og.Camera}

Sets camera to eye position.
Name Type Description
eye og.Vec3 Camera position.
look og.Vec3 Look point.
up og.Vec3 Camera up vector.
Returns:
Type Description
og.Camera - This camera.

setAspectRatio(aspect)

Sets aspect ratio.
Name Type Description
aspect Number Camera aspect ratio.

setFar(distance)

Sets far camera distance.
Name Type Description
distance number Far distance.

setNear(distance)

Sets camera's near distance.
Name Type Description
distance number Near distance.

setProjectionMatrix(angle, aspect, near, far)

Sets up camera projection matrix.
Name Type Description
angle nnumber Camera's view angle.
aspect number Screen aspect ration.
near number Near camera distance.
far number Far camera distance.

setViewAngle(angle)

Sets camera view angle in degrees.
Name Type Description
angle number View angle.

slide(du, dv, dn)

Slides camera to vector d - (du, dv, dn).
Name Type Description
du number delta X.
dv number delta Y.
dn number delta Z.

unproject(x, y){og.Vec3}

Returns normal vector direction to to the unprojected screen point from camera eye.
Name Type Description
x number Scren X coordinate.
y number Scren Y coordinate.
Returns:
Type Description
og.Vec3 - Direction vector.

abstractupdate()

Updates camera view space.
Yaw the camera to the angle in degrees.
Name Type Description
angle number Delta yaw angle in degrees.