Jelajahi Sumber

config修改 模型加载修改

wandequan 2 tahun lalu
induk
melakukan
b75576b1b6
2 mengubah file dengan 147 tambahan dan 76 penghapusan
  1. 4 1
      public/static/config/config.js
  2. 143 75
      src/components/MainMap.vue

+ 4 - 1
public/static/config/config.js

@@ -22,8 +22,11 @@ var systemConfig = {
     // shzx: "http://139.159.0.174:9002/model_data/SHLJZ/SHzhongxin/output"
     // lujiazui: "http://192.168.1.37:9002/model_data/SHLJZ/lujiazui/output",
     mainBuild: "http://192.168.1.37:9002/model_data/SHLJZ/SHSJT",
+    shzxZJY_wai: "http://192.168.1.37:9002/model_data/SHZX/FBX/output/DD",
+    shzxZJY_nei: "http://192.168.1.37:9002/model_data/SHZX/FBX/output/ZX",
+
     lujiazui: "http://192.168.1.37:9002/model_data/SHLJZ/bm_SHLJZ/output",
-    shzx: "http://192.168.1.37:9002/model_data/SHLJZ/SHzhongxin/output",
+    // shzx: "http://192.168.1.37:9002/model_data/SHLJZ/SHzhongxin/output",
 
     bim: "http://192.168.1.37:9002/model_data/SHLJZ/SHZX_13F/V1_2"
   },

+ 143 - 75
src/components/MainMap.vue

@@ -150,89 +150,154 @@ export default {
       `,
     });
 
-    // 重要建筑
-    let mainBuildTileset = this.add3DTiles(
+    // 张金雨建模  外
+    let shzxZJYTileset_N = this.add3DTiles(
       viewer,
-      systemConfig.server.mainBuild,
+      systemConfig.server.shzxZJY_wai,
       false
     );
-    this.mainBuildTileset = mainBuildTileset;
-    mainBuildTileset.readyPromise.then(function (tileset) {
-      // tileset.modelMatrix = that.createMatrix4({
-      //   longitude: 121.4983784,
-      //   latitude: 31.2392238,
-      //   height: 0,
-      //   rx: 0,
-      //   ry: 0,
-      //   rz: 0,
-      // });
-
-      // // 偏移
-      // //笛卡尔转换为弧度
-      // var cartographic = Cesium.Cartographic.fromCartesian(
-      //   tileset.boundingSphere.center
-      // );
-      // var lng = Cesium.Math.toDegrees(cartographic.longitude); //使用经纬度和弧度的转换,将WGS84弧度坐标系转换到目标值,弧度转度
-      // var lat = Cesium.Math.toDegrees(cartographic.latitude);
-      // var height = cartographic.height;
-      // //计算中心点位置的地表坐标
-      // var surface = Cesium.Cartesian3.fromDegrees(lng, lat, height);
-      // const m = Cesium.Transforms.eastNorthUpToFixedFrame(surface);
-      // const tempTranslation = new Cesium.Cartesian3(2000, 2000, 0);
-      // const offset = Cesium.Matrix4.multiplyByPoint(
-      //   m,
-      //   tempTranslation,
-      //   new Cesium.Cartesian3(0, 0, 0)
-      // );
-      // const translation = Cesium.Cartesian3.subtract(
-      //   offset,
-      //   surface,
-      //   new Cesium.Cartesian3()
-      // );
-      // tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
+    this.shzxZJYTileset_N = shzxZJYTileset_N;
+    shzxZJYTileset_N.readyPromise.then(function (tileset) {
+      tileset.style = new Cesium.Cesium3DTileStyle({
+        color: {
+          conditions: [
+            // ["true", "color('rgb(0,255,255)',0.6)"]//135,206,250    51, 153, 255
+            ["true", "color('rgb(0,252,255)',0.8)"], //135,206,250    51, 153, 255
+          ],
+        },
+      });
+      that.panyi(tileset);
+    });
+    shzxZJYTileset_N.customShader = new Cesium.CustomShader({
+      lightingModel: Cesium.LightingModel.UNLIT,
+      varyings: {
+        v_normalMC: Cesium.VaryingType.VEC3,
+      },
+      vertexShaderText: `
+    void vertexMain(VertexInput vsInput, inout czm_modelVertexOutput vsOutput) {
+      v_normalMC = vsInput.attributes.normalMC;
+    }
+    `,
+      fragmentShaderText: `
+  void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) {
+        float _baseHeight = 0.0; // 物体的基础高度,需要修改成一个合适的建筑基础高度
+        float _heightRange = 200.0; // 高亮的范围(_baseHeight ~ _baseHeight + _      heightRange) 默认是 0-60米
+        float _glowRange = 600.0; // 光环的移动范围(高度)
 
-      // //偏移后的坐标
-      // // var offset = Cesium.Cartesian3.fromDegrees(lng + 0.0045, lat - 0.002, 0);
-      // // var offset = Cesium.Cartesian3.fromDegrees(
-      // //   121.4983784, // + 0.0045,
-      // //   31.2392238, // - 0.002,
-      // //   0
-      // // );
-      // // var translation = Cesium.Cartesian3.subtract(
-      // //   offset,
-      // //   surface,
-      // //   new Cesium.Cartesian3()
-      // // );
-      // // tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
-      // return;
+        vec3 position = fsInput.attributes.positionMC;
 
-      var transformPosition = Cesium.Cartesian3.fromDegrees(
-        121.4983784 + 0.0045,
-        31.2392238 - 0.002,
-        0
-      );
-      var matrix = Cesium.Transforms.eastNorthUpToFixedFrame(transformPosition);
-      var scale = Cesium.Matrix4.fromUniformScale(1);
-      Cesium.Matrix4.multiply(matrix, scale, matrix);
+        float vtxf_height = position.y-_baseHeight;
+        float vtxf_a11 = fract(czm_frameNumber / 300.0) * 3.14159265 * 0.8;
+        // float vtxf_a12 = vtxf_height / _heightRange + sin(vtxf_a11) * 0.5;
+        float vtxf_a12 = vtxf_height / _heightRange + vtxf_a11 * 0.8;
+        material.diffuse*= vec3(vtxf_a12, vtxf_a12, vtxf_a12);
 
-      var rotationX = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(0));
-      var rotationY = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(0));
-      var rotationZ = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(8));
-      var rotationTranslationX =
-        Cesium.Matrix4.fromRotationTranslation(rotationX);
-      var rotationTranslationY =
-        Cesium.Matrix4.fromRotationTranslation(rotationY);
-      var rotationTranslationZ =
-        Cesium.Matrix4.fromRotationTranslation(rotationZ);
-      Cesium.Matrix4.multiply(matrix, rotationTranslationX, matrix);
-      Cesium.Matrix4.multiply(matrix, rotationTranslationY, matrix);
-      Cesium.Matrix4.multiply(matrix, rotationTranslationZ, matrix);
 
-      tileset._root.transform = matrix;
+        float time = fract(czm_frameNumber / 2000.0);
+        time = abs(time - 0.5) * 2.0;
+        float diff = step(0.03, abs(clamp(position.y / _glowRange, 0.0, 1.0) - time ));
+        float diff2 = step(0.03, abs(clamp(position.y / _glowRange, 0.0, 1.0) - fract(time + 0.25 )));
+        float diff3 = step(0.03, abs(clamp(position.y / _glowRange, 0.0, 1.0) - fract(time + 0.5 )) );
+        float diff4 = step(0.03, abs(clamp(position.y / _glowRange, 0.0, 1.0) - fract(time + 0.75)));
+        material.diffuse += material.diffuse * (1.0 - (diff * diff2 * diff3 * diff4)) * (1.0 - v_normalMC.y) * 10.0;
 
-      // viewer.zoomTo(mainBuildTileset);
+      }
+  `,
+    });
+    // 张金雨建模  内
+    let shzxZJYTileset_W = this.add3DTiles(
+      viewer,
+      systemConfig.server.shzxZJY_nei,
+      false
+    );
+    this.shzxZJYTileset_W = shzxZJYTileset_W;
+    shzxZJYTileset_W.readyPromise.then(function (tileset) {
+      that.panyi(tileset);
     });
 
+    // // 重要建筑
+    // let mainBuildTileset = this.add3DTiles(
+    //   viewer,
+    //   systemConfig.server.mainBuild,
+    //   false
+    // );
+    // this.mainBuildTileset = mainBuildTileset;
+    // mainBuildTileset.readyPromise.then(function (tileset) {
+    //   // tileset.modelMatrix = that.createMatrix4({
+    //   //   longitude: 121.4983784,
+    //   //   latitude: 31.2392238,
+    //   //   height: 0,
+    //   //   rx: 0,
+    //   //   ry: 0,
+    //   //   rz: 0,
+    //   // });
+
+    //   // // 偏移
+    //   // //笛卡尔转换为弧度
+    //   // var cartographic = Cesium.Cartographic.fromCartesian(
+    //   //   tileset.boundingSphere.center
+    //   // );
+    //   // var lng = Cesium.Math.toDegrees(cartographic.longitude); //使用经纬度和弧度的转换,将WGS84弧度坐标系转换到目标值,弧度转度
+    //   // var lat = Cesium.Math.toDegrees(cartographic.latitude);
+    //   // var height = cartographic.height;
+    //   // //计算中心点位置的地表坐标
+    //   // var surface = Cesium.Cartesian3.fromDegrees(lng, lat, height);
+    //   // const m = Cesium.Transforms.eastNorthUpToFixedFrame(surface);
+    //   // const tempTranslation = new Cesium.Cartesian3(2000, 2000, 0);
+    //   // const offset = Cesium.Matrix4.multiplyByPoint(
+    //   //   m,
+    //   //   tempTranslation,
+    //   //   new Cesium.Cartesian3(0, 0, 0)
+    //   // );
+    //   // const translation = Cesium.Cartesian3.subtract(
+    //   //   offset,
+    //   //   surface,
+    //   //   new Cesium.Cartesian3()
+    //   // );
+    //   // tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
+
+    //   // //偏移后的坐标
+    //   // // var offset = Cesium.Cartesian3.fromDegrees(lng + 0.0045, lat - 0.002, 0);
+    //   // // var offset = Cesium.Cartesian3.fromDegrees(
+    //   // //   121.4983784, // + 0.0045,
+    //   // //   31.2392238, // - 0.002,
+    //   // //   0
+    //   // // );
+    //   // // var translation = Cesium.Cartesian3.subtract(
+    //   // //   offset,
+    //   // //   surface,
+    //   // //   new Cesium.Cartesian3()
+    //   // // );
+    //   // // tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
+    //   // return;
+
+    //   var transformPosition = Cesium.Cartesian3.fromDegrees(
+    //     121.4983784 + 0.0045,
+    //     31.2392238 - 0.002,
+    //     0
+    //   );
+    //   var matrix = Cesium.Transforms.eastNorthUpToFixedFrame(transformPosition);
+    //   var scale = Cesium.Matrix4.fromUniformScale(1);
+    //   Cesium.Matrix4.multiply(matrix, scale, matrix);
+
+    //   var rotationX = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(0));
+    //   var rotationY = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(0));
+    //   var rotationZ = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(8));
+    //   var rotationTranslationX =
+    //     Cesium.Matrix4.fromRotationTranslation(rotationX);
+    //   var rotationTranslationY =
+    //     Cesium.Matrix4.fromRotationTranslation(rotationY);
+    //   var rotationTranslationZ =
+    //     Cesium.Matrix4.fromRotationTranslation(rotationZ);
+    //   Cesium.Matrix4.multiply(matrix, rotationTranslationX, matrix);
+    //   Cesium.Matrix4.multiply(matrix, rotationTranslationY, matrix);
+    //   Cesium.Matrix4.multiply(matrix, rotationTranslationZ, matrix);
+
+    //   tileset._root.transform = matrix;
+
+    //   // viewer.zoomTo(mainBuildTileset);
+    // });
+
     // BIM 建模
     let bimTileset = this.add3DTiles(viewer, systemConfig.server.bim, false);
     this.bimTileset = bimTileset;
@@ -425,8 +490,11 @@ export default {
     },
 
     changeSwitch(val) {
-      this.mainBuildTileset.show = val;
-      this.bimTileset .show = !val;
+      // this.mainBuildTileset.show = val;
+      this.shzxZJYTileset_N.show = val
+      this.shzxZJYTileset_W.show = val
+
+      this.bimTileset.show = !val;
     },
 
     initMap(viewer) {