@cesium/engine 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/Build/Workers/{AttributeCompression-8a5a065e.js → AttributeCompression-f9f6c717.js} +1 -1
  2. package/Build/Workers/{AxisAlignedBoundingBox-a6f9f0e5.js → AxisAlignedBoundingBox-31fadcf0.js} +1 -1
  3. package/Build/Workers/{BoundingRectangle-b0a68595.js → BoundingRectangle-995f0079.js} +1 -1
  4. package/Build/Workers/{BoxGeometry-baedd794.js → BoxGeometry-7eb1af60.js} +1 -1
  5. package/Build/Workers/{Color-f85df1be.js → Color-2dc49658.js} +1 -1
  6. package/Build/Workers/{CoplanarPolygonGeometryLibrary-30516950.js → CoplanarPolygonGeometryLibrary-d7d972d6.js} +1 -1
  7. package/Build/Workers/{CorridorGeometryLibrary-5d5d3b3a.js → CorridorGeometryLibrary-1f5ef7b3.js} +1 -1
  8. package/Build/Workers/{CylinderGeometry-d899ae26.js → CylinderGeometry-23c67a6c.js} +1 -1
  9. package/Build/Workers/{CylinderGeometryLibrary-135b0858.js → CylinderGeometryLibrary-7bf291b4.js} +1 -1
  10. package/Build/Workers/{EllipseGeometry-a49f8449.js → EllipseGeometry-37014da4.js} +1 -1
  11. package/Build/Workers/{EllipseGeometryLibrary-cba7edde.js → EllipseGeometryLibrary-92ab6b1e.js} +1 -1
  12. package/Build/Workers/{EllipseOutlineGeometry-8095c8cb.js → EllipseOutlineGeometry-12b6fef5.js} +1 -1
  13. package/Build/Workers/{EllipsoidGeodesic-dcff5cbd.js → EllipsoidGeodesic-5b3623dc.js} +1 -1
  14. package/Build/Workers/{EllipsoidGeometry-ed93f571.js → EllipsoidGeometry-508da15c.js} +1 -1
  15. package/Build/Workers/{EllipsoidOutlineGeometry-e4854854.js → EllipsoidOutlineGeometry-40d97455.js} +1 -1
  16. package/Build/Workers/{EllipsoidRhumbLine-b672d507.js → EllipsoidRhumbLine-ef872433.js} +1 -1
  17. package/Build/Workers/{EllipsoidTangentPlane-7ae1aa9a.js → EllipsoidTangentPlane-46d4d9c2.js} +1 -1
  18. package/Build/Workers/{EncodedCartesian3-e8bbca36.js → EncodedCartesian3-57415c8a.js} +1 -1
  19. package/Build/Workers/{FrustumGeometry-b62db3e3.js → FrustumGeometry-38605e69.js} +32 -4
  20. package/Build/Workers/{GeometryAttribute-780af4fa.js → GeometryAttribute-a466e9c7.js} +1 -1
  21. package/Build/Workers/{GeometryInstance-3fb607b7.js → GeometryInstance-34d9e21e.js} +1 -1
  22. package/Build/Workers/{GeometryPipeline-36b61c99.js → GeometryPipeline-dcf79306.js} +1 -1
  23. package/Build/Workers/{IndexDatatype-b8f3e09d.js → IndexDatatype-2643aa47.js} +1 -1
  24. package/Build/Workers/{IntersectionTests-e889fcf0.js → IntersectionTests-88c49b2e.js} +1 -1
  25. package/Build/Workers/{Math-dad82b4d.js → Math-0a2ac845.js} +12 -2
  26. package/Build/Workers/{Matrix2-1e403d0e.js → Matrix2-e1298525.js} +1 -1
  27. package/Build/Workers/{Matrix3-fa806b97.js → Matrix3-41c58dde.js} +1 -1
  28. package/Build/Workers/{OrientedBoundingBox-43478ac8.js → OrientedBoundingBox-2dd47921.js} +5 -3
  29. package/Build/Workers/{Plane-c27e1ac6.js → Plane-4c3d403b.js} +1 -1
  30. package/Build/Workers/{PolygonGeometryLibrary-38a98276.js → PolygonGeometryLibrary-59126025.js} +1 -1
  31. package/Build/Workers/PolygonPipeline-1fe328c0.js +1344 -0
  32. package/Build/Workers/{PolylinePipeline-30e4cec9.js → PolylinePipeline-896735cc.js} +1 -1
  33. package/Build/Workers/{PolylineVolumeGeometryLibrary-90551d26.js → PolylineVolumeGeometryLibrary-9c0639f7.js} +1 -1
  34. package/Build/Workers/{PrimitivePipeline-558d9cb0.js → PrimitivePipeline-fc1a47ff.js} +1 -1
  35. package/Build/Workers/{RectangleGeometryLibrary-815c68df.js → RectangleGeometryLibrary-a23c9ebe.js} +1 -1
  36. package/Build/Workers/{TerrainEncoding-341ead52.js → TerrainEncoding-51b8b33b.js} +1 -1
  37. package/Build/Workers/Transforms-bc45e707.js +14699 -0
  38. package/Build/Workers/{WallGeometryLibrary-ccf90976.js → WallGeometryLibrary-007e9883.js} +1 -1
  39. package/Build/Workers/{WebMercatorProjection-76a3fcc0.js → WebMercatorProjection-13ed1a6e.js} +1 -1
  40. package/Build/Workers/{arrayRemoveDuplicates-fac118a8.js → arrayRemoveDuplicates-d2061e85.js} +1 -1
  41. package/Build/Workers/cesiumWorkerBootstrapper.js +1 -1
  42. package/Build/Workers/combineGeometry.js +1 -1
  43. package/Build/Workers/createBoxGeometry.js +1 -1
  44. package/Build/Workers/createBoxOutlineGeometry.js +1 -1
  45. package/Build/Workers/createCircleGeometry.js +1 -1
  46. package/Build/Workers/createCircleOutlineGeometry.js +1 -1
  47. package/Build/Workers/createCoplanarPolygonGeometry.js +1 -1
  48. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +1 -1
  49. package/Build/Workers/createCorridorGeometry.js +1 -1
  50. package/Build/Workers/createCorridorOutlineGeometry.js +1 -1
  51. package/Build/Workers/createCylinderGeometry.js +1 -1
  52. package/Build/Workers/createCylinderOutlineGeometry.js +1 -1
  53. package/Build/Workers/createEllipseGeometry.js +1 -1
  54. package/Build/Workers/createEllipseOutlineGeometry.js +1 -1
  55. package/Build/Workers/createEllipsoidGeometry.js +1 -1
  56. package/Build/Workers/createEllipsoidOutlineGeometry.js +1 -1
  57. package/Build/Workers/createFrustumGeometry.js +1 -1
  58. package/Build/Workers/createFrustumOutlineGeometry.js +1 -1
  59. package/Build/Workers/createGeometry.js +1 -1
  60. package/Build/Workers/createGroundPolylineGeometry.js +1 -1
  61. package/Build/Workers/createPlaneGeometry.js +1 -1
  62. package/Build/Workers/createPlaneOutlineGeometry.js +1 -1
  63. package/Build/Workers/createPolygonGeometry.js +1 -1
  64. package/Build/Workers/createPolygonOutlineGeometry.js +1 -1
  65. package/Build/Workers/createPolylineGeometry.js +1 -1
  66. package/Build/Workers/createPolylineVolumeGeometry.js +1 -1
  67. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +1 -1
  68. package/Build/Workers/createRectangleGeometry.js +1 -1
  69. package/Build/Workers/createRectangleOutlineGeometry.js +1 -1
  70. package/Build/Workers/createSimplePolylineGeometry.js +1 -1
  71. package/Build/Workers/createSphereGeometry.js +1 -1
  72. package/Build/Workers/createSphereOutlineGeometry.js +1 -1
  73. package/Build/Workers/createVectorTileClampedPolylines.js +1 -1
  74. package/Build/Workers/createVectorTileGeometries.js +1 -1
  75. package/Build/Workers/createVectorTilePoints.js +1 -1
  76. package/Build/Workers/createVectorTilePolygons.js +1 -1
  77. package/Build/Workers/createVectorTilePolylines.js +1 -1
  78. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +1 -1
  79. package/Build/Workers/createVerticesFromHeightmap.js +5 -8
  80. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +10 -15
  81. package/Build/Workers/createWallGeometry.js +1 -1
  82. package/Build/Workers/createWallOutlineGeometry.js +1 -1
  83. package/Build/Workers/decodeDraco.js +1 -1
  84. package/Build/Workers/decodeI3S.js +1 -1
  85. package/Build/Workers/package.js +1 -1
  86. package/Build/Workers/transferTypedArrayTest.js +1 -1
  87. package/Build/Workers/upsampleQuantizedTerrainMesh.js +1 -1
  88. package/Source/Core/ArcGISTiledElevationTerrainProvider.js +291 -191
  89. package/Source/Core/BingMapsGeocoderService.js +19 -1
  90. package/Source/Core/CartographicGeocoderService.js +15 -0
  91. package/Source/Core/CesiumTerrainProvider.js +571 -434
  92. package/Source/Core/Credit.js +1 -1
  93. package/Source/Core/CustomHeightmapTerrainProvider.js +12 -0
  94. package/Source/Core/EllipsoidTerrainProvider.js +17 -10
  95. package/Source/Core/FrustumGeometry.js +4 -3
  96. package/Source/Core/GeocoderService.js +32 -1
  97. package/Source/Core/GoogleEarthEnterpriseMetadata.js +86 -34
  98. package/Source/Core/GoogleEarthEnterpriseTerrainProvider.js +119 -82
  99. package/Source/Core/Ion.js +1 -1
  100. package/Source/Core/IonGeocoderService.js +17 -2
  101. package/Source/Core/IonResource.js +14 -3
  102. package/Source/Core/OpenCageGeocoderService.js +18 -1
  103. package/Source/Core/OrientedBoundingBox.js +4 -2
  104. package/Source/Core/OrthographicFrustum.js +13 -0
  105. package/Source/Core/PeliasGeocoderService.js +14 -1
  106. package/Source/Core/PerspectiveFrustum.js +14 -0
  107. package/Source/Core/Request.js +3 -2
  108. package/Source/Core/RequestScheduler.js +10 -5
  109. package/Source/Core/Resource.js +230 -236
  110. package/Source/Core/TerrainProvider.js +9 -14
  111. package/Source/Core/TileProviderError.js +8 -8
  112. package/Source/Core/VRTheWorldTerrainProvider.js +193 -124
  113. package/Source/Core/buildModuleUrl.js +4 -3
  114. package/Source/Core/createWorldTerrain.js +20 -2
  115. package/Source/Core/createWorldTerrainAsync.js +48 -0
  116. package/Source/Core/sampleTerrain.js +9 -10
  117. package/Source/Core/sampleTerrainMostDetailed.js +66 -72
  118. package/Source/DataSources/Cesium3DTilesetVisualizer.js +37 -26
  119. package/Source/DataSources/DataSourceDisplay.js +2 -2
  120. package/Source/DataSources/Entity.js +6 -1
  121. package/Source/DataSources/EntityCluster.js +126 -128
  122. package/Source/DataSources/ModelVisualizer.js +104 -34
  123. package/Source/DataSources/PolygonGraphics.js +1 -1
  124. package/Source/Renderer/UniformState.js +3 -2
  125. package/Source/Renderer/demodernizeShader.js +5 -5
  126. package/Source/Scene/ArcGisBaseMapType.js +12 -0
  127. package/Source/Scene/ArcGisMapServerImageryProvider.js +694 -376
  128. package/Source/Scene/ArcGisMapService.js +83 -0
  129. package/Source/Scene/BingMapsImageryProvider.js +511 -305
  130. package/Source/Scene/BufferLoader.js +29 -34
  131. package/Source/Scene/Camera.js +8 -7
  132. package/Source/Scene/Cesium3DTile.js +392 -254
  133. package/Source/Scene/Cesium3DTileBatchTable.js +2 -2
  134. package/Source/Scene/Cesium3DTileContent.js +16 -0
  135. package/Source/Scene/Cesium3DTileContentFactory.js +4 -4
  136. package/Source/Scene/Cesium3DTilePass.js +8 -11
  137. package/Source/Scene/Cesium3DTileStyleEngine.js +1 -1
  138. package/Source/Scene/Cesium3DTilesVoxelProvider.js +225 -117
  139. package/Source/Scene/Cesium3DTileset.js +756 -482
  140. package/Source/Scene/Cesium3DTilesetBaseTraversal.js +301 -0
  141. package/Source/Scene/Cesium3DTilesetMostDetailedTraversal.js +33 -46
  142. package/Source/Scene/Cesium3DTilesetSkipTraversal.js +421 -0
  143. package/Source/Scene/Cesium3DTilesetTraversal.js +219 -671
  144. package/Source/Scene/ClassificationPrimitive.js +7 -0
  145. package/Source/Scene/Composite3DTileContent.js +69 -26
  146. package/Source/Scene/CreditDisplay.js +132 -20
  147. package/Source/Scene/DepthPlane.js +1 -1
  148. package/Source/Scene/Empty3DTileContent.js +31 -1
  149. package/Source/Scene/Geometry3DTileContent.js +47 -7
  150. package/Source/Scene/Globe.js +5 -1
  151. package/Source/Scene/GlobeSurfaceTile.js +2 -1
  152. package/Source/Scene/GlobeSurfaceTileProvider.js +53 -30
  153. package/Source/Scene/GltfBufferViewLoader.js +47 -91
  154. package/Source/Scene/GltfDracoLoader.js +110 -112
  155. package/Source/Scene/GltfImageLoader.js +71 -78
  156. package/Source/Scene/GltfIndexBufferLoader.js +108 -121
  157. package/Source/Scene/GltfJsonLoader.js +87 -74
  158. package/Source/Scene/GltfLoader.js +381 -300
  159. package/Source/Scene/GltfStructuralMetadataLoader.js +109 -110
  160. package/Source/Scene/GltfTextureLoader.js +97 -96
  161. package/Source/Scene/GltfVertexBufferLoader.js +128 -133
  162. package/Source/Scene/GoogleEarthEnterpriseImageryProvider.js +353 -225
  163. package/Source/Scene/GoogleEarthEnterpriseMapsProvider.js +491 -331
  164. package/Source/Scene/GridImageryProvider.js +267 -104
  165. package/Source/Scene/GroundPolylinePrimitive.js +12 -1
  166. package/Source/Scene/GroundPrimitive.js +8 -1
  167. package/Source/Scene/I3SDataProvider.js +214 -113
  168. package/Source/Scene/I3SFeature.js +7 -6
  169. package/Source/Scene/I3SLayer.js +26 -37
  170. package/Source/Scene/I3SNode.js +59 -66
  171. package/Source/Scene/Imagery.js +6 -1
  172. package/Source/Scene/ImageryLayer.js +299 -48
  173. package/Source/Scene/ImageryLayerCollection.js +26 -0
  174. package/Source/Scene/ImageryProvider.js +129 -111
  175. package/Source/Scene/Implicit3DTileContent.js +72 -23
  176. package/Source/Scene/ImplicitSubtree.js +66 -45
  177. package/Source/Scene/IonImageryProvider.js +482 -275
  178. package/Source/Scene/MapboxImageryProvider.js +272 -112
  179. package/Source/Scene/MapboxStyleImageryProvider.js +270 -111
  180. package/Source/Scene/MetadataSchemaLoader.js +26 -36
  181. package/Source/Scene/Model/B3dmLoader.js +42 -46
  182. package/Source/Scene/Model/GeoJsonLoader.js +8 -32
  183. package/Source/Scene/Model/I3dmLoader.js +48 -74
  184. package/Source/Scene/Model/MaterialPipelineStage.js +12 -12
  185. package/Source/Scene/Model/Model.js +514 -135
  186. package/Source/Scene/Model/Model3DTileContent.js +83 -31
  187. package/Source/Scene/Model/ModelAnimationCollection.js +3 -3
  188. package/Source/Scene/Model/ModelDrawCommand.js +15 -26
  189. package/Source/Scene/Model/ModelUtility.js +16 -16
  190. package/Source/Scene/Model/PntsLoader.js +27 -32
  191. package/Source/Scene/Model/UniformType.js +1 -1
  192. package/Source/Scene/Multiple3DTileContent.js +134 -115
  193. package/Source/Scene/Picking.js +3 -2
  194. package/Source/Scene/PointCloud.js +11 -19
  195. package/Source/Scene/Primitive.js +20 -0
  196. package/Source/Scene/QuadtreePrimitive.js +5 -2
  197. package/Source/Scene/QuadtreeTileProvider.js +4 -8
  198. package/Source/Scene/ResourceCache.js +47 -105
  199. package/Source/Scene/ResourceCacheStatistics.js +24 -58
  200. package/Source/Scene/ResourceLoader.js +5 -17
  201. package/Source/Scene/ResourceLoaderState.js +12 -4
  202. package/Source/Scene/Scene.js +65 -0
  203. package/Source/Scene/SceneTransforms.js +3 -2
  204. package/Source/Scene/ScreenSpaceCameraController.js +2 -2
  205. package/Source/Scene/SingleTileImageryProvider.js +382 -209
  206. package/Source/Scene/Terrain.js +196 -0
  207. package/Source/Scene/TileCoordinatesImageryProvider.js +267 -104
  208. package/Source/Scene/TileMapServiceImageryProvider.js +177 -85
  209. package/Source/Scene/Tileset3DTileContent.js +47 -5
  210. package/Source/Scene/TimeDynamicPointCloud.js +15 -2
  211. package/Source/Scene/UrlTemplateImageryProvider.js +343 -215
  212. package/Source/Scene/Vector3DTileClampedPolylines.js +96 -84
  213. package/Source/Scene/Vector3DTileContent.js +47 -22
  214. package/Source/Scene/Vector3DTileGeometry.js +57 -52
  215. package/Source/Scene/Vector3DTilePoints.js +97 -81
  216. package/Source/Scene/Vector3DTilePolygons.js +118 -117
  217. package/Source/Scene/Vector3DTilePolylines.js +86 -82
  218. package/Source/Scene/Vector3DTilePrimitive.js +0 -1
  219. package/Source/Scene/VoxelContent.js +61 -63
  220. package/Source/Scene/VoxelPrimitive.js +39 -91
  221. package/Source/Scene/VoxelProvider.js +2 -2
  222. package/Source/Scene/WebMapServiceImageryProvider.js +272 -111
  223. package/Source/Scene/WebMapTileServiceImageryProvider.js +270 -107
  224. package/Source/Scene/computeFlyToLocationForRectangle.js +33 -37
  225. package/Source/Scene/createOsmBuildings.js +6 -0
  226. package/Source/Scene/createOsmBuildingsAsync.js +82 -0
  227. package/Source/Scene/createWorldImagery.js +14 -5
  228. package/Source/Scene/createWorldImageryAsync.js +39 -0
  229. package/Source/Shaders/AtmosphereCommon.glsl +51 -8
  230. package/Source/Shaders/AtmosphereCommon.js +51 -8
  231. package/Source/Shaders/PostProcessStages/AmbientOcclusionGenerate.glsl +1 -1
  232. package/Source/Shaders/PostProcessStages/AmbientOcclusionGenerate.js +1 -1
  233. package/Source/Shaders/PostProcessStages/AmbientOcclusionModulate.glsl +3 -3
  234. package/Source/Shaders/PostProcessStages/AmbientOcclusionModulate.js +3 -3
  235. package/Source/Widget/CesiumWidget.js +67 -27
  236. package/index.d.ts +2429 -1475
  237. package/index.js +324 -315
  238. package/package.json +4 -4
  239. package/Build/Workers/PolygonPipeline-d31ff61c.js +0 -1345
  240. package/Build/Workers/Transforms-9e9df299.js +0 -14714
@@ -1,4 +1,5 @@
1
1
  import defaultValue from "../Core/defaultValue.js";
2
+ import deprecationWarning from "../Core/deprecationWarning.js";
2
3
  import IonImageryProvider from "./IonImageryProvider.js";
3
4
  import IonWorldImageryStyle from "./IonWorldImageryStyle.js";
4
5
 
@@ -10,17 +11,18 @@ import IonWorldImageryStyle from "./IonWorldImageryStyle.js";
10
11
  * @param {object} [options] Object with the following properties:
11
12
  * @param {IonWorldImageryStyle} [options.style=IonWorldImageryStyle] The style of base imagery, only AERIAL, AERIAL_WITH_LABELS, and ROAD are currently supported.
12
13
  * @returns {IonImageryProvider}
14
+ * @deprecated
13
15
  *
14
16
  * @see Ion
15
17
  *
16
18
  * @example
17
- * // Create Cesium World Terrain with default settings
19
+ * // Create Cesium World Imagery with default settings
18
20
  * const viewer = new Cesium.Viewer('cesiumContainer', {
19
21
  * imageryProvider : Cesium.createWorldImagery();
20
22
  * });
21
23
  *
22
24
  * @example
23
- * // Create Cesium World Terrain with water and normals.
25
+ * // Create Cesium World Imagery with a different style
24
26
  * const viewer = new Cesium.Viewer('cesiumContainer', {
25
27
  * imageryProvider : Cesium.createWorldImagery({
26
28
  * style: Cesium.IonWorldImageryStyle.AERIAL_WITH_LABELS
@@ -29,10 +31,17 @@ import IonWorldImageryStyle from "./IonWorldImageryStyle.js";
29
31
  *
30
32
  */
31
33
  function createWorldImagery(options) {
34
+ deprecationWarning(
35
+ "createWorldImagery",
36
+ "createWorldImagery was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use createWorldImageryAsync instead."
37
+ );
38
+
32
39
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
33
40
  const style = defaultValue(options.style, IonWorldImageryStyle.AERIAL);
34
- return new IonImageryProvider({
35
- assetId: style,
36
- });
41
+ const provider = new IonImageryProvider();
42
+
43
+ // This is here for backwards compatibility
44
+ IonImageryProvider._initialize(provider, style, options);
45
+ return provider;
37
46
  }
38
47
  export default createWorldImagery;
@@ -0,0 +1,39 @@
1
+ import defaultValue from "../Core/defaultValue.js";
2
+ import IonImageryProvider from "./IonImageryProvider.js";
3
+ import IonWorldImageryStyle from "./IonWorldImageryStyle.js";
4
+
5
+ /**
6
+ * Creates an {@link IonImageryProvider} instance for ion's default global base imagery layer, currently Bing Maps.
7
+ *
8
+ * @function
9
+ *
10
+ * @param {Object} [options] Object with the following properties:
11
+ * @param {IonWorldImageryStyle} [options.style=IonWorldImageryStyle] The style of base imagery, only AERIAL, AERIAL_WITH_LABELS, and ROAD are currently supported.
12
+ * @returns {Promise<IonImageryProvider>}
13
+ *
14
+ * @see Ion
15
+ *
16
+ * @example
17
+ * // Create a Cesium World Imagery base layer with default settings
18
+ * try {
19
+ * const imageryProvider = await Cesium.createWorldImageryAsync();
20
+ * } catch (error) {
21
+ * console.log(`There was an error creating world imagery: ${error}`);
22
+ * }
23
+ *
24
+ * @example
25
+ * // Create Cesium World Imagery with different style
26
+ * try {
27
+ * const imageryProvider = await Cesium.createWorldImageryAsync({
28
+ * style: Cesium.IonWorldImageryStyle.AERIAL_WITH_LABELS
29
+ * });
30
+ * } catch (error) {
31
+ * console.log(`There was an error creating world imagery: ${error}`);
32
+ * }
33
+ */
34
+ function createWorldImageryAsync(options) {
35
+ options = defaultValue(options, defaultValue.EMPTY_OBJECT);
36
+ const style = defaultValue(options.style, IonWorldImageryStyle.AERIAL);
37
+ return IonImageryProvider.fromAssetId(style);
38
+ }
39
+ export default createWorldImageryAsync;
@@ -8,8 +8,16 @@ uniform vec3 u_atmosphereRayleighCoefficient;
8
8
  uniform vec3 u_atmosphereMieCoefficient;
9
9
 
10
10
  const float ATMOSPHERE_THICKNESS = 111e3; // The thickness of the atmosphere in meters.
11
- const int PRIMARY_STEPS = 16; // Number of times the ray from the camera to the world position (primary ray) is sampled.
12
- const int LIGHT_STEPS = 4; // Number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.
11
+ const int PRIMARY_STEPS_MAX = 16; // Maximum number of times the ray from the camera to the world position (primary ray) is sampled.
12
+ const int LIGHT_STEPS_MAX = 4; // Maximum number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.
13
+
14
+ /**
15
+ * Rational approximation to tanh(x)
16
+ */
17
+ float approximateTanh(float x) {
18
+ float x2 = x * x;
19
+ return max(-1.0, min(+1.0, x * (27.0 + x2) / (27.0 + 9.0 * x2)));
20
+ }
13
21
 
14
22
  /**
15
23
  * This function computes the colors contributed by Rayliegh and Mie scattering on a given ray, as well as
@@ -50,14 +58,36 @@ void computeScattering(
50
58
  return;
51
59
  }
52
60
 
61
+ // To deal with smaller values of PRIMARY_STEPS (e.g. 4)
62
+ // we implement a split strategy: sky or horizon.
63
+ // For performance reasons, instead of a if/else branch
64
+ // a soft choice is implemented through a weight 0.0 <= w_stop_gt_lprl <= 1.0
65
+ float x = 1e-7 * primaryRayAtmosphereIntersect.stop / length(primaryRayLength);
66
+ // Value close to 0.0: close to the horizon
67
+ // Value close to 1.0: above in the sky
68
+ float w_stop_gt_lprl = 0.5 * (1.0 + approximateTanh(x));
69
+
53
70
  // The ray should start from the first intersection with the outer atmopshere, or from the camera position, if it is inside the atmosphere.
71
+ float start_0 = primaryRayAtmosphereIntersect.start;
54
72
  primaryRayAtmosphereIntersect.start = max(primaryRayAtmosphereIntersect.start, 0.0);
55
73
  // The ray should end at the exit from the atmosphere or at the distance to the vertex, whichever is smaller.
56
74
  primaryRayAtmosphereIntersect.stop = min(primaryRayAtmosphereIntersect.stop, length(primaryRayLength));
57
75
 
76
+ // For the number of ray steps, distinguish inside or outside atmosphere (outer space)
77
+ // (1) from outer space we have to use more ray steps to get a realistic rendering
78
+ // (2) within atmosphere we need fewer steps for faster rendering
79
+ float x_o_a = start_0 - ATMOSPHERE_THICKNESS; // ATMOSPHERE_THICKNESS used as an ad-hoc constant, no precise meaning here, only the order of magnitude matters
80
+ float w_inside_atmosphere = 1.0 - 0.5 * (1.0 + approximateTanh(x_o_a));
81
+ int PRIMARY_STEPS = PRIMARY_STEPS_MAX - int(w_inside_atmosphere * 12.0); // Number of times the ray from the camera to the world position (primary ray) is sampled.
82
+ int LIGHT_STEPS = LIGHT_STEPS_MAX - int(w_inside_atmosphere * 2.0); // Number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.
83
+
58
84
  // Setup for sampling positions along the ray - starting from the intersection with the outer ring of the atmosphere.
59
- float rayStepLength = (primaryRayAtmosphereIntersect.stop - primaryRayAtmosphereIntersect.start) / float(PRIMARY_STEPS);
60
85
  float rayPositionLength = primaryRayAtmosphereIntersect.start;
86
+ // (1) Outside the atmosphere: constant rayStepLength
87
+ // (2) Inside atmosphere: variable rayStepLength to compensate the rough rendering of the smaller number of ray steps
88
+ float totalRayLength = primaryRayAtmosphereIntersect.stop - rayPositionLength;
89
+ float rayStepLengthIncrease = w_inside_atmosphere * ((1.0 - w_stop_gt_lprl) * totalRayLength / (float(PRIMARY_STEPS * (PRIMARY_STEPS + 1)) / 2.0));
90
+ float rayStepLength = max(1.0 - w_inside_atmosphere, w_stop_gt_lprl) * totalRayLength / max(7.0 * w_inside_atmosphere, float(PRIMARY_STEPS));
61
91
 
62
92
  vec3 rayleighAccumulation = vec3(0.0);
63
93
  vec3 mieAccumulation = vec3(0.0);
@@ -65,10 +95,17 @@ void computeScattering(
65
95
  vec2 heightScale = vec2(u_atmosphereRayleighScaleHeight, u_atmosphereMieScaleHeight);
66
96
 
67
97
  // Sample positions on the primary ray.
68
- for (int i = 0; i < PRIMARY_STEPS; i++) {
98
+ for (int i = 0; i < PRIMARY_STEPS_MAX; ++i) {
99
+
100
+ // The loop should be: for (int i = 0; i < PRIMARY_STEPS; ++i) {...} but WebGL1 cannot
101
+ // loop with non-constant condition, so it has to break early instead
102
+ if (i >= PRIMARY_STEPS) {
103
+ break;
104
+ }
105
+
69
106
  // Calculate sample position along viewpoint ray.
70
107
  vec3 samplePosition = primaryRay.origin + primaryRay.direction * (rayPositionLength + rayStepLength);
71
-
108
+
72
109
  // Calculate height of sample position above ellipsoid.
73
110
  float sampleHeight = length(samplePosition) - atmosphereInnerRadius;
74
111
 
@@ -79,14 +116,20 @@ void computeScattering(
79
116
  // Generate ray from the sample position segment to the light source, up to the outer ring of the atmosphere.
80
117
  czm_ray lightRay = czm_ray(samplePosition, lightDirection);
81
118
  czm_raySegment lightRayAtmosphereIntersect = czm_raySphereIntersectionInterval(lightRay, origin, atmosphereOuterRadius);
82
-
119
+
83
120
  float lightStepLength = lightRayAtmosphereIntersect.stop / float(LIGHT_STEPS);
84
121
  float lightPositionLength = 0.0;
85
122
 
86
123
  vec2 lightOpticalDepth = vec2(0.0);
87
124
 
88
125
  // Sample positions along the light ray, to accumulate incidence of light on the latest sample segment.
89
- for (int j = 0; j < LIGHT_STEPS; j++) {
126
+ for (int j = 0; j < LIGHT_STEPS_MAX; ++j) {
127
+
128
+ // The loop should be: for (int j = 0; i < LIGHT_STEPS; ++j) {...} but WebGL1 cannot
129
+ // loop with non-constant condition, so it has to break early instead
130
+ if (j >= LIGHT_STEPS) {
131
+ break;
132
+ }
90
133
 
91
134
  // Calculate sample position along light ray.
92
135
  vec3 lightPosition = samplePosition + lightDirection * (lightPositionLength + lightStepLength * 0.5);
@@ -109,7 +152,7 @@ void computeScattering(
109
152
  mieAccumulation += sampleDensity.y * attenuation;
110
153
 
111
154
  // Increment distance on primary ray.
112
- rayPositionLength += rayStepLength;
155
+ rayPositionLength += (rayStepLength += rayStepLengthIncrease);
113
156
  }
114
157
 
115
158
  // Compute the scattering amount.
@@ -9,8 +9,16 @@ uniform vec3 u_atmosphereRayleighCoefficient;\n\
9
9
  uniform vec3 u_atmosphereMieCoefficient;\n\
10
10
  \n\
11
11
  const float ATMOSPHERE_THICKNESS = 111e3; // The thickness of the atmosphere in meters.\n\
12
- const int PRIMARY_STEPS = 16; // Number of times the ray from the camera to the world position (primary ray) is sampled.\n\
13
- const int LIGHT_STEPS = 4; // Number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.\n\
12
+ const int PRIMARY_STEPS_MAX = 16; // Maximum number of times the ray from the camera to the world position (primary ray) is sampled.\n\
13
+ const int LIGHT_STEPS_MAX = 4; // Maximum number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.\n\
14
+ \n\
15
+ /**\n\
16
+ * Rational approximation to tanh(x)\n\
17
+ */\n\
18
+ float approximateTanh(float x) {\n\
19
+ float x2 = x * x;\n\
20
+ return max(-1.0, min(+1.0, x * (27.0 + x2) / (27.0 + 9.0 * x2)));\n\
21
+ }\n\
14
22
  \n\
15
23
  /**\n\
16
24
  * This function computes the colors contributed by Rayliegh and Mie scattering on a given ray, as well as\n\
@@ -51,14 +59,36 @@ void computeScattering(\n\
51
59
  return;\n\
52
60
  }\n\
53
61
  \n\
62
+ // To deal with smaller values of PRIMARY_STEPS (e.g. 4)\n\
63
+ // we implement a split strategy: sky or horizon.\n\
64
+ // For performance reasons, instead of a if/else branch\n\
65
+ // a soft choice is implemented through a weight 0.0 <= w_stop_gt_lprl <= 1.0\n\
66
+ float x = 1e-7 * primaryRayAtmosphereIntersect.stop / length(primaryRayLength);\n\
67
+ // Value close to 0.0: close to the horizon\n\
68
+ // Value close to 1.0: above in the sky\n\
69
+ float w_stop_gt_lprl = 0.5 * (1.0 + approximateTanh(x));\n\
70
+ \n\
54
71
  // The ray should start from the first intersection with the outer atmopshere, or from the camera position, if it is inside the atmosphere.\n\
72
+ float start_0 = primaryRayAtmosphereIntersect.start;\n\
55
73
  primaryRayAtmosphereIntersect.start = max(primaryRayAtmosphereIntersect.start, 0.0);\n\
56
74
  // The ray should end at the exit from the atmosphere or at the distance to the vertex, whichever is smaller.\n\
57
75
  primaryRayAtmosphereIntersect.stop = min(primaryRayAtmosphereIntersect.stop, length(primaryRayLength));\n\
76
+ \n\
77
+ // For the number of ray steps, distinguish inside or outside atmosphere (outer space)\n\
78
+ // (1) from outer space we have to use more ray steps to get a realistic rendering\n\
79
+ // (2) within atmosphere we need fewer steps for faster rendering\n\
80
+ float x_o_a = start_0 - ATMOSPHERE_THICKNESS; // ATMOSPHERE_THICKNESS used as an ad-hoc constant, no precise meaning here, only the order of magnitude matters\n\
81
+ float w_inside_atmosphere = 1.0 - 0.5 * (1.0 + approximateTanh(x_o_a));\n\
82
+ int PRIMARY_STEPS = PRIMARY_STEPS_MAX - int(w_inside_atmosphere * 12.0); // Number of times the ray from the camera to the world position (primary ray) is sampled.\n\
83
+ int LIGHT_STEPS = LIGHT_STEPS_MAX - int(w_inside_atmosphere * 2.0); // Number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.\n\
58
84
  \n\
59
85
  // Setup for sampling positions along the ray - starting from the intersection with the outer ring of the atmosphere.\n\
60
- float rayStepLength = (primaryRayAtmosphereIntersect.stop - primaryRayAtmosphereIntersect.start) / float(PRIMARY_STEPS);\n\
61
86
  float rayPositionLength = primaryRayAtmosphereIntersect.start;\n\
87
+ // (1) Outside the atmosphere: constant rayStepLength\n\
88
+ // (2) Inside atmosphere: variable rayStepLength to compensate the rough rendering of the smaller number of ray steps\n\
89
+ float totalRayLength = primaryRayAtmosphereIntersect.stop - rayPositionLength;\n\
90
+ float rayStepLengthIncrease = w_inside_atmosphere * ((1.0 - w_stop_gt_lprl) * totalRayLength / (float(PRIMARY_STEPS * (PRIMARY_STEPS + 1)) / 2.0));\n\
91
+ float rayStepLength = max(1.0 - w_inside_atmosphere, w_stop_gt_lprl) * totalRayLength / max(7.0 * w_inside_atmosphere, float(PRIMARY_STEPS));\n\
62
92
  \n\
63
93
  vec3 rayleighAccumulation = vec3(0.0);\n\
64
94
  vec3 mieAccumulation = vec3(0.0);\n\
@@ -66,10 +96,17 @@ void computeScattering(\n\
66
96
  vec2 heightScale = vec2(u_atmosphereRayleighScaleHeight, u_atmosphereMieScaleHeight);\n\
67
97
  \n\
68
98
  // Sample positions on the primary ray.\n\
69
- for (int i = 0; i < PRIMARY_STEPS; i++) {\n\
99
+ for (int i = 0; i < PRIMARY_STEPS_MAX; ++i) {\n\
100
+ \n\
101
+ // The loop should be: for (int i = 0; i < PRIMARY_STEPS; ++i) {...} but WebGL1 cannot\n\
102
+ // loop with non-constant condition, so it has to break early instead\n\
103
+ if (i >= PRIMARY_STEPS) {\n\
104
+ break;\n\
105
+ }\n\
106
+ \n\
70
107
  // Calculate sample position along viewpoint ray.\n\
71
108
  vec3 samplePosition = primaryRay.origin + primaryRay.direction * (rayPositionLength + rayStepLength);\n\
72
- \n\
109
+ \n\
73
110
  // Calculate height of sample position above ellipsoid.\n\
74
111
  float sampleHeight = length(samplePosition) - atmosphereInnerRadius;\n\
75
112
  \n\
@@ -80,14 +117,20 @@ void computeScattering(\n\
80
117
  // Generate ray from the sample position segment to the light source, up to the outer ring of the atmosphere.\n\
81
118
  czm_ray lightRay = czm_ray(samplePosition, lightDirection);\n\
82
119
  czm_raySegment lightRayAtmosphereIntersect = czm_raySphereIntersectionInterval(lightRay, origin, atmosphereOuterRadius);\n\
83
- \n\
120
+ \n\
84
121
  float lightStepLength = lightRayAtmosphereIntersect.stop / float(LIGHT_STEPS);\n\
85
122
  float lightPositionLength = 0.0;\n\
86
123
  \n\
87
124
  vec2 lightOpticalDepth = vec2(0.0);\n\
88
125
  \n\
89
126
  // Sample positions along the light ray, to accumulate incidence of light on the latest sample segment.\n\
90
- for (int j = 0; j < LIGHT_STEPS; j++) {\n\
127
+ for (int j = 0; j < LIGHT_STEPS_MAX; ++j) {\n\
128
+ \n\
129
+ // The loop should be: for (int j = 0; i < LIGHT_STEPS; ++j) {...} but WebGL1 cannot\n\
130
+ // loop with non-constant condition, so it has to break early instead\n\
131
+ if (j >= LIGHT_STEPS) {\n\
132
+ break;\n\
133
+ }\n\
91
134
  \n\
92
135
  // Calculate sample position along light ray.\n\
93
136
  vec3 lightPosition = samplePosition + lightDirection * (lightPositionLength + lightStepLength * 0.5);\n\
@@ -110,7 +153,7 @@ void computeScattering(\n\
110
153
  mieAccumulation += sampleDensity.y * attenuation;\n\
111
154
  \n\
112
155
  // Increment distance on primary ray.\n\
113
- rayPositionLength += rayStepLength;\n\
156
+ rayPositionLength += (rayStepLength += rayStepLengthIncrease);\n\
114
157
  }\n\
115
158
  \n\
116
159
  // Compute the scattering amount.\n\
@@ -58,7 +58,7 @@ void main(void)
58
58
  float gapAngle = 90.0 * czm_radiansPerDegree;
59
59
 
60
60
  // RandomNoise
61
- float randomVal = texture(randomTexture, v_textureCoordinates).x;
61
+ float randomVal = texture(randomTexture, v_textureCoordinates / pixelSize / 255.0).x;
62
62
 
63
63
  //Loop for each direction
64
64
  for (int i = 0; i < 4; i++)
@@ -59,7 +59,7 @@ void main(void)\n\
59
59
  float gapAngle = 90.0 * czm_radiansPerDegree;\n\
60
60
  \n\
61
61
  // RandomNoise\n\
62
- float randomVal = texture(randomTexture, v_textureCoordinates).x;\n\
62
+ float randomVal = texture(randomTexture, v_textureCoordinates / pixelSize / 255.0).x;\n\
63
63
  \n\
64
64
  //Loop for each direction\n\
65
65
  for (int i = 0; i < 4; i++)\n\
@@ -5,7 +5,7 @@ in vec2 v_textureCoordinates;
5
5
 
6
6
  void main(void)
7
7
  {
8
- vec3 color = texture(colorTexture, v_textureCoordinates).rgb;
9
- vec3 ao = texture(ambientOcclusionTexture, v_textureCoordinates).rgb;
10
- out_FragColor.rgb = ambientOcclusionOnly ? ao : ao * color;
8
+ vec4 color = texture(colorTexture, v_textureCoordinates);
9
+ vec4 ao = texture(ambientOcclusionTexture, v_textureCoordinates);
10
+ out_FragColor = ambientOcclusionOnly ? ao : ao * color;
11
11
  }
@@ -6,8 +6,8 @@ in vec2 v_textureCoordinates;\n\
6
6
  \n\
7
7
  void main(void)\n\
8
8
  {\n\
9
- vec3 color = texture(colorTexture, v_textureCoordinates).rgb;\n\
10
- vec3 ao = texture(ambientOcclusionTexture, v_textureCoordinates).rgb;\n\
11
- out_FragColor.rgb = ambientOcclusionOnly ? ao : ao * color;\n\
9
+ vec4 color = texture(colorTexture, v_textureCoordinates);\n\
10
+ vec4 ao = texture(ambientOcclusionTexture, v_textureCoordinates);\n\
11
+ out_FragColor = ambientOcclusionOnly ? ao : ao * color;\n\
12
12
  }\n\
13
13
  ";
@@ -1,9 +1,9 @@
1
1
  import buildModuleUrl from "../Core/buildModuleUrl.js";
2
- import createWorldImagery from "../Scene/createWorldImagery.js";
3
2
  import Cartesian3 from "../Core/Cartesian3.js";
4
3
  import Clock from "../Core/Clock.js";
5
4
  import defaultValue from "../Core/defaultValue.js";
6
5
  import defined from "../Core/defined.js";
6
+ import deprecationWarning from "../Core/deprecationWarning.js";
7
7
  import destroyObject from "../Core/destroyObject.js";
8
8
  import DeveloperError from "../Core/DeveloperError.js";
9
9
  import Ellipsoid from "../Core/Ellipsoid.js";
@@ -11,6 +11,7 @@ import FeatureDetection from "../Core/FeatureDetection.js";
11
11
  import formatError from "../Core/formatError.js";
12
12
  import getElement from "../DataSources/getElement.js";
13
13
  import Globe from "../Scene/Globe.js";
14
+ import ImageryLayer from "../Scene/ImageryLayer.js";
14
15
  import Moon from "../Scene/Moon.js";
15
16
  import Scene from "../Scene/Scene.js";
16
17
  import SceneMode from "../Scene/SceneMode.js";
@@ -123,8 +124,10 @@ function configureCameraFrustum(widget) {
123
124
  * @param {Element|string} container The DOM element or ID that will contain the widget.
124
125
  * @param {object} [options] Object with the following properties:
125
126
  * @param {Clock} [options.clock=new Clock()] The clock to use to control current time.
126
- * @param {ImageryProvider | false} [options.imageryProvider=createWorldImagery()] The imagery provider to serve as the base layer. If set to <code>false</code>, no imagery provider will be added.
127
+ * @param {ImageryProvider | false} [options.imageryProvider=createWorldImagery()] The imagery provider to serve as the base layer. If set to <code>false</code>, no imagery provider will be added. Deprecated.
128
+ * @param {ImageryLayer|false} [baseLayer=ImageryLayer.fromWorldImagery()] The bottommost imagery layer applied to the globe. If set to <code>false</code>, no imagery provider will be added.
127
129
  * @param {TerrainProvider} [options.terrainProvider=new EllipsoidTerrainProvider] The terrain provider.
130
+ * @param {Terrain} [options.terrain] A terrain object which handles asynchronous terrain provider. Can only specify if options.terrainProvider is undefined.
128
131
  * @param {SkyBox| false} [options.skyBox] The skybox used to render the stars. When <code>undefined</code>, the default stars are used. If set to <code>false</code>, no skyBox, Sun, or Moon will be added.
129
132
  * @param {SkyAtmosphere | false} [options.skyAtmosphere] Blue sky, and the glow around the Earth's limb. Set to <code>false</code> to turn it off.
130
133
  * @param {SceneMode} [options.sceneMode=SceneMode.SCENE3D] The initial scene mode.
@@ -156,26 +159,26 @@ function configureCameraFrustum(widget) {
156
159
  * // For each example, include a link to CesiumWidget.css stylesheet in HTML head,
157
160
  * // and in the body, include: <div id="cesiumContainer"></div>
158
161
  *
159
- * //Widget with no terrain and default Bing Maps imagery provider.
160
- * const widget = new Cesium.CesiumWidget('cesiumContainer');
162
+ * // Widget with no terrain and default Bing Maps imagery provider.
163
+ * const widget = new Cesium.CesiumWidget("cesiumContainer");
161
164
  *
162
- * //Widget with ion imagery and Cesium World Terrain.
163
- * const widget2 = new Cesium.CesiumWidget('cesiumContainer', {
164
- * imageryProvider : Cesium.createWorldImagery(),
165
- * terrainProvider : Cesium.createWorldTerrain(),
166
- * skyBox : new Cesium.SkyBox({
167
- * sources : {
168
- * positiveX : 'stars/TychoSkymapII.t3_08192x04096_80_px.jpg',
169
- * negativeX : 'stars/TychoSkymapII.t3_08192x04096_80_mx.jpg',
170
- * positiveY : 'stars/TychoSkymapII.t3_08192x04096_80_py.jpg',
171
- * negativeY : 'stars/TychoSkymapII.t3_08192x04096_80_my.jpg',
172
- * positiveZ : 'stars/TychoSkymapII.t3_08192x04096_80_pz.jpg',
173
- * negativeZ : 'stars/TychoSkymapII.t3_08192x04096_80_mz.jpg'
174
- * }
165
+ * // Widget with ion imagery and Cesium World Terrain.
166
+ * const widget2 = new Cesium.CesiumWidget("cesiumContainer", {
167
+ * baseLayer: Cesium.ImageryLayer.fromWorldTerrain(),
168
+ * terrain: Cesium.Terrain.fromWorldTerrain()
169
+ * skyBox: new Cesium.SkyBox({
170
+ * sources: {
171
+ * positiveX: "stars/TychoSkymapII.t3_08192x04096_80_px.jpg",
172
+ * negativeX: "stars/TychoSkymapII.t3_08192x04096_80_mx.jpg",
173
+ * positiveY: "stars/TychoSkymapII.t3_08192x04096_80_py.jpg",
174
+ * negativeY: "stars/TychoSkymapII.t3_08192x04096_80_my.jpg",
175
+ * positiveZ: "stars/TychoSkymapII.t3_08192x04096_80_pz.jpg",
176
+ * negativeZ: "stars/TychoSkymapII.t3_08192x04096_80_mz.jpg"
177
+ * }
175
178
  * }),
176
179
  * // Show Columbus View map with Web Mercator projection
177
- * sceneMode : Cesium.SceneMode.COLUMBUS_VIEW,
178
- * mapProjection : new Cesium.WebMercatorProjection()
180
+ * sceneMode: Cesium.SceneMode.COLUMBUS_VIEW,
181
+ * mapProjection: new Cesium.WebMercatorProjection()
179
182
  * });
180
183
  */
181
184
  function CesiumWidget(container, options) {
@@ -340,22 +343,47 @@ function CesiumWidget(container, options) {
340
343
  scene.skyAtmosphere = skyAtmosphere;
341
344
  }
342
345
 
343
- //Set the base imagery layer
344
- let imageryProvider =
345
- options.globe === false ? false : options.imageryProvider;
346
- if (!defined(imageryProvider)) {
347
- imageryProvider = createWorldImagery();
346
+ if (defined(options.imageryProvider)) {
347
+ deprecationWarning(
348
+ "CesiumWidget options.imageryProvider",
349
+ "options.imageryProvider was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use options.baseLayer instead."
350
+ );
348
351
  }
349
352
 
350
- if (imageryProvider !== false) {
351
- scene.imageryLayers.addImageryProvider(imageryProvider);
353
+ // Set the base imagery layer
354
+ let baseLayer = options.baseLayer;
355
+ if (
356
+ options.globe !== false &&
357
+ baseLayer !== false &&
358
+ options.imageryProvider !== false
359
+ ) {
360
+ if (defined(options.imageryProvider) && !defined(baseLayer)) {
361
+ baseLayer = new ImageryLayer(options.imageryProvider);
362
+ }
363
+
364
+ if (!defined(baseLayer)) {
365
+ baseLayer = ImageryLayer.fromWorldImagery();
366
+ }
367
+ scene.imageryLayers.add(baseLayer);
352
368
  }
353
369
 
354
- //Set the terrain provider if one is provided.
370
+ // Set the terrain provider if one is provided.
355
371
  if (defined(options.terrainProvider) && options.globe !== false) {
356
372
  scene.terrainProvider = options.terrainProvider;
357
373
  }
358
374
 
375
+ if (defined(options.terrain) && options.globe !== false) {
376
+ //>>includeStart('debug', pragmas.debug);
377
+ if (defined(options.terrainProvider)) {
378
+ throw new DeveloperError(
379
+ "Specify either options.terrainProvider or options.terrain."
380
+ );
381
+ }
382
+ //>>includeEnd('debug')
383
+
384
+ scene.setTerrain(options.terrain);
385
+ }
386
+
359
387
  this._screenSpaceEventHandler = new ScreenSpaceEventHandler(canvas);
360
388
 
361
389
  if (defined(options.sceneMode)) {
@@ -492,6 +520,18 @@ Object.defineProperties(CesiumWidget.prototype, {
492
520
  },
493
521
  },
494
522
 
523
+ /**
524
+ * Manages the list of credits to display on screen and in the lightbox.
525
+ * @memberof CesiumWidget.prototype
526
+ *
527
+ * @type {CreditDisplay}
528
+ */
529
+ creditDisplay: {
530
+ get: function () {
531
+ return this._scene.frameState.creditDisplay;
532
+ },
533
+ },
534
+
495
535
  /**
496
536
  * Gets the camera.
497
537
  * @memberof CesiumWidget.prototype