master
2022-04-15 76e3db6a828a8ad842bbcce38ae44ba589450197
添加煤堆点云
2个文件已添加
1个文件已修改
4511 ■■■■■ 已修改文件
public/hn3d/example/00_hn_new.html 99 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
public/hn3d/model/hn.txt 补丁 | 查看 | 原始文档 | blame | 历史
public/hn3d/model/hn4.txt 4412 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
public/hn3d/example/00_hn_new.html
@@ -60,17 +60,18 @@
    <button type="button" id="meipeng_pati_madao" class="btn btn-primary" style="width: 100%;">爬梯马道</button>
    <button type="button" id="meipeng_tiejia" class="btn btn-primary" style="width: 100%;">钢结构架</button>
    <button type="button" id="meipeng_dimian" class="btn btn-primary" style="width: 100%;">煤棚地面</button>
    <button type="button" id="dou_move" class="btn btn-primary" style="width: 100%;">移动</button>
    <!-- <button type="button" id="dou_move" class="btn btn-primary" style="width: 100%;">移动</button>
    <button type="button" id="dou_rote" class="btn btn-primary" style="width: 100%;">旋转</button>
    <button type="button" id="dou_work" class="btn btn-primary" style="width: 100%;">挖煤</button>
    <button type="button" id="dou_work" class="btn btn-primary" style="width: 100%;">挖煤</button> -->
    <button type="button" id="test_btn" class="btn btn-primary" style="width: 100%;">测试</button>
    <button type="button" id="point_btn" class="btn btn-primary" style="width: 100%;">煤堆</button>
  </div>
  <div class="infoview handle" id="time_line">
  <!-- <div class="infoview handle" id="time_line">
    <button type="button" class="btn btn-primary" style="width: 100%;">time1</button>
    <button type="button" class="btn btn-primary" style="width: 100%;">time2</button>
    <button type="button" class="btn btn-primary" style="width: 100%;">time3</button>
    <button type="button" class="btn btn-primary" style="width: 100%;">time4</button>
  </div>
  </div> -->
  <script src="./js/common.js"></script>
  <script type="text/javascript">
@@ -92,7 +93,7 @@
    var data_url = 'http://127.0.0.1:8001/admin/business/devicegroup/getdata?bid='
    var time_btn = $("#time_line button")
    var model_no = 0
    var distance_half = 111319.5;
    // 页面初始执行的方法
    $(document).ready(function () {
      console.log(time_btn)
@@ -243,7 +244,7 @@
        ],
      });
      addCustomLayers()
      //创建三维地球场景
@@ -294,7 +295,6 @@
        parent: dou_parent
      })
      graphicLayer.addGraphic(dou3)
      var dou4 = new mars3d.graphic.ModelEntity({
@@ -356,7 +356,6 @@
          dimian_model.show = false;
        }
      });
@@ -478,6 +477,82 @@
          $(this).addClass("active");
        });
      });
      // group方法可以将一个数组按照指定长度进行分组
      function group (array, subGroupLength) {
        let index = 0;
        let newArray = [];
        while (index < array.length) {
          newArray.push(array.slice(index, index += subGroupLength));
        }
        return newArray;
      }
      // 试加载TXT点云文件
      // 读取TXT文件并将TXT内容转换为数组
      // $.ajax({
      //   url: 'http://112.74.77.127:9100/hn/pointcloud/hn4.txt',
      //   dataType: 'text',
      //   success: function (data) {
      //     addPointCloud(data)
      //   }
      // });
      $("#point_btn").click(function () {
        var data_path = 'http://112.74.77.127:9100/hn/pointcloud/hn4.txt'
        console.log("我点击了")
        $.ajax({
          url: data_path,
          dataType: 'text',
          success: function (data) {
            addPointCloud(data)
          }
        });
      })
      function addPointCloud (data) {
        var pointPrimitives = null;// 申明点渲染集合
        pointPrimitives = map.viewer.scene.primitives.add(new Cesium.PointPrimitiveCollection());
        datas = data.split(/\s|[\r\n]/)//将txt每行内容根据空格和换行进行切割
        data_list = datas.map(Number)//将切割后的xyz左边转换为数字格式
        list = group(data_list, 3)//将转换后的数据每六个分为一组
        // 循环数组,加载点云
        for (var i = 0; i < list.length; i++) {
          var hn_lon = Number(list[i][0]) / distance_half + 121.398442;
          var hn_lat = Number(list[i][1]) / distance_half + 31.460107;
          var hn_h = 300 - Number(list[i][2]);
          var color_b = Math.floor(hn_h)
          if (hn_h <= 50) {
            color = Cesium.Color.fromCssColorString(`rgba(0, ${color_b}, ${color_b}, 1)`)
          } else if (hn_h <= 80) {
            color = Cesium.Color.fromCssColorString(`rgba(${color_b}, 0, ${color_b}, 1)`)
          } else {
            color = Cesium.Color.fromCssColorString(`rgba(${color_b}, ${color_b}, 0, 1)`)
          }
          var position = Cesium.Cartesian3.fromDegrees(hn_lon, hn_lat, hn_h);
          pointPrimitives.add({
            pixelSize: 1,
            color: color,
            //         outlineColor: Cesium.Color.BLUE,
            outlineWidth: 0,
            position: position
          });
        }
      }
      //键盘漫游
      map.keyboardRoam.setOptions({
        moveStep: 0.1, //平移步长 (米)。
@@ -502,6 +577,10 @@
    // 试加载TXT点云文件
    function addPrimitivesPointFromJSONTest () {
      console.log(map, "map")
    }
@@ -534,6 +613,10 @@
        pitch: -18,
      });
    }
    function addCustomLayers () {
      addPrimitivesPointFromJSONTest()
    }
  </script>
</body>
public/hn3d/model/hn.txt
Binary files differ
public/hn3d/model/hn4.txt
New file
Diff too large