Kaynağa Gözat

修改鼠标事件

tags/1.0.0
Caven 5 yıl önce
ebeveyn
işleme
151c3fa84b

+ 42
- 54
src/core/event/MouseEvent.js Dosyayı Görüntüle

@@ -2,7 +2,7 @@
* @Author: Caven
* @Date: 2019-12-31 16:58:31
* @Last Modified by: Caven
* @Last Modified time: 2020-03-17 22:59:30
* @Last Modified time: 2020-04-03 11:01:19
*/

import Cesium from '@/namespace'
@@ -45,6 +45,30 @@ class MouseEvent extends Event {
}
}

/**
* Get mouse event info
* @param {*} position
*/
_getMouseInfo(position) {
let target = this._viewer.scene.pick(position)
let cartesian = undefined
if (this._viewer.scene.pickPositionSupported && target) {
cartesian = this._viewer.scene.pickPosition(position)
}
if (!cartesian || !target) {
let ray = this._viewer.scene.camera.getPickRay(position)
cartesian = this._viewer.scene.globe.pick(ray, this._viewer.scene)
}
let surfaceCartesian = this._viewer.scene.camera.pickEllipsoid(
position,
Cesium.Ellipsoid.WGS84
)
return {
target: target,
cartesian: cartesian,
surfaceCartesian: surfaceCartesian
}
}
/**
*
* @param {*} target
@@ -119,21 +143,12 @@ class MouseEvent extends Event {
if (!movement || !movement.position) {
return
}
let target = this._viewer.scene.pick(movement.position)
let cartesian = this._viewer.scene.pickPosition(movement.position)
if (!cartesian || !target) {
let ray = this._viewer.scene.camera.getPickRay(movement.position)
cartesian = this._viewer.scene.globe.pick(ray, this._viewer.scene)
}
let surfaceCartesian = this._viewer.scene.camera.pickEllipsoid(
movement.position,
Cesium.Ellipsoid.WGS84
)
let result = this._getMouseInfo(movement.position)
this._raiseEvent(
Cesium.ScreenSpaceEventType.LEFT_CLICK,
target,
cartesian,
surfaceCartesian
result.target,
result.cartesian,
result.surfaceCartesian
)
}

@@ -146,21 +161,12 @@ class MouseEvent extends Event {
if (!movement || !movement.position) {
return
}
let target = this._viewer.scene.pick(movement.position)
let cartesian = this._viewer.scene.pickPosition(movement.position)
if (!cartesian || !target) {
let ray = this._viewer.scene.camera.getPickRay(movement.position)
cartesian = this._viewer.scene.globe.pick(ray, this._viewer.scene)
}
let surfaceCartesian = this._viewer.scene.camera.pickEllipsoid(
movement.position,
Cesium.Ellipsoid.WGS84
)
let result = this._getMouseInfo(movement.position)
this._raiseEvent(
Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
target,
cartesian,
surfaceCartesian
result.target,
result.cartesian,
result.surfaceCartesian
)
}

@@ -172,21 +178,12 @@ class MouseEvent extends Event {
if (!movement || !movement.position) {
return
}
let target = this._viewer.scene.pick(movement.position)
let cartesian = this._viewer.scene.pickPosition(movement.position)
if (!cartesian || !target) {
let ray = this._viewer.scene.camera.getPickRay(movement.position)
cartesian = this._viewer.scene.globe.pick(ray, this._viewer.scene)
}
let surfaceCartesian = this._viewer.scene.camera.pickEllipsoid(
movement.position,
Cesium.Ellipsoid.WGS84
)
let result = this._getMouseInfo(movement.position)
this._raiseEvent(
Cesium.ScreenSpaceEventType.RIGHT_CLICK,
target,
cartesian,
surfaceCartesian
result.target,
result.cartesian,
result.surfaceCartesian
)
}

@@ -199,22 +196,13 @@ class MouseEvent extends Event {
if (!movement || !movement.endPosition) {
return
}
let target = this._viewer.scene.pick(movement.endPosition)
this._viewer.canvas.style.cursor = target ? 'pointer' : 'default'
let cartesian = this._viewer.scene.pickPosition(movement.endPosition)
if (!cartesian || !target) {
let ray = this._viewer.scene.camera.getPickRay(movement.endPosition)
cartesian = this._viewer.scene.globe.pick(ray, this._viewer.scene)
}
let surfaceCartesian = this._viewer.scene.camera.pickEllipsoid(
movement.endPosition,
Cesium.Ellipsoid.WGS84
)
let result = this._getMouseInfo(movement.endPosition)
this._viewer.canvas.style.cursor = result.target ? 'pointer' : 'default'
this._raiseEvent(
Cesium.ScreenSpaceEventType.MOUSE_MOVE,
target,
cartesian,
surfaceCartesian
result.target,
result.cartesian,
result.surfaceCartesian
)
}
}

+ 1
- 1
src/plot/DC.Plot.js Dosyayı Görüntüle

@@ -2,7 +2,7 @@
* @Author: Caven
* @Date: 2020-01-31 15:51:32
* @Last Modified by: Caven
* @Last Modified time: 2020-04-03 10:14:32
* @Last Modified time: 2020-04-03 10:38:56
*/
import Cesium from '@/namespace'
import DrawPoint from './draw/DrawPoint'

+ 3
- 1
src/plot/edit/EditCircle.js Dosyayı Görüntüle

@@ -2,7 +2,7 @@
* @Author: Caven
* @Date: 2020-03-17 18:23:25
* @Last Modified by: Caven
* @Last Modified time: 2020-03-17 21:59:25
* @Last Modified time: 2020-04-03 10:35:22
*/
import Edit from './Edit'

@@ -34,3 +34,5 @@ class EditCircle extends Edit {
let positions = [this._center]
}
}

export default EditCircle

+ 3
- 3
src/plot/edit/EditPoint.js Dosyayı Görüntüle

@@ -2,7 +2,7 @@
* @Author: Caven
* @Date: 2020-03-17 17:52:29
* @Last Modified by: Caven
* @Last Modified time: 2020-03-17 21:51:30
* @Last Modified time: 2020-04-03 10:33:50
*/
import Edit from './Edit'

@@ -13,7 +13,7 @@ class EditPoint extends Edit {
}

_mouseClickHandler(movement) {
this._position = this._viewer.delegate.scene.camera.pickEllipsoid(
this._position = this._viewer.scene.camera.pickEllipsoid(
movement.position,
Cesium.Ellipsoid.WGS84
)
@@ -26,7 +26,7 @@ class EditPoint extends Edit {

_mouseMoveHandler(movement) {
this._viewer.tooltip.setContent('单击选择点位')
this._position = this._viewer.delegate.scene.camera.pickEllipsoid(
this._position = this._viewer.scene.camera.pickEllipsoid(
movement.endPosition,
Cesium.Ellipsoid.WGS84
)

Loading…
İptal
Kaydet