@cesium/engine 6.1.1 → 6.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 (138) hide show
  1. package/Build/Workers/{chunk-RSWBNJPT.js → chunk-3PW6ZBN4.js} +8 -304
  2. package/Build/Workers/{chunk-PB7BIXHI.js → chunk-434ZTTFX.js} +2 -2
  3. package/Build/Workers/{chunk-HSW63JN4.js → chunk-4KP73B43.js} +3 -3
  4. package/Build/Workers/{chunk-36ESDRIZ.js → chunk-52VSIKEA.js} +16 -16
  5. package/Build/Workers/{chunk-VLDDXYKI.js → chunk-5GDBZTHX.js} +18 -18
  6. package/Build/Workers/{chunk-7FEGZO3D.js → chunk-5HLGKKG3.js} +2 -2
  7. package/Build/Workers/{chunk-HEROVJML.js → chunk-5IRLXUTA.js} +7 -7
  8. package/Build/Workers/{chunk-I6TVJ6T7.js → chunk-5SK36PU4.js} +8 -8
  9. package/Build/Workers/{chunk-Z6LPXA7S.js → chunk-ARPTYYKS.js} +5 -5
  10. package/Build/Workers/{chunk-7ONRI7T4.js → chunk-ATB2I7OS.js} +4 -4
  11. package/Build/Workers/{chunk-XBZSOW3F.js → chunk-AXFRNOVC.js} +12 -12
  12. package/Build/Workers/{chunk-IZED7ODV.js → chunk-BP467WX3.js} +4 -4
  13. package/Build/Workers/{chunk-ZVUAJKAL.js → chunk-BUZDZBUH.js} +11 -13
  14. package/Build/Workers/{chunk-N7TYCDTR.js → chunk-CDGHUKQ4.js} +13 -13
  15. package/Build/Workers/{chunk-CLVEIRXT.js → chunk-CSIZ3BGT.js} +15 -17
  16. package/Build/Workers/{chunk-C53JYYKX.js → chunk-CWJQGBWT.js} +1 -1
  17. package/Build/Workers/{chunk-DTNN3ODA.js → chunk-DMCSY5BU.js} +5 -5
  18. package/Build/Workers/{chunk-T73B27DG.js → chunk-DR5XZ6K5.js} +13 -13
  19. package/Build/Workers/{chunk-ZGMOBRTG.js → chunk-FWGNCYP6.js} +7 -7
  20. package/Build/Workers/{chunk-LSGUCCKJ.js → chunk-GF5TNNKP.js} +6 -6
  21. package/Build/Workers/{chunk-VODWDCX6.js → chunk-GVL5I7TC.js} +18 -20
  22. package/Build/Workers/{chunk-3FCUUN6M.js → chunk-H5DUXHCV.js} +11 -11
  23. package/Build/Workers/{chunk-S7IBK36I.js → chunk-HFKSAB5K.js} +14 -16
  24. package/Build/Workers/{chunk-D4YHO4NZ.js → chunk-HOT2SNXP.js} +15 -20
  25. package/Build/Workers/{chunk-5NZTU5YL.js → chunk-HPH5HSFE.js} +2 -2
  26. package/Build/Workers/{chunk-KUB2HQXR.js → chunk-HPP4JLNH.js} +8 -8
  27. package/Build/Workers/{chunk-CHDJ66UM.js → chunk-HUPNRBWW.js} +6 -6
  28. package/Build/Workers/{chunk-VOAZN4IP.js → chunk-JGG36SQV.js} +4 -4
  29. package/Build/Workers/{chunk-PHQVHDVI.js → chunk-LGJUI2CE.js} +325 -5
  30. package/Build/Workers/{chunk-4EYB62WJ.js → chunk-LGL4P5KL.js} +6 -6
  31. package/Build/Workers/{chunk-J3U6Z5YQ.js → chunk-LX6XV4DK.js} +5 -5
  32. package/Build/Workers/{chunk-W7F5VTH6.js → chunk-MN34FIF5.js} +1 -1
  33. package/Build/Workers/{chunk-AI3KSNM6.js → chunk-MW3CJYLX.js} +2 -2
  34. package/Build/Workers/{chunk-SEFDWMCW.js → chunk-NE4JNU6H.js} +31 -21
  35. package/Build/Workers/{chunk-235MRXLH.js → chunk-O43GWBSF.js} +1 -1
  36. package/Build/Workers/{chunk-SJDXMQSP.js → chunk-PIXK6KHB.js} +2 -2
  37. package/Build/Workers/{chunk-QUXSQQEF.js → chunk-PZ2WJWUG.js} +6 -6
  38. package/Build/Workers/{chunk-FRG2Z7DE.js → chunk-QRBRVGZC.js} +4 -4
  39. package/Build/Workers/{chunk-D325WRAY.js → chunk-QTZQZY2C.js} +9 -9
  40. package/Build/Workers/{chunk-OTBRPBCC.js → chunk-R3HUGXBH.js} +9 -9
  41. package/Build/Workers/{chunk-6PWSSCRA.js → chunk-R4OZKBXH.js} +6 -6
  42. package/Build/Workers/{chunk-PXLFBN2Q.js → chunk-RH4N2ONY.js} +7 -7
  43. package/Build/Workers/{chunk-66CXKODF.js → chunk-RIDPF7PO.js} +2 -2
  44. package/Build/Workers/{chunk-R22RQAAM.js → chunk-SNN7WOC2.js} +13 -13
  45. package/Build/Workers/{chunk-364TQORK.js → chunk-SQVTYRZY.js} +5 -7
  46. package/Build/Workers/{chunk-VNRUVNIK.js → chunk-SV7DDPAC.js} +1 -1
  47. package/Build/Workers/{chunk-QY2WY5XJ.js → chunk-TIXXVKUY.js} +11 -11
  48. package/Build/Workers/{chunk-MOLGJDJV.js → chunk-TMPVBFJQ.js} +11 -11
  49. package/Build/Workers/{chunk-VKTKOIYG.js → chunk-XUTVA4K5.js} +11 -11
  50. package/Build/Workers/{chunk-GTEXWEAP.js → chunk-Y4OJ4B23.js} +5 -5
  51. package/Build/Workers/{chunk-YS4KPNLC.js → chunk-YBKFS53K.js} +1 -1
  52. package/Build/Workers/{chunk-K6Q5IRBK.js → chunk-Z2SIPUKB.js} +6 -6
  53. package/Build/Workers/{chunk-FGUP2QEP.js → chunk-Z4JUBRHP.js} +6 -6
  54. package/Build/Workers/{chunk-ZTYE74E2.js → chunk-ZQRZBHYI.js} +4 -4
  55. package/Build/Workers/combineGeometry.js +23 -23
  56. package/Build/Workers/createBoxGeometry.js +17 -17
  57. package/Build/Workers/createBoxOutlineGeometry.js +15 -15
  58. package/Build/Workers/createCircleGeometry.js +25 -25
  59. package/Build/Workers/createCircleOutlineGeometry.js +18 -18
  60. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -34
  61. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +30 -30
  62. package/Build/Workers/createCorridorGeometry.js +29 -29
  63. package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
  64. package/Build/Workers/createCylinderGeometry.js +19 -19
  65. package/Build/Workers/createCylinderOutlineGeometry.js +18 -19
  66. package/Build/Workers/createEllipseGeometry.js +25 -25
  67. package/Build/Workers/createEllipseOutlineGeometry.js +18 -18
  68. package/Build/Workers/createEllipsoidGeometry.js +18 -18
  69. package/Build/Workers/createEllipsoidOutlineGeometry.js +17 -17
  70. package/Build/Workers/createFrustumGeometry.js +17 -17
  71. package/Build/Workers/createFrustumOutlineGeometry.js +17 -17
  72. package/Build/Workers/createGeometry.js +23 -23
  73. package/Build/Workers/createGroundPolylineGeometry.js +22 -22
  74. package/Build/Workers/createPlaneGeometry.js +15 -15
  75. package/Build/Workers/createPlaneOutlineGeometry.js +14 -14
  76. package/Build/Workers/createPolygonGeometry.js +34 -34
  77. package/Build/Workers/createPolygonOutlineGeometry.js +29 -29
  78. package/Build/Workers/createPolylineGeometry.js +24 -24
  79. package/Build/Workers/createPolylineVolumeGeometry.js +32 -33
  80. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +28 -29
  81. package/Build/Workers/createRectangleGeometry.js +27 -27
  82. package/Build/Workers/createRectangleOutlineGeometry.js +21 -23
  83. package/Build/Workers/createSimplePolylineGeometry.js +22 -22
  84. package/Build/Workers/createSphereGeometry.js +18 -18
  85. package/Build/Workers/createSphereOutlineGeometry.js +17 -17
  86. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  87. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  88. package/Build/Workers/createVectorTileGeometries.js +23 -23
  89. package/Build/Workers/createVectorTilePoints.js +12 -12
  90. package/Build/Workers/createVectorTilePolygons.js +21 -21
  91. package/Build/Workers/createVectorTilePolylines.js +14 -14
  92. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
  93. package/Build/Workers/createVerticesFromHeightmap.js +22 -22
  94. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -19
  95. package/Build/Workers/createWallGeometry.js +23 -23
  96. package/Build/Workers/createWallOutlineGeometry.js +22 -22
  97. package/Build/Workers/decodeDraco.js +11 -11
  98. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  99. package/Build/Workers/decodeI3S.js +9 -9
  100. package/Build/Workers/transcodeKTX2.js +7 -7
  101. package/Build/Workers/transferTypedArrayTest.js +1 -1
  102. package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
  103. package/Source/Core/Ellipsoid.js +45 -0
  104. package/Source/Core/Ion.js +1 -1
  105. package/Source/Core/Quaternion.js +6 -2
  106. package/Source/Core/RectangleOutlineGeometry.js +2 -4
  107. package/Source/Core/RequestScheduler.js +3 -9
  108. package/Source/Core/TerrainEncoding.js +2 -2
  109. package/Source/Core/VerticalExaggeration.js +69 -0
  110. package/Source/Renderer/AutomaticUniforms.js +53 -0
  111. package/Source/Renderer/UniformState.js +119 -1
  112. package/Source/Scene/Cesium3DTile.js +122 -10
  113. package/Source/Scene/FrameState.js +4 -4
  114. package/Source/Scene/Globe.js +66 -19
  115. package/Source/Scene/GlobeSurfaceTile.js +4 -4
  116. package/Source/Scene/GlobeSurfaceTileProvider.js +21 -21
  117. package/Source/Scene/GroundPrimitive.js +5 -5
  118. package/Source/Scene/ImageryLayer.js +3 -3
  119. package/Source/Scene/MapboxImageryProvider.js +2 -2
  120. package/Source/Scene/Megatexture.js +1 -1
  121. package/Source/Scene/Model/Model.js +11 -0
  122. package/Source/Scene/Model/ModelRuntimePrimitive.js +6 -0
  123. package/Source/Scene/Model/VerticalExaggerationPipelineStage.js +60 -0
  124. package/Source/Scene/Scene.js +28 -3
  125. package/Source/Scene/ScreenSpaceCameraController.js +12 -19
  126. package/Source/Scene/TerrainFillMesh.js +2 -2
  127. package/Source/Scene/TileOrientedBoundingBox.js +1 -1
  128. package/Source/Scene/VoxelPrimitive.js +73 -2
  129. package/Source/Shaders/GlobeVS.glsl +3 -3
  130. package/Source/Shaders/GlobeVS.js +3 -3
  131. package/Source/Shaders/Model/ModelVS.glsl +4 -0
  132. package/Source/Shaders/Model/ModelVS.js +4 -0
  133. package/Source/Shaders/Model/VerticalExaggerationStageVS.glsl +39 -0
  134. package/Source/Shaders/Model/VerticalExaggerationStageVS.js +41 -0
  135. package/index.d.ts +35 -18
  136. package/index.js +199 -197
  137. package/package.json +1 -1
  138. package/Source/Core/TerrainExaggeration.js +0 -49
@@ -10,7 +10,7 @@ import DeveloperError from "../Core/DeveloperError.js";
10
10
  import GeometryInstance from "../Core/GeometryInstance.js";
11
11
  import OrientedBoundingBox from "../Core/OrientedBoundingBox.js";
12
12
  import Rectangle from "../Core/Rectangle.js";
13
- import TerrainExaggeration from "../Core/TerrainExaggeration.js";
13
+ import VerticalExaggeration from "../Core/VerticalExaggeration.js";
14
14
  import ClassificationPrimitive from "./ClassificationPrimitive.js";
15
15
  import ClassificationType from "./ClassificationType.js";
16
16
  import PerInstanceColorAppearance from "./PerInstanceColorAppearance.js";
@@ -763,15 +763,15 @@ GroundPrimitive.prototype.update = function (frameState) {
763
763
 
764
764
  // Now compute the min/max heights for the primitive
765
765
  setMinMaxTerrainHeights(this, rectangle, ellipsoid);
766
- const exaggeration = frameState.terrainExaggeration;
766
+ const exaggeration = frameState.verticalExaggeration;
767
767
  const exaggerationRelativeHeight =
768
- frameState.terrainExaggerationRelativeHeight;
769
- this._minHeight = TerrainExaggeration.getHeight(
768
+ frameState.verticalExaggerationRelativeHeight;
769
+ this._minHeight = VerticalExaggeration.getHeight(
770
770
  this._minTerrainHeight,
771
771
  exaggeration,
772
772
  exaggerationRelativeHeight
773
773
  );
774
- this._maxHeight = TerrainExaggeration.getHeight(
774
+ this._maxHeight = VerticalExaggeration.getHeight(
775
775
  this._maxTerrainHeight,
776
776
  exaggeration,
777
777
  exaggerationRelativeHeight
@@ -132,8 +132,8 @@ import TileImagery from "./TileImagery.js";
132
132
  * @alias ImageryLayer
133
133
  * @constructor
134
134
  *
135
- * @param {ImageryProvider} imageryProvider The imagery provider to use.
136
- * @param {ImageryLayer.ConstructorOptions} options An object describing initialization options
135
+ * @param {ImageryProvider} [imageryProvider] The imagery provider to use.
136
+ * @param {ImageryLayer.ConstructorOptions} [options] An object describing initialization options
137
137
  *
138
138
  * @see ImageryLayer.fromProviderAsync
139
139
  * @see ImageryLayer.fromWorldImagery
@@ -142,7 +142,7 @@ import TileImagery from "./TileImagery.js";
142
142
  * // Add an OpenStreetMaps layer
143
143
  * const imageryLayer = new Cesium.ImageryLayer(new Cesium.OpenStreetMapImageryProvider({
144
144
  * url: "https://tile.openstreetmap.org/"
145
- * })),
145
+ * }));
146
146
  * scene.imageryLayers.add(imageryLayer);
147
147
  *
148
148
  * @example
@@ -43,8 +43,8 @@ const defaultCredit = new Credit(
43
43
  * accessToken: 'thisIsMyAccessToken'
44
44
  * });
45
45
  *
46
- * @see {@link https://www.mapbox.com/developers/api/maps/#tiles}
47
- * @see {@link https://www.mapbox.com/developers/api/#access-tokens}
46
+ * @see {@link https://docs.mapbox.com/api/maps/raster-tiles/}
47
+ * @see {@link https://docs.mapbox.com/api/accounts/tokens/}
48
48
  */
49
49
  function MapboxImageryProvider(options) {
50
50
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
@@ -366,7 +366,7 @@ Megatexture.getApproximateTextureMemoryByteLength = function (
366
366
  const voxelCountTotal =
367
367
  tileCount * dimensions.x * dimensions.y * dimensions.z;
368
368
 
369
- const sliceCountPerRegionX = Math.ceil(Math.sqrt(dimensions.z));
369
+ const sliceCountPerRegionX = Math.ceil(Math.sqrt(dimensions.x));
370
370
  const sliceCountPerRegionY = Math.ceil(dimensions.z / sliceCountPerRegionX);
371
371
  const voxelCountPerRegionX = sliceCountPerRegionX * dimensions.x;
372
372
  const voxelCountPerRegionY = sliceCountPerRegionY * dimensions.y;
@@ -333,6 +333,8 @@ function Model(options) {
333
333
  this._heightDirty = this._heightReference !== HeightReference.NONE;
334
334
  this._removeUpdateHeightCallback = undefined;
335
335
 
336
+ this._verticalExaggerationOn = false;
337
+
336
338
  this._clampedModelMatrix = undefined; // For use with height reference
337
339
 
338
340
  const scene = options.scene;
@@ -1789,6 +1791,7 @@ Model.prototype.update = function (frameState) {
1789
1791
  updateSkipLevelOfDetail(this, frameState);
1790
1792
  updateClippingPlanes(this, frameState);
1791
1793
  updateSceneMode(this, frameState);
1794
+ updateVerticalExaggeration(this, frameState);
1792
1795
 
1793
1796
  this._defaultTexture = frameState.context.defaultTexture;
1794
1797
 
@@ -1983,6 +1986,14 @@ function updateSceneMode(model, frameState) {
1983
1986
  }
1984
1987
  }
1985
1988
 
1989
+ function updateVerticalExaggeration(model, frameState) {
1990
+ const verticalExaggerationNeeded = frameState.verticalExaggeration !== 1.0;
1991
+ if (model._verticalExaggerationOn !== verticalExaggerationNeeded) {
1992
+ model.resetDrawCommands();
1993
+ model._verticalExaggerationOn = verticalExaggerationNeeded;
1994
+ }
1995
+ }
1996
+
1986
1997
  function buildDrawCommands(model, frameState) {
1987
1998
  if (!model._drawCommandsBuilt) {
1988
1999
  model.destroyPipelineResources();
@@ -24,6 +24,7 @@ import PrimitiveStatisticsPipelineStage from "./PrimitiveStatisticsPipelineStage
24
24
  import SceneMode2DPipelineStage from "./SceneMode2DPipelineStage.js";
25
25
  import SelectedFeatureIdPipelineStage from "./SelectedFeatureIdPipelineStage.js";
26
26
  import SkinningPipelineStage from "./SkinningPipelineStage.js";
27
+ import VerticalExaggerationPipelineStage from "./VerticalExaggerationPipelineStage.js";
27
28
  import WireframePipelineStage from "./WireframePipelineStage.js";
28
29
 
29
30
  /**
@@ -198,6 +199,7 @@ ModelRuntimePrimitive.prototype.configurePipeline = function (frameState) {
198
199
  const mode = frameState.mode;
199
200
  const use2D =
200
201
  mode !== SceneMode.SCENE3D && !frameState.scene3DOnly && model._projectTo2D;
202
+ const exaggerateTerrain = frameState.verticalExaggeration !== 1.0;
201
203
 
202
204
  const hasMorphTargets =
203
205
  defined(primitive.morphTargets) && primitive.morphTargets.length > 0;
@@ -281,6 +283,10 @@ ModelRuntimePrimitive.prototype.configurePipeline = function (frameState) {
281
283
  pipelineStages.push(CPUStylingPipelineStage);
282
284
  }
283
285
 
286
+ if (exaggerateTerrain) {
287
+ pipelineStages.push(VerticalExaggerationPipelineStage);
288
+ }
289
+
284
290
  if (hasCustomShader) {
285
291
  pipelineStages.push(CustomShaderPipelineStage);
286
292
  }
@@ -0,0 +1,60 @@
1
+ import Cartesian2 from "../../Core/Cartesian2.js";
2
+ import ShaderDestination from "../../Renderer/ShaderDestination.js";
3
+ import VerticalExaggerationStageVS from "../../Shaders/Model/VerticalExaggerationStageVS.js";
4
+
5
+ /**
6
+ * The custom shader pipeline stage takes GLSL callbacks from the
7
+ * {@link CustomShader} and inserts them into the overall shader code for the
8
+ * {@link Model}. The input to the callback is a struct with many
9
+ * properties that depend on the attributes of the primitive. This shader code
10
+ * is automatically generated by this stage.
11
+ *
12
+ * @namespace VerticalExaggerationPipelineStage
13
+ *
14
+ * @private
15
+ */
16
+ const VerticalExaggerationPipelineStage = {
17
+ name: "VerticalExaggerationPipelineStage", // Helps with debugging
18
+ };
19
+
20
+ const scratchExaggerationUniform = new Cartesian2();
21
+
22
+ /**
23
+ * Add vertical exaggeration to a shader
24
+ *
25
+ * @param {PrimitiveRenderResources} renderResources The render resources for the primitive
26
+ * @param {ModelComponents.Primitive} primitive The primitive to be rendered
27
+ * @param {FrameState} frameState The frame state.
28
+ * @private
29
+ */
30
+ VerticalExaggerationPipelineStage.process = function (
31
+ renderResources,
32
+ primitive,
33
+ frameState
34
+ ) {
35
+ const { shaderBuilder, uniformMap } = renderResources;
36
+
37
+ shaderBuilder.addVertexLines(VerticalExaggerationStageVS);
38
+
39
+ shaderBuilder.addDefine(
40
+ "HAS_VERTICAL_EXAGGERATION",
41
+ undefined,
42
+ ShaderDestination.VERTEX
43
+ );
44
+
45
+ shaderBuilder.addUniform(
46
+ "vec2",
47
+ "u_verticalExaggerationAndRelativeHeight",
48
+ ShaderDestination.VERTEX
49
+ );
50
+
51
+ uniformMap.u_verticalExaggerationAndRelativeHeight = function () {
52
+ return Cartesian2.fromElements(
53
+ frameState.verticalExaggeration,
54
+ frameState.verticalExaggerationRelativeHeight,
55
+ scratchExaggerationUniform
56
+ );
57
+ };
58
+ };
59
+
60
+ export default VerticalExaggerationPipelineStage;
@@ -356,6 +356,24 @@ function Scene(options) {
356
356
  */
357
357
  this.nearToFarDistance2D = 1.75e6;
358
358
 
359
+ /**
360
+ * The vertical exaggeration of the scene.
361
+ * When set to 1.0, no exaggeration is applied.
362
+ *
363
+ * @type {number}
364
+ * @default 1.0
365
+ */
366
+ this.verticalExaggeration = 1.0;
367
+
368
+ /**
369
+ * The reference height for vertical exaggeration of the scene.
370
+ * When set to 0.0, the exaggeration is applied relative to the ellipsoid surface.
371
+ *
372
+ * @type {number}
373
+ * @default 0.0
374
+ */
375
+ this.verticalExaggerationRelativeHeight = 0.0;
376
+
359
377
  /**
360
378
  * This property is for debugging only; it is not for production use.
361
379
  * <p>
@@ -1880,10 +1898,17 @@ Scene.prototype.updateFrameState = function () {
1880
1898
  frameState.cameraUnderground = this._cameraUnderground;
1881
1899
  frameState.globeTranslucencyState = this._globeTranslucencyState;
1882
1900
 
1883
- if (defined(this.globe)) {
1884
- frameState.terrainExaggeration = this.globe.terrainExaggeration;
1885
- frameState.terrainExaggerationRelativeHeight = this.globe.terrainExaggerationRelativeHeight;
1901
+ const { globe } = this;
1902
+ if (defined(globe) && globe._terrainExaggerationChanged) {
1903
+ // Honor a user-set value for the old deprecated globe.terrainExaggeration.
1904
+ // This can be removed when Globe.terrainExaggeration is removed.
1905
+ this.verticalExaggeration = globe._terrainExaggeration;
1906
+ this.verticalExaggerationRelativeHeight =
1907
+ globe._terrainExaggerationRelativeHeight;
1908
+ globe._terrainExaggerationChanged = false;
1886
1909
  }
1910
+ frameState.verticalExaggeration = this.verticalExaggeration;
1911
+ frameState.verticalExaggerationRelativeHeight = this.verticalExaggerationRelativeHeight;
1887
1912
 
1888
1913
  if (
1889
1914
  defined(this._specularEnvironmentMapAtlas) &&
@@ -17,7 +17,7 @@ import OrthographicFrustum from "../Core/OrthographicFrustum.js";
17
17
  import Plane from "../Core/Plane.js";
18
18
  import Quaternion from "../Core/Quaternion.js";
19
19
  import Ray from "../Core/Ray.js";
20
- import TerrainExaggeration from "../Core/TerrainExaggeration.js";
20
+ import VerticalExaggeration from "../Core/VerticalExaggeration.js";
21
21
  import Transforms from "../Core/Transforms.js";
22
22
  import CameraEventAggregator from "./CameraEventAggregator.js";
23
23
  import CameraEventType from "./CameraEventType.js";
@@ -2948,9 +2948,7 @@ const scratchPreviousDirection = new Cartesian3();
2948
2948
  */
2949
2949
  ScreenSpaceCameraController.prototype.update = function () {
2950
2950
  const scene = this._scene;
2951
- const camera = scene.camera;
2952
- const globe = scene.globe;
2953
- const mode = scene.mode;
2951
+ const { camera, globe, mode } = scene;
2954
2952
 
2955
2953
  if (!Matrix4.equals(camera.transform, Matrix4.IDENTITY)) {
2956
2954
  this._globe = undefined;
@@ -2962,26 +2960,21 @@ ScreenSpaceCameraController.prototype.update = function () {
2962
2960
  : scene.mapProjection.ellipsoid;
2963
2961
  }
2964
2962
 
2965
- const exaggeration = defined(this._globe)
2966
- ? this._globe.terrainExaggeration
2967
- : 1.0;
2968
- const exaggerationRelativeHeight = defined(this._globe)
2969
- ? this._globe.terrainExaggerationRelativeHeight
2970
- : 0.0;
2971
- this._minimumCollisionTerrainHeight = TerrainExaggeration.getHeight(
2963
+ const { verticalExaggeration, verticalExaggerationRelativeHeight } = scene;
2964
+ this._minimumCollisionTerrainHeight = VerticalExaggeration.getHeight(
2972
2965
  this.minimumCollisionTerrainHeight,
2973
- exaggeration,
2974
- exaggerationRelativeHeight
2966
+ verticalExaggeration,
2967
+ verticalExaggerationRelativeHeight
2975
2968
  );
2976
- this._minimumPickingTerrainHeight = TerrainExaggeration.getHeight(
2969
+ this._minimumPickingTerrainHeight = VerticalExaggeration.getHeight(
2977
2970
  this.minimumPickingTerrainHeight,
2978
- exaggeration,
2979
- exaggerationRelativeHeight
2971
+ verticalExaggeration,
2972
+ verticalExaggerationRelativeHeight
2980
2973
  );
2981
- this._minimumTrackBallHeight = TerrainExaggeration.getHeight(
2974
+ this._minimumTrackBallHeight = VerticalExaggeration.getHeight(
2982
2975
  this.minimumTrackBallHeight,
2983
- exaggeration,
2984
- exaggerationRelativeHeight
2976
+ verticalExaggeration,
2977
+ verticalExaggerationRelativeHeight
2985
2978
  );
2986
2979
 
2987
2980
  this._cameraUnderground = scene.cameraUnderground && defined(this._globe);
@@ -830,9 +830,9 @@ function createFillMesh(tileProvider, frameState, tile, vertexArraysToDestroy) {
830
830
  const fill = surfaceTile.fill;
831
831
  const rectangle = tile.rectangle;
832
832
 
833
- const exaggeration = frameState.terrainExaggeration;
833
+ const exaggeration = frameState.verticalExaggeration;
834
834
  const exaggerationRelativeHeight =
835
- frameState.terrainExaggerationRelativeHeight;
835
+ frameState.verticalExaggerationRelativeHeight;
836
836
  const hasExaggeration = exaggeration !== 1.0;
837
837
 
838
838
  const ellipsoid = tile.tilingScheme.ellipsoid;
@@ -106,7 +106,7 @@ Object.defineProperties(TileOrientedBoundingBox.prototype, {
106
106
  *
107
107
  * @memberof TileOrientedBoundingBox.prototype
108
108
  *
109
- * @type {object}
109
+ * @type {OrientedBoundingBox}
110
110
  * @readonly
111
111
  */
112
112
  boundingVolume: {
@@ -131,6 +131,38 @@ function VoxelPrimitive(options) {
131
131
  */
132
132
  this._maxBoundsOld = new Cartesian3();
133
133
 
134
+ /**
135
+ * Minimum bounds with vertical exaggeration applied
136
+ *
137
+ * @type {Cartesian3}
138
+ * @private
139
+ */
140
+ this._exaggeratedMinBounds = new Cartesian3();
141
+
142
+ /**
143
+ * Used to detect if the shape is dirty.
144
+ *
145
+ * @type {Cartesian3}
146
+ * @private
147
+ */
148
+ this._exaggeratedMinBoundsOld = new Cartesian3();
149
+
150
+ /**
151
+ * Maximum bounds with vertical exaggeration applied
152
+ *
153
+ * @type {Cartesian3}
154
+ * @private
155
+ */
156
+ this._exaggeratedMaxBounds = new Cartesian3();
157
+
158
+ /**
159
+ * Used to detect if the shape is dirty.
160
+ *
161
+ * @type {Cartesian3}
162
+ * @private
163
+ */
164
+ this._exaggeratedMaxBoundsOld = new Cartesian3();
165
+
134
166
  /**
135
167
  * This member is not known until the provider is ready.
136
168
  *
@@ -442,6 +474,7 @@ function initialize(primitive, provider) {
442
474
  // Create the shape object, and update it so it is valid for VoxelTraversal
443
475
  const ShapeConstructor = VoxelShapeType.getShapeConstructor(shapeType);
444
476
  primitive._shape = new ShapeConstructor();
477
+ updateVerticalExaggeration(primitive);
445
478
  primitive._shapeVisible = updateShapeAndTransforms(
446
479
  primitive,
447
480
  primitive._shape,
@@ -964,6 +997,8 @@ VoxelPrimitive.prototype.update = function (frameState) {
964
997
  return;
965
998
  }
966
999
 
1000
+ updateVerticalExaggeration(this, frameState);
1001
+
967
1002
  // Check if the shape is dirty before updating it. This needs to happen every
968
1003
  // frame because the member variables can be modified externally via the
969
1004
  // getters.
@@ -1107,6 +1142,32 @@ VoxelPrimitive.prototype.update = function (frameState) {
1107
1142
  frameState.commandList.push(command);
1108
1143
  };
1109
1144
 
1145
+ /**
1146
+ * Update the exaggerated bounds of a primitive to account for vertical exaggeration
1147
+ * Currently only applies to Ellipsoid shape type
1148
+ * @param {VoxelPrimitive} primitive
1149
+ * @param {FrameState} [frameState]
1150
+ * @private
1151
+ */
1152
+ function updateVerticalExaggeration(primitive, frameState) {
1153
+ primitive._exaggeratedMinBounds = Cartesian3.clone(
1154
+ primitive._minBounds,
1155
+ primitive._exaggeratedMinBounds
1156
+ );
1157
+ primitive._exaggeratedMaxBounds = Cartesian3.clone(
1158
+ primitive._maxBounds,
1159
+ primitive._exaggeratedMaxBounds
1160
+ );
1161
+ if (defined(frameState) && primitive.shape === VoxelShapeType.ELLIPSOID) {
1162
+ const relativeHeight = frameState.verticalExaggerationRelativeHeight;
1163
+ const exaggeration = frameState.verticalExaggeration;
1164
+ primitive._exaggeratedMinBounds.z =
1165
+ (primitive._minBounds.z - relativeHeight) * exaggeration + relativeHeight;
1166
+ primitive._exaggeratedMaxBounds.z =
1167
+ (primitive._maxBounds.z - relativeHeight) * exaggeration + relativeHeight;
1168
+ }
1169
+ }
1170
+
1110
1171
  /**
1111
1172
  * Initialize primitive properties that are derived from the voxel provider
1112
1173
  * @param {VoxelPrimitive} primitive
@@ -1203,6 +1264,16 @@ function checkTransformAndBounds(primitive, provider) {
1203
1264
  updateBound(primitive, "_compoundModelMatrix", "_compoundModelMatrixOld") +
1204
1265
  updateBound(primitive, "_minBounds", "_minBoundsOld") +
1205
1266
  updateBound(primitive, "_maxBounds", "_maxBoundsOld") +
1267
+ updateBound(
1268
+ primitive,
1269
+ "_exaggeratedMinBounds",
1270
+ "_exaggeratedMinBoundsOld"
1271
+ ) +
1272
+ updateBound(
1273
+ primitive,
1274
+ "_exaggeratedMaxBounds",
1275
+ "_exaggeratedMaxBoundsOld"
1276
+ ) +
1206
1277
  updateBound(primitive, "_minClippingBounds", "_minClippingBoundsOld") +
1207
1278
  updateBound(primitive, "_maxClippingBounds", "_maxClippingBoundsOld");
1208
1279
  return numChanges > 0;
@@ -1239,8 +1310,8 @@ function updateBound(primitive, newBoundKey, oldBoundKey) {
1239
1310
  function updateShapeAndTransforms(primitive, shape, provider) {
1240
1311
  const visible = shape.update(
1241
1312
  primitive._compoundModelMatrix,
1242
- primitive.minBounds,
1243
- primitive.maxBounds,
1313
+ primitive._exaggeratedMinBounds,
1314
+ primitive._exaggeratedMaxBounds,
1244
1315
  primitive.minClippingBounds,
1245
1316
  primitive.maxClippingBounds
1246
1317
  );
@@ -11,7 +11,7 @@ in vec3 geodeticSurfaceNormal;
11
11
  #endif
12
12
 
13
13
  #ifdef EXAGGERATION
14
- uniform vec2 u_terrainExaggerationAndRelativeHeight;
14
+ uniform vec2 u_verticalExaggerationAndRelativeHeight;
15
15
  #endif
16
16
 
17
17
  uniform vec3 u_center3D;
@@ -173,8 +173,8 @@ void main()
173
173
  #endif
174
174
 
175
175
  #if defined(EXAGGERATION) && defined(GEODETIC_SURFACE_NORMALS)
176
- float exaggeration = u_terrainExaggerationAndRelativeHeight.x;
177
- float relativeHeight = u_terrainExaggerationAndRelativeHeight.y;
176
+ float exaggeration = u_verticalExaggerationAndRelativeHeight.x;
177
+ float relativeHeight = u_verticalExaggerationAndRelativeHeight.y;
178
178
  float newHeight = (height - relativeHeight) * exaggeration + relativeHeight;
179
179
 
180
180
  // stop from going through center of earth
@@ -12,7 +12,7 @@ in vec3 geodeticSurfaceNormal;\n\
12
12
  #endif\n\
13
13
  \n\
14
14
  #ifdef EXAGGERATION\n\
15
- uniform vec2 u_terrainExaggerationAndRelativeHeight;\n\
15
+ uniform vec2 u_verticalExaggerationAndRelativeHeight;\n\
16
16
  #endif\n\
17
17
  \n\
18
18
  uniform vec3 u_center3D;\n\
@@ -174,8 +174,8 @@ void main()\n\
174
174
  #endif\n\
175
175
  \n\
176
176
  #if defined(EXAGGERATION) && defined(GEODETIC_SURFACE_NORMALS)\n\
177
- float exaggeration = u_terrainExaggerationAndRelativeHeight.x;\n\
178
- float relativeHeight = u_terrainExaggerationAndRelativeHeight.y;\n\
177
+ float exaggeration = u_verticalExaggerationAndRelativeHeight.x;\n\
178
+ float relativeHeight = u_verticalExaggerationAndRelativeHeight.y;\n\
179
179
  float newHeight = (height - relativeHeight) * exaggeration + relativeHeight;\n\
180
180
  \n\
181
181
  // stop from going through center of earth\n\
@@ -93,6 +93,10 @@ void main()
93
93
  MetadataStatistics metadataStatistics;
94
94
  metadataStage(metadata, metadataClass, metadataStatistics, attributes);
95
95
 
96
+ #ifdef HAS_VERTICAL_EXAGGERATION
97
+ verticalExaggerationStage(attributes);
98
+ #endif
99
+
96
100
  #ifdef HAS_CUSTOM_VERTEX_SHADER
97
101
  czm_modelVertexOutput vsOutput = defaultVertexOutput(attributes.positionMC);
98
102
  customShaderStage(vsOutput, attributes, featureIds, metadata, metadataClass, metadataStatistics);
@@ -93,6 +93,10 @@ void main() \n\
93
93
  MetadataClass metadataClass;\n\
94
94
  MetadataStatistics metadataStatistics;\n\
95
95
  metadataStage(metadata, metadataClass, metadataStatistics, attributes);\n\
96
+ \n\
97
+ #ifdef HAS_VERTICAL_EXAGGERATION\n\
98
+ verticalExaggerationStage(attributes);\n\
99
+ #endif\n\
96
100
  \n\
97
101
  #ifdef HAS_CUSTOM_VERTEX_SHADER\n\
98
102
  czm_modelVertexOutput vsOutput = defaultVertexOutput(attributes.positionMC);\n\
@@ -0,0 +1,39 @@
1
+ void verticalExaggerationStage(
2
+ inout ProcessedAttributes attributes
3
+ ) {
4
+ // Compute the distance from the camera to the local center of curvature.
5
+ vec4 vertexPositionENU = czm_modelToEnu * vec4(attributes.positionMC, 1.0);
6
+ vec2 vertexAzimuth = normalize(vertexPositionENU.xy);
7
+ // Curvature = 1 / radius of curvature.
8
+ float azimuthalCurvature = dot(vertexAzimuth * vertexAzimuth, czm_eyeEllipsoidCurvature);
9
+ float eyeToCenter = 1.0 / azimuthalCurvature + czm_eyeHeight;
10
+
11
+ // Compute the approximate ellipsoid normal at the vertex position.
12
+ // Uses a circular approximation for the Earth curvature along the geodesic.
13
+ vec3 vertexPositionEC = (czm_modelView * vec4(attributes.positionMC, 1.0)).xyz;
14
+ vec3 centerToVertex = eyeToCenter * czm_eyeEllipsoidNormalEC + vertexPositionEC;
15
+ vec3 vertexNormal = normalize(centerToVertex);
16
+
17
+ // Estimate the (sine of the) angle between the camera direction and the vertex normal
18
+ float verticalDistance = dot(vertexPositionEC, czm_eyeEllipsoidNormalEC);
19
+ float horizontalDistance = length(vertexPositionEC - verticalDistance * czm_eyeEllipsoidNormalEC);
20
+ float sinTheta = horizontalDistance / (eyeToCenter + verticalDistance);
21
+ bool isSmallAngle = clamp(sinTheta, 0.0, 0.05) == sinTheta;
22
+
23
+ // Approximate the change in height above the ellipsoid, from camera to vertex position.
24
+ float exactVersine = 1.0 - dot(czm_eyeEllipsoidNormalEC, vertexNormal);
25
+ float smallAngleVersine = 0.5 * sinTheta * sinTheta;
26
+ float versine = isSmallAngle ? smallAngleVersine : exactVersine;
27
+ float dHeight = dot(vertexPositionEC, vertexNormal) - eyeToCenter * versine;
28
+ float vertexHeight = czm_eyeHeight + dHeight;
29
+
30
+ // Transform the approximate vertex normal to model coordinates.
31
+ vec3 vertexNormalMC = (czm_inverseModelView * vec4(vertexNormal, 0.0)).xyz;
32
+ vertexNormalMC = normalize(vertexNormalMC);
33
+
34
+ // Compute the exaggeration and apply it along the approximate vertex normal.
35
+ float stretch = u_verticalExaggerationAndRelativeHeight.x;
36
+ float shift = u_verticalExaggerationAndRelativeHeight.y;
37
+ float exaggeration = (vertexHeight - shift) * (stretch - 1.0);
38
+ attributes.positionMC += exaggeration * vertexNormalMC;
39
+ }
@@ -0,0 +1,41 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "void verticalExaggerationStage(\n\
3
+ inout ProcessedAttributes attributes\n\
4
+ ) {\n\
5
+ // Compute the distance from the camera to the local center of curvature.\n\
6
+ vec4 vertexPositionENU = czm_modelToEnu * vec4(attributes.positionMC, 1.0);\n\
7
+ vec2 vertexAzimuth = normalize(vertexPositionENU.xy);\n\
8
+ // Curvature = 1 / radius of curvature.\n\
9
+ float azimuthalCurvature = dot(vertexAzimuth * vertexAzimuth, czm_eyeEllipsoidCurvature);\n\
10
+ float eyeToCenter = 1.0 / azimuthalCurvature + czm_eyeHeight;\n\
11
+ \n\
12
+ // Compute the approximate ellipsoid normal at the vertex position.\n\
13
+ // Uses a circular approximation for the Earth curvature along the geodesic.\n\
14
+ vec3 vertexPositionEC = (czm_modelView * vec4(attributes.positionMC, 1.0)).xyz;\n\
15
+ vec3 centerToVertex = eyeToCenter * czm_eyeEllipsoidNormalEC + vertexPositionEC;\n\
16
+ vec3 vertexNormal = normalize(centerToVertex);\n\
17
+ \n\
18
+ // Estimate the (sine of the) angle between the camera direction and the vertex normal\n\
19
+ float verticalDistance = dot(vertexPositionEC, czm_eyeEllipsoidNormalEC);\n\
20
+ float horizontalDistance = length(vertexPositionEC - verticalDistance * czm_eyeEllipsoidNormalEC);\n\
21
+ float sinTheta = horizontalDistance / (eyeToCenter + verticalDistance);\n\
22
+ bool isSmallAngle = clamp(sinTheta, 0.0, 0.05) == sinTheta;\n\
23
+ \n\
24
+ // Approximate the change in height above the ellipsoid, from camera to vertex position.\n\
25
+ float exactVersine = 1.0 - dot(czm_eyeEllipsoidNormalEC, vertexNormal);\n\
26
+ float smallAngleVersine = 0.5 * sinTheta * sinTheta;\n\
27
+ float versine = isSmallAngle ? smallAngleVersine : exactVersine;\n\
28
+ float dHeight = dot(vertexPositionEC, vertexNormal) - eyeToCenter * versine;\n\
29
+ float vertexHeight = czm_eyeHeight + dHeight;\n\
30
+ \n\
31
+ // Transform the approximate vertex normal to model coordinates.\n\
32
+ vec3 vertexNormalMC = (czm_inverseModelView * vec4(vertexNormal, 0.0)).xyz;\n\
33
+ vertexNormalMC = normalize(vertexNormalMC);\n\
34
+ \n\
35
+ // Compute the exaggeration and apply it along the approximate vertex normal.\n\
36
+ float stretch = u_verticalExaggerationAndRelativeHeight.x;\n\
37
+ float shift = u_verticalExaggerationAndRelativeHeight.y;\n\
38
+ float exaggeration = (vertexHeight - shift) * (stretch - 1.0);\n\
39
+ attributes.positionMC += exaggeration * vertexNormalMC;\n\
40
+ }\n\
41
+ ";