Planet

Main class for rendering a planet.

Constructor

new Planet(optionsopt)

Parameters:
NameTypeAttributesDefaultDescription
optionsIPlanetParams<optional>
{}

Planet configuration parameters.

Properties
NameTypeAttributesDefaultDescription
namestring<optional>

Planet name.

ellipsoidEllipsoid<optional>
wgs84

Planet ellipsoid.

minAltitudenumber<optional>

Minimum camera altitude above terrain.

maxAltitudenumber<optional>

Maximum camera altitude above terrain.

frustumsArray.<Array.<number>><optional>

Planet camera frustum configuration.

maxGridSizenumber<optional>
256

Maximum terrain segment grid size.

maxLoadingRequestsnumber<optional>
12

Maximum concurrent tile loading requests.

maxNodesCountnumber<optional>
400

Maximum number of created quadtree nodes.

maxEqualZoomAltitudenumber<optional>
15000000.0

Max altitude where visible segments keep the same zoom.

minEqualZoomAltitudenumber<optional>
10000.0

Min altitude where visible segments keep the same zoom.

minEqualZoomCameraSlopenumber<optional>
0.8

Min camera slope for equal-zoom segment strategy.

quadTreeStrategyPrototypefunction<optional>
EarthQuadTreeStrategy

Quadtree strategy class.

nightTextureSrcstring | null<optional>

Night lights texture URL (null disables texture loading).

specularTextureSrcstring | null<optional>

Water/specular mask texture URL (null disables texture loading).

atmosphereEnabledboolean<optional>
false

Enables atmosphere rendering.

transitionOpacityEnabledboolean<optional>

Enables terrain transition opacity blending.

atmosphereParametersIAtmosphereParams<optional>

Atmosphere model parameters.

minDistanceBeforeMemClearnumber<optional>

Camera travel distance threshold before automatic memory cleanup.

vectorTileSizenumber<optional>

Vector tile texture size for vector layer baking.

transparentBackgroundboolean<optional>
false

Enables transparent renderer background.

nearPlaneStrategyINearPlaneStrategy<optional>

Near-plane strategy implementation.

shadeModenumber | string<optional>
0.5

Terrain shading mode: 0|none|unlit, 0.5|phong, 1|pbr.

reverseDepthboolean<optional>
true

Enables reverse-Z depth for the default planet camera in perspective mode.

Fires:
  • event:draw - Triggered before globe frame begins to render.
  • event:layeradd - Triggered when a layer is added to the planet.
  • event:baselayerchange - Triggered when the base layer changes.
  • event:layerremove - Triggered when a layer is removed from the planet.
  • event:layervisibilitychange - Triggered when layer visibility changes.
  • event:rendercompleted - Triggered when all data is loaded.
  • event:terraincompleted - Triggered when terrain data is loaded.
  • event:layerloadend - Triggered when layer data finishes loading.

Extends

Members

atmosphereControl

Returns atmosphere control instance bound to the planet.

atmosphereEnabled

Enables or disables atmosphere rendering and related programs.

atmosphereEnabled

Returns atmosphere activity flag.

atmosphereMaxMinOpacity

Gets atmosphere opacity range [max, min].

atmosphereMaxOpacity

Sets maximum atmosphere opacity.

atmosphereMaxOpacity

Gets maximum atmosphere opacity.

atmosphereMinOpacity

Sets minimum atmosphere opacity.

atmosphereMinOpacity

Gets minimum atmosphere opacity.

layers

Returns current layers snapshot.

maxGridSize

Returns max segment grid size used by the quadtree.

normalMapCreator

Returns normal-map generator used by the planet.

shadeMode

Returns active terrain shade mode.

shadeMode

Sets terrain shade mode.

sun

Returns Sun control instance if attached to the renderer.

sunPos

Returns current sun world position.

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.

Overrides

_clearLayerMaterial(layer)

Clears material resources related to a layer in quadtree segments.

Parameters:
NameTypeDescription
layerLayer

Material layer.

_onLayerVisibilityChanged(layer)

Dispatch layer visibility changing event.

Parameters:
NameTypeDescription
layerLayer

Changed layer.

_renderingOpaqueScreenNodes()

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) → {Scene}

Adds entity collection.

Parameters:
NameTypeAttributesDescription
entityCollectionEntityCollection

Entity collection.

isHiddenboolean<optional>

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

Returns:
Type: 
Scene

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.

addNode()

Adds node to the current hierarchy.

Overrides

assign(renderer)

Assign render node with renderer.

Parameters:
NameTypeDescription
rendererRenderer

Render node's renderer.

Overrides

createDefaultTextures(param0, param1)

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

Parameters:
NameTypeDescription
param0IDefaultTextureParams

Default texture params for the first texture.

param1IDefaultTextureParams

Default texture params for the second texture.

destroy()

Destroy planet.

Overrides

draw()

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

Overrides

drawPickingEntityCollections(ec)

Draw entity collections picking frame.

Parameters:
NameTypeDescription
ecArray.<EntityCollection>

Entity collection array.

flyCartesian(cartesian, params)

Fly camera to the point.

Parameters:
NameTypeDescription
cartesianVec3

Fly cartesian coordinates.

paramsIPlanetFlyCartesianParams

Flight parameters.

flyExtent(extent, heightopt, params)

Fly active camera to the view extent.

Parameters:
NameTypeAttributesDescription
extentExtent

Geographical extent.

heightNumber<optional>

Height on the end of the flight route.

paramsIPlanetFlyCartesianParams

Flight parameters.

flyLonLat(lonlat, params)

Fly camera to the geodetic position.

Parameters:
NameTypeDescription
lonlatLonLat

Fly geographical coordinates.

paramsIPlanetFlyCartesianParams

Flight parameters.

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 | IBaseInputState

Pixel screen 2d coordinates.

Returns:
Type: 
Vec3 | undefined

getDistanceFromPixel(px) → {number}

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

Parameters:
NameTypeDescription
pxVec2 | IBaseInputState

Screen coordinates.

Returns:
Type: 
number

getDistanceFromPixelEllipsoid(px) → {number|undefined}

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

Parameters:
NameTypeDescription
pxVec2 | IBaseInputState

Screen coordinates.

Returns:
Type: 
number | undefined

getEntityTerrainPoint(entity, res) → {Vec3|undefined}

Finds terrain point under an entity in currently rendered segments.

Parameters:
NameTypeDescription
entityEntity

Entity to test.

resVec3

Output vector for terrain point.

Returns:
  • Terrain point if found.
Type: 
Vec3 | undefined

getExtent() → {Extent}

Gets current camera view extent.

Returns:
Type: 
Extent

getFrameRotation(cartesian) → {Quat}

Returns local frame rotation for a cartesian point.

Parameters:
NameTypeDescription
cartesianVec3

Cartesian point.

Returns:
  • Rotation from world frame to local frame.
Type: 
Quat

(async) getHeightAboveELL(lonLat) → {Promise.<number>}

Returns terrain height above ellipsoid at the given coordinates.

Parameters:
NameTypeDescription
lonLatLonLat

Geodetic coordinates.

Returns:
  • Height above ellipsoid.
Type: 
Promise.<number>

(async) getHeightDefault(lonLat) → {Promise.<number>}

Returns terrain height at the given coordinates in default terrain datum.

Parameters:
NameTypeDescription
lonLatLonLat

Geodetic coordinates.

Returns:
  • Height value.
Type: 
Promise.<number>

getHeightFactor() → {number}

Gets elevation scale.

Returns:

Terrain elevation scale

Type: 
number

getLayerByName(name) → {Layer|undefined}

Returns a layer by name.

Parameters:
NameTypeDescription
namestring

Layer name.

Returns:
Type: 
Layer | undefined

getLonLatFromPixelEllipsoid(px) → {LonLat|undefined}

Project screen coordinates to the planet ellipsoid.

Parameters:
NameTypeDescription
pxVec2

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

getNorthFrameRotation(cartesian) → {Quat}

Returns local north frame rotation for a cartesian point.

Parameters:
NameTypeDescription
cartesianVec3

Cartesian point.

Returns:
  • Rotation from world frame to local north frame.
Type: 
Quat

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}

Returns currently cached quadtree view extent.

Returns:
  • Cached view extent.
Type: 
Extent

init()

Initializes render resources, workers, shaders, and layer state.

initAtmosphereShader(atmosParamsopt)

Reinitializes terrain forward/deferred shaders for atmosphere mode.

Parameters:
NameTypeAttributesDescription
atmosParamsAtmosphereParameters<optional>

Optional atmosphere shader parameters.

initLayers()

Reattaches already registered layers to apply initialization logic.

isActive() → {Boolean}

Gets render node activity.

Returns:
Type: 
Boolean

lockQuadTree()

Pauses quadtree render-node collection and disables camera terrain collision checks.

memClear()

Starts clear memory thread.

onremove()

Handles node detachment and frees runtime terrain data.

preDraw()

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

Overrides

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.

renderDepthFramebuffer(cam, quadTreeStrategy)

Renders terrain depth and frustum id into the depth framebuffer.

Parameters:
NameTypeDescription
camPlanetCamera

Camera used for rendering.

quadTreeStrategyQuadTreeStrategy

Quadtree strategy with rendered node lists.

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.

setLodSize(currentLodSize, minLodSizeopt, maxLodSizeopt)

Sets LOD thresholds for quadtree terrain rendering. Proxy to QuadTreeStrategy.setLodSize.

Parameters:
NameTypeAttributesDescription
currentLodSizenumber

Current LOD size target.

minLodSizenumber<optional>

Minimum LOD size.

maxLodSizenumber<optional>

Maximum LOD size.

setTerrain(terrain)

Sets terrain provider

Parameters:
NameTypeDescription
terrainEmptyTerrain

Terrain provider.

stopFlying()

Stop current flight.

unlockQuadTree()

Resumes quadtree render-node collection and enables camera terrain collision checks.

updateAttributionsList()

Updates attribution lists

updateBillboardsTexCoords()

Refreshes billboard texture coordinates for all visible entity collections.

updateVisibleLayers()

Schedules visible layers list refresh for the next frame.

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.