吉安感知网项目-前端
chenyao
4 days ago 899f3474a9bc54d1a72710b4fd992176c1888e70
applications/drone-command/src/utils/cesium/shapeTools/draw/DrawRectangleTool.js
@@ -33,7 +33,7 @@
      this.handler.setInputAction(click => this.handleLeftClick(click), Cesium.ScreenSpaceEventType.LEFT_CLICK)
      this.handler.setInputAction(movement => this.handleMouseMove(movement), Cesium.ScreenSpaceEventType.MOUSE_MOVE)
      this.tooltip.show('单击设置起点', { x: 0, y: 0 })
      this.tooltip.hide()
   }
   handleLeftClick(click) {
@@ -60,14 +60,17 @@
   }
   handleMouseMove(movement) {
      if (!this.isDrawing) {
      const tipText = this.startPosition ? '单击结束绘制' : '单击设置起点'
      if (!this.tooltip?.isVisible) {
         this.tooltip.show(tipText, movement.endPosition)
      } else {
         this.tooltip.show(tipText)
         this.tooltip.move(movement.endPosition)
         return
      }
      if (!this.isDrawing) return
      const position = this.getPositionFromScreen(movement.endPosition)
      if (!position) return
      this.endPosition = position
      this.tooltip.move(movement.endPosition)
   }
   createEntities() {
@@ -114,7 +117,8 @@
   getPositionFromScreen(screenPosition) {
      const scene = this.viewer.scene
      const cartesian = scene.pickPosition(screenPosition)
      const ray = scene.camera.getPickRay(screenPosition)
      const cartesian = ray ? scene.globe.pick(ray, scene) : null
      if (cartesian) return cartesian
      return scene.camera.pickEllipsoid(screenPosition, scene.globe.ellipsoid)
   }