PlanetCamera

Planet camera.

Constructor

new PlanetCamera(planet, optionsopt)

Parameters:
NameTypeAttributesDescription
planetPlanet

Planet render node.

optionsIPlanetCameraParams<optional>

Planet camera options:

Properties
NameTypeAttributesDescription
namestring<optional>

Camera name.

viewAnglenumber<optional>

Camera angle of view.

nearnumber<optional>

Camera near plane distance. Default is 1.0

farnumber<optional>

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

minAltitudenumber<optional>

Minimal altitude for the camera. Default is 5

maxAltitudenumber<optional>

Maximal altitude for the camera. Default is 20000000

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)

Fires:
  • event:viewchange
  • event:moveend
  • event:flystart
  • event:flyend
  • event:flystop

Extends

Members

depthZeroToOne

Returns active depth range mode.

focusDistance

Returns focus distance used for orthographic projection size.

frustum

Returns current active frustum.

height

Returns viewport height.

Overrides

horizontalViewAngle

Returns camera horizontal view angle in degrees.

id

Returns camera identifier.

Overrides

isOrthographic

Returns current projection mode.

reverseDepth

Returns reverse depth flag.

reverseDepthActive

Returns active reverse depth state.

verticalViewAngle

Returns camera vertical view angle in degrees.

viewAngle

Returns camera vertical view angle in degrees.

width

Returns viewport width.

Overrides

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)

Overrides

_setProj(viewAngle, aspect)

Sets camera projection.

Parameters:
NameTypeDescription
viewAnglenumber

Camera view angle.

aspectnumber

Screen aspect ratio.

bindFrustumsPickingColors(renderer)

Binds picking colors for all frustums.

Parameters:
NameTypeDescription
rendererRenderer

Renderer instance.

checkFly()

Prepare camera to the frame. Used in render node frame function.

checkMoveEnd()

Checks whether the camera stopped moving and dispatches moveend.

checkTerrainCollision() → {Vec3|undefined}

Updates terrain altitude and keeps camera above minimum altitude.

Returns:

Terrain point under camera when available.

Type: 
Vec3 | undefined

containsSphere(sphere) → {boolean}

Checks whether sphere intersects any camera frustum.

Parameters:
NameTypeDescription
sphereSphere

Bounding sphere.

Returns:

true when visible in at least one frustum.

Type: 
boolean

copy(cam)

Copies camera pose and projection settings from another camera.

Parameters:
NameTypeDescription
camCamera

Source camera.

Overrides

flyCartesian(cartesianopt, paramsopt)

Flies to the cartesian coordinates.

Parameters:
NameTypeAttributesDescription
cartesianVec3<optional>

Finish cartesian coordinates.

paramsIFlyCartesianParams<optional>

Flight parameters

flyDistance(cartesian, distanceopt, paramsopt)

Flies camera to a position at a fixed distance from the target point.

Parameters:
NameTypeAttributesDefaultDescription
cartesianVec3

Target cartesian point.

distancenumber<optional>
10000.0

Distance from the target.

paramsIPlanetFlyCartesianParams<optional>

Flight parameters.

flyExtent(extent, heightopt, paramsopt)

Flies to the current extent.

Parameters:
NameTypeAttributesDescription
extentExtent

Current extent.

heightnumber<optional>

Destination height.

paramsIPlanetFlyCartesianParams<optional>

Flight parameters

flyLonLat(lonlat, paramsopt)

Flies to the geo coordinates.

Parameters:
NameTypeAttributesDescription
lonlatLonLat

Finish coordinates.

paramsIPlanetFlyCartesianParams<optional>

Flight parameters

getAbsolutePitch() → {number}

Returns absolute pitch angle.

Returns:

Absolute pitch angle in radians.

Type: 
number

getAbsoluteRoll() → {number}

Returns absolute roll angle.

Returns:

Absolute roll angle in radians.

Type: 
number

getAbsoluteYaw() → {number}

Returns absolute yaw angle.

Returns:

Absolute yaw angle in radians.

Type: 
number

getAltitude()

Gets altitude over the terrain.

getAspectRatio() → {number}

Returns aspect ratio.

Returns:

Aspect ratio.

Type: 
number

getBackward() → {Vec3}

Returns backward direction vector.

Returns:

Backward direction.

Type: 
Vec3

getCurrentFrustum() → {number}

Returns current active frustum index.

Returns:

Current frustum index.

Type: 
number

getDown() → {Vec3}

Returns down direction vector.

Returns:

Down direction.

Type: 
Vec3

getExtentPosition(extent, height) → {Vec3}

Gets position by viewable extent.

Parameters:
NameTypeDescription
extentExtent

Viewable extent.

heightNumber

Camera height

Returns:
Type: 
Vec3

getForward() → {Vec3}

Returns forward direction vector.

Returns:

Forward direction.

Type: 
Vec3

getHeading() → {number}

Returns heading angle in degrees. Should match getYaw() in most cases.

Returns:

Heading in [0, 360) degrees.

Type: 
number

getHeight() → {number}

Returns camera height.

Returns:
Type: 
number

getInverseProjectionMatrix() → {NumberArray16}

Returns inverse projection matrix.

Returns:

Inverse projection matrix.

Type: 
NumberArray16

getInverseProjectionViewMatrix() → {NumberArray16}

Returns inverse projection-view matrix.

Returns:

Inverse projection-view matrix.

Type: 
NumberArray16

getLeft() → {Vec3}

Returns left direction vector.

Returns:

Left direction.

Type: 
Vec3

getLonLat() → {LonLat}

Returns camera geographical position.

Returns:
Type: 
LonLat

getNormalMatrix() → {NumberArray9}

Returns normal matrix.

Returns:
  • Normal matrix.
Type: 
NumberArray9

getPitch() → {number}

Returns pitch angle in local planet frame.

Returns:

Pitch angle in radians.

Type: 
number

getProjectionMatrix() → {NumberArray16}

Returns projection matrix.

Returns:

Projection matrix.

Type: 
NumberArray16

getProjectionViewMatrix() → {NumberArray16}

Returns projection-view matrix.

Returns:

Projection-view matrix.

Type: 
NumberArray16

getProjectionViewRTEMatrix() → {NumberArray16}

Returns projection-view RTE matrix.

Returns:

Projection-view RTE matrix.

Type: 
NumberArray16

getRight() → {Vec3}

Returns right direction vector.

Returns:

Right direction.

Type: 
Vec3

getRoll() → {number}

Returns roll angle in local planet frame.

Returns:

Roll angle in radians.

Type: 
number

getRotation() → {Quat}

Returns camera rotation quaternion.

Returns:

Camera rotation quaternion.

Type: 
Quat

getSurfaceVisibleDistance(d) → {number}

Returns visible surface arc distance from current altitude.

Parameters:
NameTypeDescription
dnumber

Additional height offset.

Returns:

Visible surface distance.

Type: 
number

getUp() → {Vec3}

Returns up direction vector.

Overrides
Returns:

Up direction.

Type: 
Vec3

getViewAngle() → {number}

Returns camera vertical view angle in degrees.

Returns:

View angle in degrees.

Type: 
number

getViewMatrix() → {NumberArray16}

Returns model matrix.

Returns:
  • View matrix.
Type: 
NumberArray16

getYaw() → {number}

Returns yaw angle in local planet frame. Should match getHeading() in most cases.

Overrides
Returns:

Yaw angle in radians.

Type: 
number

isFlying() → {boolean}

Returns camera is flying.

Returns:
Type: 
boolean

isVisible(poi) → {boolean}

Checks whether a cartesian point is visible above the horizon.

Parameters:
NameTypeDescription
poiVec3

Point in cartesian coordinates.

Returns:

true when the point is visible.

Type: 
boolean

look(look, upopt)

Sets camera look point

Parameters:
NameTypeAttributesDescription
lookVec3

Look point

upVec3<optional>

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

Overrides

project(x, y, z) → {Vec2}

Gets projected 3d point to the 2d screen coordinates

Parameters:
NameTypeDescription
xnumber

X coordinate

ynumber

Y coordinate

znumber

Z coordinate

Returns:
  • Screen point coordinates
Type: 
Vec2

project3v(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. It is very important function used in Node.ts

Parameters:
NameTypeDescription
pVec3

Point in 3d.

rVec3

size.

Returns:
  • Size factor.
Type: 
number

refresh()

Refresh camera matrices

rotate(rot)

Rotates current camera basis by quaternion.

Parameters:
NameTypeDescription
rotQuat

Rotation quaternion.

Overrides

rotateAround(angle, isArcopt, centeropt, upopt)

Rotates camera around center point

Parameters:
NameTypeAttributesDefaultDescription
anglenumber

Rotation angle in radians

isArcboolean<optional>
false

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

rotateDown(angle)

Rotates around planet to the South Pole.

Parameters:
NameTypeDescription
anglenumber

Rotation angle.

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.

rotateLeft(angle, spinopt)

Rotates around planet to the left.

Parameters:
NameTypeAttributesDescription
anglenumber

Rotation angle.

spinboolean<optional>

If its true rotates around globe spin.

rotateRight(angle, spinopt)

Rotates around planet to the right.

Parameters:
NameTypeAttributesDescription
anglenumber

Rotation angle.

spinboolean<optional>

If its true rotates around globe spin.

rotateUp(angle)

Rotates around planet to the North Pole.

Parameters:
NameTypeDescription
anglenumber

Rotation angle.

rotateVertical(angle, center, minSlopeopt)

Rotates camera vertically around the given center.

Parameters:
NameTypeAttributesDefaultDescription
anglenumber

Rotation angle in radians.

centerVec3

Rotation center.

minSlopenumber<optional>
0

Minimum allowed slope limit.

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

Sets camera to eye position

Parameters:
NameTypeDescription
eyeVec3

Camera position

lookVec3

Look point

upVec3

Camera up vector

Overrides
Returns:
  • This camera
Type: 
Camera

setAltitude(alt)

Sets altitude over the terrain.

Parameters:
NameTypeDescription
altnumber

Altitude over the terrain.

setCurrentFrustum(k)

Sets current active frustum index.

Parameters:
NameTypeDescription
knumber

Frustum index.

setDepthZeroToOne(enabled)

Enables or disables ZERO_TO_ONE depth range mode.

Parameters:
NameTypeDescription
enabledboolean

Depth range mode flag.

setFrustums(frustums)

Replaces camera frustum ranges.

Parameters:
NameTypeDescription
frustumsArray.<NumberArray2>

Array of [near, far] ranges.

setLonLat(lonlat, lookLonLatopt, upopt)

Places camera to view to the geographical point.

Parameters:
NameTypeAttributesDescription
lonlatLonLat

New camera and camera view position.

lookLonLatLonLat<optional>

Look up coordinates.

upVec3<optional>

Camera UP vector. Default (0,1,0)

setNearFar(near, faropt, frustumIndexopt)

Updates near/far planes for one frustum.

Parameters:
NameTypeAttributesDefaultDescription
nearnumber

Near clipping plane distance.

farnumber<optional>

Far clipping plane distance.

frustumIndexnumber<optional>
0

Frustum index.

setPitch(a)

Sets pitch angle in local planet frame.

Parameters:
NameTypeDescription
anumber

Pitch angle in radians.

setPitchYawRoll(pitch, yaw, roll)

Sets orientation from pitch, yaw and roll in local planet frame.

Parameters:
NameTypeDescription
pitchnumber

Pitch angle in radians.

yawnumber

Yaw angle in radians.

rollnumber

Roll angle in radians.

setRoll(a)

Sets roll angle in local planet frame.

Parameters:
NameTypeDescription
anumber

Roll angle in radians.

setRotation(rot, upopt, rightopt, backopt)

Sets camera orientation from a quaternion.

Parameters:
NameTypeAttributesDescription
rotQuat

Rotation quaternion.

upVec3<optional>

Base up vector.

rightVec3<optional>

Base right vector.

backVec3<optional>

Base backward vector.

setTerrainCollisionActivity(isActive)

Enables or disables terrain collision checks.

Parameters:
NameTypeDescription
isActiveboolean

Terrain collision flag.

setViewAngle(angle)

Sets camera view angle in degrees

Parameters:
NameTypeDescription
anglenumber

View angle

setViewportSize(width, height)

Sets viewport size and updates projection.

Parameters:
NameTypeDescription
widthnumber

Viewport width in pixels.

heightnumber

Viewport height in pixels.

setYaw(a)

Sets yaw angle in local planet frame.

Parameters:
NameTypeDescription
anumber

Yaw angle in radians.

Overrides

slide(du, dv, dn)

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

Parameters:
NameTypeDescription
dunumber

delta X

dvnumber

delta Y

dnnumber

delta Z

Overrides

stopFlying()

Breaks the flight.

unproject(x, y, distopt, outPosopt) → {Vec3}

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

Parameters:
NameTypeAttributesDescription
xnumber

Screen X coordinate in pixels.

ynumber

Screen Y coordinate in pixels.

distnumber<optional>

Optional projection distance for orthographic mode.

outPosVec3<optional>

Optional output world position for orthographic mode.

Returns:
  • Direction vector.
Type: 
Vec3

unproject2v(pos, distopt, outPosopt) → {Vec3}

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

Parameters:
NameTypeAttributesDescription
posVec2

Screen coordinates in pixels.

distnumber<optional>

Optional projection distance for orthographic mode.

outPosVec3<optional>

Optional output world position for orthographic mode.

Returns:
  • Direction vector.
Type: 
Vec3

(abstract) update()

Updates camera view space.

Overrides

updateGeodeticPosition()

Updates camera geographic coordinates from current cartesian position.

viewDistance(cartesian, distanceopt)

Places camera at a fixed distance from a target point and looks at it.

Parameters:
NameTypeAttributesDefaultDescription
cartesianVec3

Target cartesian point.

distancenumber<optional>
10000.0

Distance from the target.

viewExtent(extent, heightopt)

View current extent.

Parameters:
NameTypeAttributesDescription
extentExtent

Current extent.

heightnumber<optional>