@cesium/engine 22.2.0 → 22.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 (215) hide show
  1. package/Build/Workers/{chunk-C35SJ4QP.js → chunk-2MLJ46ZZ.js} +13 -13
  2. package/Build/Workers/{chunk-JERDRSEI.js → chunk-4BBANFU6.js} +1 -1
  3. package/Build/Workers/{chunk-JONWM4IO.js → chunk-4O2ARYS7.js} +1 -1
  4. package/Build/Workers/{chunk-VGH2CSC7.js → chunk-4R6FGUFP.js} +9 -9
  5. package/Build/Workers/{chunk-IVN5HSOI.js → chunk-5PJB7ASO.js} +6 -6
  6. package/Build/Workers/{chunk-35J4D6PX.js → chunk-6GBGEUWR.js} +2 -2
  7. package/Build/Workers/{chunk-DCR62BCO.js → chunk-6WDMPXQ7.js} +12 -12
  8. package/Build/Workers/{chunk-4ZQN7M7E.js → chunk-7ATKQRBM.js} +10 -10
  9. package/Build/Workers/{chunk-FPRM6PCE.js → chunk-7SLNBIZS.js} +5 -34
  10. package/Build/Workers/{chunk-VSZ5DB2W.js → chunk-7U5YNLF3.js} +1 -1
  11. package/Build/Workers/{chunk-I4D5IP46.js → chunk-AFGP5BXS.js} +7 -7
  12. package/Build/Workers/{chunk-IWOSJVFQ.js → chunk-AWELU5C6.js} +14 -14
  13. package/Build/Workers/{chunk-LDSQMLRC.js → chunk-BO22JHBX.js} +3 -3
  14. package/Build/Workers/{chunk-2YVTOY5Z.js → chunk-D2PEV362.js} +10 -10
  15. package/Build/Workers/{chunk-PSHZAHFE.js → chunk-D63Z7KKL.js} +11 -11
  16. package/Build/Workers/{chunk-AMWXJ5A7.js → chunk-D6OKR3BQ.js} +2 -2
  17. package/Build/Workers/{chunk-I45CATZK.js → chunk-E4YDCSQK.js} +9 -9
  18. package/Build/Workers/{chunk-YFEZPDAY.js → chunk-EAAH543Q.js} +11 -11
  19. package/Build/Workers/{chunk-SDUH3N6G.js → chunk-EOSX23OS.js} +4 -4
  20. package/Build/Workers/{chunk-A3NUMZBG.js → chunk-EUDHHS7K.js} +6 -6
  21. package/Build/Workers/{chunk-BKYJBTHW.js → chunk-EY5HOJFQ.js} +5 -5
  22. package/Build/Workers/{chunk-64PJ4MTB.js → chunk-FDOLXORR.js} +7 -7
  23. package/Build/Workers/{chunk-WH4HDRGN.js → chunk-FS42VX2H.js} +2 -2
  24. package/Build/Workers/{chunk-ED4UXMYY.js → chunk-FUDC3KOT.js} +5 -5
  25. package/Build/Workers/{chunk-CQCEPC6N.js → chunk-HWGP4GVC.js} +13 -13
  26. package/Build/Workers/{chunk-QO6Z5UJE.js → chunk-IHFAFGR2.js} +2 -2
  27. package/Build/Workers/{chunk-72LZ3FN6.js → chunk-IXL46IYV.js} +12 -12
  28. package/Build/Workers/{chunk-JFN2DQHY.js → chunk-K2PLKJJG.js} +5 -5
  29. package/Build/Workers/{chunk-NY3CWLIZ.js → chunk-K4PGSAR5.js} +8 -8
  30. package/Build/Workers/{chunk-UBJYWGMV.js → chunk-KIJR26N3.js} +16 -16
  31. package/Build/Workers/{chunk-MWGB6DLR.js → chunk-L4OFWHNI.js} +1 -1
  32. package/Build/Workers/{chunk-XPNY2VY3.js → chunk-LK7GEFGB.js} +2 -2
  33. package/Build/Workers/{chunk-3JB2X2PR.js → chunk-LWZHJWYK.js} +6 -6
  34. package/Build/Workers/{chunk-ZGWX2R5I.js → chunk-LYBNPUEI.js} +4 -4
  35. package/Build/Workers/{chunk-4I7BCCNU.js → chunk-M5DVYXJJ.js} +6 -6
  36. package/Build/Workers/{chunk-4MCPC4TE.js → chunk-MASEF4OV.js} +8 -8
  37. package/Build/Workers/{chunk-FM5XPC2E.js → chunk-N66PIK46.js} +4 -4
  38. package/Build/Workers/{chunk-C6FTHSJA.js → chunk-N6XBJBI7.js} +6 -6
  39. package/Build/Workers/{chunk-7OPRTZBT.js → chunk-NO3LMU7T.js} +7 -7
  40. package/Build/Workers/{chunk-DIJ7IG5D.js → chunk-NVL7JXAQ.js} +10 -10
  41. package/Build/Workers/{chunk-O3GWUTWM.js → chunk-OOYICVOK.js} +1 -1
  42. package/Build/Workers/{chunk-K6BXEBAF.js → chunk-PJLRXIMS.js} +17 -17
  43. package/Build/Workers/{chunk-7CDQUIP5.js → chunk-S2KVL7OJ.js} +8 -8
  44. package/Build/Workers/{chunk-PMDPP22G.js → chunk-T5MJDW43.js} +7 -7
  45. package/Build/Workers/{chunk-GMHDOQPH.js → chunk-TCOUGKXF.js} +4 -4
  46. package/Build/Workers/{chunk-ZUWF63QU.js → chunk-TMGLPEZW.js} +4 -4
  47. package/Build/Workers/{chunk-JUOSYFXT.js → chunk-TY5JXMVO.js} +1 -1
  48. package/Build/Workers/{chunk-3HUEBDFC.js → chunk-VIQIKMTZ.js} +14 -14
  49. package/Build/Workers/{chunk-N5MNKWED.js → chunk-VRAAQ3FS.js} +2 -2
  50. package/Build/Workers/{chunk-K64RQCRK.js → chunk-W5NV72VR.js} +17 -17
  51. package/Build/Workers/{chunk-G6WQA27G.js → chunk-WHLGBMBC.js} +5 -5
  52. package/Build/Workers/{chunk-2JNPWPLE.js → chunk-WUWPKBOZ.js} +6 -6
  53. package/Build/Workers/{chunk-MSTAVM2N.js → chunk-XLIJV3YZ.js} +10 -10
  54. package/Build/Workers/{chunk-V26Y7ZQL.js → chunk-Y5MRBKQN.js} +37 -27
  55. package/Build/Workers/{chunk-L2FSBEW2.js → chunk-YHPBT4I5.js} +5 -5
  56. package/Build/Workers/{chunk-7MGTX4WP.js → chunk-ZGGVEGTA.js} +12 -12
  57. package/Build/Workers/{chunk-P7ISUYLW.js → chunk-ZWWN2CQH.js} +4 -4
  58. package/Build/Workers/combineGeometry.js +24 -24
  59. package/Build/Workers/createBoxGeometry.js +18 -18
  60. package/Build/Workers/createBoxOutlineGeometry.js +16 -16
  61. package/Build/Workers/createCircleGeometry.js +26 -26
  62. package/Build/Workers/createCircleOutlineGeometry.js +19 -19
  63. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
  64. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
  65. package/Build/Workers/createCorridorGeometry.js +29 -29
  66. package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
  67. package/Build/Workers/createCylinderGeometry.js +20 -20
  68. package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
  69. package/Build/Workers/createEllipseGeometry.js +26 -26
  70. package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
  71. package/Build/Workers/createEllipsoidGeometry.js +19 -19
  72. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
  73. package/Build/Workers/createFrustumGeometry.js +18 -18
  74. package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
  75. package/Build/Workers/createGeometry.js +24 -24
  76. package/Build/Workers/createGroundPolylineGeometry.js +22 -22
  77. package/Build/Workers/createPlaneGeometry.js +16 -16
  78. package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
  79. package/Build/Workers/createPolygonGeometry.js +32 -32
  80. package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
  81. package/Build/Workers/createPolylineGeometry.js +25 -25
  82. package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
  83. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
  84. package/Build/Workers/createRectangleGeometry.js +27 -27
  85. package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
  86. package/Build/Workers/createSimplePolylineGeometry.js +23 -23
  87. package/Build/Workers/createSphereGeometry.js +19 -19
  88. package/Build/Workers/createSphereOutlineGeometry.js +18 -18
  89. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  90. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  91. package/Build/Workers/createVectorTileGeometries.js +24 -24
  92. package/Build/Workers/createVectorTilePoints.js +13 -13
  93. package/Build/Workers/createVectorTilePolygons.js +22 -22
  94. package/Build/Workers/createVectorTilePolylines.js +14 -14
  95. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
  96. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
  97. package/Build/Workers/createVerticesFromHeightmap.js +22 -22
  98. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
  99. package/Build/Workers/createWallGeometry.js +24 -24
  100. package/Build/Workers/createWallOutlineGeometry.js +23 -23
  101. package/Build/Workers/decodeDraco.js +10 -10
  102. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  103. package/Build/Workers/decodeI3S.js +10 -10
  104. package/Build/Workers/gaussianSplatSorter.js +4 -4
  105. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  106. package/Build/Workers/incrementallyBuildTerrainPicker.js +20 -12
  107. package/Build/Workers/transcodeKTX2.js +6 -6
  108. package/Build/Workers/transferTypedArrayTest.js +1 -1
  109. package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
  110. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
  111. package/Source/Core/BoxGeometry.js +1 -1
  112. package/Source/Core/CornerType.js +1 -1
  113. package/Source/Core/CorridorGeometry.js +1 -1
  114. package/Source/Core/FeatureDetection.js +1 -32
  115. package/Source/Core/Geometry.js +1 -1
  116. package/Source/Core/IntersectionTests.js +2 -2
  117. package/Source/Core/Ion.js +1 -1
  118. package/Source/Core/PinBuilder.js +1 -1
  119. package/Source/Core/PolygonGeometry.js +1 -1
  120. package/Source/Core/PolylineGeometry.js +1 -1
  121. package/Source/Core/PolylineVolumeGeometry.js +1 -1
  122. package/Source/Core/RectangleGeometry.js +1 -1
  123. package/Source/Core/ScreenSpaceEventHandler.js +4 -8
  124. package/Source/Core/TerrainMesh.js +11 -8
  125. package/Source/Core/TerrainPicker.js +24 -7
  126. package/Source/Core/VideoSynchronizer.js +1 -1
  127. package/Source/Core/WallGeometry.js +1 -1
  128. package/Source/Core/writeTextToCanvas.js +40 -86
  129. package/Source/DataSources/BillboardGraphics.js +1 -1
  130. package/Source/DataSources/BoxGraphics.js +1 -1
  131. package/Source/DataSources/CallbackPositionProperty.js +1 -1
  132. package/Source/DataSources/CorridorGraphics.js +1 -1
  133. package/Source/DataSources/CzmlDataSource.js +1 -1
  134. package/Source/DataSources/EllipseGraphics.js +1 -1
  135. package/Source/DataSources/EllipsoidGraphics.js +1 -1
  136. package/Source/DataSources/Entity.js +1 -1
  137. package/Source/DataSources/EntityCluster.js +2 -2
  138. package/Source/DataSources/GeoJsonDataSource.js +2 -2
  139. package/Source/DataSources/GpxDataSource.js +1 -1
  140. package/Source/DataSources/KmlDataSource.js +1 -1
  141. package/Source/DataSources/KmlTour.js +1 -1
  142. package/Source/DataSources/LabelGraphics.js +1 -1
  143. package/Source/DataSources/ModelGraphics.js +1 -1
  144. package/Source/DataSources/PlaneGraphics.js +1 -1
  145. package/Source/DataSources/PolygonGraphics.js +1 -1
  146. package/Source/DataSources/PolylineGraphics.js +1 -1
  147. package/Source/DataSources/PolylineVolumeGraphics.js +1 -1
  148. package/Source/DataSources/RectangleGraphics.js +1 -1
  149. package/Source/DataSources/WallGraphics.js +1 -1
  150. package/Source/DataSources/exportKml.js +1 -1
  151. package/Source/Renderer/Context.js +11 -10
  152. package/Source/Renderer/ContextLimits.js +66 -33
  153. package/Source/Renderer/ShaderSource.js +19 -18
  154. package/Source/Renderer/Texture.js +1 -1
  155. package/Source/Renderer/Texture3D.js +166 -7
  156. package/Source/Renderer/TextureAtlas.js +2 -2
  157. package/Source/Scene/Appearance.js +1 -1
  158. package/Source/Scene/ArcGisMapService.js +1 -1
  159. package/Source/Scene/Billboard.js +1 -1
  160. package/Source/Scene/BillboardCollection.js +1 -1
  161. package/Source/Scene/BillboardTexture.js +4 -1
  162. package/Source/Scene/Camera.js +13 -2
  163. package/Source/Scene/ClippingPlaneCollection.js +2 -2
  164. package/Source/Scene/CloudCollection.js +2 -2
  165. package/Source/Scene/CumulusCloud.js +1 -1
  166. package/Source/Scene/DynamicEnvironmentMapManager.js +41 -26
  167. package/Source/Scene/Fog.js +1 -1
  168. package/Source/Scene/GaussianSplatPrimitive.js +1 -1
  169. package/Source/Scene/Globe.js +3 -10
  170. package/Source/Scene/GltfLoader.js +10 -0
  171. package/Source/Scene/ImageBasedLighting.js +2 -2
  172. package/Source/Scene/ImageryLayerCollection.js +2 -2
  173. package/Source/Scene/ImageryProvider.js +2 -2
  174. package/Source/Scene/Label.js +1 -1
  175. package/Source/Scene/LabelCollection.js +1 -1
  176. package/Source/Scene/Material.js +1 -1
  177. package/Source/Scene/MaterialAppearance.js +1 -1
  178. package/Source/Scene/Megatexture.js +174 -242
  179. package/Source/Scene/Model/MaterialPipelineStage.js +17 -0
  180. package/Source/Scene/Model/Model.js +1 -1
  181. package/Source/Scene/ModelComponents.js +10 -0
  182. package/Source/Scene/ParticleSystem.js +2 -2
  183. package/Source/Scene/PointPrimitive.js +1 -1
  184. package/Source/Scene/Polyline.js +0 -1
  185. package/Source/Scene/PolylineCollection.js +1 -4
  186. package/Source/Scene/PolylineColorAppearance.js +1 -6
  187. package/Source/Scene/PolylineMaterialAppearance.js +1 -6
  188. package/Source/Scene/PostProcessStageCollection.js +1 -1
  189. package/Source/Scene/QuadtreePrimitive.js +6 -3
  190. package/Source/Scene/ShadowMap.js +1 -2
  191. package/Source/Scene/Vector3DTileClampedPolylines.js +1 -5
  192. package/Source/Scene/Vector3DTilePolylines.js +1 -5
  193. package/Source/Scene/VoxelPrimitive.js +16 -33
  194. package/Source/Scene/VoxelRenderResources.js +1 -8
  195. package/Source/Scene/VoxelTraversal.js +16 -61
  196. package/Source/Scene/WebMapTileServiceImageryProvider.js +1 -1
  197. package/Source/Scene/createElevationBandMaterial.js +1 -1
  198. package/Source/Scene/processVoxelProperties.js +1 -1
  199. package/Source/Shaders/Builtin/Functions/columbusViewMorph.glsl +8 -1
  200. package/Source/Shaders/Builtin/Functions/columbusViewMorph.js +8 -1
  201. package/Source/Shaders/Model/ModelFS.glsl +8 -0
  202. package/Source/Shaders/Model/ModelFS.js +8 -0
  203. package/Source/Shaders/Model/ModelVS.glsl +2 -0
  204. package/Source/Shaders/Model/ModelVS.js +2 -0
  205. package/Source/Shaders/Voxels/IntersectionUtils.glsl +1 -1
  206. package/Source/Shaders/Voxels/IntersectionUtils.js +1 -1
  207. package/Source/Shaders/Voxels/Megatexture.glsl +15 -83
  208. package/Source/Shaders/Voxels/Megatexture.js +15 -83
  209. package/Source/Shaders/Voxels/Octree.glsl +6 -9
  210. package/Source/Shaders/Voxels/Octree.js +6 -9
  211. package/Source/Widget/CesiumWidget.js +1 -1
  212. package/Source/Workers/incrementallyBuildTerrainPicker.js +16 -2
  213. package/index.d.ts +18 -4
  214. package/index.js +90 -90
  215. package/package.json +2 -1
@@ -10,6 +10,7 @@ import SceneMode from "../Scene/SceneMode.js";
10
10
  import Interval from "./Interval.js";
11
11
  import Check from "./Check.js";
12
12
  import DeveloperError from "./DeveloperError.js";
13
+ import CesiumMath from "./Math.js";
13
14
 
14
15
  // Terrain picker can be 4 levels deep (0-3)
15
16
  const MAXIMUM_TERRAIN_PICKER_LEVEL = 3;
@@ -20,7 +21,7 @@ const MAXIMUM_TERRAIN_PICKER_LEVEL = 3;
20
21
  * @alias TerrainPicker
21
22
  * @constructor
22
23
  *
23
- * @param {Float32Array} vertices The terrain mesh's vertex buffer.
24
+ * @param {Float64Array} vertices The terrain mesh's vertex buffer.
24
25
  * @param {Uint8Array|Uint16Array|Uint32Array} indices The terrain mesh's index buffer.
25
26
  * @param {TerrainEncoding} encoding The terrain mesh's vertex encoding.
26
27
  *
@@ -35,7 +36,7 @@ function TerrainPicker(vertices, indices, encoding) {
35
36
 
36
37
  /**
37
38
  * The terrain mesh's vertex buffer.
38
- * @type {Float32Array}
39
+ * @type {Float64Array}
39
40
  */
40
41
  this._vertices = vertices;
41
42
  /**
@@ -268,7 +269,7 @@ function createAABBForNode(x, y, level) {
268
269
  /**
269
270
  * Packs triangle vertex positions and index into provided buffers, for the worker to process.
270
271
  * (The worker does tests to organize triangles into child nodes of the quadtree.)
271
- * @param {Float32Array} trianglePositionsBuffer The buffer to pack triangle vertex positions into.
272
+ * @param {Float64Array} trianglePositionsBuffer The buffer to pack triangle vertex positions into.
272
273
  * @param {Uint32Array} triangleIndicesBuffer The buffer to pack triangle indices into.
273
274
  * @param {Cartesian3[]} trianglePositions The triangle's vertex positions.
274
275
  * @param {number} triangleIndex The triangle's index in the overall tile's index buffer.
@@ -424,7 +425,7 @@ function getClosestTriangleInNode(
424
425
  let triangleIndices;
425
426
  if (shouldBuildChildren) {
426
427
  // If the tree can be built deeper, prepare buffers to store triangle data for child nodes
427
- trianglePositions = new Float32Array(triangleCount * 9); // 3 vertices per triangle * 3 floats per vertex
428
+ trianglePositions = new Float64Array(triangleCount * 9); // 3 vertices per triangle * 3 floats per vertex
428
429
  triangleIndices = new Uint32Array(triangleCount);
429
430
  }
430
431
 
@@ -434,6 +435,7 @@ function getClosestTriangleInNode(
434
435
  encoding,
435
436
  mode,
436
437
  projection,
438
+ ray,
437
439
  vertices,
438
440
  indices[3 * triIndex],
439
441
  scratchTrianglePoints[0],
@@ -442,6 +444,7 @@ function getClosestTriangleInNode(
442
444
  encoding,
443
445
  mode,
444
446
  projection,
447
+ ray,
445
448
  vertices,
446
449
  indices[3 * triIndex + 1],
447
450
  scratchTrianglePoints[1],
@@ -450,6 +453,7 @@ function getClosestTriangleInNode(
450
453
  encoding,
451
454
  mode,
452
455
  projection,
456
+ ray,
453
457
  vertices,
454
458
  indices[3 * triIndex + 2],
455
459
  scratchTrianglePoints[2],
@@ -502,7 +506,8 @@ const scratchCartographic = new Cartographic();
502
506
  * @param {TerrainEncoding} encoding The terrain encoding.
503
507
  * @param {SceneMode} mode The scene mode (2D/3D/Columbus View).
504
508
  * @param {MapProjection} projection The map projection.
505
- * @param {Float32Array} vertices The vertex buffer of the terrain mesh.
509
+ * @param {Ray} ray The pick ray being tested (used here as a reference to resolve antimeridian wrapping in 2D/Columbus View).
510
+ * @param {Float64Array} vertices The terrain mesh's vertex buffer.
506
511
  * @param {Number} index The index of the vertex to get.
507
512
  * @param {Cartesian3} result The decoded, exaggerated, and possibly projected vertex position.
508
513
  * @returns {Cartesian3} The result vertex position.
@@ -512,6 +517,7 @@ function getVertexPosition(
512
517
  encoding,
513
518
  mode,
514
519
  projection,
520
+ ray,
515
521
  vertices,
516
522
  index,
517
523
  result,
@@ -535,6 +541,14 @@ function getVertexPosition(
535
541
  result,
536
542
  );
537
543
 
544
+ // Due to wrapping in 2D/CV modes, near the antimeridian, the vertex
545
+ // position may correspond to the other side of the world from the ray origin.
546
+ // Compare the vertex position to the ray origin and adjust it accordingly.
547
+ // A spherical approximation is sufficient for cylindrical projections,
548
+ // like mercator and geographic.
549
+ const worldWidth = CesiumMath.TWO_PI * projection.ellipsoid.maximumRadius;
550
+ const k = Math.round((ray.origin.y - position.y) / worldWidth);
551
+ position.y += k * worldWidth;
538
552
  return position;
539
553
  }
540
554
 
@@ -544,7 +558,7 @@ function getVertexPosition(
544
558
  * @param {Matrix4} inverseTransform
545
559
  * @param {TerrainNode} node
546
560
  * @param {Uint32Array} triangleIndices
547
- * @param {Float32Array} trianglePositions
561
+ * @param {Float64Array} trianglePositions
548
562
  * @returns {Promise<void>} A promise that resolves when the triangles have been added to the child nodes.
549
563
  * @private
550
564
  */
@@ -596,7 +610,10 @@ async function addTrianglesToChildrenNodes(
596
610
  // Assign these to the child nodes
597
611
  const result = await incrementallyBuildTerrainPickerPromise;
598
612
  result.intersectingTrianglesArrays.forEach((buffer, index) => {
599
- node.children[index].intersectingTriangles = new Uint32Array(buffer);
613
+ // Guard against case where tree is reset while waiting for worker
614
+ if (defined(node.children[index])) {
615
+ node.children[index].intersectingTriangles = new Uint32Array(buffer);
616
+ }
600
617
  });
601
618
 
602
619
  // The node's triangles have been distributed to its children
@@ -16,7 +16,7 @@ import JulianDate from "./JulianDate.js";
16
16
  * @param {JulianDate} [options.epoch=Iso8601.MINIMUM_VALUE] The simulation time that marks the start of the video.
17
17
  * @param {number} [options.tolerance=1.0] The maximum amount of time, in seconds, that the clock and video can diverge.
18
18
  *
19
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Video.html|Video Material Demo}
19
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=video|Video Material Demo}
20
20
  */
21
21
  function VideoSynchronizer(options) {
22
22
  options = options ?? Frozen.EMPTY_OBJECT;
@@ -46,7 +46,7 @@ const scratchNormal = new Cartesian3();
46
46
  * @see WallGeometry#createGeometry
47
47
  * @see WallGeometry#fromConstantHeight
48
48
  *
49
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Wall.html|Cesium Sandcastle Wall Demo}
49
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=wall|Cesium Sandcastle Wall Demo}
50
50
  *
51
51
  * @example
52
52
  * // create a wall that spans from ground level to 10000 meters
@@ -3,95 +3,41 @@ import Frozen from "./Frozen.js";
3
3
  import defined from "./defined.js";
4
4
  import DeveloperError from "./DeveloperError.js";
5
5
 
6
- function measureText(context2D, textString, font, stroke, fill) {
6
+ /**
7
+ * Computes dimensions for text, based on current canvas state.
8
+ *
9
+ * Rounds metrics, excluding width, to whole pixels. This is purely to minimize
10
+ * rendering differences with migration to in-browser measureText(), and may be
11
+ * revised in the future. See: github.com/CesiumGS/cesium/pull/13081
12
+ */
13
+ function measureText(context2D, textString) {
7
14
  const metrics = context2D.measureText(textString);
8
15
  const isSpace = !/\S/.test(textString);
9
16
 
10
- if (!isSpace) {
11
- const fontSize = document.defaultView
12
- .getComputedStyle(context2D.canvas)
13
- .getPropertyValue("font-size")
14
- .replace("px", "");
15
- const canvas = document.createElement("canvas");
16
- const padding = 100;
17
- const width = (metrics.width + padding) | 0;
18
- const height = 3 * fontSize;
19
- const baseline = height / 2;
20
- canvas.width = width;
21
- canvas.height = height;
22
-
23
- const ctx = canvas.getContext("2d");
24
- ctx.font = font;
25
- ctx.fillStyle = "white";
26
- ctx.fillRect(0, 0, canvas.width + 1, canvas.height + 1);
27
-
28
- if (stroke) {
29
- ctx.strokeStyle = "black";
30
- ctx.lineWidth = context2D.lineWidth;
31
- ctx.strokeText(textString, padding / 2, baseline);
32
- }
33
-
34
- if (fill) {
35
- ctx.fillStyle = "black";
36
- ctx.fillText(textString, padding / 2, baseline);
37
- }
38
-
39
- // Context image data has width * height * 4 elements, because
40
- // each pixel's R, G, B and A are consecutive values in the array.
41
- const pixelData = ctx.getImageData(0, 0, width, height).data;
42
- const length = pixelData.length;
43
- const width4 = width * 4;
44
- let i, j;
45
-
46
- let ascent, descent;
47
- // Find the number of rows (from the top) until the first non-white pixel
48
- for (i = 0; i < length; ++i) {
49
- if (pixelData[i] !== 255) {
50
- ascent = (i / width4) | 0;
51
- break;
52
- }
53
- }
54
-
55
- // Find the number of rows (from the bottom) until the first non-white pixel
56
- for (i = length - 1; i >= 0; --i) {
57
- if (pixelData[i] !== 255) {
58
- descent = (i / width4) | 0;
59
- break;
60
- }
61
- }
62
-
63
- let minx = -1;
64
- // For each column, for each row, check for first non-white pixel
65
- for (i = 0; i < width && minx === -1; ++i) {
66
- for (j = 0; j < height; ++j) {
67
- const pixelIndex = i * 4 + j * width4;
68
- if (
69
- pixelData[pixelIndex] !== 255 ||
70
- pixelData[pixelIndex + 1] !== 255 ||
71
- pixelData[pixelIndex + 2] !== 255 ||
72
- pixelData[pixelIndex + 3] !== 255
73
- ) {
74
- minx = i;
75
- break;
76
- }
77
- }
78
- }
79
-
17
+ if (isSpace) {
80
18
  return {
81
19
  width: metrics.width,
82
- height: descent - ascent,
83
- ascent: baseline - ascent,
84
- descent: descent - baseline,
85
- minx: minx - padding / 2,
20
+ height: 0,
21
+ ascent: 0,
22
+ descent: 0,
23
+ minx: 0,
86
24
  };
87
25
  }
88
26
 
27
+ // Baseline alignment requires `height = ascent + descent`. Rounding (if any)
28
+ // must be done before summing, or glyph pairs like "ij" may be misaligned.
29
+ const ascent = Math.round(metrics.actualBoundingBoxAscent);
30
+ const descent = Math.round(metrics.actualBoundingBoxDescent);
31
+
32
+ // Characters like "_" may have height <0.5 at some sizes, don't round to zero.
33
+ const height = Math.max(ascent + descent, 1);
34
+
89
35
  return {
90
36
  width: metrics.width,
91
- height: 0,
92
- ascent: 0,
93
- descent: 0,
94
- minx: 0,
37
+ height,
38
+ ascent,
39
+ descent,
40
+ minx: -Math.round(metrics.actualBoundingBoxLeft),
95
41
  };
96
42
  }
97
43
 
@@ -164,28 +110,36 @@ function writeTextToCanvas(text, options) {
164
110
  canvas.style.visibility = "hidden";
165
111
  document.body.appendChild(canvas);
166
112
 
167
- const dimensions = measureText(context2D, text, font, stroke, fill);
168
- // Set canvas.dimensions to be accessed in LabelCollection
113
+ const dimensions = measureText(context2D, text);
114
+
115
+ // Set canvas.dimensions to be accessed in LabelCollection. LabelCollection
116
+ // hard-codes strokeWidth=0, so dimensions should not include stroke padding.
169
117
  canvas.dimensions = dimensions;
170
118
 
171
119
  document.body.removeChild(canvas);
172
120
  canvas.style.visibility = "";
173
121
 
122
+ // measureText does not account for stroke width, added here. LabelCollection
123
+ // calls writeTextToCanvas with hard-coded strokeWidth=0, so stroke padding
124
+ // matters only when calling `writeTextToCanvas` directly.
125
+ const isSpace = !/\S/.test(text);
126
+ const strokePadding = stroke && !isSpace ? Math.ceil(strokeWidth / 2) : 0;
127
+ const doubleStrokePadding = strokePadding * 2;
128
+
174
129
  // Some characters, such as the letter j, have a non-zero starting position.
175
130
  // This value is used for kerning later, but we need to take it into account
176
131
  // now in order to draw the text completely on the canvas
177
- const x = -dimensions.minx;
132
+ const x = -dimensions.minx + strokePadding;
178
133
 
179
134
  // Expand the width to include the starting position.
180
- const width = Math.ceil(dimensions.width) + x + doublePadding;
135
+ const width = Math.ceil(dimensions.width) + x + doublePadding + strokePadding;
181
136
 
182
137
  // While the height of the letter is correct, we need to adjust
183
138
  // where we start drawing it so that letters like j and y properly dip
184
139
  // below the line.
185
140
 
186
- const height = dimensions.height + doublePadding;
187
- const baseline = height - dimensions.ascent + padding;
188
- const y = height - baseline + doublePadding;
141
+ const height = dimensions.height + doublePadding + doubleStrokePadding;
142
+ const y = dimensions.ascent + padding + strokePadding;
189
143
 
190
144
  canvas.width = width;
191
145
  canvas.height = height;
@@ -46,7 +46,7 @@ import createPropertyDescriptor from "./createPropertyDescriptor.js";
46
46
  *
47
47
  * @param {BillboardGraphics.ConstructorOptions} [options] Object describing initialization options
48
48
  *
49
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Billboards.html|Cesium Sandcastle Billboard Demo}
49
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=billboards|Cesium Sandcastle Billboard Demo}
50
50
  */
51
51
  function BillboardGraphics(options) {
52
52
  this._definitionChanged = new Event();
@@ -31,7 +31,7 @@ import createPropertyDescriptor from "./createPropertyDescriptor.js";
31
31
  *
32
32
  * @param {BoxGraphics.ConstructorOptions} [options] Object describing initialization options
33
33
  *
34
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Box.html|Cesium Sandcastle Box Demo}
34
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=box|Cesium Sandcastle Box Demo}
35
35
  */
36
36
  function BoxGraphics(options) {
37
37
  this._definitionChanged = new Event();
@@ -15,7 +15,7 @@ import PositionProperty from "./PositionProperty.js";
15
15
  * @param {boolean} isConstant <code>true</code> when the callback function returns the same value every time, <code>false</code> if the value will change.
16
16
  * @param {ReferenceFrame} [referenceFrame=ReferenceFrame.FIXED] The reference frame in which the position is defined.
17
17
  *
18
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Callback%20Position%20Property.html|Cesium Sandcastle Callback Position Property Demo}
18
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=callback-position-property|Cesium Sandcastle Callback Position Property Demo}
19
19
  */
20
20
  function CallbackPositionProperty(callback, isConstant, referenceFrame) {
21
21
  this._callback = undefined;
@@ -41,7 +41,7 @@ import createPropertyDescriptor from "./createPropertyDescriptor.js";
41
41
  * @param {CorridorGraphics.ConstructorOptions} [options] Object describing initialization options
42
42
  *
43
43
  * @see Entity
44
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Corridor.html|Cesium Sandcastle Corridor Demo}
44
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=corridor|Cesium Sandcastle Corridor Demo}
45
45
  */
46
46
  function CorridorGraphics(options) {
47
47
  this._definitionChanged = new Event();
@@ -4817,7 +4817,7 @@ function DocumentPacket() {
4817
4817
  *
4818
4818
  * @param {string} [name] An optional name for the data source. This value will be overwritten if a loaded document contains a name.
4819
4819
  *
4820
- * @demo {@link https://sandcastle.cesium.com/index.html?src=CZML.html|Cesium Sandcastle CZML Demo}
4820
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=czml|Cesium Sandcastle CZML Demo}
4821
4821
  */
4822
4822
  function CzmlDataSource(name) {
4823
4823
  this._name = name;
@@ -43,7 +43,7 @@ import createPropertyDescriptor from "./createPropertyDescriptor.js";
43
43
  *
44
44
  * @param {EllipseGraphics.ConstructorOptions} [options] Object describing initialization options
45
45
  *
46
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Circles and Ellipses.html|Cesium Sandcastle Circles and Ellipses Demo}
46
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=circles-and-ellipses|Cesium Sandcastle Circles and Ellipses Demo}
47
47
  */
48
48
  function EllipseGraphics(options) {
49
49
  this._definitionChanged = new Event();
@@ -38,7 +38,7 @@ import createPropertyDescriptor from "./createPropertyDescriptor.js";
38
38
  *
39
39
  * @param {EllipsoidGraphics.ConstructorOptions} [options] Object describing initialization options
40
40
  *
41
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Spheres%20and%20Ellipsoids.html|Cesium Sandcastle Spheres and Ellipsoids Demo}
41
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=spheres-and-ellipsoids|Cesium Sandcastle Spheres and Ellipsoids Demo}
42
42
  */
43
43
  function EllipsoidGraphics(options) {
44
44
  this._definitionChanged = new Event();
@@ -302,7 +302,7 @@ Object.defineProperties(Entity.prototype, {
302
302
  },
303
303
  /**
304
304
  * Gets or sets the entity's tracking reference frame.
305
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Entity tracking.html|Cesium Sandcastle Entity tracking Demo}
305
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=entity-tracking|Cesium Sandcastle Entity tracking Demo}
306
306
  *
307
307
  * @memberof Entity.prototype
308
308
  * @type {TrackingReferenceFrame}
@@ -30,7 +30,7 @@ import KDBush from "kdbush";
30
30
  * @alias EntityCluster
31
31
  * @constructor
32
32
  *
33
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Clustering.html|Cesium Sandcastle Clustering Demo}
33
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=clustering|Cesium Sandcastle Clustering Demo}
34
34
  */
35
35
  function EntityCluster(options) {
36
36
  options = options ?? Frozen.EMPTY_OBJECT;
@@ -330,7 +330,7 @@ function createDeclutterCallback(entityCluster) {
330
330
  let collectionIndex;
331
331
 
332
332
  if (points.length > 0) {
333
- const index = new KDBush(points.length, 64, Uint32Array);
333
+ const index = new KDBush(points.length, 64, Float64Array);
334
334
  for (let p = 0; p < points.length; ++p) {
335
335
  index.add(points[p].coord.x, points[p].coord.y);
336
336
  }
@@ -578,8 +578,8 @@ function processTopology(dataSource, geoJson, geometry, crsFunction, options) {
578
578
  * @param {string} [name] The name of this data source. If undefined, a name will be taken from
579
579
  * the name of the GeoJSON file.
580
580
  *
581
- * @demo {@link https://sandcastle.cesium.com/index.html?src=GeoJSON%20and%20TopoJSON.html|Cesium Sandcastle GeoJSON and TopoJSON Demo}
582
- * @demo {@link https://sandcastle.cesium.com/index.html?src=GeoJSON%20simplestyle.html|Cesium Sandcastle GeoJSON simplestyle Demo}
581
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=geojson-and-topojson|Cesium Sandcastle GeoJSON and TopoJSON Demo}
582
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=geojson-simplestyle|Cesium Sandcastle GeoJSON simplestyle Demo}
583
583
  *
584
584
  * @example
585
585
  * const viewer = new Cesium.Viewer('cesiumContainer');
@@ -738,7 +738,7 @@ function load(dataSource, entityCollection, data, options) {
738
738
  * @see {@link http://www.topografix.com/gpx.asp|Topografix GPX Standard}
739
739
  * @see {@link http://www.topografix.com/gpx/1/1/|Topografix GPX Documentation}
740
740
  *
741
- * @demo {@link http://sandcastle.cesium.com/index.html?src=GPX.html}
741
+ * @demo {@link http://sandcastle.cesium.com/index.html?id=gpx}
742
742
  *
743
743
  * @example
744
744
  * const viewer = new Cesium.Viewer('cesiumContainer');
@@ -3518,7 +3518,7 @@ function load(dataSource, entityCollection, data, options) {
3518
3518
  * @see {@link http://www.opengeospatial.org/standards/kml/|Open Geospatial Consortium KML Standard}
3519
3519
  * @see {@link https://developers.google.com/kml/|Google KML Documentation}
3520
3520
  *
3521
- * @demo {@link https://sandcastle.cesium.com/index.html?src=KML.html|Cesium Sandcastle KML Demo}
3521
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=kml|Cesium Sandcastle KML Demo}
3522
3522
  *
3523
3523
  * @example
3524
3524
  * const viewer = new Cesium.Viewer('cesiumContainer');
@@ -14,7 +14,7 @@ import Event from "../Core/Event.js";
14
14
  * @see KmlTourFlyTo
15
15
  * @see KmlTourWait
16
16
  *
17
- * @demo {@link https://sandcastle.cesium.com/?src=KML%20Tours.html|KML Tours}
17
+ * @demo {@link https://sandcastle.cesium.com/?id=kml-tours|KML Tours}
18
18
  */
19
19
  function KmlTour(name, id) {
20
20
  /**
@@ -46,7 +46,7 @@ import createPropertyDescriptor from "./createPropertyDescriptor.js";
46
46
  *
47
47
  * @param {LabelGraphics.ConstructorOptions} [options] Object describing initialization options
48
48
  *
49
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Labels.html|Cesium Sandcastle Labels Demo}
49
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=labels|Cesium Sandcastle Labels Demo}
50
50
  */
51
51
  function LabelGraphics(options) {
52
52
  this._definitionChanged = new Event();
@@ -66,7 +66,7 @@ function createEnvironmentMapPropertyBag(value) {
66
66
  *
67
67
  * @param {ModelGraphics.ConstructorOptions} [options] Object describing initialization options
68
68
  *
69
- * @demo {@link https://sandcastle.cesium.com/index.html?src=3D%20Models.html|Cesium Sandcastle 3D Models Demo}
69
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=3d-models|Cesium Sandcastle 3D Models Demo}
70
70
  */
71
71
  function ModelGraphics(options) {
72
72
  this._definitionChanged = new Event();
@@ -30,7 +30,7 @@ import createPropertyDescriptor from "./createPropertyDescriptor.js";
30
30
  *
31
31
  * @param {PlaneGraphics.ConstructorOptions} [options] Object describing initialization options
32
32
  *
33
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Plane.html|Cesium Sandcastle Plane Demo}
33
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=plane|Cesium Sandcastle Plane Demo}
34
34
  */
35
35
  function PlaneGraphics(options) {
36
36
  this._definitionChanged = new Event();
@@ -55,7 +55,7 @@ function createPolygonHierarchyProperty(value) {
55
55
  * @param {PolygonGraphics.ConstructorOptions} [options] Object describing initialization options
56
56
  *
57
57
  * @see Entity
58
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Polygon.html|Cesium Sandcastle Polygon Demo}
58
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=polygon|Cesium Sandcastle Polygon Demo}
59
59
  */
60
60
  function PolygonGraphics(options) {
61
61
  this._definitionChanged = new Event();
@@ -35,7 +35,7 @@ import createPropertyDescriptor from "./createPropertyDescriptor.js";
35
35
  * @param {PolylineGraphics.ConstructorOptions} [options] Object describing initialization options
36
36
  *
37
37
  * @see Entity
38
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Polyline.html|Cesium Sandcastle Polyline Demo}
38
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=polyline|Cesium Sandcastle Polyline Demo}
39
39
  */
40
40
  function PolylineGraphics(options) {
41
41
  this._definitionChanged = new Event();
@@ -34,7 +34,7 @@ import createPropertyDescriptor from "./createPropertyDescriptor.js";
34
34
  * @param {PolylineVolumeGraphics.ConstructorOptions} [options] Object describing initialization options
35
35
  *
36
36
  * @see Entity
37
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Polyline%20Volume.html|Cesium Sandcastle Polyline Volume Demo}
37
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=polyline-volume|Cesium Sandcastle Polyline Volume Demo}
38
38
  */
39
39
  function PolylineVolumeGraphics(options) {
40
40
  this._definitionChanged = new Event();
@@ -41,7 +41,7 @@ import createPropertyDescriptor from "./createPropertyDescriptor.js";
41
41
  * @param {RectangleGraphics.ConstructorOptions} [options] Object describing initialization options
42
42
  *
43
43
  * @see Entity
44
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Rectangle.html|Cesium Sandcastle Rectangle Demo}
44
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=rectangle|Cesium Sandcastle Rectangle Demo}
45
45
  */
46
46
  function RectangleGraphics(options) {
47
47
  this._definitionChanged = new Event();
@@ -34,7 +34,7 @@ import createPropertyDescriptor from "./createPropertyDescriptor.js";
34
34
  * @param {WallGraphics.ConstructorOptions} [options] Object describing initialization options
35
35
  *
36
36
  * @see Entity
37
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Wall.html|Cesium Sandcastle Wall Demo}
37
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=wall|Cesium Sandcastle Wall Demo}
38
38
  */
39
39
  function WallGraphics(options) {
40
40
  this._definitionChanged = new Event();
@@ -263,7 +263,7 @@ IdManager.prototype.get = function (id) {
263
263
  * @param {boolean} [options.kmz=false] If true KML and external files will be compressed into a kmz file.
264
264
  *
265
265
  * @returns {Promise<exportKmlResultKml|exportKmlResultKmz>} A promise that resolved to an object containing the KML string and a dictionary of external file blobs, or a kmz file as a blob if options.kmz is true.
266
- * @demo {@link https://sandcastle.cesium.com/index.html?src=Export%20KML.html|Cesium Sandcastle KML Export Demo}
266
+ * @demo {@link https://sandcastle.cesium.com/index.html?id=export-kml|Cesium Sandcastle KML Export Demo}
267
267
  * @example
268
268
  * Cesium.exportKml({
269
269
  * entities: entityCollection
@@ -86,32 +86,33 @@ function Context(canvas, options) {
86
86
 
87
87
  ContextLimits._maximumCombinedTextureImageUnits = gl.getParameter(
88
88
  gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS,
89
- ); // min: 8
89
+ );
90
90
  ContextLimits._maximumCubeMapSize = gl.getParameter(
91
91
  gl.MAX_CUBE_MAP_TEXTURE_SIZE,
92
- ); // min: 16
92
+ );
93
93
  ContextLimits._maximumFragmentUniformVectors = gl.getParameter(
94
94
  gl.MAX_FRAGMENT_UNIFORM_VECTORS,
95
- ); // min: 16
95
+ );
96
96
  ContextLimits._maximumTextureImageUnits = gl.getParameter(
97
97
  gl.MAX_TEXTURE_IMAGE_UNITS,
98
- ); // min: 8
98
+ );
99
99
  ContextLimits._maximumRenderbufferSize = gl.getParameter(
100
100
  gl.MAX_RENDERBUFFER_SIZE,
101
- ); // min: 1
102
- ContextLimits._maximumTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); // min: 64
101
+ );
102
+ ContextLimits._maximumTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
103
+ ContextLimits._maximum3DTextureSize = gl.getParameter(gl.MAX_3D_TEXTURE_SIZE);
103
104
  ContextLimits._maximumVaryingVectors = gl.getParameter(
104
105
  gl.MAX_VARYING_VECTORS,
105
- ); // min: 8
106
+ );
106
107
  ContextLimits._maximumVertexAttributes = gl.getParameter(
107
108
  gl.MAX_VERTEX_ATTRIBS,
108
- ); // min: 8
109
+ );
109
110
  ContextLimits._maximumVertexTextureImageUnits = gl.getParameter(
110
111
  gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS,
111
- ); // min: 0
112
+ );
112
113
  ContextLimits._maximumVertexUniformVectors = gl.getParameter(
113
114
  gl.MAX_VERTEX_UNIFORM_VECTORS,
114
- ); // min: 128
115
+ );
115
116
 
116
117
  ContextLimits._maximumSamples = this._webgl2
117
118
  ? gl.getParameter(gl.MAX_SAMPLES)