/**
|
* 工具栏-特效
|
*/
|
//流场
|
var flowFieldValue = 40;
|
//风场
|
var WindFarmValue = 40;
|
//流动线,流动墙
|
var TrailLine = [];
|
//链路
|
var linkData = [];
|
//扩散
|
var KS = [];
|
//雷达
|
var LD = [];
|
//清除
|
import Bus from "@tools/Bus";
|
import { refreshStyles } from "less";
|
var particleHandel;
|
export default {
|
methods: {
|
addDiffusionTotree(entity, position, maxRadius, color, type) {
|
let data = {
|
id: window.sgworld.Core.getuid(),
|
name: entity.treeobj.name,
|
sourceType: type,
|
item: entity,
|
position,
|
maxRadius,
|
color,
|
}
|
Bus.$emit("addOtherData", '特效', data);
|
},
|
//添加特效
|
addParticleEffectTotree(ParticleSystem, name, position) {
|
let data = {
|
id: window.sgworld.Core.getuid(),
|
name: name,
|
sourceType: 'ParticleEffect',
|
item: ParticleSystem,
|
position,
|
flyTo: [position.x, position.y, 200],
|
}
|
Bus.$emit("addOtherData", '特效', data);
|
},
|
// 特效左键点击事件
|
addEffectLeftClick(event, one = true) {
|
this.destroyLeftEvent()
|
|
particleHandel = sgworld.AttachEvent(
|
"OnLButtonClk",
|
(movement, degrees) => {
|
one && this.destroyLeftEvent()
|
event && typeof event === 'function' && event(movement, degrees)
|
}
|
);
|
particleHandel.setInputAction(event => {
|
tooltip.showAt(event.endPosition, '点击添加特效,右键取消')
|
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
particleHandel.setInputAction(event => {
|
this.destroyLeftEvent()
|
}, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
|
},
|
// 销毁特效事件
|
destroyLeftEvent() {
|
particleHandel && particleHandel.destroy()
|
particleHandel = undefined
|
|
tooltip.show(false)
|
},
|
//特效-烟
|
cigarette() {
|
let self = this;
|
this.addEffectLeftClick(function (movement, degrees) {
|
let smog = sgworld.Analysis.createParticleEffect(
|
"smog",
|
{
|
x: degrees.lon,
|
y: degrees.lat,
|
z: degrees.height,
|
},
|
{
|
translation: Cesium.Cartesian3.fromElements(0, 0, 0), //平移
|
},
|
);
|
self.addParticleEffectTotree(smog, "smog", {
|
x: degrees.lon,
|
y: degrees.lat,
|
z: degrees.height,
|
})
|
})
|
},
|
//特效-火
|
fire() {
|
let self = this;
|
this.addEffectLeftClick(function (movement, degrees) {
|
let fire = sgworld.Analysis.createParticleEffect(
|
"flame",
|
{
|
x: degrees.lon,
|
y: degrees.lat,
|
z: degrees.height,
|
},
|
{
|
translation: Cesium.Cartesian3.fromElements(0, 0, 0), //平移
|
}
|
);
|
self.addParticleEffectTotree(fire, "flame", {
|
x: degrees.lon,
|
y: degrees.lat,
|
z: degrees.height,
|
})
|
});
|
},
|
//特效-喷泉
|
fountain() {
|
let self = this;
|
this.addEffectLeftClick(function (movement, degrees) {
|
let fountain = sgworld.Analysis.createParticleEffect(
|
"fountain",
|
{
|
x: degrees.lon,
|
y: degrees.lat,
|
z: degrees.height,
|
},
|
{
|
translation: Cesium.Cartesian3.fromElements(0, 0, 0), //平移
|
}
|
);
|
self.addParticleEffectTotree(fountain, "fountain", {
|
x: degrees.lon,
|
y: degrees.lat,
|
z: degrees.height,
|
})
|
});
|
},
|
//特效-烟花
|
fireworks() {
|
let self = this;
|
this.addEffectLeftClick(function (movement, degrees) {
|
let fireworks = sgworld.Analysis.createParticleEffect(
|
"fireworks",
|
{
|
x: degrees.lon,
|
y: degrees.lat,
|
z: degrees.height,
|
},
|
{}
|
);
|
self.addParticleEffectTotree(fireworks, "fireworks", {
|
x: degrees.lon,
|
y: degrees.lat,
|
z: degrees.height,
|
});
|
});
|
},
|
//特效-流场
|
flowField(btn) {
|
btn.checked = !btn.checked;
|
if (btn.checked) {
|
sgworld.Navigate.Stop(); //取消飞行状态
|
sgworld.Navigate.flyToPointsInterest({ //跳转视角
|
destination: new Cesium.Cartesian3.fromDegrees(110, 32, 8000000)
|
});
|
window.liuchang = sgworld.Creator.createField({
|
type: "ocean",
|
upath: SmartEarthRootUrl + "Workers/field/data/MIT.0000000001_UVEL_1.dat",
|
vpath: SmartEarthRootUrl + "Workers/field/data/MIT.0000000001_VVEL_1.dat",
|
}, function () {
|
|
});
|
} else {
|
window.liuchang && window.liuchang.destroy();
|
window.liuchang = undefined;
|
}
|
},
|
//特效-风场
|
WindFarm(btn) {
|
btn.checked = !btn.checked;
|
if (btn.checked) {
|
sgworld.Navigate.Stop(); //取消飞行状态
|
sgworld.Navigate.flyToPointsInterest({ //跳转视角
|
destination: new Cesium.Cartesian3.fromDegrees(110, 32, 8000000)
|
});
|
window.fengchang = sgworld.Creator.createWindField(
|
window.SmartEarthRootUrl + "Workers/json/wind.json",
|
{
|
color: "random",
|
num: flowFieldValue * 15,
|
}
|
);
|
WindFarmValue = 0;
|
} else {
|
window.fengchang && window.fengchang.destroy();
|
window.fengchang = undefined;
|
WindFarmValue = 40;
|
}
|
},
|
//特效-流动线
|
FlowLine() {
|
sgworld.Creator.createSimpleGraphic(
|
"polyline",
|
{ clampToGround: true },
|
(entity) => {
|
if (entity) {
|
let positions = entity.polyline.positions.getValue()
|
let _TrailLine = sgworld.Creator.createTrailLine(
|
positions,
|
{
|
//time: 3000, //时间(可选)
|
width: 5, //线宽(可选)
|
color: "#0000ff", //线颜色(可选)
|
//url: 'http://183.162.245.49:82/05sdkdemo/src/static/image/TrailLine.png', //渐变图片链接(可选)
|
clampToGround: true, //是否贴地(可选)
|
}
|
);
|
sgworld.Creator.SimpleGraphic.remove(entity.id);
|
TrailLine.push(_TrailLine);
|
|
let data = {
|
id: _TrailLine.treeobj.id,
|
name: _TrailLine.treeobj.name,
|
sourceType: 'FlowField',
|
style: {
|
width: 5, //线宽(可选)
|
color: "#0000ff", //线颜色(可选)
|
clampToGround: true, //是否贴地(可选)
|
},
|
positions,
|
item: _TrailLine,
|
}
|
data.item.boundingSphere = Cesium.BoundingSphere.fromPoints(positions);
|
Bus.$emit("addOtherData", '特效', data);
|
}
|
}
|
);
|
},
|
//特效-流动墙
|
MobileWall() {
|
sgworld.Creator.createSimpleGraphic(
|
"polyline",
|
{ clampToGround: true },
|
(entity) => {
|
if (entity) {
|
let positions = entity.polyline.positions.getValue();
|
addWall(positions, [entity]);
|
sgworld.Creator.SimpleGraphic.remove(entity.id);
|
}
|
}
|
);
|
async function addWall(positions) {
|
let LineInterpolation = sgworld.Core.LineInterpolation(Viewer, {
|
positions: positions,
|
num: 50,
|
getHeight: true,
|
});
|
let min = LineInterpolation.height;
|
let max = min.map((item) => {
|
return item + 50;
|
});
|
|
let _TrailLine = sgworld.Creator.createTrailLineWall(
|
LineInterpolation.positions,
|
{
|
maximumHeights: max,
|
minimumHeights: Array(max.length).fill(0),
|
color: "#ffffff", //线颜色(可选)
|
// url: $('#sdkContainerifm')[0].contentWindow.SmartEarthRootUrl + "Workers/image/colors.png",
|
url: window.SmartEarthRootUrl + "Workers/image/colors.png",
|
}
|
);
|
TrailLine.push(_TrailLine);
|
let data = {
|
id: _TrailLine.treeobj.id,
|
name: _TrailLine.treeobj.name,
|
sourceType: 'MobileWall',
|
style: {
|
maximumHeights: max,
|
minimumHeights: Array(max.length).fill(0),
|
color: "#ffffff", //线颜色(可选)
|
url: window.SmartEarthRootUrl + "Workers/image/colors.png",
|
},
|
LineInterpolation,
|
item: _TrailLine,
|
}
|
data.item.boundingSphere = Cesium.BoundingSphere.fromPoints(positions);
|
Bus.$emit("addOtherData", '特效', data);
|
}
|
|
},
|
//特效-链路 有bug
|
link() {
|
let _linkData = sgworld.Creator.createLinkPros(
|
(entity) => {
|
let data = {
|
id: entity.id,
|
name: entity.name,
|
sourceType: 'link',
|
positions: entity.polyline.positions._value,
|
item: entity,
|
}
|
Bus.$emit("addOtherData", '特效', data);
|
}
|
);
|
linkData.push(_linkData);
|
},
|
// 光锥体
|
effectCone() {
|
this.$refs.EffectCone.open();
|
},
|
//特效圆
|
rotateEffectCircle() {
|
this.$refs.RotateEffectCircle.open()
|
},
|
//扩散围墙
|
effectCylinder() {
|
this.$refs.EffectCylinder.open()
|
},
|
//垂直飞线
|
flyingLine() {
|
this.$refs.FlyingLine.open()
|
},
|
//四面体
|
tetrahedron() {
|
this.$refs.Tetrahedron.open()
|
},
|
//特效-圆形扩散
|
CircularDiffusion() {
|
sgworld.Creator.createSimpleGraphic(
|
"circle",
|
{},
|
(entity) => {
|
let position = sgworld.Core.toDegrees(entity.position.getValue())
|
let maxRadius = entity.ellipse.semiMajorAxis.getValue()
|
sgworld.drawObj = undefined;
|
if (entity) {
|
let circle = sgworld.Analysis.createCircleScan(
|
position,
|
maxRadius,
|
"#00ff00",
|
3000,
|
true
|
);
|
sgworld.Creator.SimpleGraphic.remove(entity.id);
|
KS.push(circle);
|
this.addDiffusionTotree(circle, position, maxRadius, "#00ff00", "CircularDiffusion")
|
}
|
}
|
);
|
},
|
//特效-扇形扩散
|
FanDiffusion() {
|
sgworld.Command.execute(
|
1,
|
7,
|
{
|
fillColor: Cesium.Color.RED.withAlpha(0.7),
|
},
|
(entity, data) => {
|
Viewer.entities.remove(entity);
|
|
if (entity) {
|
let sxksData = sgworld.Analysis.createSectorScan(
|
data.position,
|
data.distance,
|
"#ff0000",
|
60,
|
data.angle - 30,
|
true,
|
4000,
|
true
|
);
|
KS.push(sxksData);
|
let faninfo = {
|
id: sxksData.treeobj.id,
|
name: sxksData.treeobj.name,
|
sourceType: "FanDiffusion",
|
item: sxksData,
|
position: data.position,
|
distance: data.distance,
|
angle: data.angle - 30,
|
}
|
Bus.$emit("addOtherData", '特效', faninfo);
|
}
|
}
|
);
|
},
|
//特效-扩散源
|
DiffusionSource() {
|
sgworld.Creator.createSimpleGraphic(
|
"circle",
|
{ color: "rgba(255,0,0,0.6)" },
|
(entity) => {
|
if (entity) {
|
let position = sgworld.Core.toDegrees(entity.position.getValue())
|
let maxRadius = entity.ellipse.semiMajorAxis.getValue()
|
let circle = sgworld.Analysis.createMultiCircleScan(
|
position,
|
maxRadius,
|
"#ff0000",
|
3000,
|
true
|
);
|
sgworld.Creator.SimpleGraphic.remove(entity.id);
|
KS.push(circle);
|
this.addDiffusionTotree(circle, position, maxRadius, "#ff0000", "DiffusionSource")
|
}
|
}
|
);
|
},
|
//特效-风险扩散模拟
|
RiskDiffusion() {
|
sgworld.Creator.createSimpleGraphic(
|
"circle",
|
{ color: "rgba(255,0,0,0.6)" },
|
(entity) => {
|
if (entity) {
|
let position = sgworld.Core.toDegrees(entity.position.getValue())
|
let maxRadius = entity.ellipse.semiMajorAxis.getValue()
|
let circle = sgworld.Analysis.createCircleScan(
|
position,
|
maxRadius,
|
"#ff0000",
|
3000,
|
true
|
);
|
sgworld.Creator.SimpleGraphic.remove(entity.id);
|
KS.push(circle);
|
this.addDiffusionTotree(circle, position, maxRadius, "#ff0000", "RiskDiffusion");
|
}
|
}
|
);
|
},
|
|
//特效-雷达扩散模拟
|
RadarMask() {
|
sgworld.Creator.createSimpleGraphic(
|
"circle",
|
{ color: "rgba(127,255,212,0.5)" },
|
(entity) => {
|
if (entity) {
|
let degrees = sgworld.Core.toDegrees(entity.position.getValue());
|
let position = [degrees.lon, degrees.lat, degrees.height];
|
let cylinder = {
|
radius: entity.ellipse.semiMajorAxis.getValue(), //半径
|
angle: 30, //扫描角度(可选)
|
speed: 5, //倍速(可选)
|
stackPartitions: 80, //横向网格数(可选)
|
slicePartitions: 80, //纵向网格数(可选)
|
//color: 'rgba(255,255,255,0.5)', //球颜色(可选)
|
//outlineColor: 'rgba(255,255,255,0.5)', //球边框线颜色(可选)
|
wallColor: "rgba(255,255,255,0)", //扫描墙颜色(可选)
|
//wallOutlineColor: 'rgba(255,0,0,0.5)', //扫描墙颜色(可选)
|
//surfaceColor: 'rgba(255,0,0,0.5)', //扫描夹角颜色(可选)
|
};
|
let ldData = sgworld.Creator.createRectangularSensor(
|
position,
|
cylinder
|
);
|
sgworld.Creator.SimpleGraphic.remove(entity.id);
|
LD.push(ldData);
|
let data = {
|
id: entity.id,
|
name: "雷达扩散模拟",
|
sourceType: "RadarMask",
|
item: ldData,
|
position,
|
cylinder,
|
}
|
Bus.$emit("addOtherData", '特效', data);
|
}
|
}
|
);
|
},
|
//特效-动态卫星正射
|
DynamicSatellite() {
|
this.addEffectLeftClick(function (movement, degrees) {
|
let position = [degrees.lon, degrees.lat, 700000];
|
let dtwxzsData = sgworld.Creator.createConeRadar(position, {
|
color: "#7b9ef7",
|
radius: 200000,
|
});
|
let weixin = sgworld.Creator.createModel(
|
position,
|
window.SmartEarthRootUrl + "Workers/Model/weixin.gltf",
|
{ scale: 15 },
|
"0",
|
"卫星"
|
);
|
LD.push(dtwxzsData, weixin);
|
let data = {
|
id: window.sgworld.Core.getuid(),
|
name: dtwxzsData.treeobj.name,
|
sourceType: 'DynamicSatellite',
|
item: {
|
weixin,
|
dtwxzsData,
|
},
|
position,
|
flyTo: position,
|
}
|
Bus.$emit("addOtherData", '特效', data);
|
});
|
},
|
//特效-清除
|
clearTX() {
|
// var type = ["fireworks", "fountain", "flame", "smog"];
|
// type.forEach((item) => {
|
// sgworld.Analysis.removeParticleEffect(item);
|
// });
|
// this.destroyLeftEvent()
|
|
// TrailLine.forEach((item) => {
|
// item.clear();
|
// });
|
// TrailLine = [];
|
|
// KS.forEach((item) => {
|
// item.remove();
|
// });
|
// KS = [];
|
|
// LD.forEach((item) => {
|
// item.deleteObject();
|
// });
|
// LD = [];
|
// linkData.forEach((item) => {
|
// Viewer.entities.remove(item.item);
|
// });
|
Bus.$emit("clearFirstParentNode", '特效');
|
this.$message.info("添加特效已全部清除");
|
},
|
}
|
}
|