A widget containing a Cesium scene.
参数名称 |
类型 |
描述信息 |
container |
Element
|
string
|
The DOM element or ID that will contain the widget. |
options |
object
|
可选
Object with the following properties:
参数名称 |
类型 |
默认值 |
描述信息 |
clock |
Clock
|
new Clock()
|
可选
The clock to use to control current time. |
shouldAnimate |
boolean
|
false
|
可选
true if the clock should attempt to advance simulation time by default, false otherwise. |
ellipsoid |
Ellipsoid
|
Ellipsoid.default
|
可选
The default ellipsoid. |
baseLayer |
ImageryLayer
|
false
|
ImageryLayer.fromWorldImagery()
|
可选
The bottommost imagery layer applied to the globe. If set to false , no imagery provider will be added. |
terrainProvider |
TerrainProvider
|
new EllipsoidTerrainProvider(options.ellipsoid)
|
可选
The terrain provider. |
terrain |
Terrain
|
|
可选
A terrain object which handles asynchronous terrain provider. Can only specify if options.terrainProvider is undefined. |
skyBox |
SkyBox
|
false
|
|
可选
The skybox used to render the stars. When undefined and the WGS84 ellipsoid used, the default stars are used. If set to false , no skyBox, Sun, or Moon will be added. |
skyAtmosphere |
SkyAtmosphere
|
false
|
|
可选
Blue sky, and the glow around the Earth's limb. Enabled when the default ellipsoid used. Set to false to turn it off. |
sceneMode |
SceneMode
|
SceneMode.SCENE3D
|
可选
The initial scene mode. |
scene3DOnly |
boolean
|
false
|
可选
When true , each geometry instance will only be rendered in 3D to save GPU memory. |
orderIndependentTranslucency |
boolean
|
true
|
可选
If true and the configuration supports it, use order independent translucency. |
mapProjection |
MapProjection
|
new GeographicProjection(options.ellipsoid)
|
可选
The map projection to use in 2D and Columbus View modes. |
globe |
Globe
|
false
|
new Globe(options.ellipsoid)
|
可选
The globe to use in the scene. If set to false , no globe will be added and the sky atmosphere will be hidden by default. |
useDefaultRenderLoop |
boolean
|
true
|
可选
True if this widget should control the render loop, false otherwise. |
useBrowserRecommendedResolution |
boolean
|
true
|
可选
If true, render at the browser's recommended resolution and ignore window.devicePixelRatio . |
targetFrameRate |
number
|
|
可选
The target frame rate when using the default render loop. |
showRenderLoopErrors |
boolean
|
true
|
可选
If true, this widget will automatically display an HTML panel to the user containing the error, if a render loop error occurs. |
automaticallyTrackDataSourceClocks |
boolean
|
true
|
可选
If true, this widget will automatically track the clock settings of newly added DataSources, updating if the DataSource's clock changes. Set this to false if you want to configure the clock independently. |
contextOptions |
ContextOptions
|
|
可选
Context and WebGL creation properties passed to Scene . |
creditContainer |
Element
|
string
|
|
可选
The DOM element or ID that will contain the CreditDisplay . If not specified, the credits are added
to the bottom of the widget itself. |
creditViewport |
Element
|
string
|
|
可选
The DOM element or ID that will contain the credit pop up created by the CreditDisplay . If not specified, it will appear over the widget itself. |
dataSources |
DataSourceCollection
|
new DataSourceCollection()
|
可选
The collection of data sources visualized by the widget. If this parameter is provided,
the instance is assumed to be owned by the caller and will not be destroyed when the widget is destroyed. |
shadows |
boolean
|
false
|
可选
Determines if shadows are cast by light sources. |
terrainShadows |
ShadowMode
|
ShadowMode.RECEIVE_ONLY
|
可选
Determines if the terrain casts or receives shadows from light sources. |
mapMode2D |
MapMode2D
|
MapMode2D.INFINITE_SCROLL
|
可选
Determines if the 2D map is rotatable or can be scrolled infinitely in the horizontal direction. |
blurActiveElementOnCanvasFocus |
boolean
|
true
|
可选
If true, the active element will blur when the widget's canvas is clicked. Setting this to false is useful for cases when the canvas is clicked only for retrieving position or an entity data without actually meaning to set the canvas to be the active element. |
requestRenderMode |
boolean
|
false
|
可选
If true, rendering a frame will only occur when needed as determined by changes within the scene. Enabling improves performance of the application, but requires using Scene#requestRender to render a new frame explicitly in this mode. This will be necessary in many cases after making changes to the scene in other parts of the API. See Improving Performance with Explicit Rendering. |
maximumRenderTimeChange |
number
|
0.0
|
可选
If requestRenderMode is true, this value defines the maximum change in simulation time allowed before a render is requested. See Improving Performance with Explicit Rendering. |
msaaSamples |
number
|
4
|
可选
If provided, this value controls the rate of multisample antialiasing. Typical multisampling rates are 2, 4, and sometimes 8 samples per pixel. Higher sampling rates of MSAA may impact performance in exchange for improved visual quality. This value only applies to WebGL2 contexts that support multisample render targets. Set to 1 to disable MSAA. |
|
Throws:
-
DeveloperError
: Element with id "container" does not exist in the document.
使用示例:
// 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.
const widget = new Cesium.CesiumWidget("cesiumContainer");
// Widget with ion imagery and Cesium World Terrain.
const widget2 = new Cesium.CesiumWidget("cesiumContainer", {
baseLayer: Cesium.ImageryLayer.fromWorldTerrain(),
terrain: Cesium.Terrain.fromWorldTerrain()
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()
});
Demo:
成员(属性)
Gets or sets whether or not data sources can temporarily pause
animation in order to avoid showing an incomplete picture to the user.
For example, if asynchronous primitives are being processed in the
background, the clock will not advance until the geometry is ready.
Gets the camera.
Gets the canvas.
Gets the clock.
Gets or sets the data source to track with the widget's clock.
Gets the parent container.
Gets the credit container.
Manages the list of credits to display on screen and in the lightbox.
Gets the credit viewport
Gets the display used for
DataSource
visualization.
Gets the set of
DataSource
instances to be visualized.
Gets the default ellipsoid for the scene.
Gets the collection of image layers that will be rendered on the globe.
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.
1.0
Gets the scene.
Gets the screen space event handler.
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.
The terrain provider providing surface geometry for the globe.
Gets or sets the Entity instance currently being tracked by the camera.
Gets the event that is raised when the tracked entity changes.
Boolean flag indicating if the browser's recommended resolution is used.
If true, the browser's device pixel ratio is ignored and 1.0 is used instead,
effectively rendering based on CSS pixels instead of device pixels. This can improve
performance on less powerful devices that have high pixel density. When false, rendering
will be in device pixels.
CesiumWidget#resolutionScale
will still take effect whether
this flag is true or false.
true
Gets or sets whether or not this widget should control the render loop.
If 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.
方法
Destroys the widget. Should be called if permanently
removing the widget from layout.
Flies the camera to the provided entity, entities, or data source.
If the data source is still in the process of loading or the visualization is otherwise still loading,
this method waits for the data to be ready before performing the flight.
The offset is heading/pitch/range in the local east-north-up reference frame centered at the center of the bounding sphere.
The heading and the pitch angles are defined in the local east-north-up reference frame.
The heading is the angle from y axis and increasing towards the x axis. Pitch is the rotation from the xy-plane. Positive pitch
angles are above the plane. Negative pitch angles are below the plane. The range is the distance from the center. If the range is
zero, a range will be computed such that the whole bounding sphere is visible.
In 2D, there must be a top down view. The camera will be placed above the target looking down. The height above the
target will be the range. The heading will be determined from the offset. If the heading cannot be
determined from the offset, the heading will be north.
返回值:
A Promise that resolves to true if the flight was successful or false if the target is not currently visualized in the scene or the flight was cancelled. //TODO: Cleanup entity mentions
返回值:
true if the object has been destroyed, false otherwise.
Renders the scene. This function is called automatically
unless useDefaultRenderLoop
is set to false;
Updates the canvas size, camera aspect ratio, and viewport size.
This function is called automatically as needed unless
useDefaultRenderLoop
is set to false.
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.
参数名称 |
类型 |
描述信息 |
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
|
可选
The error to be displayed on the error panel. This string is formatted using formatError and then displayed as text. |
Asynchronously sets the camera to view the provided entity, entities, or data source.
If the data source is still in the process of loading or the visualization is otherwise still loading,
this method waits for the data to be ready before performing the zoom.
The offset is heading/pitch/range in the local east-north-up reference frame centered at the center of the bounding sphere.
The heading and the pitch angles are defined in the local east-north-up reference frame.
The heading is the angle from y axis and increasing towards the x axis. Pitch is the rotation from the xy-plane. Positive pitch
angles are above the plane. Negative pitch angles are below the plane. The range is the distance from the center. If the range is
zero, a range will be computed such that the whole bounding sphere is visible.
In 2D, there must be a top down view. The camera will be placed above the target looking down. The height above the
target will be the range. The heading will be determined from the offset. If the heading cannot be
determined from the offset, the heading will be north.
返回值:
A Promise that resolves to true if the zoom was successful or false if the target is not currently visualized in the scene or the zoom was cancelled.