radar.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * @Description: 雷达扫描效果(参考开源代码)
  3. * @Version: 1.0
  4. * @Author: Julian
  5. * @Date: 2022-03-04 20:02:48
  6. * @LastEditors: Julian
  7. * @LastEditTime: 2022-03-05 15:26:47
  8. */
  9. class Radar {
  10. constructor(options) {
  11. // this._definitionChanged = new Cesium.Event();
  12. // this._color = undefined;
  13. // this._speed = undefined;
  14. // this.color = options.color;
  15. // this.speed = options.speed;
  16. let that = this;
  17. this._viewer = options.viewer;
  18. this._position = options.position;
  19. this._num = options.num;
  20. this._maxAngle = options.maxAngle;
  21. this._entity = this._viewer.entities.add({
  22. position: that._position, //Cesium.Cartesian3
  23. orientation: new Cesium.CallbackProperty(() => {
  24. that._num += 0.3;
  25. if (that._num >= that._maxAngle) that._num = 0;
  26. return Cesium.Transforms.headingPitchRollQuaternion(
  27. that._entity.position.getValue(Cesium),
  28. new Cesium.HeadingPitchRoll((that._num * Math.PI) / 180, 0, 0)
  29. );
  30. }, false),
  31. ellipsoid: {
  32. radii: new Cesium.Cartesian3(100000.0, 100000.00, 2000.0), // 扇形半径
  33. innerRadii: new Cesium.Cartesian3(1.0, 1.0, 1.0), // 内半径
  34. minimumClock: Cesium.Math.toRadians(-10),
  35. maximumClock: Cesium.Math.toRadians(10),
  36. minimumCone: Cesium.Math.toRadians(90), // 上下偏角 可以都设置为90
  37. maximumCone: Cesium.Math.toRadians(90),
  38. material: Cesium.Color.GREEN.withAlpha(0.5),
  39. outline: true,
  40. outlineColor: Cesium.Color.GREEN.withAlpha(.8),
  41. heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, //RELATIVE_TO_GROUND CLAMP_TO_GROUND
  42. },
  43. });
  44. return this._entity
  45. };
  46. }