| @@ -2,15 +2,17 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-05-09 13:19:53 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 11:05:39 | |||
| * @Last Modified time: 2020-05-11 17:24:59 | |||
| */ | |||
| import { MouseEventType, SceneEventType } from './event/EventType' | |||
| import { Layer, LayerType } from './layer' | |||
| import { Overlay, OverlayType } from './overlay' | |||
| import ImageryType from './imagery/ImageryType' | |||
| import State from './state/State' | |||
| DC.mixin({ | |||
| State: State, | |||
| ImageryType: ImageryType, | |||
| LayerType: LayerType, | |||
| OverlayType: OverlayType, | |||
| @@ -1,14 +0,0 @@ | |||
| /* | |||
| * @Author: Caven | |||
| * @Date: 2020-05-10 10:13:00 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 11:29:06 | |||
| */ | |||
| const EffectState = { | |||
| INITIALIZED: 'initialized', | |||
| ADDED: 'added', | |||
| REMOVED: 'removed' | |||
| } | |||
| export default EffectState | |||
| @@ -2,13 +2,13 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-13 10:13:53 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 08:58:15 | |||
| * @Last Modified time: 2020-05-11 17:00:13 | |||
| */ | |||
| import { Cesium } from '../../namespace' | |||
| import { Billboard, Polyline, Polygon } from '../overlay' | |||
| import State from '../state/State' | |||
| import Layer from './Layer' | |||
| import LayerState from './LayerState' | |||
| class GeoJsonLayer extends Layer { | |||
| constructor(id, url, options = {}) { | |||
| @@ -18,7 +18,7 @@ class GeoJsonLayer extends Layer { | |||
| super(id) | |||
| this._delegate = Cesium.GeoJsonDataSource.load(url, options) | |||
| this.type = Layer.getLayerType('geojson') | |||
| this._state = LayerState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| set show(show) { | |||
| @@ -2,12 +2,12 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-02-12 21:43:33 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 08:59:25 | |||
| * @Last Modified time: 2020-05-11 17:00:20 | |||
| */ | |||
| import { Cesium } from '../../namespace' | |||
| import State from '../state/State' | |||
| import Layer from './Layer' | |||
| import LayerState from './LayerState' | |||
| class HtmlLayer extends Layer { | |||
| constructor(id) { | |||
| @@ -16,7 +16,7 @@ class HtmlLayer extends Layer { | |||
| this._delegate.setAttribute('id', this._id) | |||
| this._renderRemoveCallback = undefined | |||
| this.type = Layer.getLayerType('html') | |||
| this._state = LayerState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| set show(show) { | |||
| @@ -51,7 +51,7 @@ class HtmlLayer extends Layer { | |||
| } | |||
| }) | |||
| }, this) | |||
| this._state = LayerState.ADDED | |||
| this._state = State.ADDED | |||
| } | |||
| /** | |||
| @@ -61,7 +61,7 @@ class HtmlLayer extends Layer { | |||
| _removeHandler() { | |||
| this._renderRemoveCallback && this._renderRemoveCallback() | |||
| this._viewer.dcContainer.removeChild(this._delegate) | |||
| this._state = LayerState.REMOVED | |||
| this._state = State.REMOVED | |||
| } | |||
| /** | |||
| @@ -73,7 +73,7 @@ class HtmlLayer extends Layer { | |||
| this._delegate.removeChild(childs[i]) | |||
| } | |||
| this._cache = {} | |||
| this._state = LayerState.CLEARED | |||
| this._state = State.CLEARED | |||
| return this | |||
| } | |||
| } | |||
| @@ -2,11 +2,11 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-03-30 17:14:00 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 09:00:11 | |||
| * @Last Modified time: 2020-05-11 16:59:59 | |||
| */ | |||
| import { Cesium } from '../../namespace' | |||
| import State from '../state/State' | |||
| import Layer from './Layer' | |||
| import LayerState from './LayerState' | |||
| class LabelLayer extends Layer { | |||
| constructor(id, url) { | |||
| @@ -18,7 +18,7 @@ class LabelLayer extends Layer { | |||
| this._delegate = new Cesium.CustomDataSource(id) | |||
| this._initLabel() | |||
| this.type = Layer.registerType('label') | |||
| this._state = LayerState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| _createLabel(entity) { | |||
| @@ -2,14 +2,13 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-03 09:38:21 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 08:56:01 | |||
| * @Last Modified time: 2020-05-11 17:04:58 | |||
| */ | |||
| import { Cesium } from '../../namespace' | |||
| import { LayerEvent } from '../event' | |||
| import { LayerEventType, OverlayEventType } from '../event/EventType' | |||
| import LayerState from './LayerState' | |||
| import OverlayState from '../overlay/OverlayState' | |||
| import State from '../state/State' | |||
| import LayerType from './LayerType' | |||
| class Layer { | |||
| @@ -25,7 +24,7 @@ class Layer { | |||
| this._layerEvent = new LayerEvent() | |||
| this._layerEvent.on(LayerEventType.ADD, this._addHandler, this) | |||
| this._layerEvent.on(LayerEventType.REMOVE, this._removeHandler, this) | |||
| this._state = LayerState.INITIALIZED | |||
| this._state = undefined | |||
| this.type = undefined | |||
| } | |||
| @@ -87,7 +86,7 @@ class Layer { | |||
| this._viewer.dataSources.add(this._delegate) | |||
| } | |||
| this._addedHook && this._addedHook() | |||
| this._state = LayerState.ADDED | |||
| this._state = State.ADDED | |||
| } | |||
| /** | |||
| @@ -113,7 +112,7 @@ class Layer { | |||
| this._viewer.dataSources.remove(this._delegate) | |||
| } | |||
| this._removedHook && this._removedHook() | |||
| this._state = LayerState.REMOVED | |||
| this._state = State.REMOVED | |||
| } | |||
| } | |||
| @@ -127,12 +126,12 @@ class Layer { | |||
| if ( | |||
| overlay && | |||
| overlay.overlayEvent && | |||
| overlay.state !== OverlayState.ADDED | |||
| !this._cache.hasOwnProperty(overlay.overlayId) | |||
| ) { | |||
| overlay.overlayEvent.fire(OverlayEventType.ADD, this) | |||
| this._cache[overlay.overlayId] = overlay | |||
| if (this._state === LayerState.CLEARED) { | |||
| this._state = LayerState.ADDED | |||
| if (this._state === State.CLEARED) { | |||
| this._state = State.ADDED | |||
| } | |||
| } | |||
| } | |||
| @@ -147,7 +146,7 @@ class Layer { | |||
| if ( | |||
| overlay && | |||
| overlay.overlayEvent && | |||
| overlay.state !== OverlayState.REMOVED | |||
| this._cache.hasOwnProperty(overlay.overlayId) | |||
| ) { | |||
| overlay.overlayEvent.fire(OverlayEventType.REMOVE, this) | |||
| delete this._cache[overlay.overlayId] | |||
| @@ -218,9 +217,9 @@ class Layer { | |||
| */ | |||
| getOverlaysByAttr(atrrName, attrVal) { | |||
| let result = [] | |||
| Object.keys(this._cache).forEach(key => { | |||
| if (this._cache[key].attr[atrrName] === attrVal) { | |||
| result.push[this._cache[key]] | |||
| this.eachOverlay(item => { | |||
| if (item.attr[atrrName] === attrVal) { | |||
| result.push(item) | |||
| } | |||
| }) | |||
| return result | |||
| @@ -1,15 +0,0 @@ | |||
| /* | |||
| * @Author: Caven | |||
| * @Date: 2020-05-10 08:23:03 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 08:23:26 | |||
| */ | |||
| const LayerState = { | |||
| INITIALIZED: 'initialized', | |||
| ADDED: 'added', | |||
| REMOVED: 'removed', | |||
| CLEARED: 'cleared' | |||
| } | |||
| export default LayerState | |||
| @@ -2,12 +2,12 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-09 09:16:27 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 09:01:06 | |||
| * @Last Modified time: 2020-05-11 17:00:30 | |||
| */ | |||
| import { Cesium } from '../../namespace' | |||
| import State from '../state/State' | |||
| import Layer from './Layer' | |||
| import LayerState from './LayerState' | |||
| /** | |||
| * TilesetLayer is used to add various tileset | |||
| @@ -17,13 +17,13 @@ class TilesetLayer extends Layer { | |||
| super(id) | |||
| this._delegate = new Cesium.PrimitiveCollection() | |||
| this.type = Layer.getLayerType('tileset') | |||
| this._state = LayerState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| clear() { | |||
| this._delegate.removeAll() | |||
| this._cache = {} | |||
| this._state = LayerState.CLEARED | |||
| this._state = State.CLEARED | |||
| return this | |||
| } | |||
| } | |||
| @@ -2,11 +2,11 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-03-22 01:12:39 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 09:02:45 | |||
| * @Last Modified time: 2020-05-11 17:05:29 | |||
| */ | |||
| import GeoJsonLayer from './GeoJsonLayer' | |||
| import LayerState from './LayerState' | |||
| import State from '../state/State' | |||
| class TopoJsonLayer extends GeoJsonLayer { | |||
| constructor(id, url, options = {}) { | |||
| @@ -15,7 +15,7 @@ class TopoJsonLayer extends GeoJsonLayer { | |||
| } | |||
| super(id, url, options) | |||
| this.type = GeoJsonLayer.getLayerType('topojson') | |||
| this._state = LayerState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| } | |||
| @@ -2,12 +2,12 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-02 16:42:03 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 09:06:31 | |||
| * @Last Modified time: 2020-05-11 17:05:49 | |||
| */ | |||
| import { Cesium } from '../../namespace' | |||
| import State from '../state/State' | |||
| import Layer from './Layer' | |||
| import LayerState from './LayerState' | |||
| /** | |||
| * The vector layer is used to add various enitity, which is essentially a CustomDataSource | |||
| @@ -18,13 +18,13 @@ class VectorLayer extends Layer { | |||
| super(id) | |||
| this._delegate = new Cesium.CustomDataSource(id) | |||
| this.type = Layer.getLayerType('vector') | |||
| this._state = LayerState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| clear() { | |||
| this._delegate.entities && this._delegate.entities.removeAll() | |||
| this._cache = {} | |||
| this._state = LayerState.CLEARED | |||
| this._state = State.CLEARED | |||
| return this | |||
| } | |||
| } | |||
| @@ -1,13 +0,0 @@ | |||
| /* | |||
| * @Author: Caven | |||
| * @Date: 2020-05-10 08:24:54 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 09:08:27 | |||
| */ | |||
| const OverlayState = { | |||
| INITIALIZED: 'initialized', | |||
| ADDED: 'added', | |||
| REMOVED: 'removed' | |||
| } | |||
| export default OverlayState | |||
| @@ -2,14 +2,14 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-19 10:18:23 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 09:19:13 | |||
| * @Last Modified time: 2020-05-11 17:08:29 | |||
| */ | |||
| import { Cesium } from '../../../namespace' | |||
| import { Util } from '../../utils' | |||
| import Transform from '../../transform/Transform' | |||
| import State from '../../state/State' | |||
| import Overlay from '../Overlay' | |||
| import OverlayState from '../OverlayState' | |||
| class Billboard extends Overlay { | |||
| constructor(position, icon) { | |||
| @@ -22,7 +22,7 @@ class Billboard extends Overlay { | |||
| this._size = [32, 32] | |||
| this._delegate = new Cesium.Entity() | |||
| this.type = Overlay.getOverlayType('billboard') | |||
| this._state = OverlayState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| set position(position) { | |||
| @@ -2,14 +2,14 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-31 18:57:02 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 09:31:39 | |||
| * @Last Modified time: 2020-05-11 17:08:52 | |||
| */ | |||
| import { Cesium } from '../../../namespace' | |||
| import { Util } from '../../utils' | |||
| import Transform from '../../transform/Transform' | |||
| import State from '../../state/State' | |||
| import Overlay from '../Overlay' | |||
| import OverlayState from '../OverlayState' | |||
| class Circle extends Overlay { | |||
| constructor(center, radius) { | |||
| @@ -23,7 +23,7 @@ class Circle extends Overlay { | |||
| this._rotateAmount = 0 | |||
| this._stRotation = 0 | |||
| this.type = Overlay.getOverlayType('circle') | |||
| this._state = OverlayState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| set center(center) { | |||
| @@ -2,14 +2,14 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-02-12 21:46:22 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 09:33:35 | |||
| * @Last Modified time: 2020-05-11 17:09:28 | |||
| */ | |||
| import { DomUtil, Util } from '../../utils' | |||
| import { isBetween } from '../../math' | |||
| import Transform from '../../transform/Transform' | |||
| import State from '../State' | |||
| import Overlay from '../Overlay' | |||
| import OverlayState from '../OverlayState' | |||
| class DivIcon extends Overlay { | |||
| constructor(position, content) { | |||
| @@ -27,7 +27,7 @@ class DivIcon extends Overlay { | |||
| }) | |||
| this.content = content | |||
| this.type = Overlay.getOverlayType('div_icon') | |||
| this._state = OverlayState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| set show(show) { | |||
| @@ -108,7 +108,7 @@ class DivIcon extends Overlay { | |||
| position: Transform.transformWGS84ToCartesian(this._position) | |||
| }) | |||
| }) | |||
| this._state = OverlayState.ADDED | |||
| this._state = State.ADDED | |||
| } | |||
| /** | |||
| @@ -117,7 +117,7 @@ class DivIcon extends Overlay { | |||
| _removeHandler() { | |||
| if (this._layer) { | |||
| this._layer.delegate.removeChild(this._delegate) | |||
| this._state = OverlayState.REMOVED | |||
| this._state = State.REMOVED | |||
| } | |||
| } | |||
| @@ -2,13 +2,13 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-02-01 11:59:28 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 09:35:11 | |||
| * @Last Modified time: 2020-05-11 17:10:01 | |||
| */ | |||
| import { Cesium } from '../../../namespace' | |||
| import { Util } from '../../utils' | |||
| import Transform from '../../transform/Transform' | |||
| import State from '../../state/State' | |||
| import Overlay from '../Overlay' | |||
| import OverlayState from '../OverlayState' | |||
| class Label extends Overlay { | |||
| constructor(position, text) { | |||
| @@ -20,7 +20,7 @@ class Label extends Overlay { | |||
| this._text = text | |||
| this._delegate = new Cesium.Entity() | |||
| this.type = Overlay.getOverlayType('label') | |||
| this._state = OverlayState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| set position(position) { | |||
| @@ -2,14 +2,14 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-06 15:03:25 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 09:39:09 | |||
| * @Last Modified time: 2020-05-11 17:10:26 | |||
| */ | |||
| import { Cesium } from '../../../namespace' | |||
| import { Util } from '../../utils' | |||
| import Transform from '../../transform/Transform' | |||
| import State from '../../state/State' | |||
| import Overlay from '../Overlay' | |||
| import OverlayState from '../OverlayState' | |||
| const DEF_STYLE = { | |||
| pixelSize: 8, | |||
| @@ -26,7 +26,7 @@ class Point extends Overlay { | |||
| this._position = position | |||
| this._delegate = new Cesium.Entity() | |||
| this.type = Overlay.getOverlayType('point') | |||
| this._state = OverlayState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| set position(position) { | |||
| @@ -2,15 +2,15 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-09 09:10:37 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 09:40:38 | |||
| * @Last Modified time: 2020-05-11 17:10:49 | |||
| */ | |||
| import { Cesium } from '../../../namespace' | |||
| import { Util } from '../../utils' | |||
| import { center, area } from '../../math' | |||
| import Transform from '../../transform/Transform' | |||
| import Parse from '../../parse/Parse' | |||
| import State from '../../state/State' | |||
| import Overlay from '../Overlay' | |||
| import OverlayState from '../OverlayState' | |||
| class Polygon extends Overlay { | |||
| constructor(positions) { | |||
| @@ -22,7 +22,7 @@ class Polygon extends Overlay { | |||
| this._holes = [] | |||
| this._delegate = new Cesium.Entity() | |||
| this.type = Overlay.getOverlayType('polygon') | |||
| this._state = OverlayState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| set positions(positions) { | |||
| @@ -2,7 +2,7 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-06 15:03:25 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 09:40:07 | |||
| * @Last Modified time: 2020-05-11 17:11:13 | |||
| */ | |||
| import { Cesium } from '../../../namespace' | |||
| @@ -10,8 +10,8 @@ import { Util } from '../../utils' | |||
| import { center, distance } from '../../math' | |||
| import Transform from '../../transform/Transform' | |||
| import Parse from '../../parse/Parse' | |||
| import State from '../../state/State' | |||
| import Overlay from '../Overlay' | |||
| import OverlayState from '../OverlayState' | |||
| class Polyline extends Overlay { | |||
| constructor(positions) { | |||
| @@ -22,7 +22,7 @@ class Polyline extends Overlay { | |||
| this._positions = Parse.parsePositions(positions) | |||
| this._delegate = new Cesium.Entity() | |||
| this.type = Overlay.getOverlayType('polyline') | |||
| this._state = OverlayState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| set positions(positions) { | |||
| @@ -2,14 +2,14 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-06 15:03:25 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 10:08:07 | |||
| * @Last Modified time: 2020-05-11 17:11:35 | |||
| */ | |||
| import { Cesium } from '../../../namespace' | |||
| import { Util } from '../../utils' | |||
| import Transform from '../../transform/Transform' | |||
| import State from '../../state/State' | |||
| import Overlay from '../Overlay' | |||
| import OverlayState from '../OverlayState' | |||
| class Model extends Overlay { | |||
| constructor(position, modelUrl) { | |||
| @@ -22,7 +22,7 @@ class Model extends Overlay { | |||
| this._delegate = new Cesium.Entity() | |||
| this._rotateAmount = 0 | |||
| this.type = Overlay.getOverlayType('model') | |||
| this._state = OverlayState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| set position(position) { | |||
| @@ -2,12 +2,12 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-07 08:51:56 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 09:51:10 | |||
| * @Last Modified time: 2020-05-11 17:12:18 | |||
| */ | |||
| import { Cesium } from '../../../namespace' | |||
| import { Util } from '../../utils' | |||
| import State from '../../state/State' | |||
| import Overlay from '../Overlay' | |||
| import OverlayState from '../OverlayState' | |||
| class Tileset extends Overlay { | |||
| constructor(url, options = {}) { | |||
| @@ -23,7 +23,7 @@ class Tileset extends Overlay { | |||
| this._duration = undefined | |||
| this._center = undefined | |||
| this.type = Overlay.getOverlayType('tileset') | |||
| this._state = OverlayState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| /** | |||
| @@ -47,7 +47,7 @@ class Tileset extends Overlay { | |||
| this._layer.delegate.add(tileset) | |||
| tileset.layer = layer | |||
| tileset.overlayId = this._id | |||
| this._state = OverlayState.ADDED | |||
| this._state = State.ADDED | |||
| }) | |||
| } | |||
| @@ -60,7 +60,7 @@ class Tileset extends Overlay { | |||
| } | |||
| this._delegate.readyPromise.then(tileset => { | |||
| this._layer.delegate.remove(tileset) | |||
| this._state = OverlayState.REMOVED | |||
| this._state = State.REMOVED | |||
| }) | |||
| } | |||
| /** | |||
| @@ -0,0 +1,18 @@ | |||
| /* | |||
| * @Author: Caven | |||
| * @Date: 2020-05-11 16:39:23 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-11 16:54:51 | |||
| */ | |||
| const State = { | |||
| INITIALIZED: 'initialized', | |||
| ADDED: 'added', | |||
| REMOVED: 'removed', | |||
| CLEARED: 'cleared', | |||
| INSTALLED: 'installed', | |||
| ENABLED: 'enabled', | |||
| DISABLED: 'disabled' | |||
| } | |||
| export default State | |||
| @@ -2,7 +2,7 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-07 09:00:32 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 08:25:35 | |||
| * @Last Modified time: 2020-05-11 16:34:47 | |||
| */ | |||
| import { Cesium } from '../../namespace' | |||
| import Position from '../position/Position' | |||
| @@ -121,6 +121,7 @@ class Transform { | |||
| */ | |||
| static transformWindowToWGS84(position, viewer) { | |||
| let scene = viewer.scene | |||
| let cartesian = undefined | |||
| if (scene.mode === Cesium.SceneMode.SCENE3D) { | |||
| let ray = scene.camera.getPickRay(position) | |||
| cartesian = scene.globe.pick(ray, scene) | |||
| @@ -2,7 +2,7 @@ | |||
| * @Author: Caven | |||
| * @Date: 2019-12-27 17:13:24 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 10:15:27 | |||
| * @Last Modified time: 2020-05-11 16:58:42 | |||
| */ | |||
| import { Cesium } from '../../namespace' | |||
| @@ -24,8 +24,6 @@ import { | |||
| import { DomUtil } from '../utils' | |||
| import Transform from '../transform/Transform' | |||
| import Position from '../position/Position' | |||
| import LayerState from '../layer/LayerState' | |||
| import EffectState from '../effects/EffectState' | |||
| const DEF_OPTS = { | |||
| animation: false, //Whether to create animated widgets, lower left corner of the meter | |||
| @@ -171,43 +169,61 @@ class Viewer { | |||
| return position | |||
| } | |||
| /** | |||
| * | |||
| * @param {*} layer | |||
| */ | |||
| _addLayer(layer) { | |||
| if (layer && layer.layerEvent && layer.state !== LayerState.ADDED) { | |||
| if (layer && layer.layerEvent) { | |||
| !this._layerCache[layer.type] && (this._layerCache[layer.type] = {}) | |||
| layer.layerEvent.fire(LayerEventType.ADD, this) | |||
| this._layerCache[layer.type][layer.id] = layer | |||
| if (!Object(this._layerCache[layer.type]).hasOwnProperty(layer.id)) { | |||
| layer.layerEvent.fire(LayerEventType.ADD, this) | |||
| this._layerCache[layer.type][layer.id] = layer | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * | |||
| * @param {*} layer | |||
| */ | |||
| _removeLayer(layer) { | |||
| if (layer && layer.layerEvent && layer.state !== LayerState.REMOVED) { | |||
| if ( | |||
| layer && | |||
| layer.layerEvent && | |||
| Object(this._layerCache[layer.type]).hasOwnProperty(layer.id) | |||
| ) { | |||
| layer.layerEvent.fire(LayerEventType.REMOVE, this) | |||
| if ( | |||
| this._layerCache[layer.type] && | |||
| this._layerCache[layer.type][layer.id] | |||
| ) { | |||
| delete this._layerCache[layer.type][layer.id] | |||
| } | |||
| delete this._layerCache[layer.type][layer.id] | |||
| } | |||
| } | |||
| /** | |||
| * | |||
| * @param {*} effect | |||
| */ | |||
| _addEffect(effect) { | |||
| if (effect && effect.effectEvent && effect.state !== EffectState.ADDED) { | |||
| if (effect && effect.effectEvent) { | |||
| !this._effectCache[effect.type] && (this._effectCache[effect.type] = {}) | |||
| effect.effectEvent.fire(EffectEventType.ADD, this) | |||
| this._effectCache[effect.type][effect.id] = effect | |||
| if (!Object(this._effectCache[effect.type]).hasOwnProperty(effect.id)) { | |||
| effect.effectEvent.fire(EffectEventType.ADD, this) | |||
| this._effectCache[effect.type][effect.id] = effect | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * | |||
| * @param {*} effect | |||
| */ | |||
| _removeEffect(effect) { | |||
| if (effect && effect.effectEvent && effect.state !== EffectState.REMOVED) { | |||
| if ( | |||
| effect && | |||
| effect.effectEvent && | |||
| Object(this._effectCache[effect.type]).hasOwnProperty(effect.id) | |||
| ) { | |||
| effect.effectEvent.fire(EffectEventType.REMOVE, this) | |||
| if ( | |||
| this._effectCache[effect.type] && | |||
| this._effectCache[effect.type][effect.id] | |||
| ) { | |||
| delete this._effectCache[effect.type][effect.id] | |||
| } | |||
| delete this._effectCache[effect.type][effect.id] | |||
| } | |||
| } | |||
| @@ -2,11 +2,11 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-02-11 21:08:01 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 10:21:31 | |||
| * @Last Modified time: 2020-05-11 17:13:48 | |||
| */ | |||
| import { DomUtil } from '../utils' | |||
| import State from '../state/State' | |||
| import Widget from './Widget' | |||
| import WidgetState from './WidgetState' | |||
| class Attribution extends Widget { | |||
| constructor() { | |||
| @@ -26,7 +26,7 @@ class Attribution extends Widget { | |||
| ` | |||
| this._config = undefined | |||
| this.type = Widget.getWidgetType('attribution') | |||
| this._state = WidgetState.INSTALLED | |||
| this._state = State.INSTALLED | |||
| } | |||
| _installHook() { | |||
| @@ -2,13 +2,13 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-03-19 13:11:12 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 10:23:07 | |||
| * @Last Modified time: 2020-05-11 17:14:02 | |||
| */ | |||
| import { Cesium } from '../../namespace' | |||
| import { DomUtil } from '../utils' | |||
| import State from '../state/State' | |||
| import Widget from './Widget' | |||
| import WidgetState from './WidgetState' | |||
| const svg_out_ring = | |||
| 'm 66.5625,0 0,15.15625 3.71875,0 0,-10.40625 5.5,10.40625 4.375,0 0,-15.15625 -3.71875,0 0,10.40625 L 70.9375,0 66.5625,0 z M 72.5,20.21875 c -28.867432,0 -52.28125,23.407738 -52.28125,52.28125 0,28.87351 23.413818,52.3125 52.28125,52.3125 28.86743,0 52.28125,-23.43899 52.28125,-52.3125 0,-28.873512 -23.41382,-52.28125 -52.28125,-52.28125 z m 0,1.75 c 13.842515,0 26.368948,5.558092 35.5,14.5625 l -11.03125,11 0.625,0.625 11.03125,-11 c 8.9199,9.108762 14.4375,21.579143 14.4375,35.34375 0,13.764606 -5.5176,26.22729 -14.4375,35.34375 l -11.03125,-11 -0.625,0.625 11.03125,11 c -9.130866,9.01087 -21.658601,14.59375 -35.5,14.59375 -13.801622,0 -26.321058,-5.53481 -35.4375,-14.5 l 11.125,-11.09375 c 6.277989,6.12179 14.857796,9.90625 24.3125,9.90625 19.241896,0 34.875,-15.629154 34.875,-34.875 0,-19.245847 -15.633104,-34.84375 -34.875,-34.84375 -9.454704,0 -18.034511,3.760884 -24.3125,9.875 L 37.0625,36.4375 C 46.179178,27.478444 58.696991,21.96875 72.5,21.96875 z m -0.875,0.84375 0,13.9375 1.75,0 0,-13.9375 -1.75,0 z M 36.46875,37.0625 47.5625,48.15625 C 41.429794,54.436565 37.65625,63.027539 37.65625,72.5 c 0,9.472461 3.773544,18.055746 9.90625,24.34375 L 36.46875,107.9375 c -8.96721,-9.1247 -14.5,-21.624886 -14.5,-35.4375 0,-13.812615 5.53279,-26.320526 14.5,-35.4375 z M 72.5,39.40625 c 18.297686,0 33.125,14.791695 33.125,33.09375 0,18.302054 -14.827314,33.125 -33.125,33.125 -18.297687,0 -33.09375,-14.822946 -33.09375,-33.125 0,-18.302056 14.796063,-33.09375 33.09375,-33.09375 z M 22.84375,71.625 l 0,1.75 13.96875,0 0,-1.75 -13.96875,0 z m 85.5625,0 0,1.75 14,0 0,-1.75 -14,0 z M 71.75,108.25 l 0,13.9375 1.71875,0 0,-13.9375 -1.71875,0 z' | |||
| @@ -35,7 +35,7 @@ class Compass extends Widget { | |||
| this._mouseMoveHandle = undefined | |||
| this._mouseUpHandle = undefined | |||
| this.type = Widget.getWidgetType('compass') | |||
| this._state = WidgetState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| _installHook() { | |||
| @@ -2,14 +2,14 @@ | |||
| * @Author: Caven | |||
| * @Date: 2019-12-31 17:32:01 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 10:25:38 | |||
| * @Last Modified time: 2020-05-11 17:14:23 | |||
| */ | |||
| import { Cesium } from '../../namespace' | |||
| import { DomUtil } from '../utils' | |||
| import { MouseEventType } from '../event/EventType' | |||
| import State from '../state/State' | |||
| import Widget from './Widget' | |||
| import WidgetState from './WidgetState' | |||
| class ContextMenu extends Widget { | |||
| constructor() { | |||
| @@ -19,7 +19,7 @@ class ContextMenu extends Widget { | |||
| this._config = {} | |||
| this._positionChangeable = true | |||
| this.type = Widget.getWidgetType('contextmenu') | |||
| this._state = WidgetState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| set config(config) { | |||
| @@ -2,13 +2,13 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-03-15 17:47:42 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 10:28:12 | |||
| * @Last Modified time: 2020-05-11 17:14:40 | |||
| */ | |||
| import { Cesium } from '../../namespace' | |||
| import { DomUtil, Util } from '../utils' | |||
| import State from '../state/State' | |||
| import Widget from './Widget' | |||
| import WidgetState from './WidgetState' | |||
| const DEF_OPTS = { | |||
| animation: false, | |||
| @@ -33,7 +33,7 @@ class HawkeyeMap extends Widget { | |||
| this._baseLayer = undefined | |||
| this._delegate = undefined | |||
| this.type = Widget.getWidgetType('hawkeye_map') | |||
| this._state = WidgetState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| _prepareDelegate() { | |||
| @@ -2,10 +2,10 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-15 19:17:52 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 10:20:27 | |||
| * @Last Modified time: 2020-05-11 17:13:28 | |||
| */ | |||
| import { Cesium } from '../../namespace' | |||
| import WidgetState from './WidgetState' | |||
| import State from '../state/State' | |||
| import WidgetType from './WidgetType' | |||
| class Widget { | |||
| @@ -21,7 +21,7 @@ class Widget { | |||
| set enable(enable) { | |||
| this._enable = enable | |||
| this._state = this._enable ? WidgetState.ENABLED : WidgetState.DISABLED | |||
| this._state = this._enable ? State.ENABLED : State.DISABLED | |||
| this._enableHook && this._enableHook() | |||
| } | |||
| @@ -62,7 +62,7 @@ class Widget { | |||
| */ | |||
| install(viewer) { | |||
| this._viewer = viewer | |||
| this._state = WidgetState.INSTALLED | |||
| this._state = State.INSTALLED | |||
| /** | |||
| * add postRender Listener | |||
| */ | |||
| @@ -1,14 +0,0 @@ | |||
| /* | |||
| * @Author: Caven | |||
| * @Date: 2020-05-10 10:16:29 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 10:17:39 | |||
| */ | |||
| const WidgetState = { | |||
| INITIALIZED: 'initialized', | |||
| INSTALLED: 'installed', | |||
| ENABLED: 'enabled', | |||
| DISABLED: 'disabled' | |||
| } | |||
| export default WidgetState | |||
| @@ -2,7 +2,7 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-05-06 13:25:36 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-09 22:37:46 | |||
| * @Last Modified time: 2020-05-11 17:15:05 | |||
| */ | |||
| import Widget from './Widget' | |||
| @@ -2,10 +2,11 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-02-20 13:26:49 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 11:16:13 | |||
| * @Last Modified time: 2020-05-11 17:18:09 | |||
| */ | |||
| import Effect from './Effect' | |||
| import EffectState from './EffectState' | |||
| const State = DC.State | |||
| class BloomEffect extends Effect { | |||
| constructor(id) { | |||
| @@ -17,7 +18,7 @@ class BloomEffect extends Effect { | |||
| this._sigma = 2 | |||
| this._stepSize = 1 | |||
| this.type = Effect.getEffectType('bloom') | |||
| this._state = EffectState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| set contrast(contrast) { | |||
| @@ -2,14 +2,15 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-02-24 14:11:22 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 11:20:04 | |||
| * @Last Modified time: 2020-05-11 17:18:29 | |||
| */ | |||
| import Effect from './Effect' | |||
| import EffectState from './EffectState' | |||
| const { Cesium } = DC.Namespace | |||
| const State = DC.State | |||
| const CircleScanShader = require('../shader/CircleScanShader.glsl') | |||
| class CircleScanEffect extends Effect { | |||
| @@ -24,7 +25,7 @@ class CircleScanEffect extends Effect { | |||
| this._duration = Cesium.defaultValue(duration, 1) * 1e3 | |||
| this._addable = true | |||
| this.type = Effect.getEffectType('circle_scan') | |||
| this._state = EffectState.INITIALIZED | |||
| this._state = State.INITIALIZED | |||
| } | |||
| _mountedHook() { | |||
| @@ -2,13 +2,15 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-14 18:33:33 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 11:19:14 | |||
| * @Last Modified time: 2020-05-11 17:19:17 | |||
| */ | |||
| import { EffectEvent } from '../../core/event' | |||
| import { EffectEventType } from '../../core/event/EventType' | |||
| import EffectType from './EffectType' | |||
| const EffectEventType = DC.EffectEventType | |||
| class Effect { | |||
| constructor(id) { | |||
| this._id = id || DC.Util.uuid() | |||
| @@ -2,12 +2,12 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-14 18:22:10 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 10:54:57 | |||
| * @Last Modified time: 2020-05-11 17:24:53 | |||
| */ | |||
| const install = function(DC) { | |||
| if (!DC) { | |||
| throw new Error('DC.Plugins: Missing DC Base SDK') | |||
| if (!DC || !DC.ready) { | |||
| throw new Error('Plugins: Missing DC Core ') | |||
| } | |||
| if (window.mapv) { | |||
| DC.Namespace['mapv'] = window.mapv | |||