k10_underground.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
  6. <meta name="author" content="火星科技 http://mars3d.cn " />
  7. <meta name="apple-touch-fullscreen" content="yes" />
  8. <meta name="apple-mobile-web-app-capable" content="yes" />
  9. <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  10. <meta name="format-detection" content="telephone=no" />
  11. <meta name="x5-fullscreen" content="true" />
  12. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
  13. <!-- 标题及搜索关键字 -->
  14. <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
  15. <meta
  16. name="description"
  17. content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型 gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包 地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
  18. />
  19. <link rel="shortcut icon" type="image/x-icon" href="" />
  20. <title>地表透明(地下模式) </title>
  21. <!--第三方lib-->
  22. <script
  23. type="text/javascript"
  24. src="../lib/include-lib.js"
  25. libpath="../lib/"
  26. include="jquery,font-awesome,bootstrap,bootstrap-checkbox,bootstrap-slider,layer,haoutil,turf,mars3d"
  27. ></script>
  28. <link href="css/style.css" rel="stylesheet" />
  29. </head>
  30. <body class="dark">
  31. <!--加载前进行操作提示,优化用户体验-->
  32. <div id="mask" class="signmask" onclick="removeMask()"></div>
  33. <div id="mars3dContainer" class="mars3d-container"></div>
  34. <!-- 面板 -->
  35. <div class="infoview">
  36. <table class="mars-table">
  37. <tr class="undergroundAttr">
  38. <td>状态:</td>
  39. <td>
  40. <div class="checkbox checkbox-primary checkbox-inline">
  41. <input id="chkUnderground" class="styled" type="checkbox" checked />
  42. <label for="chkUnderground"> 开启地下模式 </label>
  43. </div>
  44. </td>
  45. </tr>
  46. <tr class="undergroundAttr">
  47. <td>地表透明度:</td>
  48. <td>
  49. <input id="alpha"/>
  50. </td>
  51. </tr>
  52. <tr>
  53. <td>演示视角:</td>
  54. <td>
  55. <input type="button" class="btn btn-primary" value="俯视视角" onclick="centerAtDX1()" />
  56. <input type="button" class="btn btn-primary" value="地下视角1" onclick="centerAtDX2()" />
  57. <input type="button" class="btn btn-primary" value="地下视角2" onclick="centerAtDX3()" />
  58. </td>
  59. </tr>
  60. </table>
  61. </div>
  62. <script src="./js/common.js"></script>
  63. <script type="text/javascript">
  64. "use script"; //开发环境建议开启严格模式
  65. var map;
  66. function initMap(options) {
  67. //合并属性参数,可覆盖config.json中的对应配置
  68. var mapOptions = mars3d.Util.merge(options, {
  69. scene: {
  70. center: { lat: 31.840106, lng: 117.216768, alt: 554, heading: 0, pitch: -59 },
  71. globe: {
  72. depthTestAgainstTerrain: true,
  73. },
  74. },
  75. });
  76. //创建三维地球场景
  77. map = new mars3d.Map("mars3dContainer", mapOptions);
  78. // 设置滑动条的样式
  79. $("#alpha")
  80. .slider({ min: 0.0, max: 1.0, step: 0.1, value: 0.5 })
  81. .on("change", (e) => {
  82. if (e?.value) {
  83. underground.alpha = e.value.newValue;
  84. }
  85. });
  86. let alpha = Number($("#alpha").val());
  87. var underground = new mars3d.thing.Underground({
  88. alpha: alpha,
  89. });
  90. map.addThing(underground);
  91. //地下颜色的个性化处理
  92. // underground.color = Cesium.Color.BLACK
  93. // underground.colorAlphaByDistance = new Cesium.NearFarScalar(1000.0, 0.0, 1000000.0, 1.0)
  94. $("#chkUnderground").change(function () {
  95. var val = $(this).is(":checked");
  96. underground.enabled = val;
  97. });
  98. //以下为演示数据
  99. // 加个模型
  100. var tiles3dLayer = new mars3d.layer.TilesetLayer({
  101. name: "地下管网",
  102. url: "//data.mars3d.cn/3dtiles/max-piping/tileset.json",
  103. position: { lng: 117.215457, lat: 31.843363, alt: -3.6 },
  104. rotation: { z: 336.7 },
  105. maximumScreenSpaceError: 2,
  106. maximumMemoryUsage: 1024,
  107. highlight: { type: "click", color: "#00FFFF" },
  108. popup: "all",
  109. center: { lat: 31.838081, lng: 117.216584, alt: 406, heading: 1, pitch: -34 },
  110. });
  111. map.addLayer(tiles3dLayer);
  112. //创建矢量数据图层
  113. var graphicLayer = new mars3d.layer.GraphicLayer();
  114. map.addLayer(graphicLayer);
  115. //黄色盒子
  116. var graphic = new mars3d.graphic.BoxEntity({
  117. position: [117.218633, 31.843935, 41.43],
  118. style: {
  119. dimensions: new Cesium.Cartesian3(40.0, 30.0, 50.0),
  120. fill: true,
  121. color: "#ffff00",
  122. opacity: 1,
  123. },
  124. });
  125. graphicLayer.addGraphic(graphic);
  126. //创建gltf模型
  127. var graphicModel = new mars3d.graphic.ModelEntity({
  128. position: [117.214494, 31.844015, 30],
  129. style: {
  130. url: "//data.mars3d.cn/gltf/mars/firedrill/xiaofangche2.gltf",
  131. scale: 7,
  132. minimumPixelSize: 50,
  133. },
  134. });
  135. graphicLayer.addGraphic(graphicModel);
  136. }
  137. function centerAtDX1() {
  138. map.setCameraView({
  139. y: 31.840106,
  140. x: 117.216768,
  141. z: 554.36,
  142. heading: 0,
  143. pitch: -59.3,
  144. roll: 0,
  145. });
  146. }
  147. function centerAtDX2() {
  148. map.setCameraView({
  149. y: 31.841263,
  150. x: 117.21538,
  151. z: -13.35,
  152. heading: 40.6,
  153. pitch: 15.7,
  154. roll: 0.1,
  155. });
  156. }
  157. function centerAtDX3() {
  158. map.setCameraView({
  159. y: 31.838908,
  160. x: 117.217486,
  161. z: -63.75,
  162. heading: 349.2,
  163. pitch: 18.2,
  164. roll: 0,
  165. });
  166. }
  167. </script>
  168. </body>
  169. </html>