@cesium/engine 2.2.0 → 2.4.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 (139) hide show
  1. package/Build/Workers/{AttributeCompression-8a5a065e.js → AttributeCompression-f9f6c717.js} +1 -1
  2. package/Build/Workers/{AxisAlignedBoundingBox-379015ef.js → AxisAlignedBoundingBox-4bfd84f3.js} +1 -1
  3. package/Build/Workers/{BoundingRectangle-57f2b24f.js → BoundingRectangle-5fd6403a.js} +1 -1
  4. package/Build/Workers/{BoxGeometry-ecabfc78.js → BoxGeometry-af7d05ef.js} +1 -1
  5. package/Build/Workers/{Color-14d1a36d.js → Color-e5bfda3f.js} +1 -1
  6. package/Build/Workers/{CoplanarPolygonGeometryLibrary-048c3c14.js → CoplanarPolygonGeometryLibrary-59c69b0a.js} +1 -1
  7. package/Build/Workers/{CorridorGeometryLibrary-520c8619.js → CorridorGeometryLibrary-63907365.js} +1 -1
  8. package/Build/Workers/{CylinderGeometry-119068b8.js → CylinderGeometry-dbaa1678.js} +1 -1
  9. package/Build/Workers/{CylinderGeometryLibrary-135b0858.js → CylinderGeometryLibrary-7bf291b4.js} +1 -1
  10. package/Build/Workers/{EllipseGeometry-2dfc3523.js → EllipseGeometry-6508b78b.js} +1 -1
  11. package/Build/Workers/{EllipseGeometryLibrary-0a1e0170.js → EllipseGeometryLibrary-21262a28.js} +1 -1
  12. package/Build/Workers/{EllipseOutlineGeometry-c5251669.js → EllipseOutlineGeometry-2a2510bb.js} +1 -1
  13. package/Build/Workers/{EllipsoidGeodesic-dcff5cbd.js → EllipsoidGeodesic-5b3623dc.js} +1 -1
  14. package/Build/Workers/{EllipsoidGeometry-d10a5221.js → EllipsoidGeometry-8155e3a2.js} +1 -1
  15. package/Build/Workers/{EllipsoidOutlineGeometry-7039a0ae.js → EllipsoidOutlineGeometry-c045678d.js} +1 -1
  16. package/Build/Workers/{EllipsoidRhumbLine-b672d507.js → EllipsoidRhumbLine-ef872433.js} +1 -1
  17. package/Build/Workers/{EllipsoidTangentPlane-857186be.js → EllipsoidTangentPlane-546c0d5e.js} +1 -1
  18. package/Build/Workers/{EncodedCartesian3-e8bbca36.js → EncodedCartesian3-57415c8a.js} +1 -1
  19. package/Build/Workers/{FrustumGeometry-400fa1b7.js → FrustumGeometry-d3ff16d0.js} +31 -3
  20. package/Build/Workers/{GeometryAttribute-7a2de5c6.js → GeometryAttribute-13da9466.js} +1 -1
  21. package/Build/Workers/{GeometryInstance-3fb607b7.js → GeometryInstance-34d9e21e.js} +1 -1
  22. package/Build/Workers/{GeometryPipeline-916636fa.js → GeometryPipeline-03bc5709.js} +1 -1
  23. package/Build/Workers/{IndexDatatype-b8f3e09d.js → IndexDatatype-2643aa47.js} +1 -1
  24. package/Build/Workers/{IntersectionTests-b4d02d4d.js → IntersectionTests-85350792.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-96fe1752.js → OrientedBoundingBox-29fb0fcd.js} +1 -1
  29. package/Build/Workers/{Plane-c27e1ac6.js → Plane-4c3d403b.js} +1 -1
  30. package/Build/Workers/{PolygonGeometryLibrary-931f1ec6.js → PolygonGeometryLibrary-d447448d.js} +1 -1
  31. package/Build/Workers/PolygonPipeline-460cce4e.js +1344 -0
  32. package/Build/Workers/{PolylinePipeline-6d5c63e5.js → PolylinePipeline-7119eb3f.js} +1 -1
  33. package/Build/Workers/{PolylineVolumeGeometryLibrary-f068c1fb.js → PolylineVolumeGeometryLibrary-d25f0050.js} +1 -1
  34. package/Build/Workers/{PrimitivePipeline-879f996a.js → PrimitivePipeline-e648752b.js} +1 -1
  35. package/Build/Workers/{RectangleGeometryLibrary-2d6f36f3.js → RectangleGeometryLibrary-bb378fb6.js} +1 -1
  36. package/Build/Workers/{TerrainEncoding-82882059.js → TerrainEncoding-c8e029a2.js} +1 -1
  37. package/Build/Workers/Transforms-e2d4a55a.js +14713 -0
  38. package/Build/Workers/{WallGeometryLibrary-db7a64fb.js → WallGeometryLibrary-3e0819ec.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 +1 -1
  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/BingMapsGeocoderService.js +19 -1
  89. package/Source/Core/CartographicGeocoderService.js +15 -0
  90. package/Source/Core/Credit.js +1 -1
  91. package/Source/Core/FrustumGeometry.js +3 -2
  92. package/Source/Core/GeocoderService.js +32 -1
  93. package/Source/Core/GoogleMaps.js +56 -0
  94. package/Source/Core/Ion.js +2 -1
  95. package/Source/Core/IonGeocoderService.js +17 -2
  96. package/Source/Core/OpenCageGeocoderService.js +18 -1
  97. package/Source/Core/OrthographicFrustum.js +13 -0
  98. package/Source/Core/PeliasGeocoderService.js +14 -1
  99. package/Source/Core/PerspectiveFrustum.js +14 -0
  100. package/Source/Core/Request.js +3 -2
  101. package/Source/Core/RequestScheduler.js +10 -4
  102. package/Source/Core/Resource.js +240 -233
  103. package/Source/DataSources/DataSourceDisplay.js +2 -2
  104. package/Source/DataSources/EntityCluster.js +126 -128
  105. package/Source/DataSources/ModelVisualizer.js +5 -3
  106. package/Source/Renderer/UniformState.js +3 -2
  107. package/Source/Renderer/demodernizeShader.js +5 -5
  108. package/Source/Scene/ArcGisBaseMapType.js +12 -0
  109. package/Source/Scene/ArcGisMapServerImageryProvider.js +162 -20
  110. package/Source/Scene/ArcGisMapService.js +84 -0
  111. package/Source/Scene/Camera.js +8 -7
  112. package/Source/Scene/Cesium3DTile.js +4 -3
  113. package/Source/Scene/Cesium3DTileset.js +6 -5
  114. package/Source/Scene/CreditDisplay.js +112 -16
  115. package/Source/Scene/GlobeSurfaceTileProvider.js +4 -4
  116. package/Source/Scene/GltfJsonLoader.js +12 -0
  117. package/Source/Scene/GltfLoader.js +6 -37
  118. package/Source/Scene/IonImageryProvider.js +11 -11
  119. package/Source/Scene/Model/MaterialPipelineStage.js +12 -12
  120. package/Source/Scene/Model/Model.js +90 -47
  121. package/Source/Scene/Model/UniformType.js +1 -1
  122. package/Source/Scene/Picking.js +3 -2
  123. package/Source/Scene/QuadtreePrimitive.js +3 -2
  124. package/Source/Scene/SceneTransforms.js +3 -2
  125. package/Source/Scene/ScreenSpaceCameraController.js +140 -32
  126. package/Source/Scene/Vector3DTilePoints.js +25 -13
  127. package/Source/Scene/createGooglePhotorealistic3DTileset.js +53 -0
  128. package/Source/Shaders/AtmosphereCommon.glsl +51 -8
  129. package/Source/Shaders/AtmosphereCommon.js +51 -8
  130. package/Source/Shaders/PostProcessStages/AmbientOcclusionGenerate.glsl +1 -1
  131. package/Source/Shaders/PostProcessStages/AmbientOcclusionGenerate.js +1 -1
  132. package/Source/Shaders/PostProcessStages/AmbientOcclusionModulate.glsl +3 -3
  133. package/Source/Shaders/PostProcessStages/AmbientOcclusionModulate.js +3 -3
  134. package/Source/Widget/CesiumWidget.js +12 -0
  135. package/index.d.ts +244 -17
  136. package/index.js +14 -10
  137. package/package.json +4 -4
  138. package/Build/Workers/PolygonPipeline-32fc92cc.js +0 -1345
  139. package/Build/Workers/Transforms-9052372a.js +0 -14715
@@ -76,14 +76,6 @@ function EntityCluster(options) {
76
76
  this.show = defaultValue(options.show, true);
77
77
  }
78
78
 
79
- function getX(point) {
80
- return point.coord.x;
81
- }
82
-
83
- function getY(point) {
84
- return point.coord.y;
85
- }
86
-
87
79
  function expandBoundingBox(bbox, pixelRange) {
88
80
  bbox.x -= pixelRange;
89
81
  bbox.y -= pixelRange;
@@ -335,153 +327,159 @@ function createDeclutterCallback(entityCluster) {
335
327
  let collection;
336
328
  let collectionIndex;
337
329
 
338
- const index = new KDBush(points, getX, getY, 64, Int32Array);
330
+ if (points.length > 0) {
331
+ const index = new KDBush(points.length, 64, Uint32Array);
332
+ for (let p = 0; p < points.length; ++p) {
333
+ index.add(points[p].coord.x, points[p].coord.y);
334
+ }
335
+ index.finish();
339
336
 
340
- if (currentHeight < previousHeight) {
341
- length = clusters.length;
342
- for (i = 0; i < length; ++i) {
343
- const cluster = clusters[i];
337
+ if (currentHeight < previousHeight) {
338
+ length = clusters.length;
339
+ for (i = 0; i < length; ++i) {
340
+ const cluster = clusters[i];
344
341
 
345
- if (!occluder.isPointVisible(cluster.position)) {
346
- continue;
342
+ if (!occluder.isPointVisible(cluster.position)) {
343
+ continue;
344
+ }
345
+
346
+ const coord = Billboard._computeScreenSpacePosition(
347
+ Matrix4.IDENTITY,
348
+ cluster.position,
349
+ Cartesian3.ZERO,
350
+ Cartesian2.ZERO,
351
+ scene
352
+ );
353
+ if (!defined(coord)) {
354
+ continue;
355
+ }
356
+
357
+ const factor = 1.0 - currentHeight / previousHeight;
358
+ let width = (cluster.width = cluster.width * factor);
359
+ let height = (cluster.height = cluster.height * factor);
360
+
361
+ width = Math.max(width, cluster.minimumWidth);
362
+ height = Math.max(height, cluster.minimumHeight);
363
+
364
+ const minX = coord.x - width * 0.5;
365
+ const minY = coord.y - height * 0.5;
366
+ const maxX = coord.x + width;
367
+ const maxY = coord.y + height;
368
+
369
+ neighbors = index.range(minX, minY, maxX, maxY);
370
+ neighborLength = neighbors.length;
371
+ numPoints = 0;
372
+ ids = [];
373
+
374
+ for (j = 0; j < neighborLength; ++j) {
375
+ neighborIndex = neighbors[j];
376
+ neighborPoint = points[neighborIndex];
377
+ if (!neighborPoint.clustered) {
378
+ ++numPoints;
379
+
380
+ collection = neighborPoint.collection;
381
+ collectionIndex = neighborPoint.index;
382
+ ids.push(collection.get(collectionIndex).id);
383
+ }
384
+ }
385
+
386
+ if (numPoints >= minimumClusterSize) {
387
+ addCluster(cluster.position, numPoints, ids, entityCluster);
388
+ newClusters.push(cluster);
389
+
390
+ for (j = 0; j < neighborLength; ++j) {
391
+ points[neighbors[j]].clustered = true;
392
+ }
393
+ }
347
394
  }
395
+ }
348
396
 
349
- const coord = Billboard._computeScreenSpacePosition(
350
- Matrix4.IDENTITY,
351
- cluster.position,
352
- Cartesian3.ZERO,
353
- Cartesian2.ZERO,
354
- scene
355
- );
356
- if (!defined(coord)) {
397
+ length = points.length;
398
+ for (i = 0; i < length; ++i) {
399
+ const point = points[i];
400
+ if (point.clustered) {
357
401
  continue;
358
402
  }
359
403
 
360
- const factor = 1.0 - currentHeight / previousHeight;
361
- let width = (cluster.width = cluster.width * factor);
362
- let height = (cluster.height = cluster.height * factor);
404
+ point.clustered = true;
363
405
 
364
- width = Math.max(width, cluster.minimumWidth);
365
- height = Math.max(height, cluster.minimumHeight);
406
+ collection = point.collection;
407
+ collectionIndex = point.index;
366
408
 
367
- const minX = coord.x - width * 0.5;
368
- const minY = coord.y - height * 0.5;
369
- const maxX = coord.x + width;
370
- const maxY = coord.y + height;
409
+ const item = collection.get(collectionIndex);
410
+ bbox = getBoundingBox(
411
+ item,
412
+ point.coord,
413
+ pixelRange,
414
+ entityCluster,
415
+ pointBoundinRectangleScratch
416
+ );
417
+ const totalBBox = BoundingRectangle.clone(
418
+ bbox,
419
+ totalBoundingRectangleScratch
420
+ );
371
421
 
372
- neighbors = index.range(minX, minY, maxX, maxY);
422
+ neighbors = index.range(
423
+ bbox.x,
424
+ bbox.y,
425
+ bbox.x + bbox.width,
426
+ bbox.y + bbox.height
427
+ );
373
428
  neighborLength = neighbors.length;
374
- numPoints = 0;
375
- ids = [];
429
+
430
+ const clusterPosition = Cartesian3.clone(item.position);
431
+ numPoints = 1;
432
+ ids = [item.id];
376
433
 
377
434
  for (j = 0; j < neighborLength; ++j) {
378
435
  neighborIndex = neighbors[j];
379
436
  neighborPoint = points[neighborIndex];
380
437
  if (!neighborPoint.clustered) {
438
+ const neighborItem = neighborPoint.collection.get(
439
+ neighborPoint.index
440
+ );
441
+ const neighborBBox = getBoundingBox(
442
+ neighborItem,
443
+ neighborPoint.coord,
444
+ pixelRange,
445
+ entityCluster,
446
+ neighborBoundingRectangleScratch
447
+ );
448
+
449
+ Cartesian3.add(
450
+ neighborItem.position,
451
+ clusterPosition,
452
+ clusterPosition
453
+ );
454
+
455
+ BoundingRectangle.union(totalBBox, neighborBBox, totalBBox);
381
456
  ++numPoints;
382
457
 
383
- collection = neighborPoint.collection;
384
- collectionIndex = neighborPoint.index;
385
- ids.push(collection.get(collectionIndex).id);
458
+ ids.push(neighborItem.id);
386
459
  }
387
460
  }
388
461
 
389
462
  if (numPoints >= minimumClusterSize) {
390
- addCluster(cluster.position, numPoints, ids, entityCluster);
391
- newClusters.push(cluster);
392
-
393
- for (j = 0; j < neighborLength; ++j) {
394
- points[neighbors[j]].clustered = true;
395
- }
396
- }
397
- }
398
- }
399
-
400
- length = points.length;
401
- for (i = 0; i < length; ++i) {
402
- const point = points[i];
403
- if (point.clustered) {
404
- continue;
405
- }
406
-
407
- point.clustered = true;
408
-
409
- collection = point.collection;
410
- collectionIndex = point.index;
411
-
412
- const item = collection.get(collectionIndex);
413
- bbox = getBoundingBox(
414
- item,
415
- point.coord,
416
- pixelRange,
417
- entityCluster,
418
- pointBoundinRectangleScratch
419
- );
420
- const totalBBox = BoundingRectangle.clone(
421
- bbox,
422
- totalBoundingRectangleScratch
423
- );
424
-
425
- neighbors = index.range(
426
- bbox.x,
427
- bbox.y,
428
- bbox.x + bbox.width,
429
- bbox.y + bbox.height
430
- );
431
- neighborLength = neighbors.length;
432
-
433
- const clusterPosition = Cartesian3.clone(item.position);
434
- numPoints = 1;
435
- ids = [item.id];
436
-
437
- for (j = 0; j < neighborLength; ++j) {
438
- neighborIndex = neighbors[j];
439
- neighborPoint = points[neighborIndex];
440
- if (!neighborPoint.clustered) {
441
- const neighborItem = neighborPoint.collection.get(
442
- neighborPoint.index
443
- );
444
- const neighborBBox = getBoundingBox(
445
- neighborItem,
446
- neighborPoint.coord,
447
- pixelRange,
448
- entityCluster,
449
- neighborBoundingRectangleScratch
450
- );
451
-
452
- Cartesian3.add(
453
- neighborItem.position,
463
+ const position = Cartesian3.multiplyByScalar(
454
464
  clusterPosition,
465
+ 1.0 / numPoints,
455
466
  clusterPosition
456
467
  );
468
+ addCluster(position, numPoints, ids, entityCluster);
469
+ newClusters.push({
470
+ position: position,
471
+ width: totalBBox.width,
472
+ height: totalBBox.height,
473
+ minimumWidth: bbox.width,
474
+ minimumHeight: bbox.height,
475
+ });
457
476
 
458
- BoundingRectangle.union(totalBBox, neighborBBox, totalBBox);
459
- ++numPoints;
460
-
461
- ids.push(neighborItem.id);
462
- }
463
- }
464
-
465
- if (numPoints >= minimumClusterSize) {
466
- const position = Cartesian3.multiplyByScalar(
467
- clusterPosition,
468
- 1.0 / numPoints,
469
- clusterPosition
470
- );
471
- addCluster(position, numPoints, ids, entityCluster);
472
- newClusters.push({
473
- position: position,
474
- width: totalBBox.width,
475
- height: totalBBox.height,
476
- minimumWidth: bbox.width,
477
- minimumHeight: bbox.height,
478
- });
479
-
480
- for (j = 0; j < neighborLength; ++j) {
481
- points[neighbors[j]].clustered = true;
477
+ for (j = 0; j < neighborLength; ++j) {
478
+ points[neighbors[j]].clustered = true;
479
+ }
480
+ } else {
481
+ addNonClusteredItem(item, entityCluster);
482
482
  }
483
- } else {
484
- addNonClusteredItem(item, entityCluster);
485
483
  }
486
484
  }
487
485
 
@@ -63,6 +63,7 @@ function ModelVisualizer(scene, entityCollection) {
63
63
  this._entityCollection = entityCollection;
64
64
  this._modelHash = {};
65
65
  this._entitiesToVisualize = new AssociativeArray();
66
+
66
67
  this._onCollectionChanged(entityCollection, entityCollection.values, [], []);
67
68
  }
68
69
 
@@ -444,11 +445,12 @@ ModelVisualizer.prototype.getBoundingSphere = function (entity, result) {
444
445
 
445
446
  const scene = this._scene;
446
447
  const globe = scene.globe;
447
- const ellipsoid = globe.ellipsoid;
448
- const terrainProvider = globe.terrainProvider;
449
448
 
449
+ // cannot access a terrain provider if there is no globe; formally set to undefined
450
+ const terrainProvider = defined(globe) ? globe.terrainProvider : undefined;
450
451
  const hasHeightReference = model.heightReference !== HeightReference.NONE;
451
- if (hasHeightReference) {
452
+ if (defined(globe) && hasHeightReference) {
453
+ const ellipsoid = globe.ellipsoid;
452
454
  // We cannot query the availability of the terrain provider till its ready, so the
453
455
  // bounding sphere state will remain pending till the terrain provider is ready.
454
456
  // ready is deprecated. This is here for backwards compatibility
@@ -1173,8 +1173,9 @@ UniformState.prototype.updateFrustum = function (frustum) {
1173
1173
  this._oneOverLog2FarDepthFromNearPlusOne =
1174
1174
  1.0 / this._log2FarDepthFromNearPlusOne;
1175
1175
 
1176
- if (defined(frustum._offCenterFrustum)) {
1177
- frustum = frustum._offCenterFrustum;
1176
+ const offCenterFrustum = frustum.offCenterFrustum;
1177
+ if (defined(offCenterFrustum)) {
1178
+ frustum = offCenterFrustum;
1178
1179
  }
1179
1180
 
1180
1181
  this._frustumPlanes.x = frustum.top;
@@ -41,16 +41,16 @@ function demodernizeShader(input, isFragmentShader) {
41
41
  output = output.replaceAll(/out_FragData_(\d+)/g, `gl_FragData[$1]`);
42
42
  }
43
43
 
44
- // Replace out_FragColor with gl_FragColor.
45
- output = output.replaceAll(/out_FragColor/g, `gl_FragColor`);
46
- output = output.replaceAll(/out_FragColor\[(\d+)\]/g, `gl_FragColor[$1]`);
47
-
48
44
  // Remove all layout declarations for out_FragColor.
49
45
  output = output.replaceAll(
50
- /layout\s+\(location\s*=\s*0\)\s*out\s+vec4\s+out_FragColor/g,
46
+ /layout\s+\(location\s*=\s*0\)\s*out\s+vec4\s+out_FragColor;/g,
51
47
  ``
52
48
  );
53
49
 
50
+ // Replace out_FragColor with gl_FragColor.
51
+ output = output.replaceAll(/out_FragColor/g, `gl_FragColor`);
52
+ output = output.replaceAll(/out_FragColor\[(\d+)\]/g, `gl_FragColor[$1]`);
53
+
54
54
  if (/gl_FragDepth/.test(output)) {
55
55
  output = `#extension GL_EXT_frag_depth : enable\n${output}`;
56
56
  // Replace gl_FragDepth with gl_FragDepthEXT.
@@ -0,0 +1,12 @@
1
+ /**
2
+ * ArcGisBaseMapType enumerates the ArcGIS image tile layers that are supported by default.
3
+ *
4
+ * @enum {number}
5
+ * @see ArcGisMapServerImageryProvider
6
+ */
7
+ const ArcGisBaseMapType = {
8
+ SATELLITE: 1,
9
+ OCEANS: 2,
10
+ HILLSHADE: 3,
11
+ };
12
+ export default Object.freeze(ArcGisBaseMapType);
@@ -16,9 +16,12 @@ import RuntimeError from "../Core/RuntimeError.js";
16
16
  import TileProviderError from "../Core/TileProviderError.js";
17
17
  import WebMercatorProjection from "../Core/WebMercatorProjection.js";
18
18
  import WebMercatorTilingScheme from "../Core/WebMercatorTilingScheme.js";
19
+ import ArcGisMapService from "./ArcGisMapService.js";
19
20
  import DiscardMissingTileImagePolicy from "./DiscardMissingTileImagePolicy.js";
20
21
  import ImageryLayerFeatureInfo from "./ImageryLayerFeatureInfo.js";
21
22
  import ImageryProvider from "./ImageryProvider.js";
23
+ import ArcGisBaseMapType from "./ArcGisBaseMapType.js";
24
+ import DeveloperError from "../Core/DeveloperError.js";
22
25
 
23
26
  /**
24
27
  * @typedef {object} ArcGisMapServerImageryProvider.ConstructorOptions
@@ -39,8 +42,7 @@ import ImageryProvider from "./ImageryProvider.js";
39
42
  * that no tiles are discarded, construct and pass a {@link NeverTileDiscardPolicy} for this
40
43
  * parameter.
41
44
  * @property {boolean} [usePreCachedTilesIfAvailable=true] If true, the server's pre-cached
42
- * tiles are used if they are available. If false, any pre-cached tiles are ignored and the
43
- * 'export' service is used.
45
+ * tiles are used if they are available. Exporting Tiles is only supported with deprecated APIs.
44
46
  * @property {string} [layers] A comma-separated list of the layers to show, or undefined if all layers should be shown.
45
47
  * @property {boolean} [enablePickFeatures=true] If true, {@link ArcGisMapServerImageryProvider#pickFeatures} will invoke
46
48
  * the Identify service on the MapServer and return the features included in the response. If false,
@@ -59,6 +61,8 @@ import ImageryProvider from "./ImageryProvider.js";
59
61
  * @property {number} [tileHeight=256] The height of each tile in pixels. This parameter is ignored when accessing a tiled server.
60
62
  * @property {number} [maximumLevel] The maximum tile level to request, or undefined if there is no maximum. This parameter is ignored when accessing
61
63
  * a tiled server.
64
+ *
65
+ *
62
66
  */
63
67
 
64
68
  /**
@@ -85,6 +89,7 @@ function ImageryProviderBuilder(options) {
85
89
  credit = new Credit(credit);
86
90
  }
87
91
  this.credit = credit;
92
+ this.tileCredits = undefined;
88
93
  this.tileDiscardPolicy = options.tileDiscardPolicy;
89
94
 
90
95
  this.tileWidth = defaultValue(options.tileWidth, 256);
@@ -104,6 +109,7 @@ ImageryProviderBuilder.prototype.build = function (provider) {
104
109
  provider._tilingScheme = this.tilingScheme;
105
110
  provider._rectangle = this.rectangle;
106
111
  provider._credit = this.credit;
112
+ provider._tileCredits = this.tileCredits;
107
113
  provider._tileDiscardPolicy = this.tileDiscardPolicy;
108
114
  provider._tileWidth = this.tileWidth;
109
115
  provider._tileHeight = this.tileHeight;
@@ -221,7 +227,11 @@ function metadataSuccess(data, imageryProviderBuilder) {
221
227
  }
222
228
 
223
229
  if (defined(data.copyrightText) && data.copyrightText.length > 0) {
224
- imageryProviderBuilder.credit = new Credit(data.copyrightText);
230
+ if (defined(imageryProviderBuilder.credit)) {
231
+ imageryProviderBuilder.tileCredits = [new Credit(data.copyrightText)];
232
+ } else {
233
+ imageryProviderBuilder.credit = new Credit(data.copyrightText);
234
+ }
225
235
  }
226
236
  }
227
237
 
@@ -255,7 +265,7 @@ async function requestMetadata(resource, imageryProviderBuilder, provider) {
255
265
  });
256
266
 
257
267
  try {
258
- const data = await jsonResource.fetchJsonp();
268
+ const data = await jsonResource.fetchJson();
259
269
  metadataSuccess(data, imageryProviderBuilder);
260
270
  } catch (error) {
261
271
  metadataFailure(resource, error, provider);
@@ -264,34 +274,49 @@ async function requestMetadata(resource, imageryProviderBuilder, provider) {
264
274
 
265
275
  /**
266
276
  * <div class="notice">
267
- * To construct a ArcGisMapServerImageryProvider call {@link ArcGisMapServerImageryProvider.fromUrl}. Do not call the constructor directly.
277
+ * This object is normally not instantiated directly, use {@link ArcGisMapServerImageryProvider.fromBasemapType} or {@link ArcGisMapServerImageryProvider.fromUrl}.
268
278
  * </div>
269
279
  *
270
280
  * Provides tiled imagery hosted by an ArcGIS MapServer. By default, the server's pre-cached tiles are
271
281
  * used, if available.
282
+ *
283
+ * <br/>
284
+ *
285
+ * An {@link https://developers.arcgis.com/documentation/mapping-apis-and-services/security| ArcGIS Access Token } is required to authenticate requests to an ArcGIS Image Tile service.
286
+ * To access secure ArcGIS resources, it's required to create an ArcGIS developer
287
+ * account or an ArcGIS online account, then implement an authentication method to obtain an access token.
272
288
  *
273
289
  * @alias ArcGisMapServerImageryProvider
274
290
  * @constructor
275
291
  *
276
292
  * @param {ArcGisMapServerImageryProvider.ConstructorOptions} [options] Object describing initialization options
277
293
  *
278
- * @see ArcGisMapServerImagery.fromUrl
279
- * @see BingMapsImageryProvider
280
- * @see GoogleEarthEnterpriseMapsProvider
281
- * @see OpenStreetMapImageryProvider
282
- * @see SingleTileImageryProvider
283
- * @see TileMapServiceImageryProvider
284
- * @see WebMapServiceImageryProvider
285
- * @see WebMapTileServiceImageryProvider
286
- * @see UrlTemplateImageryProvider
294
+ * @see ArcGisMapServerImageryProvider.fromBasemapType
295
+ * @see ArcGisMapServerImageryProvider.fromUrl
296
+ *
297
+ * @example
298
+ * // Set the default access token for accessing ArcGIS Image Tile service
299
+ * Cesium.ArcGisMapService.defaultAccessToken = "<ArcGIS Access Token>";
300
+ *
301
+ * // Add a base layer from a default ArcGIS basemap
302
+ * const viewer = new Cesium.Viewer("cesiumContainer", {
303
+ * baseLayer: Cesium.ImageryLayer.fromProviderAsync(
304
+ * Cesium.ArcGisMapServerImageryProvider.fromBasemapType(
305
+ * Cesium.ArcGisBaseMapType.SATELLITE
306
+ * )
307
+ * ),
308
+ * });
287
309
  *
288
310
  * @example
311
+ * // Create an imagery provider from the url directly
289
312
  * const esri = await Cesium.ArcGisMapServerImageryProvider.fromUrl(
290
- * "https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"
291
- * );
313
+ * "https://ibasemaps-api.arcgis.com/arcgis/rest/services/World_Imagery/MapServer", {
314
+ * token: "<ArcGIS Access Token>"
315
+ * });
292
316
  *
293
317
  * @see {@link https://developers.arcgis.com/rest/|ArcGIS Server REST API}
294
- * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}
318
+ * @see {@link https://developers.arcgis.com/documentation/mapping-apis-and-services/security| ArcGIS Access Token }
319
+
295
320
  */
296
321
  function ArcGisMapServerImageryProvider(options) {
297
322
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
@@ -321,7 +346,13 @@ function ArcGisMapServerImageryProvider(options) {
321
346
  this._tilingScheme.rectangle
322
347
  );
323
348
  this._layers = options.layers;
324
- this._credit = undefined;
349
+ this._credit = options.credit;
350
+ this._tileCredits = undefined;
351
+
352
+ let credit = options.credit;
353
+ if (typeof credit === "string") {
354
+ credit = new Credit(credit);
355
+ }
325
356
 
326
357
  /**
327
358
  * Gets or sets a value indicating whether feature picking is enabled. If true, {@link ArcGisMapServerImageryProvider#pickFeatures} will
@@ -371,6 +402,117 @@ function ArcGisMapServerImageryProvider(options) {
371
402
  }
372
403
  }
373
404
 
405
+ /**
406
+ * Creates an {@link ImageryProvider} which provides tiled imagery from an ArcGIS base map.
407
+ * @param {ArcGisBaseMapType} style The style of the ArcGIS base map imagery. Valid options are {@link ArcGisBaseMapType.SATELLITE}, {@link ArcGisBaseMapType.OCEANS}, and {@link ArcGisBaseMapType.HILLSHADE}.
408
+ * @param {ArcGisMapServerImageryProvider.ConstructorOptions} [options] Object describing initialization options.
409
+ * @returns {Promise<ArcGisMapServerImageryProvider>} A promise that resolves to the created ArcGisMapServerImageryProvider.
410
+ *
411
+ * @example
412
+ * // Set the default access token for accessing ArcGIS Image Tile service
413
+ * Cesium.ArcGisMapService.defaultAccessToken = "<ArcGIS Access Token>";
414
+ *
415
+ * // Add a base layer from a default ArcGIS basemap
416
+ * const provider = await Cesium.ArcGisMapServerImageryProvider.fromBasemapType(
417
+ * Cesium.ArcGisBaseMapType.SATELLITE);
418
+ *
419
+ * @example
420
+ * // Add a base layer from a default ArcGIS Basemap
421
+ * const viewer = new Cesium.Viewer("cesiumContainer", {
422
+ * baseLayer: Cesium.ImageryLayer.fromProviderAsync(
423
+ * Cesium.ArcGisMapServerImageryProvider.fromBasemapType(
424
+ * Cesium.ArcGisBaseMapType.HILLSHADE, {
425
+ * token: "<ArcGIS Access Token>"
426
+ * }
427
+ * )
428
+ * ),
429
+ * });
430
+ */
431
+
432
+ ArcGisMapServerImageryProvider.fromBasemapType = async function (
433
+ style,
434
+ options
435
+ ) {
436
+ //>>includeStart('debug', pragmas.debug);
437
+ Check.defined("style", style);
438
+ //>>includeEnd('debug');
439
+
440
+ options = defaultValue(options, defaultValue.EMPTY_OBJECT);
441
+ let accessToken;
442
+ let server;
443
+ let warningCredit;
444
+ switch (style) {
445
+ case ArcGisBaseMapType.SATELLITE:
446
+ {
447
+ accessToken = defaultValue(
448
+ options.token,
449
+ ArcGisMapService.defaultAccessToken
450
+ );
451
+ server = Resource.createIfNeeded(
452
+ defaultValue(options.url, ArcGisMapService.defaultWorldImageryServer)
453
+ );
454
+ server.appendForwardSlash();
455
+ const defaultTokenCredit = ArcGisMapService.getDefaultTokenCredit(
456
+ accessToken
457
+ );
458
+ if (defined(defaultTokenCredit)) {
459
+ warningCredit = Credit.clone(defaultTokenCredit);
460
+ }
461
+ }
462
+ break;
463
+ case ArcGisBaseMapType.OCEANS:
464
+ {
465
+ accessToken = defaultValue(
466
+ options.token,
467
+ ArcGisMapService.defaultAccessToken
468
+ );
469
+ server = Resource.createIfNeeded(
470
+ defaultValue(options.url, ArcGisMapService.defaultWorldOceanServer)
471
+ );
472
+ server.appendForwardSlash();
473
+ const defaultTokenCredit = ArcGisMapService.getDefaultTokenCredit(
474
+ accessToken
475
+ );
476
+ if (defined(defaultTokenCredit)) {
477
+ warningCredit = Credit.clone(defaultTokenCredit);
478
+ }
479
+ }
480
+ break;
481
+ case ArcGisBaseMapType.HILLSHADE:
482
+ {
483
+ accessToken = defaultValue(
484
+ options.token,
485
+ ArcGisMapService.defaultAccessToken
486
+ );
487
+ server = Resource.createIfNeeded(
488
+ defaultValue(
489
+ options.url,
490
+ ArcGisMapService.defaultWorldHillshadeServer
491
+ )
492
+ );
493
+ server.appendForwardSlash();
494
+ const defaultTokenCredit = ArcGisMapService.getDefaultTokenCredit(
495
+ accessToken
496
+ );
497
+ if (defined(defaultTokenCredit)) {
498
+ warningCredit = Credit.clone(defaultTokenCredit);
499
+ }
500
+ }
501
+ break;
502
+ default:
503
+ //>>includeStart('debug', pragmas.debug);
504
+ throw new DeveloperError(`Unsupported basemap type: ${style}`);
505
+ //>>includeEnd('debug');
506
+ }
507
+
508
+ return ArcGisMapServerImageryProvider.fromUrl(server, {
509
+ ...options,
510
+ token: accessToken,
511
+ credit: warningCredit,
512
+ usePreCachedTilesIfAvailable: true, // ArcGIS Base Map Service Layers only support Tiled views
513
+ });
514
+ };
515
+
374
516
  function buildImageResource(imageryProvider, x, y, level, request) {
375
517
  let resource;
376
518
  if (imageryProvider._useTiles) {
@@ -413,7 +555,6 @@ function buildImageResource(imageryProvider, x, y, level, request) {
413
555
  queryParameters: query,
414
556
  });
415
557
  }
416
-
417
558
  return resource;
418
559
  }
419
560
 
@@ -941,7 +1082,7 @@ ArcGisMapServerImageryProvider.prototype.getTileCredits = function (
941
1082
  y,
942
1083
  level
943
1084
  ) {
944
- return undefined;
1085
+ return this._tileCredits;
945
1086
  };
946
1087
 
947
1088
  /**
@@ -1078,4 +1219,5 @@ ArcGisMapServerImageryProvider.prototype.pickFeatures = function (
1078
1219
  return result;
1079
1220
  });
1080
1221
  };
1222
+ ArcGisMapServerImageryProvider._metadataCache = {};
1081
1223
  export default ArcGisMapServerImageryProvider;