Camera

Camera class.

Constructor

new Camera(rendereropt, optionsopt)

Parameters:
NameTypeAttributesDescription
rendererRenderer<optional>

Renderer uses the camera instance.

optionsObject<optional>

Camera options:

Properties
NameTypeAttributesDefaultDescription
nameObject<optional>

Camera name.

viewAnglenumber<optional>
47

Camera angle of view. Default is 47.0

nearnumber<optional>
1

Camera near plane distance. Default is 1.0

farnumber<optional>
og.math.MAX

Camera far plane distance. Default is og.math.MAX

eyeVec3<optional>
[0,0,0]

Camera eye position. Default (0,0,0)

lookVec3<optional>
[0,0,0]

Camera look position. Default (0,0,0)

upVec3<optional>
[0,1,0]

Camera eye position. Default (0,1,0)

Fires:
  • EventsHandler#event:viewchange
  • EventsHandler#event:moveend

Methods

_init(optionsopt)

Camera initialization.

Parameters:
NameTypeAttributesDescription
optionsObject<optional>

Camera options:

Properties
NameTypeAttributesDescription
viewAnglenumber<optional>

Camera angle of view.

nearnumber<optional>

Camera near plane distance. Default is 1.0

farnumber<optional>

Camera far plane distance. Default is math.MAX

eyeVec3<optional>

Camera eye position. Default (0,0,0)

lookVec3<optional>

Camera look position. Default (0,0,0)

upVec3<optional>

Camera eye position. Default (0,1,0)

_setProj(angle, aspect)

Sets up camera projection

Parameters:
NameTypeDescription
anglenumber

Camera view angle

aspectnumber

Screen aspect ratio

getAspectRatio() → {number}

Returns aspect ratio

Returns:
  • Aspect ratio
Type: 
number

getInverseProjectionMatrix() → {Mat4}

Returns inverse projection matrix.

Returns:
  • Inverse projection-view matrix.
Type: 
Mat4

getInverseProjectionViewMatrix() → {Mat4}

Returns inverse projection and model matrix product.

Returns:
  • Inverse projection-view matrix.
Type: 
Mat4

getNormalMatrix() → {NumberArray9}

Returns normal matrix.

Returns:
  • Normal matrix.
Type: 
NumberArray9

getProjectionMatrix() → {Mat4}

Returns projection matrix.

Returns:
  • Projection matrix.
Type: 
Mat4

getProjectionViewMatrix() → {Mat4}

Returns projection and model matrix product.

Returns:
  • Projection-view matrix.
Type: 
Mat4

getViewAngle() → {number}

Gets camera view angle in degrees

Returns:

angle -

Type: 
number

getViewMatrix() → {NumberArray16}

Returns model matrix.

Returns:
  • View matrix.
Type: 
NumberArray16

look(look, upopt)

Sets camera look point

Parameters:
NameTypeAttributesDescription
lookVec3

Look point

upVec3<optional>

Camera up vector otherwise camera current up vector(this._u)

pitch(angle)

Pitch the camera to the angle in degrees

Parameters:
NameTypeDescription
anglenumber

Delta pitch angle in degrees

project(v) → {Vec2}

Gets projected 3d point to the 2d screen coordinates

Parameters:
NameTypeDescription
vVec3

Cartesian 3d coordinates

Returns:
  • Screen point coordinates
Type: 
Vec2

projectedSize(p, r) → {number}

Gets 3d size factor. Uses in LOD distance calculation.

Parameters:
NameTypeDescription
pVec3

Far point.

rVec3

Far point.

Returns:
  • Size factor.
Type: 
number

refresh()

Refresh camera matrices

roll(angle)

Roll the camera to the angle in degrees

Parameters:
NameTypeDescription
anglenumber

Delta roll angle in degrees

rotateAround(angle, isArcopt, centeropt, upopt)

Rotates camera around center point

Parameters:
NameTypeAttributesDescription
anglenumber

Rotation angle in radians

isArcboolean<optional>

If true camera up vector gets from current up vector every frame, otherwise up is always input parameter.

centerVec3<optional>

Point that the camera rotates around

upVec3<optional>

Camera up vector

rotateHorizontal(angle, isArcopt, centeropt, upopt)

Rotates camera around center point by horizontal.

Parameters:
NameTypeAttributesDescription
anglenumber

Rotation angle in radians.

isArcboolean<optional>

If true camera up vector gets from current up vector every frame, otherwise up is always input parameter.

centerVec3<optional>

Point that the camera rotates around.

upVec3<optional>

Camera up vector.

rotateVertical(angle, centeropt)

Rotates camera around center point by vertical.

Parameters:
NameTypeAttributesDescription
anglenumber

Rotation angle in radians.

centerVec3<optional>

Point that the camera rotates around.

set(eye, look, up) → {Camera}

Sets camera to eye position

Parameters:
NameTypeDescription
eyeVec3

Camera position

lookVec3

Look point

upVec3

Camera up vector

Returns:
  • This camera
Type: 
Camera

setAspectRatio(aspect)

Sets aspect ratio

Parameters:
NameTypeDescription
aspectNumber

Camera aspect ratio

setViewAngle(angle)

Sets camera view angle in degrees

Parameters:
NameTypeDescription
anglenumber

View angle

slide(du, dv, dn)

Slides camera to vector d - (du, dv, dn)

Parameters:
NameTypeDescription
dunumber

delta X

dvnumber

delta Y

dnnumber

delta Z

unproject(x, y) → {Vec3}

Returns normal vector direction to the unprojected screen point from camera eye

Parameters:
NameTypeDescription
xnumber

Screen X coordinate

ynumber

Screen Y coordinate

Returns:
  • Direction vector
Type: 
Vec3

(abstract) update()

Updates camera view space

yaw(angle)

Yaw the camera to the angle in degrees

Parameters:
NameTypeDescription
anglenumber

Delta yaw angle in degrees