用于构建应用程序的基础部件 。 它将所有标准的 NT 0 部件合成一个可重复使用的软件包.
部件总是可以通过使用混音器来扩展,这些混音器增加了对各种应用程序有用的功能.
| Name | Type | Description |
|---|---|---|
container |
Element | string | The DOM element or ID that will contain the widget. |
options |
Viewer.ConstructorOptions | optional 描述初始化选项的对象 |
Throws:
-
DeveloperError : Element with id "container" does not exist in the document.
-
DeveloperError : options.selectedImageryProviderViewModel is not available when not using the BaseLayerPicker widget, specify options.baseLayer instead.
-
DeveloperError : options.selectedTerrainProviderViewModel is not available when not using the BaseLayerPicker widget, specify options.terrainProvider instead.
Example:
// Initialize the viewer widget with several custom options and mixins.
try {
const viewer = new Cesium.Viewer("cesiumContainer", {
// Start in Columbus Viewer
sceneMode: Cesium.SceneMode.COLUMBUS_VIEW,
// Use Cesium World Terrain
terrain: Cesium.Terrain.fromWorldTerrain(),
// Hide the base layer picker
baseLayerPicker: false,
// Use OpenStreetMaps
baseLayer: new Cesium.ImageryLayer(new Cesium.OpenStreetMapImageryProvider({
url: "https://tile.openstreetmap.org/"
})),
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
mapProjection: new Cesium.WebMercatorProjection()
});
} catch (error) {
console.log(error);
}
// Add basic drag and drop functionality
viewer.extend(Cesium.viewerDragDropMixin);
// Show a pop-up alert if we encounter an error when processing a dropped file
viewer.dropError.addEventListener(function(dropHandler, name, error) {
console.log(error);
window.alert(error);
});
Demo:
See:
Members
获取或设定数据源是否可以暂时暂停
动画,以避免向用户显示不完整的图片.
例如,如果同步原始物正在处理中
背景,在几何学准备好之前,时钟不会前进.
readonly animation : Animation
获得动画部件.
readonly baseLayerPicker : BaseLayerPicker
得到的BaseLayerPicker.
获取窗口下方含有“% 1” 的区域的 NT 0 元素
CreditDisplay and potentially other things.
readonly camera : Camera
获取相机.
得到画布.
readonly cesiumWidget : CesiumWidget
获取铯维基.
readonly clock : Clock
得到的钟.
clockTrackedDataSource : DataSource
获取或设置数据源以跟随查看器的时钟.
readonly clockViewModel : ClockViewModel
获得时钟视图模型.
得到母容器.
creditDisplay : CreditDisplay
管理要在屏幕和灯盒中显示的信用列表.
readonly dataSourceDisplay : DataSourceDisplay
Gets the display used for
DataSource visualization.
readonly dataSources : DataSourceCollection
Gets the set of
DataSource instances to be visualized.
readonly ellipsoid : Ellipsoid
获取场景的默认椭圆 .
-
Default Value:
Ellipsoid.default
readonly entities : EntityCollection
获得不与特定数据源绑定的实体的收集.
这是 [ dataSourceDisplay.defaultDataSource.entities ]
Viewer#dataSourceDisplay 的捷径.
readonly fullscreenButton : FullscreenButton
得到全屏按钮.
readonly geocoder : Geocoder
获取地理编码器.
readonly homeButton : HomeButton
得到家用按钮.
readonly imageryLayers : ImageryLayerCollection
获得将在全球渲染的图像层的集合 .
readonly infoBox : InfoBox
获取信息框.
readonly navigationHelpButton : NavigationHelpButton
获取导航帮助按钮.
readonly postProcessStages : PostProcessStageCollection
获得后处理阶段.
readonly projectionPicker : ProjectionPicker
得到投影选手.
获取或设置渲染分辨率的缩放因子。 小于1.0的值可以改进
在功率较低的设备上进行性能,而数值大于1.0的则在较高时进行性能
然后缩小范围,从而提高视觉的忠诚度.
例如,如果部件的大小为 640x480, 则该值为 0. 5
将会使场景在 320x240 进行渲染,然后在设置时放大
它到2.0将会使场景在1280x960上渲染,然后缩放.
-
Default Value:
1.0
readonly scene : Scene
得到场景.
readonly sceneModePicker : SceneModePicker
获取SceneModePicker.
readonly screenSpaceEventHandler : ScreenSpaceEventHandler
获得屏幕空间事件处理器.
selectedEntity : Entity|undefined
获取或设置要显示选择指标的对象实例.
如果用户交互选择一个 Cesium3DtilesFeature 实例, 那么这个属性
将包含一个短暂的 NT 0 实例,其中包含一个名为“地貌”的属性,即
被选中的例子.
readonly selectedEntityChanged : Event
获取选定实体更改时提出的事件.
readonly selectionIndicator : SelectionIndicator
获得选择指标.
readonly shadowMap : ShadowMap
获取现场的阴影图
确定阴影是否由光源投射.
当 NT 0 us DefaultRenderLoop NT 1 时获取或设定部件的目标帧率
没错 如果未定义, 浏览器请求的 AnimationFrame 执行
确定帧率。 如果定义,此值必须大于 0 。 更高值
动画 框架的实施不会产生任何效果.
terrainProvider : TerrainProvider
提供地球表面几何的地形提供者.
terrainShadows : ShadowMode
确定地形是来自光源的投影还是阴影.
readonly timeline : Timeline
获取时间线部件 .
trackedEntity : Entity|undefined
获取或设置正在由相机跟踪的 NT 0 实例 .
readonly trackedEntityChanged : Event
获取跟踪实体改变时提起的事件.
布尔旗表示是否使用浏览器推荐的分辨率 .
如果真实, 浏览器的设备像素比被忽略, 并使用1.0 代替,
基于 NT 0 像素而不是设备像素的有效渲染. 这可以改善
在像素密度高的功率较低的设备上运行。 当虚假时, 渲染
will be in device pixels.
Viewer#resolutionScale will still take effect whether
这个旗帜是真实的还是假的.
-
Default Value:
true
获取或设定此部件是否控制渲染循环 .
如果选中的话, 部件将使用请求动画 框架为
执行部件的渲染和调整大小,以及驱动
模拟时钟. 如果设定为虚假,则必须手动调用
-NT+0 调整 NT+1 , NT+2 放弃 NT+3 方法
as part of a custom render loop. If an error occurs during rendering,
Scene's
-NT+0+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 事件将会被提起, 而此财产
将变成假的。 必须回到真实的状态 继续做
错误发生后.
readonly vrButton : VRButton
得到VR按钮.
Methods
摧毁部件。 如果永久调用, 应该调用
从布局中删除部件 .
以提供的混音器扩展基本查看器功能.
混音可能添加额外的属性、功能或其他行为
到所提供的查看器实例.
| Name | Type | Description |
|---|---|---|
mixin |
Viewer.ViewerMixin | 查看器混合到此实例中 . |
options |
object | optional 选项对象要传递到混合函数 . |
See:
将相机悬挂到所提供的实体、实体或数据源.
如果数据源仍在装入过程中,或者可视化还在装入,
这种方法在进行飞行前等待数据准备好.
-NT=0=- 翻译: 页:1.
标题和投球角度在局部的东-北上参考框中定义.
标题是Y轴的角度,向x轴增加。 皮奇是Xy飞机的旋转 正投篮
角度在飞机上方。 负投球角度位于飞机下方. 范围是中心距离. 如果范围是
0, 将计算一个范围, 使整个边框为 NT% 1
NT 0 在2D中,必须有一个上下视图. 摄像头会放在目标上方 上面的高处
目标将是范围。 该标题将由抵消部分确定。 如果标题不能是
由冲抵确定,标题为 NT
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
target |
Entity | Array.<Entity> | EntityCollection | DataSource | ImageryLayer | Cesium3DTileset | TimeDynamicPointCloud | Promise.<(Entity|Array.<Entity>|EntityCollection|DataSource|ImageryLayer|Cesium3DTileset|TimeDynamicPointCloud|VoxelPrimitive)> | 实体、 实体数组、 实体收集、 数据源、 NT % 0 、 点云或图像层。 您也可以将一个承诺传递给前述类型之一. | ||||||||||||||||
options |
object |
optional
下列属性的对象 :
|
Returns:
如果飞行成功或失实,如果目标目前未在现场可视化或飞行取消,则确定为真实的 Promise . // TODO :清理实体提到
这迫使部件重新思考其布局,包括
部件大小和信用设置 .
Returns:
如果物体已被销毁, 则真实无误 .
播映场景. 此函数自动调用
除非 NT 0 use DefaultRenderLoop NT 1 被设定为虚假;
调整部件大小以匹配容器大小.
除非
NT 0 use DefaultRenderLoop NT 1 被设定为虚假.
同步设置相机以查看所提供的实体,实体或数据源.
如果数据源仍在装入过程中,或者可视化还在装入,
此方法等待数据准备好后再进行缩放.
-NT=0=- 翻译: 页:1.
标题和投球角度在局部的东-北上参考框中定义.
标题是Y轴的角度,向x轴增加。 皮奇是Xy飞机的旋转 正投篮
角度在飞机上方。 负投球角度位于飞机下方. 范围是中心距离. 如果范围是
0, 将计算一个范围, 使整个边框为 NT% 1
NT 0 在2D中,必须有一个上下视图. 摄像头会放在目标上方 上面的高处
目标将是范围。 该标题将由抵消部分确定。 如果标题不能是
由冲抵确定,标题为 NT
| Name | Type | Description |
|---|---|---|
target |
Entity | Array.<Entity> | EntityCollection | DataSource | ImageryLayer | Cesium3DTileset | TimeDynamicPointCloud | Promise.<(Entity|Array.<Entity>|EntityCollection|DataSource|ImageryLayer|Cesium3DTileset|TimeDynamicPointCloud|VoxelPrimitive)> | 实体、 实体数组、 实体收集、 数据源、 NT % 0 、 点云或图像层。 您也可以将一个承诺传递给前述类型之一. |
offset |
HeadingPitchRange | optional 由当地东北参照框架的实体中心抵消. |
Returns:
如果缩放成功或虚假,如果目标目前未在现场可视化,或者缩放被取消,则解析为真实的 NT++0 .
Type Definitions
查看器构建器的初始化选项
Properties:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
animation |
boolean |
<optional> |
true | If set to false, the Animation widget will not be created. |
baseLayerPicker |
boolean |
<optional> |
true | If set to false, the BaseLayerPicker widget will not be created. |
fullscreenButton |
boolean |
<optional> |
true | If set to false, the FullscreenButton widget will not be created. |
vrButton |
boolean |
<optional> |
false | If set to true, the VRButton widget will be created. |
geocoder |
boolean | IonGeocodeProviderType | Array.<GeocoderService> |
<optional> |
IonGeocodeProviderType.DEFAULT | The geocoding service or services to use when searching with the Geocoder widget. If set to false, the Geocoder widget will not be created. |
homeButton |
boolean |
<optional> |
true | If set to false, the HomeButton widget will not be created. |
infoBox |
boolean |
<optional> |
true | If set to false, the InfoBox widget will not be created. |
sceneModePicker |
boolean |
<optional> |
true | If set to false, the SceneModePicker widget will not be created. |
selectionIndicator |
boolean |
<optional> |
true | If set to false, the SelectionIndicator widget will not be created. |
timeline |
boolean |
<optional> |
true | If set to false, the Timeline widget will not be created. |
navigationHelpButton |
boolean |
<optional> |
true | If set to false, the navigation help button will not be created. |
navigationInstructionsInitiallyVisible |
boolean |
<optional> |
true | True if the navigation instructions should initially be visible, or false if the should not be shown until the user explicitly clicks the button. |
scene3DOnly |
boolean |
<optional> |
false | When true, each geometry instance will only be rendered in 3D to save GPU memory. |
shouldAnimate |
boolean |
<optional> |
false | true if the clock should attempt to advance simulation time by default, false otherwise. This option takes precedence over setting Viewer#clockViewModel. |
clockViewModel |
ClockViewModel |
<optional> |
new ClockViewModel(clock) | The clock view model to use to control current time. |
selectedImageryProviderViewModel |
ProviderViewModel |
<optional> |
The view model for the current base imagery layer, if not supplied the first available base layer is used. This value is only valid if `baseLayerPicker` is set to true. | |
imageryProviderViewModels |
Array.<ProviderViewModel> |
<optional> |
createDefaultImageryProviderViewModels() | The array of ProviderViewModels to be selectable from the BaseLayerPicker. This value is only valid if `baseLayerPicker` is set to true. |
selectedTerrainProviderViewModel |
ProviderViewModel |
<optional> |
The view model for the current base terrain layer, if not supplied the first available base layer is used. This value is only valid if `baseLayerPicker` is set to true. | |
terrainProviderViewModels |
Array.<ProviderViewModel> |
<optional> |
createDefaultTerrainProviderViewModels() | The array of ProviderViewModels to be selectable from the BaseLayerPicker. This value is only valid if `baseLayerPicker` is set to true. |
baseLayer |
ImageryLayer | false |
<optional> |
ImageryLayer.fromWorldImagery() | The bottommost imagery layer applied to the globe. If set to false, no imagery provider will be added. This value is only valid if `baseLayerPicker` is set to false. Cannot be used when `globe` is set to false. |
ellipsoid |
Ellipsoid |
<optional> |
Ellipsoid.default | The default ellipsoid. |
terrainProvider |
TerrainProvider |
<optional> |
new EllipsoidTerrainProvider() | The terrain provider to use |
terrain |
Terrain |
<optional> |
A terrain object which handles asynchronous terrain provider. Can only specify if options.terrainProvider is undefined. | |
skyBox |
SkyBox | false |
<optional> |
用来制造星星的天盒 当使用 未定义 和 WGS84 椭圆时,使用默认星等. 如果设置为 NT 3 false NT 4 ,则不会添加天盒,太阳或月球. |
|
skyAtmosphere |
SkyAtmosphere | false |
<optional> |
蓝色的天空 和地球四肢周围的光芒 当使用 NT 0 椭圆时启用。 设定为 NT 1 假 NT 2 关机. | |
fullscreenElement |
Element | string |
<optional> |
document.body | The element or id to be placed into fullscreen mode when the full screen button is pressed. |
useDefaultRenderLoop |
boolean |
<optional> |
true | True if this widget should control the render loop, false otherwise. |
targetFrameRate |
number |
<optional> |
使用默认渲染环时的目标帧率 . | |
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. |
useBrowserRecommendedResolution |
boolean |
<optional> |
true | If true, render at the browser's recommended resolution and ignore window.devicePixelRatio. |
automaticallyTrackDataSourceClocks |
boolean |
<optional> |
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 |
<optional> |
Context and WebGL creation properties passed to Scene. |
|
sceneMode |
SceneMode |
<optional> |
SceneMode.SCENE3D | The initial scene mode. |
mapProjection |
MapProjection |
<optional> |
new GeographicProjection(options.ellipsoid) | The map projection to use in 2D and Columbus View modes. |
globe |
Globe | false |
<optional> |
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. |
orderIndependentTranslucency |
boolean |
<optional> |
true | If true and the configuration supports it, use order independent translucency. |
creditContainer |
Element | string |
<optional> |
包含 CreditDisplay 的 DOM 元素或ID. 如果没有指定,则在部件本身的底部添加这些入计量. |
|
creditViewport |
Element | string |
<optional> |
将包含由 CreditDisplay 所创建的信用弹出 的 DOM 元素或 ID 。 如果不指定, 它会出现在部件上 . |
|
dataSources |
DataSourceCollection |
<optional> |
new DataSourceCollection() | The collection of data sources visualized by the widget. If this parameter is provided, 该实例被假定为呼叫者拥有,在观看者被摧毁时不会被销毁. |
shadows |
boolean |
<optional> |
false | Determines if shadows are cast by light sources. |
terrainShadows |
ShadowMode |
<optional> |
ShadowMode.RECEIVE_ONLY | Determines if the terrain casts or receives shadows from light sources. |
mapMode2D |
MapMode2D |
<optional> |
MapMode2D.INFINITE_SCROLL | Determines if the 2D map is rotatable or can be scrolled infinitely in the horizontal direction. |
projectionPicker |
boolean |
<optional> |
false | If set to true, the ProjectionPicker widget will be created. |
blurActiveElementOnCanvasFocus |
boolean |
<optional> |
true | If true, the active element will blur when the viewer'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 |
<optional> |
false | If true, rendering a frame will only occur when needed as determined by changes within the scene. Enabling reduces the CPU/GPU usage of your application and uses less battery on mobile, 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 |
<optional> |
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. |
depthPlaneEllipsoidOffset |
number |
<optional> |
0.0 | 调整深程图,处理椭圆零高度以下的渲染工艺. |
msaaSamples |
number |
<optional> |
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. |
功能可以增加查看器实例的功能 .
| Name | Type | Description |
|---|---|---|
viewer |
Viewer | 观者例. |
options |
object | 要传递到混音函数的选项对象 . |