| | |
| | | :value="dict.value"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="模型高度" prop="modelHeight"> |
| | | <el-input v-model="form.modelHeight" placeholder="请输入模型高度" /> |
| | | </el-form-item> |
| | | <el-form-item label="文件上传" prop="modelRoute"> |
| | | <el-upload class="upload-demo" action="" :auto-upload="false" accept=".glb" |
| | | :on-change="getFile" :limit="1"> |
| | |
| | | modelName: [ |
| | | { required: true, message: '请输入模型名称', trigger: 'blur' } |
| | | ], |
| | | deptId: [ |
| | | { required: true, message: '归属部门' } // trigger监听不到 使用@input单独校验vue-treeSelect表单项 |
| | | ] |
| | | modelHeight: [ |
| | | { required: true, message: '请输入模型名称', trigger: 'blur' } |
| | | ], |
| | | }, |
| | | // 部门数据 |
| | | deptOptions: null, |
| | |
| | | this.open = true |
| | | this.$nextTick(() => { |
| | | this.$refs.cesiumMapNoSelect.clearMap() |
| | | this.addModel() |
| | | this.addModel(this.form) |
| | | }) |
| | | }) |
| | | } else { |
| | |
| | | } |
| | | }); |
| | | }, |
| | | addModel(){ |
| | | addModel(row){ |
| | | console.log(window) |
| | | console.log(window.viewer) |
| | | // viewer.entities.add({ |
| | | // position: Cesium.Cartesian3.fromDegrees(0, 0, 0), |
| | | // model: { |
| | | // uri: "/Model/tower.glb", |
| | | // scale: 10000, |
| | | // minimumPixelSize: 50, |
| | | // }, |
| | | // }); |
| | | // const position = Cesium.Cartesian3.fromDegrees(139.745433, 35.658581, 0); |
| | | const position = Cesium.Cartesian3.fromDegrees(0, 0, 0); |
| | | |
| | | // 设置模型方向(可选) |
| | | const heading = Cesium.Math.toRadians(135); // 朝东南方向 |
| | | const heading = Cesium.Math.toRadians(0); // 朝东南方向 |
| | | const pitch = 0; |
| | | const roll = 0; |
| | | const orientation = Cesium.Transforms.headingPitchRollQuaternion( |
| | | position, |
| | | new Cesium.HeadingPitchRoll(heading, pitch, roll) |
| | | ); |
| | | if(row){ |
| | | const entity = viewer.entities.add({ |
| | | name: "MyModel", |
| | | position: position, |
| | | orientation: orientation, |
| | | model: { |
| | | uri: row.modelRoute, // 替换成你的模型路径 |
| | | }, |
| | | }); |
| | | console.log(entity) |
| | | |
| | | // 加载 glTF 模型 |
| | | const entity = viewer.entities.add({ |
| | | name: "MyModel", |
| | | position: position, |
| | | orientation: orientation, |
| | | model: { |
| | | uri: "/Model/tower.glb", // 替换成你的模型路径 |
| | | scale: 1000, |
| | | }, |
| | | }); |
| | | console.log(entity) |
| | | |
| | | // 飞行到模型位置 |
| | | viewer.flyTo(entity) |
| | | // 飞行到模型位置 |
| | | viewer.flyTo(entity) |
| | | } |
| | | }, |
| | | cancel() { |
| | | this.$refs.cesiumMapNoSelect.clearMap() |