Class: CesiumWidget

CesiumWidget

new CesiumWidget(container, optionsopt)

A widget containing a Cesium scene.
Parameters:
Name Type Attributes Description
container Element | String The DOM element or ID that will contain the widget.
options Object <optional>
Object with the following properties:
Properties
Name Type Attributes Default Description
clock Clock <optional>
new Clock() The clock to use to control current time.
imageryProvider ImageryProvider <optional>
new BingMapsImageryProvider() The imagery provider to serve as the base layer. If set to false, no imagery provider will be added.
terrainProvider TerrainProvider <optional>
new EllipsoidTerrainProvider The terrain provider.
skyBox SkyBox <optional>
The skybox used to render the stars. When undefined, the default stars are used. If set to false, no skyBox, Sun, or Moon will be added.
skyAtmosphere SkyAtmosphere <optional>
Blue sky, and the glow around the Earth's limb. Set to false to turn it off.
sceneMode SceneMode <optional>
SceneMode.SCENE3D The initial scene mode.
scene3DOnly Boolean <optional>
false When true, each geometry instance will only be rendered in 3D to save GPU memory.
orderIndependentTranslucency Boolean <optional>
true If true and the configuration supports it, use order independent translucency.
mapProjection MapProjection <optional>
new GeographicProjection() The map projection to use in 2D and Columbus View modes.
globe Globe <optional>
new Globe(mapProjection.ellipsoid) The globe to use in the scene. If set to false, no globe will be added.
useDefaultRenderLoop Boolean <optional>
true True if this widget should control the render loop, false otherwise.
targetFrameRate Number <optional>
The target frame rate when using the default render loop.
showRenderLoopErrors Boolean <optional>
true If true, this widget will automatically display an HTML panel to the user containing the error, if a render loop error occurs.
contextOptions Object <optional>
Context and WebGL creation properties corresponding to options passed to Scene.
creditContainer Element | String <optional>
The DOM element or ID that will contain the CreditDisplay. If not specified, the credits are added to the bottom of the widget itself.
terrainExaggeration Number <optional>
1.0 A scalar used to exaggerate the terrain. Note that terrain exaggeration will not modify any other primitive as they are positioned relative to the ellipsoid.
shadows Boolean <optional>
false Determines if shadows are cast by the sun.
terrainShadows ShadowMode <optional>
ShadowMode.RECEIVE_ONLY Determines if the terrain casts or receives shadows from the sun.
mapMode2D MapMode2D <optional>
MapMode2D.INFINITE_SCROLL Determines if the 2D map is rotatable or can be scrolled infinitely in the horizontal direction.
Source:
Throws:
Element with id "container" does not exist in the document.
Type
DeveloperError
Example
// For each example, include a link to CesiumWidget.css stylesheet in HTML head,
// and in the body, include: <div id="cesiumContainer"></div>

//Widget with no terrain and default Bing Maps imagery provider.
var widget = new Cesium.CesiumWidget('cesiumContainer');

//Widget with OpenStreetMaps imagery provider and Cesium terrain provider hosted by AGI.
var widget = new Cesium.CesiumWidget('cesiumContainer', {
    imageryProvider : Cesium.createOpenStreetMapImageryProvider(),
    terrainProvider : new Cesium.CesiumTerrainProvider({
        url : 'https://assets.agi.com/stk-terrain/world'
    }),
    // Use high-res stars downloaded from https://github.com/AnalyticalGraphicsInc/cesium-assets
    skyBox : new Cesium.SkyBox({
        sources : {
          positiveX : 'stars/TychoSkymapII.t3_08192x04096_80_px.jpg',
          negativeX : 'stars/TychoSkymapII.t3_08192x04096_80_mx.jpg',
          positiveY : 'stars/TychoSkymapII.t3_08192x04096_80_py.jpg',
          negativeY : 'stars/TychoSkymapII.t3_08192x04096_80_my.jpg',
          positiveZ : 'stars/TychoSkymapII.t3_08192x04096_80_pz.jpg',
          negativeZ : 'stars/TychoSkymapII.t3_08192x04096_80_mz.jpg'
        }
    }),
    // Show Columbus View map with Web Mercator projection
    sceneMode : Cesium.SceneMode.COLUMBUS_VIEW,
    mapProjection : new Cesium.WebMercatorProjection()
});

Members

(readonly) camera :Camera

Gets the camera.
Type:
Source:

canvas :Canvas

Gets the canvas.
Type:
  • Canvas
Source:

clock :Clock

Gets the clock.
Type:
Source:

container :Element

Gets the parent container.
Type:
  • Element
Source:

creditContainer :Element

Gets the credit container.
Type:
  • Element
Source:

(readonly) imageryLayers :ImageryLayerCollection

Gets the collection of image layers that will be rendered on the globe.
Type:
Source:

resolutionScale :Number

Gets or sets a scaling factor for rendering resolution. Values less than 1.0 can improve performance on less powerful devices while values greater than 1.0 will render at a higher resolution and then scale down, resulting in improved visual fidelity. For example, if the widget is laid out at a size of 640x480, setting this value to 0.5 will cause the scene to be rendered at 320x240 and then scaled up while setting it to 2.0 will cause the scene to be rendered at 1280x960 and then scaled down.
Type:
  • Number
Default Value:
  • 1.0
Source:

scene :Scene

Gets the scene.
Type:
Source:

screenSpaceEventHandler :ScreenSpaceEventHandler

Gets the screen space event handler.
Type:
Source:

targetFrameRate :Number

Gets or sets the target frame rate of the widget when useDefaultRenderLoop is true. If undefined, the browser's requestAnimationFrame implementation determines the frame rate. If defined, this value must be greater than 0. A value higher than the underlying requestAnimationFrame implementation will have no effect.
Type:
  • Number
Source:

terrainProvider :TerrainProvider

The terrain provider providing surface geometry for the globe.
Type:
Source:

useDefaultRenderLoop :Boolean

Gets or sets whether or not this widget should control the render loop. If set to true the widget will use requestAnimationFrame to perform rendering and resizing of the widget, as well as drive the simulation clock. If set to false, you must manually call the resize, render methods as part of a custom render loop. If an error occurs during rendering, Scene's renderError event will be raised and this property will be set to false. It must be set back to true to continue rendering after the error.
Type:
  • Boolean
Source:

Methods

destroy()

Destroys the widget. Should be called if permanently removing the widget from layout.
Source:

isDestroyed() → {Boolean}

Source:
Returns:
true if the object has been destroyed, false otherwise.
Type
Boolean

render()

Renders the scene. This function is called automatically unless useDefaultRenderLoop is set to false;
Source:

resize()

Updates the canvas size, camera aspect ratio, and viewport size. This function is called automatically as needed unless useDefaultRenderLoop is set to false.
Source:

showErrorPanel(title, message, erroropt)

Show an error panel to the user containing a title and a longer error message, which can be dismissed using an OK button. This panel is displayed automatically when a render loop error occurs, if showRenderLoopErrors was not false when the widget was constructed.
Parameters:
Name Type Attributes Description
title String The title to be displayed on the error panel. This string is interpreted as text.
message String A helpful, user-facing message to display prior to the detailed error information. This string is interpreted as HTML.
error String <optional>
The error to be displayed on the error panel. This string is formatted using formatError and then displayed as text.
Source: