// 光锥体
|
<template>
|
<Popup
|
ref="pop"
|
:title="title"
|
:shadow="false"
|
:left="left"
|
width="310px"
|
:showBtn="false"
|
>
|
<el-form ref="form" :model="data" :rules="rules" label-width="70px">
|
<el-form-item label="半径:">
|
<el-input-number v-model="data.radius"></el-input-number>
|
</el-form-item>
|
<el-form-item label="长度:">
|
<el-input-number v-model="data.length"></el-input-number>
|
</el-form-item>
|
<el-form-item label="高度:">
|
<el-input-number v-model="data.height"></el-input-number>
|
</el-form-item>
|
<el-form-item label="颜色:">
|
<el-color-picker v-model="data.color"></el-color-picker>
|
</el-form-item>
|
<el-form-item label="绘制:">
|
<el-button type="info" size="mini" @click="draw">图上选点</el-button>
|
</el-form-item>
|
</el-form>
|
</Popup>
|
</template>
|
|
<script>
|
import Popup from "@tools/Popup";
|
import Bus from "@tools/Bus";
|
|
let handler;
|
export default {
|
name: "EffectCone",
|
components: {
|
Popup,
|
},
|
data() {
|
return {
|
title: "添加光锥体",
|
left: "calc(100% - 320px)",
|
data: {
|
color: "#80ccff",
|
radius: 100,
|
length: 600,
|
height: 1,
|
},
|
// 表单验证规则
|
rules: {},
|
};
|
},
|
mounted() {},
|
methods: {
|
// 关闭弹窗
|
close() {
|
handler && handler.destroy();
|
handler = undefined;
|
// 重置data值
|
Object.assign(this.$data, this.$options.data());
|
},
|
// 打开弹窗
|
open() {
|
this.close();
|
this.$refs.pop.open();
|
},
|
draw() {
|
this.$refs.form.validate((valid) => {
|
// 验证通过
|
if (valid) {
|
handler && handler.destroy();
|
handler = new Cesium.ScreenSpaceEventHandler(Viewer.scene.canvas);
|
this.$message("在场景内点击左键添加");
|
|
handler.setInputAction((event) => {
|
// 获取经纬度
|
let degrees = sgworld.Navigate.getMouseDegrees(event);
|
this.addEffectCone(degrees);
|
// 销毁点击事件
|
handler.destroy();
|
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
}
|
});
|
},
|
addEffectCone(degrees) {
|
let scale = this.data.radius / 50;
|
degrees.height = this.data.height;
|
// 特效圆-动态辐射波
|
let circle = sgworld.Creator.addDRWEffectCircle({
|
position: degrees,
|
radius: this.data.radius,
|
// radius: 50 * scale,
|
color: this.data.color,
|
});
|
|
// 特效圆锥
|
let cone = sgworld.Creator.addEffectCone({
|
position: degrees,
|
color: this.data.color,
|
radius: 3 * scale,
|
length: this.data.length,
|
});
|
|
// 添加到图层树
|
Bus.$emit("addOtherData", "特效", {
|
id: sgworld.Core.getuid(),
|
name: "新建光锥体",
|
sourceType: "effectCone",
|
position: degrees,
|
...this.data,
|
item: [cone, circle],
|
});
|
},
|
},
|
};
|
</script>
|
|
<style scoped lang="less">
|
.el-form {
|
margin-top: 20px;
|
margin-right: 10px;
|
width: 300px;
|
|
/deep/ .el-form-item__label {
|
color: #fff;
|
font-size: 18px;
|
}
|
}
|
</style>
|