Cesium中卫星探测效果实现

1.本示例使用的是Flowm/cesium-sensor-volumes插件实现的探测效果

首先我们将插件下载后在js文件最上方引入cesium,如下图所示

然后直接可以在本项目中全局访问:CesiumSensorVolumes,该类中有许多探测效果形状,这里我们使用的是RectangularSensorGraphics,具体使用如下代码:


const addSateliteSensor = satelliteId => {
  const satelliteEntity = viewer.entities.getById(satelliteId)
  const sensorPosition = satelliteEntity.position.getValue()
  const sensorOrientation = Cesium.Transforms.headingPitchRollQuaternion(sensorPosition, new Cesium.HeadingPitchRoll(0, Cesium.Math.toRadians(180), 0))
  const sensorEntityOption = {
    name: 'sensor',
    id: 'sensor',
    // 传感器位置与卫星绑定
    position: new Cesium.CallbackProperty((time, result) => {
      let sourpos = satelliteEntity.position.getValue(time)
      return sourpos
    }, false),
    orientation: sensorOrientation,
    // 传感器体积配置
    rectangularSensor: new CesiumSensorVolumes.RectangularSensorGraphics({})
  }
  const sensorEntity = viewer.entities.add(sensorEntityOption)
  sensorEntity.rectangularSensor.xHalfAngle = Cesium.Math.toRadians(20)
  sensorEntity.rectangularSensor.yHalfAngle = Cesium.Math.toRadians(20)
  sensorEntity.rectangularSensor.radius = new Cesium.CallbackProperty((time, result) => {
    let sourpos = satelliteEntity.position.getValue(time)
    let height = Cesium.Ellipsoid.WGS84.cartesianToCartographic(sourpos).height * 3
    return height
  }, false)
  sensorEntity.rectangularSensor.showIntersection = true
  sensorEntity.rectangularSensor.intersectionColor = Cesium.Color.fromAlpha(Cesium.Color.YELLOW, 0.6)
  sensorEntity.rectangularSensor.intersectionWidth = 1
  sensorEntity.rectangularSensor.lateralSurfaceMaterial = new Cesium.ColorMaterialProperty(Cesium.Color.CYAN.withAlpha(0.18))
}

注意事项:

        1.position、orientation、rectangularSensor必须配置,否则无效果

        2.rectangularSensor字段必须先创建完entity实体后再单独配置rectangularSensor的属性,如果直接在new CesiumSensorVolumes.RectangularSensorGraphics({})构造函数中配置不会生效

效果图如下:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值