浏览代码

模型拉伸

maxiaoxiao 10 月之前
父节点
当前提交
d405c3cb33
共有 1 个文件被更改,包括 41 次插入51 次删除
  1. 41 51
      src/views/modelStretch/index.vue

+ 41 - 51
src/views/modelStretch/index.vue

@@ -225,7 +225,9 @@ export default {
     clear() {
     clear() {
       this.$refs.range.reset();
       this.$refs.range.reset();
       // this.pullClear();
       // this.pullClear();
-      this.removeEntities();
+      // this.removeEntities();
+      viewer.entities.removeAll();
+      viewer.dataSources.removeAll();
     },
     },
     submit() {
     submit() {
       var _temp = this.$refs.range.getRange();
       var _temp = this.$refs.range.getRange();
@@ -239,7 +241,7 @@ export default {
           }
           }
           this.form.geojson = parse(_temp.geom);
           this.form.geojson = parse(_temp.geom);
           // this.pullUp(_temp, this.form.BuildingHeight);
           // this.pullUp(_temp, this.form.BuildingHeight);
-          this.onSubmit(this.form.geojson);
+          this.onSubmit();
         }
         }
       });
       });
     },
     },
@@ -267,9 +269,8 @@ export default {
 
 
       return gcHight;
       return gcHight;
     },
     },
-    onSubmit(geojson) {
-      let that = this;
-      that.removeEntities();
+    onSubmit() {
+      // that.removeEntities();
       // //基础高度(地形高度)加入地形后可删除
       // //基础高度(地形高度)加入地形后可删除
       let jcgd = 0;
       let jcgd = 0;
       jcgd = this.getjcHigeht(geojson);
       jcgd = this.getjcHigeht(geojson);
@@ -278,58 +279,47 @@ export default {
         minH = jcgd;
         minH = jcgd;
       for (
       for (
         let FLOORindex = 1;
         let FLOORindex = 1;
-        FLOORindex <= Math.ceil(that.form.BuildingHeight / that.form.FLOORH);
+        FLOORindex <= Math.ceil(this.form.BuildingHeight / this.form.FLOORH);
         FLOORindex++
         FLOORindex++
       ) {
       ) {
-        // debugger;
-        maxH += that.form.FLOORH;
-        minH = maxH - that.form.FLOORH;
-        if (maxH > that.form.BuildingHeight) maxH = that.form.BuildingHeight;
+        maxH += this.form.FLOORH;
+        minH = maxH - this.form.FLOORH;
+        if (maxH > this.form.BuildingHeight) maxH = this.form.BuildingHeight;
         console.log("maxH:" + maxH + "----minH:" + minH);
         console.log("maxH:" + maxH + "----minH:" + minH);
         this.loadGeoJSON(this.form.geojson, "#ffffff", "", minH, maxH, "");
         this.loadGeoJSON(this.form.geojson, "#ffffff", "", minH, maxH, "");
-        let ps = [];
-        // for (let index = 0; index < element.geometry.points.length; index++) {
-        //   const point = element.geometry.points[index];
-        //   ps.push(point.x);
-        //   ps.push(point.y);
-        //   // ps.push(minH);
-        // }
-        // geojson.coordinates[0].forEach((gom) => {
-        //   ps.push(gom[0]);
-        //   ps.push(gom[1]);
-        // });
-        // // let id = uuidv4();
-        // this.addPolygon(ps, jcgd, that.form.BuildingHeight);
-
-        // let pss = [];
-        // // for (let index = 0; index < element.geometry.points.length; index++) {
-        // //   const point = element.geometry.points[index];
-        // //   pss.push(point.x);
-        // //   pss.push(point.y);
-        // //   pss.push(maxH);
-        // // }
-        // geojson.coordinates[0].forEach((gom) => {
-        //   pss.push(gom[0]);
-        //   pss.push(gom[1]);
-        //   pss.push(maxH);
-        // });
-        // this.addPolyline(pss);
-
-        // viewer.entities.add({
-        //   id: id,
-        //   polygon: {
-        //     hierarchy: Cesium.Cartesian3.fromDegreesArrayHeights(ps),
-        //     extrudedHeight: Number(maxH),
-        //     perPositionHeight: true,
-        //     material: Cesium.Color.CHARTREUSE.withAlpha(0.1),
-        //     outline: true,
-        //     outlineColor: Cesium.Color.MEDIUMSPRINGGREEN,
-        //     outlineWidth: 1.0,
-        //     shadows: Cesium.ShadowMode.ENABLED,
-        //   },
-        // });
+        // this.addPrimitive(this.form.geojson);
       }
       }
     },
     },
+
+    addPrimitive() {
+      // let ps = [];
+      // geojson.coordinates[0].forEach((gom) => {
+      //   ps.push(gom[0]);
+      //   ps.push(gom[1]);
+      // });
+      // // let id = uuidv4();
+      // this.addPolygon(ps, jcgd, that.form.BuildingHeight);
+      // let pss = [];
+      // geojson.coordinates[0].forEach((gom) => {
+      //   pss.push(gom[0]);
+      //   pss.push(gom[1]);
+      //   pss.push(maxH);
+      // });
+      // this.addPolyline(pss);
+      // viewer.entities.add({
+      //   id: id,
+      //   polygon: {
+      //     hierarchy: Cesium.Cartesian3.fromDegreesArrayHeights(ps),
+      //     extrudedHeight: Number(maxH),
+      //     perPositionHeight: true,
+      //     material: Cesium.Color.CHARTREUSE.withAlpha(0.1),
+      //     outline: true,
+      //     outlineColor: Cesium.Color.MEDIUMSPRINGGREEN,
+      //     outlineWidth: 1.0,
+      //     shadows: Cesium.ShadowMode.ENABLED,
+      //   },
+      // });
+    },
     addPolygon(ps, minH, maxH) {
     addPolygon(ps, minH, maxH) {
       // 定义多边形的顶点(经纬度)
       // 定义多边形的顶点(经纬度)
       var polygonHierarchy = new Cesium.PolygonHierarchy(
       var polygonHierarchy = new Cesium.PolygonHierarchy(