// @ts-ignore import { Cartesian3 } from 'cesium'; import { Category, CesiumTypes, PolylineStyle } from '../type'; import Basic from '../bastic'; export class Polyline extends Basic { constructor(cesium: CesiumTypes, viewer: any, style?: PolylineStyle) { super(cesium, viewer, style); this.cesium = cesium; this.setState('drawing'); this.onDoubleClick(); } getCategory(): Category { return 'polyline' } addPoint(cartesian: Cartesian3) { this.points.push(cartesian); if (this.points.length < 2) { this.onMouseMove(); } } updateMovingPoint(cartesian: Cartesian3) { const tempPoints = [...this.points, cartesian]; let geometryPoints: any[] = []; if (tempPoints.length === 2) { this.setGeometryPoints(tempPoints); this.drawLine(); this.mainEntity = this.lineEntity } else { geometryPoints = this.createGraphic(tempPoints); this.setGeometryPoints(geometryPoints); } } updateDraggingPoint(cartesian: Cartesian3, index: number) { this.points[index] = cartesian; const geometryPoints = this.createGraphic(this.points); this.setGeometryPoints(geometryPoints); this.drawLine(); this.mainEntity = this.lineEntity } getPoints() { return this.points; } }