// @ts-ignore import { Cartesian3 } from 'cesium'; import { Category, CesiumTypes, PolygonStyle } from '../type'; import Basic from '../bastic'; export class FreehandLine extends Basic { points: Cartesian3[] = []; freehand: boolean; constructor(cesium: CesiumTypes, viewer: any, style?: PolygonStyle) { super(cesium, viewer, style); this.cesium = cesium; this.freehand = true; this.setState('drawing'); } getCategory(): Category { return 'polyline' } addPoint(cartesian: Cartesian3) { this.points.push(cartesian); if (this.points.length < 2) { this.onMouseMove(); } else { this.finishDrawing(); } } updateMovingPoint(cartesian: Cartesian3) { this.points.push(cartesian); this.setGeometryPoints(this.points); this.drawLine(); this.mainEntity = this.lineEntity this.eventDispatcher.dispatchEvent('drawUpdate', cartesian); } updateDraggingPoint(cartesian: Cartesian3, index: number) { this.points[index] = cartesian; this.setGeometryPoints(this.points); this.drawLine(); this.mainEntity = this.lineEntity } getPoints() { return this.points; } }