edit AttackArrow

This commit is contained in:
ethan 2023-08-17 19:35:20 +08:00
parent b7191a8054
commit 1730b93706
2 changed files with 22 additions and 9 deletions

View File

@ -135,4 +135,14 @@ export default class AttackArrow extends Draw {
}
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();
}
}

View File

@ -8,7 +8,7 @@ export default class Draw {
polygonEntity: CesiumTypeOnly.Entity;
geometryPoints: CesiumTypeOnly.Cartesian3[] = [];
state: State = 'drawing';
controlPoints: CesiumTypeOnly.EntityCollection;
controlPoints: CesiumTypeOnly.EntityCollection = [];
controlPointsEventHandler: CesiumTypeOnly.ScreenSpaceEventHandler;
lineEntity: CesiumTypeOnly.Entity;
@ -55,8 +55,8 @@ export default class Draw {
}
this.addPoint(cartesian);
} else if (this.state === 'edit') {
//In edit mode, exiting the edit state and deleting control points when clicking in the blank area.
if (!hitEntities) {
//In edit mode, exit the editing state and delete control points when clicking outside the currently edited shape.
if (!hitEntities || this.polygonEntity.id !== pickedObject.id.id) {
this.setState('static');
this.removeControlPoints();
}
@ -217,6 +217,7 @@ export default class Draw {
const cartesian = this.viewer.camera.pickEllipsoid(moveEvent.endPosition, this.viewer.scene.globe.ellipsoid);
if (cartesian) {
draggedIcon.position.setValue(cartesian);
console.error(123);
this.updateDraggingPoint(cartesian, draggedIcon.index);
}
}
@ -231,6 +232,7 @@ export default class Draw {
}
removeControlPoints() {
if (this.controlPoints.length > 0) {
this.controlPoints.forEach((entity: CesiumTypeOnly.Entity) => {
this.viewer.entities.remove(entity);
});
@ -238,6 +240,7 @@ export default class Draw {
this.controlPointsEventHandler.removeInputAction(this.cesium.ScreenSpaceEventType.MOUSE_MOVE);
this.controlPointsEventHandler.removeInputAction(this.cesium.ScreenSpaceEventType.LEFT_UP);
}
}
addPoint(cartesian: CesiumTypeOnly.Cartesian3) {
//Abstract method that must be implemented by subclasses.