@cesium/engine 2.1.0 → 2.2.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 (193) hide show
  1. package/Build/Workers/{AxisAlignedBoundingBox-a6f9f0e5.js → AxisAlignedBoundingBox-379015ef.js} +1 -1
  2. package/Build/Workers/{BoundingRectangle-b0a68595.js → BoundingRectangle-57f2b24f.js} +1 -1
  3. package/Build/Workers/{BoxGeometry-baedd794.js → BoxGeometry-ecabfc78.js} +1 -1
  4. package/Build/Workers/{Color-f85df1be.js → Color-14d1a36d.js} +1 -1
  5. package/Build/Workers/{CoplanarPolygonGeometryLibrary-30516950.js → CoplanarPolygonGeometryLibrary-048c3c14.js} +1 -1
  6. package/Build/Workers/{CorridorGeometryLibrary-5d5d3b3a.js → CorridorGeometryLibrary-520c8619.js} +1 -1
  7. package/Build/Workers/{CylinderGeometry-d899ae26.js → CylinderGeometry-119068b8.js} +1 -1
  8. package/Build/Workers/{EllipseGeometry-a49f8449.js → EllipseGeometry-2dfc3523.js} +1 -1
  9. package/Build/Workers/{EllipseGeometryLibrary-cba7edde.js → EllipseGeometryLibrary-0a1e0170.js} +1 -1
  10. package/Build/Workers/{EllipseOutlineGeometry-8095c8cb.js → EllipseOutlineGeometry-c5251669.js} +1 -1
  11. package/Build/Workers/{EllipsoidGeometry-ed93f571.js → EllipsoidGeometry-d10a5221.js} +1 -1
  12. package/Build/Workers/{EllipsoidOutlineGeometry-e4854854.js → EllipsoidOutlineGeometry-7039a0ae.js} +1 -1
  13. package/Build/Workers/{EllipsoidTangentPlane-7ae1aa9a.js → EllipsoidTangentPlane-857186be.js} +1 -1
  14. package/Build/Workers/{FrustumGeometry-b62db3e3.js → FrustumGeometry-400fa1b7.js} +2 -2
  15. package/Build/Workers/{GeometryAttribute-780af4fa.js → GeometryAttribute-7a2de5c6.js} +1 -1
  16. package/Build/Workers/{GeometryPipeline-36b61c99.js → GeometryPipeline-916636fa.js} +1 -1
  17. package/Build/Workers/{IntersectionTests-e889fcf0.js → IntersectionTests-b4d02d4d.js} +1 -1
  18. package/Build/Workers/{OrientedBoundingBox-43478ac8.js → OrientedBoundingBox-96fe1752.js} +5 -3
  19. package/Build/Workers/{PolygonGeometryLibrary-38a98276.js → PolygonGeometryLibrary-931f1ec6.js} +1 -1
  20. package/Build/Workers/{PolygonPipeline-d31ff61c.js → PolygonPipeline-32fc92cc.js} +1 -1
  21. package/Build/Workers/{PolylinePipeline-30e4cec9.js → PolylinePipeline-6d5c63e5.js} +1 -1
  22. package/Build/Workers/{PolylineVolumeGeometryLibrary-90551d26.js → PolylineVolumeGeometryLibrary-f068c1fb.js} +1 -1
  23. package/Build/Workers/{PrimitivePipeline-558d9cb0.js → PrimitivePipeline-879f996a.js} +1 -1
  24. package/Build/Workers/{RectangleGeometryLibrary-815c68df.js → RectangleGeometryLibrary-2d6f36f3.js} +1 -1
  25. package/Build/Workers/{TerrainEncoding-341ead52.js → TerrainEncoding-82882059.js} +1 -1
  26. package/Build/Workers/{Transforms-9e9df299.js → Transforms-9052372a.js} +6 -5
  27. package/Build/Workers/{WallGeometryLibrary-ccf90976.js → WallGeometryLibrary-db7a64fb.js} +1 -1
  28. package/Build/Workers/cesiumWorkerBootstrapper.js +1 -1
  29. package/Build/Workers/combineGeometry.js +1 -1
  30. package/Build/Workers/createBoxGeometry.js +1 -1
  31. package/Build/Workers/createBoxOutlineGeometry.js +1 -1
  32. package/Build/Workers/createCircleGeometry.js +1 -1
  33. package/Build/Workers/createCircleOutlineGeometry.js +1 -1
  34. package/Build/Workers/createCoplanarPolygonGeometry.js +1 -1
  35. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +1 -1
  36. package/Build/Workers/createCorridorGeometry.js +1 -1
  37. package/Build/Workers/createCorridorOutlineGeometry.js +1 -1
  38. package/Build/Workers/createCylinderGeometry.js +1 -1
  39. package/Build/Workers/createCylinderOutlineGeometry.js +1 -1
  40. package/Build/Workers/createEllipseGeometry.js +1 -1
  41. package/Build/Workers/createEllipseOutlineGeometry.js +1 -1
  42. package/Build/Workers/createEllipsoidGeometry.js +1 -1
  43. package/Build/Workers/createEllipsoidOutlineGeometry.js +1 -1
  44. package/Build/Workers/createFrustumGeometry.js +1 -1
  45. package/Build/Workers/createFrustumOutlineGeometry.js +1 -1
  46. package/Build/Workers/createGeometry.js +1 -1
  47. package/Build/Workers/createGroundPolylineGeometry.js +1 -1
  48. package/Build/Workers/createPlaneGeometry.js +1 -1
  49. package/Build/Workers/createPlaneOutlineGeometry.js +1 -1
  50. package/Build/Workers/createPolygonGeometry.js +1 -1
  51. package/Build/Workers/createPolygonOutlineGeometry.js +1 -1
  52. package/Build/Workers/createPolylineGeometry.js +1 -1
  53. package/Build/Workers/createPolylineVolumeGeometry.js +1 -1
  54. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +1 -1
  55. package/Build/Workers/createRectangleGeometry.js +1 -1
  56. package/Build/Workers/createRectangleOutlineGeometry.js +1 -1
  57. package/Build/Workers/createSimplePolylineGeometry.js +1 -1
  58. package/Build/Workers/createSphereGeometry.js +1 -1
  59. package/Build/Workers/createSphereOutlineGeometry.js +1 -1
  60. package/Build/Workers/createVectorTileGeometries.js +1 -1
  61. package/Build/Workers/createVectorTilePolygons.js +1 -1
  62. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +1 -1
  63. package/Build/Workers/createVerticesFromHeightmap.js +1 -1
  64. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +10 -15
  65. package/Build/Workers/createWallGeometry.js +1 -1
  66. package/Build/Workers/createWallOutlineGeometry.js +1 -1
  67. package/Build/Workers/package.js +1 -1
  68. package/Build/Workers/transferTypedArrayTest.js +1 -1
  69. package/Build/Workers/upsampleQuantizedTerrainMesh.js +1 -1
  70. package/Source/Core/ArcGISTiledElevationTerrainProvider.js +291 -191
  71. package/Source/Core/CesiumTerrainProvider.js +571 -434
  72. package/Source/Core/CustomHeightmapTerrainProvider.js +12 -0
  73. package/Source/Core/EllipsoidTerrainProvider.js +17 -10
  74. package/Source/Core/FrustumGeometry.js +1 -1
  75. package/Source/Core/GoogleEarthEnterpriseMetadata.js +86 -34
  76. package/Source/Core/GoogleEarthEnterpriseTerrainProvider.js +119 -82
  77. package/Source/Core/Ion.js +1 -1
  78. package/Source/Core/IonResource.js +14 -3
  79. package/Source/Core/OrientedBoundingBox.js +4 -2
  80. package/Source/Core/RequestScheduler.js +1 -1
  81. package/Source/Core/Resource.js +2 -2
  82. package/Source/Core/TerrainProvider.js +9 -14
  83. package/Source/Core/TileProviderError.js +8 -8
  84. package/Source/Core/VRTheWorldTerrainProvider.js +193 -124
  85. package/Source/Core/buildModuleUrl.js +4 -3
  86. package/Source/Core/createWorldTerrain.js +20 -2
  87. package/Source/Core/createWorldTerrainAsync.js +48 -0
  88. package/Source/Core/sampleTerrain.js +9 -10
  89. package/Source/Core/sampleTerrainMostDetailed.js +66 -72
  90. package/Source/DataSources/Cesium3DTilesetVisualizer.js +37 -26
  91. package/Source/DataSources/Entity.js +6 -1
  92. package/Source/DataSources/ModelVisualizer.js +99 -31
  93. package/Source/DataSources/PolygonGraphics.js +1 -1
  94. package/Source/Scene/ArcGisMapServerImageryProvider.js +552 -376
  95. package/Source/Scene/BingMapsImageryProvider.js +511 -305
  96. package/Source/Scene/BufferLoader.js +29 -34
  97. package/Source/Scene/Cesium3DTile.js +388 -251
  98. package/Source/Scene/Cesium3DTileBatchTable.js +2 -2
  99. package/Source/Scene/Cesium3DTileContent.js +16 -0
  100. package/Source/Scene/Cesium3DTileContentFactory.js +4 -4
  101. package/Source/Scene/Cesium3DTilePass.js +8 -11
  102. package/Source/Scene/Cesium3DTileStyleEngine.js +1 -1
  103. package/Source/Scene/Cesium3DTilesVoxelProvider.js +225 -117
  104. package/Source/Scene/Cesium3DTileset.js +755 -481
  105. package/Source/Scene/Cesium3DTilesetBaseTraversal.js +301 -0
  106. package/Source/Scene/Cesium3DTilesetMostDetailedTraversal.js +33 -46
  107. package/Source/Scene/Cesium3DTilesetSkipTraversal.js +421 -0
  108. package/Source/Scene/Cesium3DTilesetTraversal.js +219 -671
  109. package/Source/Scene/ClassificationPrimitive.js +7 -0
  110. package/Source/Scene/Composite3DTileContent.js +69 -26
  111. package/Source/Scene/CreditDisplay.js +20 -4
  112. package/Source/Scene/DepthPlane.js +1 -1
  113. package/Source/Scene/Empty3DTileContent.js +31 -1
  114. package/Source/Scene/Geometry3DTileContent.js +47 -7
  115. package/Source/Scene/Globe.js +5 -1
  116. package/Source/Scene/GlobeSurfaceTile.js +2 -1
  117. package/Source/Scene/GlobeSurfaceTileProvider.js +50 -27
  118. package/Source/Scene/GltfBufferViewLoader.js +47 -91
  119. package/Source/Scene/GltfDracoLoader.js +110 -112
  120. package/Source/Scene/GltfImageLoader.js +71 -78
  121. package/Source/Scene/GltfIndexBufferLoader.js +108 -121
  122. package/Source/Scene/GltfJsonLoader.js +75 -74
  123. package/Source/Scene/GltfLoader.js +392 -280
  124. package/Source/Scene/GltfStructuralMetadataLoader.js +109 -110
  125. package/Source/Scene/GltfTextureLoader.js +97 -96
  126. package/Source/Scene/GltfVertexBufferLoader.js +128 -133
  127. package/Source/Scene/GoogleEarthEnterpriseImageryProvider.js +353 -225
  128. package/Source/Scene/GoogleEarthEnterpriseMapsProvider.js +491 -331
  129. package/Source/Scene/GridImageryProvider.js +267 -104
  130. package/Source/Scene/GroundPolylinePrimitive.js +12 -1
  131. package/Source/Scene/GroundPrimitive.js +8 -1
  132. package/Source/Scene/I3SDataProvider.js +214 -113
  133. package/Source/Scene/I3SFeature.js +7 -6
  134. package/Source/Scene/I3SLayer.js +26 -37
  135. package/Source/Scene/I3SNode.js +59 -66
  136. package/Source/Scene/Imagery.js +6 -1
  137. package/Source/Scene/ImageryLayer.js +299 -48
  138. package/Source/Scene/ImageryLayerCollection.js +26 -0
  139. package/Source/Scene/ImageryProvider.js +129 -111
  140. package/Source/Scene/Implicit3DTileContent.js +72 -23
  141. package/Source/Scene/ImplicitSubtree.js +66 -45
  142. package/Source/Scene/IonImageryProvider.js +471 -264
  143. package/Source/Scene/MapboxImageryProvider.js +272 -112
  144. package/Source/Scene/MapboxStyleImageryProvider.js +270 -111
  145. package/Source/Scene/MetadataSchemaLoader.js +26 -36
  146. package/Source/Scene/Model/B3dmLoader.js +42 -46
  147. package/Source/Scene/Model/GeoJsonLoader.js +8 -32
  148. package/Source/Scene/Model/I3dmLoader.js +48 -74
  149. package/Source/Scene/Model/Model.js +470 -132
  150. package/Source/Scene/Model/Model3DTileContent.js +83 -31
  151. package/Source/Scene/Model/ModelAnimationCollection.js +3 -3
  152. package/Source/Scene/Model/ModelDrawCommand.js +15 -26
  153. package/Source/Scene/Model/ModelUtility.js +16 -16
  154. package/Source/Scene/Model/PntsLoader.js +27 -32
  155. package/Source/Scene/Multiple3DTileContent.js +134 -115
  156. package/Source/Scene/PointCloud.js +11 -19
  157. package/Source/Scene/Primitive.js +20 -0
  158. package/Source/Scene/QuadtreePrimitive.js +2 -0
  159. package/Source/Scene/QuadtreeTileProvider.js +4 -8
  160. package/Source/Scene/ResourceCache.js +47 -105
  161. package/Source/Scene/ResourceCacheStatistics.js +24 -58
  162. package/Source/Scene/ResourceLoader.js +5 -17
  163. package/Source/Scene/ResourceLoaderState.js +12 -4
  164. package/Source/Scene/Scene.js +65 -0
  165. package/Source/Scene/ScreenSpaceCameraController.js +1 -1
  166. package/Source/Scene/SingleTileImageryProvider.js +382 -209
  167. package/Source/Scene/Terrain.js +196 -0
  168. package/Source/Scene/TileCoordinatesImageryProvider.js +267 -104
  169. package/Source/Scene/TileMapServiceImageryProvider.js +177 -85
  170. package/Source/Scene/Tileset3DTileContent.js +47 -5
  171. package/Source/Scene/TimeDynamicPointCloud.js +15 -2
  172. package/Source/Scene/UrlTemplateImageryProvider.js +343 -215
  173. package/Source/Scene/Vector3DTileClampedPolylines.js +96 -84
  174. package/Source/Scene/Vector3DTileContent.js +47 -22
  175. package/Source/Scene/Vector3DTileGeometry.js +57 -52
  176. package/Source/Scene/Vector3DTilePoints.js +72 -68
  177. package/Source/Scene/Vector3DTilePolygons.js +118 -117
  178. package/Source/Scene/Vector3DTilePolylines.js +86 -82
  179. package/Source/Scene/Vector3DTilePrimitive.js +0 -1
  180. package/Source/Scene/VoxelContent.js +61 -63
  181. package/Source/Scene/VoxelPrimitive.js +39 -91
  182. package/Source/Scene/VoxelProvider.js +2 -2
  183. package/Source/Scene/WebMapServiceImageryProvider.js +272 -111
  184. package/Source/Scene/WebMapTileServiceImageryProvider.js +270 -107
  185. package/Source/Scene/computeFlyToLocationForRectangle.js +33 -37
  186. package/Source/Scene/createOsmBuildings.js +6 -0
  187. package/Source/Scene/createOsmBuildingsAsync.js +82 -0
  188. package/Source/Scene/createWorldImagery.js +14 -5
  189. package/Source/Scene/createWorldImageryAsync.js +39 -0
  190. package/Source/Widget/CesiumWidget.js +55 -27
  191. package/index.d.ts +2158 -1395
  192. package/index.js +58 -51
  193. package/package.json +1 -1
@@ -16,7 +16,7 @@ import RuntimeError from "./RuntimeError.js";
16
16
  * @augments Resource
17
17
  *
18
18
  * @param {object} endpoint The result of the Cesium ion asset endpoint service.
19
- * @param {Resource} endpointResource The resource used to retreive the endpoint.
19
+ * @param {Resource} endpointResource The resource used to retrieve the endpoint.
20
20
  *
21
21
  * @see Ion
22
22
  * @see IonImageryProvider
@@ -87,8 +87,14 @@ if (defined(Object.create)) {
87
87
  * @returns {Promise<IonResource>} A Promise to am instance representing the Cesium ion Asset.
88
88
  *
89
89
  * @example
90
- * //Load a Cesium3DTileset with asset ID of 124624234
91
- * viewer.scene.primitives.add(new Cesium.Cesium3DTileset({ url: Cesium.IonResource.fromAssetId(124624234) }));
90
+ * // Load a Cesium3DTileset with asset ID of 124624234
91
+ * try {
92
+ * const resource = await Cesium.IonResource.fromAssetId(124624234);
93
+ * const tileset = await Cesium.Cesium3DTileset.fromUrl(resource);
94
+ * scene.primitives.add(tileset);
95
+ * } catch (error) {
96
+ * console.error(`Error creating tileset: ${error}`);
97
+ * }
92
98
  *
93
99
  * @example
94
100
  * //Load a CZML file with asset ID of 10890
@@ -197,6 +203,11 @@ IonResource.prototype._makeRequest = function (options) {
197
203
  options.headers = {};
198
204
  }
199
205
  options.headers.Authorization = `Bearer ${this._ionEndpoint.accessToken}`;
206
+ options.headers["X-Cesium-Client"] = "CesiumJS";
207
+ /* global CESIUM_VERSION */
208
+ if (typeof CESIUM_VERSION !== "undefined") {
209
+ options.headers["X-Cesium-Client-Version"] = CESIUM_VERSION;
210
+ }
200
211
 
201
212
  return Resource.prototype._makeRequest.call(this, options);
202
213
  };
@@ -24,7 +24,7 @@ import Rectangle from "./Rectangle.js";
24
24
  *
25
25
  * @param {Cartesian3} [center=Cartesian3.ZERO] The center of the box.
26
26
  * @param {Matrix3} [halfAxes=Matrix3.ZERO] The three orthogonal half-axes of the bounding box.
27
- * Equivalently, the transformation matrix, to rotate and scale a 1x1x1
27
+ * Equivalently, the transformation matrix, to rotate and scale a 2x2x2
28
28
  * cube centered at the origin.
29
29
  *
30
30
  *
@@ -46,7 +46,9 @@ function OrientedBoundingBox(center, halfAxes) {
46
46
  */
47
47
  this.center = Cartesian3.clone(defaultValue(center, Cartesian3.ZERO));
48
48
  /**
49
- * The transformation matrix, to rotate the box to the right position.
49
+ * The three orthogonal half-axes of the bounding box. Equivalently, the
50
+ * transformation matrix, to rotate and scale a 2x2x2 cube centered at the
51
+ * origin.
50
52
  * @type {Matrix3}
51
53
  * @default {@link Matrix3.ZERO}
52
54
  */
@@ -76,7 +76,7 @@ RequestScheduler.maximumRequestsPerServer = 6;
76
76
  */
77
77
  RequestScheduler.requestsByServer = {
78
78
  "api.cesium.com:443": 18,
79
- "assets.cesium.com:443": 18,
79
+ "assets.ion.cesium.com:443": 18,
80
80
  };
81
81
 
82
82
  /**
@@ -721,7 +721,7 @@ Resource.prototype.getDerivedResource = function (options) {
721
721
  /**
722
722
  * Called when a resource fails to load. This will call the retryCallback function if defined until retryAttempts is reached.
723
723
  *
724
- * @param {Error} [error] The error that was encountered.
724
+ * @param {RequestErrorEvent} [error] The error that was encountered.
725
725
  *
726
726
  * @returns {Promise<boolean>} A promise to a boolean, that if true will cause the resource request to be retried.
727
727
  *
@@ -2301,7 +2301,7 @@ Resource.DEFAULT = Object.freeze(
2301
2301
  * @callback Resource.RetryCallback
2302
2302
  *
2303
2303
  * @param {Resource} [resource] The resource that failed to load.
2304
- * @param {Error} [error] The error that occurred during the loading of the resource.
2304
+ * @param {RequestErrorEvent} [error] The error that occurred during the loading of the resource.
2305
2305
  * @returns {boolean|Promise<boolean>} If true or a promise that resolved to true, the resource will be retried. Otherwise the failure will be returned.
2306
2306
  */
2307
2307
  export default Resource;
@@ -22,7 +22,7 @@ function TerrainProvider() {
22
22
 
23
23
  Object.defineProperties(TerrainProvider.prototype, {
24
24
  /**
25
- * Gets an event that is raised when the terrain provider encounters an asynchronous error.. By subscribing
25
+ * Gets an event that is raised when the terrain provider encounters an asynchronous error. By subscribing
26
26
  * to the event, you will be notified of the error and can potentially recover from it. Event listeners
27
27
  * are passed an instance of {@link TileProviderError}.
28
28
  * @memberof TerrainProvider.prototype
@@ -35,8 +35,7 @@ Object.defineProperties(TerrainProvider.prototype, {
35
35
 
36
36
  /**
37
37
  * Gets the credit to display when this terrain provider is active. Typically this is used to credit
38
- * the source of the terrain. This function should
39
- * not be called before {@link TerrainProvider#ready} returns true.
38
+ * the source of the terrain.
40
39
  * @memberof TerrainProvider.prototype
41
40
  * @type {Credit}
42
41
  * @readonly
@@ -46,8 +45,7 @@ Object.defineProperties(TerrainProvider.prototype, {
46
45
  },
47
46
 
48
47
  /**
49
- * Gets the tiling scheme used by the provider. This function should
50
- * not be called before {@link TerrainProvider#ready} returns true.
48
+ * Gets the tiling scheme used by the provider.
51
49
  * @memberof TerrainProvider.prototype
52
50
  * @type {TilingScheme}
53
51
  * @readonly
@@ -61,6 +59,7 @@ Object.defineProperties(TerrainProvider.prototype, {
61
59
  * @memberof TerrainProvider.prototype
62
60
  * @type {boolean}
63
61
  * @readonly
62
+ * @deprecated
64
63
  */
65
64
  ready: {
66
65
  get: DeveloperError.throwInstantiationError,
@@ -71,6 +70,7 @@ Object.defineProperties(TerrainProvider.prototype, {
71
70
  * @memberof TerrainProvider.prototype
72
71
  * @type {Promise<boolean>}
73
72
  * @readonly
73
+ * @deprecated
74
74
  */
75
75
  readyPromise: {
76
76
  get: DeveloperError.throwInstantiationError,
@@ -79,8 +79,7 @@ Object.defineProperties(TerrainProvider.prototype, {
79
79
  /**
80
80
  * Gets a value indicating whether or not the provider includes a water mask. The water mask
81
81
  * indicates which areas of the globe are water rather than land, so they can be rendered
82
- * as a reflective surface with animated waves. This function should not be
83
- * called before {@link TerrainProvider#ready} returns true.
82
+ * as a reflective surface with animated waves.
84
83
  * @memberof TerrainProvider.prototype
85
84
  * @type {boolean}
86
85
  * @readonly
@@ -91,7 +90,6 @@ Object.defineProperties(TerrainProvider.prototype, {
91
90
 
92
91
  /**
93
92
  * Gets a value indicating whether or not the requested tiles include vertex normals.
94
- * This function should not be called before {@link TerrainProvider#ready} returns true.
95
93
  * @memberof TerrainProvider.prototype
96
94
  * @type {boolean}
97
95
  * @readonly
@@ -102,8 +100,7 @@ Object.defineProperties(TerrainProvider.prototype, {
102
100
 
103
101
  /**
104
102
  * Gets an object that can be used to determine availability of terrain from this provider, such as
105
- * at points and in rectangles. This function should not be called before
106
- * {@link TerrainProvider#ready} returns true. This property may be undefined if availability
103
+ * at points and in rectangles. This property may be undefined if availability
107
104
  * information is not available.
108
105
  * @memberof TerrainProvider.prototype
109
106
  * @type {TileAvailability}
@@ -399,8 +396,7 @@ TerrainProvider.getEstimatedLevelZeroGeometricErrorForAHeightmap = function (
399
396
  };
400
397
 
401
398
  /**
402
- * Requests the geometry for a given tile. This function should not be called before
403
- * {@link TerrainProvider#ready} returns true. The result must include terrain data and
399
+ * Requests the geometry for a given tile. The result must include terrain data and
404
400
  * may optionally include a water mask and an indication of which child tiles are available.
405
401
  * @function
406
402
  *
@@ -417,8 +413,7 @@ TerrainProvider.prototype.requestTileGeometry =
417
413
  DeveloperError.throwInstantiationError;
418
414
 
419
415
  /**
420
- * Gets the maximum geometric error allowed in a tile at a given level. This function should not be
421
- * called before {@link TerrainProvider#ready} returns true.
416
+ * Gets the maximum geometric error allowed in a tile at a given level.
422
417
  * @function
423
418
  *
424
419
  * @param {number} level The tile level for which to get the maximum geometric error.
@@ -92,14 +92,14 @@ function TileProviderError(
92
92
  * @param {TileProviderError} previousError The error instance returned by this function the last
93
93
  * time it was called for this error, or undefined if this is the first time this error has
94
94
  * occurred.
95
- * @param {ImageryProvider|TerrainProvider} provider The imagery or terrain provider that encountered the error.
96
- * @param {Event} event The event to raise to inform listeners of the error.
97
- * @param {string} message The message describing the error.
98
- * @param {number} x The X coordinate of the tile that experienced the error, or undefined if the
95
+ * @param {ImageryProvider|TerrainProvider} [provider] The imagery or terrain provider that encountered the error.
96
+ * @param {Event} [event] The event to raise to inform listeners of the error.
97
+ * @param {string} [message] The message describing the error.
98
+ * @param {number} [x] The X coordinate of the tile that experienced the error, or undefined if the
99
99
  * error is not specific to a particular tile.
100
- * @param {number} y The Y coordinate of the tile that experienced the error, or undefined if the
100
+ * @param {number} [y] The Y coordinate of the tile that experienced the error, or undefined if the
101
101
  * error is not specific to a particular tile.
102
- * @param {number} level The level-of-detail of the tile that experienced the error, or undefined if the
102
+ * @param {number} [level] The level-of-detail of the tile that experienced the error, or undefined if the
103
103
  * error is not specific to a particular tile.
104
104
  * @param {Error} [errorDetails] The error or exception that occurred, if any.
105
105
  * @returns {TileProviderError} The error instance that was passed to the event listeners and that
@@ -138,9 +138,9 @@ TileProviderError.reportError = function (
138
138
  ++error.timesRetried;
139
139
  }
140
140
 
141
- if (event.numberOfListeners > 0) {
141
+ if (defined(event) && event.numberOfListeners > 0) {
142
142
  event.raiseEvent(error);
143
- } else {
143
+ } else if (defined(provider)) {
144
144
  console.log(
145
145
  `An error occurred in "${provider.constructor.name}": ${formatError(
146
146
  message
@@ -1,7 +1,8 @@
1
+ import Check from "./Check.js";
1
2
  import Credit from "./Credit.js";
2
3
  import defaultValue from "./defaultValue.js";
3
4
  import defined from "./defined.js";
4
- import DeveloperError from "./DeveloperError.js";
5
+ import deprecationWarning from "./deprecationWarning.js";
5
6
  import Ellipsoid from "./Ellipsoid.js";
6
7
  import Event from "./Event.js";
7
8
  import GeographicTilingScheme from "./GeographicTilingScheme.js";
@@ -20,38 +21,143 @@ function DataRectangle(rectangle, maxLevel) {
20
21
  }
21
22
 
22
23
  /**
24
+ * @typedef {Object} VRTheWorldTerrainProvider.ConstructorOptions
25
+ *
26
+ * Initialization options for the VRTheWorldTerrainProvider constructor
27
+ *
28
+ * @property {Ellipsoid} [ellipsoid] The ellipsoid. If not specified, the WGS84 ellipsoid is used.
29
+ * @property {Credit|string} [credit] A credit for the data source, which is displayed on the canvas.
30
+ * @property {Resource|string} [url] The URL of the VR-TheWorld TileMap. Deprecated.
31
+ */
32
+
33
+ /**
34
+ * Used to track creation details while fetching initial metadata
35
+ *
36
+ * @constructor
37
+ * @private
38
+ *
39
+ * @param {VRTheWorldTerrainProvider.ConstructorOptions} options An object describing initialization options
40
+ */
41
+ function TerrainProviderBuilder(options) {
42
+ this.ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.WGS84);
43
+ this.tilingScheme = undefined;
44
+ this.heightmapWidth = undefined;
45
+ this.heightmapHeight = undefined;
46
+ this.levelZeroMaximumGeometricError = undefined;
47
+ this.rectangles = [];
48
+ }
49
+
50
+ TerrainProviderBuilder.prototype.build = function (provider) {
51
+ provider._tilingScheme = this.tilingScheme;
52
+ provider._heightmapWidth = this.heightmapWidth;
53
+ provider._heightmapHeight = this.heightmapHeight;
54
+ provider._levelZeroMaximumGeometricError = this.levelZeroMaximumGeometricError;
55
+ provider._rectangles = this.rectangles;
56
+ provider._ready = true;
57
+ };
58
+
59
+ function metadataSuccess(terrainProviderBuilder, xml) {
60
+ const srs = xml.getElementsByTagName("SRS")[0].textContent;
61
+ if (srs === "EPSG:4326") {
62
+ terrainProviderBuilder.tilingScheme = new GeographicTilingScheme({
63
+ ellipsoid: terrainProviderBuilder.ellipsoid,
64
+ });
65
+ } else {
66
+ throw new RuntimeError(`SRS ${srs} is not supported`);
67
+ }
68
+
69
+ const tileFormat = xml.getElementsByTagName("TileFormat")[0];
70
+ terrainProviderBuilder.heightmapWidth = parseInt(
71
+ tileFormat.getAttribute("width"),
72
+ 10
73
+ );
74
+ terrainProviderBuilder.heightmapHeight = parseInt(
75
+ tileFormat.getAttribute("height"),
76
+ 10
77
+ );
78
+ terrainProviderBuilder.levelZeroMaximumGeometricError = TerrainProvider.getEstimatedLevelZeroGeometricErrorForAHeightmap(
79
+ terrainProviderBuilder.ellipsoid,
80
+ Math.min(
81
+ terrainProviderBuilder.heightmapWidth,
82
+ terrainProviderBuilder.heightmapHeight
83
+ ),
84
+ terrainProviderBuilder.tilingScheme.getNumberOfXTilesAtLevel(0)
85
+ );
86
+
87
+ const dataRectangles = xml.getElementsByTagName("DataExtent");
88
+
89
+ for (let i = 0; i < dataRectangles.length; ++i) {
90
+ const dataRectangle = dataRectangles[i];
91
+
92
+ const west = CesiumMath.toRadians(
93
+ parseFloat(dataRectangle.getAttribute("minx"))
94
+ );
95
+ const south = CesiumMath.toRadians(
96
+ parseFloat(dataRectangle.getAttribute("miny"))
97
+ );
98
+ const east = CesiumMath.toRadians(
99
+ parseFloat(dataRectangle.getAttribute("maxx"))
100
+ );
101
+ const north = CesiumMath.toRadians(
102
+ parseFloat(dataRectangle.getAttribute("maxy"))
103
+ );
104
+ const maxLevel = parseInt(dataRectangle.getAttribute("maxlevel"), 10);
105
+
106
+ terrainProviderBuilder.rectangles.push(
107
+ new DataRectangle(new Rectangle(west, south, east, north), maxLevel)
108
+ );
109
+ }
110
+ }
111
+
112
+ function metadataFailure(resource, error, provider) {
113
+ let message = `An error occurred while accessing ${resource.url}`;
114
+
115
+ if (defined(error) && defined(error.message)) {
116
+ message = `${message}: ${error.message}`;
117
+ }
118
+
119
+ TileProviderError.reportError(
120
+ undefined,
121
+ provider,
122
+ defined(provider) ? provider._errorEvent : undefined,
123
+ message
124
+ );
125
+
126
+ throw new RuntimeError(message);
127
+ }
128
+
129
+ async function requestMetadata(terrainProviderBuilder, resource, provider) {
130
+ try {
131
+ const xml = await resource.fetchXML();
132
+ metadataSuccess(terrainProviderBuilder, xml);
133
+ } catch (error) {
134
+ metadataFailure(resource, error, provider);
135
+ }
136
+ }
137
+
138
+ /**
139
+ * <div class="notice">
140
+ * To construct a VRTheWorldTerrainProvider, call {@link VRTheWorldTerrainProvider.fromUrl}. Do not call the constructor directly.
141
+ * </div>
142
+ *
23
143
  * A {@link TerrainProvider} that produces terrain geometry by tessellating height maps
24
144
  * retrieved from a {@link http://vr-theworld.com/|VT MÄK VR-TheWorld server}.
25
145
  *
26
146
  * @alias VRTheWorldTerrainProvider
27
147
  * @constructor
28
148
  *
29
- * @param {object} options Object with the following properties:
30
- * @param {Resource|string} options.url The URL of the VR-TheWorld TileMap.
31
- * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid. If this parameter is not
32
- * specified, the WGS84 ellipsoid is used.
33
- * @param {Credit|string} [options.credit] A credit for the data source, which is displayed on the canvas.
34
- *
149
+ * @param {VRTheWorldTerrainProvider.ConstructorOptions} [options] An object describing initialization options.
35
150
  *
36
151
  * @example
37
- * const terrainProvider = new Cesium.VRTheWorldTerrainProvider({
38
- * url : 'https://www.vr-theworld.com/vr-theworld/tiles1.0.0/73/'
39
- * });
152
+ * const terrainProvider = await Cesium.VRTheWorldTerrainProvider.fromUrl(
153
+ * "https://www.vr-theworld.com/vr-theworld/tiles1.0.0/73/"
154
+ * );
40
155
  * viewer.terrainProvider = terrainProvider;
41
156
  *
42
157
  * @see TerrainProvider
43
158
  */
44
159
  function VRTheWorldTerrainProvider(options) {
45
160
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
46
- //>>includeStart('debug', pragmas.debug);
47
- if (!defined(options.url)) {
48
- throw new DeveloperError("options.url is required.");
49
- }
50
- //>>includeEnd('debug');
51
-
52
- const resource = Resource.createIfNeeded(options.url);
53
-
54
- this._resource = resource;
55
161
 
56
162
  this._errorEvent = new Event();
57
163
  this._ready = false;
@@ -76,80 +182,26 @@ function VRTheWorldTerrainProvider(options) {
76
182
  this._tilingScheme = undefined;
77
183
  this._rectangles = [];
78
184
 
79
- const that = this;
80
- let metadataError;
81
- const ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.WGS84);
82
-
83
- function metadataSuccess(xml) {
84
- const srs = xml.getElementsByTagName("SRS")[0].textContent;
85
- if (srs === "EPSG:4326") {
86
- that._tilingScheme = new GeographicTilingScheme({ ellipsoid: ellipsoid });
87
- } else {
88
- return Promise.reject(new RuntimeError(`SRS ${srs} is not supported.`));
89
- }
90
-
91
- const tileFormat = xml.getElementsByTagName("TileFormat")[0];
92
- that._heightmapWidth = parseInt(tileFormat.getAttribute("width"), 10);
93
- that._heightmapHeight = parseInt(tileFormat.getAttribute("height"), 10);
94
- that._levelZeroMaximumGeometricError = TerrainProvider.getEstimatedLevelZeroGeometricErrorForAHeightmap(
95
- ellipsoid,
96
- Math.min(that._heightmapWidth, that._heightmapHeight),
97
- that._tilingScheme.getNumberOfXTilesAtLevel(0)
185
+ if (defined(options.url)) {
186
+ deprecationWarning(
187
+ "VRTheWorldTerrainProvider options.url",
188
+ "options.url was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. VRTheWorldTerrainProvider.fromUrl instead."
98
189
  );
99
-
100
- const dataRectangles = xml.getElementsByTagName("DataExtent");
101
-
102
- for (let i = 0; i < dataRectangles.length; ++i) {
103
- const dataRectangle = dataRectangles[i];
104
-
105
- const west = CesiumMath.toRadians(
106
- parseFloat(dataRectangle.getAttribute("minx"))
107
- );
108
- const south = CesiumMath.toRadians(
109
- parseFloat(dataRectangle.getAttribute("miny"))
110
- );
111
- const east = CesiumMath.toRadians(
112
- parseFloat(dataRectangle.getAttribute("maxx"))
113
- );
114
- const north = CesiumMath.toRadians(
115
- parseFloat(dataRectangle.getAttribute("maxy"))
116
- );
117
- const maxLevel = parseInt(dataRectangle.getAttribute("maxlevel"), 10);
118
-
119
- that._rectangles.push(
120
- new DataRectangle(new Rectangle(west, south, east, north), maxLevel)
121
- );
122
- }
123
-
124
- that._ready = true;
125
- return Promise.resolve(true);
126
- }
127
-
128
- function metadataFailure(e) {
129
- const message = defaultValue(
130
- defined(e) ? e.message : undefined,
131
- `An error occurred while accessing ${that._resource.url}.`
132
- );
133
- metadataError = TileProviderError.reportError(
134
- metadataError,
135
- that,
136
- that._errorEvent,
137
- message
138
- );
139
- if (metadataError.retry) {
140
- return requestMetadata();
141
- }
142
- return Promise.reject(new RuntimeError(message));
143
- }
144
-
145
- function requestMetadata() {
146
- return that._resource
147
- .fetchXML()
148
- .then(metadataSuccess)
149
- .catch(metadataFailure);
190
+ const that = this;
191
+ const terrainProviderBuilder = new TerrainProviderBuilder(options);
192
+ const resource = Resource.createIfNeeded(options.url);
193
+
194
+ this._resource = resource;
195
+
196
+ this._readyPromise = requestMetadata(
197
+ terrainProviderBuilder,
198
+ resource,
199
+ that
200
+ ).then(() => {
201
+ terrainProviderBuilder.build(that);
202
+ return true;
203
+ });
150
204
  }
151
-
152
- this._readyPromise = requestMetadata();
153
205
  }
154
206
 
155
207
  Object.defineProperties(VRTheWorldTerrainProvider.prototype, {
@@ -169,7 +221,7 @@ Object.defineProperties(VRTheWorldTerrainProvider.prototype, {
169
221
 
170
222
  /**
171
223
  * Gets the credit to display when this terrain provider is active. Typically this is used to credit
172
- * the source of the terrain. This function should not be called before {@link VRTheWorldTerrainProvider#ready} returns true.
224
+ * the source of the terrain.
173
225
  * @memberof VRTheWorldTerrainProvider.prototype
174
226
  * @type {Credit}
175
227
  * @readonly
@@ -181,22 +233,13 @@ Object.defineProperties(VRTheWorldTerrainProvider.prototype, {
181
233
  },
182
234
 
183
235
  /**
184
- * Gets the tiling scheme used by this provider. This function should
185
- * not be called before {@link VRTheWorldTerrainProvider#ready} returns true.
236
+ * Gets the tiling scheme used by this provider.
186
237
  * @memberof VRTheWorldTerrainProvider.prototype
187
238
  * @type {GeographicTilingScheme}
188
239
  * @readonly
189
240
  */
190
241
  tilingScheme: {
191
242
  get: function () {
192
- //>>includeStart('debug', pragmas.debug);
193
- if (!this.ready) {
194
- throw new DeveloperError(
195
- "requestTileGeometry must not be called before ready returns true."
196
- );
197
- }
198
- //>>includeEnd('debug');
199
-
200
243
  return this._tilingScheme;
201
244
  },
202
245
  },
@@ -206,9 +249,14 @@ Object.defineProperties(VRTheWorldTerrainProvider.prototype, {
206
249
  * @memberof VRTheWorldTerrainProvider.prototype
207
250
  * @type {boolean}
208
251
  * @readonly
252
+ * @deprecated
209
253
  */
210
254
  ready: {
211
255
  get: function () {
256
+ deprecationWarning(
257
+ "VRTheWorldTerrainProvider.ready",
258
+ "VRTheWorldTerrainProvider.ready was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use VRTheWorldTerrainProvider.fromUrl instead."
259
+ );
212
260
  return this._ready;
213
261
  },
214
262
  },
@@ -218,9 +266,14 @@ Object.defineProperties(VRTheWorldTerrainProvider.prototype, {
218
266
  * @memberof VRTheWorldTerrainProvider.prototype
219
267
  * @type {Promise<boolean>}
220
268
  * @readonly
269
+ * @deprecated
221
270
  */
222
271
  readyPromise: {
223
272
  get: function () {
273
+ deprecationWarning(
274
+ "VRTheWorldTerrainProvider.readyPromise",
275
+ "VRTheWorldTerrainProvider.readyPromise was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use VRTheWorldTerrainProvider.fromUrl instead."
276
+ );
224
277
  return this._readyPromise;
225
278
  },
226
279
  },
@@ -228,8 +281,7 @@ Object.defineProperties(VRTheWorldTerrainProvider.prototype, {
228
281
  /**
229
282
  * Gets a value indicating whether or not the provider includes a water mask. The water mask
230
283
  * indicates which areas of the globe are water rather than land, so they can be rendered
231
- * as a reflective surface with animated waves. This function should not be
232
- * called before {@link VRTheWorldTerrainProvider#ready} returns true.
284
+ * as a reflective surface with animated waves.
233
285
  * @memberof VRTheWorldTerrainProvider.prototype
234
286
  * @type {boolean}
235
287
  * @readonly
@@ -242,7 +294,6 @@ Object.defineProperties(VRTheWorldTerrainProvider.prototype, {
242
294
 
243
295
  /**
244
296
  * Gets a value indicating whether or not the requested tiles include vertex normals.
245
- * This function should not be called before {@link VRTheWorldTerrainProvider#ready} returns true.
246
297
  * @memberof VRTheWorldTerrainProvider.prototype
247
298
  * @type {boolean}
248
299
  * @readonly
@@ -254,8 +305,7 @@ Object.defineProperties(VRTheWorldTerrainProvider.prototype, {
254
305
  },
255
306
  /**
256
307
  * Gets an object that can be used to determine availability of terrain from this provider, such as
257
- * at points and in rectangles. This function should not be called before
258
- * {@link TerrainProvider#ready} returns true. This property may be undefined if availability
308
+ * at points and in rectangles. This property may be undefined if availability
259
309
  * information is not available.
260
310
  * @memberof VRTheWorldTerrainProvider.prototype
261
311
  * @type {TileAvailability}
@@ -269,8 +319,42 @@ Object.defineProperties(VRTheWorldTerrainProvider.prototype, {
269
319
  });
270
320
 
271
321
  /**
272
- * Requests the geometry for a given tile. This function should not be called before
273
- * {@link VRTheWorldTerrainProvider#ready} returns true. The result includes terrain
322
+ * Creates a {@link TerrainProvider} that produces terrain geometry by tessellating height maps
323
+ * retrieved from a {@link http://vr-theworld.com/|VT MÄK VR-TheWorld server}.
324
+ *
325
+ * @param {Resource|String} url The URL of the VR-TheWorld TileMap.
326
+ * @param {VRTheWorldTerrainProvider.ConstructorOptions} [options] An object describing initialization options.
327
+ * @returns {Promise<VRTheWorldTerrainProvider>}
328
+ *
329
+ * @example
330
+ * const terrainProvider = await Cesium.VRTheWorldTerrainProvider.fromUrl(
331
+ * "https://www.vr-theworld.com/vr-theworld/tiles1.0.0/73/"
332
+ * );
333
+ * viewer.terrainProvider = terrainProvider;
334
+ *
335
+ * @exception {RuntimeError} metadata specifies and unknown SRS
336
+ */
337
+ VRTheWorldTerrainProvider.fromUrl = async function (url, options) {
338
+ //>>includeStart('debug', pragmas.debug);
339
+ Check.defined("url", url);
340
+ //>>includeEnd('debug');
341
+
342
+ options = defaultValue(options, defaultValue.EMPTY_OBJECT);
343
+
344
+ const terrainProviderBuilder = new TerrainProviderBuilder(options);
345
+ const resource = Resource.createIfNeeded(url);
346
+
347
+ await requestMetadata(terrainProviderBuilder, resource);
348
+
349
+ const provider = new VRTheWorldTerrainProvider(options);
350
+ terrainProviderBuilder.build(provider);
351
+ provider._resource = resource;
352
+
353
+ return provider;
354
+ };
355
+
356
+ /**
357
+ * Requests the geometry for a given tile. The result includes terrain
274
358
  * data and indicates that all child tiles are available.
275
359
  *
276
360
  * @param {number} x The X coordinate of the tile for which to request geometry.
@@ -287,14 +371,6 @@ VRTheWorldTerrainProvider.prototype.requestTileGeometry = function (
287
371
  level,
288
372
  request
289
373
  ) {
290
- //>>includeStart('debug', pragmas.debug);
291
- if (!this.ready) {
292
- throw new DeveloperError(
293
- "requestTileGeometry must not be called before ready returns true."
294
- );
295
- }
296
- //>>includeEnd('debug');
297
-
298
374
  const yTiles = this._tilingScheme.getNumberOfYTilesAtLevel(level);
299
375
  const resource = this._resource.getDerivedResource({
300
376
  url: `${level}/${x}/${yTiles - y - 1}.tif`,
@@ -331,13 +407,6 @@ VRTheWorldTerrainProvider.prototype.requestTileGeometry = function (
331
407
  VRTheWorldTerrainProvider.prototype.getLevelMaximumGeometricError = function (
332
408
  level
333
409
  ) {
334
- //>>includeStart('debug', pragmas.debug);
335
- if (!this.ready) {
336
- throw new DeveloperError(
337
- "requestTileGeometry must not be called before ready returns true."
338
- );
339
- }
340
- //>>includeEnd('debug');
341
410
  return this._levelZeroMaximumGeometricError / (1 << level);
342
411
  };
343
412
 
@@ -98,9 +98,10 @@ let implementation;
98
98
  *
99
99
  * @example
100
100
  * const viewer = new Cesium.Viewer("cesiumContainer", {
101
- * imageryProvider: new Cesium.TileMapServiceImageryProvider({
102
- * url: Cesium.buildModuleUrl("Assets/Textures/NaturalEarthII"),
103
- * }),
101
+ * baseLayer: Cesium.ImageryLayer.fromProviderAsync(
102
+ * Cesium.TileMapServiceImageryProvider.fromUrl(
103
+ * Cesium.buildModuleUrl("Assets/Textures/NaturalEarthII"),
104
+ * )),
104
105
  * baseLayerPicker: false,
105
106
  * });
106
107
  */