Cesium 中創建viewer 的參數詳解

Cesium 需要創建viewer,構建基礎的場景信息。創建viewer的過程,包含很多參數,可以調節viewer的樣式,或者展現出來的功能。今天具體探索一下這些參數的含義。

首先看一下,創建viewer的時候有哪些可選的參數。

Name Type Description
container Element | String The DOM element or ID that will contain the widget.
options Object optional Object with the following properties:
Name Type Default Description
animation Boolean TRUE optional If set to false, the Animation widget will not be created.
baseLayerPicker Boolean TRUE optional If set to false, the BaseLayerPicker widget will not be created.
fullscreenButton Boolean TRUE optional If set to false, the FullscreenButton widget will not be created.
vrButton Boolean FALSE optional If set to true, the VRButton widget will be created.
geocoder Boolean | Array.<GeocoderService> TRUE optional If set to false, the Geocoder widget will not be created.
homeButton Boolean TRUE optional If set to false, the HomeButton widget will not be created.
infoBox Boolean TRUE optional If set to false, the InfoBox widget will not be created.
sceneModePicker Boolean TRUE optional If set to false, the SceneModePicker widget will not be created.
selectionIndicator Boolean TRUE optional If set to false, the SelectionIndicator widget will not be created.
timeline Boolean TRUE optional If set to false, the Timeline widget will not be created.
navigationHelpButton Boolean TRUE optional If set to false, the navigation help button will not be created.
navigationInstructionsInitiallyVisible Boolean TRUE optional 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 FALSE optional When true, each geometry instance will only be rendered in 3D to save GPU memory.
shouldAnimate Boolean FALSE optional true if the clock should attempt to advance simulation time by default, false otherwise. This option takes precedence over setting Viewer#clockViewModel.
clockViewModel ClockViewModel new ClockViewModel(options.clock) optional 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 options.baseLayerPicker is set to true.
imageryProviderViewModels Array.<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.
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 options.baseLayerPicker is set to true.
terrainProviderViewModels Array.<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.
imageryProvider ImageryProvider createWorldImagery() optional The imagery provider to use. This value is only valid if options.baseLayerPicker is set to false.
terrainProvider TerrainProvider new EllipsoidTerrainProvider() optional The terrain provider to use
skyBox SkyBox   optional The skybox used to render the stars. When undefined, the default stars are used.
skyAtmosphere SkyAtmosphere   optional Blue sky, and the glow around the Earth's limb. Set to false to turn it off.
fullscreenElement Element | String document.body optional The element or id to be placed into fullscreen mode when the full screen button is pressed.
useDefaultRenderLoop Boolean TRUE optional True if this widget should control the render loop, false otherwise.
targetFrameRate Number   optional The target frame rate when using the default render loop.
showRenderLoopErrors Boolean TRUE optional If true, this widget will automatically display an HTML panel to the user containing the error, if a render loop error occurs.
useBrowserRecommendedResolution Boolean TRUE optional If true, render at the browser's recommended resolution and ignore window.devicePixelRatio.
automaticallyTrackDataSourceClocks Boolean TRUE optional 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 Object   optional Context and WebGL creation properties corresponding to options passed to Scene.
sceneMode SceneMode SceneMode.SCENE3D optional The initial scene mode.
mapProjection MapProjection new GeographicProjection() optional The map projection to use in 2D and Columbus View modes.
globe Globe new Globe(mapProjection.ellipsoid) optional The globe to use in the scene. If set to false, no globe will be added.
orderIndependentTranslucency Boolean TRUE optional If true and the configuration supports it, use order independent translucency.
creditContainer Element | 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.
creditViewport Element | 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.
dataSources DataSourceCollection new 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.
terrainExaggeration Number 1 optional 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.
shadows Boolean FALSE optional Determines if shadows are cast by light sources.
terrainShadows ShadowMode ShadowMode.RECEIVE_ONLY optional Determines if the terrain casts or receives shadows from light sources.
mapMode2D MapMode2D MapMode2D.INFINITE_SCROLL optional Determines if the 2D map is rotatable or can be scrolled infinitely in the horizontal direction.
projectionPicker Boolean FALSE optional If set to true, the ProjectionPicker widget will be created.
requestRenderMode Boolean FALSE optional 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 0 optional 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:
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章