| | |
| | | :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="" |
| | | <el-upload class="upload-demo" action="" :auto-upload="false" accept=".glb" |
| | | :on-change="getFile" :limit="1"> |
| | | <div class="icon-bg-box icon-bg-box1"> |
| | | <el-icon ><PictureFilled /> </el-icon> |
| | |
| | | |
| | | <script> |
| | | import cesiumMapNoSelect from "@/components/common/cesiumMapNoSelect.vue"; |
| | | import { uploadFile} from "@/api/system/device" |
| | | export default { |
| | | name: 'modelManage', |
| | | components: { cesiumMapNoSelect }, |
| | |
| | | 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 { |
| | |
| | | // formData.append("type", 'pic'); |
| | | //上传图片的接口 |
| | | uploadFile(formData).then(res => { |
| | | this.$set(this.form, 'modelRoute', res.data.url) |
| | | this.$set(this.form, 'modelRoute', res.url) |
| | | }) |
| | | }, |
| | | handleSelectAddress(data) { |
| | |
| | | submitForm() { |
| | | this.$refs["form"].validate(valid => { |
| | | console.log(this.form) |
| | | // if (valid) { |
| | | // this.$api.save('work/tower/', 'id', Object.assign({}, this.form)).then(res => { |
| | | // this.form = {} |
| | | // this.$emit('on-submit') |
| | | // this.open = false |
| | | // }) |
| | | // } |
| | | |
| | | if (valid) { |
| | | this.$api.save('tower/model/', 'id', Object.assign({}, this.form)).then(res => { |
| | | this.form = {} |
| | | this.$emit('on-submit') |
| | | this.open = false |
| | | }) |
| | | } |
| | | }); |
| | | }, |
| | | 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() |