Planet

Extends: Scene

Source: Planet.ts:167

Main class for rendering a planet.

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.

Constructor

new Planet(options?: IPlanetParams): Planet

Parameters

  • options (IPlanetParams, optional, default: "{}") — Planet configuration parameters.
    • options.name (string, optional) — Planet name.
    • options.ellipsoid (Ellipsoid, optional, default: "wgs84") — Planet ellipsoid.
    • options.minAltitude (number, optional) — Minimum camera altitude above terrain.
    • options.maxAltitude (number, optional) — Maximum camera altitude above terrain.
    • options.frustums (Array.<Array.<number>>, optional) — Planet camera frustum configuration.
    • options.maxGridSize (number, optional, default: 256) — Maximum terrain segment grid size.
    • options.maxLoadingRequests (number, optional, default: 12) — Maximum concurrent tile loading requests.
    • options.maxNodesCount (number, optional, default: 400) — Maximum number of created quadtree nodes.
    • options.maxEqualZoomAltitude (number, optional, default: "15000000.0") — Max altitude where visible segments keep the same zoom.
    • options.minEqualZoomAltitude (number, optional, default: "10000.0") — Min altitude where visible segments keep the same zoom.
    • options.minEqualZoomCameraSlope (number, optional, default: 0.8) — Min camera slope for equal-zoom segment strategy.
    • options.quadTreeStrategyPrototype (function, optional, default: "EarthQuadTreeStrategy") — Quadtree strategy class.
    • options.nightTextureSrc (string | null, optional) — Night lights texture URL (null disables texture loading).
    • options.specularTextureSrc (string | null, optional) — Water/specular mask texture URL (null disables texture loading).
    • options.atmosphereEnabled (boolean, optional, default: false) — Enables atmosphere rendering.
    • options.transitionOpacityEnabled (boolean, optional) — Enables terrain transition opacity blending.
    • options.atmosphereParameters (IAtmosphereParams, optional) — Atmosphere model parameters.
    • options.minDistanceBeforeMemClear (number, optional) — Camera travel distance threshold before automatic memory cleanup.
    • options.disableMemClear (boolean, optional, default: false) — Disables automatic memory cleanup via memClear().
    • options.vectorTileSize (number, optional) — Vector tile texture size for vector layer baking.
    • options.transparentBackground (boolean, optional, default: false) — Enables transparent renderer background.
    • options.nearPlaneStrategy (INearPlaneStrategy, optional) — Near-plane strategy implementation.
    • options.shadeMode (number | string, optional, default: 0.5) — Terrain shading mode: 0|none|unlit, 0.5|phong, 1|pbr.
    • options.reverseDepth (boolean, optional, default: true) — Enables reverse-Z depth for the default planet camera in perspective mode.

Instance Methods

getNorthFrameRotation(cartesian: Vec3): Quat

Returns local north frame rotation for a cartesian point.

Parameters

  • cartesian (Vec3) — Cartesian point.

Returns

getFrameRotation(cartesian: Vec3): Quat

Returns local frame rotation for a cartesian point.

Parameters

  • cartesian (Vec3) — Cartesian point.

Returns

addControl(control: Control)

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

Parameters

addControls(cArr: Array.<Control>)

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

Parameters

  • cArr (Array.<Control>) — Control array.

getLayerByName(name: string): Layer | undefined

Returns a layer by name.

Parameters

  • name (string) — Layer name.

Returns

addLayer(layer: Layer)

Adds layer to the planet.

Parameters

  • layer (Layer) — Layer object.

_onLayerVisibilityChanged(layer: Layer)

Dispatch layer visibility changing event.

Parameters

  • layer (Layer) — Changed layer.

addLayers(layers: Array.<Layer>)

Adds the given layers array to the planet.

Parameters

  • layers (Array.<Layer>) — Layers array.

removeLayer(layer: Layer)

Removes the given layer from the planet.

Parameters

  • layer (Layer) — Layer to remove.

_clearLayerMaterial(layer: Layer)

Clears material resources related to a layer in quadtree segments.

Parameters

  • layer (Layer) — Material layer.

setBaseLayer(layer: Layer)

Sets base layer coverage to the planet.

Parameters

  • layer (Layer) — Layer object.

setHeightFactor(factor: number)

Sets elevation scale. 1.0 is default.

Parameters

  • factor (number) — Elevation scale.

getHeightFactor(): number

Gets elevation scale.

Returns

  • number — Terrain elevation scale

setLodSize( currentLodSize: number, minLodSize?: number, maxLodSize?: number, )

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

Parameters

  • currentLodSize (number) — Current LOD size target.
  • minLodSize (number, optional) — Minimum LOD size.
  • maxLodSize (number, optional) — Maximum LOD size.

getTerrainByName(name: string): EmptyTerrain | undefined

Returns a terrain provider by name.

Parameters

  • name (string) — Terrain provider name.

Returns

addTerrain(terrain: EmptyTerrain)

Attaches terrain provider to the planet without activating it.

Parameters

addTerrains(terrains: Array.<EmptyTerrain>)

Attaches the given terrain providers array to the planet.

Parameters

  • terrains (Array.<EmptyTerrain>) — Terrain providers array.

removeTerrain(terrain: EmptyTerrain)

Detaches terrain provider from the planet. Currently active terrain provider can't be removed.

Parameters

setTerrain(terrain: EmptyTerrain)

Sets terrain provider. Only one terrain provider could be active at a time. The given provider is automatically attached to the planet terrain providers list.

Parameters

initAtmosphereShader(atmosParams?: AtmosphereParameters)

Reinitializes terrain forward/deferred shaders for atmosphere mode.

Parameters

  • atmosParams (AtmosphereParameters, optional) — Optional atmosphere shader parameters.

init()

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

initLayers()

Reattaches already registered layers to apply initialization logic.

createDefaultTextures( param0: IDefaultTextureParams, param1: IDefaultTextureParams, )

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

Parameters

  • param0 (IDefaultTextureParams) — Default texture params for the first texture.
  • param1 (IDefaultTextureParams) — Default texture params for the second texture.

updateAttributionsList()

Updates attribution lists

updateVisibleLayers()

Schedules visible layers list refresh for the next frame.

_applyAttribution()

Apply to render list of layer attributions

_sortLayers()

Sort visible layer - preparing for rendering.

lockQuadTree()

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

unlockQuadTree()

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

_renderingOpaqueScreenNodes()

Drawing nodes

renderDepthFramebuffer( cam: PlanetCamera, quadTreeStrategy: QuadTreeStrategy, )

Renders terrain depth and frustum id into the depth framebuffer.

Parameters

  • cam (PlanetCamera) — Camera used for rendering.
  • quadTreeStrategy (QuadTreeStrategy) — Quadtree strategy with rendered node lists.

memClear()

Starts a clear memory thread.

getRayIntersectionEllipsoid(ray: Ray): Vec3 | undefined

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

Parameters

  • ray (Ray) — Ray.

Returns

getCartesianFromPixelEllipsoid( px: Vec2 | IBaseInputState, ): Vec3 | undefined

Project screen coordinates to the planet ellipsoid.

Parameters

  • px (Vec2 | IBaseInputState) — Screen coordinates.

Returns

getLonLatFromPixelEllipsoid(px: Vec2): LonLat | undefined

Project screen coordinates to the planet ellipsoid.

Parameters

  • px (Vec2) — Screen coordinates.

Returns

getCartesianFromMouseTerrain(): Vec3 | undefined

Returns mouse position cartesian coordinates on the current terrain.

Returns

getCartesianFromPixelTerrain( px: Vec2 | IBaseInputState, ): Vec3 | undefined

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

Parameters

  • px (Vec2 | IBaseInputState) — Pixel screen 2d coordinates.

Returns

getLonLatFromPixelTerrain( px: Vec2 | IBaseInputState, ): 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

  • px (Vec2 | IBaseInputState) — Pixel screen 2d coordinates.

Returns

getPixelFromCartesian(coords: Vec3): Vec2

Project cartesian coordinates to screen space.

Parameters

  • coords (Vec3) — Cartesian coordinates.

Returns

getPixelFromLonLat(lonlat: LonLat): Vec2 | undefined

Project geodetic coordinates to screen space.

Parameters

  • lonlat (LonLat) — Geodetic coordinates.

Returns

getDistanceFromPixelEllipsoid( px: Vec2 | IBaseInputState, ): number | undefined

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

Parameters

  • px (Vec2 | IBaseInputState) — Screen coordinates.

Returns

  • number | undefined

getDistanceFromPixel(px: Vec2 | IBaseInputState): number

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

Parameters

  • px (Vec2 | IBaseInputState) — Screen coordinates.

Returns

  • number

viewExtent(extent: Extent)

Sets camera to the planet geographical extent.

Parameters

  • extent (Extent) — Geographical extent.

viewExtentArr(extentArr: Array.<number>)

Fits camera position for the view extent.

Parameters

  • extentArr (Array.<number>) — Geographical extent array, (exactly 4 entries) where index 0 - southwest longitude, 1 - latitude southwest, 2 - longitude northeast, 3 - latitude northeast.

getExtent(): Extent

Gets current camera view extent.

Returns

getViewExtent(): Extent

Returns currently cached quadtree view extent.

Returns

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

Sets camera to the planet geographical position.

Parameters

  • lonlat (LonLat) — Camera position.
  • lookLonLat (LonLat, optional) — Viewpoint.
  • up (Vec3, optional) — Camera up vector.

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

Fly active camera to the view extent.

Parameters

  • extent (Extent) — Geographical extent.
  • height (Number, optional) — Height on the end of the flight route.
  • params (IPlanetFlyCartesianParams) — Flight parameters.

flyCartesian(cartesian: Vec3, params: IPlanetFlyCartesianParams)

Fly camera to the point.

Parameters

  • cartesian (Vec3) — Fly cartesian coordinates.
  • params (IPlanetFlyCartesianParams) — Flight parameters.

flyLonLat(lonlat: LonLat, params: IPlanetFlyCartesianParams)

Fly camera to the geodetic position.

Parameters

  • lonlat (LonLat) — Fly geographical coordinates.
  • params (IPlanetFlyCartesianParams) — Flight parameters.

stopFlying()

Stop current flight.

updateBillboardsTexCoords()

Refreshes billboard texture coordinates for all visible entity collections.

getEntityTerrainPoint( entity: Entity, res: Vec3, ): Vec3 | undefined

Finds terrain point under an entity in currently rendered segments.

Parameters

  • entity (Entity) — Entity to test.
  • res (Vec3) — Output vector for terrain point.

Returns

getCartesianTerrainPoint( cart: Vec3, res: Vec3, ): number | undefined

Finds terrain point under a cartesian point.

Parameters

  • cart (Vec3) — Cartesian point to test.
  • res (Vec3) — Output vector for terrain point.

Returns

  • number | undefined

getHeightDefault(lonLat: LonLat): Promise.<number>

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

Parameters

  • lonLat (LonLat) — Geodetic coordinates.

Returns

  • Promise.<number>

getHeightAboveELL(lonLat: LonLat): Promise.<number>

Returns terrain height above ellipsoid at the given coordinates.

Parameters

  • lonLat (LonLat) — Geodetic coordinates.

Returns

  • Promise.<number>

onremove()

Handles node detachment and frees runtime terrain data.

destroy()

Overrides: Scene#destroy

Destroy planet.

addNode()

Inherited from Scene#addNode

Overrides: Scene#addNode

Adds node to the current hierarchy.

assign(renderer: Renderer)

Inherited from Scene#assign

Overrides: Scene#assign

Assign render node with renderer.

Parameters

  • renderer (Renderer) — Render node's renderer.

_clear()

protected
Scene.ts:196

Inherited from Scene#_clear

Overrides: Scene#_clear

Clear current node.

addEntityCollection( entityCollection: EntityCollection, isHidden?: boolean, ): Scene

Inherited from Scene#addEntityCollection

Overrides: Scene#addEntityCollection

Adds an entity collection.

Parameters

  • entityCollection (EntityCollection) — Entity collection.
  • isHidden (boolean, optional) — If it's true that this collection has specific rendering.

Returns

removeEntityCollection(entityCollection: EntityCollection)

Inherited from Scene#removeEntityCollection

Overrides: Scene#removeEntityCollection

Removes entity collection.

Parameters

isActive(): Boolean

Inherited from Scene#isActive

Overrides: Scene#isActive

Gets render node activity.

Returns

  • Boolean

setActive(isActive: boolean)

Inherited from Scene#setActive

Overrides: Scene#setActive

Rendering activation.

Parameters

  • isActive (boolean) — Activation flag.

setDrawMode(mode: Number)

Inherited from Scene#setDrawMode

Overrides: Scene#setDrawMode

Sets draw mode

Parameters

  • mode (Number) — Draw mode, such as gl.TRIANGLES, gl.TRIANGLE_STRIP, gl.LINES etc.

drawPickingEntityCollections(ec: Array.<EntityCollection>)

Inherited from Scene#drawPickingEntityCollections

Overrides: Scene#drawPickingEntityCollections

Draw entity collections picking frame.

Parameters

Instance Fields

terrainReady

Returns true if the current terrain data set is loaded

maxGridSize

Returns max segment grid size used by the quadtree.

Returns

  • number

atmosphereMaxOpacity

Sets maximum atmosphere opacity.

Parameters

  • opacity (number) — Opacity value in range [0..1].

atmosphereMaxOpacity

Gets maximum atmosphere opacity.

Returns

  • number

atmosphereMinOpacity

Sets minimum atmosphere opacity.

Parameters

  • opacity (number) — Opacity value in range [0..1].

atmosphereMinOpacity

Gets minimum atmosphere opacity.

Returns

  • number

atmosphereOpacityCurveShift

Sets atmosphere opacity interpolation curve shift.

Parameters

  • curveShift (number) — Curve shift. Zero produces linear interpolation.

atmosphereOpacityCurveShift

Gets atmosphere opacity interpolation curve shift.

Returns

  • number

atmosphereMaxMinOpacity

Gets target atmosphere opacity parameters [max, min, curveShift].

Returns

  • Float32Array

atmosphereEnabled

Enables or disables atmosphere rendering and related programs.

Parameters

  • enabled (boolean) — Atmosphere activity flag.

atmosphereEnabled

Returns atmosphere activity flag.

Returns

  • boolean

shadeMode

Returns active terrain shade mode.

Returns

  • number

shadeMode

Sets terrain shade mode.

Parameters

  • m (number | string) — Shade mode id (0|0.5|1 or none|phong|pbr).

normalMapCreator

Returns normal-map generator used by the planet.

Returns

  • NormalMapCreator

layers

Returns current layers snapshot.

Returns

sun

Returns Sun control instance if attached to the renderer.

Returns

  • Sun | undefined

sunPos

Returns current sun world position.

Returns

terrains

Returns attached terrain providers snapshot.

Returns

atmosphereControl

Returns atmosphere control instance bound to the planet.

Returns

  • Atmosphere