Cesium添加倾斜摄影

async DrawTiltPhotographyToModifyHeightFun() {
      try {
        //
        viewer.scene.globe.depthTestAgainstTerrain = true; //开始深度测试
        const tileset = await Cesium.Cesium3DTileset.fromUrl(
          "data/test3dtiles/tileset.json"
        ); // await Cesium.Cesium3DTileset.fromIonAssetId(75343);
        viewer.scene.primitives.add(tileset);
        viewer.zoomTo(tileset);
      } catch (error) {
        console.log(`Error loading tileset: ${error}`);
      }
    },
async DrawTiltPhotographyToModifyHeightFun() {
      try {
        //
        viewer.scene.globe.depthTestAgainstTerrain = true; //开始深度测试
        const tileset = await Cesium.Cesium3DTileset.fromUrl(
          "data/test3dtiles/tileset.json"
        ); // await Cesium.Cesium3DTileset.fromIonAssetId(75343);

        var boundingSphere = tileset.boundingSphere;
        var cartographic = Cesium.Cartographic.fromCartesian(
          boundingSphere.center
        );
        var longitude = cartographic.longitude;
        var latitude = cartographic.latitude;
        var alt = cartographic.height;
        //世界坐标
        var origin = Cesium.Cartesian3.fromRadians(
          cartographic.longitude,
          cartographic.latitude,
          cartographic.height
        );
        //偏移后点
        var alt1 = alt - 10;
        var offset = Cesium.Cartesian3.fromRadians(longitude, latitude, alt1);
        //计算向量
        var translate = Cesium.Cartesian3.subtract(
          offset,
          origin,
          new Cesium.Cartesian3()
        );
        console.log(translate);
        tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translate);
        //矩阵偏移

        viewer.scene.primitives.add(tileset);
        viewer.zoomTo(tileset);
      } catch (error) {
        console.log(`Error loading tileset: ${error}`);
      }
    },

你可能感兴趣的:(前端,javascript,开发语言)