import { SketchEditorNew, ViewEventType } from '@mapgis/webclient-common'

class SketchEditor3D extends SketchEditorNew {
  constructor(options) {
    super(options)
  }

  /**
   * cesium中拾取最上层草图方法
   * @private
   * */
  _hitTestEvent() {
    const self = this
    const handler = (event) => {
      const pickedObject = self._mapView._innerView.scene.pick(
        event.event.position
      )
      if (
        Cesium.defined(pickedObject) &&
        Cesium.defined(pickedObject.primitive) &&
        Cesium.defined(pickedObject.id)
      ) {
        self._sketchStage.entityGraphics.forEach((item) => {
          if (pickedObject.primitive.feature.id === item.id) {
            self._hitTestFeature(item)
          }
        })
      }
    }
    this._hitTestEventHandlers = [handler]
    if (this.snappingOption && this.snappingOption._hitTestMode === 1) {
      this._mapView.on(ViewEventType.mouseDown, handler)
    } else {
      this._mapView.on(ViewEventType.click, handler)
    }
  }

  hitTestSketch() {
    const handler = null
    this._mapView.on(ViewEventType.mouseDown, handler)
  }
}
export default SketchEditor3D
