Skip to content

Commit

Permalink
Merge pull request #195 from deyihu/194
Browse files Browse the repository at this point in the history
drawtool support ground point when clampToModel
  • Loading branch information
cavencj authored Jul 12, 2024
2 parents f2d7757 + f5887bf commit f7a61aa
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/modules/tools/DrawTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,26 @@ 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
* @returns {boolean}
* @private
*/
_onClick(e) {
let position =
this._options.clampToModel && e.position ? e.position : e.surfacePosition
let position = this._getEventPosition(e);
if (!position) {
return false
}
Expand All @@ -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
}
Expand All @@ -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));
}

/**
Expand All @@ -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,
},
Expand Down

0 comments on commit f7a61aa

Please sign in to comment.