UI主体组件

yfy
许宏杰 3 weeks ago
parent 677a4e0182
commit 4d6b9a743c

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

@ -0,0 +1,4 @@
@font-face {
font-family: "YouSheBiaoTiHei";
src: url("./font/YouSheBiaoTiHei.ttf");
}

@ -6,6 +6,7 @@
@import './btn.scss'; @import './btn.scss';
@import './ruoyi.scss'; @import './ruoyi.scss';
@import './marsMap.scss'; @import './marsMap.scss';
@import './font.css';
body { body {
width: 100%; width: 100%;

@ -1,12 +1,26 @@
<template> <template>
<div class="map-container" id="mapContainer"> <div class="map-container" id="mapContainer">
<slot></slot> <div class="top-main">
<div class="map-title">
<span> 云航低空研训基地飞行控制中心</span>
</div>
</div>
<div class="bottom-box"></div>
<div class="left-bg">
<slot name="left"></slot>
</div>
<div class="right-bg">
<slot name="right"></slot>
</div>
<div class="map-main">
<slot name="map"></slot>
</div>
</div> </div>
</template> </template>
<script setup> <script setup>
import { onMounted } from 'vue'; import { onMounted } from "vue";
import autofit from 'autofit.js' import autofit from "autofit.js";
onMounted(() => { onMounted(() => {
// //
autofit.init({ autofit.init({
@ -14,9 +28,8 @@
dh: 1080, dh: 1080,
dw: 1920, dw: 1920,
resize: true, resize: true,
}) });
}) });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -25,7 +38,67 @@
z-index: 100; z-index: 100;
height: 100%; height: 100%;
width: 100%; width: 100%;
.map-main {
height: 100%;
width: 100%;
}
.top-main {
position: fixed;
top: 0;
width: 100%;
z-index: 1000;
height: 120px;
background: url("@/assets/images/top-box.png");
background-size: 100% 100%;
}
.map-title {
width: 100%;
height: 100%;
background: url("@/assets/images/map-title.png") no-repeat top center;
background-size: 100% cover;
text-align: center;
span {
display: inline-block;
letter-spacing: 2px;
font-size: 40px;
color: #ffffff;
font-family: "YouSheBiaoTiHei";
text-shadow: 2px 6px 4px #0e426c;
}
}
.bottom-box {
position: absolute;
bottom: 0;
z-index: 200;
width: 100%;
height: 150px;
background: url("@/assets/images/bottom-box.png");
background-size: 100% 100%;
}
.left-bg {
position: absolute;
left: 0;
top: 0;
z-index: 200;
height: 100%;
width: 500px;
background: url("@/assets/images/left-bg.png");
background-size: 100% 100%;
box-sizing: border-box;
padding: 120px 47px 67px 47px;
}
.right-bg {
position: absolute;
right: 0;
top: 0;
z-index: 100;
height: 100%;
width: 500px;
background: url("@/assets/images/right-bg.png");
background-size: 100% 100%;
box-sizing: border-box;
padding: 120px 47px 67px 47px;
}
} }
</style> </style>

@ -17,15 +17,9 @@ let options = {
}, },
showSun: false, showSun: false,
showMoon: false, showMoon: false,
showSkyBox: false, showSkyBox: true,
showSkyAtmosphere: false, showSkyAtmosphere: true,
fog: false, fog: false,
// backgroundColor: "#363635", //
globe: {
baseColor: "#363635", //
showGroundAtmosphere: false,
enableLighting: false,
},
clock: { clock: {
currentTime: "2023-11-01 12:00:00", // currentTime: "2023-11-01 12:00:00", //
}, },
@ -62,8 +56,39 @@ let options = {
}, },
], ],
}; };
const params = reactive({
lat: 31.162232,
lng: 120.734077,
altitude: 3000,
heading: 0, //
pitch: 0, //
roll: 0, //
correction: 1,
speed: 800,
});
const EARTH_RADIUS = 6371000;
let isUav = true
const DIRECTION = {
UP: "w",
DOWN: "s",
LEFT: "a",
RIGHT: "d",
SPEED_UP: "q",
SPEED_DOWN: "e",
};
const keyboardMap = {
[DIRECTION.UP]: false,
[DIRECTION.DOWN]: false,
[DIRECTION.LEFT]: false,
[DIRECTION.RIGHT]: false,
[DIRECTION.SPEED_UP]: false,
[DIRECTION.SPEED_DOWN]: false,
};
let map = null; let map = null;
let list = [];
let uav = null
const mapLayer = {}; const mapLayer = {};
const mapLoad = (mapInstance) => { const mapLoad = (mapInstance) => {
map = mapInstance; map = mapInstance;
@ -73,24 +98,136 @@ const mapLoad = (mapInstance) => {
}); });
map.addLayer(mapLayer.markerLayer); map.addLayer(mapLayer.markerLayer);
// //
initUav() // initUav()
// // //
initRectangle(); // initRectangle();
initMarker(); // initMarker();
boostrapUav()
}; };
const boostrapUav = () => {
// initUav()
// onAddKeyboardListener()
// const renderer = () => {
// onAdjustParams();
// onAdjustAttitude();
// requestAnimationFrame(renderer);
// };
// renderer();
}
//
const onAddKeyboardListener = () => {
document.addEventListener("keydown", (e) => {
if (Object.keys(keyboardMap).includes(e.key)) {
keyboardMap[e.key] = true;
}
});
document.addEventListener("keyup", (e) => {
if (Object.keys(keyboardMap).includes(e.key)) {
keyboardMap[e.key] = false;
}
});
};
//
const onAdjustParams = () => {
if (keyboardMap[DIRECTION.SPEED_UP]) {
params.speed += 100;
}
if (keyboardMap[DIRECTION.SPEED_DOWN]) {
if (params.speed >= 500) {
params.speed -= 100;
}
}
//
if (keyboardMap[DIRECTION.UP] && params.pitch <= 0.3) {
params.pitch += 0.005;
if (params.pitch > 0) {
const { speed, pitch } = params;
const temp = (params.speed / 60 / 60 / 60) * 110;
//1110km
params.altitude += temp * Math.sin(pitch);
}
}
//
if (keyboardMap[DIRECTION.DOWN] && params.pitch >= -0.3) {
params.pitch -= 0.006;
if (params.pitch < 0) {
const { speed, pitch } = params;
//1110km
const temp = (params.speed / 60 / 60 / 60) * 110;
params.altitude += temp * Math.sin(pitch);
}
}
//
if (keyboardMap[DIRECTION.LEFT]) {
params.heading -= 0.115;
if (params.roll > -10) {
params.roll -= 0.115;
}
}
//
if (keyboardMap[DIRECTION.RIGHT]) {
params.heading += 0.115;
if (params.roll < 10) {
params.roll += 0.115;
}
}
const { heading, pitch, roll } = params;
const { abs, cos } = Math;
params.correction = abs(cos(heading) * cos(pitch));
if (abs(heading) < 0.001) params.heading = 0;
if (abs(roll) < 0.001) params.roll = 0;
if (abs(pitch) < 0.001) params.pitch = 0;
//
// if (params.heading > 0) params.heading -= 0.0025
// if (params.heading < 0) params.heading += 0.0025
if (params.roll > 0) params.roll -= 0.003;
if (params.roll < 0) params.roll += 0.003;
if (params.pitch < 0) params.pitch += 0.005;
if (params.pitch > 0) params.pitch -= 0.003;
};
// 姿/
const onAdjustAttitude = () => {
const temp = params.speed / 60 / 60 / 60 / 110;
params.lng += temp * Math.cos(params.heading);
params.lat -= temp * Math.sin(params.heading);
const { lng, lat, altitude, heading, pitch, roll } = params;
params.altitude += temp * Math.sin(pitch) * 110 * 1000 * 10;
const position = Cesium.Cartesian3.fromDegrees(lng, lat, altitude);
uav.model.setStyle({
heading,
pitch,
roll
});
uav.addTimePosition(position);
};
const initUav = () => { const initUav = () => {
let list = [] if (list.length == 0) {
PointJson.map(item=>{ PointJson.map((item) => {
list.push(item.wz.split(",").map(Number)) list.push(item.wz.split(",").map(Number));
}) });
const uav = new mars3d.graphic.Route({ }
uav = new mars3d.graphic.Route({
id: "uav", id: "uav",
name: "无人机模型", name: "无人机模型",
position: { position: {
type: "time", // type: "time", //
speed: 100, speed: 100,
list: list list: list,
}, },
model: { model: {
url: "https://data.mars3d.cn/gltf/mars/wrj.glb", url: "https://data.mars3d.cn/gltf/mars/wrj.glb",
@ -98,13 +235,15 @@ const initUav = ()=>{
minimumPixelSize: 0.1, minimumPixelSize: 0.1,
runAnimations: true, runAnimations: true,
mergeOrientation: true, mergeOrientation: true,
}, },
camera: { camera: {
type: "gs", type: "gs",
} },
}) });
mapLayer.markerLayer.addGraphic(uav); mapLayer.markerLayer.addGraphic(uav);
} };
const initRectangle = () => { const initRectangle = () => {
const graphic = new mars3d.graphic.RectanglePrimitive({ const graphic = new mars3d.graphic.RectanglePrimitive({
@ -124,7 +263,6 @@ const initRectangle = () => {
mapLayer.markerLayer.addGraphic(graphic); mapLayer.markerLayer.addGraphic(graphic);
}; };
/** /**
* 渲染所有点位 * 渲染所有点位
*/ */

@ -9,6 +9,6 @@
<style scoped> <style scoped>
.panel-left{ .panel-left{
left: 46px;
} }
</style> </style>

@ -1,11 +1,16 @@
<template> <template>
<div> <div>
<map-container> <map-container>
<!-- <panel-left></panel-left> <template #map>
<panel-right></panel-right> -->
<mars-map></mars-map> <mars-map></mars-map>
</template>
<template #left>
<panel-left></panel-left>
</template>
<template #right>
<panel-right></panel-right>
</template>
</map-container> </map-container>
</div> </div>
</template> </template>
@ -20,12 +25,8 @@ import {
<style lang="scss" scoped> <style lang="scss" scoped>
.panel-box { .panel-box {
position: absolute; height: 100%;
top: 50%; width: 100%;
z-index: 100;
transform: translateY(-50%);
height: calc(100% - 175px);
width: 390px;
background: url("../assets/images/panel-bg.png"); background: url("../assets/images/panel-bg.png");
background-size: 100% 100%; background-size: 100% 100%;
} }

Loading…
Cancel
Save