| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- /**
- * @Author: Caven
- * @Date: 2020-08-30 17:10:33
- */
-
- const { Transform, Parse, PlotUtil } = DC
-
- const { Cesium } = DC.Namespace
-
- const HALF_PI = Math.PI / 2
-
- class FineArrowGraphics {
- constructor(options) {
- this._positions = options?.positions || []
- this.tailWidthFactor = 0.15
- this.neckWidthFactor = 0.2
- this.headWidthFactor = 0.25
- this.headAngle = Math.PI / 8.5
- this.neckAngle = Math.PI / 13
- }
-
- set positions(positions) {
- this._positions = positions
- }
-
- get positions() {
- return this._positions
- }
-
- get hierarchy() {
- return this._createHierarchy()
- }
-
- _createHierarchy() {
- let pnts = Parse.parsePolygonCoordToArray(
- Transform.transformCartesianArrayToWGS84Array(this._positions)
- )[0]
- let pnt1 = pnts[0]
- let pnt2 = pnts[1]
- let len = PlotUtil.getBaseLength(pnts)
- let tailWidth = len * this.tailWidthFactor
- let neckWidth = len * this.neckWidthFactor
- let headWidth = len * this.headWidthFactor
- let tailLeft = PlotUtil.getThirdPoint(pnt2, pnt1, HALF_PI, tailWidth, true)
- let tailRight = PlotUtil.getThirdPoint(
- pnt2,
- pnt1,
- HALF_PI,
- tailWidth,
- false
- )
- let headLeft = PlotUtil.getThirdPoint(
- pnt1,
- pnt2,
- this.headAngle,
- headWidth,
- false
- )
- let headRight = PlotUtil.getThirdPoint(
- pnt1,
- pnt2,
- this.headAngle,
- headWidth,
- true
- )
- let neckLeft = PlotUtil.getThirdPoint(
- pnt1,
- pnt2,
- this.neckAngle,
- neckWidth,
- false
- )
- let neckRight = PlotUtil.getThirdPoint(
- pnt1,
- pnt2,
- this.neckAngle,
- neckWidth,
- true
- )
- return new Cesium.PolygonHierarchy(
- Transform.transformWGS84ArrayToCartesianArray(
- Parse.parsePositions([
- tailLeft,
- neckLeft,
- headLeft,
- pnt2,
- headRight,
- neckRight,
- tailRight
- ])
- )
- )
- }
- }
-
- export default FineArrowGraphics
|