Planet

Main class for rendering planet

Constructor

new Planet()

Parameters:
NameTypeAttributesDefaultDescription
options.namestring<optional>
"Earth"

Planet name(Earth by default)

options.ellipsoidEllipsoid<optional>

Planet ellipsoid(WGS84 by default)

options.maxGridSizeNumber<optional>
128

Segment maximal grid size

options.maxEqualZoomAltitudeNumber<optional>
15000000.0

Maximal altitude since segments on the screen become the same zoom level

options.minEqualZoomAltitudeNumber<optional>
10000.0

Minimal altitude since segments on the screen become the same zoom level

options.minEqualZoomCameraSlopeNumber<optional>
0.8

Minimal camera slope above te globe where segments on the screen become the same zoom level

Fires:
  • EventsHandler#event:draw
  • EventsHandler#event:layeradd
  • EventsHandler#event:baselayerchange
  • EventsHandler#event:layerremove
  • EventsHandler#event:layervisibilitychange
  • EventsHandler#event:geoimageadd

Extends

Members

terrainReady

Returns true if current terrain data set is loaded

Methods

(protected) _applyAttribution()

Apply to render list of layer attributions

(protected) _clear()

Clear current node.

_clearLayerMaterial(layer)

Parameters:
NameTypeDescription
layerLayer

Material layer.

(protected) _collectRenderNodes()

Collects visible quad nodes.

_onLayerVisibilityChanged(layer)

Dispatch layer visibility changing event.

Parameters:
NameTypeDescription
layerLayer

Changed layer.

_renderingScreenNodes()

Drawing nodes

(protected) _sortLayers()

Sort visible layer - preparing for rendering.

addControl(control)

Add the given control to the renderer of the planet scene.

Parameters:
NameTypeDescription
controlControl

Control.

addControls(cArr)

Add the given controls array to the renderer of the planet.

Parameters:
NameTypeDescription
cArrArray.<Control>

Control array.

addEntityCollection(entityCollection, isHiddenopt) → {RenderNode}

Adds entity collection.

Parameters:
NameTypeAttributesDescription
entityCollectionEntityCollection

Entity collection.

isHiddenboolean<optional>

If it's true that this collection has specific rendering.

Returns:
Type: 
RenderNode

addLayer(layer)

Adds layer to the planet.

Parameters:
NameTypeDescription
layerLayer

Layer object.

addLayers(layers)

Adds the given layers array to the planet.

Parameters:
NameTypeDescription
layersArray.<Layer>

Layers array.

addLight(light) → {RenderNode}

Adds point light source.

Parameters:
NameTypeDescription
lightLightSource

Light source.

Returns:
Type: 
RenderNode

addNode()

Adds node to the current hierarchy.

assign(renderer)

Assign render node with renderer.

Parameters:
NameTypeDescription
rendererRenderer

Render node's renderer.

createDefaultTextures()

Creates default textures first for the North Pole and whole globe and second for the South Pole.

destroy()

Destroy node.

drawNode()

Calls render frame node's callback. Used in renderer.

drawPickingEntityCollections(ec)

Draw entity collections picking frame.

Parameters:
NameTypeDescription
ecArray.<EntityCollection>

Entity collection array.

flyCartesian(cartesian, lookopt, upopt, amplopt, completeCallbackopt, startCallbackopt, frameCallbackopt)

Fly camera to the point.

Parameters:
NameTypeAttributesDescription
cartesianVec3

Point coordinates.

lookVec3<optional>

Camera "look at" point.

upVec3<optional>

Camera UP vector on the end of a flying.

amplNumber<optional>

Altitude amplitude factor.

completeCallbackfunction<optional>

Call the function in the end of flight

startCallbackfunction<optional>

Call the function in the beginning

frameCallbackfunction<optional>

Each frame callback

flyExtent(extent, heightopt, upopt, amplopt, startCallbackopt, completeCallbackopt)

Fly active camera to the view extent.

Parameters:
NameTypeAttributesDescription
extentExtent

Geographical extent.

heightNumber<optional>

Height on the end of the flight route.

upVec3<optional>

Camera UP vector on the end of a flying.

amplNumber<optional>

Altitude amplitude factor.

startCallbackfunction<optional>

Callback that calls before the flying begins.

completeCallbackfunction<optional>

Callback that calls after flying when flying is finished.

flyLonLat(lonlat, lookopt, upopt, amplopt, completeCallbackopt, startCallbackopt, frameCallbackopt)

Fly camera to the geodetic position.

Parameters:
NameTypeAttributesDescription
lonlatLonLat

Fly geographical coordinates.

lookVec3 | LonLat<optional>

Camera viewpoint in the end of the flight.

upVec3<optional>

Camera UP vector on the end of a flying.

amplNumber<optional>

Altitude amplitude factor.

completeCallback<optional>
startCallback<optional>
frameCallback<optional>

frame()

Render node callback. Frame function is called for each renderer activrCamera frustum.

getCartesianFromMouseTerrain() → {Vec3|undefined}

Returns mouse position cartesian coordinates on the current terrain.

Returns:
Type: 
Vec3 | undefined

getCartesianFromPixelEllipsoid(px) → {Vec3|undefined}

Project screen coordinates to the planet ellipsoid.

Parameters:
NameTypeDescription
pxVec2 | IBaseInputState

Screen coordinates.

Returns:
  • Cartesian coordinates.
Type: 
Vec3 | undefined

getCartesianFromPixelTerrain(px) → {Vec3|undefined}

Returns screen coordinates cartesian coordinates on the current terrain. position or null if input coordinates is outside the planet.

Parameters:
NameTypeDescription
pxVec2

Pixel screen 2d coordinates.

Returns:
Type: 
Vec3 | undefined

getDistanceFromPixel(px) → {number|undefined}

Returns distance from active (screen) camera to the planet terrain by screen coordinates.

Parameters:
NameTypeDescription
pxVec2 | IBaseInputState

Screen coordinates.

Returns:
Type: 
number | undefined

getDistanceFromPixelEllipsoid(px) → {number}

Returns distance from an active (screen) camera to the planet ellipsoid.

Parameters:
NameTypeDescription
pxVec2

Screen coordinates.

Returns:
Type: 
number

getHeightFactor() → {number}

Gets elevation scale.

Returns:

Terrain elevation scale

Type: 
number

getLayerByName(name) → {Layer}

Return layer by it name

Parameters:
NameTypeDescription
namestring

Name of the layer. og.Layer.prototype.name

Returns:
Type: 
Layer

getLayers() → {Array.<Layer>}

Returns:

Layers array.

Type: 
Array.<Layer>

getLightByName(name) → {LightSource}

Gets light object by its name.

Parameters:
NameTypeDescription
namestring

Point light name.

Returns:
Type: 
LightSource

getLonLatFromPixelEllipsoid(px) → {LonLat|undefined}

Project screen coordinates to the planet ellipsoid.

Parameters:
NameTypeDescription
pxVec2 | IBaseInputState

Screen coordinates.

Returns:
  • Geodetic coordinates.
Type: 
LonLat | undefined

getLonLatFromPixelTerrain(px) → {LonLat|undefined}

Returns geodetic coordinates on the current terrain planet by its screen coordinates. position or null if input coordinates is outside the planet.

Parameters:
NameTypeDescription
pxVec2 | IBaseInputState

Pixel screen 2d coordinates.

Returns:
Type: 
LonLat | undefined

getNodeByName(name) → {RenderNode}

Gets node by name in the current.

Parameters:
NameTypeDescription
namestring

Node name.

Returns:

Node object in the current node.

Type: 
RenderNode

getPixelFromCartesian(coords) → {Vec2}

Project cartesian coordinates to screen space.

Parameters:
NameTypeDescription
coordsVec3

Cartesian coordinates.

Returns:
  • Screen coordinates.
Type: 
Vec2

getPixelFromLonLat(lonlat) → {Vec2|undefined}

Project geodetic coordinates to screen space.

Parameters:
NameTypeDescription
lonlatLonLat

Geodetic coordinates.

Returns:
  • Screen coordinates.
Type: 
Vec2 | undefined

getRayIntersectionEllipsoid(ray) → {Vec3|undefined}

Returns ray vector hit ellipsoid coordinates. If the ray doesn't hit ellipsoid it returns 'undefined'.

Parameters:
NameTypeDescription
rayRay

Ray.

Returns:
Type: 
Vec3 | undefined

getViewExtent() → {Extent}

Gets current camera view extent.

Returns:
Type: 
Extent

isActive() → {Boolean}

Gets render node activity.

Returns:
Type: 
Boolean

memClear()

Starts clear memory thread.

preDrawNode()

Calls render frame node's callback. Used in renderer.

preFrame()

Render node callback.

removeEntityCollection(entityCollection)

Removes entity collection.

Parameters:
NameTypeDescription
entityCollectionEntityCollection

Entity collection for remove.

removeLayer(layer)

Removes the given layer from the planet.

Parameters:
NameTypeDescription
layerLayer

Layer to remove.

removeLight(light)

Removes light source.

Parameters:
NameTypeDescription
lightLightSource

Light source object.

setActive(isActive)

Rendering activation.

Parameters:
NameTypeDescription
isActiveboolean

Activation flag.

setBaseLayer(layer)

Sets base layer coverage to the planet.

Parameters:
NameTypeDescription
layerLayer

Layer object.

setDrawMode(mode)

Sets draw mode

Parameters:
NameTypeDescription
modeNumber

Draw mode, such as gl.TRIANGLES, gl.TRIANGLE_STRIP, gl.LINES etc.

setHeightFactor(factor)

Sets elevation scale. 1.0 is default.

Parameters:
NameTypeDescription
factornumber

Elevation scale.

setTerrain(terrain)

Sets terrain provider

Parameters:
NameTypeDescription
terrainEmptyTerrain

Terrain provider.

stopFlying()

Stop current flight.

transformLights()

IMPORTANT: This function have to be called manually in each render node frame callback, before drawing scene geometry.

updateAttributionsList()

Updates attribution lists

viewExtent(extent)

Sets camera to the planet geographical extent.

Parameters:
NameTypeDescription
extentExtent

Geographical extent.

viewExtentArr(extentArr)

Fits camera position for the view extent.

Parameters:
NameTypeDescription
extentArrArray.<number>

Geographical extent array, (exactly 4 entries) where index 0 - southwest longitude, 1 - latitude southwest, 2 - longitude northeast, 3 - latitude northeast.

viewLonLat(lonlat, lookLonLatopt, upopt)

Sets camera to the planet geographical position.

Parameters:
NameTypeAttributesDescription
lonlatLonLat

Camera position.

lookLonLatLonLat<optional>

Viewpoint.

upVec3<optional>

Camera up vector.