Browse Source

1.修改鼠标事件的类型 ,2. 添加覆盖物的鼠标移除和移入的事件

tags/1.5.2
Caven Chen 5 years ago
parent
commit
f97c4d4ab0

+ 7
- 0
CHANGE.md View File

# 更新 # 更新


## 1.5.2

### 2020-5-15

> 1. 修改鼠标事件的类型
> 2. 添加覆盖物的鼠标移除和移入的事件

## 1.5.1 ## 1.5.1


### 2020-5-12 ### 2020-5-12

+ 10
- 10
dist/dc.base.min.js
File diff suppressed because it is too large
View File


+ 1
- 1
dist/dc.core.min.js
File diff suppressed because it is too large
View File


+ 1
- 1
package.json View File

{ {
"name": "@dvgis/dc-sdk", "name": "@dvgis/dc-sdk",
"version": "1.5.1",
"version": "1.5.2",
"description": " The SDK is a secondary development based on the open source project Cesium, which optimizes some operations of Cesium and enables developers to quickly develop 3D applications through the framework.", "description": " The SDK is a secondary development based on the open source project Cesium, which optimizes some operations of Cesium and enables developers to quickly develop 3D applications through the framework.",
"main": "index.js", "main": "index.js",
"repository": "https://github.com/Digital-Visual/dc-sdk.git", "repository": "https://github.com/Digital-Visual/dc-sdk.git",

+ 1
- 1
src/base/index.js View File

* @Author: Caven * @Author: Caven
* @Date: 2020-04-22 09:44:30 * @Date: 2020-04-22 09:44:30
* @Last Modified by: Caven * @Last Modified by: Caven
* @Last Modified time: 2020-05-12 19:58:35
* @Last Modified time: 2020-05-15 09:00:52
*/ */


import { initMixin, initUse } from './global-api' import { initMixin, initUse } from './global-api'

+ 7
- 3
src/core/Loader.Base.js View File

* @Author: Caven * @Author: Caven
* @Date: 2020-05-09 13:19:53 * @Date: 2020-05-09 13:19:53
* @Last Modified by: Caven * @Last Modified by: Caven
* @Last Modified time: 2020-05-12 09:27:35
* @Last Modified time: 2020-05-15 09:00:29
*/ */


import { DomUtil, Util } from './utils' import { DomUtil, Util } from './utils'
import { Layer, LayerType } from './layer' import { Layer, LayerType } from './layer'
import { Overlay, OverlayType } from './overlay' import { Overlay, OverlayType } from './overlay'
import ImageryType from './imagery/ImageryType' import ImageryType from './imagery/ImageryType'
import WidgetType from './widget/WidgetType'
import State from './state/State' import State from './state/State'
import Position from './position/Position' import Position from './position/Position'
import Transform from './transform/Transform' import Transform from './transform/Transform'
import Parse from './parse/Parse' import Parse from './parse/Parse'


DC.mixin({
const base = {
DomUtil, DomUtil,
Util, Util,
State, State,
OverlayType, OverlayType,
MouseEventType, MouseEventType,
SceneEventType, SceneEventType,
WidgetType,
Layer, Layer,
Overlay, Overlay,
Position, Position,
T: Transform, T: Transform,
Parse, Parse,
P: Parse P: Parse
})
}

DC.mixin(base)

+ 7
- 5
src/core/Loader.js View File

* @Author: Caven * @Author: Caven
* @Date: 2019-12-27 17:18:52 * @Date: 2019-12-27 17:18:52
* @Last Modified by: Caven * @Last Modified by: Caven
* @Last Modified time: 2020-05-12 00:45:45
* @Last Modified time: 2020-05-15 09:01:23
*/ */


import ImageryLayerFactory from './imagery/ImageryLayerFactory' import ImageryLayerFactory from './imagery/ImageryLayerFactory'
Cesium.Math.heading = heading Cesium.Math.heading = heading
Cesium.Math.isBetween = isBetween Cesium.Math.isBetween = isBetween


DC.mixin({
const core = {
ImageryLayerFactory, ImageryLayerFactory,
TerrainFactory, TerrainFactory,
Viewer, Viewer,
World: Viewer,
GeoJsonLayer, GeoJsonLayer,
HtmlLayer, HtmlLayer,
LabelLayer, LabelLayer,
Polyline, Polyline,
Polygon, Polygon,
Model, Model,
Tileset
})
Tileset,
Math: Cesium.Math
}


DC.Math = Cesium.Math
DC.mixin(core)

+ 22
- 4
src/core/event/EventType.js View File

* @Author: Caven * @Author: Caven
* @Date: 2020-04-10 17:02:28 * @Date: 2020-04-10 17:02:28
* @Last Modified by: Caven * @Last Modified by: Caven
* @Last Modified time: 2020-05-11 23:20:10
* @Last Modified time: 2020-05-15 13:46:18
*/ */


const { Cesium } = DC.Namespace const { Cesium } = DC.Namespace
MOUSE_MOVE: Cesium.ScreenSpaceEventType.MOUSE_MOVE, MOUSE_MOVE: Cesium.ScreenSpaceEventType.MOUSE_MOVE,
WHEEL: Cesium.ScreenSpaceEventType.WHEEL, WHEEL: Cesium.ScreenSpaceEventType.WHEEL,
MOUSE_OVER: 'mouseover', MOUSE_OVER: 'mouseover',
MOUSE_OUT: 'mouseout'
MOUSE_OUT: 'mouseout',
DRAG_START: 'dragStart',
DRAG_END: 'dragEnd',
EDIT_START: 'editStart',
EDIT_END: 'editEnd'
} }


const ViewerEventType = { const ViewerEventType = {
ADD_LAYER: 'addLayer', ADD_LAYER: 'addLayer',
REMOVE_LAYER: 'removeLayer', REMOVE_LAYER: 'removeLayer',
ADD_EFFECT: 'addEffect', ADD_EFFECT: 'addEffect',
REMOVE_EFFECT: 'removeEffect'
REMOVE_EFFECT: 'removeEffect',
CLICK: Cesium.ScreenSpaceEventType.LEFT_CLICK,
RIGHT_CLICK: Cesium.ScreenSpaceEventType.RIGHT_CLICK,
DB_CLICK: Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
MOUSE_MOVE: Cesium.ScreenSpaceEventType.MOUSE_MOVE,
WHEEL: Cesium.ScreenSpaceEventType.WHEEL
} }


const SceneEventType = { const SceneEventType = {
} }


const OverlayEventType = { const OverlayEventType = {
...baseEventType
...baseEventType,
CLICK: Cesium.ScreenSpaceEventType.LEFT_CLICK,
RIGHT_CLICK: Cesium.ScreenSpaceEventType.RIGHT_CLICK,
DB_CLICK: Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
MOUSE_OVER: 'mouseover',
MOUSE_OUT: 'mouseout',
DRAG_START: 'dragStart',
DRAG_END: 'dragEnd',
EDIT_START: 'editStart',
EDIT_END: 'editEnd'
} }


export { export {

+ 42
- 4
src/core/event/MouseEvent.js View File

* @Author: Caven * @Author: Caven
* @Date: 2019-12-31 16:58:31 * @Date: 2019-12-31 16:58:31
* @Last Modified by: Caven * @Last Modified by: Caven
* @Last Modified time: 2020-05-11 22:35:29
* @Last Modified time: 2020-05-15 14:16:56
*/ */


import { MouseEventType } from './EventType' import { MouseEventType } from './EventType'
constructor(viewer) { constructor(viewer) {
super() super()
this._viewer = viewer this._viewer = viewer
this._selected = undefined
this._setInputAction() this._setInputAction()
this.on(MouseEventType.CLICK, this._clickHandler, this) this.on(MouseEventType.CLICK, this._clickHandler, this)
this.on(MouseEventType.DB_CLICK, this._dbClickHandler, this) this.on(MouseEventType.DB_CLICK, this._dbClickHandler, this)
} }
} }


/**
* Gets the Overlay id
* @param {*} target
*/
_getOverlayId(target) {
let overlayId = undefined

/**
* Entity
*/
if (target && target.id && target.id instanceof Cesium.Entity) {
overlayId = target.id.overlayId
}

/**
* Cesium3DTileFeature
*/
if (target && target instanceof Cesium.Cesium3DTileFeature) {
overlayId = target.tileset.overlayId
}

return overlayId
}

/** /**
* *
* Gets the target information for the mouse event * Gets the target information for the mouse event
* @param {*} mouseInfo * @param {*} mouseInfo
* *
*/ */
_raiseEvent(type, mouseInfo = {}) {
_raiseEvent(type, mouseInfo = {}, callback) {
let event = undefined let event = undefined
let targetInfo = this._getTargetInfo(mouseInfo.target) let targetInfo = this._getTargetInfo(mouseInfo.target)
let overlay = targetInfo.overlay let overlay = targetInfo.overlay
if (overlay && overlay.overlayEvent) { if (overlay && overlay.overlayEvent) {
event = overlay.overlayEvent.getEvent(type) event = overlay.overlayEvent.getEvent(type)
} else {
event = this._viewer.viewerEvent.getEvent(type)
} }
// stopPropagation
!event && (event = this._viewer.viewerEvent.getEvent(type))
event && event &&
event.numberOfListeners > 0 && event.numberOfListeners > 0 &&
event.raiseEvent({ event.raiseEvent({
...targetInfo, ...targetInfo,
...mouseInfo ...mouseInfo
}) })
callback && callback()
} }


/** /**
let mouseInfo = this._getMouseInfo(movement.endPosition) let mouseInfo = this._getMouseInfo(movement.endPosition)
this._viewer.canvas.style.cursor = mouseInfo.target ? 'pointer' : 'default' this._viewer.canvas.style.cursor = mouseInfo.target ? 'pointer' : 'default'
this._raiseEvent(MouseEventType.MOUSE_MOVE, mouseInfo) this._raiseEvent(MouseEventType.MOUSE_MOVE, mouseInfo)

// add event for overlay
if (
!this._selected ||
this._getOverlayId(this._selected.target) !==
this._getOverlayId(mouseInfo.target)
) {
this._raiseEvent(MouseEventType.MOUSE_OUT, this._selected)
this._raiseEvent(MouseEventType.MOUSE_OVER, mouseInfo, () => {
this._selected = mouseInfo
})
}
} }
} }



+ 2
- 7
src/core/event/OverlayEvent.js View File

* @Author: Caven * @Author: Caven
* @Date: 2020-01-02 14:26:35 * @Date: 2020-01-02 14:26:35
* @Last Modified by: Caven * @Last Modified by: Caven
* @Last Modified time: 2020-05-11 23:57:41
* @Last Modified time: 2020-05-15 10:05:01
*/ */


import { MouseEventType, OverlayEventType } from './EventType'
import { OverlayEventType } from './EventType'
import Event from './Event' import Event from './Event'


const { Cesium } = DC.Namespace const { Cesium } = DC.Namespace
} }


_registerEvent() { _registerEvent() {
Object.keys(MouseEventType).forEach(key => {
let type = MouseEventType[key]
this._cache[type] = new Cesium.Event()
})

Object.keys(OverlayEventType).forEach(key => { Object.keys(OverlayEventType).forEach(key => {
let type = OverlayEventType[key] let type = OverlayEventType[key]
this._cache[type] = new Cesium.Event() this._cache[type] = new Cesium.Event()

+ 2
- 7
src/core/event/ViewerEvent.js View File

* @Author: Caven * @Author: Caven
* @Date: 2020-01-02 14:26:35 * @Date: 2020-01-02 14:26:35
* @Last Modified by: Caven * @Last Modified by: Caven
* @Last Modified time: 2020-05-11 23:57:30
* @Last Modified time: 2020-05-15 10:05:24
*/ */


import { MouseEventType, ViewerEventType } from './EventType'
import { ViewerEventType } from './EventType'
import Event from './Event' import Event from './Event'


const { Cesium } = DC.Namespace const { Cesium } = DC.Namespace
} }


_registerEvent() { _registerEvent() {
Object.keys(MouseEventType).forEach(key => {
let type = MouseEventType[key]
this._cache[type] = new Cesium.Event()
})

Object.keys(ViewerEventType).forEach(key => { Object.keys(ViewerEventType).forEach(key => {
let type = ViewerEventType[key] let type = ViewerEventType[key]
this._cache[type] = new Cesium.Event() this._cache[type] = new Cesium.Event()

+ 1
- 3
src/core/math/area.js View File

* @Author: Caven * @Author: Caven
* @Date: 2020-04-24 14:49:37 * @Date: 2020-04-24 14:49:37
* @Last Modified by: Caven * @Last Modified by: Caven
* @Last Modified time: 2020-05-12 00:38:59
* @Last Modified time: 2020-05-15 08:58:33
*/ */


import Transform from '../transform/Transform' import Transform from '../transform/Transform'
} }
return result return result
} }

Cesium.Math.area = area

+ 1
- 1
src/core/math/bounds.js View File

* @Author: Caven * @Author: Caven
* @Date: 2020-04-23 09:29:56 * @Date: 2020-04-23 09:29:56
* @Last Modified by: Caven * @Last Modified by: Caven
* @Last Modified time: 2020-05-12 00:46:48
* @Last Modified time: 2020-05-15 08:58:37
*/ */


export default function bounds(positions = [], expand = 0) { export default function bounds(positions = [], expand = 0) {

+ 1
- 1
src/core/math/center.js View File

* @Author: Caven * @Author: Caven
* @Date: 2020-04-24 14:43:39 * @Date: 2020-04-24 14:43:39
* @Last Modified by: Caven * @Last Modified by: Caven
* @Last Modified time: 2020-05-12 00:42:28
* @Last Modified time: 2020-05-15 08:58:38
*/ */


import Transform from '../transform/Transform' import Transform from '../transform/Transform'

Loading…
Cancel
Save