Cesium 中创建viewer 的参数详解

Cesium 需要创建viewer,构建基础的场景信息。创建viewer的过程,包含很多参数,可以调节viewer的样式,或者展现出来的功能。今天具体探索一下这些参数的含义。

首先看一下,创建viewer的时候有哪些可选的参数。

NameTypeDescription
containerElement | StringThe DOM element or ID that will contain the widget.
optionsObjectoptional Object with the following properties:
NameTypeDefaultDescription
animationBooleanTRUEoptional If set to false, the Animation widget will not be created.
baseLayerPickerBooleanTRUEoptional If set to false, the BaseLayerPicker widget will not be created.
fullscreenButtonBooleanTRUEoptional If set to false, the FullscreenButton widget will not be created.
vrButtonBooleanFALSEoptional If set to true, the VRButton widget will be created.
geocoderBoolean | Array.<GeocoderService>TRUEoptional If set to false, the Geocoder widget will not be created.
homeButtonBooleanTRUEoptional If set to false, the HomeButton widget will not be created.
infoBoxBooleanTRUEoptional If set to false, the InfoBox widget will not be created.
sceneModePickerBooleanTRUEoptional If set to false, the SceneModePicker widget will not be created.
selectionIndicatorBooleanTRUEoptional If set to false, the SelectionIndicator widget will not be created.
timelineBooleanTRUEoptional If set to false, the Timeline widget will not be created.
navigationHelpButtonBooleanTRUEoptional If set to false, the navigation help button will not be created.
navigationInstructionsInitiallyVisibleBooleanTRUEoptional True if the navigation instructions should initially be visible, or false if the should not be shown until the user explicitly clicks the button.
scene3DOnlyBooleanFALSEoptional When true, each geometry instance will only be rendered in 3D to save GPU memory.
shouldAnimateBooleanFALSEoptional true if the clock should attempt to advance simulation time by default, false otherwise. This option takes precedence over setting Viewer#clockViewModel.
clockViewModelClockViewModelnew ClockViewModel(options.clock)optional The clock view model to use to control current time.
selectedImageryProviderViewModelProviderViewModel 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 options.baseLayerPicker is set to true.
imageryProviderViewModelsArray.<ProviderViewModel>createDefaultImageryProviderViewModels()optional The array of ProviderViewModels to be selectable from the BaseLayerPicker. This value is only valid if options.baseLayerPicker is set to true.
selectedTerrainProviderViewModelProviderViewModel 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 options.baseLayerPicker is set to true.
terrainProviderViewModelsArray.<ProviderViewModel>createDefaultTerrainProviderViewModels()optional The array of ProviderViewModels to be selectable from the BaseLayerPicker. This value is only valid if options.baseLayerPicker is set to true.
imageryProviderImageryProvidercreateWorldImagery()optional The imagery provider to use. This value is only valid if options.baseLayerPicker is set to false.
terrainProviderTerrainProvidernew EllipsoidTerrainProvider()optional The terrain provider to use
skyBoxSkyBox optional The skybox used to render the stars. When undefined, the default stars are used.
skyAtmosphereSkyAtmosphere optional Blue sky, and the glow around the Earth's limb. Set to false to turn it off.
fullscreenElementElement | Stringdocument.bodyoptional The element or id to be placed into fullscreen mode when the full screen button is pressed.
useDefaultRenderLoopBooleanTRUEoptional True if this widget should control the render loop, false otherwise.
targetFrameRateNumber optional The target frame rate when using the default render loop.
showRenderLoopErrorsBooleanTRUEoptional If true, this widget will automatically display an HTML panel to the user containing the error, if a render loop error occurs.
useBrowserRecommendedResolutionBooleanTRUEoptional If true, render at the browser's recommended resolution and ignore window.devicePixelRatio.
automaticallyTrackDataSourceClocksBooleanTRUEoptional 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.
contextOptionsObject optional Context and WebGL creation properties corresponding to options passed to Scene.
sceneModeSceneModeSceneMode.SCENE3Doptional The initial scene mode.
mapProjectionMapProjectionnew GeographicProjection()optional The map projection to use in 2D and Columbus View modes.
globeGlobenew Globe(mapProjection.ellipsoid)optional The globe to use in the scene. If set to false, no globe will be added.
orderIndependentTranslucencyBooleanTRUEoptional If true and the configuration supports it, use order independent translucency.
creditContainerElement | 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.
creditViewportElement | String optional 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.
dataSourcesDataSourceCollectionnew DataSourceCollection()optional 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 viewer is destroyed.
terrainExaggerationNumber1optional 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.
shadowsBooleanFALSEoptional Determines if shadows are cast by light sources.
terrainShadowsShadowModeShadowMode.RECEIVE_ONLYoptional Determines if the terrain casts or receives shadows from light sources.
mapMode2DMapMode2DMapMode2D.INFINITE_SCROLLoptional Determines if the 2D map is rotatable or can be scrolled infinitely in the horizontal direction.
projectionPickerBooleanFALSEoptional If set to true, the ProjectionPicker widget will be created.
requestRenderModeBooleanFALSEoptional 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.
maximumRenderTimeChangeNumber0optional 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.

 把这个参数翻译一下,就是

  • animation://是否创建动画小器件,左下角仪表

  • baseLayerPicker://是否显示图层选择器

  • fullscreenButton://是否显示全屏按钮

  • vrButton:// VR控件,见上图全屏按钮左侧
  • geocoder:// 显示查询定位按钮

  • homeButton: // 返回主视角
  • infoBox: // //是否显示信息框

  • sceneModePicker: // 地图按3D/2D显示

  • selectionIndicator:// 选中目标,通过绿框指示拾取到的对象,如上图
  • timeline: //是否显示时间轴

 

  • navigationHelpButton://是否显示右上角的帮助按钮

  • navigationInstructionsInitiallyVisible:// 帮助按钮,初始化的时候是否展开
  • scene3DOnly://如果设置为true,则所有几何图形以3D模式绘制以节约GPU资源
  • shouldAnimate:// 当动画控件出现,用来控制是否通过旋转控件,旋转场景

  • clockViewModel://用于控制当前时间的时钟对象

  • selectedImageryProviderViewModel://当前图像图层的显示模型,仅baseLayerPicker设为true有意义
  • imageryProviderViewModels://可供BaseLayerPicker选择的图像图层ProviderViewModel数组
  • selectedTerrainProviderViewModel://当前地形图层的显示模型,仅baseLayerPicker设为true有意义
  • terrainProviderViewModels://可供BaseLayerPicker选择的地形图层ProviderViewModel数组
  • imageryProvider://图像图层提供者,仅baseLayerPicker设为false有意义
  • terrainProvider://地形图层提供者,仅baseLayerPicker设为false有意义

以上几类,基本和地图数据加载相关,比如支持自定义地图数据,自定义地形数据等

  • skyBox://用于渲染星空的SkyBox对象,可以指定图片渲染星空

  • skyAtmosphere:// 天空中的大气,比如有没有光照,有没有雾

  • fullscreenElement:// //全屏时渲染的HTML元素
  • useDefaultRenderLoop: //如果需要控制渲染循环,则设为true
  • targetFrameRate://使用默认render loop时的帧率
  • showRenderLoopErrors://如果设为true,将在一个HTML面板中显示错误信息
  • useBrowserRecommendedResolution:
  • automaticallyTrackDataSourceClocks://自动追踪最近添加的数据源的时钟设置
  • contextOptions:
  • sceneMode://初始场景模式,与上面的【sceneModePicker】对应

下面的好多都没有用过,也没有找到对应的效果,待后续完善

  • mapProjection://地图投影体系
  • globe:
  • orderIndependentTranslucency:
  • creditContainer:
  • creditViewport:
  • dataSources://需要进行可视化的数据源的集合
  • terrainExaggeration:
  • shadows:// 阴影效果
  • terrainShadows:// 地形阴影效果
  • mapMode2D:
  • projectionPicker:
  • requestRenderMode:
  • maximumRenderTimeChange:
  • 0
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

老朱自强不息

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值