f60_space_conicSensor.html 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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>ConicSensor 圆椎体(任意方向) </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,mars3d-space"
  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. <div style="width: 100%; text-align: center; font-size: 16px">参数设置</div>
  37. <table class="mars-table">
  38. <tr>
  39. <td class="nametd">圆锥体</td>
  40. <td>
  41. <div class="checkbox checkbox-primary checkbox-inline">
  42. <input id="chkShow" class="styled" type="checkbox" checked />
  43. <label for="chkShow"> 显示/隐藏 </label>
  44. </div>
  45. </td>
  46. </tr>
  47. <tr>
  48. <td class="nametd">方向角(heading)</td>
  49. <td>
  50. <input id="model_heading" />
  51. </td>
  52. </tr>
  53. <tr>
  54. <td class="nametd">俯仰角(pitch)</td>
  55. <td>
  56. <input id="model_pitch" />
  57. </td>
  58. </tr>
  59. <tr>
  60. <td class="nametd">左右角(roll)</td>
  61. <td>
  62. <input id="model_roll" />
  63. </td>
  64. </tr>
  65. <tr>
  66. <td class="nametd">夹角(半场角)</td>
  67. <td>
  68. <input id="model_angle1" />
  69. </td>
  70. </tr>
  71. <tr>
  72. <td class="nametd">长度(米)</td>
  73. <td>
  74. <input id="model_length" type="number" class="form-control" min="1" max="99999999999" step="1.0" value="700000" title="半径" />
  75. </td>
  76. </tr>
  77. <tr>
  78. <td class="nametd">顶盖</td>
  79. <td>
  80. <div class="checkbox checkbox-primary checkbox-inline">
  81. <input id="chkShowTop" class="styled" type="checkbox" checked />
  82. <label for="chkShowTop"> 是否显示 </label>
  83. </div>
  84. </td>
  85. </tr>
  86. </table>
  87. </div>
  88. <script src="./js/common.js"></script>
  89. <script type="text/javascript">
  90. "use script"; //开发环境建议开启严格模式
  91. var map;
  92. function initMap(options) {
  93. //合并属性参数,可覆盖config.json中的对应配置
  94. var mapOptions = mars3d.Util.merge(options, {
  95. scene: {
  96. center: { lat: 23.729961, lng: 116.284734, alt: 1868672, heading: 355, pitch: -65 },
  97. cameraController: {
  98. constrainedAxis: false, //解除在南北极区域鼠标操作限制
  99. },
  100. },
  101. });
  102. //创建三维地球场景
  103. map = new mars3d.Map("mars3dContainer", mapOptions);
  104. //移除2.5D视图
  105. var arr = $(".cesium-sceneModePicker-wrapper").children();
  106. if (arr.length > 3) {
  107. arr[3].remove();
  108. }
  109. //创建矢量数据图层
  110. var graphicLayer = new mars3d.layer.GraphicLayer();
  111. map.addLayer(graphicLayer);
  112. //加个模型
  113. var graphic = new mars3d.graphic.ModelEntity({
  114. name: "地面站模型",
  115. position: [117.170264, 31.840312, 258],
  116. style: {
  117. url: "//data.mars3d.cn/gltf/mars/leida.glb",
  118. scale: 1,
  119. minimumPixelSize: 40,
  120. clampToGround: true,
  121. },
  122. });
  123. graphicLayer.addGraphic(graphic);
  124. //滑动条
  125. $("#model_heading")
  126. .slider({ min: 0, max: 360, step: 0.01, value: 0 })
  127. .on("change", (e) => {
  128. if (e && e.value) {
  129. conicSensor.heading = e.value.newValue;
  130. }
  131. });
  132. $("#model_pitch")
  133. .slider({ min: -180, max: 180, step: 0.01, value: 40 })
  134. .on("change", (e) => {
  135. if (e && e.value) {
  136. conicSensor.pitch = e.value.newValue;
  137. }
  138. });
  139. $("#model_roll")
  140. .slider({ min: -180, max: 180, step: 0.01, value: 0 })
  141. .on("change", (e) => {
  142. if (e && e.value) {
  143. conicSensor.roll = e.value.newValue;
  144. }
  145. });
  146. $("#model_angle1")
  147. .slider({ min: 0.1, max: 89.9, step: 0.01, value: 5 })
  148. .on("change", (e) => {
  149. if (e && e.value) {
  150. conicSensor.angle = e.value.newValue;
  151. }
  152. });
  153. //参数
  154. var heading = Number($("#model_heading").val());
  155. var pitch = Number($("#model_pitch").val());
  156. var roll = Number($("#model_roll").val());
  157. var angle = Number($("#model_angle1").val());
  158. var length = Number($("#model_length").val());
  159. //圆锥体
  160. var conicSensor = new mars3d.graphic.ConicSensor({
  161. position: [117.170264, 31.840312, 363],
  162. style: {
  163. angle: angle,
  164. length: length,
  165. // length: new Cesium.CallbackProperty(function (time) {
  166. // length += 100 //测试动态length
  167. // return length
  168. // }, false),
  169. heading: heading,
  170. pitch: pitch,
  171. roll: roll,
  172. color: "rgba(255,0,0,0.4)",
  173. outlineColor: "rgba(255,255,255,0.9)",
  174. },
  175. });
  176. graphicLayer.addGraphic(conicSensor);
  177. //测试连接线
  178. let testLine = new mars3d.graphic.PolylineEntity({
  179. positions: new Cesium.CallbackProperty(function (time) {
  180. var localEnd = conicSensor.rayPosition;
  181. if (!localEnd) {
  182. return [];
  183. }
  184. return [conicSensor.position, localEnd];
  185. }, false),
  186. style: {
  187. arcType: Cesium.ArcType.NONE,
  188. material: mars3d.MaterialUtil.createMaterialProperty(mars3d.MaterialType.PolylineDash, {
  189. color: "#ff0000",
  190. }),
  191. width: 1,
  192. },
  193. });
  194. graphicLayer.addGraphic(testLine);
  195. $("#model_length").change(function () {
  196. conicSensor.length = Number($(this).val());
  197. });
  198. $("#chkShowTop").change(function () {
  199. var val = $(this).is(":checked");
  200. conicSensor.topShow = val;
  201. });
  202. $("#chkShow").change(function () {
  203. var val = $(this).is(":checked");
  204. conicSensor.show = val;
  205. testLine.show = val;
  206. });
  207. }
  208. </script>
  209. </body>
  210. </html>