feat:实现通讯波跟随两点,待完善监听和关闭等其他逻辑
This commit is contained in:
parent
01758f3bbd
commit
a1bf52118e
@ -102,13 +102,13 @@ export class Beam {
|
|||||||
this.topEntity = opt.topEntity
|
this.topEntity = opt.topEntity
|
||||||
this.bottomEntity = opt.bottomEntity
|
this.bottomEntity = opt.bottomEntity
|
||||||
this.color = opt.color || '#00dcff82'
|
this.color = opt.color || '#00dcff82'
|
||||||
this.topRadius = opt.topRadius || 0
|
this.topRadius = opt.topRadius || 100
|
||||||
this.bottomRadius = opt.bottomRadius || 10000
|
this.bottomRadius = opt.bottomRadius || 200000
|
||||||
this.duration = opt.duration || 2000
|
this.duration = opt.duration || 3000
|
||||||
this.repeat = opt.repeat || 160
|
this.repeat = opt.repeat || 160
|
||||||
|
|
||||||
this.centerPoint = null
|
this.centerPoint = null
|
||||||
this.distance = null
|
this.distance = 0
|
||||||
this.beamEntity = null
|
this.beamEntity = null
|
||||||
|
|
||||||
this._listener = null
|
this._listener = null
|
||||||
@ -118,13 +118,10 @@ export class Beam {
|
|||||||
const cylinder = viewer.entities.add({
|
const cylinder = viewer.entities.add({
|
||||||
// name: 'Red cone',
|
// name: 'Red cone',
|
||||||
position: this.centerPoint,
|
position: this.centerPoint,
|
||||||
// orientation: null,
|
|
||||||
cylinder: {
|
cylinder: {
|
||||||
topRadius: 0,
|
topRadius: this.topRadius,
|
||||||
bottomRadius: 10000,
|
bottomRadius: this.bottomRadius,
|
||||||
length: this.distance,
|
length: this.distance,
|
||||||
topSurface: true, //新增参数,控制顶部是否渲染
|
|
||||||
bottomSurface: true, //新增参数,控制底部是否渲染
|
|
||||||
material: new Cesium.BeamPrimitiveMaterialProperty({
|
material: new Cesium.BeamPrimitiveMaterialProperty({
|
||||||
color: Cesium.Color.fromCssColorString(this.color),
|
color: Cesium.Color.fromCssColorString(this.color),
|
||||||
thickness: 0.2,
|
thickness: 0.2,
|
||||||
@ -135,43 +132,46 @@ export class Beam {
|
|||||||
})
|
})
|
||||||
this.beamEntity = cylinder
|
this.beamEntity = cylinder
|
||||||
|
|
||||||
|
// const that = this
|
||||||
this._listener = (scene, time) => {
|
this._listener = (scene, time) => {
|
||||||
if (!this.beamEntity) {
|
if (!this.beamEntity) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let topPosition = Cesium.Property.getValueOrUndefined(
|
let topPosition = Cesium.Property.getValueOrUndefined(
|
||||||
this.topEntity.position,
|
this.topEntity.position,
|
||||||
time,
|
time
|
||||||
new Cesium.Cartesian3()
|
|
||||||
)
|
)
|
||||||
let bottomPosition = this.bottomEntity.position
|
if (!topPosition) {
|
||||||
console.log(bottomPosition, 'bottomPosition')
|
return
|
||||||
|
}
|
||||||
|
// console.log(topPosition, 'topPosition')
|
||||||
|
let bottomPosition = this.bottomEntity.position._value
|
||||||
|
// console.log(bottomPosition, 'bottomPosition')
|
||||||
this.centerPoint = this._getCenterPoint(topPosition, bottomPosition)
|
this.centerPoint = this._getCenterPoint(topPosition, bottomPosition)
|
||||||
console.log(this.centerPoint, 'centerPoint')
|
// console.log(this.centerPoint, 'centerPoint')
|
||||||
this.beamEntity.position = this.centerPoint
|
this.beamEntity.position = this.centerPoint
|
||||||
this.distance = this._getDistance(topPosition, bottomPosition)
|
this.distance = this._getDistance(topPosition, bottomPosition)
|
||||||
this.beamEntity.cylinder.length = this.distance
|
this.beamEntity.cylinder.length = this.distance
|
||||||
|
|
||||||
console.log(this.distance)
|
const orientation = this._getOrientation(bottomPosition, topPosition)
|
||||||
const orientation = this._getOrientation(topPosition, bottomPosition)
|
|
||||||
|
|
||||||
this.beamEntity.orientation = orientation
|
this.beamEntity.orientation = orientation
|
||||||
|
console.log('1')
|
||||||
|
// throw new Error('TODO: Beam.js:26 Uncaught Error: TODO: Beam.js:26')
|
||||||
}
|
}
|
||||||
|
|
||||||
viewer.scene.preRender.addEventListener(this._listener)
|
// viewer.scene.preRender.addEventListener(this._listener)
|
||||||
|
setInterval(() => {
|
||||||
|
this._listener(viewer.scene, viewer.clock.currentTime)
|
||||||
|
}, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
_getCenterPoint(t, b) {
|
_getCenterPoint(t, b) {
|
||||||
this.centerPoint = Cesium.Cartesian3.lerp(
|
return Cesium.Cartesian3.lerp(t, b, 0.5, new Cesium.Cartesian3())
|
||||||
t,
|
|
||||||
b,
|
|
||||||
0.5,
|
|
||||||
new Cesium.Cartesian3()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_getDistance(t, b) {
|
_getDistance(t, b) {
|
||||||
this.distance = Cesium.Cartesian3.distance(t, b)
|
return Cesium.Cartesian3.distance(t, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
_getOrientation(t, b) {
|
_getOrientation(t, b) {
|
||||||
|
@ -141,7 +141,7 @@ function createSatelliteCommunicationPayload(satId: string) {
|
|||||||
console.log(mbId, 'mbId')
|
console.log(mbId, 'mbId')
|
||||||
if (mubiaoMap.has(mbId)) {
|
if (mubiaoMap.has(mbId)) {
|
||||||
const beam = new Beam({
|
const beam = new Beam({
|
||||||
topEntity: satelliteMap.get(satId),
|
topEntity: satelliteMap.get(satId).entity,
|
||||||
bottomEntity: mubiaoMap.get(mbId),
|
bottomEntity: mubiaoMap.get(mbId),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user