|
@@ -388,102 +388,6 @@ export default {
|
|
|
Math.random().toFixed(3)*2000
|
|
Math.random().toFixed(3)*2000
|
|
|
);
|
|
);
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
- // 生成随机数
|
|
|
|
|
- randomNum(minNum, maxNum) {
|
|
|
|
|
- switch (arguments.length) {
|
|
|
|
|
- case 1:
|
|
|
|
|
- return parseInt(Math.random() * minNum + 1, 10);
|
|
|
|
|
- case 2:
|
|
|
|
|
- return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
|
|
|
|
|
- default:
|
|
|
|
|
- return 0;
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- //给模型上描边
|
|
|
|
|
- getWtStatue(code) {
|
|
|
|
|
- if (code === 1) {
|
|
|
|
|
- return "#fff";
|
|
|
|
|
- } else if (code === 2) {
|
|
|
|
|
- return "#1890ff";
|
|
|
|
|
- } else {
|
|
|
|
|
- return "#f25656";
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- //添加模型
|
|
|
|
|
- addModel(viewer, uri, name, lon, lat, scale, val) {
|
|
|
|
|
- const hpRoll = new Cesium.HeadingPitchRoll(90.0, 0.0, 0.0);
|
|
|
|
|
- const position = Cesium.Cartesian3.fromDegrees(lon, lat);
|
|
|
|
|
- const orientation = Cesium.Transforms.headingPitchRollQuaternion(
|
|
|
|
|
- position,
|
|
|
|
|
- hpRoll
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- const wtStatue = this.randomNum(1, 3);
|
|
|
|
|
- const statueColor = this.getWtStatue(wtStatue);
|
|
|
|
|
-
|
|
|
|
|
- const entity = viewer.entities.add({
|
|
|
|
|
- name, // 模型名称
|
|
|
|
|
- position, // 模型位置
|
|
|
|
|
- orientation, // 模型朝向
|
|
|
|
|
- animation: false,
|
|
|
|
|
- model: {
|
|
|
|
|
- uri,
|
|
|
|
|
- scale,
|
|
|
|
|
- // 模型贴地
|
|
|
|
|
- heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
|
|
|
- silhouetteSize: 2,
|
|
|
|
|
- silhouetteColor: Cesium.Color.fromCssColorString(statueColor),
|
|
|
|
|
- runAnimations: wtStatue === 3 ? false : true,
|
|
|
|
|
- },
|
|
|
|
|
- //添加标签
|
|
|
|
|
- label: {
|
|
|
|
|
- text: val ? val.name : name, // 标签文字
|
|
|
|
|
- font: "14px sans-serif", // 字体
|
|
|
|
|
- fillColor: Cesium.Color.fromBytes(255, 255, 255), // 填充颜色
|
|
|
|
|
- outlineColor: Cesium.Color.BLACK, // 描边颜色
|
|
|
|
|
- outlineWidth: 2, // 描边宽度
|
|
|
|
|
- style: Cesium.LabelStyle.FILL_AND_OUTLINE, // 填充+描边
|
|
|
|
|
- verticalOrigin: Cesium.VerticalOrigin.BOTTOM, // 文本在模型上方
|
|
|
|
|
- horizontalOrigin: Cesium.HorizontalOrigin.CENTER, // 水平居中
|
|
|
|
|
- eyeOffset: new Cesium.Cartesian3(-100, 1100, 5), // 向上 15 米
|
|
|
|
|
- translucencyByDistance: new Cesium.NearFarScalar(
|
|
|
|
|
- 1.0e6,
|
|
|
|
|
- 1.0,
|
|
|
|
|
- 6.0e6,
|
|
|
|
|
- 0.0
|
|
|
|
|
- ),
|
|
|
|
|
- },
|
|
|
|
|
- });
|
|
|
|
|
- let that = this;
|
|
|
|
|
- // 创建事件处理器
|
|
|
|
|
- const handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
|
|
|
|
|
- // handler.setInputAction(function(click) {
|
|
|
|
|
- // const picked = viewer.scene.pick(click.position);
|
|
|
|
|
- // if (picked && picked.id === entity) {
|
|
|
|
|
- // console.log('你点击了标签或模型!', entity);
|
|
|
|
|
- // console.log('标签或模型数据!', val);
|
|
|
|
|
- // // alert('你点击了: ' + entity.label.text.getValue());
|
|
|
|
|
- // // this.$refs.comModelDialog.init(val)
|
|
|
|
|
- // if (name !== '光伏') {
|
|
|
|
|
- // that.showcomModelDia = true
|
|
|
|
|
- // that.modelVal = val
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
|
|
|
- handler.setInputAction(function (movement) {
|
|
|
|
|
- var position = movement.position;
|
|
|
|
|
- var pickedObject = viewer.scene.pick(position);
|
|
|
|
|
- if (pickedObject && pickedObject.id === entity) {
|
|
|
|
|
- console.log("你点击了标签或模型!", entity);
|
|
|
|
|
- console.log("标签或模型数据!", val);
|
|
|
|
|
- that.modelVal = val;
|
|
|
|
|
- // 找到实体,显示包含实体信息的弹框
|
|
|
|
|
- that.showRightClickPopup(position, val);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
|
|
|
|
|
- },
|
|
|
|
|
//添加svg或png贴图
|
|
//添加svg或png贴图
|
|
|
addSvg(viewer, uri, lon, lat, val, index) {
|
|
addSvg(viewer, uri, lon, lat, val, index) {
|
|
|
let that = this;
|
|
let that = this;
|
|
@@ -501,11 +405,12 @@ export default {
|
|
|
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
|
},
|
|
},
|
|
|
label: {
|
|
label: {
|
|
|
- text: val.name ? val.name : val.plantname,
|
|
|
|
|
|
|
+ // text: val.name ? val.name : val.plantname,
|
|
|
|
|
+ text: `${val.name}\n风速: 10m/s\n状态: 测试`,
|
|
|
font: '14px sans-serif',
|
|
font: '14px sans-serif',
|
|
|
fillColor: Cesium.Color.fromBytes(255, 255, 255),
|
|
fillColor: Cesium.Color.fromBytes(255, 255, 255),
|
|
|
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
|
- pixelOffset: val.name === 'F10号风机' ? new Cesium.Cartesian2(40, -20) : new Cesium.Cartesian2(0, 0)
|
|
|
|
|
|
|
+ pixelOffset: val.name === 'F10号风机' ? new Cesium.Cartesian2(50, -20) : new Cesium.Cartesian2(0, 20)
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
// 创建事件处理器
|
|
// 创建事件处理器
|