| | |
| | | import configTool from "@/assets/js/tool/configTool"; |
| | | import store from "@/store"; |
| | | const palyTools = { |
| | | playIndex: 0, |
| | | isPlay: false, |
| | | data: null, |
| | | time: null, |
| | | depthTestAgainstTerrain: null, |
| | | Init(res) { |
| | | if (res.sourceType != "demoAnimation") return; |
| | | this.data = res.animationDatas; |
| | | this.playIndex = 0; |
| | | this.isPlay = true; |
| | | this.playStart(); |
| | | this.depthTestAgainstTerrain = Viewer.scene.globe.depthTestAgainstTerrain; |
| | | if (this.depthTestAgainstTerrain) { |
| | | Viewer.scene.globe.depthTestAgainstTerrain = false; |
| | | } |
| | | }, |
| | | stop() { |
| | | clearTimeout(this.time); |
| | | this.time = null; |
| | | this.playIndex = 0; |
| | | this.isPlay = false; |
| | | Viewer.scene.globe.depthTestAgainstTerrain = this.depthTestAgainstTerrain; |
| | | this.depthTestAgainstTerrain = null; |
| | | }, |
| | | playStart() { |
| | | if (this.playIndex > this.data.length - 1) { |
| | | this.stop(); |
| | | return; |
| | | } else if (!this.isPlay) { |
| | | return; |
| | | } |
| | | |
| | | let thisPlay = this.data[this.playIndex]; |
| | | |
| | | if (thisPlay.type === "位置") { |
| | | let position = thisPlay.view; |
| | | Viewer.camera.flyTo({ |
| | | destination: Cesium.Cartesian3.fromDegrees( |
| | | position.lon, |
| | | position.lat, |
| | | position.height |
| | | ), |
| | | orientation: { |
| | | heading: Cesium.Math.toRadians(position.heading), |
| | | pitch: Cesium.Math.toRadians(position.pitch), |
| | | roll: 0, |
| | | }, |
| | | }); |
| | | } else if (thisPlay.type === "操作") { |
| | | let show; |
| | | if (thisPlay.actionType === "显示对象") { |
| | | show = true; |
| | | } else if (thisPlay.actionType === "隐藏对象") { |
| | | show = false; |
| | | } |
| | | store.state.setAnimation = { |
| | | info: thisPlay.selectInfo, |
| | | show: show, |
| | | }; |
| | | } |
| | | let time = 0; |
| | | if (thisPlay.type === "位置") { |
| | | time = 3; |
| | | } |
| | | if (thisPlay.time) { |
| | | this.timeOut(() => { |
| | | // 定时 |
| | | this.playIndex++; |
| | | this.playStart(); |
| | | }, thisPlay.time + time); |
| | | } else { |
| | | this.timeOut(() => { |
| | | // 定时 |
| | | this.playIndex++; |
| | | this.playStart(); |
| | | }, time); |
| | | } |
| | | }, |
| | | timeOut(callback, time) { |
| | | clearTimeout(this.time); |
| | | this.time = setTimeout(callback, time * 1000); |
| | | }, |
| | | }; |
| | | export default palyTools; |
| | | import configTool from "@/assets/js/tool/configTool";
|
| | | import store from "@/store";
|
| | | const palyTools = {
|
| | | playIndex: 0,
|
| | | isPlay: false,
|
| | | data: null,
|
| | | time: null,
|
| | | depthTestAgainstTerrain: null,
|
| | | Init(res) {
|
| | | if (res.sourceType != "demoAnimation") return;
|
| | | this.data = res.animationDatas;
|
| | | this.playIndex = 0;
|
| | | this.isPlay = true;
|
| | | this.playStart();
|
| | | this.depthTestAgainstTerrain = Viewer.scene.globe.depthTestAgainstTerrain;
|
| | | if (this.depthTestAgainstTerrain) {
|
| | | Viewer.scene.globe.depthTestAgainstTerrain = false;
|
| | | }
|
| | | },
|
| | | stop() {
|
| | | clearTimeout(this.time);
|
| | | this.time = null;
|
| | | this.playIndex = 0;
|
| | | this.isPlay = false;
|
| | | Viewer.scene.globe.depthTestAgainstTerrain = this.depthTestAgainstTerrain;
|
| | | this.depthTestAgainstTerrain = null;
|
| | | },
|
| | | playStart() {
|
| | | if (this.playIndex > this.data.length - 1) {
|
| | | this.stop();
|
| | | return;
|
| | | } else if (!this.isPlay) {
|
| | | return;
|
| | | }
|
| | |
|
| | | let thisPlay = this.data[this.playIndex];
|
| | |
|
| | | if (thisPlay.type === "位置") {
|
| | | let position = thisPlay.view;
|
| | | Viewer.camera.flyTo({
|
| | | destination: Cesium.Cartesian3.fromDegrees(
|
| | | position.lon,
|
| | | position.lat,
|
| | | position.height
|
| | | ),
|
| | | orientation: {
|
| | | heading: Cesium.Math.toRadians(position.heading),
|
| | | pitch: Cesium.Math.toRadians(position.pitch),
|
| | | roll: 0,
|
| | | },
|
| | | });
|
| | | } else if (thisPlay.type === "操作") {
|
| | | let show;
|
| | | if (thisPlay.actionType === "显示对象") {
|
| | | show = true;
|
| | | } else if (thisPlay.actionType === "隐藏对象") {
|
| | | show = false;
|
| | | }
|
| | | store.state.setAnimation = {
|
| | | info: thisPlay.selectInfo,
|
| | | show: show,
|
| | | };
|
| | | }
|
| | | let time = 0;
|
| | | if (thisPlay.type === "位置") {
|
| | | time = 3;
|
| | | }
|
| | | if (thisPlay.time) {
|
| | | this.timeOut(() => {
|
| | | // 定时
|
| | | this.playIndex++;
|
| | | this.playStart();
|
| | | }, thisPlay.time + time);
|
| | | } else {
|
| | | this.timeOut(() => {
|
| | | // 定时
|
| | | this.playIndex++;
|
| | | this.playStart();
|
| | | }, time);
|
| | | }
|
| | | },
|
| | | timeOut(callback, time) {
|
| | | clearTimeout(this.time);
|
| | | this.time = setTimeout(callback, time * 1000);
|
| | | },
|
| | | };
|
| | | export default palyTools;
|