@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,9 +1,13 @@
1
1
  import Cartesian2 from "../Core/Cartesian2.js";
2
2
  import Cartesian4 from "../Core/Cartesian4.js";
3
+ import Check from "../Core/Check.js";
4
+ import createWorldImageryAsync from "../Scene/createWorldImageryAsync.js";
3
5
  import defaultValue from "../Core/defaultValue.js";
4
6
  import defined from "../Core/defined.js";
5
7
  import destroyObject from "../Core/destroyObject.js";
8
+ import deprecationWarning from "../Core/deprecationWarning.js";
6
9
  import DeveloperError from "../Core/DeveloperError.js";
10
+ import Event from "../Core/Event.js";
7
11
  import FeatureDetection from "../Core/FeatureDetection.js";
8
12
  import GeographicProjection from "../Core/GeographicProjection.js";
9
13
  import IndexDatatype from "../Core/IndexDatatype.js";
@@ -37,35 +41,31 @@ import SplitDirection from "./SplitDirection.js";
37
41
  import TileImagery from "./TileImagery.js";
38
42
 
39
43
  /**
40
- * An imagery layer that displays tiled image data from a single imagery provider
41
- * on a {@link Globe}.
44
+ * @typedef {Object} ImageryLayer.ConstructorOptions
42
45
  *
43
- * @alias ImageryLayer
44
- * @constructor
46
+ * Initialization options for the ImageryLayer constructor.
45
47
  *
46
- * @param {ImageryProvider} imageryProvider The imagery provider to use.
47
- * @param {object} [options] Object with the following properties:
48
- * @param {Rectangle} [options.rectangle=imageryProvider.rectangle] The rectangle of the layer. This rectangle
48
+ * @property {Rectangle} [rectangle=imageryProvider.rectangle] The rectangle of the layer. This rectangle
49
49
  * can limit the visible portion of the imagery provider.
50
- * @param {number|Function} [options.alpha=1.0] The alpha blending value of this layer, from 0.0 to 1.0.
50
+ * @property {number|Function} [alpha=1.0] The alpha blending value of this layer, from 0.0 to 1.0.
51
51
  * This can either be a simple number or a function with the signature
52
52
  * <code>function(frameState, layer, x, y, level)</code>. The function is passed the
53
53
  * current frame state, this layer, and the x, y, and level coordinates of the
54
54
  * imagery tile for which the alpha is required, and it is expected to return
55
55
  * the alpha value to use for the tile.
56
- * @param {number|Function} [options.nightAlpha=1.0] The alpha blending value of this layer on the night side of the globe, from 0.0 to 1.0.
56
+ * @property {number|Function} [nightAlpha=1.0] The alpha blending value of this layer on the night side of the globe, from 0.0 to 1.0.
57
57
  * This can either be a simple number or a function with the signature
58
58
  * <code>function(frameState, layer, x, y, level)</code>. The function is passed the
59
59
  * current frame state, this layer, and the x, y, and level coordinates of the
60
60
  * imagery tile for which the alpha is required, and it is expected to return
61
61
  * the alpha value to use for the tile. This only takes effect when <code>enableLighting</code> is <code>true</code>.
62
- * @param {number|Function} [options.dayAlpha=1.0] The alpha blending value of this layer on the day side of the globe, from 0.0 to 1.0.
62
+ * @property {number|Function} [dayAlpha=1.0] The alpha blending value of this layer on the day side of the globe, from 0.0 to 1.0.
63
63
  * This can either be a simple number or a function with the signature
64
64
  * <code>function(frameState, layer, x, y, level)</code>. The function is passed the
65
65
  * current frame state, this layer, and the x, y, and level coordinates of the
66
66
  * imagery tile for which the alpha is required, and it is expected to return
67
67
  * the alpha value to use for the tile. This only takes effect when <code>enableLighting</code> is <code>true</code>.
68
- * @param {number|Function} [options.brightness=1.0] The brightness of this layer. 1.0 uses the unmodified imagery
68
+ * @property {number|Function} [brightness=1.0] The brightness of this layer. 1.0 uses the unmodified imagery
69
69
  * color. Less than 1.0 makes the imagery darker while greater than 1.0 makes it brighter.
70
70
  * This can either be a simple number or a function with the signature
71
71
  * <code>function(frameState, layer, x, y, level)</code>. The function is passed the
@@ -73,7 +73,7 @@ import TileImagery from "./TileImagery.js";
73
73
  * imagery tile for which the brightness is required, and it is expected to return
74
74
  * the brightness value to use for the tile. The function is executed for every
75
75
  * frame and for every tile, so it must be fast.
76
- * @param {number|Function} [options.contrast=1.0] The contrast of this layer. 1.0 uses the unmodified imagery color.
76
+ * @property {number|Function} [contrast=1.0] The contrast of this layer. 1.0 uses the unmodified imagery color.
77
77
  * Less than 1.0 reduces the contrast while greater than 1.0 increases it.
78
78
  * This can either be a simple number or a function with the signature
79
79
  * <code>function(frameState, layer, x, y, level)</code>. The function is passed the
@@ -81,14 +81,14 @@ import TileImagery from "./TileImagery.js";
81
81
  * imagery tile for which the contrast is required, and it is expected to return
82
82
  * the contrast value to use for the tile. The function is executed for every
83
83
  * frame and for every tile, so it must be fast.
84
- * @param {number|Function} [options.hue=0.0] The hue of this layer. 0.0 uses the unmodified imagery color.
84
+ * @property {number|Function} [hue=0.0] The hue of this layer. 0.0 uses the unmodified imagery color.
85
85
  * This can either be a simple number or a function with the signature
86
86
  * <code>function(frameState, layer, x, y, level)</code>. The function is passed the
87
87
  * current frame state, this layer, and the x, y, and level coordinates
88
88
  * of the imagery tile for which the hue is required, and it is expected to return
89
89
  * the contrast value to use for the tile. The function is executed for every
90
90
  * frame and for every tile, so it must be fast.
91
- * @param {number|Function} [options.saturation=1.0] The saturation of this layer. 1.0 uses the unmodified imagery color.
91
+ * @property {number|Function} [saturation=1.0] The saturation of this layer. 1.0 uses the unmodified imagery color.
92
92
  * Less than 1.0 reduces the saturation while greater than 1.0 increases it.
93
93
  * This can either be a simple number or a function with the signature
94
94
  * <code>function(frameState, layer, x, y, level)</code>. The function is passed the
@@ -96,39 +96,75 @@ import TileImagery from "./TileImagery.js";
96
96
  * of the imagery tile for which the saturation is required, and it is expected to return
97
97
  * the contrast value to use for the tile. The function is executed for every
98
98
  * frame and for every tile, so it must be fast.
99
- * @param {number|Function} [options.gamma=1.0] The gamma correction to apply to this layer. 1.0 uses the unmodified imagery color.
99
+ * @property {number|Function} [gamma=1.0] The gamma correction to apply to this layer. 1.0 uses the unmodified imagery color.
100
100
  * This can either be a simple number or a function with the signature
101
101
  * <code>function(frameState, layer, x, y, level)</code>. The function is passed the
102
102
  * current frame state, this layer, and the x, y, and level coordinates of the
103
103
  * imagery tile for which the gamma is required, and it is expected to return
104
104
  * the gamma value to use for the tile. The function is executed for every
105
105
  * frame and for every tile, so it must be fast.
106
- * @param {SplitDirection|Function} [options.splitDirection=SplitDirection.NONE] The {@link SplitDirection} split to apply to this layer.
107
- * @param {TextureMinificationFilter} [options.minificationFilter=TextureMinificationFilter.LINEAR] The
106
+ * @property {SplitDirection|Function} [splitDirection=SplitDirection.NONE] The {@link SplitDirection} split to apply to this layer.
107
+ * @property {TextureMinificationFilter} [minificationFilter=TextureMinificationFilter.LINEAR] The
108
108
  * texture minification filter to apply to this layer. Possible values
109
109
  * are <code>TextureMinificationFilter.LINEAR</code> and
110
110
  * <code>TextureMinificationFilter.NEAREST</code>.
111
- * @param {TextureMagnificationFilter} [options.magnificationFilter=TextureMagnificationFilter.LINEAR] The
111
+ * @property {TextureMagnificationFilter} [magnificationFilter=TextureMagnificationFilter.LINEAR] The
112
112
  * texture minification filter to apply to this layer. Possible values
113
113
  * are <code>TextureMagnificationFilter.LINEAR</code> and
114
114
  * <code>TextureMagnificationFilter.NEAREST</code>.
115
- * @param {boolean} [options.show=true] True if the layer is shown; otherwise, false.
116
- * @param {number} [options.maximumAnisotropy=maximum supported] The maximum anisotropy level to use
115
+ * @property {boolean} [show=true] True if the layer is shown; otherwise, false.
116
+ * @property {number} [maximumAnisotropy=maximum supported] The maximum anisotropy level to use
117
117
  * for texture filtering. If this parameter is not specified, the maximum anisotropy supported
118
118
  * by the WebGL stack will be used. Larger values make the imagery look better in horizon
119
119
  * views.
120
- * @param {number} [options.minimumTerrainLevel] The minimum terrain level-of-detail at which to show this imagery layer,
120
+ * @property {number} [minimumTerrainLevel] The minimum terrain level-of-detail at which to show this imagery layer,
121
121
  * or undefined to show it at all levels. Level zero is the least-detailed level.
122
- * @param {number} [options.maximumTerrainLevel] The maximum terrain level-of-detail at which to show this imagery layer,
122
+ * @property {number} [maximumTerrainLevel] The maximum terrain level-of-detail at which to show this imagery layer,
123
123
  * or undefined to show it at all levels. Level zero is the least-detailed level.
124
- * @param {Rectangle} [options.cutoutRectangle] Cartographic rectangle for cutting out a portion of this ImageryLayer.
125
- * @param {Color} [options.colorToAlpha] Color to be used as alpha.
126
- * @param {number} [options.colorToAlphaThreshold=0.004] Threshold for color-to-alpha.
124
+ * @property {Rectangle} [cutoutRectangle] Cartographic rectangle for cutting out a portion of this ImageryLayer.
125
+ * @property {Color} [colorToAlpha] Color to be used as alpha.
126
+ * @property {number} [colorToAlphaThreshold=0.004] Threshold for color-to-alpha.
127
+ */
128
+
129
+ /**
130
+ * An imagery layer that displays tiled image data from a single imagery provider
131
+ * on a {@link Globe}.
132
+ *
133
+ * @alias ImageryLayer
134
+ * @constructor
135
+ *
136
+ * @param {ImageryProvider} imageryProvider The imagery provider to use.
137
+ * @param {ImageryLayer.ConstructorOptions} options An object describing initialization options
138
+ *
139
+ * @see ImageryLayer.fromProviderAsync
140
+ * @see ImageryLayer.fromWorldImagery
141
+ *
142
+ * @example
143
+ * // Add an OpenStreetMaps layer
144
+ * const imageryLayer = new Cesium.ImageryLayer(OpenStreetMapImageryProvider({
145
+ * url: "https://a.tile.openstreetmap.org/"
146
+ * })),
147
+ * scene.imageryLayers.add(imageryLayer);
148
+ *
149
+ * @example
150
+ * // Add Cesium ion's default world imagery layer
151
+ * const imageryLayer = Cesium.ImageryLayer.fromWorldImagery();
152
+ * scene.imageryLayers.add(imageryLayer);
153
+ *
154
+ * @example
155
+ * // Add a new transparent layer from Cesium ion
156
+ * const imageryLayer = Cesium.ImageryLayer.fromProviderAsync(Cesium.IonImageryProvider.fromAssetId(3812));
157
+ * imageryLayer.alpha = 0.5;
158
+ * scene.imageryLayers.add(imageryLayer);
127
159
  */
128
160
  function ImageryLayer(imageryProvider, options) {
129
161
  this._imageryProvider = imageryProvider;
130
162
 
163
+ this._readyEvent = new Event();
164
+ this._errorEvent = new Event();
165
+
131
166
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
167
+ imageryProvider = defaultValue(imageryProvider, defaultValue.EMPTY_OBJECT);
132
168
 
133
169
  /**
134
170
  * The alpha blending value of this layer, with 0.0 representing fully transparent and
@@ -139,7 +175,7 @@ function ImageryLayer(imageryProvider, options) {
139
175
  */
140
176
  this.alpha = defaultValue(
141
177
  options.alpha,
142
- defaultValue(imageryProvider.defaultAlpha, 1.0)
178
+ defaultValue(imageryProvider._defaultAlpha, 1.0)
143
179
  );
144
180
 
145
181
  /**
@@ -151,7 +187,7 @@ function ImageryLayer(imageryProvider, options) {
151
187
  */
152
188
  this.nightAlpha = defaultValue(
153
189
  options.nightAlpha,
154
- defaultValue(imageryProvider.defaultNightAlpha, 1.0)
190
+ defaultValue(imageryProvider._defaultNightAlpha, 1.0)
155
191
  );
156
192
 
157
193
  /**
@@ -163,7 +199,7 @@ function ImageryLayer(imageryProvider, options) {
163
199
  */
164
200
  this.dayAlpha = defaultValue(
165
201
  options.dayAlpha,
166
- defaultValue(imageryProvider.defaultDayAlpha, 1.0)
202
+ defaultValue(imageryProvider._defaultDayAlpha, 1.0)
167
203
  );
168
204
 
169
205
  /**
@@ -176,7 +212,7 @@ function ImageryLayer(imageryProvider, options) {
176
212
  this.brightness = defaultValue(
177
213
  options.brightness,
178
214
  defaultValue(
179
- imageryProvider.defaultBrightness,
215
+ imageryProvider._defaultBrightness,
180
216
  ImageryLayer.DEFAULT_BRIGHTNESS
181
217
  )
182
218
  );
@@ -190,7 +226,10 @@ function ImageryLayer(imageryProvider, options) {
190
226
  */
191
227
  this.contrast = defaultValue(
192
228
  options.contrast,
193
- defaultValue(imageryProvider.defaultContrast, ImageryLayer.DEFAULT_CONTRAST)
229
+ defaultValue(
230
+ imageryProvider._defaultContrast,
231
+ ImageryLayer.DEFAULT_CONTRAST
232
+ )
194
233
  );
195
234
 
196
235
  /**
@@ -201,7 +240,7 @@ function ImageryLayer(imageryProvider, options) {
201
240
  */
202
241
  this.hue = defaultValue(
203
242
  options.hue,
204
- defaultValue(imageryProvider.defaultHue, ImageryLayer.DEFAULT_HUE)
243
+ defaultValue(imageryProvider._defaultHue, ImageryLayer.DEFAULT_HUE)
205
244
  );
206
245
 
207
246
  /**
@@ -214,7 +253,7 @@ function ImageryLayer(imageryProvider, options) {
214
253
  this.saturation = defaultValue(
215
254
  options.saturation,
216
255
  defaultValue(
217
- imageryProvider.defaultSaturation,
256
+ imageryProvider._defaultSaturation,
218
257
  ImageryLayer.DEFAULT_SATURATION
219
258
  )
220
259
  );
@@ -227,7 +266,7 @@ function ImageryLayer(imageryProvider, options) {
227
266
  */
228
267
  this.gamma = defaultValue(
229
268
  options.gamma,
230
- defaultValue(imageryProvider.defaultGamma, ImageryLayer.DEFAULT_GAMMA)
269
+ defaultValue(imageryProvider._defaultGamma, ImageryLayer.DEFAULT_GAMMA)
231
270
  );
232
271
 
233
272
  /**
@@ -238,7 +277,7 @@ function ImageryLayer(imageryProvider, options) {
238
277
  */
239
278
  this.splitDirection = defaultValue(
240
279
  options.splitDirection,
241
- defaultValue(imageryProvider.defaultSplit, ImageryLayer.DEFAULT_SPLIT)
280
+ ImageryLayer.DEFAULT_SPLIT
242
281
  );
243
282
 
244
283
  /**
@@ -255,7 +294,7 @@ function ImageryLayer(imageryProvider, options) {
255
294
  this.minificationFilter = defaultValue(
256
295
  options.minificationFilter,
257
296
  defaultValue(
258
- imageryProvider.defaultMinificationFilter,
297
+ imageryProvider._defaultMinificationFilter,
259
298
  ImageryLayer.DEFAULT_MINIFICATION_FILTER
260
299
  )
261
300
  );
@@ -274,7 +313,7 @@ function ImageryLayer(imageryProvider, options) {
274
313
  this.magnificationFilter = defaultValue(
275
314
  options.magnificationFilter,
276
315
  defaultValue(
277
- imageryProvider.defaultMagnificationFilter,
316
+ imageryProvider._defaultMagnificationFilter,
278
317
  ImageryLayer.DEFAULT_MAGNIFICATION_FILTER
279
318
  )
280
319
  );
@@ -337,7 +376,7 @@ function ImageryLayer(imageryProvider, options) {
337
376
 
338
377
  Object.defineProperties(ImageryLayer.prototype, {
339
378
  /**
340
- * Gets the imagery provider for this layer.
379
+ * Gets the imagery provider for this layer. This should not be called before {@link ImageryLayer#ready} returns true.
341
380
  * @memberof ImageryLayer.prototype
342
381
  * @type {ImageryProvider}
343
382
  * @readonly
@@ -348,6 +387,45 @@ Object.defineProperties(ImageryLayer.prototype, {
348
387
  },
349
388
  },
350
389
 
390
+ /**
391
+ * Returns true when the terrain provider has been successfully created. Otherwise, returns false.
392
+ * @memberof ImageryLayer.prototype
393
+ * @type {boolean}
394
+ * @readonly
395
+ */
396
+ ready: {
397
+ get: function () {
398
+ return defined(this._imageryProvider);
399
+ },
400
+ },
401
+
402
+ /**
403
+ * Gets an event that is raised when the imagery provider encounters an asynchronous error. By subscribing
404
+ * to the event, you will be notified of the error and can potentially recover from it. Event listeners
405
+ * are passed an instance of the thrown error.
406
+ * @memberof Imagery.prototype
407
+ * @type {Event<Imagery.ErrorEventCallback>}
408
+ * @readonly
409
+ */
410
+ errorEvent: {
411
+ get: function () {
412
+ return this._errorEvent;
413
+ },
414
+ },
415
+
416
+ /**
417
+ * Gets an event that is raised when the imagery provider has been successfully created. Event listeners
418
+ * are passed the created instance of {@link ImageryProvider}.
419
+ * @memberof ImageryLayer.prototype
420
+ * @type {Event<ImageryLayer.ReadyEventCallback>}
421
+ * @readonly
422
+ */
423
+ readyEvent: {
424
+ get: function () {
425
+ return this._readyEvent;
426
+ },
427
+ },
428
+
351
429
  /**
352
430
  * Gets the rectangle of this layer. If this rectangle is smaller than the rectangle of the
353
431
  * {@link ImageryProvider}, only a portion of the imagery provider is shown.
@@ -430,6 +508,113 @@ ImageryLayer.DEFAULT_MAGNIFICATION_FILTER = TextureMagnificationFilter.LINEAR;
430
508
  */
431
509
  ImageryLayer.DEFAULT_APPLY_COLOR_TO_ALPHA_THRESHOLD = 0.004;
432
510
 
511
+ /**
512
+ * Create a new imagery layer from an asynchronous imagery provider. The layer will handle any asynchronous loads or errors, and begin rendering the imagery layer once ready.
513
+ *
514
+ * @param {Promise<ImageryProvider>} imageryProviderPromise A promise which resolves to a imagery provider
515
+ * @param {ImageryLayer.ConstructorOptions} options An object describing initialization options
516
+ * @returns {ImageryLayer} The created imagery layer.
517
+ *
518
+ * @example
519
+ * // Create a new base layer
520
+ * const viewer = new Cesium.Viewer("cesiumContainer", {
521
+ * baseLayer: Cesium.ImageryLayer.fromProviderAsync(Cesium.IonImageryProvider.fromAssetId(3812));
522
+ * });
523
+ *
524
+ * @example
525
+ * // Add a new transparent layer
526
+ * const imageryLayer = Cesium.ImageryLayer.fromProviderAsync(Cesium.IonImageryProvider.fromAssetId(3812));
527
+ * imageryLayer.alpha = 0.5;
528
+ * viewer.imageryLayers.add(imageryLayer);
529
+ *
530
+ * @example
531
+ * // Handle loading events
532
+ * const imageryLayer = Cesium.ImageryLayer.fromProviderAsync(Cesium.IonImageryProvider.fromAssetId(3812));
533
+ * viewer.imageryLayers.add(imageryLayer);
534
+ *
535
+ * imageryLayer.readyEvent.addEventListener(provider => {
536
+ * imageryLayer.provider.errorEvent.addEventListener(error => {
537
+ * alert(`Encountered an error while loading imagery tiles! ${error}`);
538
+ * });
539
+ * });
540
+ *
541
+ * imageryLayer.errorEvent.addEventListener(error => {
542
+ * alert(`Encountered an error while creating an imagery layer! ${error}`);
543
+ * });
544
+ *
545
+ * @see ImageryLayer.errorEvent
546
+ * @see ImageryLayer.readyEvent
547
+ * @see ImageryLayer.provider
548
+ * @see ImageryLayer.fromWorldImagery
549
+ */
550
+ ImageryLayer.fromProviderAsync = function (imageryProviderPromise, options) {
551
+ //>>includeStart('debug', pragmas.debug);
552
+ Check.typeOf.object("imageryProviderPromise", imageryProviderPromise);
553
+ //>>includeEnd('debug');
554
+
555
+ const layer = new ImageryLayer(undefined, options);
556
+
557
+ handlePromise(layer, Promise.resolve(imageryProviderPromise));
558
+
559
+ return layer;
560
+ };
561
+
562
+ /**
563
+ * @typedef {ImageryLayer.ConstructorOptions} ImageryLayer.WorldImageryConstructorOptions
564
+ *
565
+ * Initialization options for ImageryLayer.fromWorldImagery
566
+ *
567
+ * @property {IonWorldImageryStyle} [options.style=IonWorldImageryStyle] The style of base imagery, only AERIAL, AERIAL_WITH_LABELS, and ROAD are currently supported.
568
+ */
569
+
570
+ /**
571
+ * Create a new imagery layer for ion's default global base imagery layer, currently Bing Maps. The layer will handle any asynchronous loads or errors, and begin rendering the imagery layer once ready.
572
+ *
573
+ * @param {ImageryLayer.WorldImageryConstructorOptions} options An object describing initialization options
574
+ * @returns {ImageryLayer} The created imagery layer.
575
+ *
576
+ * * @example
577
+ * // Create a new base layer
578
+ * const viewer = new Cesium.Viewer("cesiumContainer", {
579
+ * baseLayer: Cesium.ImageryLayer.fromWorldImagery();
580
+ * });
581
+ *
582
+ * @example
583
+ * // Add a new transparent layer
584
+ * const imageryLayer = Cesium.ImageryLayer.fromWorldImagery();
585
+ * imageryLayer.alpha = 0.5;
586
+ * viewer.imageryLayers.add(imageryLayer);
587
+ *
588
+ * @example
589
+ * // Handle loading events
590
+ * const imageryLayer = Cesium.ImageryLayer.fromWorldImagery();
591
+ * viewer.imageryLayers.add(imageryLayer);
592
+ *
593
+ * imageryLayer.readyEvent.addEventListener(provider => {
594
+ * imageryLayer.provider.errorEvent.addEventListener(error => {
595
+ * alert(`Encountered an error while loading imagery tiles! ${error}`);
596
+ * });
597
+ * });
598
+ *
599
+ * imageryLayer.errorEvent.addEventListener(error => {
600
+ * alert(`Encountered an error while creating an imagery layer! ${error}`);
601
+ * });
602
+ *
603
+ * @see ImageryLayer.errorEvent
604
+ * @see ImageryLayer.readyEvent
605
+ * @see ImageryLayer.provider
606
+ */
607
+ ImageryLayer.fromWorldImagery = function (options) {
608
+ options = defaultValue(options, defaultValue.EMPTY_OBJECT);
609
+
610
+ return ImageryLayer.fromProviderAsync(
611
+ createWorldImageryAsync({
612
+ style: options.style,
613
+ }),
614
+ options
615
+ );
616
+ };
617
+
433
618
  /**
434
619
  * Gets a value indicating whether this layer is the base layer in the
435
620
  * {@link ImageryLayerCollection}. The base layer is the one that underlies all
@@ -496,12 +681,37 @@ const terrainRectangleScratch = new Rectangle();
496
681
  * });
497
682
  * });
498
683
  */
499
- ImageryLayer.prototype.getViewableRectangle = function () {
684
+ ImageryLayer.prototype.getViewableRectangle = async function () {
685
+ deprecationWarning(
686
+ "ImageryLayer.getViewableRectangle",
687
+ "ImageryLayer.getViewableRectangle was deprecated in CesiumJS 1.104. It will be removed in CesiumJS 1.107. Use ImageryLayer.getImageryRectangle instead."
688
+ );
689
+
500
690
  const imageryProvider = this._imageryProvider;
501
691
  const rectangle = this._rectangle;
502
- return imageryProvider.readyPromise.then(function () {
503
- return Rectangle.intersection(imageryProvider.rectangle, rectangle);
504
- });
692
+ // readyPromise has been deprecated. This is here for backward compatibility and can be removed with readyPromise.
693
+ await imageryProvider._readyPromise;
694
+ return Rectangle.intersection(imageryProvider.rectangle, rectangle);
695
+ };
696
+
697
+ /**
698
+ * Computes the intersection of this layer's rectangle with the imagery provider's availability rectangle,
699
+ * producing the overall bounds of imagery that can be produced by this layer.
700
+ *
701
+ * @returns {Rectangle} A rectangle which defines the overall bounds of imagery that can be produced by this layer.
702
+ *
703
+ * @example
704
+ * // Zoom to an imagery layer.
705
+ * const imageryRectangle = imageryLayer.getImageryRectangle();
706
+ * scene.camera.flyTo({
707
+ * destination: rectangle
708
+ * });
709
+ *
710
+ */
711
+ ImageryLayer.prototype.getImageryRectangle = function () {
712
+ const imageryProvider = this._imageryProvider;
713
+ const rectangle = this._rectangle;
714
+ return Rectangle.intersection(imageryProvider.rectangle, rectangle);
505
715
  };
506
716
 
507
717
  /**
@@ -511,7 +721,7 @@ ImageryLayer.prototype.getViewableRectangle = function () {
511
721
  * @private
512
722
  *
513
723
  * @param {Tile} tile The terrain tile.
514
- * @param {TerrainProvider} terrainProvider The terrain provider associated with the terrain tile.
724
+ * @param {TerrainProvider|undefined} terrainProvider The terrain provider associated with the terrain tile.
515
725
  * @param {number} insertionPoint The position to insert new skeletons before in the tile's imagery list.
516
726
  * @returns {boolean} true if this layer overlaps any portion of the terrain tile; otherwise, false.
517
727
  */
@@ -523,8 +733,9 @@ ImageryLayer.prototype._createTileImagerySkeletons = function (
523
733
  const surfaceTile = tile.data;
524
734
 
525
735
  if (
526
- defined(this._minimumTerrainLevel) &&
527
- tile.level < this._minimumTerrainLevel
736
+ !defined(terrainProvider) ||
737
+ (defined(this._minimumTerrainLevel) &&
738
+ tile.level < this._minimumTerrainLevel)
528
739
  ) {
529
740
  return false;
530
741
  }
@@ -535,13 +746,13 @@ ImageryLayer.prototype._createTileImagerySkeletons = function (
535
746
  return false;
536
747
  }
537
748
 
538
- const imageryProvider = this._imageryProvider;
539
-
540
749
  if (!defined(insertionPoint)) {
541
750
  insertionPoint = surfaceTile.imagery.length;
542
751
  }
543
752
 
544
- if (!imageryProvider.ready) {
753
+ const imageryProvider = this._imageryProvider;
754
+ // ready is deprecated. This is here for backwards compatibility
755
+ if (!this.ready || !imageryProvider._ready) {
545
756
  // The imagery provider is not ready, so we can't create skeletons, yet.
546
757
  // Instead, add a placeholder so that we'll know to create
547
758
  // the skeletons once the provider is ready.
@@ -959,7 +1170,7 @@ ImageryLayer.prototype._requestImagery = function (imagery) {
959
1170
  return;
960
1171
  }
961
1172
 
962
- // Initially assume failure. handleError may retry, in which case the state will
1173
+ // Initially assume failure. An error handler may retry, in which case the state will
963
1174
  // change to TRANSITIONING.
964
1175
  imagery.state = ImageryState.FAILED;
965
1176
  imagery.request = undefined;
@@ -1538,4 +1749,44 @@ function getLevelWithMaximumTexelSpacing(
1538
1749
  const rounded = Math.round(level);
1539
1750
  return rounded | 0;
1540
1751
  }
1752
+
1753
+ function handleError(errorEvent, error) {
1754
+ if (errorEvent.numberOfListeners > 0) {
1755
+ errorEvent.raiseEvent(error);
1756
+ } else {
1757
+ // Default handler is to log to the console
1758
+ console.error(error);
1759
+ }
1760
+ }
1761
+
1762
+ async function handlePromise(instance, promise) {
1763
+ let provider;
1764
+ try {
1765
+ provider = await Promise.resolve(promise);
1766
+ if (instance.isDestroyed()) {
1767
+ return;
1768
+ }
1769
+ instance._imageryProvider = provider;
1770
+ instance._readyEvent.raiseEvent(provider);
1771
+ } catch (error) {
1772
+ handleError(instance._errorEvent, error);
1773
+ }
1774
+ }
1775
+
1541
1776
  export default ImageryLayer;
1777
+
1778
+ /**
1779
+ * A function that is called when an error occurs.
1780
+ * @callback ImageryLayer.ErrorEventCallback
1781
+ *
1782
+ * @this ImageryLayer
1783
+ * @param {Error} err An object holding details about the error that occurred.
1784
+ */
1785
+
1786
+ /**
1787
+ * A function that is called when the provider has been created
1788
+ * @callback ImageryLayer.ReadyEventCallback
1789
+ *
1790
+ * @this ImageryLayer
1791
+ * @param {ImageryProvider} provider The created imagery provider.
1792
+ */
@@ -76,6 +76,14 @@ Object.defineProperties(ImageryLayerCollection.prototype, {
76
76
  * be added on top of all existing layers.
77
77
  *
78
78
  * @exception {DeveloperError} index, if supplied, must be greater than or equal to zero and less than or equal to the number of the layers.
79
+ *
80
+ * @example
81
+ * const imageryLayer = Cesium.ImageryLayer.fromWorldImagery();
82
+ * scene.imageryLayers.add(imageryLayer);
83
+ *
84
+ * @example
85
+ * const imageryLayer = Cesium.ImageryLayer.fromProviderAsync(Cesium.IonImageryProvider.fromAssetId(3812));
86
+ * scene.imageryLayers.add(imageryLayer);
79
87
  */
80
88
  ImageryLayerCollection.prototype.add = function (layer, index) {
81
89
  const hasIndex = defined(index);
@@ -104,6 +112,10 @@ ImageryLayerCollection.prototype.add = function (layer, index) {
104
112
 
105
113
  this._update();
106
114
  this.layerAdded.raiseEvent(layer, index);
115
+ const removeReadyEventListener = layer.readyEvent.addEventListener(() => {
116
+ this.layerShownOrHidden.raiseEvent(layer, layer._layerIndex, layer.show);
117
+ removeReadyEventListener();
118
+ });
107
119
  };
108
120
 
109
121
  /**
@@ -113,6 +125,14 @@ ImageryLayerCollection.prototype.add = function (layer, index) {
113
125
  * @param {number} [index] the index to add the layer at. If omitted, the layer will
114
126
  * added on top of all existing layers.
115
127
  * @returns {ImageryLayer} The newly created layer.
128
+ *
129
+ * @example
130
+ * try {
131
+ * const provider = await Cesium.IonImageryProvider.fromAssetId(3812);
132
+ * scene.imageryLayers.addImageryProvider(provider);
133
+ * } catch (error) {
134
+ * console.log(`There was an error creating the imagery layer. ${error}`)
135
+ * }
116
136
  */
117
137
  ImageryLayerCollection.prototype.addImageryProvider = function (
118
138
  imageryProvider,
@@ -353,6 +373,9 @@ function pickImageryHelper(scene, pickedLocation, pickFeatures, callback) {
353
373
  if (!defined(imagery)) {
354
374
  continue;
355
375
  }
376
+ if (!imagery.imageryLayer.ready) {
377
+ continue;
378
+ }
356
379
  const provider = imagery.imageryLayer.imageryProvider;
357
380
  if (pickFeatures && !defined(provider.pickFeatures)) {
358
381
  continue;
@@ -476,6 +499,9 @@ ImageryLayerCollection.prototype.pickImageryLayerFeatures = function (
476
499
  const imageryLayers = [];
477
500
 
478
501
  pickImageryHelper(scene, pickedLocation, true, function (imagery) {
502
+ if (!imagery.imageryLayer.ready) {
503
+ return undefined;
504
+ }
479
505
  const provider = imagery.imageryLayer.imageryProvider;
480
506
  const promise = provider.pickFeatures(
481
507
  imagery.x,