cesium 动态调整模型位置和角度

记录一下cesium动态调整模型的位置和角度的代码,有错误还请指出。

这里只记录主要代码,有问题可在评论区留言

<template>
<el-form
              :model="tileModelTool"
              label-width="60px"
              style="width: 100%"
            >
              <el-form-item label="经度">
                <el-input-number
                  v-model="tileModelTool.longitude"
                  @change="
                    (currentValue, oldValue) => {
                      updateMaxtrix(currentValue, oldValue, 4);
                    }
                  "
                  :step="0.00001"
                ></el-input-number>
              </el-form-item>
              <el-form-item label="纬度">
                <el-input-number
                  v-model="tileModelTool.latitude"
                  @change="
                    (currentValue, oldValue) => {
                      updateMaxtrix(currentValue, oldValue, 5);
                    }
                  "
                  :step="0.00001"
                ></el-input-number>
              </el-form-item>
              <el-form-item label="高度">
                <el-input-number
                  v-model="tileModelTool.height"
                  @change="
                    (currentValue, oldValue) => {
                      updateMaxtrix(currentValue, oldValue, 6);
                    }
                  "
                  :step="1"
                ></el-input-number>
              </el-form-item>
              <el-form-item label="偏航角">
                <el-input-number
                  v-model="tileModelTool.rz"
                  @change="
                    (currentValue, oldValue) => {
                      updateMaxtrix(currentValue, oldValue, 1);
                    }
                  "
                  :min="-180"
                  :max="180"
                ></el-input-number>
              </el-form-item>

              <el-form-item label="俯仰角">
                <el-input-number
                  v-model="tileModelTool.ry"
                  @change="
                    (currentValue, oldValue) => {
                      updateMaxtrix(currentValue, oldValue, 2);
                    }
                  "
                  :min="-180"
                  :max="180"
                ></el-input-number>
              </el-form-item>
              <el-form-item label="旋转角">
                <el-input-number
                  v-model="tileModelTool.rx"
                  @change="
                    (currentValue, oldValue) => {
                      updateMaxtrix(currentValue, oldValue, 3);
                    }
                  "
                  :min="-180"
                  :max="180"
                ></el-input-number>
              </el-form-item>
            </el-form>
</template>



<script>
import { ref} from "vue";
export default {
    setup() {
    const tileModelTool = ref({
      longitude: 118.576311,
      latitude: 32.595694,
      height: 220.08, //修改高度
      rx: 0,
      ry: 0,
      rz: 0, //修改旋转
    });

const updateMaxtrix = (currentValue, oldValue, type) => {
      let number = currentValue - oldValue;
      let paramesVal = tileModelTool.value;
      let m1;


       var position = Cesium.Cartesian3.fromDegrees(paramesVal.longitude,
          paramesVal.latitude,
          paramesVal.height);
        var heading = Cesium.Math.toRadians(paramesVal.rz);
        var pitch = Cesium.Math.toRadians(paramesVal.ry);
        var roll = Cesium.Math.toRadians(paramesVal.rx);
        var headingPitchRoll = new Cesium.HeadingPitchRoll(heading, pitch, roll);
 
        var m = Cesium.Transforms.headingPitchRollToFixedFrame(position, headingPitchRoll, Cesium.Ellipsoid.WGS84, Cesium.Transforms.eastNorthUpToFixedFrame, new Cesium.Matrix4());
        console.log(m);
        _models.modelMatrix=m


    };

return {
    tileModelTool,
updateMaxtrix
}


}
}
</script>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值