Commit d07cf1ae by lyc

修改了代码格式

parent c90d3136
var viewer;
var satelliteEntity var satelliteEntity
export function addViewTrack() { export function addViewTrack(viewer) {
const script = document.createElement('script'); var start = new Cesium.JulianDate.fromDate(new Date());//把js中的时间转换为儒略时间
script.src = 'https://cesium.com/downloads/cesiumjs/releases/1.99/Build/Cesium/Cesium.js';
script.onload = () => {
window.Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3Njg4ZWU5Yi1iZDhiLTRhYmUtOTRiYS04YjM5NmUwNjVmMDMiLCJpZCI6MjI3MzQ3LCJpYXQiOjE3MjA1MjA4Mjh9.E5XW4LnwgfVAaBC-znaYr61m4yK0-j2qEQhi9qwFFPE'
viewer = new window.Cesium.Viewer('cesiumContainer', {
infoBox: false,
});
var start = new Cesium.JulianDate.fromDate(new Date());//把js中的时间转换为儒略时间
start = Cesium.JulianDate.addHours(start, 8, new Cesium.JulianDate());//东八区时间 start = Cesium.JulianDate.addHours(start, 8, new Cesium.JulianDate());//东八区时间
// 结束时间 // 结束时间
var stop = Cesium.JulianDate.addSeconds(start, 360, new Cesium.JulianDate()); var stop = Cesium.JulianDate.addSeconds(start, 360, new Cesium.JulianDate());
//确保查看器处于预期的时间 //确保查看器处于预期的时间
viewer.clock.startTime = start.clone(); viewer.clock.startTime = start.clone();
viewer.clock.stopTime = stop.clone(); viewer.clock.stopTime = stop.clone();
...@@ -110,25 +102,12 @@ export function addViewTrack() { ...@@ -110,25 +102,12 @@ export function addViewTrack() {
satelliteEntity.position.setInterpolationOptions({ satelliteEntity.position.setInterpolationOptions({
interpolationDegree: 5, interpolationDegree: 5,
interpolationAlgorithm: Cesium.LagrangePolynomialApproximation interpolationAlgorithm: Cesium.LagrangePolynomialApproximation
}); })
// viewer.zoomTo(satelliteEntity)
// viewer.trackedEntity = satelliteEntity;
};
document.head.appendChild(script);
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = 'https://cesium.com/downloads/cesiumjs/releases/1.119/Build/Cesium/Widgets/widgets.css';
document.head.appendChild(link);
} }
export function viewTrack() { export function viewTrack(viewer) {
viewer.camera.flyTo({ viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(60, 0, 1000000.0) destination: Cesium.Cartesian3.fromDegrees(60, 0, 1000000.0)
}) })
viewer.trackedEntity = satelliteEntity; viewer.trackedEntity = satelliteEntity
} }
\ No newline at end of file
<template> <template>
<div id="cesiumContainer" class="cesium-container"> </div> <div id="cesiumContainer" class="cesium-container"> </div>
<button @click="viewTrack" class="btn-class">viewTrack</button> <button @click="viewTrack(viewer)" class="btn-class">viewTrack</button>
</template> </template>
<script setup> <script setup>
import { onMounted } from 'vue'; import { onMounted } from 'vue';
import { addViewTrack, viewTrack } from './function'; import { addViewTrack, viewTrack } from './function';
let viewer
onMounted(() => { onMounted(() => {
addViewTrack() const script = document.createElement('script');
script.src = 'https://cesium.com/downloads/cesiumjs/releases/1.99/Build/Cesium/Cesium.js';
script.onload = () => {
window.Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3Njg4ZWU5Yi1iZDhiLTRhYmUtOTRiYS04YjM5NmUwNjVmMDMiLCJpZCI6MjI3MzQ3LCJpYXQiOjE3MjA1MjA4Mjh9.E5XW4LnwgfVAaBC-znaYr61m4yK0-j2qEQhi9qwFFPE'
viewer = new window.Cesium.Viewer('cesiumContainer', {
infoBox: false,
});
addViewTrack(viewer)
};
document.head.appendChild(script);
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = 'https://cesium.com/downloads/cesiumjs/releases/1.119/Build/Cesium/Widgets/widgets.css';
document.head.appendChild(link);
}); });
</script> </script>
......
...@@ -31,7 +31,7 @@ onMounted(() => { ...@@ -31,7 +31,7 @@ onMounted(() => {
<style> <style>
.cesium-container { .cesium-container {
width: 100%; width: 100%;
height: 100vh; height: 100vh;
} }
</style> </style>
\ No newline at end of file
import { ref } from 'vue'; export function addDial(viewer,timetext) {
let viewer
export var bei = ref(1)
export var timetext = ref('')
export function addDial() {
const script = document.createElement('script');
script.src = 'https://cesium.com/downloads/cesiumjs/releases/1.99/Build/Cesium/Cesium.js';
script.onload = () => {
window.Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3Njg4ZWU5Yi1iZDhiLTRhYmUtOTRiYS04YjM5NmUwNjVmMDMiLCJpZCI6MjI3MzQ3LCJpYXQiOjE3MjA1MjA4Mjh9.E5XW4LnwgfVAaBC-znaYr61m4yK0-j2qEQhi9qwFFPE'
viewer = new window.Cesium.Viewer('cesiumContainer', {
animation: false,
baseLayerPicker: false,
fullscreenButton: false,
vrButton :false,
geocoder:false,
homeButton:false,
infoBox:false,
sceneModePicker:false,
selectionIndicator:false,
timeline:true,
navigationHelpButton:false,
});
// 格式化时间轴 // 格式化时间轴
viewer.timeline.makeLabel = function (date) { viewer.timeline.makeLabel = function (date) {
const julianDT = new Cesium.JulianDate(); const julianDT = new Cesium.JulianDate();
...@@ -30,46 +6,40 @@ export function addDial() { ...@@ -30,46 +6,40 @@ export function addDial() {
var gregorianDT = Cesium.JulianDate.toGregorianDate(julianDT); var gregorianDT = Cesium.JulianDate.toGregorianDate(julianDT);
let hour = gregorianDT.hour + ""; let hour = gregorianDT.hour + "";
let minute = gregorianDT.minute + ""; let minute = gregorianDT.minute + "";
let second = gregorianDT.second + ""; let second = gregorianDT.second + "";
timetext.value = `${gregorianDT.year}${gregorianDT.month}${gregorianDT.day}${hour.padStart(2, "0")}:${minute.padStart(2, "0")}:${second.padStart(2,"0")}` timetext = `${gregorianDT.year}${gregorianDT.month}${gregorianDT.day}${hour.padStart(2, "0")}:${minute.padStart(2, "0")}:${second.padStart(2,"0")}`
return `${gregorianDT.year}${gregorianDT.month}${gregorianDT.day}${hour.padStart(2, "0")}:${minute.padStart(2, "0")}:${second.padStart(2,"0")}`; return `${gregorianDT.year}${gregorianDT.month}${gregorianDT.day}${hour.padStart(2, "0")}:${minute.padStart(2, "0")}:${second.padStart(2,"0")}`;
}; };
}; };
document.head.appendChild(script);
const link = document.createElement('link'); export function forward(viewer) {
link.rel = 'stylesheet';
link.href = 'https://cesium.com/downloads/cesiumjs/releases/1.119/Build/Cesium/Widgets/widgets.css';
document.head.appendChild(link);
}
export function forward() {
let t = viewer.clockViewModel.multiplier; let t = viewer.clockViewModel.multiplier;
viewer.clockViewModel.multiplier = Math.abs(t); viewer.clockViewModel.multiplier = Math.abs(t);
viewer.clock.shouldAnimate = true;
} }
var flag = false; var flag = false;
export function start() { export function start(viewer) {
flag = !(flag); flag = !(flag);
if(flag==true) if(flag==true)
viewer.clock.shouldAnimate = true; viewer.clock.shouldAnimate = true;
else else
viewer.clock.shouldAnimate = false; viewer.clock.shouldAnimate = false;
} }
export function back() { export function back(viewer) {
let t = viewer.clockViewModel.multiplier; let t = viewer.clockViewModel.multiplier;
viewer.clockViewModel.multiplier = -Math.abs(t); viewer.clockViewModel.multiplier = -Math.abs(t);
viewer.clock.shouldAnimate = true;
} }
export function multiplier() { export function multiplier(viewer) {
viewer.clockViewModel.multiplier *= 2; viewer.clockViewModel.multiplier *= 2;
bei.value = viewer.clockViewModel.multiplier let q=viewer.clockViewModel.multiplier
return q
} }
export function divide() { export function divide(viewer,bei) {
viewer.clockViewModel.multiplier /= 2; viewer.clockViewModel.multiplier /= 2;
bei.value = viewer.clockViewModel.multiplier bei = viewer.clockViewModel.multiplier
} }
export function reset() { export function reset(viewer) {
viewer.clock.currentTime = viewer.clock.startTime; viewer.clock.currentTime = viewer.clock.startTime;
} }
\ No newline at end of file
...@@ -6,23 +6,49 @@ ...@@ -6,23 +6,49 @@
<div class="time"> <div class="time">
<img src="https://raw.githubusercontent.com/jinlinchao123/Cesium-assets/main/time.png" <img src="https://raw.githubusercontent.com/jinlinchao123/Cesium-assets/main/time.png"
style="width: 100%; height: 100%;"> style="width: 100%; height: 100%;">
<button class="button1" @click="forward"></button> <button class="button1" @click="forward(viewer)"></button>
<button class="button2" v-on:click="start"></button> <button class="button2" v-on:click="start(viewer)"></button>
<button class="button3" v-on:click="back"></button> <button class="button3" v-on:click="back(viewer)"></button>
<button class="button4" v-on:click="multiplier">×2</button> <button class="button4" v-on:click="qqq">X2</button>
<button class="button5" v-on:click="divide">×-2</button> <button class="button5" v-on:click="divide(viewer, bei)">X-2</button>
<button class="button6" v-on:click="reset"></button> <button class="button6" v-on:click="reset(viewer)"></button>
<p class="bei">{{ bei }}X</p> <p class="bei">X{{ bei }}</p>
<p class="time-text"> {{ timetext }}</p> <p class="time-text"> {{ timetext }}</p>
</div> </div>
</template> </template>
<script setup> <script setup>
import { onMounted,ref } from 'vue'; import { onMounted,ref, watch } from 'vue';
import { addDial, divide, multiplier, back, start, forward, reset } from './function'; import { addDial, divide, multiplier, back, start, forward, reset } from './function';
import bei from './function'; let viewer=ref();
import timetext from './function'; const bei = ref(1)
const timetext=ref('')
onMounted(() => { onMounted(() => {
addDial() const script = document.createElement('script');
script.src = 'https://cesium.com/downloads/cesiumjs/releases/1.99/Build/Cesium/Cesium.js';
script.onload = () => {
window.Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3Njg4ZWU5Yi1iZDhiLTRhYmUtOTRiYS04YjM5NmUwNjVmMDMiLCJpZCI6MjI3MzQ3LCJpYXQiOjE3MjA1MjA4Mjh9.E5XW4LnwgfVAaBC-znaYr61m4yK0-j2qEQhi9qwFFPE'
viewer = new window.Cesium.Viewer('cesiumContainer', {
animation: false,
baseLayerPicker: false,
fullscreenButton: false,
vrButton: false,
geocoder: false,
homeButton: false,
infoBox: false,
sceneModePicker: false,
selectionIndicator: false,
timeline: true,
navigationHelpButton: false,
});
addDial(viewer, timetext)
bei.value = multiplier(viewer)
};
document.head.appendChild(script);
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = 'https://cesium.com/downloads/cesiumjs/releases/1.119/Build/Cesium/Widgets/widgets.css';
document.head.appendChild(link);
}); });
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment