yzt
2023-05-08 24e1c6a1c3d5331b5a4f1111dcbae3ef148eda1a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import Cartesian3 from "./Cartesian3.js";
 
/**
 * @private
 */
var TerrainExaggeration = {};
 
/**
 * Scales a height relative to an offset.
 *
 * @param {Number} height The height.
 * @param {Number} scale A scalar used to exaggerate the terrain. If the value is 1.0 there will be no effect.
 * @param {Number} relativeHeight The height relative to which terrain is exaggerated. If the value is 0.0 terrain will be exaggerated relative to the ellipsoid surface.
 */
TerrainExaggeration.getHeight = function (height, scale, relativeHeight) {
  return (height - relativeHeight) * scale + relativeHeight;
};
 
var scratchCartographic = new Cartesian3();
 
/**
 * Scales a position by exaggeration.
 */
TerrainExaggeration.getPosition = function (
  position,
  ellipsoid,
  terrainExaggeration,
  terrainExaggerationRelativeHeight,
  result
) {
  var cartographic = ellipsoid.cartesianToCartographic(
    position,
    scratchCartographic
  );
  var newHeight = TerrainExaggeration.getHeight(
    cartographic.height,
    terrainExaggeration,
    terrainExaggerationRelativeHeight
  );
  return Cartesian3.fromRadians(
    cartographic.longitude,
    cartographic.latitude,
    newHeight,
    ellipsoid,
    result
  );
};
 
export default TerrainExaggeration;