Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

TailedAttackArrowGraphics.js 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * @Author: Caven
  3. * @Date: 2020-08-30 17:26:34
  4. */
  5. import { Cesium } from '@dc-modules/namespace'
  6. import Parse from '@dc-modules/parse/Parse'
  7. import { Transform } from '@dc-modules/transform'
  8. import { PlotUtil } from '@dc-modules/utils'
  9. import AttackArrowGraphics from './AttackArrowGraphics'
  10. class TailedAttackArrowGraphics extends AttackArrowGraphics {
  11. constructor(options) {
  12. super(options)
  13. this.headHeightFactor = 0.18
  14. this.headWidthFactor = 0.3
  15. this.neckHeightFactor = 0.85
  16. this.neckWidthFactor = 0.15
  17. this.tailWidthFactor = 0.1
  18. this.headTailFactor = 0.8
  19. this.swallowTailFactor = 1
  20. }
  21. _createHierarchy() {
  22. let pnts = Parse.parsePolygonCoordToArray(
  23. Transform.transformCartesianArrayToWGS84Array(this._positions)
  24. )[0]
  25. let tailLeft = pnts[0]
  26. let tailRight = pnts[1]
  27. if (PlotUtil.isClockWise(pnts[0], pnts[1], pnts[2])) {
  28. tailLeft = pnts[1]
  29. tailRight = pnts[0]
  30. }
  31. let midTail = PlotUtil.mid(tailLeft, tailRight)
  32. let bonePnts = [midTail].concat(pnts.slice(2))
  33. let headPnts = this._getArrowHeadPoints(bonePnts, tailLeft, tailRight)
  34. let neckLeft = headPnts[0]
  35. let neckRight = headPnts[4]
  36. let tailWidth = PlotUtil.distance(tailLeft, tailRight)
  37. let allLen = PlotUtil.getBaseLength(bonePnts)
  38. let len = allLen * this.tailWidthFactor * this.swallowTailFactor
  39. let swallowTailPnt = PlotUtil.getThirdPoint(
  40. bonePnts[1],
  41. bonePnts[0],
  42. 0,
  43. len,
  44. true
  45. )
  46. let factor = tailWidth / allLen
  47. let bodyPnts = this._getArrowBodyPoints(
  48. bonePnts,
  49. neckLeft,
  50. neckRight,
  51. factor
  52. )
  53. let count = bodyPnts.length
  54. let leftPnts = [tailLeft].concat(bodyPnts.slice(0, count / 2))
  55. leftPnts.push(neckLeft)
  56. let rightPnts = [tailRight].concat(bodyPnts.slice(count / 2, count))
  57. rightPnts.push(neckRight)
  58. leftPnts = PlotUtil.getQBSplinePoints(leftPnts)
  59. rightPnts = PlotUtil.getQBSplinePoints(rightPnts)
  60. return new Cesium.PolygonHierarchy(
  61. Transform.transformWGS84ArrayToCartesianArray(
  62. Parse.parsePositions(
  63. leftPnts.concat(headPnts, rightPnts.reverse(), [
  64. swallowTailPnt,
  65. leftPnts[0]
  66. ])
  67. )
  68. )
  69. )
  70. }
  71. }
  72. export default TailedAttackArrowGraphics