PlanetCamera

Extends: Camera

Source: PlanetCamera.ts:69

Planet camera.

Fires

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

Constructor

new PlanetCamera( planet: Planet, options?: IPlanetCameraParams, ): PlanetCamera

Parameters

  • planet (Planet) — Planet render node.
  • options (IPlanetCameraParams, optional) — Planet camera options:
    • options.name (string, optional) — Camera name.
    • options.viewAngle (number, optional) — Camera angle of view.
    • options.near (number, optional) — Camera near plane distance. Default is 1.0
    • options.far (number, optional) — Camera far plane distance. Default is og.math.MAX
    • options.minAltitude (number, optional) — Minimal altitude for the camera. Default is 5
    • options.maxAltitude (number, optional) — Maximal altitude for the camera. Default is 20000000
    • options.reverseDepth (boolean, optional, default: true) — Enables reverse-Z depth in perspective mode.
    • options.eye (Vec3, optional) — Camera eye position. Default (0,0,0)
    • options.look (Vec3, optional) — Camera look position. Default (0,0,0)
    • options.up (Vec3, optional) — Camera eye position. Default (0,1,0)

Instance Methods

setTerrainCollisionActivity(isActive: boolean)

Enables or disables terrain collision checks.

Parameters

  • isActive (boolean) — Terrain collision flag.

update()

Overrides: Camera#update

Updates camera view space.

updateCameraSlope()

Overrides: Camera#updateCameraSlope

Updates camera slope against the planet surface normal.

updateGeodeticPosition()

Updates camera geographic coordinates from current cartesian position.

setAltitude(alt: number)

Sets altitude over the terrain.

Parameters

  • alt (number) — Altitude over the terrain.

getAltitude()

Overrides: Camera#getAltitude

Gets altitude over the terrain.

setLonLat(lonlat: LonLat, lookLonLat?: LonLat, up?: Vec3)

Places camera to view to the geographical point.

Parameters

  • lonlat (LonLat) — New camera and camera view position.
  • lookLonLat (LonLat, optional) — Look up coordinates.
  • up (Vec3, optional) — Camera UP vector. Defaults to the local surface normal for an explicit look point.

getLonLat(): LonLat

Returns camera geographical position.

Returns

getHeight(): number

Returns camera height.

Returns

  • number

getExtentPosition(extent: Extent, height: Number): Vec3

Gets position by viewable extent.

Parameters

  • extent (Extent) — Viewable extent.
  • height (Number) — Camera height

Returns

viewExtent(extent: Extent, height?: number)

View current extent.

Parameters

  • extent (Extent) — Current extent.
  • height (number, optional)

_viewExtentHeight(extent: Extent, height: number)

Places the camera over the extent center at the given ground height.

Parameters

  • extent (Extent) — Extent to fit.
  • height (number) — Ground height under the extent center.

flyExtent( extent: Extent, height?: number, params?: IPlanetFlyCartesianParams, )

Flies to the current extent.

Parameters

  • extent (Extent) — Current extent.
  • height (number, optional) — Destination height.
  • params (IPlanetFlyCartesianParams, optional) — Flight parameters

viewDistance(cartesian: Vec3, distance?: number)

Overrides: Camera#viewDistance

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

Parameters

  • cartesian (Vec3) — Target cartesian point.
  • distance (number, optional, default: "10000.0") — Distance from the target.

flyLonLat(lonlat: LonLat, params?: IPlanetFlyCartesianParams)

Flies to the geo coordinates.

Parameters

  • lonlat (LonLat) — Finish coordinates.
  • params (IPlanetFlyCartesianParams, optional) — Flight parameters

flyDistance( cartesian: Vec3, distance?: number, params?: IPlanetFlyCartesianParams, )

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

Parameters

  • cartesian (Vec3) — Target cartesian point.
  • distance (number, optional, default: "10000.0") — Distance from the target.
  • params (IPlanetFlyCartesianParams, optional) — Flight parameters.

rotateLeft(angle: number, spin?: boolean)

Rotates around planet to the left.

Parameters

  • angle (number) — Rotation angle.
  • spin (boolean, optional) — If its true rotates around globe spin.

rotateRight(angle: number, spin?: boolean)

Rotates around planet to the right.

Parameters

  • angle (number) — Rotation angle.
  • spin (boolean, optional) — If its true rotates around globe spin.

rotateUp(angle: number)

Rotates around planet to the North Pole.

Parameters

  • angle (number) — Rotation angle.

rotateDown(angle: number)

Rotates around planet to the South Pole.

Parameters

  • angle (number) — Rotation angle.

rotateVertical(angle: number, center: Vec3, minSlope?: number)

Overrides: Camera#rotateVertical

Rotates camera vertically around the given center.

Parameters

  • angle (number) — Rotation angle in radians.
  • center (Vec3) — Rotation center.
  • minSlope (number, optional, default: 0) — Minimum allowed slope limit.

checkTerrainCollision(): Vec3 | undefined

Updates terrain altitude and keeps camera above minimum altitude.

Returns

  • Vec3 | undefined — Terrain point under camera when available.

getSurfaceVisibleDistance(d: number): number

Returns visible surface arc distance from current altitude.

Parameters

  • d (number) — Additional height offset.

Returns

  • number — Visible surface distance.

getRayIntersectionEllipsoid( x: number, y: number, ): Vec3 | undefined

Returns the ellipsoid intersection point for a screen-space ray. If the ray doesn't hit ellipsoid, it returns 'undefined'.

Parameters

  • x (number) — Screen X coordinate in pixels.
  • y (number) — Screen Y coordinate in pixels.

Returns

  • Vec3 | undefined — Cartesian intersection point.

getHeading(): number

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

Returns

  • number — Heading in [0, 360) degrees.

isVisible(poi: Vec3): boolean

Checks whether a cartesian point is visible above the horizon.

Parameters

  • poi (Vec3) — Point in cartesian coordinates.

Returns

  • boolean — true when the point is visible.

getPitch(): number

Overrides: Camera#getPitch

Returns pitch angle in local planet frame.

Returns

  • number — Pitch angle in radians.

getYaw(): number

Overrides: Camera#getYaw

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

Returns

  • number — Yaw angle in radians.

getRoll(): number

Overrides: Camera#getRoll

Returns roll angle in local planet frame.

Returns

  • number — Roll angle in radians.

setPitch(a: number)

Overrides: Camera#setPitch

Sets pitch angle in local planet frame.

Parameters

  • a (number) — Pitch angle in radians.

setYaw(a: number)

Overrides: Camera#setYaw

Sets yaw angle in local planet frame.

Parameters

  • a (number) — Yaw angle in radians.

setRoll(a: number)

Overrides: Camera#setRoll

Sets roll angle in local planet frame.

Parameters

  • a (number) — Roll angle in radians.

setPitchYawRoll(pitch: number, yaw: number, roll: number)

Overrides: Camera#setPitchYawRoll

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

Parameters

  • pitch (number) — Pitch angle in radians.
  • yaw (number) — Yaw angle in radians.
  • roll (number) — Roll angle in radians.

setDepthZeroToOne(enabled: boolean)

Inherited from Camera#setDepthZeroToOne

Overrides: Camera#setDepthZeroToOne

Enables or disables ZERO_TO_ONE depth range mode.

Parameters

  • enabled (boolean) — Depth range mode flag.

_setOrthoFocus(distance?: number)

protected
Camera.ts:452

Inherited from Camera#_setOrthoFocus

Overrides: Camera#_setOrthoFocus

Keeps the orthographic scale on whatever the camera has just been aimed at.

Parameters

  • distance (number, optional) — Distance from the eye to the point in view.

flyCartesian(cartesian?: Vec3, params?: IFlyCartesianParams)

Inherited from Camera#flyCartesian

Overrides: Camera#flyCartesian

Flies to the cartesian coordinates.

Parameters

  • cartesian (Vec3, optional) — Finish cartesian coordinates.
  • params (IFlyCartesianParams, optional) — Flight parameters

stopFlying()

Inherited from Camera#stopFlying

Overrides: Camera#stopFlying

Breaks the flight.

checkFly()

Inherited from Camera#checkFly

Overrides: Camera#checkFly

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

isFlying(): boolean

Inherited from Camera#isFlying

Overrides: Camera#isFlying

Returns camera is flying.

Returns

  • boolean

checkViewChanges()

Inherited from Camera#checkViewChanges

Overrides: Camera#checkViewChanges

Checks camera movement and projection changes.

checkMoveEnd(): boolean

Inherited from Camera#checkMoveEnd

Overrides: Camera#checkMoveEnd

Checks whether the camera stopped moving and dispatches moveend.

Returns

  • boolean — true when the camera is moving after the check.

_checkViewChange()

protected
Camera.ts:636

Inherited from Camera#_checkViewChange

Overrides: Camera#_checkViewChange

Checks whether the camera view or projection changed and dispatches viewchange.

bindFrustumsPickingColors(renderer: Renderer)

Inherited from Camera#bindFrustumsPickingColors

Overrides: Camera#bindFrustumsPickingColors

Binds picking colors for all frustums.

Parameters

  • renderer (Renderer) — Renderer instance.

_init(options?: Object)

Inherited from Camera#_init

Overrides: Camera#_init

Camera initialization.

Parameters

  • options (Object, optional) — Camera options:
    • options.viewAngle (number, optional) — Camera angle of view.
    • options.near (number, optional) — Camera near plane distance. Default is 1.0
    • options.far (number, optional) — Camera far plane distance. Default is math.MAX
    • options.eye (Vec3, optional) — Camera eye position. Default (0,0,0)
    • options.look (Vec3, optional) — Camera look position. Default (0,0,0)
    • options.up (Vec3, optional) — Camera eye position. Default (0,1,0)

getUp(): Vec3

Inherited from Camera#getUp

Overrides: Camera#getUp

Returns up direction vector.

Returns

  • Vec3 — Up direction.

getDown(): Vec3

Inherited from Camera#getDown

Overrides: Camera#getDown

Returns down direction vector.

Returns

  • Vec3 — Down direction.

getRight(): Vec3

Inherited from Camera#getRight

Overrides: Camera#getRight

Returns right direction vector.

Returns

  • Vec3 — Right direction.

getLeft(): Vec3

Inherited from Camera#getLeft

Overrides: Camera#getLeft

Returns left direction vector.

Returns

  • Vec3 — Left direction.

getForward(): Vec3

Inherited from Camera#getForward

Overrides: Camera#getForward

Returns forward direction vector.

Returns

  • Vec3 — Forward direction.

getBackward(): Vec3

Inherited from Camera#getBackward

Overrides: Camera#getBackward

Returns backward direction vector.

Returns

  • Vec3 — Backward direction.

refresh()

Inherited from Camera#refresh

Overrides: Camera#refresh

Refresh camera matrices

setViewportSize(width: number, height: number)

Inherited from Camera#setViewportSize

Overrides: Camera#setViewportSize

Sets viewport size and updates projection.

Parameters

  • width (number) — Viewport width in pixels.
  • height (number) — Viewport height in pixels.

getAspectRatio(): number

Inherited from Camera#getAspectRatio

Overrides: Camera#getAspectRatio

Returns aspect ratio.

Returns

  • number — Aspect ratio.

_setProj(viewAngle: number, aspect: number)

Inherited from Camera#_setProj

Overrides: Camera#_setProj

Sets camera projection.

Parameters

  • viewAngle (number) — Camera view angle.
  • aspect (number) — Screen aspect ratio.

setNearFar(near: number, far?: number, frustumIndex?: number)

Inherited from Camera#setNearFar

Overrides: Camera#setNearFar

Updates near/far planes for one frustum.

Parameters

  • near (number) — Near clipping plane distance.
  • far (number, optional) — Far clipping plane distance.
  • frustumIndex (number, optional, default: 0) — Frustum index.

setFrustums(frustums: Array.<NumberArray2>)

Inherited from Camera#setFrustums

Overrides: Camera#setFrustums

Replaces camera frustum ranges.

Parameters

  • frustums (Array.<NumberArray2>) — Array of [near, far] ranges.

setViewAngle(angle: number)

Inherited from Camera#setViewAngle

Overrides: Camera#setViewAngle

Sets camera view angle in degrees

Parameters

  • angle (number) — View angle

setHorizontalViewAngle(angle: number)

Inherited from Camera#setHorizontalViewAngle

Overrides: Camera#setHorizontalViewAngle

Sets camera horizontal view angle in degrees.

Parameters

  • angle (number) — Horizontal view angle.

getViewAngle(): number

Inherited from Camera#getViewAngle

Overrides: Camera#getViewAngle

Returns camera vertical view angle in degrees.

Returns

  • number — View angle in degrees.

set(eye: Vec3, look: Vec3, up: Vec3): Camera

Inherited from Camera#set

Overrides: Camera#set

Sets camera to eye position

Parameters

  • eye (Vec3) — Camera position
  • look (Vec3) — Look point
  • up (Vec3) — Camera up vector

Returns

look(look: Vec3, up?: Vec3)

Inherited from Camera#look

Overrides: Camera#look

Sets camera look point

Parameters

  • look (Vec3) — Look point
  • up (Vec3, optional) — Camera up vector otherwise camera current up vector(this._u)

slide(du: number, dv: number, dn: number)

Inherited from Camera#slide

Overrides: Camera#slide

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

Parameters

  • du (number) — delta X
  • dv (number) — delta Y
  • dn (number) — delta Z

getAbsolutePitch(): number

Inherited from Camera#getAbsolutePitch

Overrides: Camera#getAbsolutePitch

Returns absolute pitch angle.

Returns

  • number — Absolute pitch angle in radians.

getAbsoluteYaw(): number

Inherited from Camera#getAbsoluteYaw

Overrides: Camera#getAbsoluteYaw

Returns absolute yaw angle.

Returns

  • number — Absolute yaw angle in radians.

getAbsoluteRoll(): number

Inherited from Camera#getAbsoluteRoll

Overrides: Camera#getAbsoluteRoll

Returns absolute roll angle.

Returns

  • number — Absolute roll angle in radians.

getRotation(): Quat

Inherited from Camera#getRotation

Overrides: Camera#getRotation

Returns camera rotation quaternion.

Returns

  • Quat — Camera rotation quaternion.

setRotation(rot: Quat, up?: Vec3, right?: Vec3, back?: Vec3)

Inherited from Camera#setRotation

Overrides: Camera#setRotation

Sets camera orientation from a quaternion.

Parameters

  • rot (Quat) — Rotation quaternion.
  • up (Vec3, optional) — Base up vector.
  • right (Vec3, optional) — Base right vector.
  • back (Vec3, optional) — Base backward vector.

rotate(rot: Quat)

Inherited from Camera#rotate

Overrides: Camera#rotate

Rotates current camera basis by quaternion.

Parameters

  • rot (Quat) — Rotation quaternion.

unproject2v(pos: Vec2, dist?: number, outPos?: Vec3): Vec3

Inherited from Camera#unproject2v

Overrides: Camera#unproject2v

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

Parameters

  • pos (Vec2) — Screen coordinates in pixels.
  • dist (number, optional) — Optional projection distance for orthographic mode.
  • outPos (Vec3, optional) — Optional output world position for orthographic mode.

Returns

unproject( x: number, y: number, dist?: number, outPos?: Vec3, ): Vec3

Inherited from Camera#unproject

Overrides: Camera#unproject

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

Parameters

  • x (number) — Screen X coordinate in pixels.
  • y (number) — Screen Y coordinate in pixels.
  • dist (number, optional) — Optional projection distance for orthographic mode.
  • outPos (Vec3, optional) — Optional output world position for orthographic mode.

Returns

getRay(x: number, y: number): Ray

Inherited from Camera#getRay

Overrides: Camera#getRay

Returns a world-space ray corresponding to the given screen point. For perspective camera the ray shares camera eye as origin. For orthographic camera the origin is offset across the view plane, and the direction equals the camera forward vector.

Parameters

  • x (number) — Screen X coordinate in pixels.
  • y (number) — Screen Y coordinate in pixels.

Returns

getRay2v(pos: Vec2): Ray

Inherited from Camera#getRay2v

Overrides: Camera#getRay2v

Returns a world-space ray corresponding to the given screen point.

Parameters

  • pos (Vec2) — Screen coordinates in pixels.

Returns

project3v(v: Vec3): Vec2

Inherited from Camera#project3v

Overrides: Camera#project3v

Gets projected 3d point to the 2d screen coordinates

Parameters

  • v (Vec3) — Cartesian 3d coordinates

Returns

project(x: number, y: number, z: number): Vec2

Inherited from Camera#project

Overrides: Camera#project

Gets projected 3d point to the 2d screen coordinates

Parameters

  • x (number) — X coordinate
  • y (number) — Y coordinate
  • z (number) — Z coordinate

Returns

rotateAround( angle: number, isArc?: boolean, center?: Vec3, up?: Vec3, )

Inherited from Camera#rotateAround

Overrides: Camera#rotateAround

Rotates camera around center point

Parameters

  • angle (number) — Rotation angle in radians
  • isArc (boolean, optional, default: false) — If true camera up vector gets from current up vector every frame, otherwise up is always input parameter.
  • center (Vec3, optional) — Point that the camera rotates around
  • up (Vec3, optional) — Camera up vector

rotateHorizontal( angle: number, isArc?: boolean, center?: Vec3, up?: Vec3, )

Inherited from Camera#rotateHorizontal

Overrides: Camera#rotateHorizontal

Rotates camera around the center point by horizontal.

Parameters

  • angle (number) — Rotation angle in radians.
  • isArc (boolean, optional) — If true camera up vector gets from current up vector every frame, otherwise up is always input parameter.
  • center (Vec3, optional) — Point that the camera rotates around.
  • up (Vec3, optional) — Camera up vector.

projectedSize(p: Vec3, r: Vec3): number

Inherited from Camera#projectedSize

Overrides: Camera#projectedSize

Gets 3d size factor. Uses in LOD distance calculation. It is a very important function used in Node.ts

Parameters

  • p (Vec3) — Point in 3d.
  • r (Vec3) — size.

Returns

  • number

getViewMatrix(): NumberArray16

Inherited from Camera#getViewMatrix

Overrides: Camera#getViewMatrix

Returns model matrix.

Returns

  • NumberArray16

getNormalMatrix(): NumberArray9

Inherited from Camera#getNormalMatrix

Overrides: Camera#getNormalMatrix

Returns camera normal matrix.

Returns

  • NumberArray9

setCurrentFrustum(k: number)

Inherited from Camera#setCurrentFrustum

Overrides: Camera#setCurrentFrustum

Sets current active frustum index.

Parameters

  • k (number) — Frustum index.

getCurrentFrustum(): number

Inherited from Camera#getCurrentFrustum

Overrides: Camera#getCurrentFrustum

Returns current active frustum index.

Returns

  • number — Current frustum index.

containsSphere(sphere: Sphere): boolean

Inherited from Camera#containsSphere

Overrides: Camera#containsSphere

Checks whether the sphere intersects any camera frustum.

Parameters

  • sphere (Sphere) — Bounding sphere.

Returns

  • boolean — true when visible in at least one frustum.

containsPoint(point: Vec3): boolean

Inherited from Camera#containsPoint

Overrides: Camera#containsPoint

Checks whether a point is inside any camera frustum.

Parameters

  • point (Vec3) — Cartesian point.

Returns

  • boolean — true when visible in at least one frustum.

getProjectionMatrix(): NumberArray16

Inherited from Camera#getProjectionMatrix

Overrides: Camera#getProjectionMatrix

Returns projection matrix.

Returns

  • NumberArray16 — Projection matrix.

getProjectionViewMatrix(): NumberArray16

Inherited from Camera#getProjectionViewMatrix

Overrides: Camera#getProjectionViewMatrix

Returns projection-view matrix.

Returns

  • NumberArray16 — Projection-view matrix.

getProjectionViewRTEMatrix(): NumberArray16

Inherited from Camera#getProjectionViewRTEMatrix

Overrides: Camera#getProjectionViewRTEMatrix

Returns projection-view RTE matrix.

Returns

  • NumberArray16 — Projection-view RTE matrix.

getInverseProjectionViewMatrix(): NumberArray16

Inherited from Camera#getInverseProjectionViewMatrix

Overrides: Camera#getInverseProjectionViewMatrix

Returns inverse projection-view matrix.

Returns

  • NumberArray16 — Inverse projection-view matrix.

getInverseProjectionMatrix(): NumberArray16

Inherited from Camera#getInverseProjectionMatrix

Overrides: Camera#getInverseProjectionMatrix

Returns inverse projection matrix.

Returns

  • NumberArray16 — Inverse projection matrix.

copy(cam: Camera)

Inherited from Camera#copy

Overrides: Camera#copy

Copies camera pose and projection settings from another camera.

Parameters

  • cam (Camera) — Source camera.

Instance Fields

isOrthographic

Inherited from Camera#isOrthographic

Overrides: Camera#isOrthographic

Returns current projection mode.

Returns

  • boolean — true when orthographic projection is enabled.

reverseDepth

Inherited from Camera#reverseDepth

Overrides: Camera#reverseDepth

Returns reverse depth flag.

Returns

  • boolean — true when reverse depth mode is enabled.

reverseDepthActive

Inherited from Camera#reverseDepthActive

Overrides: Camera#reverseDepthActive

Returns active reverse depth state.

Returns

  • boolean — true for perspective reverse-Z mode.

depthZeroToOne

Inherited from Camera#depthZeroToOne

Overrides: Camera#depthZeroToOne

Returns active depth range mode.

Returns

  • boolean — true when ZERO_TO_ONE depth range is active.

focusDistance

Inherited from Camera#focusDistance

Overrides: Camera#focusDistance

Returns focus distance used for orthographic projection size.

Returns

  • number — Focus distance.

id

Inherited from Camera#id

Overrides: Camera#id

Returns camera identifier.

Returns

  • number — Camera id.

width

Inherited from Camera#width

Overrides: Camera#width

Returns viewport width.

Returns

  • number — Viewport width in pixels.

height

Inherited from Camera#height

Overrides: Camera#height

Returns viewport height.

Returns

  • number — Viewport height in pixels.

viewAngle

Inherited from Camera#viewAngle

Overrides: Camera#viewAngle

Returns camera vertical view angle in degrees.

Returns

  • number — Vertical view angle.

verticalViewAngle

Inherited from Camera#verticalViewAngle

Overrides: Camera#verticalViewAngle

Returns camera vertical view angle in degrees.

Returns

  • number — Vertical view angle.

horizontalViewAngle

Inherited from Camera#horizontalViewAngle

Overrides: Camera#horizontalViewAngle

Returns camera horizontal view angle in degrees.

Returns

  • number — Horizontal view angle.

frustum

Inherited from Camera#frustum

Overrides: Camera#frustum

Returns current active frustum.

Returns

  • Frustum — Active frustum instance.