/** * 请求实体数据、创建实体 */ import * as DT from 'dt-sdk' import moment from 'moment' import { viewer, lodLayer } from '@/components/dt-scene/index.vue' import { getRealOrbitList, getEntityPosAndQua } from '@/api/scene' import { BEAM_TYPE } from '@/enum' import { debounce } from '@/utils' import { mapGetters, mapMutations } from 'vuex' let fontSize = document.getRootNode().documentElement.style.fontSize.replace('px', '') / 12 export default { mixins: [], data() { return { nextQuery: { // 下一次轨迹数据请求时间 preTime: '', nextTime: '', isQeury: false }, satelliteUpdateOptions: {}, stopWatchUpdate: false, stripeInfos: [], loadSatelliteComplete: false, callbackFunction: null, currentSatelliteData: undefined, toVisibleIds: [], destroySatelliteIds: [], yaTaiUnloadBeamIds: [4575, 4576, 4577, 4578, 4579, 11074, 11073, 11072], show2DBillboard: false, satelliteColors: {}, alwaysShowModel: false, autoUpdatePath: false, // 是否自动更新轨迹,解决一次请求多圈数据,跑到后面卫星和轨迹不对应问题 } }, computed: { ...mapGetters([ 'currentTime', 'multiplier', 'sceneMode', 'showBeam', 'showTrack', 'showSatelliteLabel', 'showStationLabel', ]) }, watch: { satelliteColors: { handler: function (nv) { console.log(nv, 88888); }, deep: true }, /** * 监听场景当前时间,更新地球上渲染物体的数据 * @author wangxueshen * @date 2021-11-24 * @param {any} time * @returns {any} */ currentTime(time) { if (this.stopWatchUpdate) { return } let currentTime = DT.Cesium.JulianDate.fromDate(new Date(time)) if (this.nextQuery.nextTime && !this.nextQuery.isQeury) { let nextQueryTime = DT.Cesium.JulianDate.fromDate( new Date(this.nextQuery.nextTime) ) let preTime = DT.Cesium.JulianDate.fromDate( new Date(this.nextQuery.preTime) ) if (this.multiplier > 0) { // 监听场景当前时间小于下一次请求时间时,并且下一次请求时间与当前时间差 小于 (速度 * 10)秒,发送请求下一时段数据 if ( DT.Cesium.JulianDate.lessThan(currentTime, nextQueryTime) && DT.Cesium.JulianDate.secondsDifference(nextQueryTime, currentTime) < 10 * Math.abs(this.multiplier) ) { if (!this.nextQuery.isQeury) { if (this.nextQuery.preTime !== this.nextQuery.nextTime) { this.nextQuery.isQeury = true // 请求时间 let queryTime = moment(this.nextQuery.nextTime) .subtract(10 * Math.abs(this.multiplier), 'seconds') .utc() .format('YYYY-MM-DDTHH:mm:ss') + 'Z' let newPreTime = queryTime // this.nextQuery.preTime = this.nextQuery.nextTime this.getEntityData({ sceneId: this.satelliteUpdateOptions.sceneId, satIds: this.satelliteUpdateOptions.satIds, checkedIds: this.visibleIds, startTime: queryTime, step: 60 * 10, callback: () => { this.nextQuery.preTime = newPreTime this.nextQuery.isQeury = false } }) } } } // (如果当前时间小于preTime 或者大于nextQueryTime)并且 当前时间与上一次请求时间差 大于 (速度 * 10) 秒 则需要更新数据 if ( DT.Cesium.JulianDate.greaterThan(currentTime, nextQueryTime) || DT.Cesium.JulianDate.lessThan(currentTime, preTime) ) { if (!this.nextQuery.isQeury) { this.nextQuery.isQeury = true // this.loading = true // 请求时间 // this.nextQuery.preTime = time this.getEntityData({ sceneId: this.satelliteUpdateOptions.sceneId, satIds: this.satelliteUpdateOptions.satIds, checkedIds: this.visibleIds, startTime: time, step: 60 * 10, callback: () => { // this.loading = false this.nextQuery.preTime = time this.nextQuery.isQeury = false }, }) } } } else { // 监听场景当前时间小于下一次请求时间时,并且下一次请求时间与当前时间差 小于 (速度 * 10)秒,发送请求下一时段数据 if ( DT.Cesium.JulianDate.greaterThan(currentTime, preTime) && DT.Cesium.JulianDate.secondsDifference(currentTime, preTime) < 10 * Math.abs(this.multiplier) ) { if (!this.nextQuery.isQeury) { if (this.nextQuery.preTime !== this.nextQuery.nextTime) { this.nextQuery.isQeury = true // 请求时间 let queryTime = moment(this.nextQuery.preTime) .add(10 * Math.abs(this.multiplier), 'seconds') .utc() .format('YYYY-MM-DDTHH:mm:ss') + 'Z' // this.nextQuery.nextTime = this.nextQuery.preTime let newNextTime = queryTime this.getEntityData({ sceneId: this.satelliteUpdateOptions.sceneId, satIds: this.satelliteUpdateOptions.satIds, checkedIds: this.visibleIds, endTime: queryTime, step: 60 * 10, callback: () => { this.nextQuery.nextTime = newNextTime this.nextQuery.isQeury = false } }) } } } // (如果当前时间小于preTime 或者大于nextQueryTime)并且 当前时间与上一次请求时间差 大于 (速度 * 10) 秒 则需要更新数据 if ( DT.Cesium.JulianDate.lessThan(currentTime, preTime) || (DT.Cesium.JulianDate.greaterThan(currentTime, nextQueryTime)) ) { if (!this.nextQuery.isQeury) { this.nextQuery.isQeury = true // 请求时间 // this.nextQuery.nextTime = time this.getEntityData({ sceneId: this.satelliteUpdateOptions.sceneId, satIds: this.satelliteUpdateOptions.satIds, checkedIds: this.visibleIds, endTime: time, step: 60 * 10, callback: () => { this.nextQuery.nextTime = time this.nextQuery.isQeury = false } }) } } } } }, /** * 监听场景模式变化 * @author wangxueshen * @date 2022-04-02 * @returns {any} */ sceneMode() { if (this.stopWatchUpdate) { return } // 请求时间 let queryTime = moment() .utc() .format('YYYY-MM-DDTHH:mm:ss') + 'Z' this.getEntityData({ sceneId: this.satelliteUpdateOptions.sceneId, satIds: this.satelliteUpdateOptions.satIds, checkedIds: this.visibleIds, startTime: queryTime, step: 60 * 10, callback: () => { this.nextQuery.preTime = queryTime this.nextQuery.isQeury = false } }) }, loadSatelliteComplete: { handler: function (nv) { if (nv && typeof this.callbackFunction === 'function') { this.callbackFunction() } } } }, mounted() { // 设置相机至中国区域 // viewer.cesiumViewer.camera.setView({ // destination: DT.Cesium.Cartesian3.fromDegrees(100, 40, 40000000) // }) // viewer.dataSourceDisplay._defaultDataSource.entities.add({ // id: 'risk-zone', // rectangle: { // coordinates: DT.Cesium.Rectangle.fromDegrees( // -180, // -90, // 180, // 90, // ), // height: 0, // material: DT.Cesium.Color.RED // }, // }); }, methods: { ...mapMutations('scene-control', [ 'SET_ANIMATE', ]), /** * 分批加载、更新实体 * @author wangxueshen * @date 2022-04-22 * @param {any} res 实体数据 * @param {any} checkedIds 创建时需要显示实体id * @param {any} per_load 单批加载实体数量 * @param {any} n * @returns {any} */ loadSatellitePerload(res, checkedIds, per_load, n, loadIds) { let keys = Object.keys(res) const loadArr = [] for (var i = 0; i < per_load; i++) { if (!keys[per_load * n + i]) break const key = keys[per_load * n + i] let data = res[key] if (!data || data.length === 0) { this.destroySatelliteIds.push(parseInt(key)) continue } if (loadIds.indexOf(parseInt(key)) === -1) continue let satellite = this.updateEntity(+key, data, checkedIds) // satellite.readyPromise的resolve标志着satellite准备完成 if (satellite) { loadArr.push(satellite.readyPromise) // loadArr.push(Promise.resolve(satellite.readyPromise)) } } Promise.all(loadArr).then(() => { if (keys[(n + 1) * per_load]) { this.loadSatellitePerload(res, checkedIds, per_load, n + 1, loadIds) } else { this.loadSatelliteComplete = true return } // if (!keys[(n + 1) * per_load]) { // this.loadSatelliteComplete = true // console.log('加载完毕') // console.timeEnd('satellite loading') // } }) }, /** * 创建 / 更新地面站 * @author wangxueshen * @date 2022-03-23 * @param {any} data * @returns {any} */ updateStation(data, visible = true) { let entity = lodLayer.getEntityById(data.staId) if (entity) { entity.position = DT.Cesium.Cartesian3.fromDegrees( data.longitude, data.latitude, data.altitude + 300 ) } else { // console.log('地面站颜色', data.staId) let station = new DT.Satellite({ id: 'station-' + data.staId, enabled: visible, show: visible, reference: DT.Cesium.ReferenceFrame.FIXED, modelConfig: { url: data.style.modelFile.fileUrl, // url: process.env.BASE_URL + 'data/models/test.glb', // minimumPixelSize: 64 }, billboardConfig: { image: data.style.iconFile.fileUrl, // disableDepthTestDistance: Number.POSITIVE_INFINITY, width: 24, height: 24 // url: process.env.BASE_URL + 'data/billboard64.gif', }, pointConfig: { color: DT.Cesium.Color.fromCssColorString( data.style.pointColor || '#f00' ), pixelSize: 6 }, labelConfig: { text: data.staName, font: `${fontSize}px Microsoft YaHei`, verticalOrigin: DT.Cesium.VerticalOrigin.CENTER, outlineColor: DT.Cesium.Color.BLACK, outlineWidth: 2, style: DT.Cesium.LabelStyle.FILL_AND_OUTLINE, pixelOffset: new DT.Cesium.Cartesian2(30, 0), distanceDisplayCondition: new DT.Cesium.DistanceDisplayCondition( 0, 10000000 ) }, // position: DT.Cesium.Cartesian3.fromDegrees(data.longitude, data.latitude, 1000) position: DT.Cesium.Cartesian3.fromDegrees( data.longitude, data.latitude, data.altitude + 300 ) }) // 添加椭圆 // let ellipse = new DT.EllipseEntity({ // semiMajorAxis: 1880000, // semiMinorAxis: 1880000, // height: 1000, // fill: false, // outline: true, // material: DT.Cesium.Color.GREEN.withAlpha(0.2), // outlineColor: DT.Cesium.Color.fromCssColorString( // 'rgb(255, 0, 255)' // ).withAlpha(1), // id: 'station-' + data.staId + '-ellipse', // enabled: false // }) // station.add(ellipse) lodLayer.add(station) // data.radarList.forEach(radar => { // /* // radar.detectionDistance // */ // viewer.entities.add({ // id: `station-${data.staId}-${radar.radarName}`, // position: DT.Cesium.Cartesian3.fromDegrees( // data.longitude, // data.latitude, // data.altitude // ), // ellipsoid: { // radii: new DT.Cesium.Cartesian3(radar.detectionDistance * 1000, radar.detectionDistance * 1000, radar.detectionDistance * 1000), // maximumCone: DT.Cesium.Math.PI_OVER_TWO, // material: DT.Cesium.Color.RED.withAlpha(0.2), // outline: true, // outlineColor: DT.Cesium.Color.RED // }, // }) // }) } }, /** * 获取地图需要渲染的,轨迹,卫星,波束 * @author wzw * @date 2021-12-13 * @param {any} option * @param {any} callback * @returns {any} */ getEntityData: debounce(function (options) { options.checkedIds = options.checkedIds || [] this.satelliteUpdateOptions = options this.callbackFunction = null this.loadSatelliteComplete = false let params = { sceneId: options.sceneId, satIds: options.satIds, step: options.step } let multiplier = JSON.parse(JSON.stringify(this.multiplier)) // 判断当前时前进还是后退 if (this.multiplier > 0 && options.startTime) { params.startTime = moment(options.startTime) .utc() .format('YYYY-MM-DDTHH:mm:ss') + 'Z' if (options.endTime) { params.endTime = moment(options.endTime).utc().format('YYYY-MM-DDTHH:mm:ss') + 'Z' } } if (this.multiplier < 0 && options.endTime) { params.endTime = moment(options.endTime) .utc() .format('YYYY-MM-DDTHH:mm:ss') + 'Z' if (options.startTime) { params.startTime = moment(options.startTime).utc().format('YYYY-MM-DDTHH:mm:ss') + 'Z' } } getEntityPosAndQua(params) .then(res => { let data = res.data.data if (!data) return this.currentSatelliteData = data let lengthArr = [] Object.keys(data).forEach(key => { if (data[key].length > 0) { lengthArr.push({ endTime: data[key][data[key].length - 1][0], startTime: data[key][0][0], length: data[key].length, name: key }) } }) // 分批加载 this.loadSatellitePerload( data, this.visibleIds, 300, 0, this.visibleIds ) if (multiplier > 0) { this.nextQuery.nextTime = lengthArr.sort( (a, b) => a.length - b.length )[0].endTime } else { this.nextQuery.preTime = lengthArr.sort( (a, b) => a.length - b.length )[0].startTime } // console.log(this.nextQuery.nextTime, '下次请求时间') // if (options.immediateCallback) { // options.immediateCallback() // 立即执行函数,不用等到卫星加载完毕 // } // 回调函数 if (options.callback) { this.callbackFunction = options.callback } else { this.nextQuery.isQeury = false } // if (this.mapUpdateCompleteCallback) { // this.mapUpdateCompleteCallback() // } }) .catch(e => { this.loadSatelliteComplete = true }) // getRealOrbitList({ sceneId: options.sceneId, startTime: options.startTime, step: options.step }).then(res => { // let data = res.data.data // let lengthArr = [] // Object.keys(data).forEach(key => { // if (data[key].length > 0) { // lengthArr.push({ // time: data[key][data[key].length - 1].time, // length: data[key].length, // name: key // }) // } // this.updateEntity(data[key], options.checkedIds) // }) // this.nextQuery.nextTime = lengthArr.sort((a, b) => a.length - b.length)[0].time // // this.loading = false // // if (viewer && speed) { // // viewer.cesiumViewer.clock.multiplier = speed // // console.log('速度还原'); // // } // if (options.callback) { // options.callback() // } else { // this.nextQuery.isQeury = false // } // if (this.mapUpdateCompleteCallback) { // this.mapUpdateCompleteCallback() // } // }) }, 200), /** * 加载、更新实体 * @author wangxueshen * @date 2022-03-09 * @param {any} satId * @param {any} data * @param {any} checkedIds * @returns {any} */ updateEntity(satId, data, checkedIds) { if (data.length === 0) return if (!this.isInited) { // 初始化渲染 this.isInited = true lodLayer.shouldUpdate = true } // 卫星实体是否已创建 let entity = lodLayer.getEntityById('satellite-' + satId) let satelliteConfig = this.sceneInfo.satelliteList.find( config => config.satId === satId ) if (!satelliteConfig) return // 卫星配置信息 if (entity) { // 先清空采样数据 let times = entity.sampledPositionProperty._property._times entity.sampledPositionProperty.removeSamples( new DT.Cesium.TimeInterval({ start: times[0], stop: times[times.length - 1] }) ) // 更新实体 // 更新卫星采样数据 data.forEach(item => { let time = DT.Cesium.JulianDate.fromDate(new Date(item[0])) let position = new DT.Cesium.Cartesian3(item[1], item[2], item[3]) entity.addPositionSample(time, position) }) entity.show = checkedIds.length > 0 ? checkedIds.includes(satId) : false entity.label.show = this.showSatelliteLabel // 重绘轨迹 entity.updateTrajectory( DT.Cesium.JulianDate.fromDate(new Date(data[0][0])) ) // 更新条带 if ( satelliteConfig.payloadList && satelliteConfig.payloadList.length > 0 ) { satelliteConfig.payloadList.forEach(payload => { // 载荷配置信息 payload.beamList && payload.beamList.forEach(beam => { let beamId = `beam-${BEAM_TYPE[beam.viewType]}-${beam.beamId}` if (beam.showTimeList && beam.showTimeList.length > 0) { let beamEntity = entity.getEntityById(beamId) if (beamEntity) { // 添加波束生命周期 beam.showTimeList.forEach(timeRange => { const startTime = DT.Cesium.JulianDate.fromDate( new Date(timeRange[0])) const endTime = DT.Cesium.JulianDate.fromDate( new Date(timeRange[1])) const ypr = JSON.parse(timeRange[2]) beamEntity.availability.push( new DT.Cesium.TimeInterval({ start: startTime, stop: endTime }) ) if (ypr) { beamEntity.addRotationSample(startTime, DT.Pointing.YPRToQuaternion( new DT.YPR(DT.Cesium.Math.toRadians(ypr[0]), DT.Cesium.Math.toRadians(ypr[1]), DT.Cesium.Math.toRadians(ypr[2])), new DT.Cesium.Quaternion() )) beamEntity.addRotationSample(endTime, DT.Pointing.YPRToQuaternion( new DT.YPR(DT.Cesium.Math.toRadians(ypr[0]), DT.Cesium.Math.toRadians(ypr[1]), DT.Cesium.Math.toRadians(ypr[2])), new DT.Cesium.Quaternion() )) // 重置姿态 beamEntity.addRotationSample(DT.Cesium.JulianDate.addSeconds(endTime, 1, new DT.Cesium.JulianDate()), DT.Pointing.YPRToQuaternion( new DT.YPR(DT.Cesium.Math.toRadians(0), DT.Cesium.Math.toRadians(0), DT.Cesium.Math.toRadians(0)), new DT.Cesium.Quaternion() )) } }) } } // 添加条带 if (beam.boundaryList && beam.boundaryList.length > 0) { let tempCopy = JSON.parse(JSON.stringify(beam.boundaryList)) tempCopy.forEach((stripe, i) => { for ( let i = 2; i <= stripe.boundaryCoordinate.length; i += 3 ) { stripe.boundaryCoordinate.splice(i, 0, 500) } let stripeEntity = entity.getEntityById( `${beamId}-${i}-stripe` ) if (stripeEntity) { // 添加条带生命周期 stripeEntity.availability.push( new DT.Cesium.TimeInterval({ start: DT.Cesium.JulianDate.fromDate( new Date(stripe.startTime) ), stop: DT.Cesium.JulianDate.fromDate( new Date(stripe.endTime) ) }) ) } else { this.stripeInfos.push({ parentId: 'satellite-' + satId, id: `${beamId}-${i}-stripe` }) stripeEntity = new DT.StripeEntity({ id: `${beamId}-${i}-stripe`, positions: DT.Cesium.Cartesian3.fromDegreesArrayHeights( stripe.boundaryCoordinate ), material: DT.Cesium.Color.fromCssColorString( satelliteConfig.satBasic.style.orbitColor || '#fff' ) }) // 添加条带生命周期 stripeEntity.availability.push( new DT.Cesium.TimeInterval({ start: DT.Cesium.JulianDate.fromDate( new Date(stripe.startTime) ), stop: DT.Cesium.JulianDate.fromDate( new Date(stripe.endTime) ) }) ) entity.add(stripeEntity) } }) } }) }) } return undefined } else { // 创建实体 let isEnable = checkedIds.length > 0 && checkedIds.includes(satId) let isBeamEnable = isEnable && this.showBeam let isPolylineEnable = isEnable && this.showTrack try { // let showModel = satelliteConfig?.satBasic?.orbitType && (satelliteConfig.satBasic.orbitType === 'IGSO' || satelliteConfig.satBasic.orbitType === 'GEO') let satellite = new DT.Satellite({ id: 'satellite-' + satId, enabled: checkedIds.length > 0 ? checkedIds.includes(satId) : false, // enabled: true, // alwaysShowModel: showModel, enableVelocityOrientAttach: true, alwaysShowModel: this.alwaysShowModel, show2DBillboard: false, reference: DT.Cesium.ReferenceFrame.INERTIAL, // reference: DT.Cesium.ReferenceFrame.FIXED, modelConfig: { // url: process.env.BASE_URL + 'model/ship/ship.gltf', url: satelliteConfig.satBasic.style.modelFile.fileUrl, // url: 'data/satellite/scene.gltf', minimumPixelSize: 64 }, billboardConfig: { image: satelliteConfig.satBasic.style.iconFile.fileUrl, width: 24, height: 24 // disableDepthTestDistance: Number.POSITIVE_INFINITY }, pointConfig: { color: DT.Cesium.Color.fromCssColorString( this.satelliteColors[satId] ? this.satelliteColors[satId] : satelliteConfig.satBasic.style.pointColor || '#f00' ), scaleByDistance: new DT.Cesium.NearFarScalar(1000, 4, 10000000, 1.2), pixelSize: 5 }, labelConfig: { text: satelliteConfig.satBasic.satName, font: `${fontSize}px Microsoft YaHei`, verticalOrigin: DT.Cesium.VerticalOrigin.CENTER, outlineColor: DT.Cesium.Color.BLACK, outlineWidth: 2, style: DT.Cesium.LabelStyle.FILL_AND_OUTLINE, pixelOffset: new DT.Cesium.Cartesian2(30, 0), // distanceDisplayCondition: showModel // ? new DT.Cesium.DistanceDisplayCondition(0, 10000000000) // : new DT.Cesium.DistanceDisplayCondition(0, 10000000) distanceDisplayCondition: new DT.Cesium.DistanceDisplayCondition(0, 10000000) }, // position: new DT.Cesium.Cartesian3(data[0][1], data[0][2], data[0][3]), pathOptions: { show: false, material: DT.Cesium.Color.fromCssColorString( satelliteConfig.satBasic.style.orbitColor || '#fff' ).withAlpha(0.2), width: satelliteConfig.satBasic.style.orbitWidth, mode: 0, leadTime: satelliteConfig.satBasic.period + 120, trailTime: satelliteConfig.satBasic.period + 120, resolution: this.sceneInfo.satelliteList.length <= 60 ? 1 : 100, autoUpdate: this.autoUpdatePath }, // alwaysShowModel: this.sceneInfo.satelliteList.length <= 60 ? true : false, // revolutionPeriod: satelliteConfig.satBasic.period + 600 revolutionPeriod: satelliteConfig.satBasic.period + 120 }) // satellite.model.imageBasedLightingFactor = new DT.Cesium.Cartesian2(0, 0) satellite.model.lightColor = new DT.Cesium.Cartesian3(10, 10, 10) satellite.model.luminanceAtZenith = 0.5 // satellite.model.shadows = DT.Cesium.ShadowMode.DISABLED satellite.faceSunNodes = [ { nodeName: 'TYB_1', faceVector: new DT.Cesium.Cartesian3(0, 1, 0) }, { nodeName: 'TYB_2', faceVector: new DT.Cesium.Cartesian3(0, 1, 0) } ] // 添加载荷波束 if ( satelliteConfig.payloadList && satelliteConfig.payloadList.length > 0 && !this.yaTaiUnloadBeamIds.includes(satId) ) { satelliteConfig.payloadList.forEach(payload => { // 载荷配置信息 payload.beamList && payload.beamList.forEach(beam => { // 波束配置信息 let beamId = `beam-${BEAM_TYPE[beam.viewType]}-${beam.beamId}` let beamEntity switch (beam.viewType) { // 圆锥波束 case 0: beamEntity = new DT.SimpleCone({ id: beamId, // 波束 id enabled: isBeamEnable, halfAngle: DT.Cesium.Math.toRadians( beam.roundHalfAngle ), // 波束半角 length: data[0][4] + 200000, // 波束高度 // length: 1000000, /* 材质可以使用动态材质,也可使用静态颜色 */ // material: new DT.WaveMaterial({ // 动态材质 // color: DT.Cesium.Color.SPRINGGREEN.withAlpha(0.8), // 波纹颜色 // baseColor: DT.Cesium.Color.SPRINGGREEN.withAlpha(0.2), // 基础颜色 // repeat: 30.0, // 波纹个数 // thickness: 0.5, // 波纹间隔 // speed: -2 // 动画速度:正数向上流动,负数向下流动 // }), // enableSurfaceEdge: true, material: DT.Cesium.Color.fromCssColorString( satelliteConfig.satBasic.style.orbitColor || '#fff' ).withAlpha(0.4) // 静态颜色 // material: DT.Cesium.Color.fromCssColorString( // '#4aa1fb' // ).withAlpha(0.2) // 静态颜色 }) break // 矩形波束 case 1: beamEntity = new DT.RectangularCone({ id: beamId, // 波束 id enabled: isBeamEnable, horizontalHalfAngle: DT.Cesium.Math.toRadians( beam.horizontalHalfAngle ), // 波束水平半角 verticalHalfAngle: DT.Cesium.Math.toRadians( beam.verticalHalfAngle ), // 波束垂直半角 length: data[0][4] + 200000, // 波束高度 // length: 1000000, /* 材质可以使用动态材质,也可使用静态颜色 */ // material: new DT.WaveMaterial({ // 动态材质 // color: DT.Cesium.Color.YELLOW.withAlpha(0.8), // 波纹颜色 // baseColor: DT.Cesium.Color.YELLOW.withAlpha(0.2), // 基础颜色 // repeat: 30.0, // 波纹个数 // thickness: 0.5, // 波纹间隔 // speed: -2 // 动画速度:正数向上流动,负数向下流动 // }, false), material: DT.Cesium.Color.fromCssColorString( satelliteConfig.satBasic.style.orbitColor || '#fff' ).withAlpha(0.4) // 静态颜色 // material: DT.Cesium.Color.fromCssColorString( // '#4aa1fb' // ).withAlpha(0.2) // 静态颜色 }) break } // 添加波束生命周期 if (beam.showTimeList && beam.showTimeList.length > 0) { beam.showTimeList.forEach(timeRange => { const startTime = DT.Cesium.JulianDate.fromDate( new Date(timeRange[0])) const endTime = DT.Cesium.JulianDate.fromDate( new Date(timeRange[1])) const ypr = JSON.parse(timeRange[2]) beamEntity.availability.push( new DT.Cesium.TimeInterval({ start: startTime, stop: endTime }) ) if (ypr) { beamEntity.addRotationSample(startTime, DT.Pointing.YPRToQuaternion( new DT.YPR(DT.Cesium.Math.toRadians(ypr[0]), DT.Cesium.Math.toRadians(ypr[1]), DT.Cesium.Math.toRadians(ypr[2])), new DT.Cesium.Quaternion() )) beamEntity.addRotationSample(endTime, DT.Pointing.YPRToQuaternion( new DT.YPR(DT.Cesium.Math.toRadians(ypr[0]), DT.Cesium.Math.toRadians(ypr[1]), DT.Cesium.Math.toRadians(ypr[2])), new DT.Cesium.Quaternion() )) // 重置姿态 beamEntity.addRotationSample(DT.Cesium.JulianDate.addSeconds(endTime, 1, new DT.Cesium.JulianDate()), DT.Pointing.YPRToQuaternion( new DT.YPR(DT.Cesium.Math.toRadians(0), DT.Cesium.Math.toRadians(0), DT.Cesium.Math.toRadians(0)), new DT.Cesium.Quaternion() )) } }) } beamEntity.pointing.ypr = new DT.YPR( DT.Cesium.Math.toRadians(beam.attitude.ypr[0]), DT.Cesium.Math.toRadians(beam.attitude.ypr[1]), DT.Cesium.Math.toRadians(beam.attitude.ypr[2]) ) satellite.add(beamEntity) // 添加条带 if (beam.boundaryList && beam.boundaryList.length > 0) { let tempCopy = JSON.parse(JSON.stringify(beam.boundaryList)) tempCopy.forEach((stripe, i) => { for ( let i = 2; i <= stripe.boundaryCoordinate.length; i += 3 ) { stripe.boundaryCoordinate.splice(i, 0, 500) } let stripeEntity = new DT.StripeEntity({ id: `${beamId}-${i}-stripe`, positions: DT.Cesium.Cartesian3.fromDegreesArrayHeights( stripe.boundaryCoordinate ), material: DT.Cesium.Color.fromCssColorString( satelliteConfig.satBasic.style.orbitColor || '#fff' ) }) // 添加条带生命周期 stripeEntity.availability.push( new DT.Cesium.TimeInterval({ start: DT.Cesium.JulianDate.fromDate( new Date(stripe.startTime) ), stop: DT.Cesium.JulianDate.fromDate( new Date(stripe.endTime) ) }) ) this.stripeInfos.push({ parentId: 'satellite-' + satId, id: `${beamId}-${i}-stripe` }) satellite.add(stripeEntity) }) } }) }) } // 更新卫星采样数据 data.forEach(item => { // 位置差值数据 - 笛卡尔 let time = DT.Cesium.JulianDate.fromDate(new Date(item[0])) // let position = DT.Cesium.Cartesian3.fromDegrees(item[7], item[8], item[9]); let position = new DT.Cesium.Cartesian3(item[1], item[2], item[3]) satellite.addPositionSample(time, position) // 姿态差值数据 - 四元数 // let qua = new DT.Cesium.Quaternion(item[10], item[11], item[12], item[13]) // satellite.addRotationSample(time, qua) // } }) lodLayer.add(satellite) return satellite } catch (error) { console.log(error) } } }, loadSatelliteUnadded(ids, toIds) { if (!this.currentSatelliteData) return let info = {} ids.forEach(item => { if (this.currentSatelliteData[item]) { info[item] = this.currentSatelliteData[item] } }) this.loadSatelliteComplete = false this.toVisibleIds = toIds this.callbackFunction = this.handleLoadAfter if (ids.length > 50) { this.loading = true this.loadingCount++ } this.loadSatellitePerload(info, [], 300, 0, ids) }, handleLoadAfter() { this.loading = false if (this.loadingCount > 0) { this.loadingCount-- } // this.loadingCount-- this.dynamicChangeEntityVisibleAfter(this.toVisibleIds) } } }