Kaynağa Gözat

Merge pull request #195 from deyihu/194

drawtool support ground point when clampToModel
tags/4.0.0
Caven Chen 1 yıl önce
ebeveyn
işleme
f7a61aab5e
No account linked to committer's email address
1 değiştirilmiş dosya ile 16 ekleme ve 9 silme
  1. 16
    9
      src/modules/tools/DrawTool.js

+ 16
- 9
src/modules/tools/DrawTool.js Dosyayı Görüntüle

@@ -29,6 +29,18 @@ class DrawTool {
this._tooltipMess = tooltipMess
}

_getEventPosition(e) {
const { overlay, layer, position, surfacePosition } = e;
if (!this._options.clampToModel) {
return surfacePosition;
}
if (!overlay && !layer) {
return surfacePosition;
}
return position;

}

/**
*
* @param e
@@ -36,8 +48,7 @@ class DrawTool {
* @private
*/
_onClick(e) {
let position =
this._options.clampToModel && e.position ? e.position : e.surfacePosition
let position = this._getEventPosition(e);
if (!position) {
return false
}
@@ -54,8 +65,7 @@ class DrawTool {
*/
_onMouseMove(e) {
this._viewer.tooltip.showAt(e.windowPosition, this._tooltipMess)
let position =
this._options.clampToModel && e.position ? e.position : e.surfacePosition
let position = this._getEventPosition(e);
if (!position) {
return false
}
@@ -69,10 +79,7 @@ class DrawTool {
* @private
*/
_onRightClick(e) {
this._plotEvent.fire(
PlotEventType.DRAW_STOP,
this._options.clampToModel && e.position ? e.position : e.surfacePosition
)
this._plotEvent.fire(PlotEventType.DRAW_STOP, this._getEventPosition(e));
}

/**
@@ -92,7 +99,7 @@ class DrawTool {
eyeOffset: new Cesium.Cartesian3(0, 0, -100),
heightReference:
this._viewer.scene.mode === Cesium.SceneMode.SCENE3D &&
!this._options.clampToModel
!this._options.clampToModel
? Cesium.HeightReference.CLAMP_TO_GROUND
: Cesium.HeightReference.NONE,
},

Loading…
İptal
Kaydet