mirror of
				https://github.com/ethan-zf/cesium-plot-js.git
				synced 2025-11-04 01:04:18 +00:00 
			
		
		
		
	add growth animation
This commit is contained in:
		
							parent
							
								
									b234fca7dd
								
							
						
					
					
						commit
						6d45edd800
					
				@ -13,6 +13,7 @@ export default class AssaultDirection extends FineArrow {
 | 
				
			|||||||
  headWidthFactor: number;
 | 
					  headWidthFactor: number;
 | 
				
			||||||
  headAngle: number;
 | 
					  headAngle: number;
 | 
				
			||||||
  neckAngle: number;
 | 
					  neckAngle: number;
 | 
				
			||||||
 | 
					  minPointsForShape: number;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  constructor(cesium: any, viewer: any, style?: PolygonStyle) {
 | 
					  constructor(cesium: any, viewer: any, style?: PolygonStyle) {
 | 
				
			||||||
    super(cesium, viewer, style);
 | 
					    super(cesium, viewer, style);
 | 
				
			||||||
@ -22,10 +23,11 @@ export default class AssaultDirection extends FineArrow {
 | 
				
			|||||||
    this.headWidthFactor = 0.13;
 | 
					    this.headWidthFactor = 0.13;
 | 
				
			||||||
    this.headAngle = Math.PI / 4;
 | 
					    this.headAngle = Math.PI / 4;
 | 
				
			||||||
    this.neckAngle = Math.PI * 0.17741;
 | 
					    this.neckAngle = Math.PI * 0.17741;
 | 
				
			||||||
 | 
					    this.minPointsForShape = 2;
 | 
				
			||||||
    this.setState('drawing');
 | 
					    this.setState('drawing');
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  createPolygon(positions: Cartesian3[]) {
 | 
					  createGraphic(positions: Cartesian3[]) {
 | 
				
			||||||
    const [p1, p2] = positions.map(this.cartesianToLnglat);
 | 
					    const [p1, p2] = positions.map(this.cartesianToLnglat);
 | 
				
			||||||
    const len = Utils.getBaseLength([p1, p2]) * 1.5;
 | 
					    const len = Utils.getBaseLength([p1, p2]) * 1.5;
 | 
				
			||||||
    const tailWidth = len * this.tailWidthFactor;
 | 
					    const tailWidth = len * this.tailWidthFactor;
 | 
				
			||||||
 | 
				
			|||||||
@ -11,6 +11,7 @@ export default class AttackArrow extends Base {
 | 
				
			|||||||
  neckHeightFactor: number;
 | 
					  neckHeightFactor: number;
 | 
				
			||||||
  neckWidthFactor: number;
 | 
					  neckWidthFactor: number;
 | 
				
			||||||
  headTailFactor: number;
 | 
					  headTailFactor: number;
 | 
				
			||||||
 | 
					  minPointsForShape: number;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  constructor(cesium: any, viewer: any, style?: PolygonStyle) {
 | 
					  constructor(cesium: any, viewer: any, style?: PolygonStyle) {
 | 
				
			||||||
    super(cesium, viewer, style);
 | 
					    super(cesium, viewer, style);
 | 
				
			||||||
@ -20,6 +21,7 @@ export default class AttackArrow extends Base {
 | 
				
			|||||||
    this.neckHeightFactor = 0.85;
 | 
					    this.neckHeightFactor = 0.85;
 | 
				
			||||||
    this.neckWidthFactor = 0.15;
 | 
					    this.neckWidthFactor = 0.15;
 | 
				
			||||||
    this.headTailFactor = 0.8;
 | 
					    this.headTailFactor = 0.8;
 | 
				
			||||||
 | 
					    this.minPointsForShape = 3;
 | 
				
			||||||
    this.setState('drawing');
 | 
					    this.setState('drawing');
 | 
				
			||||||
    this.onDoubleClick();
 | 
					    this.onDoubleClick();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -50,7 +52,7 @@ export default class AttackArrow extends Base {
 | 
				
			|||||||
    if (tempPoints.length === 2) {
 | 
					    if (tempPoints.length === 2) {
 | 
				
			||||||
      this.addFirstLineOfTheArrow();
 | 
					      this.addFirstLineOfTheArrow();
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      const geometryPoints = this.createPolygon(tempPoints);
 | 
					      const geometryPoints = this.createGraphic(tempPoints);
 | 
				
			||||||
      this.setGeometryPoints(geometryPoints);
 | 
					      this.setGeometryPoints(geometryPoints);
 | 
				
			||||||
      this.drawPolygon();
 | 
					      this.drawPolygon();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -59,7 +61,7 @@ export default class AttackArrow extends Base {
 | 
				
			|||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Generate geometric shapes based on key points.
 | 
					   * Generate geometric shapes based on key points.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  createPolygon(positions: Cartesian3[]): Cartesian3[] {
 | 
					  createGraphic(positions: Cartesian3[]): Cartesian3[] {
 | 
				
			||||||
    const lnglatPoints = positions.map((pnt) => {
 | 
					    const lnglatPoints = positions.map((pnt) => {
 | 
				
			||||||
      return this.cartesianToLnglat(pnt);
 | 
					      return this.cartesianToLnglat(pnt);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
@ -143,7 +145,7 @@ export default class AttackArrow extends Base {
 | 
				
			|||||||
   */
 | 
					   */
 | 
				
			||||||
  updateDraggingPoint(cartesian: Cartesian3, index: number) {
 | 
					  updateDraggingPoint(cartesian: Cartesian3, index: number) {
 | 
				
			||||||
    this.points[index] = cartesian;
 | 
					    this.points[index] = cartesian;
 | 
				
			||||||
    const geometryPoints = this.createPolygon(this.points);
 | 
					    const geometryPoints = this.createGraphic(this.points);
 | 
				
			||||||
    this.setGeometryPoints(geometryPoints);
 | 
					    this.setGeometryPoints(geometryPoints);
 | 
				
			||||||
    this.drawPolygon();
 | 
					    this.drawPolygon();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
@ -49,8 +49,8 @@ export default class CurvedArrow extends Base {
 | 
				
			|||||||
    const distance = Utils.MathDistance(pnt1, pnt2);
 | 
					    const distance = Utils.MathDistance(pnt1, pnt2);
 | 
				
			||||||
    let len = distance / this.arrowLengthScale;
 | 
					    let len = distance / this.arrowLengthScale;
 | 
				
			||||||
    len = len > this.maxArrowLength ? this.maxArrowLength : len;
 | 
					    len = len > this.maxArrowLength ? this.maxArrowLength : len;
 | 
				
			||||||
    const leftPnt = Utils.getThirdPoint(pnt1, pnt2, Math.PI / 6, len, false);
 | 
					    const leftPnt = Utils.getThirdPoint(pnt1, pnt2, Math.PI / 6, len / 3, false);
 | 
				
			||||||
    const rightPnt = Utils.getThirdPoint(pnt1, pnt2, Math.PI / 6, len, true);
 | 
					    const rightPnt = Utils.getThirdPoint(pnt1, pnt2, Math.PI / 6, len / 3, true);
 | 
				
			||||||
    const points = [...pnt1, ...pnt2, ...leftPnt, ...pnt2, ...rightPnt];
 | 
					    const points = [...pnt1, ...pnt2, ...leftPnt, ...pnt2, ...rightPnt];
 | 
				
			||||||
    const cartesianPoints = this.cesium.Cartesian3.fromDegreesArray(points);
 | 
					    const cartesianPoints = this.cesium.Cartesian3.fromDegreesArray(points);
 | 
				
			||||||
    return cartesianPoints;
 | 
					    return cartesianPoints;
 | 
				
			||||||
@ -86,8 +86,8 @@ export default class CurvedArrow extends Base {
 | 
				
			|||||||
    const distance = Utils.wholeDistance(lnglatPoints);
 | 
					    const distance = Utils.wholeDistance(lnglatPoints);
 | 
				
			||||||
    let len = distance / this.arrowLengthScale;
 | 
					    let len = distance / this.arrowLengthScale;
 | 
				
			||||||
    len = len > this.maxArrowLength ? this.maxArrowLength : len;
 | 
					    len = len > this.maxArrowLength ? this.maxArrowLength : len;
 | 
				
			||||||
    const leftPnt = Utils.getThirdPoint(pnt1, pnt2, Math.PI / 6, len, false);
 | 
					    const leftPnt = Utils.getThirdPoint(pnt1, pnt2, Math.PI / 6, len / 3, false);
 | 
				
			||||||
    const rightPnt = Utils.getThirdPoint(pnt1, pnt2, Math.PI / 6, len, true);
 | 
					    const rightPnt = Utils.getThirdPoint(pnt1, pnt2, Math.PI / 6, len / 3, true);
 | 
				
			||||||
    const temp = [].concat(...curvePoints);
 | 
					    const temp = [].concat(...curvePoints);
 | 
				
			||||||
    const points = [...temp, ...leftPnt, ...pnt2, ...rightPnt];
 | 
					    const points = [...temp, ...leftPnt, ...pnt2, ...rightPnt];
 | 
				
			||||||
    const cartesianPoints = this.cesium.Cartesian3.fromDegreesArray(points);
 | 
					    const cartesianPoints = this.cesium.Cartesian3.fromDegreesArray(points);
 | 
				
			||||||
 | 
				
			|||||||
@ -13,6 +13,7 @@ export default class FineArrow extends Base {
 | 
				
			|||||||
  headWidthFactor: number;
 | 
					  headWidthFactor: number;
 | 
				
			||||||
  headAngle: number;
 | 
					  headAngle: number;
 | 
				
			||||||
  neckAngle: number;
 | 
					  neckAngle: number;
 | 
				
			||||||
 | 
					  minPointsForShape: number;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  constructor(cesium: any, viewer: any, style?: PolygonStyle) {
 | 
					  constructor(cesium: any, viewer: any, style?: PolygonStyle) {
 | 
				
			||||||
    super(cesium, viewer, style);
 | 
					    super(cesium, viewer, style);
 | 
				
			||||||
@ -22,6 +23,7 @@ export default class FineArrow extends Base {
 | 
				
			|||||||
    this.headWidthFactor = 0.25;
 | 
					    this.headWidthFactor = 0.25;
 | 
				
			||||||
    this.headAngle = Math.PI / 8.5;
 | 
					    this.headAngle = Math.PI / 8.5;
 | 
				
			||||||
    this.neckAngle = Math.PI / 13;
 | 
					    this.neckAngle = Math.PI / 13;
 | 
				
			||||||
 | 
					    this.minPointsForShape = 2;
 | 
				
			||||||
    this.setState('drawing');
 | 
					    this.setState('drawing');
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -38,7 +40,7 @@ export default class FineArrow extends Base {
 | 
				
			|||||||
      this.onMouseMove();
 | 
					      this.onMouseMove();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (this.points.length === 2) {
 | 
					    if (this.points.length === 2) {
 | 
				
			||||||
      const geometryPoints = this.createPolygon(this.points);
 | 
					      const geometryPoints = this.createGraphic(this.points);
 | 
				
			||||||
      this.setGeometryPoints(geometryPoints);
 | 
					      this.setGeometryPoints(geometryPoints);
 | 
				
			||||||
      this.drawPolygon();
 | 
					      this.drawPolygon();
 | 
				
			||||||
      this.finishDrawing();
 | 
					      this.finishDrawing();
 | 
				
			||||||
@ -50,7 +52,7 @@ export default class FineArrow extends Base {
 | 
				
			|||||||
   */
 | 
					   */
 | 
				
			||||||
  updateMovingPoint(cartesian: Cartesian3) {
 | 
					  updateMovingPoint(cartesian: Cartesian3) {
 | 
				
			||||||
    const tempPoints = [...this.points, cartesian];
 | 
					    const tempPoints = [...this.points, cartesian];
 | 
				
			||||||
    const geometryPoints = this.createPolygon(tempPoints);
 | 
					    const geometryPoints = this.createGraphic(tempPoints);
 | 
				
			||||||
    this.setGeometryPoints(geometryPoints);
 | 
					    this.setGeometryPoints(geometryPoints);
 | 
				
			||||||
    this.drawPolygon();
 | 
					    this.drawPolygon();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -60,7 +62,7 @@ export default class FineArrow extends Base {
 | 
				
			|||||||
   */
 | 
					   */
 | 
				
			||||||
  updateDraggingPoint(cartesian: Cartesian3, index: number) {
 | 
					  updateDraggingPoint(cartesian: Cartesian3, index: number) {
 | 
				
			||||||
    this.points[index] = cartesian;
 | 
					    this.points[index] = cartesian;
 | 
				
			||||||
    const geometryPoints = this.createPolygon(this.points);
 | 
					    const geometryPoints = this.createGraphic(this.points);
 | 
				
			||||||
    this.setGeometryPoints(geometryPoints);
 | 
					    this.setGeometryPoints(geometryPoints);
 | 
				
			||||||
    this.drawPolygon();
 | 
					    this.drawPolygon();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -68,7 +70,7 @@ export default class FineArrow extends Base {
 | 
				
			|||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Generate geometric shapes based on key points.
 | 
					   * Generate geometric shapes based on key points.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  createPolygon(positions: Cartesian3[]) {
 | 
					  createGraphic(positions: Cartesian3[]) {
 | 
				
			||||||
    const [p1, p2] = positions.map(this.cartesianToLnglat);
 | 
					    const [p1, p2] = positions.map(this.cartesianToLnglat);
 | 
				
			||||||
    const len = Utils.getBaseLength([p1, p2]);
 | 
					    const len = Utils.getBaseLength([p1, p2]);
 | 
				
			||||||
    const tailWidth = len * this.tailWidthFactor;
 | 
					    const tailWidth = len * this.tailWidthFactor;
 | 
				
			||||||
 | 
				
			|||||||
@ -20,6 +20,7 @@ export default class SquadCombat extends AttackArrow {
 | 
				
			|||||||
    this.neckHeightFactor = 0.85;
 | 
					    this.neckHeightFactor = 0.85;
 | 
				
			||||||
    this.neckWidthFactor = 0.15;
 | 
					    this.neckWidthFactor = 0.15;
 | 
				
			||||||
    this.tailWidthFactor = 0.1;
 | 
					    this.tailWidthFactor = 0.1;
 | 
				
			||||||
 | 
					    this.minPointsForShape = 2;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
@ -43,7 +44,7 @@ export default class SquadCombat extends AttackArrow {
 | 
				
			|||||||
    if (tempPoints.length < 2) {
 | 
					    if (tempPoints.length < 2) {
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      const geometryPoints = this.createPolygon(tempPoints);
 | 
					      const geometryPoints = this.createGraphic(tempPoints);
 | 
				
			||||||
      this.setGeometryPoints(geometryPoints);
 | 
					      this.setGeometryPoints(geometryPoints);
 | 
				
			||||||
      this.drawPolygon();
 | 
					      this.drawPolygon();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -52,7 +53,7 @@ export default class SquadCombat extends AttackArrow {
 | 
				
			|||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Generate geometric shapes based on key points.
 | 
					   * Generate geometric shapes based on key points.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  createPolygon(positions: Cartesian3[]): Cartesian3[] {
 | 
					  createGraphic(positions: Cartesian3[]): Cartesian3[] {
 | 
				
			||||||
    const lnglatPoints = positions.map((pnt) => {
 | 
					    const lnglatPoints = positions.map((pnt) => {
 | 
				
			||||||
      return this.cartesianToLnglat(pnt);
 | 
					      return this.cartesianToLnglat(pnt);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
				
			|||||||
@ -8,10 +8,12 @@ export default class StraightArrow extends Base {
 | 
				
			|||||||
  points: Cartesian3[] = [];
 | 
					  points: Cartesian3[] = [];
 | 
				
			||||||
  arrowLengthScale: number = 5;
 | 
					  arrowLengthScale: number = 5;
 | 
				
			||||||
  maxArrowLength: number = 3000000;
 | 
					  maxArrowLength: number = 3000000;
 | 
				
			||||||
 | 
					  minPointsForShape: number;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  constructor(cesium: any, viewer: any, style?: LineStyle) {
 | 
					  constructor(cesium: any, viewer: any, style?: LineStyle) {
 | 
				
			||||||
    super(cesium, viewer, style);
 | 
					    super(cesium, viewer, style);
 | 
				
			||||||
    this.cesium = cesium;
 | 
					    this.cesium = cesium;
 | 
				
			||||||
 | 
					    this.minPointsForShape = 2;
 | 
				
			||||||
    this.setState('drawing');
 | 
					    this.setState('drawing');
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -28,7 +30,7 @@ export default class StraightArrow extends Base {
 | 
				
			|||||||
      this.onMouseMove();
 | 
					      this.onMouseMove();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (this.points.length === 2) {
 | 
					    if (this.points.length === 2) {
 | 
				
			||||||
      const geometryPoints = this.createLine(this.points);
 | 
					      const geometryPoints = this.createGraphic(this.points);
 | 
				
			||||||
      this.setGeometryPoints(geometryPoints);
 | 
					      this.setGeometryPoints(geometryPoints);
 | 
				
			||||||
      this.drawLine();
 | 
					      this.drawLine();
 | 
				
			||||||
      this.finishDrawing();
 | 
					      this.finishDrawing();
 | 
				
			||||||
@ -40,7 +42,7 @@ export default class StraightArrow extends Base {
 | 
				
			|||||||
   */
 | 
					   */
 | 
				
			||||||
  updateMovingPoint(cartesian: Cartesian3) {
 | 
					  updateMovingPoint(cartesian: Cartesian3) {
 | 
				
			||||||
    const tempPoints = [...this.points, cartesian];
 | 
					    const tempPoints = [...this.points, cartesian];
 | 
				
			||||||
    const geometryPoints = this.createLine(tempPoints);
 | 
					    const geometryPoints = this.createGraphic(tempPoints);
 | 
				
			||||||
    this.setGeometryPoints(geometryPoints);
 | 
					    this.setGeometryPoints(geometryPoints);
 | 
				
			||||||
    this.drawLine();
 | 
					    this.drawLine();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -50,7 +52,7 @@ export default class StraightArrow extends Base {
 | 
				
			|||||||
   */
 | 
					   */
 | 
				
			||||||
  updateDraggingPoint(cartesian: Cartesian3, index: number) {
 | 
					  updateDraggingPoint(cartesian: Cartesian3, index: number) {
 | 
				
			||||||
    this.points[index] = cartesian;
 | 
					    this.points[index] = cartesian;
 | 
				
			||||||
    const geometryPoints = this.createLine(this.points);
 | 
					    const geometryPoints = this.createGraphic(this.points);
 | 
				
			||||||
    this.setGeometryPoints(geometryPoints);
 | 
					    this.setGeometryPoints(geometryPoints);
 | 
				
			||||||
    this.drawLine();
 | 
					    this.drawLine();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -58,13 +60,13 @@ export default class StraightArrow extends Base {
 | 
				
			|||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Generate geometric shapes based on key points.
 | 
					   * Generate geometric shapes based on key points.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  createLine(positions: Cartesian3[]) {
 | 
					  createGraphic(positions: Cartesian3[]) {
 | 
				
			||||||
    const [pnt1, pnt2] = positions.map(this.cartesianToLnglat);
 | 
					    const [pnt1, pnt2] = positions.map(this.cartesianToLnglat);
 | 
				
			||||||
    const distance = Utils.MathDistance(pnt1, pnt2);
 | 
					    const distance = Utils.MathDistance(pnt1, pnt2);
 | 
				
			||||||
    let len = distance / this.arrowLengthScale;
 | 
					    let len = distance / this.arrowLengthScale;
 | 
				
			||||||
    len = len > this.maxArrowLength ? this.maxArrowLength : len;
 | 
					    len = len > this.maxArrowLength ? this.maxArrowLength : len;
 | 
				
			||||||
    const leftPnt = Utils.getThirdPoint(pnt1, pnt2, Math.PI / 6, len, false);
 | 
					    const leftPnt = Utils.getThirdPoint(pnt1, pnt2, Math.PI / 6, len / 3, false);
 | 
				
			||||||
    const rightPnt = Utils.getThirdPoint(pnt1, pnt2, Math.PI / 6, len, true);
 | 
					    const rightPnt = Utils.getThirdPoint(pnt1, pnt2, Math.PI / 6, len / 3, true);
 | 
				
			||||||
    const points = [...pnt1, ...pnt2, ...leftPnt, ...pnt2, ...rightPnt];
 | 
					    const points = [...pnt1, ...pnt2, ...leftPnt, ...pnt2, ...rightPnt];
 | 
				
			||||||
    const cartesianPoints = this.cesium.Cartesian3.fromDegreesArray(points);
 | 
					    const cartesianPoints = this.cesium.Cartesian3.fromDegreesArray(points);
 | 
				
			||||||
    return cartesianPoints;
 | 
					    return cartesianPoints;
 | 
				
			||||||
 | 
				
			|||||||
@ -26,12 +26,13 @@ export default class SwallowtailAttackArrow extends AttackArrow {
 | 
				
			|||||||
    this.headTailFactor = 0.8;
 | 
					    this.headTailFactor = 0.8;
 | 
				
			||||||
    this.swallowTailFactor = 1;
 | 
					    this.swallowTailFactor = 1;
 | 
				
			||||||
    this.swallowTailPnt = [0, 0];
 | 
					    this.swallowTailPnt = [0, 0];
 | 
				
			||||||
 | 
					    this.minPointsForShape = 3;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Generate geometric shapes based on key points.
 | 
					   * Generate geometric shapes based on key points.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  createPolygon(positions: Cartesian3[]): Cartesian3[] {
 | 
					  createGraphic(positions: Cartesian3[]): Cartesian3[] {
 | 
				
			||||||
    const lnglatPoints = positions.map((pnt) => {
 | 
					    const lnglatPoints = positions.map((pnt) => {
 | 
				
			||||||
      return this.cartesianToLnglat(pnt);
 | 
					      return this.cartesianToLnglat(pnt);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
				
			|||||||
@ -23,12 +23,13 @@ export default class SwallowtailSquadCombat extends SquadCombat {
 | 
				
			|||||||
    this.neckWidthFactor = 0.15;
 | 
					    this.neckWidthFactor = 0.15;
 | 
				
			||||||
    this.tailWidthFactor = 0.1;
 | 
					    this.tailWidthFactor = 0.1;
 | 
				
			||||||
    this.swallowTailFactor = 1;
 | 
					    this.swallowTailFactor = 1;
 | 
				
			||||||
 | 
					    this.minPointsForShape = 2;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Generate geometric shapes based on key points.
 | 
					   * Generate geometric shapes based on key points.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  createPolygon(positions: Cartesian3[]): Cartesian3[] {
 | 
					  createGraphic(positions: Cartesian3[]): Cartesian3[] {
 | 
				
			||||||
    const lnglatPoints = positions.map((pnt) => {
 | 
					    const lnglatPoints = positions.map((pnt) => {
 | 
				
			||||||
      return this.cartesianToLnglat(pnt);
 | 
					      return this.cartesianToLnglat(pnt);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
				
			|||||||
@ -710,7 +710,7 @@ export default class Base {
 | 
				
			|||||||
        tempPoints[tempPoints.length - 1] = newPosition;
 | 
					        tempPoints[tempPoints.length - 1] = newPosition;
 | 
				
			||||||
        const geometryPoints = this.createGraphic(tempPoints);
 | 
					        const geometryPoints = this.createGraphic(tempPoints);
 | 
				
			||||||
        this.setGeometryPoints(geometryPoints);
 | 
					        this.setGeometryPoints(geometryPoints);
 | 
				
			||||||
        this.showAnimation(0, 0, undefined);
 | 
					        this.showWithAnimation(0, 0, undefined);
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
      this.viewer.clock.onTick.addEventListener(frameListener);
 | 
					      this.viewer.clock.onTick.addEventListener(frameListener);
 | 
				
			||||||
    }, delay);
 | 
					    }, delay);
 | 
				
			||||||
 | 
				
			|||||||
@ -23,7 +23,7 @@ export default class Curve extends Base {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * 仅点击事件会添加点
 | 
						 * Points are only added upon click events.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	addPoint(cartesian: Cartesian3) {
 | 
						addPoint(cartesian: Cartesian3) {
 | 
				
			||||||
		this.points.push(cartesian);
 | 
							this.points.push(cartesian);
 | 
				
			||||||
@ -36,7 +36,7 @@ export default class Curve extends Base {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * 初次绘制时根据鼠标移动的点位绘制图形.
 | 
						 * Draw the shape based on the mouse movement position during the initial drawing.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	updateMovingPoint(cartesian: Cartesian3) {
 | 
						updateMovingPoint(cartesian: Cartesian3) {
 | 
				
			||||||
		const tempPoints = [...this.points, cartesian];
 | 
							const tempPoints = [...this.points, cartesian];
 | 
				
			||||||
@ -45,25 +45,25 @@ export default class Curve extends Base {
 | 
				
			|||||||
			this.setGeometryPoints(tempPoints);
 | 
								this.setGeometryPoints(tempPoints);
 | 
				
			||||||
			this.drawLine();
 | 
								this.drawLine();
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			geometryPoints = this.createLine(tempPoints);
 | 
								geometryPoints = this.createGraphic(tempPoints);
 | 
				
			||||||
			this.setGeometryPoints(geometryPoints);
 | 
								this.setGeometryPoints(geometryPoints);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * 编辑状态下,拖拽关键点位,更新对应关键点位数据
 | 
						 * During editing mode, drag key points to update the corresponding data.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	updateDraggingPoint(cartesian: Cartesian3, index: number) {
 | 
						updateDraggingPoint(cartesian: Cartesian3, index: number) {
 | 
				
			||||||
		this.points[index] = cartesian;
 | 
							this.points[index] = cartesian;
 | 
				
			||||||
		const geometryPoints = this.createLine(this.points);
 | 
							const geometryPoints = this.createGraphic(this.points);
 | 
				
			||||||
		this.setGeometryPoints(geometryPoints);
 | 
							this.setGeometryPoints(geometryPoints);
 | 
				
			||||||
		this.drawLine();
 | 
							this.drawLine();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * 根据关键点生成几何图形点位.
 | 
						 * Generate geometric shape points based on key points..
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	createLine(positions: Cartesian3[]) {
 | 
						createGraphic(positions: Cartesian3[]) {
 | 
				
			||||||
		const lnglatPoints = positions.map(pnt => {
 | 
							const lnglatPoints = positions.map(pnt => {
 | 
				
			||||||
			return this.cartesianToLnglat(pnt);
 | 
								return this.cartesianToLnglat(pnt);
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user