Class: Widget

Widget

new Widget(container)

Components containing SuperMap 3D scenes.

Name Type Default Description
container Element | String

The DOM element or ID that contains the widget.

options.clock Clock new Clock() optional

The clock used to control the current time.

options.imageryProvider ImageryProvider new BingMapsImageryProvider() optional

As an image provider for the base layer. If set to false, no image provider will be added.

options.terrainProvider TerrainProvider new EllipsoidTerrainProvider optional

Terrain provider.

options.skyBox SkyBox optional

A sky box used for rendering stars. If not defined, use default stars. If set to false, no skybox, sun, or moon will be added.

options.skyAtmosphere SkyAtmosphere optional

The halo effect of blue sky and the edge of the earth. Set it to false to turn it off.

options.sceneMode SceneMode SceneMode.SCENE3D optional

Initial scene mode.

options.scene3DOnly Boolean false optional

When set to true, each geometry instance will only be presented in 3D to save GPU memory.

options.orderIndependentTranslucency Boolean true optional

If it is true and the configuration supports it, use a semi transparent effect that is independent of the order.

options.mapProjection MapProjection new GeographicProjection() optional

Map projection used in 2D and Columbus view modes.

options.globe Globe new Globe(mapProjection.ellipsoid) optional

The Earth to be used in the scene. If set to false, the Earth will not be added.

options.useDefaultRenderLoop Boolean true optional

If this widget controls the rendering loop, it is true; otherwise, it is false.

options.targetFrameRate Number optional

The target frame rate when using the default rendering loop.

options.showRenderLoopErrors Boolean true optional

If true, this widget will automatically display an HTML panel containing error information to the user when a rendering loop error occurs.

options.contextOptions Object optional

Create context and WebGL attributes corresponding to the options passed to the Scene.

options.creditContainer Element | String optional

The DOM element or ID containing CreditDisplay. If not specified, it will be added to the bottom of the widget itself.

options.terrainExaggeration Number 1.0 optional

Scalar used for terrain exaggeration. Please note that terrain exaggeration will not modify any other primitives as they are positioned relative to the ellipsoid.

options.shadows Boolean false optional

Determine whether the sun casts shadows.

options.terrainShadows Boolean false optional

Determine whether the terrain will cast solar shadows.

options.mapMode2D MapMode2D MapMode2D.INFINITE_SCROLL optional

Determine whether the 2D map can rotate or scroll infinitely in the horizontal direction.

Throws:

There is no element with ID container in the document.

Type
DeveloperError
Example
// For each example, include a link to Widget.css stylesheet in HTML head,
// and in the body, include: 
//Widget with no terrain and default Bing Maps imagery provider. var widget = new SuperMap3D.Widget('Container'); //Widget with OpenStreetMaps imagery provider and SuperMap3D terrain provider hosted by AGI. var widget = new SuperMap3D.Widget('Container', { imageryProvider : SuperMap3D.createOpenStreetMapImageryProvider(), terrainProvider : new SuperMap3D.SuperMapTerrainProvider({ url : 'https://assets.agi.com/stk-terrain/v1/tilesets/world/tiles' }), skyBox : new SuperMap3D.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 : SuperMap3D.SceneMode.COLUMBUS_VIEW, mapProjection : new SuperMap3D.WebMercatorProjection() });

Members

readonly cameraCamera

Get the camera.

canvasCanvas

Get the canvas.

clockClock

Get the clock.

containerElement

Retrieve the parent container.

creditContainerElement

Obtain the copyright declaration container.

creditViewportElement

Gets the credit viewport

errorListenerEventObject

Get listening crash error events.

readonly imageryLayersImageryLayerCollection

Obtain the collection of image layers to be rendered on Earth.

resolutionScaleNumber

Get or set the scaling factor for rendering resolution. A value less than 1.0 can improve the performance of weaker devices, while a value greater than 1.0 will render at a higher resolution and then shrink, thereby improving visual fidelity. For example, if the size of the widget is 640x480, setting this value to 0.5 will render the scene at 320x240 and then scale it up, while setting it to 2.0 will render the scene at 1280x960 and then scale it down.

Default Value:
1.0

sceneScene

Obtain the scene.

screenSpaceEventHandlerScreenSpaceEventHandler

Obtain the screen space event handler.

setErrorPanelIsShowBoolean

Get or set whether the crash log is displayed.

targetFrameRateNumber

When useDefaultRenderLoop is true, obtain or set the target frame rate of the widget. If not defined, the frame rate is determined by the browser's requestAnimationFrame implementation. If defined, the value must be greater than 0, and it will not have any impact if it is higher than the value implemented by the underlying requestAnimationFrame.

terrainProviderTerrainProvider

Obtain the geometry provided by the terrain provider for the Earth's surface.

useBrowserRecommendedResolutionBoolean

Boolean flag, indicating whether to use the resolution recommended by the browser. If true, the browser's device pixel ratio will be ignored and replaced with 1.0, effectively rendering based on CSS pixels instead of device pixels. This can improve the performance of devices with higher pixel density but weaker performance. When set to false, rendering will be done in device pixels. Regardless of whether this flag is true or false, Widget # solutionScale remains valid.

Default Value:
false

useDefaultRenderLoopBoolean

If set to true, the widget will use requestAnimationFrame to perform rendering and resizing of the widget, and drive the simulation clock. If set to false, the resizing and rendering methods must be manually called in the custom rendering loop. If an error occurs during the rendering process, the renderError event of Scene will be triggered and this property will also be set to false. After an error, the attribute must be set to true in order to continue rendering.

Methods

destroy()

Destruction of components.

isDestroyed(){Boolean}

Returns:
Type Description
Boolean If the object has been destroyed, it is true; otherwise, it is false.

render()

Rendering the scene. This function will be automatically called unless useDefaultRenderLoop is set to false.

resize()

Update canvas size, camera aspect ratio, and viewport size. Unless useDefaultRenderLoop is set to false, this function will be automatically called when needed.

showErrorPanel(title, message, error)

Display an error panel containing a title and lengthy error information to the user, who can use the OK button to cancel the panel. If showRenderLoopErrors is not false when creating a widget, the panel will automatically display when a rendering loop error occurs.

Name Type Description
title String

The title displayed on the error panel. This string is interpreted as text.

message String

User oriented useful information displayed before detailed error messages. This string can be interpreted as HTML.

error String optional

Errors that will be displayed on the error panel. The string will be formatted with formatError and then displayed in text form.