LY_terrain.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. const onlineterrains = function onlineterrainterrain() {
  2. viewer.terrainProvider = Cesium.createWorldTerrain({
  3. requestWaterMask: true, // required for water effects
  4. requestVertexNormals: true // required for terrain lighting
  5. });
  6. };
  7. const outlineterrainterrains = function outlineterrainterrain() {
  8. // 本地地形
  9. var terrainLayer = new Cesium.CesiumTerrainProvider({
  10. url: "http://data.mars3d.cn/terrain"
  11. });
  12. viewer.terrainProvider = terrainLayer;
  13. };
  14. const ArcGlsterrainterrains = function ArcGlsterrainterrain() {
  15. // 本地地形
  16. var terrainLayer = new Cesium.ArcGISTiledElevationTerrainProvider({
  17. url:
  18. "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"
  19. });
  20. viewer.terrainProvider = terrainLayer;
  21. };
  22. const contourLines = function contourLine() {
  23. viewer.terrainProvider = Cesium.createWorldTerrain({
  24. requestWaterMask: true, // required for water effects
  25. requestVertexNormals: true // required for terrain lighting
  26. });
  27. let globe = viewer.scene.globe;
  28. let contourUniforms = {};
  29. // 使用等高线材质
  30. let material = Cesium.Material.fromType("ElevationContour");
  31. contourUniforms = material.uniforms;
  32. // 线宽2.0px
  33. contourUniforms.width = 2.0;
  34. // 高度间隔为150米
  35. contourUniforms.spacing = 150;
  36. contourUniforms.color = Cesium.Color.RED;
  37. // 设置材质
  38. globe.material = material;
  39. };
  40. const terrainExaggerations = function terrainExaggeration() {
  41. viewer.terrainProvider = Cesium.createWorldTerrain({
  42. requestWaterMask: true, // required for water effects
  43. requestVertexNormals: true // required for terrain lighting
  44. });
  45. // 地形夸张
  46. viewer.scene.globe.terrainExaggeration = 50.0;
  47. };
  48. const getclippens = function getclippen() {
  49. //左键绘制,右键结束
  50. drawClippings = new ClippingPlanes({
  51. viewer: viewer,
  52. color: "#fff"
  53. });
  54. drawClippings.StartClippingPlanes();
  55. };
  56. const unclippens = function unclippen() {
  57. drawClippings.unterrionclippingPlanes();
  58. };
  59. const terrainList = data => {
  60. let Vuemouunted = null;
  61. let bodydiv = null;
  62. let Vuedata = null;
  63. let Vuemethod = null;
  64. let importData = null;
  65. let refdata = null;
  66. switch (data.name) {
  67. case "在线地形":
  68. Vuemouunted =
  69. "\n" + data.interiormethod + "\n" + onlineterrains.toString();
  70. break;
  71. case "离线地形":
  72. Vuemouunted =
  73. "\n" + data.interiormethod + "\n" + outlineterrainterrains.toString();
  74. break;
  75. case "ArcGis地形":
  76. Vuemouunted =
  77. "\n" + data.interiormethod + "\n" + ArcGlsterrainterrains.toString();
  78. break;
  79. case "等高线":
  80. Vuemouunted = "\n" + data.interiormethod + "\n" + contourLines.toString();
  81. break;
  82. case "地形夸张":
  83. Vuemouunted =
  84. "\n" + data.interiormethod + "\n" + terrainExaggerations.toString();
  85. break;
  86. case "地形开挖":
  87. bodydiv = data.bodydiv;
  88. importData = data.importData;
  89. let methods = getclippens.toString() + "," + unclippens.toString();
  90. Vuemethod = methods.replace(/function/g, "\n");
  91. break;
  92. }
  93. return { bodydiv, Vuedata, importData, Vuemethod, Vuemouunted, refdata };
  94. };
  95. export { terrainList };