Appearance
KBE3D / KBCore / Cesium / CesiumWidget
类: CesiumWidget
A widget containing a Cesium scene.
示例
ts
// 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()
});参数
The DOM element or ID that will contain the widget.
参数
Object with the following properties:
参数
The clock to use to control current time.
参数
<code>true</code> if the clock should attempt to advance simulation time by default, <code>false</code> otherwise.
参数
The default ellipsoid.
参数
The bottommost imagery layer applied to the globe. If set to <code>false</code>, no imagery provider will be added.
参数
The terrain provider.
参数
A terrain object which handles asynchronous terrain provider. Can only specify if options.terrainProvider is undefined.
参数
The skybox used to render the stars. When <code>undefined</code> and the WGS84 ellipsoid used, the default stars are used. If set to <code>false</code>, no skyBox, Sun, or Moon will be added.
参数
Blue sky, and the glow around the Earth's limb. Enabled when the default ellipsoid used. Set to <code>false</code> to turn it off.
参数
The initial scene mode.
参数
When <code>true</code>, each geometry instance will only be rendered in 3D to save GPU memory.
参数
If true and the configuration supports it, use order independent translucency.
参数
The map projection to use in 2D and Columbus View modes.
参数
The globe to use in the scene. If set to <code>false</code>, no globe will be added and the sky atmosphere will be hidden by default.
参数
True if this widget should control the render loop, false otherwise.
参数
If true, render at the browser's recommended resolution and ignore <code>window.devicePixelRatio</code>.
参数
The target frame rate when using the default render loop.
参数
If true, this widget will automatically display an HTML panel to the user containing the error, if a render loop error occurs.
参数
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.
参数
Context and WebGL creation properties passed to Scene.
参数
The DOM element or ID that will contain the CreditDisplay. If not specified, the credits are added to the bottom of the widget itself.
参数
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.
参数
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.
参数
Determines if shadows are cast by light sources.
参数
Determines if the terrain casts or receives shadows from light sources.
参数
Determines if the 2D map is rotatable or can be scrolled infinitely in the horizontal direction.
参数
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.
参数
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.
参数
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.
参数
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.
属性
container
readonlycontainer:Element
Gets the parent container.
canvas
readonlycanvas:HTMLCanvasElement
Gets the canvas.
creditContainer
readonlycreditContainer:Element
Gets the credit container.
creditViewport
readonlycreditViewport:Element
Gets the credit viewport
scene
readonlyscene:Scene
Gets the scene.
imageryLayers
readonlyimageryLayers:ImageryLayerCollection
Gets the collection of image layers that will be rendered on the globe.
terrainProvider
terrainProvider:
TerrainProvider
The terrain provider providing surface geometry for the globe.
creditDisplay
creditDisplay:
CreditDisplay
Manages the list of credits to display on screen and in the lightbox.
dataSourceDisplay
readonlydataSourceDisplay:DataSourceDisplay
Gets the display used for DataSource visualization.
entities
readonlyentities:EntityCollection
Gets the collection of entities not tied to a particular data source. This is a shortcut to [dataSourceDisplay.defaultDataSource.entities]CesiumWidget#dataSourceDisplay.
dataSources
readonlydataSources:DataSourceCollection
Gets the set of DataSource instances to be visualized.
camera
readonlycamera:Camera
Gets the camera.
ellipsoid
readonlyellipsoid:Ellipsoid
Gets the default ellipsoid for the scene.
clock
readonlyclock:Clock
Gets the clock.
screenSpaceEventHandler
readonlyscreenSpaceEventHandler:ScreenSpaceEventHandler
Gets the screen space event handler.
targetFrameRate
targetFrameRate:
number
Gets or sets the target frame rate of the widget when <code>useDefaultRenderLoop</code> 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.
useDefaultRenderLoop
useDefaultRenderLoop:
boolean
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 <code>resize</code>, <code>render</code> methods as part of a custom render loop. If an error occurs during rendering, Scene's <code>renderError</code> 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.
resolutionScale
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.
useBrowserRecommendedResolution
useBrowserRecommendedResolution:
boolean
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.
allowDataSourcesToSuspendAnimation
allowDataSourcesToSuspendAnimation:
boolean
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.
trackedEntity
trackedEntity:
Entity|undefined
Gets or sets the Entity instance currently being tracked by the camera.
trackedEntityChanged
readonlytrackedEntityChanged:Event
Gets the event that is raised when the tracked entity changes.
clockTrackedDataSource
clockTrackedDataSource:
DataSource
Gets or sets the data source to track with the widget's clock.
方法
showErrorPanel()
showErrorPanel(
title:string,message?:string,error?:string):void
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.
返回
void
isDestroyed()
isDestroyed():
boolean
返回
boolean
true if the object has been destroyed, false otherwise.
destroy()
destroy():
void
Destroys the widget. Should be called if permanently removing the widget from layout.
返回
void
resize()
resize():
void
Updates the canvas size, camera aspect ratio, and viewport size. This function is called automatically as needed unless <code>useDefaultRenderLoop</code> is set to false.
返回
void
render()
render():
void
Renders the scene. This function is called automatically unless <code>useDefaultRenderLoop</code> is set to false;
返回
void
zoomTo()
zoomTo(
target:Entity|DataSource|EntityCollection|Entity[] |Cesium3DTileset|ImageryLayer|TimeDynamicPointCloud|Promise<Entity|DataSource|EntityCollection|Entity[] |Cesium3DTileset|ImageryLayer|TimeDynamicPointCloud|VoxelPrimitive>,offset?:HeadingPitchRange):Promise<boolean>
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.
<p>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.</p>
<p>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.</p>
参数
target
The entity, array of entities, entity collection, data source, Cesium3DTileset, point cloud, or imagery layer to view. You can also pass a promise that resolves to one of the previously mentioned types.
Entity | DataSource | EntityCollection | Entity[] | Cesium3DTileset | ImageryLayer | TimeDynamicPointCloud | Promise<Entity | DataSource | EntityCollection | Entity[] | Cesium3DTileset | ImageryLayer | TimeDynamicPointCloud | VoxelPrimitive>
offset?
The offset from the center of the entity in the local east-north-up reference frame.
返回
Promise<boolean>
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.
flyTo()
flyTo(
target:Entity|DataSource|EntityCollection|Entity[] |Cesium3DTileset|ImageryLayer|TimeDynamicPointCloud|Promise<Entity|DataSource|EntityCollection|Entity[] |Cesium3DTileset|ImageryLayer|TimeDynamicPointCloud|VoxelPrimitive>,options?: {duration?:number;maximumHeight?:number;offset?:HeadingPitchRange; }):Promise<boolean>
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.
<p>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.</p>
<p>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.</p>
参数
target
The entity, array of entities, entity collection, data source, Cesium3DTileset, point cloud, or imagery layer to view. You can also pass a promise that resolves to one of the previously mentioned types.
Entity | DataSource | EntityCollection | Entity[] | Cesium3DTileset | ImageryLayer | TimeDynamicPointCloud | Promise<Entity | DataSource | EntityCollection | Entity[] | Cesium3DTileset | ImageryLayer | TimeDynamicPointCloud | VoxelPrimitive>
options?
Object with the following properties:
duration?
number
The duration of the flight in seconds.
maximumHeight?
number
The maximum height at the peak of the flight.
offset?
The offset from the target in the local east-north-up reference frame centered at the target.
返回
Promise<boolean>
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
构造函数
构造函数
new CesiumWidget(
container:string|Element,options?: {clock?:Clock;shouldAnimate?:boolean;ellipsoid?:Ellipsoid;baseLayer?:false|ImageryLayer;terrainProvider?:TerrainProvider;terrain?:Terrain;skyBox?:false|SkyBox;skyAtmosphere?:false|SkyAtmosphere;sceneMode?:SceneMode;scene3DOnly?:boolean;orderIndependentTranslucency?:boolean;mapProjection?:MapProjection;globe?:false|Globe;useDefaultRenderLoop?:boolean;useBrowserRecommendedResolution?:boolean;targetFrameRate?:number;showRenderLoopErrors?:boolean;automaticallyTrackDataSourceClocks?:boolean;contextOptions?:ContextOptions;creditContainer?:string|Element;creditViewport?:string|Element;dataSources?:DataSourceCollection;shadows?:boolean;terrainShadows?:ShadowMode;mapMode2D?:MapMode2D;blurActiveElementOnCanvasFocus?:boolean;requestRenderMode?:boolean;maximumRenderTimeChange?:number;msaaSamples?:number; }):CesiumWidget
参数
container
string | Element
options?
clock?
shouldAnimate?
boolean
ellipsoid?
baseLayer?
false | ImageryLayer
terrainProvider?
terrain?
skyBox?
false | SkyBox
skyAtmosphere?
false | SkyAtmosphere
sceneMode?
scene3DOnly?
boolean
orderIndependentTranslucency?
boolean
mapProjection?
globe?
false | Globe
useDefaultRenderLoop?
boolean
useBrowserRecommendedResolution?
boolean
targetFrameRate?
number
showRenderLoopErrors?
boolean
automaticallyTrackDataSourceClocks?
boolean
contextOptions?
creditContainer?
string | Element
creditViewport?
string | Element
dataSources?
shadows?
boolean
terrainShadows?
mapMode2D?
blurActiveElementOnCanvasFocus?
boolean
requestRenderMode?
boolean
maximumRenderTimeChange?
number
msaaSamples?
number
返回
CesiumWidget
