mirror of
https://github.com/ethan-zf/cesium-plot-js.git
synced 2025-06-24 03:27:29 +00:00
edit AttackArrow
This commit is contained in:
parent
b7191a8054
commit
1730b93706
@ -135,4 +135,14 @@ export default class AttackArrow extends Draw {
|
|||||||
}
|
}
|
||||||
return leftBodyPnts.concat(rightBodyPnts);
|
return leftBodyPnts.concat(rightBodyPnts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In edit mode, drag key points to update corresponding key point data.
|
||||||
|
*/
|
||||||
|
updateDraggingPoint(cartesian: Cartesian3, index: number) {
|
||||||
|
this.points[index] = cartesian;
|
||||||
|
const geometryPoints = this.createPolygon(this.points);
|
||||||
|
this.setGeometryPoints(geometryPoints);
|
||||||
|
this.addToMap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
21
src/draw.ts
21
src/draw.ts
@ -8,7 +8,7 @@ export default class Draw {
|
|||||||
polygonEntity: CesiumTypeOnly.Entity;
|
polygonEntity: CesiumTypeOnly.Entity;
|
||||||
geometryPoints: CesiumTypeOnly.Cartesian3[] = [];
|
geometryPoints: CesiumTypeOnly.Cartesian3[] = [];
|
||||||
state: State = 'drawing';
|
state: State = 'drawing';
|
||||||
controlPoints: CesiumTypeOnly.EntityCollection;
|
controlPoints: CesiumTypeOnly.EntityCollection = [];
|
||||||
controlPointsEventHandler: CesiumTypeOnly.ScreenSpaceEventHandler;
|
controlPointsEventHandler: CesiumTypeOnly.ScreenSpaceEventHandler;
|
||||||
lineEntity: CesiumTypeOnly.Entity;
|
lineEntity: CesiumTypeOnly.Entity;
|
||||||
|
|
||||||
@ -55,8 +55,8 @@ export default class Draw {
|
|||||||
}
|
}
|
||||||
this.addPoint(cartesian);
|
this.addPoint(cartesian);
|
||||||
} else if (this.state === 'edit') {
|
} else if (this.state === 'edit') {
|
||||||
//In edit mode, exiting the edit state and deleting control points when clicking in the blank area.
|
//In edit mode, exit the editing state and delete control points when clicking outside the currently edited shape.
|
||||||
if (!hitEntities) {
|
if (!hitEntities || this.polygonEntity.id !== pickedObject.id.id) {
|
||||||
this.setState('static');
|
this.setState('static');
|
||||||
this.removeControlPoints();
|
this.removeControlPoints();
|
||||||
}
|
}
|
||||||
@ -217,6 +217,7 @@ export default class Draw {
|
|||||||
const cartesian = this.viewer.camera.pickEllipsoid(moveEvent.endPosition, this.viewer.scene.globe.ellipsoid);
|
const cartesian = this.viewer.camera.pickEllipsoid(moveEvent.endPosition, this.viewer.scene.globe.ellipsoid);
|
||||||
if (cartesian) {
|
if (cartesian) {
|
||||||
draggedIcon.position.setValue(cartesian);
|
draggedIcon.position.setValue(cartesian);
|
||||||
|
console.error(123);
|
||||||
this.updateDraggingPoint(cartesian, draggedIcon.index);
|
this.updateDraggingPoint(cartesian, draggedIcon.index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -231,12 +232,14 @@ export default class Draw {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeControlPoints() {
|
removeControlPoints() {
|
||||||
this.controlPoints.forEach((entity: CesiumTypeOnly.Entity) => {
|
if (this.controlPoints.length > 0) {
|
||||||
this.viewer.entities.remove(entity);
|
this.controlPoints.forEach((entity: CesiumTypeOnly.Entity) => {
|
||||||
});
|
this.viewer.entities.remove(entity);
|
||||||
this.controlPointsEventHandler.removeInputAction(this.cesium.ScreenSpaceEventType.LEFT_DOWN);
|
});
|
||||||
this.controlPointsEventHandler.removeInputAction(this.cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
this.controlPointsEventHandler.removeInputAction(this.cesium.ScreenSpaceEventType.LEFT_DOWN);
|
||||||
this.controlPointsEventHandler.removeInputAction(this.cesium.ScreenSpaceEventType.LEFT_UP);
|
this.controlPointsEventHandler.removeInputAction(this.cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
||||||
|
this.controlPointsEventHandler.removeInputAction(this.cesium.ScreenSpaceEventType.LEFT_UP);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addPoint(cartesian: CesiumTypeOnly.Cartesian3) {
|
addPoint(cartesian: CesiumTypeOnly.Cartesian3) {
|
||||||
|
Loading…
Reference in New Issue
Block a user