瀏覽代碼

update dependencies

tags/3.0.0
Caven Chen 2 年之前
父節點
當前提交
fde7366fda
共有 100 個檔案被更改,包括 1102 行新增799 行删除
  1. 3
    1
      .eslintrc
  2. 2
    0
      README.md
  3. 10
    3
      gulpfile.js
  4. 2
    0
      package.json
  5. 43
    11
      src/index.js
  6. 76
    0
      src/modules/chart/ChartLayer.js
  7. 84
    0
      src/modules/chart/GLMapCoordSys.js
  8. 18
    0
      src/modules/chart/GLMapModel.js
  9. 26
    0
      src/modules/chart/GLMapView.js
  10. 24
    0
      src/modules/chart/index.js
  11. 43
    43
      src/modules/exts/BaseLayerPicker.js
  12. 155
    72
      src/modules/exts/Viewer.js
  13. 41
    41
      src/modules/material/type/circle.js
  14. 9
    9
      src/modules/material/type/cylinder.js
  15. 9
    9
      src/modules/material/type/ellipsoid.js
  16. 1
    1
      src/modules/math/area.js
  17. 2
    2
      src/modules/math/bounds.js
  18. 3
    3
      src/modules/math/center.js
  19. 2
    2
      src/modules/math/distance.js
  20. 3
    3
      src/modules/math/heading.js
  21. 1
    1
      src/modules/math/midCartesian.js
  22. 4
    4
      src/modules/math/midPosition.js
  23. 2
    2
      src/modules/measure/draw/DrawPolygon.js
  24. 2
    2
      src/modules/measure/draw/DrawPolyline.js
  25. 9
    9
      src/modules/measure/type/Angle.js
  26. 5
    5
      src/modules/overlay/Overlay.js
  27. 9
    13
      src/modules/overlay/custom/CustomBillboard.js
  28. 8
    11
      src/modules/overlay/custom/CustomLabel.js
  29. 5
    5
      src/modules/overlay/dynamic/DynamicBillboard.js
  30. 5
    6
      src/modules/overlay/dynamic/DynamicModel.js
  31. 5
    5
      src/modules/overlay/dynamic/DynamicOverlay.js
  32. 10
    13
      src/modules/overlay/html/DivIcon.js
  33. 6
    9
      src/modules/overlay/model/Model.js
  34. 12
    15
      src/modules/overlay/model/Tileset.js
  35. 6
    7
      src/modules/overlay/plot/AttackArrow.js
  36. 5
    6
      src/modules/overlay/plot/DoubleArrow.js
  37. 6
    7
      src/modules/overlay/plot/FineArrow.js
  38. 5
    6
      src/modules/overlay/plot/GatheringPlace.js
  39. 6
    7
      src/modules/overlay/plot/TailedAttackArrow.js
  40. 5
    8
      src/modules/overlay/primitive/BillboardPrimitive.js
  41. 3
    3
      src/modules/overlay/primitive/BounceBillboardPrimitive.js
  42. 3
    3
      src/modules/overlay/primitive/BounceLabelPrimitive.js
  43. 5
    6
      src/modules/overlay/primitive/CloudPrimitive.js
  44. 11
    11
      src/modules/overlay/primitive/DiffuseWallPrimitive.js
  45. 14
    15
      src/modules/overlay/primitive/ElecEllipsoidPrimitive.js
  46. 10
    11
      src/modules/overlay/primitive/FlowLinePrimitive.js
  47. 5
    7
      src/modules/overlay/primitive/LabelPrimitive.js
  48. 24
    28
      src/modules/overlay/primitive/LightCylinderPrimitive.js
  49. 8
    11
      src/modules/overlay/primitive/ModelCollectionPrimitive.js
  50. 5
    7
      src/modules/overlay/primitive/ModelPrimitive.js
  51. 7
    8
      src/modules/overlay/primitive/PointPrimitive.js
  52. 6
    7
      src/modules/overlay/primitive/PolylinePrimitive.js
  53. 10
    12
      src/modules/overlay/primitive/ScanCirclePrimitive.js
  54. 11
    12
      src/modules/overlay/primitive/TrailLinePrimitive.js
  55. 13
    16
      src/modules/overlay/primitive/VideoPrimitive.js
  56. 12
    13
      src/modules/overlay/primitive/WaterPrimitive.js
  57. 6
    6
      src/modules/overlay/vector/Billboard.js
  58. 8
    8
      src/modules/overlay/vector/Box.js
  59. 7
    7
      src/modules/overlay/vector/Circle.js
  60. 8
    9
      src/modules/overlay/vector/Corridor.js
  61. 5
    5
      src/modules/overlay/vector/Cylinder.js
  62. 5
    5
      src/modules/overlay/vector/Ellipse.js
  63. 5
    5
      src/modules/overlay/vector/Ellipsoid.js
  64. 6
    6
      src/modules/overlay/vector/Label.js
  65. 8
    8
      src/modules/overlay/vector/Plane.js
  66. 7
    7
      src/modules/overlay/vector/Point.js
  67. 10
    10
      src/modules/overlay/vector/Polygon.js
  68. 10
    11
      src/modules/overlay/vector/Polyline.js
  69. 8
    9
      src/modules/overlay/vector/PolylineVolume.js
  70. 6
    6
      src/modules/overlay/vector/Rectangle.js
  71. 8
    9
      src/modules/overlay/vector/Wall.js
  72. 5
    6
      src/modules/parse/Parse.js
  73. 4
    4
      src/modules/plot/Plot.js
  74. 3
    4
      src/modules/plot/draw/Draw.js
  75. 9
    9
      src/modules/plot/draw/DrawAttackArrow.js
  76. 9
    10
      src/modules/plot/draw/DrawBillboard.js
  77. 11
    11
      src/modules/plot/draw/DrawCircle.js
  78. 10
    10
      src/modules/plot/draw/DrawDoubleArrow.js
  79. 10
    9
      src/modules/plot/draw/DrawFineArrow.js
  80. 10
    9
      src/modules/plot/draw/DrawGatheringPlace.js
  81. 9
    9
      src/modules/plot/draw/DrawPoint.js
  82. 10
    10
      src/modules/plot/draw/DrawPolygon.js
  83. 9
    9
      src/modules/plot/draw/DrawPolyline.js
  84. 10
    10
      src/modules/plot/draw/DrawRectangle.js
  85. 9
    9
      src/modules/plot/draw/DrawTailedAttackArrow.js
  86. 5
    5
      src/modules/plot/edit/Edit.js
  87. 1
    1
      src/modules/plot/edit/EditAttackArrow.js
  88. 2
    2
      src/modules/plot/edit/EditBillboard.js
  89. 7
    7
      src/modules/plot/edit/EditCircle.js
  90. 1
    1
      src/modules/plot/edit/EditDoubleArrow.js
  91. 1
    3
      src/modules/plot/edit/EditFineArrow.js
  92. 1
    1
      src/modules/plot/edit/EditGatheringPlace.js
  93. 2
    2
      src/modules/plot/edit/EditPoint.js
  94. 10
    10
      src/modules/plot/edit/EditPolygon.js
  95. 8
    8
      src/modules/plot/edit/EditPolyline.js
  96. 11
    9
      src/modules/plot/edit/EditRectangle.js
  97. 1
    1
      src/modules/plot/edit/EditTailedAttackArrow.js
  98. 4
    4
      src/modules/plot/graphics/AttackArrowGraphics.js
  99. 4
    4
      src/modules/plot/graphics/DoubleArrowGraphics.js
  100. 0
    0
      src/modules/plot/graphics/FineArrowGraphics.js

+ 3
- 1
.eslintrc 查看文件

"no-trailing-spaces": 0, "no-trailing-spaces": 0,
"no-mixed-spaces-and-tabs": 0, "no-mixed-spaces-and-tabs": 0,
"space-before-function-paren": [0, "always"], "space-before-function-paren": [0, "always"],
"no-multiple-empty-lines": 0
"no-multiple-empty-lines": 0,
"no-prototype-builtins": 0,
"no-loss-of-precision":0
} }
} }

+ 2
- 0
README.md 查看文件

# DC-SDK

<p> <p>
<img src="https://img.shields.io/github/actions/workflow/status/dvgis/dc-sdk/build.yml"/> <img src="https://img.shields.io/github/actions/workflow/status/dvgis/dc-sdk/build.yml"/>
<img src="https://img.shields.io/badge/license-Apache%202-blue"/> <img src="https://img.shields.io/badge/license-Apache%202-blue"/>

+ 10
- 3
gulpfile.js 查看文件

import { babel } from '@rollup/plugin-babel' import { babel } from '@rollup/plugin-babel'
import startServer from './server.js' import startServer from './server.js'
import { uglify } from 'rollup-plugin-uglify' import { uglify } from 'rollup-plugin-uglify'
import inlineImage from 'esbuild-plugin-inline-image'
import { glsl } from 'esbuild-plugin-glsl'


const obfuscatorConfig = { const obfuscatorConfig = {
compact: true, //压缩代码 compact: true, //压缩代码
sourcemap: false, sourcemap: false,
write: true, write: true,
logLevel: 'info', logLevel: 'info',
plugins: [
inlineImage({
limit: -1,
}),
glsl(),
],
} }


const packageJson = fse.readJsonSync('./package.json') const packageJson = fse.readJsonSync('./package.json')


async function buildNamespace(options) { async function buildNamespace(options) {
const bundle = await rollup({ const bundle = await rollup({
input: 'src/namespace.js',
input: 'src/namespace/libs.js',
plugins: [ plugins: [
commonjs(), commonjs(),
resolve({ preferBuiltins: true }), resolve({ preferBuiltins: true }),


const exportNamespace = ` const exportNamespace = `
export const __namespace = { export const __namespace = {
Cesium: exports.Cesium,
turf: exports.turf
Cesium: exports.Cesium
} }
` `



+ 2
- 0
package.json 查看文件

"@turf/turf": "^6.5.0", "@turf/turf": "^6.5.0",
"chalk": "^5.2.0", "chalk": "^5.2.0",
"esbuild": "^0.17.18", "esbuild": "^0.17.18",
"esbuild-plugin-glsl": "^1.2.1",
"esbuild-plugin-inline-image": "^0.0.9",
"eslint": "^8.40.0", "eslint": "^8.40.0",
"eslint-config-prettier": "^8.8.0", "eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5", "eslint-plugin-import": "^2.27.5",

+ 43
- 11
src/index.js 查看文件

/** /**
@Author: Caven Chen @Author: Caven Chen
**/ **/
import { registerLib } from './global-api/lib-utils.js'
import { getLib, registerLib } from './global-api/lib-utils.js'


export { registerLib, getLib } from './global-api/lib-utils.js' export { registerLib, getLib } from './global-api/lib-utils.js'


} }


export function ready(options = {}) { export function ready(options = {}) {
if (options.baseUrl) {
this.config.baseUrl = options.baseUrl
if (options['baseUrl']) {
this.config.baseUrl = options['baseUrl']
} }
if (options.accessToken) {
this.config.accessToken = options.accessToken
if (options['accessToken']) {
this.config.accessToken = options['accessToken']
} }
const { Cesium, turf } = this['__namespace']
registerLib('Cesium', Cesium)
registerLib('turf', turf)

if (options['Cesium']) {
registerLib('Cesium', options['Cesium'])
} else {
registerLib('Cesium', this['__namespace']['Cesium'])
}

// if (options['echarts']) {
// registerLib('echarts', options['echarts'])
// }

// if (options['turf']) {
// registerLib('turf', options['turf'])
// }

this['__cmdOut'] && this['__cmdOut']() this['__cmdOut'] && this['__cmdOut']()

return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const Cesium = getLib('Cesium')
if (!Cesium) {
throw new Error('missing Cesium Lib')
}
this.config.baseUrl && Cesium.buildModuleUrl.setBaseUrl(this.config.baseUrl)
// register common modules
const modules = require('./modules') const modules = require('./modules')
this.config.baseUrl &&
Cesium &&
Cesium.buildModuleUrl.setBaseUrl(this.config.baseUrl)
Object.keys(modules).forEach((key) => { Object.keys(modules).forEach((key) => {
this[key] = modules[key] this[key] = modules[key]
}) })

// register chart module
if (getLib('echarts')) {
const modules = require('./modules/chart')
Object.keys(modules).forEach((key) => {
this[key] = modules[key]
})
}

// register turf module
if (getLib('turf')) {
// todo
}

resolve() resolve()
}).catch((e) => {
throw new Error(e.message)
}) })
} }

+ 76
- 0
src/modules/chart/ChartLayer.js 查看文件

/**
@author : Caven Chen
@date : 2023-05-23
*/

import { echarts } from '../../namespace'
import { Layer } from '../layer'
const { init } = echarts

class ChartLayer extends Layer {
constructor(id, viewer) {
super(id)
this._viewer.canvas.setAttribute('tabIndex', '0')
this._chartEl = this._createChartElement()
this._chart = init(this._chartEl)
this._show = true
Object(this._chart.getZr()).viewer = viewer
}

get id() {
return this._id
}

set show(show) {
this._show = show
this._chartEl.style.visibility = show ? 'visible' : 'hidden'
}

get show() {
return this._show
}

/**
*
* @returns {HTMLDivElement}
* @private
*/
_createChartElement() {
let canvas = this._viewer.scene.canvas
let el = document.createElement('div')
el.setAttribute('id', this._id)
el.style.cssText = `position:absolute; top:0; left:0; width: ${canvas.clientWidth}px; height: ${canvas.clientHeight}px;pointer-events:none;`
this._viewer.container.appendChild(el)
return el
}

/**
*
* @param option
* @returns {ChartLayer}
*/
setOption(option = {}) {
this._chart.setOption({ ...option, GLMap: {}, animation: false })
return this
}

/**
*
* @returns {ChartLayer}
*/
clear() {
this._chart.clear()
return this
}

/**
*
* @returns {ChartLayer}
*/
resize() {
this._chart.resize()
return this
}
}

export default ChartLayer

+ 84
- 0
src/modules/chart/GLMapCoordSys.js 查看文件

/**
@author : Caven Chen
@date : 2023-05-23
*/

import { echarts, Cesium } from '../../namespace'
const { Cartesian3, Ellipsoid, Math: CesiumMath } = Cesium
const { graphic, matrix } = echarts

class GLMapCoordSys {
constructor(api) {
this._api = api
this._viewer = Object(api.getZr()).viewer
this._mapOffset = [0, 0]
this.dimensions = ['lng', 'lat']
}

getViewer() {
return this._viewer
}

setMapOffset(mapOffset) {
this._mapOffset = mapOffset
return this
}

dataToPoint(data) {
let result = []
let cartesian3 = Cartesian3.fromDegrees(data[0], data[1])
if (!cartesian3) {
return result
}
let up = Ellipsoid.WGS84.geodeticSurfaceNormal(cartesian3, new Cartesian3())
let cd = this._viewer.camera.direction
if (Cartesian3.dot(up, cd) >= 0) {
return result
}
let coords = this._viewer.scene.cartesianToCanvasCoordinates(cartesian3)
if (!coords) {
return result
}
return [coords.x - this._mapOffset[0], coords.y - this._mapOffset[1]]
}

pointToData(point) {
let ellipsoid = this._viewer.scene.globe.ellipsoid
let cartesian3 = new Cartesian3(
point[0] + this._mapOffset[0],
point[1] + this._mapOffset[1],
0
)
let cartographic = ellipsoid.cartesianToCartographic(cartesian3)
return [
CesiumMath.toDegrees(cartographic.longitude),
CesiumMath.toDegrees(cartographic.latitude),
]
}

getViewRect() {
let api = this._api
return new graphic.BoundingRect(0, 0, api.getWidth(), api.getHeight())
}

getRoamTransform() {
return matrix.create()
}

static create(ecModel, api) {
let coordinateSys = undefined
ecModel.eachComponent('GLMap', function (model) {
coordinateSys = new GLMapCoordSys(api)
coordinateSys.setMapOffset(model['__mapOffset'] || [0, 0])
model.coordinateSystem = coordinateSys
})
ecModel.eachSeries(function (model) {
'GLMap' === model.get('coordinateSystem') &&
(model.coordinateSystem = coordinateSys)
})
}
}

GLMapCoordSys.dimensions = ['lng', 'lat']

export default GLMapCoordSys

+ 18
- 0
src/modules/chart/GLMapModel.js 查看文件

/**
@author : Caven Chen
@date : 2023-05-23
*/

import { echarts } from '../../namespace'

const { extendComponentModel } = echarts

extendComponentModel({
type: 'GLMap',
getViewer() {
return Object(this.getZr()).viewer
},
defaultOption: {
roam: false,
},
})

+ 26
- 0
src/modules/chart/GLMapView.js 查看文件

/**
@Author: Caven Chen
**/

import { echarts } from '../../namespace'

const { extendComponentView } = echarts

extendComponentView({
type: 'GLMap',
init: function (ecModel, api) {
this.api = api
let viewer = api.getZr().viewer
viewer.scene.postRender.addEventListener(this.moveHandler, this)
},
moveHandler: function (t, e) {
this.api.dispatchAction({
type: 'GLMapRoam',
})
},
render: function (t, e, i) {},
dispose: function (t) {
let viewer = this.api.getZr().viewer
viewer.scene.postRender.removeEventListener(this.moveHandler, this)
},
})

+ 24
- 0
src/modules/chart/index.js 查看文件

/**
@Author: Caven Chen
**/

import { echarts } from '../../namespace'

import './GLMapModel'
import './GLMapView'
import GLMapCoordSys from './GLMapCoordSys'
import ChartLayer from './ChartLayer.js'

const { registerAction, registerCoordinateSystem } = echarts

registerCoordinateSystem('GLMap', GLMapCoordSys)
registerAction(
{
type: 'GLMapRoam',
event: 'GLMapRoam',
update: 'updateLayout',
},
function (payload, ecModel) {}
)

export { ChartLayer }

+ 43
- 43
src/modules/exts/BaseLayerPicker.js 查看文件

/** /**
@author : Caven Chen
@date : 2023-05-09
*/
@Author: Caven Chen
**/


import { Cesium } from '../../namespace/index.js' import { Cesium } from '../../namespace/index.js'
const { DeveloperError, EllipsoidTerrainProvider } = Cesium

const { EllipsoidTerrainProvider } = Cesium


class BaseLayerPicker { class BaseLayerPicker {
constructor(options) { constructor(options) {
if (!options.globe) { if (!options.globe) {
throw new DeveloperError('globe is required')
throw new Error('globe is required')
} }
this._globe = options.globe this._globe = options.globe
this._imageryProviders = []
this._imageryLayers = []
this._terrainProviders = [] this._terrainProviders = []
this._selectedImagery = undefined
this._selectedImageryLayer = undefined
this._selectedTerrain = undefined this._selectedTerrain = undefined
this._count = 0
} }


set selectedImagery(imagery) {
if (!imagery || !imagery.providers) {
new DeveloperError('imagery format error')
set selectedImageryLayer(imageryLayer) {
if (!imageryLayer || !imageryLayer.layers) {
new Error('imagery format error')
} }
const imageryLayers = this._globe.imageryLayers
if (!this._selectedImagery) {
for (let i = imagery.providers.length - 1; i >= 0; i--) {
imageryLayers.addImageryProvider(imagery.providers[i], 0)
let imageryLayers = this._globe.imageryLayers
if (!this._selectedImageryLayer) {
for (let i = imageryLayer.layers.length - 1; i >= 0; i--) {
imageryLayers.add(imageryLayer.layers[i], 0)
} }
} else if ( } else if (
this._selectedImagery &&
imagery.id !== this._selectedImagery.id
this._selectedImageryLayer &&
imageryLayer.id !== this._selectedImageryLayer.id
) { ) {
imageryLayers.removeAll() imageryLayers.removeAll()
for (let i = imagery.providers.length - 1; i >= 0; i--) {
imageryLayers.addImageryProvider(imagery.providers[i], 0)
for (let i = imageryLayer.layers.length - 1; i >= 0; i--) {
imageryLayers.addImageryProvider(imageryLayer.layers[i], 0)
} }
} }
this._selectedImagery = imagery
this._selectedImageryLayer = imageryLayer
} }


get selectedImagery() {
return this._selectedImagery
get selectedImageryLayer() {
return this._selectedImageryLayer
} }


set selectedTerrain(terrian) {
if (this.selectedImagery !== terrian) {
set selectedTerrain(terrain) {
if (this.selectedTerrain !== terrain) {
this._globe.depthTestAgainstTerrain = !( this._globe.depthTestAgainstTerrain = !(
terrian instanceof EllipsoidTerrainProvider
terrain instanceof EllipsoidTerrainProvider
) )
this._globe.terrainProvider = terrian
this._selectedTerrain = terrian
this._globe.terrainProvider = terrain
this._selectedTerrain = terrain
} }
} }




/** /**
* *
* @param provider
* @param imageryLayer
* @returns {BaseLayerPicker} * @returns {BaseLayerPicker}
*/ */
addImageryProvider(provider) {
let providers = []
let len = this._imageryProviders.length + 1
if (Array.isArray(provider)) {
providers = provider.slice(0)
addImageryLayer(imageryLayer) {
let imageryLayers = []
if (Array.isArray(imageryLayer)) {
imageryLayers = imageryLayer.slice(0)
} else { } else {
providers = [provider]
imageryLayers = [imageryLayer]
} }
this._imageryProviders.push({
id: `dc-imagery-${len}`,
providers,
this._count++
this._imageryLayers.push({
id: `dc-imagery-${this._count}`,
layers: imageryLayers,
}) })
return this return this
} }
* @param index * @param index
* @returns {BaseLayerPicker} * @returns {BaseLayerPicker}
*/ */
changeImagery(index) {
if (index > this._imageryProviders.length - 1) {
new DeveloperError('index error ')
return this
changeImageryLayer(index) {
if (index > this._imageryLayers.length - 1) {
throw new Error('index error')
} }
this.selectedImagery = this._imageryProviders[index]
this.selectedImageryLayer = this._imageryLayers[index]
return this return this
} }


*/ */
changeTerrain(index) { changeTerrain(index) {
if (index > this._terrainProviders.length - 1) { if (index > this._terrainProviders.length - 1) {
new DeveloperError('index error ')
return this
throw new Error('index error')
} }
this.selectedTerrain = this._terrainProviders[index] this.selectedTerrain = this._terrainProviders[index]
return this
} }
} }



+ 155
- 72
src/modules/exts/Viewer.js 查看文件

/** /**
@author : Caven Chen @author : Caven Chen
@date : 2023-05-07
@date : 2023-05-23
*/ */
import { Cesium } from '../../namespace'
import { Cesium } from '../../namespace/index.js'

const { const {
BoundingSphere, BoundingSphere,
BoundingSphereState, BoundingSphereState,
} }


/** /**
* @typedef {object} Viewer.ConstructorOptions
*
* Initialization options for the Viewer constructor
* *
* @param container
* @param options
* @property {ImageryProvider|false} [imageryProvider=createWorldImagery()] The imagery provider to use. This value is only valid if `baseLayerPicker` is set to false. Deprecated.
* @property {ImageryLayer|false} [baseLayer=ImageryLayer.fromWorldImagery()] The bottommost imagery layer applied to the globe. If set to <code>false</code>, no imagery provider will be added. This value is only valid if `baseLayerPicker` is set to false.
* @property {TerrainProvider} [terrainProvider=new EllipsoidTerrainProvider()] The terrain provider to use
* @property {Terrain} [terrain] A terrain object which handles asynchronous terrain provider. Can only specify if options.terrainProvider is undefined.
* @property {SkyBox|false} [skyBox] The skybox used to render the stars. When <code>undefined</code>, the default stars are used. If set to <code>false</code>, no skyBox, Sun, or Moon will be added.
* @property {SkyAtmosphere|false} [skyAtmosphere] Blue sky, and the glow around the Earth's limb. Set to <code>false</code> to turn it off.
* @property {Element|string} [fullscreenElement=document.body] The element or id to be placed into fullscreen mode when the full screen button is pressed.
* @property {boolean} [useDefaultRenderLoop=true] True if this widget should control the render loop, false otherwise.
* @property {number} [targetFrameRate] The target frame rate when using the default render loop.
* @property {boolean} [showRenderLoopErrors=true] If true, this widget will automatically display an HTML panel to the user containing the error, if a render loop error occurs.
* @property {boolean} [useBrowserRecommendedResolution=true] If true, render at the browser's recommended resolution and ignore <code>window.devicePixelRatio</code>.
* @property {boolean} [automaticallyTrackDataSourceClocks=true] If true, this widget will automatically track the clock settings of newly added DataSources, updating if the DataSource's clock changes. Set this to false if you want to configure the clock independently.
* @property {ContextOptions} [contextOptions] Context and WebGL creation properties passed to {@link Scene}.
* @property {SceneMode} [sceneMode=SceneMode.SCENE3D] The initial scene mode.
* @property {MapProjection} [mapProjection=new GeographicProjection()] The map projection to use in 2D and Columbus View modes.
* @property {Globe|false} [globe=new Globe(mapProjection.ellipsoid)] The globe to use in the scene. If set to <code>false</code>, no globe will be added.
* @property {boolean} [orderIndependentTranslucency=true] If true and the configuration supports it, use order independent translucency.
* @property {Element|string} [creditContainer] The DOM element or ID that will contain the {@link CreditDisplay}. If not specified, the credits are added to the bottom of the widget itself.
* @property {Element|string} [creditViewport] The DOM element or ID that will contain the credit pop up created by the {@link CreditDisplay}. If not specified, it will appear over the widget itself.
* @property {DataSourceCollection} [dataSources=new DataSourceCollection()] The collection of data sources visualized by the widget. If this parameter is provided,
* the instance is assumed to be owned by the caller and will not be destroyed when the viewer is destroyed.
* @property {boolean} [shadows=false] Determines if shadows are cast by light sources.
* @property {ShadowMode} [terrainShadows=ShadowMode.RECEIVE_ONLY] Determines if the terrain casts or receives shadows from light sources.
* @property {MapMode2D} [mapMode2D=MapMode2D.INFINITE_SCROLL] Determines if the 2D map is rotatable or can be scrolled infinitely in the horizontal direction.
* @property {boolean} [projectionPicker=false] If set to true, the ProjectionPicker widget will be created.
* @property {boolean} [blurActiveElementOnCanvasFocus=true] If true, the active element will blur when the viewer's canvas is clicked. Setting this to false is useful for cases when the canvas is clicked only for retrieving position or an entity data without actually meaning to set the canvas to be the active element.
* @property {boolean} [requestRenderMode=false] If true, rendering a frame will only occur when needed as determined by changes within the scene. Enabling reduces the CPU/GPU usage of your application and uses less battery on mobile, but requires using {@link Scene#requestRender} to render a new frame explicitly in this mode. This will be necessary in many cases after making changes to the scene in other parts of the API. See {@link https://cesium.com/blog/2018/01/24/cesium-scene-rendering-performance/|Improving Performance with Explicit Rendering}.
* @property {number} [maximumRenderTimeChange=0.0] If requestRenderMode is true, this value defines the maximum change in simulation time allowed before a render is requested. See {@link https://cesium.com/blog/2018/01/24/cesium-scene-rendering-performance/|Improving Performance with Explicit Rendering}.
* @property {number} [depthPlaneEllipsoidOffset=0.0] Adjust the DepthPlane to address rendering artefacts below ellipsoid zero elevation.
* @property {number} [msaaSamples=1] If provided, this value controls the rate of multisample antialiasing. Typical multisampling rates are 2, 4, and sometimes 8 samples per pixel. Higher sampling rates of MSAA may impact performance in exchange for improved visual quality. This value only applies to WebGL2 contexts that support multisample render targets.
*/

/**
* A base widget for building applications. It composites all of the standard Cesium widgets into one reusable package.
* The widget can always be extended by using mixins, which add functionality useful for a variety of applications.
*
* @alias Viewer
* @constructor * @constructor
*
* @param {Element|string} container The DOM element or ID that will contain the widget.
* @param {Viewer.ConstructorOptions} [options] Object describing initialization options
*
* @exception {DeveloperError} Element with id "container" does not exist in the document.
* @exception {DeveloperError} options.selectedImageryProviderViewModel is not available when not using the BaseLayerPicker widget, specify options.baseLayer instead.
* @exception {DeveloperError} options.selectedTerrainProviderViewModel is not available when not using the BaseLayerPicker widget, specify options.terrainProvider instead.
*
* @see Animation
* @see BaseLayerPicker
* @see CesiumWidget
* @see FullscreenButton
* @see HomeButton
* @see SceneModePicker
* @see Timeline
* @see viewerDragDropMixin
*
* @demo {@link https://sandcastle.cesium.com/index.html?src=Hello%20World.html|Cesium Sandcastle Hello World Demo}
*
* @example
* // Initialize the viewer widget with several custom options and mixins.
* try {
* const viewer = new Cesium.Viewer("cesiumContainer", {
* // Start in Columbus Viewer
* sceneMode: Cesium.SceneMode.COLUMBUS_VIEW,
* // Use Cesium World Terrain
* terrain: Cesium.Terrain.fromWorldTerrain(),
* // Use OpenStreetMaps
* baseLayer: new Cesium.ImageryLayer(OpenStreetMapImageryProvider({
* url: "https://a.tile.openstreetmap.org/"
* })),
* skyBox: new Cesium.SkyBox({
* sources: {
* positiveX: "stars/TychoSkymapII.t3_08192x04096_80_px.jpg",
* negativeX: "stars/TychoSkymapII.t3_08192x04096_80_mx.jpg",
* positiveY: "stars/TychoSkymapII.t3_08192x04096_80_py.jpg",
* negativeY: "stars/TychoSkymapII.t3_08192x04096_80_my.jpg",
* positiveZ: "stars/TychoSkymapII.t3_08192x04096_80_pz.jpg",
* negativeZ: "stars/TychoSkymapII.t3_08192x04096_80_mz.jpg"
* }
* }),
* // Show Columbus View map with Web Mercator projection
* mapProjection: new Cesium.WebMercatorProjection()
* });
* } catch (error) {
* console.log(error);
* }
*
* // Add basic drag and drop functionality
* viewer.extend(Cesium.viewerDragDropMixin);
*
* // Show a pop-up alert if we encounter an error when processing a dropped file
* viewer.dropError.addEventListener(function(dropHandler, name, error) {
* console.log(error);
* window.alert(error);
* });
*/ */
function Viewer(container, options) { function Viewer(container, options) {
//>>includeStart('debug', pragmas.debug); //>>includeStart('debug', pragmas.debug);
container = getElement(container) container = getElement(container)
options = defaultValue(options, defaultValue.EMPTY_OBJECT) options = defaultValue(options, defaultValue.EMPTY_OBJECT)


//>>includeEnd('debug')
const viewerContainer = document.createElement('div') const viewerContainer = document.createElement('div')
viewerContainer.className = 'dc-viewer'
container.appendChild(viewerContainer)

// Cesium widget container
const cesiumWidgetContainer = document.createElement('div')
cesiumWidgetContainer.className = 'dc-viewer-widget-container'
viewerContainer.appendChild(cesiumWidgetContainer)


// Bottom container
const bottomContainer = document.createElement('div') const bottomContainer = document.createElement('div')
bottomContainer.className = 'dc-viewer-bottom'


const scene3DOnly = defaultValue(options.scene3DOnly, false) const scene3DOnly = defaultValue(options.scene3DOnly, false)


} }


// Cesium widget // Cesium widget
const cesiumWidget = new CesiumWidget(cesiumWidgetContainer, {
const cesiumWidget = new CesiumWidget(container, {
baseLayer: false, baseLayer: false,
clock: clock, clock: clock,
skyBox: options.skyBox, skyBox: options.skyBox,
targetFrameRate: options.targetFrameRate, targetFrameRate: options.targetFrameRate,
showRenderLoopErrors: options.showRenderLoopErrors, showRenderLoopErrors: options.showRenderLoopErrors,
useBrowserRecommendedResolution: options.useBrowserRecommendedResolution, useBrowserRecommendedResolution: options.useBrowserRecommendedResolution,
creditContainer: defined(options.creditContainer)
? options.creditContainer
: bottomContainer,
creditViewport: options.creditViewport,
scene3DOnly: scene3DOnly, scene3DOnly: scene3DOnly,
shadows: options.shadows, shadows: options.shadows,
terrainShadows: options.terrainShadows, terrainShadows: options.terrainShadows,
msaaSamples: options.msaaSamples, msaaSamples: options.msaaSamples,
}) })


cesiumWidget.container.firstChild.className = 'dc-widget'
cesiumWidget.scene.backgroundColor = Color.TRANSPARENT cesiumWidget.scene.backgroundColor = Color.TRANSPARENT
cesiumWidget.scene.screenSpaceCameraController.maximumZoomDistance = 40489014.0

let childrens = cesiumWidget.creditViewport.children


for (let i = 0; i < childrens.length; i++) {
if (!(childrens[i] instanceof HTMLCanvasElement)) {
cesiumWidget.creditViewport.removeChild(childrens[i])
}
while (
cesiumWidget.creditViewport.hasChildNodes() &&
!(cesiumWidget.creditViewport.lastChild instanceof HTMLCanvasElement)
) {
cesiumWidget.creditViewport.removeChild(
cesiumWidget.creditViewport.lastChild
)
} }


cesiumWidget.creditViewport.className = 'dc-viewer-canvas'

let dataSourceCollection = options.dataSources let dataSourceCollection = options.dataSources
let destroyDataSourceCollection = false let destroyDataSourceCollection = false
if (!defined(dataSourceCollection)) { if (!defined(dataSourceCollection)) {


// Main Toolbar // Main Toolbar
const toolbar = document.createElement('div') const toolbar = document.createElement('div')
toolbar.className = 'dc-viewer-toolbar'
//Assign all properties to this instance. No "this" assignments should //Assign all properties to this instance. No "this" assignments should
//take place above this line. //take place above this line.
this._dataSourceChangedListeners = {} this._dataSourceChangedListeners = {}
Object.defineProperties(Viewer.prototype, { Object.defineProperties(Viewer.prototype, {
/** /**
* Gets the parent container. * Gets the parent container.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* @type {Element} * @type {Element}
* @readonly * @readonly
*/ */
/** /**
* Gets the DOM element for the area at the bottom of the window containing the * Gets the DOM element for the area at the bottom of the window containing the
* {@link CreditDisplay} and potentially other things. * {@link CreditDisplay} and potentially other things.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* @type {Element} * @type {Element}
* @readonly * @readonly
*/ */


/** /**
* Gets the CesiumWidget. * Gets the CesiumWidget.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* @type {CesiumWidget} * @type {CesiumWidget}
* @readonly * @readonly
*/ */


/** /**
* Gets the display used for {@link DataSource} visualization. * Gets the display used for {@link DataSource} visualization.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* @type {DataSourceDisplay} * @type {DataSourceDisplay}
* @readonly * @readonly
*/ */
/** /**
* Gets the collection of entities not tied to a particular data source. * Gets the collection of entities not tied to a particular data source.
* This is a shortcut to [dataSourceDisplay.defaultDataSource.entities]{@link Viewer#dataSourceDisplay}. * This is a shortcut to [dataSourceDisplay.defaultDataSource.entities]{@link Viewer#dataSourceDisplay}.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* @type {EntityCollection} * @type {EntityCollection}
* @readonly * @readonly
*/ */


/** /**
* Gets the set of {@link DataSource} instances to be visualized. * Gets the set of {@link DataSource} instances to be visualized.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* @type {DataSourceCollection} * @type {DataSourceCollection}
* @readonly * @readonly
*/ */


/** /**
* Gets the canvas. * Gets the canvas.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* @type {HTMLCanvasElement} * @type {HTMLCanvasElement}
* @readonly * @readonly
*/ */


/** /**
* Gets the scene. * Gets the scene.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* @type {Scene} * @type {Scene}
* @readonly * @readonly
*/ */


/** /**
* Determines if shadows are cast by light sources. * Determines if shadows are cast by light sources.
* @memberof viewer.prototype
* @type {Boolean}
* @memberof Viewer.prototype
* @type {boolean}
*/ */
shadows: { shadows: {
get: function () { get: function () {


/** /**
* Determines if the terrain casts or shadows from light sources. * Determines if the terrain casts or shadows from light sources.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* @type {ShadowMode} * @type {ShadowMode}
*/ */
terrainShadows: { terrainShadows: {


/** /**
* Get the scene's shadow map * Get the scene's shadow map
* @memberof viewer.prototype
* @memberof Viewer.prototype
* @type {ShadowMap} * @type {ShadowMap}
* @readonly * @readonly
*/ */


/** /**
* Gets the collection of image layers that will be rendered on the globe. * Gets the collection of image layers that will be rendered on the globe.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* *
* @type {ImageryLayerCollection} * @type {ImageryLayerCollection}
* @readonly * @readonly


/** /**
* The terrain provider providing surface geometry for the globe. * The terrain provider providing surface geometry for the globe.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* *
* @type {TerrainProvider} * @type {TerrainProvider}
*/ */


/** /**
* Gets the camera. * Gets the camera.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* *
* @type {Camera} * @type {Camera}
* @readonly * @readonly


/** /**
* Gets the post-process stages. * Gets the post-process stages.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* *
* @type {PostProcessStageCollection} * @type {PostProcessStageCollection}
* @readonly * @readonly


/** /**
* Gets the clock. * Gets the clock.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* @type {Clock} * @type {Clock}
* @readonly * @readonly
*/ */


/** /**
* Gets the screen space event handler. * Gets the screen space event handler.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* @type {ScreenSpaceEventHandler} * @type {ScreenSpaceEventHandler}
* @readonly * @readonly
*/ */
* is true. If undefined, the browser's requestAnimationFrame implementation * is true. If undefined, the browser's requestAnimationFrame implementation
* determines the frame rate. If defined, this value must be greater than 0. A value higher * determines the frame rate. If defined, this value must be greater than 0. A value higher
* than the underlying requestAnimationFrame implementation will have no effect. * than the underlying requestAnimationFrame implementation will have no effect.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* *
* @type {Number}
* @type {number}
*/ */
targetFrameRate: { targetFrameRate: {
get: function () { get: function () {
* <code>renderError</code> event will be raised and this property * <code>renderError</code> event will be raised and this property
* will be set to false. It must be set back to true to continue rendering * will be set to false. It must be set back to true to continue rendering
* after the error. * after the error.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* *
* @type {Boolean}
* @type {boolean}
*/ */
useDefaultRenderLoop: { useDefaultRenderLoop: {
get: function () { get: function () {
* For example, if the widget is laid out at a size of 640x480, setting this value to 0.5 * For example, if the widget is laid out at a size of 640x480, setting this value to 0.5
* will cause the scene to be rendered at 320x240 and then scaled up while setting * will cause the scene to be rendered at 320x240 and then scaled up while setting
* it to 2.0 will cause the scene to be rendered at 1280x960 and then scaled down. * it to 2.0 will cause the scene to be rendered at 1280x960 and then scaled down.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* *
* @type {Number}
* @type {number}
* @default 1.0 * @default 1.0
*/ */
resolutionScale: { resolutionScale: {
* performance on less powerful devices that have high pixel density. When false, rendering * performance on less powerful devices that have high pixel density. When false, rendering
* will be in device pixels. {@link Viewer#resolutionScale} will still take effect whether * will be in device pixels. {@link Viewer#resolutionScale} will still take effect whether
* this flag is true or false. * this flag is true or false.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* *
* @type {Boolean}
* @type {boolean}
* @default true * @default true
*/ */
useBrowserRecommendedResolution: { useBrowserRecommendedResolution: {
* For example, if asynchronous primitives are being processed in the * For example, if asynchronous primitives are being processed in the
* background, the clock will not advance until the geometry is ready. * background, the clock will not advance until the geometry is ready.
* *
* @memberof viewer.prototype
* @memberof Viewer.prototype
* *
* @type {Boolean}
* @type {boolean}
*/ */
allowDataSourcesToSuspendAnimation: { allowDataSourcesToSuspendAnimation: {
get: function () { get: function () {


/** /**
* Gets or sets the Entity instance currently being tracked by the camera. * Gets or sets the Entity instance currently being tracked by the camera.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* @type {Entity | undefined} * @type {Entity | undefined}
*/ */
trackedEntity: { trackedEntity: {
* If a user interactively picks a Cesium3DTilesFeature instance, then this property * If a user interactively picks a Cesium3DTilesFeature instance, then this property
* will contain a transient Entity instance with a property named "feature" that is * will contain a transient Entity instance with a property named "feature" that is
* the instance that was picked. * the instance that was picked.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* @type {Entity | undefined} * @type {Entity | undefined}
*/ */
selectedEntity: { selectedEntity: {
}, },
/** /**
* Gets the event that is raised when the selected entity changes. * Gets the event that is raised when the selected entity changes.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* @type {Event} * @type {Event}
* @readonly * @readonly
*/ */
}, },
/** /**
* Gets the event that is raised when the tracked entity changes. * Gets the event that is raised when the tracked entity changes.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* @type {Event} * @type {Event}
* @readonly * @readonly
*/ */
}, },
/** /**
* Gets or sets the data source to track with the viewer's clock. * Gets or sets the data source to track with the viewer's clock.
* @memberof viewer.prototype
* @memberof Viewer.prototype
* @type {DataSource} * @type {DataSource}
*/ */
clockTrackedDataSource: { clockTrackedDataSource: {
}) })


/** /**
* Extends the base viewer functionality with the provided mixin.
* A mixin may add additional properties, functions, or other behavior
* to the provided viewer instance.
*
* @param {Viewer.ViewerMixin} mixin The Viewer mixin to add to this instance.
* @param {object} [options] The options object to be passed to the mixin function.
* *
* @param mixin
* @param options
* @see viewerDragDropMixin
*/ */
Viewer.prototype.extend = function (mixin, options) { Viewer.prototype.extend = function (mixin, options) {
//>>includeStart('debug', pragmas.debug); //>>includeStart('debug', pragmas.debug);
} }
this._dataSourceRemoved(undefined, this._dataSourceDisplay.defaultDataSource) this._dataSourceRemoved(undefined, this._dataSourceDisplay.defaultDataSource)


this._container.removeChild(this._element)
this._element.removeChild(this._toolbar)

this._eventHelper.removeAll() this._eventHelper.removeAll()


this._dataSourceDisplay = this._dataSourceDisplay.destroy() this._dataSourceDisplay = this._dataSourceDisplay.destroy()
* target will be the range. The heading will be determined from the offset. If the heading cannot be * target will be the range. The heading will be determined from the offset. If the heading cannot be
* determined from the offset, the heading will be north.</p> * determined from the offset, the heading will be north.</p>
* *
* @param {Entity|Entity[]|EntityCollection|DataSource|ImageryLayer|Cesium3DTileset|TimeDynamicPointCloud|Promise.<Entity|Entity[]|EntityCollection|DataSource|ImageryLayer|Cesium3DTileset|TimeDynamicPointCloud>} target The entity, array of entities, entity collection, data source, Cesium3DTileset, point cloud, or imagery layer to view. You can also pass a promise that resolves to one of the previously mentioned types.
* @param {Object} [options] Object with the following properties:
* @param {Number} [options.duration=3.0] The duration of the flight in seconds.
* @param {Number} [options.maximumHeight] The maximum height at the peak of the flight.
* @param {Entity|Entity[]|EntityCollection|DataSource|ImageryLayer|Cesium3DTileset|TimeDynamicPointCloud|Promise<Entity|Entity[]|EntityCollection|DataSource|ImageryLayer|Cesium3DTileset|TimeDynamicPointCloud|VoxelPrimitive>} target The entity, array of entities, entity collection, data source, Cesium3DTileset, point cloud, or imagery layer to view. You can also pass a promise that resolves to one of the previously mentioned types.
* @param {object} [options] Object with the following properties:
* @param {number} [options.duration=3.0] The duration of the flight in seconds.
* @param {number} [options.maximumHeight] The maximum height at the peak of the flight.
* @param {HeadingPitchRange} [options.offset] The offset from the target in the local east-north-up reference frame centered at the target. * @param {HeadingPitchRange} [options.offset] The offset from the target in the local east-north-up reference frame centered at the target.
* @returns {Promise.<Boolean>} A Promise that resolves to true if the flight was successful or false if the target is not currently visualized in the scene or the flight was cancelled. //TODO: Cleanup entity mentions
* @returns {Promise<boolean>} A Promise that resolves to true if the flight was successful or false if the target is not currently visualized in the scene or the flight was cancelled. //TODO: Cleanup entity mentions
*/ */
Viewer.prototype.flyTo = function (target, options) { Viewer.prototype.flyTo = function (target, options) {
return zoomToOrFly(this, target, options, true) return zoomToOrFly(this, target, options, true)
updateZoomTarget(this) updateZoomTarget(this)
updateTrackedEntity(this) updateTrackedEntity(this)
} }

function updateZoomTarget(viewer) { function updateZoomTarget(viewer) {
const target = viewer._zoomTarget const target = viewer._zoomTarget
if (!defined(target) || viewer.scene.mode === SceneMode.MORPHING) { if (!defined(target) || viewer.scene.mode === SceneMode.MORPHING) {

+ 41
- 41
src/modules/material/type/circle.js 查看文件

* @Date: 2021-02-27 22:49:41 * @Date: 2021-02-27 22:49:41
*/ */


import { Cesium } from '@dc-modules/namespace'
import { Cesium } from '../../../namespace'


const CircleBlurMaterial = require('../shader/circle/CircleBlurMaterial.glsl') const CircleBlurMaterial = require('../shader/circle/CircleBlurMaterial.glsl')
const CircleDiffuseMaterial = require('../shader/circle/CircleDiffuseMaterial.glsl') const CircleDiffuseMaterial = require('../shader/circle/CircleDiffuseMaterial.glsl')
type: Cesium.Material.CircleBlurType, type: Cesium.Material.CircleBlurType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0
speed: 3.0,
}, },
source: CircleBlurMaterial
source: CircleBlurMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })


/** /**
type: Cesium.Material.CircleDiffuseType, type: Cesium.Material.CircleDiffuseType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0
speed: 3.0,
}, },
source: CircleDiffuseMaterial
source: CircleDiffuseMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })


/** /**
type: Cesium.Material.CircleFadeType, type: Cesium.Material.CircleFadeType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0
speed: 3.0,
}, },
source: CircleFadeMaterial
source: CircleFadeMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })


/** /**
type: Cesium.Material.CirclePulseType, type: Cesium.Material.CirclePulseType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 12.0
speed: 12.0,
}, },
source: CirclePulseMaterial
source: CirclePulseMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })


/** /**
fabric: { fabric: {
type: Cesium.Material.CircleRingType, type: Cesium.Material.CircleRingType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7)
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
}, },
source: CircleRingMaterial
source: CircleRingMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })


/** /**
type: Cesium.Material.CircleRotateType, type: Cesium.Material.CircleRotateType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
image: Cesium.Material.DefaultImageId
image: Cesium.Material.DefaultImageId,
}, },
source: CircleRotateMaterial
source: CircleRotateMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })


/** /**
type: Cesium.Material.CircleScanType, type: Cesium.Material.CircleScanType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 1
speed: 1,
}, },
source: CircleScanMaterial
source: CircleScanMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })


/** /**
type: Cesium.Material.CircleSpiralType, type: Cesium.Material.CircleSpiralType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0
speed: 3.0,
}, },
source: CircleSpiralMaterial
source: CircleSpiralMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })


/** /**
type: Cesium.Material.CircleVaryType, type: Cesium.Material.CircleVaryType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0
speed: 3.0,
}, },
source: CircleVaryMaterial
source: CircleVaryMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })


/** /**
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0, speed: 3.0,
count: 1, count: 1,
gradient: 0.1
gradient: 0.1,
}, },
source: CircleWaveMaterial
source: CircleWaveMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })

+ 9
- 9
src/modules/material/type/cylinder.js 查看文件

* @Date: 2022-05-28 21:36:23 * @Date: 2022-05-28 21:36:23
*/ */


import { Cesium } from '@dc-modules/namespace'
import { Cesium } from '../../../namespace'


const CylinderFadeMaterial = require('../shader/cylinder/CylinderFadeMaterial.glsl') const CylinderFadeMaterial = require('../shader/cylinder/CylinderFadeMaterial.glsl')
const CylinderParticlesMaterial = require('../shader/cylinder/CylinderParticlesMaterial.glsl') const CylinderParticlesMaterial = require('../shader/cylinder/CylinderParticlesMaterial.glsl')
fabric: { fabric: {
type: Cesium.Material.CylinderFadeType, type: Cesium.Material.CylinderFadeType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7)
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
}, },
source: CylinderFadeMaterial
source: CylinderFadeMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })


/** /**
type: Cesium.Material.CylinderParticlesType, type: Cesium.Material.CylinderParticlesType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
image: Cesium.Material.DefaultImageId
image: Cesium.Material.DefaultImageId,
}, },
source: CylinderParticlesMaterial
source: CylinderParticlesMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
} }
) )

+ 9
- 9
src/modules/material/type/ellipsoid.js 查看文件

* @Date: 2021-02-27 23:20:11 * @Date: 2021-02-27 23:20:11
*/ */


import { Cesium } from '@dc-modules/namespace'
import { Cesium } from '../../../namespace'


const EllipsoidElectricMaterial = require('../shader/ellipsoid/EllipsoidElectricMaterial.glsl') const EllipsoidElectricMaterial = require('../shader/ellipsoid/EllipsoidElectricMaterial.glsl')
const EllipsoidTrailMaterial = require('../shader/ellipsoid/EllipsoidTrailMaterial.glsl') const EllipsoidTrailMaterial = require('../shader/ellipsoid/EllipsoidTrailMaterial.glsl')
type: Cesium.Material.EllipsoidElectricType, type: Cesium.Material.EllipsoidElectricType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 1
speed: 1,
}, },
source: EllipsoidElectricMaterial
source: EllipsoidElectricMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
} }
) )


type: Cesium.Material.EllipsoidTrailType, type: Cesium.Material.EllipsoidTrailType,
uniforms: { uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0
speed: 3.0,
}, },
source: EllipsoidTrailMaterial
source: EllipsoidTrailMaterial,
}, },
translucent: function(material) {
translucent: function (material) {
return true return true
}
},
}) })

+ 1
- 1
src/modules/math/area.js 查看文件

*/ */


import { Cesium } from '../../namespace' import { Cesium } from '../../namespace'
import { Transform } from '@dc-modules/transform'
import { Transform } from '../transform'


/** /**
* *

+ 2
- 2
src/modules/math/bounds.js 查看文件

let minLat = 90 let minLat = 90
let maxLng = -180 let maxLng = -180
let maxLat = -90 let maxLat = -90
positions.forEach(item => {
positions.forEach((item) => {
minLng = Math.min(minLng, item.lng || item.x) minLng = Math.min(minLng, item.lng || item.x)
minLat = Math.min(minLat, item.lat || item.y) minLat = Math.min(minLat, item.lat || item.y)
maxLng = Math.max(maxLng, item.lng || item.x) maxLng = Math.max(maxLng, item.lng || item.x)
west: minLng, west: minLng,
south: minLat, south: minLat,
east: maxLng, east: maxLng,
north: maxLat
north: maxLat,
} }
} }

+ 3
- 3
src/modules/math/center.js 查看文件

* @Date: 2020-04-24 14:43:39 * @Date: 2020-04-24 14:43:39
*/ */


import { Cesium } from '@dc-modules/namespace'
import { Transform } from '@dc-modules/transform'
import Position from '@dc-modules/position/Position'
import { Cesium } from '../../namespace'
import { Transform } from '../transform'
import Position from '../position/Position'


export default function center(positions) { export default function center(positions) {
if (positions && Array.isArray(positions)) { if (positions && Array.isArray(positions)) {

+ 2
- 2
src/modules/math/distance.js 查看文件

* @Date: 2020-03-31 20:58:06 * @Date: 2020-03-31 20:58:06
*/ */


import { Cesium } from '@dc-modules/namespace'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../namespace'
import { Transform } from '../transform'


export default function distance(positions) { export default function distance(positions) {
let distance = 0 let distance = 0

+ 3
- 3
src/modules/math/heading.js 查看文件

* @Date: 2020-04-11 00:41:47 * @Date: 2020-04-11 00:41:47
*/ */


import { Cesium } from '@dc-modules/namespace'
import { Transform } from '@dc-modules/transform'
import Parse from '@dc-modules/parse/Parse'
import { Cesium } from '../../namespace'
import { Transform } from '../transform'
import Parse from '../parse/Parse'


export default function heading(start, end) { export default function heading(start, end) {
let startPosition = start let startPosition = start

+ 1
- 1
src/modules/math/midCartesian.js 查看文件

* @Date: 2020-08-21 18:16:52 * @Date: 2020-08-21 18:16:52
*/ */


import { Cesium } from '@dc-modules/namespace'
import { Cesium } from '../../namespace'


export default function midCartesian(start, end) { export default function midCartesian(start, end) {
let c1 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(start) let c1 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(start)

+ 4
- 4
src/modules/math/midPosition.js 查看文件

* @Date: 2020-08-21 18:16:52 * @Date: 2020-08-21 18:16:52
*/ */


import { Cesium } from '@dc-modules/namespace'
import { Transform } from '@dc-modules/transform'
import Parse from '@dc-modules/parse/Parse'
import Position from '@dc-modules/position/Position'
import { Cesium } from '../../namespace'
import { Transform } from '../transform'
import Parse from '../parse/Parse'
import Position from '../position/Position'


export default function midPosition(start, end) { export default function midPosition(start, end) {
let startPosition = Parse.parsePosition(start) let startPosition = Parse.parsePosition(start)

+ 2
- 2
src/modules/measure/draw/DrawPolygon.js 查看文件

} else { } else {
return null return null
} }
}, false)
}
}, false),
},
}) })
this._layer.entities.add(this._delegate) this._layer.entities.add(this._delegate)
} }

+ 2
- 2
src/modules/measure/draw/DrawPolyline.js 查看文件

...this._style, ...this._style,
positions: new Cesium.CallbackProperty(() => { positions: new Cesium.CallbackProperty(() => {
return this._positions return this._positions
}, false)
}
}, false),
},
}) })
this._layer.entities.add(this._delegate) this._layer.entities.add(this._delegate)
} }

+ 9
- 9
src/modules/measure/type/Angle.js 查看文件

} else { } else {
return null return null
} }
}, false)
}
}, false),
},
}) })
} }


new EditPolyline(delegate).start( new EditPolyline(delegate).start(
{ {
viewer: this._viewer, viewer: this._viewer,
layer: this._layer
layer: this._layer,
}, },
{ {
...this._options, ...this._options,
...{ maxAnchorSize: this._maxAnchorSize }
...{ maxAnchorSize: this._maxAnchorSize },
} }
) )
} }
positions[1], positions[1],
new Cesium.Cartesian3() new Cesium.Cartesian3()
), ),
positions[1]
positions[1],
] ]


let hegiht = Math.abs(Cesium.Plane.getPointDistance(plane, positions[1])) let hegiht = Math.abs(Cesium.Plane.getPointDistance(plane, positions[1]))
start(measure, options) { start(measure, options) {
this._startHook(measure, options) this._startHook(measure, options)
let helpLineMaterial = new Cesium.PolylineDashMaterialProperty({ let helpLineMaterial = new Cesium.PolylineDashMaterialProperty({
color: Cesium.Color.GREENYELLOW
color: Cesium.Color.GREENYELLOW,
}) })
this._helpLine.polyline.material = helpLineMaterial this._helpLine.polyline.material = helpLineMaterial
this._helpLine.polyline.depthFailMaterial = helpLineMaterial this._helpLine.polyline.depthFailMaterial = helpLineMaterial
depthFailMaterial: depthFailMaterial:
options.depthFailMaterial || options.depthFailMaterial ||
new Cesium.PolylineDashMaterialProperty({ new Cesium.PolylineDashMaterialProperty({
color: Cesium.Color.YELLOW.withAlpha(0.6)
color: Cesium.Color.YELLOW.withAlpha(0.6),
}), }),
width: options.width || 2, width: options.width || 2,
clampToGround: false
clampToGround: false,
}).start(measure, { }).start(measure, {
...options, ...options,
...{ maxAnchorSize: this._maxAnchorSize }
...{ maxAnchorSize: this._maxAnchorSize },
}) })
return this return this
} }

+ 5
- 5
src/modules/overlay/Overlay.js 查看文件

* @Date: 2020-01-03 12:18:17 * @Date: 2020-01-03 12:18:17
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import { Util } from '@dc-modules/utils'
import { OverlayEventType, OverlayEvent } from '@dc-modules/event'
import { Cesium } from '../../namespace'
import State from '../state/State'
import { Util } from '../utils'
import { OverlayEventType, OverlayEvent } from '../event'
import OverlayType from './OverlayType' import OverlayType from './OverlayType'


class Overlay { class Overlay {
if (this._delegate instanceof Cesium.Entity) { if (this._delegate instanceof Cesium.Entity) {
this._delegate.label = { this._delegate.label = {
...textStyle, ...textStyle,
text: text
text: text,
} }
} }
return this return this

+ 9
- 13
src/modules/overlay/custom/CustomBillboard.js 查看文件

* @Author: Caven * @Author: Caven
* @Date: 2020-02-12 21:44:24 * @Date: 2020-02-12 21:44:24
*/ */

import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import Parse from '../../parse/Parse'
import State from '../../state/State'
import { Transform } from '../../transform'
import { Util } from '../../utils'


class CustomBillboard extends Overlay { class CustomBillboard extends Overlay {
constructor(position, icon) { constructor(position, icon) {
this._delegate.position = Transform.transformWGS84ToCartesian( this._delegate.position = Transform.transformWGS84ToCartesian(
this._position this._position
) )
return this
} }


get position() { get position() {
set icon(icon) { set icon(icon) {
this._icon = icon this._icon = icon
this._delegate.billboard.image = this._icon this._delegate.billboard.image = this._icon
return this
} }


get icon() { get icon() {
this._size = size this._size = size
this._delegate.billboard.width = this._size[0] || 32 this._delegate.billboard.width = this._size[0] || 32
this._delegate.billboard.height = this._size[1] || 32 this._delegate.billboard.height = this._size[1] || 32
return this
} }


get size() { get size() {
setLabel(text, textStyle) { setLabel(text, textStyle) {
this._delegate.label = { this._delegate.label = {
...textStyle, ...textStyle,
text: text
text: text,
} }
return this return this
} }
...style, ...style,
positions: Transform.transformWGS84ArrayToCartesianArray([ positions: Transform.transformWGS84ArrayToCartesianArray([
position, position,
this._position
])
this._position,
]),
} }
} }
return this return this
stRotation = 0 stRotation = 0
} }
return stRotation return stRotation
}, false)
}, false),
} }
return this return this
} }

+ 8
- 11
src/modules/overlay/custom/CustomLabel.js 查看文件

* @Author: Caven * @Author: Caven
* @Date: 2020-07-28 18:37:59 * @Date: 2020-07-28 18:37:59
*/ */

import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import Parse from '../../parse/Parse'
import State from '../../state/State'
import { Transform } from '../../transform'
import { Util } from '../../utils'


class CustomLabel extends Overlay { class CustomLabel extends Overlay {
constructor(position, text) { constructor(position, text) {
this._delegate.position = Transform.transformWGS84ToCartesian( this._delegate.position = Transform.transformWGS84ToCartesian(
this._position this._position
) )
return this
} }


get position() { get position() {
set text(text) { set text(text) {
this._text = text this._text = text
this._delegate.label.text = this._text this._delegate.label.text = this._text
return this
} }


get text() { get text() {
...style, ...style,
positions: Transform.transformWGS84ArrayToCartesianArray([ positions: Transform.transformWGS84ArrayToCartesianArray([
position, position,
this._position
])
this._position,
]),
} }
} }
return this return this
stRotation = 0 stRotation = 0
} }
return stRotation return stRotation
}, false)
}, false),
} }
return this return this
} }

+ 5
- 5
src/modules/overlay/dynamic/DynamicBillboard.js 查看文件

* @Date: 2021-05-05 09:16:35 * @Date: 2021-05-05 09:16:35
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import DynamicOverlay from './DynamicOverlay' import DynamicOverlay from './DynamicOverlay'
import Parse from '../../parse/Parse'
import State from '../../state/State'
import { Transform } from '../../transform'
import { Util } from '../../utils'


class DynamicBillboard extends DynamicOverlay { class DynamicBillboard extends DynamicOverlay {
constructor(position, icon) { constructor(position, icon) {

+ 5
- 6
src/modules/overlay/dynamic/DynamicModel.js 查看文件

* @Author: Caven * @Author: Caven
* @Date: 2021-05-05 09:16:35 * @Date: 2021-05-05 09:16:35
*/ */

import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import DynamicOverlay from './DynamicOverlay' import DynamicOverlay from './DynamicOverlay'
import Parse from '../../parse/Parse'
import State from '../../state/State'
import { Transform } from '../../transform'
import { Util } from '../../utils'


class DynamicModel extends DynamicOverlay { class DynamicModel extends DynamicOverlay {
constructor(position, modelUrl) { constructor(position, modelUrl) {

+ 5
- 5
src/modules/overlay/dynamic/DynamicOverlay.js 查看文件

* @Date: 2021-05-05 09:16:35 * @Date: 2021-05-05 09:16:35
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import Parse from '../../parse/Parse'
import State from '../../state/State'
import { Transform } from '../../transform'


class DynamicOverlay extends Overlay { class DynamicOverlay extends Overlay {
constructor() { constructor() {
this._sampledPosition.removeSamples( this._sampledPosition.removeSamples(
new Cesium.TimeInterval({ new Cesium.TimeInterval({
start: start, start: start,
stop: stop
stop: stop,
}) })
) )
this._cache.splice(0, this._cache.length - this._maxCacheSize) this._cache.splice(0, this._cache.length - this._maxCacheSize)

+ 10
- 13
src/modules/overlay/html/DivIcon.js 查看文件

* @Date: 2020-02-12 21:46:22 * @Date: 2020-02-12 21:46:22
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { DomUtil, Util } from '@dc-modules/utils'
import { MouseEventType } from '@dc-modules/event'
import { isBetween } from '@dc-modules/math'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import Parse from '../../parse/Parse'
import State from '../../state/State'
import { Transform } from '../../transform'
import { isBetween } from '../../math'
import { Util, DomUtil } from '../../utils'
import { MouseEventType } from '../../event'


class DivIcon extends Overlay { class DivIcon extends Overlay {
constructor(position, content) { constructor(position, content) {
Util.merge(this._delegate.style, { Util.merge(this._delegate.style, {
position: 'absolute', position: 'absolute',
top: '0', top: '0',
left: '0'
left: '0',
}) })
this.content = content this.content = content
this._state = State.INITIALIZED this._state = State.INITIALIZED
set show(show) { set show(show) {
this._show = show this._show = show
this._delegate.style.visibility = this._show ? 'visible' : 'hidden' this._delegate.style.visibility = this._show ? 'visible' : 'hidden'
return this
} }


get show() { get show() {


set position(position) { set position(position) {
this._position = Parse.parsePosition(position) this._position = Parse.parsePosition(position)
return this
} }


get position() { get position() {
} }
this._delegate.appendChild(content) this._delegate.appendChild(content)
} }
return this
} }


get content() { get content() {
let params = { let params = {
layer: layer, layer: layer,
overlay: this, overlay: this,
position: Transform.transformWGS84ToCartesian(this._position)
position: Transform.transformWGS84ToCartesian(this._position),
} }


this._delegate.addEventListener('click', () => { this._delegate.addEventListener('click', () => {
divIcon = new DivIcon(position, content) divIcon = new DivIcon(position, content)
if (entity.billboard) { if (entity.billboard) {
divIcon.attr = { divIcon.attr = {
...entity?.properties?.getValue(now)
...entity?.properties?.getValue(now),
} }
} }
return divIcon return divIcon

+ 6
- 9
src/modules/overlay/model/Model.js 查看文件

* @Date: 2020-01-06 20:03:25 * @Date: 2020-01-06 20:03:25
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import Parse from '../../parse/Parse'
import State from '../../state/State'
import { Transform } from '../../transform'
import { Util } from '../../utils'


class Model extends Overlay { class Model extends Overlay {
constructor(position, modelUrl) { constructor(position, modelUrl) {
) )
) )
} }
return this
} }


get position() { get position() {
set modelUrl(modelUrl) { set modelUrl(modelUrl) {
this._modelUrl = modelUrl this._modelUrl = modelUrl
this._delegate.model.uri = this._modelUrl this._delegate.model.uri = this._modelUrl
return this
} }


get modelUrl() { get modelUrl() {
) )
) )
}, false) }, false)
return this
} }


get rotateAmount() { get rotateAmount() {
) )
let model = new Model(position, modelUrl) let model = new Model(position, modelUrl)
model.attr = { model.attr = {
...entity.properties.getValue(now)
...entity.properties.getValue(now),
} }
return model return model
} }

+ 12
- 15
src/modules/overlay/model/Tileset.js 查看文件

* @Date: 2020-01-07 20:51:56 * @Date: 2020-01-07 20:51:56
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import Parse from '../../parse/Parse'
import State from '../../state/State'


class Tileset extends Overlay { class Tileset extends Overlay {
constructor(url, options = {}) { constructor(url, options = {}) {
super() super()
this._delegate = new Cesium.Cesium3DTileset({ this._delegate = new Cesium.Cesium3DTileset({
...options, ...options,
url: url
url: url,
}) })
this._tileVisibleCallback = undefined this._tileVisibleCallback = undefined
this._properties = undefined this._properties = undefined
this._fragmentShader = undefined
this._replaceFS = false
this._state = State.INITIALIZED this._state = State.INITIALIZED
} }


*/ */
_updateTile(tile) { _updateTile(tile) {
let content = tile.content let content = tile.content
let model = content._model
// sets properties // sets properties
for (let i = 0; i < content.featuresLength; i++) { for (let i = 0; i < content.featuresLength; i++) {
let feature = content.getFeature(i) let feature = content.getFeature(i)
if (this._properties && this._properties.length) { if (this._properties && this._properties.length) {
this._properties.forEach(property => {
this._properties.forEach((property) => {
if ( if (
feature.hasProperty(property['key']) && feature.hasProperty(property['key']) &&
feature.getProperty(property['key']) === property['keyValue'] feature.getProperty(property['key']) === property['keyValue']
*/ */
setPosition(position) { setPosition(position) {
position = Parse.parsePosition(position) position = Parse.parsePosition(position)
this.readyPromise.then(tileset => {
this.readyPromise.then((tileset) => {
let modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame( let modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
Cesium.Cartesian3.fromDegrees(position.lng, position.lat, position.alt) Cesium.Cartesian3.fromDegrees(position.lng, position.lat, position.alt)
) )
* @returns {Tileset} * @returns {Tileset}
*/ */
setHeadingPitchRoll(heading, pitch, roll) { setHeadingPitchRoll(heading, pitch, roll) {
this.readyPromise.then(tileset => {
this.readyPromise.then((tileset) => {
let modelMatrix = tileset.root.transform let modelMatrix = tileset.root.transform
let rotation = Cesium.Matrix4.fromRotationTranslation( let rotation = Cesium.Matrix4.fromRotationTranslation(
Cesium.Matrix3.fromHeadingPitchRoll( Cesium.Matrix3.fromHeadingPitchRoll(
* @returns {Tileset} * @returns {Tileset}
*/ */
clampToGround() { clampToGround() {
this.readyPromise.then(tileset => {
this.readyPromise.then((tileset) => {
let center = Cesium.Cartographic.fromCartesian( let center = Cesium.Cartographic.fromCartesian(
tileset.boundingSphere.center tileset.boundingSphere.center
) )
* @returns {Tileset} * @returns {Tileset}
*/ */
setHeight(height, isAbsolute = false) { setHeight(height, isAbsolute = false) {
this.readyPromise.then(tileset => {
this.readyPromise.then((tileset) => {
let center = Cesium.Cartographic.fromCartesian( let center = Cesium.Cartographic.fromCartesian(
tileset.boundingSphere.center tileset.boundingSphere.center
) )
* @returns {Tileset} * @returns {Tileset}
*/ */
setScale(scale) { setScale(scale) {
this.readyPromise.then(tileset => {
this.readyPromise.then((tileset) => {
let modelMatrix = tileset.root.transform let modelMatrix = tileset.root.transform
if (scale > 0 && scale !== 1) { if (scale > 0 && scale !== 1) {
Cesium.Matrix4.multiplyByUniformScale(modelMatrix, scale, modelMatrix) Cesium.Matrix4.multiplyByUniformScale(modelMatrix, scale, modelMatrix)
* @return {Tileset} * @return {Tileset}
*/ */
setSplitDirection(splitDirection) { setSplitDirection(splitDirection) {
this.readyPromise.then(tileset => {
this.readyPromise.then((tileset) => {
tileset.splitDirection = splitDirection tileset.splitDirection = splitDirection
}) })
return this return this
* @return {Tileset} * @return {Tileset}
*/ */
setCustomShader(customShader) { setCustomShader(customShader) {
this.readyPromise.then(tileset => {
this.readyPromise.then((tileset) => {
tileset.customShader = customShader tileset.customShader = customShader
}) })
return this return this

+ 6
- 7
src/modules/overlay/plot/AttackArrow.js 查看文件

/** /**
* @Author: Caven * @Author: Caven
* @Date: 2020-08-29 21:45:14
* @Date: 2020-08-29
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util, PlotUtil } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import Parse from '../../parse/Parse'
import State from '../../state/State'
import { Transform } from '../../transform'
import { Util, PlotUtil } from '../../utils'


const HALF_PI = Math.PI / 2 const HALF_PI = Math.PI / 2


set positions(positions) { set positions(positions) {
this._positions = Parse.parsePositions(positions) this._positions = Parse.parsePositions(positions)
this._delegate.polygon.hierarchy = this._getHierarchy() this._delegate.polygon.hierarchy = this._getHierarchy()
return this
} }


get positions() { get positions() {

+ 5
- 6
src/modules/overlay/plot/DoubleArrow.js 查看文件

* @Date: 2020-08-29 22:15:47 * @Date: 2020-08-29 22:15:47
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util, PlotUtil } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import Parse from '../../parse/Parse'
import State from '../../state/State'
import { Transform } from '../../transform'
import { Util, PlotUtil } from '../../utils'


const HALF_PI = Math.PI / 2 const HALF_PI = Math.PI / 2


set positions(positions) { set positions(positions) {
this._positions = Parse.parsePositions(positions) this._positions = Parse.parsePositions(positions)
this._delegate.polygon.hierarchy = this._getHierarchy() this._delegate.polygon.hierarchy = this._getHierarchy()
return this
} }


get positions() { get positions() {

+ 6
- 7
src/modules/overlay/plot/FineArrow.js 查看文件

* @Date: 2020-08-29 22:38:10 * @Date: 2020-08-29 22:38:10
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util, PlotUtil } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import Parse from '../../parse/Parse'
import State from '../../state/State'
import { Transform } from '../../transform'
import { Util, PlotUtil } from '../../utils'


const HALF_PI = Math.PI / 2 const HALF_PI = Math.PI / 2


set positions(positions) { set positions(positions) {
this._positions = Parse.parsePositions(positions) this._positions = Parse.parsePositions(positions)
this._delegate.polygon.hierarchy = this._getHierarchy() this._delegate.polygon.hierarchy = this._getHierarchy()
return this
} }


get positions() { get positions() {
pnt2, pnt2,
headRight, headRight,
neckRight, neckRight,
tailRight
tailRight,
]) ])
) )
) )

+ 5
- 6
src/modules/overlay/plot/GatheringPlace.js 查看文件

* @Date: 2020-08-29 23:00:27 * @Date: 2020-08-29 23:00:27
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util, PlotUtil } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import Parse from '../../parse/Parse'
import State from '../../state/State'
import { Transform } from '../../transform'
import { Util, PlotUtil } from '../../utils'


const HALF_PI = Math.PI / 2 const HALF_PI = Math.PI / 2


set positions(positions) { set positions(positions) {
this._positions = Parse.parsePositions(positions) this._positions = Parse.parsePositions(positions)
this._delegate.polygon.hierarchy = this._getHierarchy() this._delegate.polygon.hierarchy = this._getHierarchy()
return this
} }


get positions() { get positions() {

+ 6
- 7
src/modules/overlay/plot/TailedAttackArrow.js 查看文件

* @Date: 2020-08-29 22:51:36 * @Date: 2020-08-29 22:51:36
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { PlotUtil } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import Parse from '../../parse/Parse'
import State from '../../state/State'
import { Transform } from '../../transform'
import { PlotUtil } from '../../utils'
import AttackArrow from './AttackArrow' import AttackArrow from './AttackArrow'


class TailedAttackArrow extends AttackArrow { class TailedAttackArrow extends AttackArrow {
set positions(positions) { set positions(positions) {
this._positions = Parse.parsePositions(positions) this._positions = Parse.parsePositions(positions)
this._delegate.polygon.hierarchy = this._getHierarchy() this._delegate.polygon.hierarchy = this._getHierarchy()
return this
} }


get positions() { get positions() {
Parse.parsePositions( Parse.parsePositions(
leftPnts.concat(headPnts, rightPnts.reverse(), [ leftPnts.concat(headPnts, rightPnts.reverse(), [
swallowTailPnt, swallowTailPnt,
leftPnts[0]
leftPnts[0],
]) ])
) )
) )

+ 5
- 8
src/modules/overlay/primitive/BillboardPrimitive.js 查看文件

* @Date: 2021-06-03 21:06:17 * @Date: 2021-06-03 21:06:17
*/ */


import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import Parse from '../../parse/Parse'
import State from '../../state/State'
import { Transform } from '../../transform'
import { Util } from '../../utils'


class BillboardPrimitive extends Overlay { class BillboardPrimitive extends Overlay {
constructor(position, icon) { constructor(position, icon) {
position: undefined, position: undefined,
image: undefined, image: undefined,
width: 0, width: 0,
height: 0
height: 0,
} }
this._state = State.INITIALIZED this._state = State.INITIALIZED
} }
this._delegate.position = Transform.transformWGS84ToCartesian( this._delegate.position = Transform.transformWGS84ToCartesian(
this._position this._position
) )
return this
} }


get position() { get position() {
set icon(icon) { set icon(icon) {
this._icon = icon this._icon = icon
this._delegate.image = this._icon this._delegate.image = this._icon
return this
} }


get icon() { get icon() {
this._size = size this._size = size
this._delegate.width = this._size[0] || 32 this._delegate.width = this._size[0] || 32
this._delegate.height = this._size[1] || 32 this._delegate.height = this._size[1] || 32
return this
} }


get size() { get size() {

+ 3
- 3
src/modules/overlay/primitive/BounceBillboardPrimitive.js 查看文件

* @Date: 2021-06-03 21:06:17 * @Date: 2021-06-03 21:06:17
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import BillboardPrimitive from './BillboardPrimitive' import BillboardPrimitive from './BillboardPrimitive'


const DEF_STYLE = { const DEF_STYLE = {
maxOffsetY: 10, maxOffsetY: 10,
offsetAmount: 0.1
offsetAmount: 0.1,
} }


class BounceBillboardPrimitive extends BillboardPrimitive { class BounceBillboardPrimitive extends BillboardPrimitive {

+ 3
- 3
src/modules/overlay/primitive/BounceLabelPrimitive.js 查看文件

* @Date: 2021-06-03 21:06:17 * @Date: 2021-06-03 21:06:17
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import LabelPrimitive from './LabelPrimitive' import LabelPrimitive from './LabelPrimitive'


const DEF_STYLE = { const DEF_STYLE = {
maxOffsetY: 10, maxOffsetY: 10,
offsetAmount: 0.1
offsetAmount: 0.1,
} }


class BounceLabelPrimitive extends LabelPrimitive { class BounceLabelPrimitive extends LabelPrimitive {

+ 5
- 6
src/modules/overlay/primitive/CloudPrimitive.js 查看文件

* @Date: 2021-11-08 20:35:42 * @Date: 2021-11-08 20:35:42
*/ */


import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Transform } from '../../transform'
import { Util } from '../../utils'


class CloudPrimitive extends Overlay { class CloudPrimitive extends Overlay {
constructor(position) { constructor(position) {
this._position = Parse.parsePosition(position) this._position = Parse.parsePosition(position)
this._delegate = { this._delegate = {
position: undefined, position: undefined,
scale: { x: 12, y: 8 }
scale: { x: 12, y: 8 },
} }
this._state = State.INITIALIZED this._state = State.INITIALIZED
} }
this._delegate.position = Transform.transformWGS84ToCartesian( this._delegate.position = Transform.transformWGS84ToCartesian(
this._position this._position
) )
return this
} }


get position() { get position() {

+ 11
- 11
src/modules/overlay/primitive/DiffuseWallPrimitive.js 查看文件

* @Date: 2021-06-04 20:38:39 * @Date: 2021-06-04 20:38:39
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Transform } from '../../transform'
import { Util } from '../../utils'


const DEF_STYLE = { const DEF_STYLE = {
minRadius: 10, minRadius: 10,
minHeight: 30, minHeight: 30,
color: Cesium.Color.RED, color: Cesium.Color.RED,
slices: 128, slices: 128,
speed: 10
speed: 10,
} }


class DiffuseWallPrimitive extends Overlay { class DiffuseWallPrimitive extends Overlay {
let geometry = new Cesium.WallGeometry({ let geometry = new Cesium.WallGeometry({
positions: positions, positions: positions,
minimumHeights: this._getHeights(positions.length, 0), minimumHeights: this._getHeights(positions.length, 0),
maximumHeights: this._getHeights(positions.length, this._currentHeight)
maximumHeights: this._getHeights(positions.length, this._currentHeight),
}) })


this._delegate = new Cesium.Primitive({ this._delegate = new Cesium.Primitive({
geometryInstances: new Cesium.GeometryInstance({ geometryInstances: new Cesium.GeometryInstance({
geometry
geometry,
}), }),
appearance: new Cesium.MaterialAppearance({ appearance: new Cesium.MaterialAppearance({
material: Cesium.Material.fromType('WallDiffuse', { material: Cesium.Material.fromType('WallDiffuse', {
color: this._style?.color
color: this._style?.color,
}), }),
flat: true
flat: true,
}), }),
asynchronous: false
asynchronous: false,
}) })
this._delegate.update(frameState) this._delegate.update(frameState)
} }

+ 14
- 15
src/modules/overlay/primitive/ElecEllipsoidPrimitive.js 查看文件

* @Date: 2021-01-09 21:40:36 * @Date: 2021-01-09 21:40:36
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Transform } from '../../transform'
import { Util } from '../../utils'


class ElecEllipsoidPrimitive extends Overlay { class ElecEllipsoidPrimitive extends Overlay {
constructor(position, radius) { constructor(position, radius) {
this._radius = radius || { x: 10, y: 10, z: 10 } this._radius = radius || { x: 10, y: 10, z: 10 }
this._delegate = new Cesium.Primitive({ this._delegate = new Cesium.Primitive({
geometryInstances: new Cesium.GeometryInstance({ geometryInstances: new Cesium.GeometryInstance({
geometry: {}
})
geometry: {},
}),
}) })
this._state = State.INITIALIZED this._state = State.INITIALIZED
} }


set position(position) { set position(position) {
this._position = Parse.parsePosition(position) this._position = Parse.parsePosition(position)
this._delegate.geometryInstances.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
Transform.transformWGS84ToCartesian(this._position)
)
return this
this._delegate.geometryInstances.modelMatrix =
Cesium.Transforms.eastNorthUpToFixedFrame(
Transform.transformWGS84ToCartesian(this._position)
)
} }


get position() { get position() {
this._radius = radius this._radius = radius
this._delegate.geometryInstances.geometry = new Cesium.EllipsoidGeometry({ this._delegate.geometryInstances.geometry = new Cesium.EllipsoidGeometry({
radii: this._radius, radii: this._radius,
maximumCone: Cesium.Math.PI_OVER_TWO
maximumCone: Cesium.Math.PI_OVER_TWO,
}) })
return this
} }


get radius() { get radius() {
this._delegate.appearance = new Cesium.MaterialAppearance({ this._delegate.appearance = new Cesium.MaterialAppearance({
material: Cesium.Material.fromType('EllipsoidElectric', { material: Cesium.Material.fromType('EllipsoidElectric', {
color: this._style?.color || Cesium.Color.GREEN, color: this._style?.color || Cesium.Color.GREEN,
speed: this._style?.speed || 5
})
speed: this._style?.speed || 5,
}),
}) })
} }



+ 10
- 11
src/modules/overlay/primitive/FlowLinePrimitive.js 查看文件

* @Date: 2021-01-05 20:18:34 * @Date: 2021-01-05 20:18:34
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Transform } from '../../transform'
import { Util } from '../../utils'


class FlowLinePrimitive extends Overlay { class FlowLinePrimitive extends Overlay {
constructor(positions, width = 1) { constructor(positions, width = 1) {
this._width = width this._width = width
this._delegate = new Cesium.Primitive({ this._delegate = new Cesium.Primitive({
geometryInstances: new Cesium.GeometryInstance({ geometryInstances: new Cesium.GeometryInstance({
geometry: {}
})
geometry: {},
}),
}) })
this._state = State.INITIALIZED this._state = State.INITIALIZED
} }
this._positions = Parse.parsePositions(positions) this._positions = Parse.parsePositions(positions)
this._delegate.geometryInstances.geometry = new Cesium.PolylineGeometry({ this._delegate.geometryInstances.geometry = new Cesium.PolylineGeometry({
positions: Transform.transformWGS84ArrayToCartesianArray(this._positions), positions: Transform.transformWGS84ArrayToCartesianArray(this._positions),
width: this._width
width: this._width,
}) })
return this
} }


get positions() { get positions() {
color: this._style?.color || new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: this._style?.color || new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: this._style?.speed || 1, speed: this._style?.speed || 1,
percent: this._style?.percent || 0.03, percent: this._style?.percent || 0.03,
gradient: this._style?.gradient || 0.1
})
gradient: this._style?.gradient || 0.1,
}),
}) })
} }



+ 5
- 7
src/modules/overlay/primitive/LabelPrimitive.js 查看文件

* @Date: 2021-06-03 22:28:49 * @Date: 2021-06-03 22:28:49
*/ */


import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Transform } from '../../transform'
import { Util } from '../../utils'


class LabelPrimitive extends Overlay { class LabelPrimitive extends Overlay {
constructor(position, text) { constructor(position, text) {
this._text = text this._text = text
this._delegate = { this._delegate = {
position: undefined, position: undefined,
text: undefined
text: undefined,
} }
this._state = State.INITIALIZED this._state = State.INITIALIZED
} }
this._delegate.position = Transform.transformWGS84ToCartesian( this._delegate.position = Transform.transformWGS84ToCartesian(
this._position this._position
) )
return this
} }


get position() { get position() {
set text(text) { set text(text) {
this._text = text this._text = text
this._delegate.text = this._text this._delegate.text = this._text
return this
} }


get text() { get text() {

+ 24
- 28
src/modules/overlay/primitive/LightCylinderPrimitive.js 查看文件

* @Date: 2022-05-28 10:25:24 * @Date: 2022-05-28 10:25:24
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { IMG_PARTICLES } from '@dc-modules/images/base64'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Transform } from '../../transform'
import { Util } from '../../utils'
import { IMG_PARTICLES } from '../../images/base64'


const DEF_STYLE = { const DEF_STYLE = {
color: Cesium.Color.ORANGE
color: Cesium.Color.ORANGE,
} }


class LightCylinderPrimitive extends Overlay { class LightCylinderPrimitive extends Overlay {
set center(position) { set center(position) {
this._center = Parse.parsePosition(position) this._center = Parse.parsePosition(position)
this._updatePrimitives() this._updatePrimitives()
return this
} }


get center() { get center() {
set length(length) { set length(length) {
this._length = length this._length = length
this._updatePrimitives() this._updatePrimitives()
return this
} }


get length() { get length() {
set topRadius(topRadius) { set topRadius(topRadius) {
this._topRadius = topRadius this._topRadius = topRadius
this._updatePrimitives() this._updatePrimitives()
return this
} }


get topRadius() { get topRadius() {
set bottomRadius(bottomRadius) { set bottomRadius(bottomRadius) {
this._bottomRadius = bottomRadius this._bottomRadius = bottomRadius
this._updatePrimitives() this._updatePrimitives()
return this
} }


get bottomRadius() { get bottomRadius() {
semiMajorAxis: radius, semiMajorAxis: radius,
semiMinorAxis: radius, semiMinorAxis: radius,
rotation: 0, rotation: 0,
granularity: 0.005
granularity: 0.005,
}, },
false, false,
true true
let polygon = Cesium.PolygonGeometry.createGeometry( let polygon = Cesium.PolygonGeometry.createGeometry(
new Cesium.PolygonGeometry({ new Cesium.PolygonGeometry({
polygonHierarchy: new Cesium.PolygonHierarchy(newpts), polygonHierarchy: new Cesium.PolygonHierarchy(newpts),
perPositionHeight: true
perPositionHeight: true,
}) })
) )
polygon.indices = define_indices polygon.indices = define_indices
polygon.attributes.st.values = sts polygon.attributes.st.values = sts
return new Cesium.GeometryInstance({ return new Cesium.GeometryInstance({
geometry: polygon
geometry: polygon,
}) })
} }


polygonHierarchy: new Cesium.PolygonHierarchy( polygonHierarchy: new Cesium.PolygonHierarchy(
this._computeEllipsePositions(this._center, this._bottomRadius * 2) this._computeEllipsePositions(this._center, this._bottomRadius * 2)
), ),
perPositionHeight: !isGroud
perPositionHeight: !isGroud,
}), }),
asynchronous: false
})
asynchronous: false,
}),
} }


// ring // ring


ring.appearance = new Cesium.EllipsoidSurfaceAppearance({ ring.appearance = new Cesium.EllipsoidSurfaceAppearance({
material: Cesium.Material.fromType(Cesium.Material.CircleRingType, { material: Cesium.Material.fromType(Cesium.Material.CircleRingType, {
color: this._style.color
})
color: this._style.color,
}),
}) })


// circle // circle
circle.appearance = new Cesium.EllipsoidSurfaceAppearance({ circle.appearance = new Cesium.EllipsoidSurfaceAppearance({
material: Cesium.Material.fromType(Cesium.Material.CircleRotateType, { material: Cesium.Material.fromType(Cesium.Material.CircleRotateType, {
color: this._style.color, color: this._style.color,
image: this._getCircleImage()
})
image: this._getCircleImage(),
}),
}) })


// cylinder // cylinder
), ),
appearance: new Cesium.EllipsoidSurfaceAppearance({ appearance: new Cesium.EllipsoidSurfaceAppearance({
material: Cesium.Material.fromType(Cesium.Material.CylinderFadeType, { material: Cesium.Material.fromType(Cesium.Material.CylinderFadeType, {
color: this._style.color
})
color: this._style.color,
}),
}), }),
asynchronous: false
asynchronous: false,
}) })


if (isGroud) { if (isGroud) {
} }


// particles // particles
Cesium.Resource.fetchImage({ url: IMG_PARTICLES }).then(image => {
Cesium.Resource.fetchImage({ url: IMG_PARTICLES }).then((image) => {
let particles = new Cesium.Primitive({ let particles = new Cesium.Primitive({
geometryInstances: this._createCylinderInstance( geometryInstances: this._createCylinderInstance(
topPositions, topPositions,
Cesium.Material.CylinderParticlesType, Cesium.Material.CylinderParticlesType,
{ {
color: this._style.color, color: this._style.color,
image: this._getParticlesImage(image)
image: this._getParticlesImage(image),
} }
)
),
}), }),
asynchronous: false
asynchronous: false,
}) })
this._delegate.add(particles) this._delegate.add(particles)
}) })

+ 8
- 11
src/modules/overlay/primitive/ModelCollectionPrimitive.js 查看文件

* @Date: 2021-08-02 20:12:04 * @Date: 2021-08-02 20:12:04
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Transform } from '../../transform'
import { Util } from '../../utils'


class ModelCollectionPrimitive extends Overlay { class ModelCollectionPrimitive extends Overlay {
constructor(positions, modelUrl) { constructor(positions, modelUrl) {


set attrs(attrs) { set attrs(attrs) {
this._attrs = attrs this._attrs = attrs
return this
} }


get attrs() { get attrs() {
this._resetDelegate() this._resetDelegate()
this._layer.delegate.add(this._delegate) this._layer.delegate.add(this._delegate)
} }
return this
} }


set modelUrl(modelUrl) { set modelUrl(modelUrl) {
this._resetDelegate() this._resetDelegate()
this._layer.delegate.add(this._delegate) this._layer.delegate.add(this._delegate)
} }
return this
} }


get modelUrl() { get modelUrl() {
_resetDelegate() { _resetDelegate() {
this._delegate = new Cesium.ModelInstanceCollection({ this._delegate = new Cesium.ModelInstanceCollection({
url: this._modelUrl, url: this._modelUrl,
instances: this._positions.map(item => {
instances: this._positions.map((item) => {
let origin = Transform.transformWGS84ToCartesian(item) let origin = Transform.transformWGS84ToCartesian(item)
let modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame( let modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(
origin, origin,
modelMatrix modelMatrix
) )
return { return {
modelMatrix
modelMatrix,
} }
}), }),
...this._style
...this._style,
}) })
this._delegate.layerId = this._layer?.layerId this._delegate.layerId = this._layer?.layerId
this._delegate.overlayId = this._id this._delegate.overlayId = this._id

+ 5
- 7
src/modules/overlay/primitive/ModelPrimitive.js 查看文件

* @Date: 2021-05-14 00:33:27 * @Date: 2021-05-14 00:33:27
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Transform } from '../../transform'
import { Util } from '../../utils'


class ModelPrimitive extends Overlay { class ModelPrimitive extends Overlay {
constructor(position, modelUrl) { constructor(position, modelUrl) {
Cesium.Math.toRadians(this._position.roll) Cesium.Math.toRadians(this._position.roll)
) )
) )
return this
} }


get position() { get position() {
this._modelUrl = modelUrl this._modelUrl = modelUrl
this._delegate = Cesium.Model.fromGltf({ url: modelUrl }) this._delegate = Cesium.Model.fromGltf({ url: modelUrl })
this.position = this._position this.position = this._position
return this
} }


get modelUrl() { get modelUrl() {

+ 7
- 8
src/modules/overlay/primitive/PointPrimitive.js 查看文件

* @Date: 2021-06-03 20:51:25 * @Date: 2021-06-03 20:51:25
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Transform } from '../../transform'
import { Util } from '../../utils'


const DEF_STYLE = { const DEF_STYLE = {
pixelSize: 8, pixelSize: 8,
outlineColor: Cesium.Color.BLUE, outlineColor: Cesium.Color.BLUE,
outlineWidth: 2
outlineWidth: 2,
} }


class PointPrimitive extends Overlay { class PointPrimitive extends Overlay {
this._position = Parse.parsePosition(position) this._position = Parse.parsePosition(position)


this._delegate = { this._delegate = {
position: undefined
position: undefined,
} }
this._state = State.INITIALIZED this._state = State.INITIALIZED
} }
this._delegate.position = Transform.transformWGS84ToCartesian( this._delegate.position = Transform.transformWGS84ToCartesian(
this._position this._position
) )
return this
} }


get position() { get position() {

+ 6
- 7
src/modules/overlay/primitive/PolylinePrimitive.js 查看文件

* @Date: 2021-06-03 21:16:27 * @Date: 2021-06-03 21:16:27
*/ */


import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { center, distance } from '@dc-modules/math'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Transform } from '../../transform'
import { Util } from '../../utils'
import { center, distance } from '../../math'


class PolylinePrimitive extends Overlay { class PolylinePrimitive extends Overlay {
constructor(positions) { constructor(positions) {
super() super()
this._positions = Parse.parsePositions(positions) this._positions = Parse.parsePositions(positions)
this._delegate = { this._delegate = {
positions: []
positions: [],
} }
this._state = State.INITIALIZED this._state = State.INITIALIZED
} }
this._delegate.positions = Transform.transformWGS84ArrayToCartesianArray( this._delegate.positions = Transform.transformWGS84ArrayToCartesianArray(
this._positions this._positions
) )
return this
} }


get positions() { get positions() {

+ 10
- 12
src/modules/overlay/primitive/ScanCirclePrimitive.js 查看文件

* @Date: 2020-12-31 11:05:32 * @Date: 2020-12-31 11:05:32
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Transform } from '../../transform'
import { Util } from '../../utils'


class ScanCirclePrimitive extends Overlay { class ScanCirclePrimitive extends Overlay {
constructor(position, radius) { constructor(position, radius) {
this._radius = radius this._radius = radius
this._delegate = new Cesium.GroundPrimitive({ this._delegate = new Cesium.GroundPrimitive({
geometryInstances: new Cesium.GeometryInstance({ geometryInstances: new Cesium.GeometryInstance({
geometry: {}
})
geometry: {},
}),
}) })
this._state = State.INITIALIZED this._state = State.INITIALIZED
} }
this._delegate.geometryInstances.geometry = new Cesium.EllipseGeometry({ this._delegate.geometryInstances.geometry = new Cesium.EllipseGeometry({
center: Transform.transformWGS84ToCartesian(this._position), center: Transform.transformWGS84ToCartesian(this._position),
semiMajorAxis: this._radius, semiMajorAxis: this._radius,
semiMinorAxis: this._radius
semiMinorAxis: this._radius,
}) })
return this
} }


get position() { get position() {
this._radius = radius this._radius = radius
this._delegate.geometryInstances.geometry.semiMajorAxis = this._radius this._delegate.geometryInstances.geometry.semiMajorAxis = this._radius
this._delegate.geometryInstances.geometry.semiMinorAxis = this._radius this._delegate.geometryInstances.geometry.semiMinorAxis = this._radius
return this
} }


get radius() { get radius() {
this._delegate.appearance = new Cesium.MaterialAppearance({ this._delegate.appearance = new Cesium.MaterialAppearance({
material: Cesium.Material.fromType('CircleScan', { material: Cesium.Material.fromType('CircleScan', {
color: this._style?.color || Cesium.Color.WHITE, color: this._style?.color || Cesium.Color.WHITE,
speed: this._style?.speed || 10
})
speed: this._style?.speed || 10,
}),
}) })
} }



+ 11
- 12
src/modules/overlay/primitive/TrailLinePrimitive.js 查看文件

/** /**
* @Author: Caven * @Author: Caven
* @Date: 2021-01-09 21:33:59
* @Date: 2021-01-09
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Transform } from '../../transform'
import { Util } from '../../utils'


class TrailLinePrimitive extends Overlay { class TrailLinePrimitive extends Overlay {
constructor(positions, width = 1) { constructor(positions, width = 1) {
this._width = width this._width = width
this._delegate = new Cesium.Primitive({ this._delegate = new Cesium.Primitive({
geometryInstances: new Cesium.GeometryInstance({ geometryInstances: new Cesium.GeometryInstance({
geometry: {}
})
geometry: {},
}),
}) })
this._state = State.INITIALIZED this._state = State.INITIALIZED
} }
this._positions = Parse.parsePositions(positions) this._positions = Parse.parsePositions(positions)
this._delegate.geometryInstances.geometry = new Cesium.PolylineGeometry({ this._delegate.geometryInstances.geometry = new Cesium.PolylineGeometry({
positions: Transform.transformWGS84ArrayToCartesianArray(this._positions), positions: Transform.transformWGS84ArrayToCartesianArray(this._positions),
width: this._width
width: this._width,
}) })
return this
} }


get positions() { get positions() {
this._delegate.appearance = new Cesium.PolylineMaterialAppearance({ this._delegate.appearance = new Cesium.PolylineMaterialAppearance({
material: Cesium.Material.fromType('PolylineTrail', { material: Cesium.Material.fromType('PolylineTrail', {
color: this._style?.color || new Cesium.Color(1.0, 0.0, 0.0, 0.7), color: this._style?.color || new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: this._style?.speed || 5
})
speed: this._style?.speed || 5,
}),
}) })
} }



+ 13
- 16
src/modules/overlay/primitive/VideoPrimitive.js 查看文件

* @Date: 2020-11-09 20:04:30 * @Date: 2020-11-09 20:04:30
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Transform } from '../../transform'
import { Util } from '../../utils'


class VideoPrimitive extends Overlay { class VideoPrimitive extends Overlay {
constructor(positions, video) { constructor(positions, video) {
this._positions = Parse.parsePositions(positions) this._positions = Parse.parsePositions(positions)
this._delegate = new Cesium.GroundPrimitive({ this._delegate = new Cesium.GroundPrimitive({
geometryInstances: new Cesium.GeometryInstance({ geometryInstances: new Cesium.GeometryInstance({
geometry: {}
})
geometry: {},
}),
}) })
this._video = video this._video = video
this._state = State.INITIALIZED this._state = State.INITIALIZED


set positions(positions) { set positions(positions) {
this._positions = Parse.parsePositions(positions) this._positions = Parse.parsePositions(positions)
this._delegate.geometryInstances.geometry = Cesium.PolygonGeometry.fromPositions(
{
this._delegate.geometryInstances.geometry =
Cesium.PolygonGeometry.fromPositions({
positions: Transform.transformWGS84ArrayToCartesianArray( positions: Transform.transformWGS84ArrayToCartesianArray(
this._positions this._positions
), ),
extrudedHeight: this._style?.extrudedHeight, extrudedHeight: this._style?.extrudedHeight,
closeTop: this._style?.closeTop, closeTop: this._style?.closeTop,
closeBottom: this._style?.closeBottom, closeBottom: this._style?.closeBottom,
vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT
}
)
return this
vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT,
})
} }


get positions() { get positions() {
set video(video) { set video(video) {
this._video = video this._video = video
this._setAppearance() this._setAppearance()
return this
} }


get video() { get video() {
_setAppearance() { _setAppearance() {
this._delegate.appearance = new Cesium.EllipsoidSurfaceAppearance({ this._delegate.appearance = new Cesium.EllipsoidSurfaceAppearance({
material: Cesium.Material.fromType('Image', { material: Cesium.Material.fromType('Image', {
image: this._video
})
image: this._video,
}),
}) })
} }



+ 12
- 13
src/modules/overlay/primitive/WaterPrimitive.js 查看文件

* @Date: 2020-10-11 18:24:37 * @Date: 2020-10-11 18:24:37
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Transform } from '../../transform'
import { Util } from '../../utils'


class WaterPrimitive extends Overlay { class WaterPrimitive extends Overlay {
constructor(positions, holes = []) { constructor(positions, holes = []) {
super() super()
this._positions = Parse.parsePositions(positions) this._positions = Parse.parsePositions(positions)
this._holes = holes.map(item => Parse.parsePositions(item))
this._holes = holes.map((item) => Parse.parsePositions(item))
this._delegate = new Cesium.GroundPrimitive({ this._delegate = new Cesium.GroundPrimitive({
geometryInstances: new Cesium.GeometryInstance({ geometryInstances: new Cesium.GeometryInstance({
geometry: {}
geometry: {},
}), }),
asynchronous: true
asynchronous: true,
}) })
this._state = State.INITIALIZED this._state = State.INITIALIZED
} }
polygonHierarchy: new Cesium.PolygonHierarchy( polygonHierarchy: new Cesium.PolygonHierarchy(
Transform.transformWGS84ArrayToCartesianArray(this._positions), Transform.transformWGS84ArrayToCartesianArray(this._positions),
this._holes.map( this._holes.map(
item =>
(item) =>
new Cesium.PolygonHierarchy( new Cesium.PolygonHierarchy(
Transform.transformWGS84ArrayToCartesianArray(item) Transform.transformWGS84ArrayToCartesianArray(item)
) )
extrudedHeight: this._style?.extrudedHeight, extrudedHeight: this._style?.extrudedHeight,
closeTop: this._style?.closeTop, closeTop: this._style?.closeTop,
closeBottom: this._style?.closeBottom, closeBottom: this._style?.closeBottom,
vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT
vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT,
}) })
return this
} }


get positions() { get positions() {
frequency: this._style?.frequency || 1000.0, frequency: this._style?.frequency || 1000.0,
animationSpeed: this._style?.animationSpeed || 0.01, animationSpeed: this._style?.animationSpeed || 0.01,
amplitude: this._style?.amplitude || 10, amplitude: this._style?.amplitude || 10,
specularIntensity: this._style?.specularIntensity || 0.5
})
specularIntensity: this._style?.specularIntensity || 0.5,
}),
}) })
} }



+ 6
- 6
src/modules/overlay/vector/Billboard.js 查看文件

* @Date: 2020-01-19 10:18:23 * @Date: 2020-01-19 10:18:23
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Util } from '../../utils'
import { Transform } from '../../transform'


class Billboard extends Overlay { class Billboard extends Overlay {
constructor(position, icon) { constructor(position, icon) {
if (entity.billboard) { if (entity.billboard) {
billboard = new Billboard(position, entity.billboard.image.getValue(now)) billboard = new Billboard(position, entity.billboard.image.getValue(now))
billboard.attr = { billboard.attr = {
...entity?.properties?.getValue(now)
...entity?.properties?.getValue(now),
} }
} }
return billboard return billboard

+ 8
- 8
src/modules/overlay/vector/Box.js 查看文件

* @Date: 2020-02-25 18:28:36 * @Date: 2020-02-25 18:28:36
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Util } from '../../utils'
import { Transform } from '../../transform'


class Box extends Overlay { class Box extends Overlay {
constructor(position, length, width, height) { constructor(position, length, width, height) {
dimensions: { dimensions: {
x: +this._length, x: +this._length,
y: +this._width, y: +this._width,
z: +this._height
}
}
z: +this._height,
},
},
}) })
this._state = State.INITIALIZED this._state = State.INITIALIZED
} }

+ 7
- 7
src/modules/overlay/vector/Circle.js 查看文件

* @Date: 2020-01-31 18:57:02 * @Date: 2020-01-31 18:57:02
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Util } from '../../utils'
import { Transform } from '../../transform'


class Circle extends Overlay { class Circle extends Overlay {
constructor(center, radius) { constructor(center, radius) {
semiMajorAxis: this._radius, semiMajorAxis: this._radius,
semiMinorAxis: this._radius, semiMinorAxis: this._radius,
rotation: 0, rotation: 0,
granularity: 0.005
granularity: 0.005,
}, },
false, false,
true true
this._delegate.position = Transform.transformWGS84ToCartesian(this._center) this._delegate.position = Transform.transformWGS84ToCartesian(this._center)
this._delegate.label = { this._delegate.label = {
...textStyle, ...textStyle,
text: text
text: text,
} }
return this return this
} }

+ 8
- 9
src/modules/overlay/vector/Corridor.js 查看文件

* @Date: 2020-04-11 18:58:17 * @Date: 2020-04-11 18:58:17
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Util } from '../../utils'
import { Transform } from '../../transform'


class Corridor extends Overlay { class Corridor extends Overlay {
constructor(positions) { constructor(positions) {


set positions(positions) { set positions(positions) {
this._positions = Parse.parsePositions(positions) this._positions = Parse.parsePositions(positions)
this._delegate.corridor.positions = Transform.transformWGS84ArrayToCartesianArray(
this._positions
)
this._delegate.corridor.positions =
Transform.transformWGS84ArrayToCartesianArray(this._positions)
return this return this
} }


) )
corridor = new Corridor(positions) corridor = new Corridor(positions)
corridor.attr = { corridor.attr = {
...entity?.properties?.getValue(now)
...entity?.properties?.getValue(now),
} }
} }
return corridor return corridor

+ 5
- 5
src/modules/overlay/vector/Cylinder.js 查看文件

* @Date: 2020-04-14 18:10:00 * @Date: 2020-04-14 18:10:00
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Util } from '../../utils'
import { Transform } from '../../transform'


class Cylinder extends Overlay { class Cylinder extends Overlay {
constructor(position, length, topRadius, bottomRadius) { constructor(position, length, topRadius, bottomRadius) {

+ 5
- 5
src/modules/overlay/vector/Ellipse.js 查看文件

* @Date: 2020-04-14 18:30:45 * @Date: 2020-04-14 18:30:45
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Util } from '../../utils'
import { Transform } from '../../transform'


class Ellipse extends Overlay { class Ellipse extends Overlay {
constructor(position, semiMajorAxis, semiMinorAxis) { constructor(position, semiMajorAxis, semiMinorAxis) {

+ 5
- 5
src/modules/overlay/vector/Ellipsoid.js 查看文件

* @Date: 2020-04-14 18:20:23 * @Date: 2020-04-14 18:20:23
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Util } from '../../utils'
import { Transform } from '../../transform'


class Ellipsoid extends Overlay { class Ellipsoid extends Overlay {
constructor(position, radius) { constructor(position, radius) {

+ 6
- 6
src/modules/overlay/vector/Label.js 查看文件

* @Date: 2020-02-01 11:59:28 * @Date: 2020-02-01 11:59:28
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Util } from '../../utils'
import { Transform } from '../../transform'


class Label extends Overlay { class Label extends Overlay {
constructor(position, text) { constructor(position, text) {
if (entity.billboard) { if (entity.billboard) {
label = new Label(position, entity.name) label = new Label(position, entity.name)
label.attr = { label.attr = {
...entity?.properties?.getValue(now)
...entity?.properties?.getValue(now),
} }
} }
return label return label

+ 8
- 8
src/modules/overlay/vector/Plane.js 查看文件

* @Date: 2020-02-18 19:08:26 * @Date: 2020-02-18 19:08:26
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Util } from '../../utils'
import { Transform } from '../../transform'


class Plane extends Overlay { class Plane extends Overlay {
constructor(position, width, height, plane = {}) { constructor(position, width, height, plane = {}) {
plane: { plane: {
dimensions: { dimensions: {
x: this._width, x: this._width,
y: this._height
y: this._height,
}, },
plane: new Cesium.Plane(this._normal, this._distance)
}
plane: new Cesium.Plane(this._normal, this._distance),
},
}) })
this._state = State.INITIALIZED this._state = State.INITIALIZED
} }

+ 7
- 7
src/modules/overlay/vector/Point.js 查看文件

* @Date: 2020-01-06 15:03:25 * @Date: 2020-01-06 15:03:25
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Util } from '../../utils'
import { Transform } from '../../transform'


const DEF_STYLE = { const DEF_STYLE = {
pixelSize: 8, pixelSize: 8,
outlineColor: Cesium.Color.BLUE, outlineColor: Cesium.Color.BLUE,
outlineWidth: 2
outlineWidth: 2,
} }


class Point extends Overlay { class Point extends Overlay {
) )
point = new Point(position) point = new Point(position)
point.attr = { point.attr = {
...entity?.properties?.getValue(now)
...entity?.properties?.getValue(now),
} }
return point return point
} }

+ 10
- 10
src/modules/overlay/vector/Polygon.js 查看文件

* @Date: 2020-01-09 09:10:37 * @Date: 2020-01-09 09:10:37
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { center, area } from '@dc-modules/math'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Util } from '../../utils'
import { Transform } from '../../transform'
import { center, area } from '../../math'


class Polygon extends Overlay { class Polygon extends Overlay {
constructor(positions) { constructor(positions) {


set holes(holes) { set holes(holes) {
if (holes && holes.length) { if (holes && holes.length) {
this._holes = holes.map(item => Parse.parsePositions(item))
this._holes = holes.map((item) => Parse.parsePositions(item))
this._delegate.polygon.hierarchy = this._computeHierarchy() this._delegate.polygon.hierarchy = this._computeHierarchy()
} }
return this return this
this._positions this._positions
) )
result.holes = this._holes.map( result.holes = this._holes.map(
item =>
(item) =>
new Cesium.PolygonHierarchy( new Cesium.PolygonHierarchy(
Transform.transformWGS84ArrayToCartesianArray(item) Transform.transformWGS84ArrayToCartesianArray(item)
) )
this._delegate.position = Transform.transformWGS84ToCartesian(this.center) this._delegate.position = Transform.transformWGS84ToCartesian(this.center)
this._delegate.label = { this._delegate.label = {
text: text, text: text,
...textStyle
...textStyle,
} }
return this return this
} }
) )
polygon = new Polygon(positions) polygon = new Polygon(positions)
polygon.attr = { polygon.attr = {
...entity?.properties?.getValue(now)
...entity?.properties?.getValue(now),
} }
} }
return polygon return polygon

+ 10
- 11
src/modules/overlay/vector/Polyline.js 查看文件

* @Date: 2020-01-06 15:03:25 * @Date: 2020-01-06 15:03:25
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { center, distance } from '@dc-modules/math'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Util } from '../../utils'
import { Transform } from '../../transform'
import { center, distance } from '../../math'


class Polyline extends Overlay { class Polyline extends Overlay {
constructor(positions) { constructor(positions) {


set positions(positions) { set positions(positions) {
this._positions = Parse.parsePositions(positions) this._positions = Parse.parsePositions(positions)
this._delegate.polyline.positions = Transform.transformWGS84ArrayToCartesianArray(
this._positions
)
this._delegate.polyline.positions =
Transform.transformWGS84ArrayToCartesianArray(this._positions)
return this return this
} }


this._delegate.position = Transform.transformWGS84ToCartesian(this.center) this._delegate.position = Transform.transformWGS84ToCartesian(this.center)
this._delegate.label = { this._delegate.label = {
text: text, text: text,
...textStyle
...textStyle,
} }
return this return this
} }
) )
polyline = new Polyline(positions) polyline = new Polyline(positions)
polyline.attr = { polyline.attr = {
...entity?.properties?.getValue(now)
...entity?.properties?.getValue(now),
} }
} }
return polyline return polyline

+ 8
- 9
src/modules/overlay/vector/PolylineVolume.js 查看文件

* @Date: 2020-04-14 20:10:34 * @Date: 2020-04-14 20:10:34
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Util } from '../../utils'
import { Transform } from '../../transform'


class PolylineVolume extends Overlay { class PolylineVolume extends Overlay {
constructor(positions, shape) { constructor(positions, shape) {


set positions(positions) { set positions(positions) {
this._positions = Parse.parsePositions(positions) this._positions = Parse.parsePositions(positions)
this._delegate.polylineVolume.positions = Transform.transformWGS84ArrayToCartesianArray(
this._positions
)
this._delegate.polylineVolume.positions =
Transform.transformWGS84ArrayToCartesianArray(this._positions)
return this return this
} }


) )
polylineVolume = new PolylineVolume(positions, shape) polylineVolume = new PolylineVolume(positions, shape)
polylineVolume.attr = { polylineVolume.attr = {
...entity?.properties?.getValue(now)
...entity?.properties?.getValue(now),
} }
} }
return polylineVolume return polylineVolume

+ 6
- 6
src/modules/overlay/vector/Rectangle.js 查看文件

* @Date: 2020-04-14 20:46:23 * @Date: 2020-04-14 20:46:23
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Overlay from '../Overlay' import Overlay from '../Overlay'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Util } from '../../utils'
import { Transform } from '../../transform'


class Rectangle extends Overlay { class Rectangle extends Overlay {
constructor(positions) { constructor(positions) {
) )
this._delegate.label = { this._delegate.label = {
...textStyle, ...textStyle,
text: text
text: text,
} }
return this return this
} }

+ 8
- 9
src/modules/overlay/vector/Wall.js 查看文件

* @Date: 2020-02-25 18:28:36 * @Date: 2020-02-25 18:28:36
*/ */


import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import State from '../../state/State'
import Parse from '../../parse/Parse'
import { Util } from '../../utils'
import { Transform } from '../../transform'
import Overlay from '../Overlay' import Overlay from '../Overlay'


class Wall extends Overlay { class Wall extends Overlay {


set positions(positions) { set positions(positions) {
this._positions = Parse.parsePositions(positions) this._positions = Parse.parsePositions(positions)
this._delegate.wall.positions = Transform.transformWGS84ArrayToCartesianArray(
this._positions
)
this._delegate.wall.positions =
Transform.transformWGS84ArrayToCartesianArray(this._positions)
return this return this
} }


) )
wall = new Wall(positions) wall = new Wall(positions)
wall.attr = { wall.attr = {
...entity?.properties?.getValue(now)
...entity?.properties?.getValue(now),
} }
} }
return wall return wall

+ 5
- 6
src/modules/parse/Parse.js 查看文件

* @Author: Caven * @Author: Caven
* @Date: 2020-03-22 00:10:25 * @Date: 2020-03-22 00:10:25
*/ */

import Position from '@dc-modules/position/Position'
import Position from '../position/Position'


class Parse { class Parse {
/** /**
if (positions.indexOf('#') >= 0) { if (positions.indexOf('#') >= 0) {
throw new Error('the positions invalid') throw new Error('the positions invalid')
} }
positions = positions.split(';').filter(item => !!item)
positions = positions.split(';').filter((item) => !!item)
} }
return positions.map(item => {
return positions.map((item) => {
if (typeof item === 'string') { if (typeof item === 'string') {
return Position.fromString(item) return Position.fromString(item)
} else if (Array.isArray(item)) { } else if (Array.isArray(item)) {
static parsePolylineCoordToArray(positions) { static parsePolylineCoordToArray(positions) {
let result = [] let result = []
positions = this.parsePositions(positions) positions = this.parsePositions(positions)
positions.forEach(item => {
positions.forEach((item) => {
result.push([item.lng, item.lat]) result.push([item.lng, item.lat])
}) })
return result return result
static parsePolygonCoordToArray(positions, loop = false) { static parsePolygonCoordToArray(positions, loop = false) {
let result = [] let result = []
positions = this.parsePositions(positions) positions = this.parsePositions(positions)
positions.forEach(item => {
positions.forEach((item) => {
result.push([item.lng, item.lat]) result.push([item.lng, item.lat])
}) })
if (loop && result.length > 0) { if (loop && result.length > 0) {

+ 4
- 4
src/modules/plot/Plot.js 查看文件

* @Date: 2020-08-29 19:26:06 * @Date: 2020-08-29 19:26:06
*/ */


import { Cesium } from '@dc-modules/namespace'
import { OverlayType } from '@dc-modules/overlay'
import { Cesium } from '../../namespace'
import { OverlayType } from '../overlay'


import DrawPoint from './draw/DrawPoint' import DrawPoint from './draw/DrawPoint'
import DrawPolyline from './draw/DrawPolyline' import DrawPolyline from './draw/DrawPolyline'
...this._options, ...this._options,
maxAnchorSize: maxAnchorSize, maxAnchorSize: maxAnchorSize,
onDrawStop: callback, onDrawStop: callback,
clampToModel: clampToModel ?? this._options.clampToModel
clampToModel: clampToModel ?? this._options.clampToModel,
}) })
return this return this
} }
this._currentWorker = this._createEditWorker(overlay)?.start(this, { this._currentWorker = this._createEditWorker(overlay)?.start(this, {
...this._options, ...this._options,
onEditStop: callback, onEditStop: callback,
clampToModel: clampToModel ?? this._options.clampToModel
clampToModel: clampToModel ?? this._options.clampToModel,
}) })
return this return this
} }

+ 3
- 4
src/modules/plot/draw/Draw.js 查看文件

* @Author: Caven * @Author: Caven
* @Date: 2020-01-31 19:45:32 * @Date: 2020-01-31 19:45:32
*/ */

import { PlotEventType } from '@dc-modules/event'
import { PlotEventType } from '../../event'


class Draw { class Draw {
constructor(style) { constructor(style) {
* Subclasses need to be overridden * Subclasses need to be overridden
* @private * @private
*/ */
_stopdHook() {}
_stoppedHook() {}


/** /**
* *
this._unbindEvent() this._unbindEvent()
this._viewer.drawTool.deactivate() this._viewer.drawTool.deactivate()
this._delegate && this._layer.entities.remove(this._delegate) this._delegate && this._layer.entities.remove(this._delegate)
this._stopdHook()
this._stoppedHook()
} }


/** /**

+ 9
- 9
src/modules/plot/draw/DrawAttackArrow.js 查看文件

* @Date: 2020-08-30 16:43:12 * @Date: 2020-08-30 16:43:12
*/ */


import { Cesium } from '@dc-modules/namespace'
import { PlotEventType } from '@dc-modules/event'
import { Transform } from '@dc-modules/transform'
import { AttackArrow } from '@dc-modules/overlay'
import { Cesium } from '../../../namespace'
import Draw from './Draw' import Draw from './Draw'
import { PlotEventType } from '../../event'
import { Transform } from '../../transform'
import { AttackArrow } from '../../overlay'
import AttackArrowGraphics from '../graphics/AttackArrowGraphics' import AttackArrowGraphics from '../graphics/AttackArrowGraphics'


const DEF_STYLE = { const DEF_STYLE = {
material: Cesium.Color.YELLOW.withAlpha(0.6), material: Cesium.Color.YELLOW.withAlpha(0.6),
fill: true
fill: true,
} }


class DrawAttackArrow extends Draw { class DrawAttackArrow extends Draw {
this._maxAnchorSize = 3 this._maxAnchorSize = 3
this._style = { this._style = {
...DEF_STYLE, ...DEF_STYLE,
...style
...style,
} }
this._graphics = new AttackArrowGraphics() this._graphics = new AttackArrowGraphics()
} }
} else { } else {
return null return null
} }
}, false)
}
}, false),
},
}) })
this._layer.entities.add(this._delegate) this._layer.entities.add(this._delegate)
} }
* *
* @private * @private
*/ */
_stopdHook() {
_stoppedHook() {
let attackArrow = null let attackArrow = null
if (this._positions.length) { if (this._positions.length) {
attackArrow = new AttackArrow( attackArrow = new AttackArrow(

+ 9
- 10
src/modules/plot/draw/DrawBillboard.js 查看文件

* @Date: 2020-08-29 20:29:59 * @Date: 2020-08-29 20:29:59
*/ */


import { Cesium } from '@dc-modules/namespace'
import { PlotEventType } from '@dc-modules/event'
import { Transform } from '@dc-modules/transform'
import { Billboard } from '@dc-modules/overlay'
import { Cesium } from '../../../namespace'
import Draw from './Draw' import Draw from './Draw'

const IMG_CIRCLE_RED = require('@dc-modules/images/circle_red.png')
import { PlotEventType } from '../../event'
import { Transform } from '../../transform'
import { Billboard } from '../../overlay'
import IMG_CIRCLE_RED from '../../images/circle_red.png'


class DrawPoint extends Draw { class DrawPoint extends Draw {
constructor(style) { constructor(style) {
this._position = Cesium.Cartesian3.ZERO this._position = Cesium.Cartesian3.ZERO
this._style = { this._style = {
image: IMG_CIRCLE_RED, image: IMG_CIRCLE_RED,
...style
...style,
} }
} }


return this._position return this._position
}, false), }, false),
billboard: { billboard: {
...this._style
}
...this._style,
},
}) })
this._layer.entities.add(this._delegate) this._layer.entities.add(this._delegate)
} }
* *
* @private * @private
*/ */
_stopdHook() {
_stoppedHook() {
let billboard = null let billboard = null
if (this._position) { if (this._position) {
billboard = new Billboard( billboard = new Billboard(

+ 11
- 11
src/modules/plot/draw/DrawCircle.js 查看文件

* @Date: 2020-08-29 21:24:55 * @Date: 2020-08-29 21:24:55
*/ */


import { Cesium } from '@dc-modules/namespace'
import { PlotEventType } from '@dc-modules/event'
import { Transform } from '@dc-modules/transform'
import { Circle } from '@dc-modules/overlay'
import { Cesium } from '../../../namespace'
import { PlotEventType } from '../../event'
import { Transform } from '../../transform'
import { Circle } from '../../overlay'
import Draw from './Draw' import Draw from './Draw'


const DEF_STYLE = { const DEF_STYLE = {
material: Cesium.Color.YELLOW.withAlpha(0.6), material: Cesium.Color.YELLOW.withAlpha(0.6),
fill: true
fill: true,
} }


class DrawCircle extends Draw { class DrawCircle extends Draw {
this._radius = 0 this._radius = 0
this._style = { this._style = {
...DEF_STYLE, ...DEF_STYLE,
...style
...style,
} }
} }


semiMajorAxis: this._radius, semiMajorAxis: this._radius,
semiMinorAxis: this._radius, semiMinorAxis: this._radius,
rotation: 0, rotation: 0,
granularity: 0.005
granularity: 0.005,
}, },
false, false,
true true
} else { } else {
return null return null
} }
}, false)
}
}, false),
},
}) })
this._layer.entities.add(this._delegate) this._layer.entities.add(this._delegate)
} }
* *
* @private * @private
*/ */
_stopdHook() {
_stoppedHook() {
let circle = null let circle = null
if (this._positions.length) { if (this._positions.length) {
circle = new Circle( circle = new Circle(
this._positions.push(position) this._positions.push(position)
this.drawTool.fire(PlotEventType.CREATE_ANCHOR, { this.drawTool.fire(PlotEventType.CREATE_ANCHOR, {
position, position,
isCenter: len === 1
isCenter: len === 1,
}) })
if (len >= this._maxAnchorSize) { if (len >= this._maxAnchorSize) {
this._positions.pop() this._positions.pop()

+ 10
- 10
src/modules/plot/draw/DrawDoubleArrow.js 查看文件

/** /**
* @Author: Caven * @Author: Caven
* @Date: 2020-08-30 16:43:12
* @Date: 2020-08-30
*/ */


import { Cesium } from '@dc-modules/namespace'
import { PlotEventType } from '@dc-modules/event'
import { Transform } from '@dc-modules/transform'
import { DoubleArrow } from '@dc-modules/overlay'
import { Cesium } from '../../../namespace'
import { PlotEventType } from '../../event'
import { Transform } from '../../transform'
import { DoubleArrow } from '../../overlay'
import Draw from './Draw' import Draw from './Draw'
import DoubleArrowGraphics from '../graphics/DoubleArrowGraphics' import DoubleArrowGraphics from '../graphics/DoubleArrowGraphics'


const DEF_STYLE = { const DEF_STYLE = {
material: Cesium.Color.YELLOW.withAlpha(0.6), material: Cesium.Color.YELLOW.withAlpha(0.6),
fill: true
fill: true,
} }


class DrawDoubleArrow extends Draw { class DrawDoubleArrow extends Draw {
this._maxAnchorSize = 4 this._maxAnchorSize = 4
this._style = { this._style = {
...DEF_STYLE, ...DEF_STYLE,
...style
...style,
} }
this._graphics = new DoubleArrowGraphics() this._graphics = new DoubleArrowGraphics()
} }
} else { } else {
return null return null
} }
}, false)
}
}, false),
},
}) })
this._layer.entities.add(this._delegate) this._layer.entities.add(this._delegate)
} }
* *
* @private * @private
*/ */
_stopdHook() {
_stoppedHook() {
let doubleArrow = null let doubleArrow = null
if (this._positions.length) { if (this._positions.length) {
doubleArrow = new DoubleArrow( doubleArrow = new DoubleArrow(

+ 10
- 9
src/modules/plot/draw/DrawFineArrow.js 查看文件

* @Date: 2020-08-30 16:43:12 * @Date: 2020-08-30 16:43:12
*/ */


import { Cesium } from '@dc-modules/namespace'
import { Transform } from '@dc-modules/transform'
import { PlotEventType } from '@dc-modules/event'
import { FineArrow } from '@dc-modules/overlay'
import { Cesium } from '../../../namespace'
import Draw from './Draw' import Draw from './Draw'
import { Transform } from '../../transform'
import { PlotEventType } from '../../event'
import { FineArrow } from '../../overlay'

import FineArrowGraphics from '../graphics/FineArrowGraphics' import FineArrowGraphics from '../graphics/FineArrowGraphics'


const DEF_STYLE = { const DEF_STYLE = {
material: Cesium.Color.YELLOW.withAlpha(0.6), material: Cesium.Color.YELLOW.withAlpha(0.6),
fill: true
fill: true,
} }


class DrawFineArrow extends Draw { class DrawFineArrow extends Draw {
this._maxAnchorSize = 2 this._maxAnchorSize = 2
this._style = { this._style = {
...DEF_STYLE, ...DEF_STYLE,
...style
...style,
} }
this._graphics = new FineArrowGraphics() this._graphics = new FineArrowGraphics()
} }
} else { } else {
return null return null
} }
}, false)
}
}, false),
},
}) })
this._layer.entities.add(this._delegate) this._layer.entities.add(this._delegate)
} }
* *
* @private * @private
*/ */
_stopdHook() {
_stoppedHook() {
let fineArrow = null let fineArrow = null
if (this._positions.length) { if (this._positions.length) {
fineArrow = new FineArrow( fineArrow = new FineArrow(

+ 10
- 9
src/modules/plot/draw/DrawGatheringPlace.js 查看文件

* @Date: 2020-08-30 17:22:21 * @Date: 2020-08-30 17:22:21
*/ */


import { Cesium } from '@dc-modules/namespace'
import { Transform } from '@dc-modules/transform'
import { PlotEventType } from '@dc-modules/event'
import { GatheringPlace } from '@dc-modules/overlay'
import { Cesium } from '../../../namespace'
import Draw from './Draw' import Draw from './Draw'
import { Transform } from '../../transform'
import { PlotEventType } from '../../event'
import { GatheringPlace } from '../../overlay'

import GatheringPlaceGraphics from '../graphics/GatheringPlaceGraphics' import GatheringPlaceGraphics from '../graphics/GatheringPlaceGraphics'


const DEF_STYLE = { const DEF_STYLE = {
material: Cesium.Color.YELLOW.withAlpha(0.6), material: Cesium.Color.YELLOW.withAlpha(0.6),
fill: true
fill: true,
} }


class DrawGatheringPlace extends Draw { class DrawGatheringPlace extends Draw {
this._maxAnchorSize = 3 this._maxAnchorSize = 3
this._style = { this._style = {
...DEF_STYLE, ...DEF_STYLE,
...style
...style,
} }
this._graphics = new GatheringPlaceGraphics() this._graphics = new GatheringPlaceGraphics()
} }
} else { } else {
return null return null
} }
}, false)
}
}, false),
},
}) })
this._layer.entities.add(this._delegate) this._layer.entities.add(this._delegate)
} }
* *
* @private * @private
*/ */
_stopdHook() {
_stoppedHook() {
let gatheringPlace = null let gatheringPlace = null
if (this._positions.length) { if (this._positions.length) {
gatheringPlace = new GatheringPlace( gatheringPlace = new GatheringPlace(

+ 9
- 9
src/modules/plot/draw/DrawPoint.js 查看文件

* @Date: 2020-01-31 16:25:29 * @Date: 2020-01-31 16:25:29
*/ */


import { Cesium } from '@dc-modules/namespace'
import { PlotEventType } from '@dc-modules/event'
import { Transform } from '@dc-modules/transform'
import { Point } from '@dc-modules/overlay'
import { Cesium } from '../../../namespace'
import { PlotEventType } from '../../event'
import { Transform } from '../../transform'
import { Point } from '../../overlay'
import Draw from './Draw' import Draw from './Draw'


const DEF_STYLE = { const DEF_STYLE = {
pixelSize: 10, pixelSize: 10,
outlineColor: Cesium.Color.BLUE, outlineColor: Cesium.Color.BLUE,
outlineWidth: 5
outlineWidth: 5,
} }


class DrawPoint extends Draw { class DrawPoint extends Draw {
this._position = Cesium.Cartesian3.ZERO this._position = Cesium.Cartesian3.ZERO
this._style = { this._style = {
...DEF_STYLE, ...DEF_STYLE,
...style
...style,
} }
} }


return this._position return this._position
}, false), }, false),
point: { point: {
...this._style
}
...this._style,
},
}) })
this._layer.entities.add(this._delegate) this._layer.entities.add(this._delegate)
} }
* *
* @private * @private
*/ */
_stopdHook() {
_stoppedHook() {
let point = null let point = null
if (this._position) { if (this._position) {
point = new Point( point = new Point(

+ 10
- 10
src/modules/plot/draw/DrawPolygon.js 查看文件

* @Date: 2020-08-29 20:55:14 * @Date: 2020-08-29 20:55:14
*/ */


import { Cesium } from '@dc-modules/namespace'
import { PlotEventType } from '@dc-modules/event'
import { Transform } from '@dc-modules/transform'
import { Polygon } from '@dc-modules/overlay'
import { Cesium } from '../../../namespace'
import { PlotEventType } from '../../event'
import { Transform } from '../../transform'
import { Polygon } from '../../overlay'
import Draw from './Draw' import Draw from './Draw'


const DEF_STYLE = { const DEF_STYLE = {
material: Cesium.Color.YELLOW.withAlpha(0.6), material: Cesium.Color.YELLOW.withAlpha(0.6),
fill: true
fill: true,
} }


class DrawPolygon extends Draw { class DrawPolygon extends Draw {
super() super()
this._style = { this._style = {
...DEF_STYLE, ...DEF_STYLE,
...style
...style,
} }
} }


hierarchy: new Cesium.CallbackProperty(() => { hierarchy: new Cesium.CallbackProperty(() => {
if (this._positions.length > 2) { if (this._positions.length > 2) {
return new Cesium.PolygonHierarchy( return new Cesium.PolygonHierarchy(
this._positions.map(item => item.clone())
this._positions.map((item) => item.clone())
) )
} else { } else {
return null return null
} }
}, false)
}
}, false),
},
}) })
this._layer.entities.add(this._delegate) this._layer.entities.add(this._delegate)
} }
* *
* @private * @private
*/ */
_stopdHook() {
_stoppedHook() {
let polygon = null let polygon = null
if (this._positions.length) { if (this._positions.length) {
polygon = new Polygon( polygon = new Polygon(

+ 9
- 9
src/modules/plot/draw/DrawPolyline.js 查看文件

* @Date: 2020-08-29 20:54:37 * @Date: 2020-08-29 20:54:37
*/ */


import { Cesium } from '@dc-modules/namespace'
import { PlotEventType } from '@dc-modules/event'
import { Transform } from '@dc-modules/transform'
import { Polyline } from '@dc-modules/overlay'
import { Cesium } from '../../../namespace'
import { PlotEventType } from '../../event'
import { Transform } from '../../transform'
import { Polyline } from '../../overlay'
import Draw from './Draw' import Draw from './Draw'


const DEF_STYLE = { const DEF_STYLE = {
width: 3, width: 3,
material: Cesium.Color.YELLOW.withAlpha(0.6)
material: Cesium.Color.YELLOW.withAlpha(0.6),
} }


class DrawPolyline extends Draw { class DrawPolyline extends Draw {
super() super()
this._style = { this._style = {
...DEF_STYLE, ...DEF_STYLE,
...style
...style,
} }
} }


...this._style, ...this._style,
positions: new Cesium.CallbackProperty(() => { positions: new Cesium.CallbackProperty(() => {
return this._positions return this._positions
}, false)
}
}, false),
},
}) })
this._layer.entities.add(this._delegate) this._layer.entities.add(this._delegate)
} }
* *
* @private * @private
*/ */
_stopdHook() {
_stoppedHook() {
let polyline = null let polyline = null
if (this._positions.length) { if (this._positions.length) {
polyline = new Polyline( polyline = new Polyline(

+ 10
- 10
src/modules/plot/draw/DrawRectangle.js 查看文件

* @Date: 2020-08-29 21:30:41 * @Date: 2020-08-29 21:30:41
*/ */


import { Cesium } from '@dc-modules/namespace'
import { PlotEventType } from '@dc-modules/event'
import { Transform } from '@dc-modules/transform'
import { Rectangle } from '@dc-modules/overlay'
import { Cesium } from '../../../namespace'
import Draw from './Draw' import Draw from './Draw'
import { PlotEventType } from '../../event'
import { Transform } from '../../transform'
import { Rectangle } from '../../overlay'


const DEF_STYLE = { const DEF_STYLE = {
material: Cesium.Color.YELLOW.withAlpha(0.6)
material: Cesium.Color.YELLOW.withAlpha(0.6),
} }


class DrawRectangle extends Draw { class DrawRectangle extends Draw {
this._maxAnchorSize = 2 this._maxAnchorSize = 2
this._style = { this._style = {
...DEF_STYLE, ...DEF_STYLE,
...style
...style,
} }
} }


this._delegate = new Cesium.Entity({ this._delegate = new Cesium.Entity({
rectangle: { rectangle: {
...this._style, ...this._style,
coordinates: new Cesium.CallbackProperty(time => {
coordinates: new Cesium.CallbackProperty((time) => {
if (this._positions.length > 1) { if (this._positions.length > 1) {
return Cesium.Rectangle.fromCartesianArray(this._positions) return Cesium.Rectangle.fromCartesianArray(this._positions)
} else { } else {
return null return null
} }
}, false)
}
}, false),
},
}) })
this._layer.entities.add(this._delegate) this._layer.entities.add(this._delegate)
} }
* *
* @private * @private
*/ */
_stopdHook() {
_stoppedHook() {
let rectangle = null let rectangle = null
if (this._positions.length) { if (this._positions.length) {
rectangle = new Rectangle( rectangle = new Rectangle(

+ 9
- 9
src/modules/plot/draw/DrawTailedAttackArrow.js 查看文件

* @Date: 2020-08-30 16:43:12 * @Date: 2020-08-30 16:43:12
*/ */


import { Cesium } from '@dc-modules/namespace'
import { PlotEventType } from '@dc-modules/event'
import { Transform } from '@dc-modules/transform'
import { TailedAttackArrow } from '@dc-modules/overlay'
import { Cesium } from '../../../namespace'
import Draw from './Draw' import Draw from './Draw'
import TailedAttackArrowGraphics from '../graphics/TailedAttackArrowGraphics' import TailedAttackArrowGraphics from '../graphics/TailedAttackArrowGraphics'
import { PlotEventType } from '../../event'
import { Transform } from '../../transform'
import { TailedAttackArrow } from '../../overlay'


const DEF_STYLE = { const DEF_STYLE = {
material: Cesium.Color.YELLOW.withAlpha(0.6), material: Cesium.Color.YELLOW.withAlpha(0.6),
fill: true
fill: true,
} }


class DrawTailedAttackArrow extends Draw { class DrawTailedAttackArrow extends Draw {
this._maxAnchorSize = 3 this._maxAnchorSize = 3
this._style = { this._style = {
...DEF_STYLE, ...DEF_STYLE,
...style
...style,
} }
this._graphics = new TailedAttackArrowGraphics() this._graphics = new TailedAttackArrowGraphics()
} }
} else { } else {
return null return null
} }
}, false)
}
}, false),
},
}) })
this._layer.entities.add(this._delegate) this._layer.entities.add(this._delegate)
} }
* *
* @private * @private
*/ */
_stopdHook() {
_stoppedHook() {
let tailedAttackArrow = null let tailedAttackArrow = null
if (this._positions.length) { if (this._positions.length) {
tailedAttackArrow = new TailedAttackArrow( tailedAttackArrow = new TailedAttackArrow(

+ 5
- 5
src/modules/plot/edit/Edit.js 查看文件

* @Date: 2020-08-30 23:50:53 * @Date: 2020-08-30 23:50:53
*/ */


import { Cesium } from '@dc-modules/namespace'
import { PlotEventType } from '@dc-modules/event'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import { PlotEventType } from '../../event'
import { Transform } from '../../transform'


class Edit { class Edit {
constructor(overlay) { constructor(overlay) {
this._positions.forEach((item, index) => { this._positions.forEach((item, index) => {
this.editTool.fire(PlotEventType.CREATE_ANCHOR, { this.editTool.fire(PlotEventType.CREATE_ANCHOR, {
position: item, position: item,
index: index
index: index,
}) })
}) })
} }
stop() { stop() {
this.editTool.fire(PlotEventType.EDIT_STOP, { this.editTool.fire(PlotEventType.EDIT_STOP, {
pickedAnchor: null, pickedAnchor: null,
position: null
position: null,
}) })
return this return this
} }

+ 1
- 1
src/modules/plot/edit/EditAttackArrow.js 查看文件

* @Date: 2020-08-30 23:46:07 * @Date: 2020-08-30 23:46:07
*/ */


import { Cesium } from '@dc-modules/namespace'
import { Cesium } from '../../../namespace'
import Edit from './Edit' import Edit from './Edit'
import AttackArrowGraphics from '../graphics/AttackArrowGraphics' import AttackArrowGraphics from '../graphics/AttackArrowGraphics'



+ 2
- 2
src/modules/plot/edit/EditBillboard.js 查看文件

* @Date: 2020-08-30 22:04:36 * @Date: 2020-08-30 22:04:36
*/ */


import { Cesium } from '@dc-modules/namespace'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Edit from './Edit' import Edit from './Edit'
import { Transform } from '../../transform'


class EditBillboard extends Edit { class EditBillboard extends Edit {
constructor(overlay) { constructor(overlay) {

+ 7
- 7
src/modules/plot/edit/EditCircle.js 查看文件

* @Date: 2020-08-31 10:54:38 * @Date: 2020-08-31 10:54:38
*/ */


import { Cesium } from '@dc-modules/namespace'
import { PlotEventType } from '@dc-modules/event'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Edit from './Edit' import Edit from './Edit'
import { PlotEventType } from '../../event'
import { Transform } from '../../transform'


class EditCircle extends Edit { class EditCircle extends Edit {
constructor(overlay) { constructor(overlay) {
this._center = Transform.transformWGS84ToCartesian(this._overlay.center) this._center = Transform.transformWGS84ToCartesian(this._overlay.center)
this._positions = [].concat([ this._positions = [].concat([
this._center, this._center,
this._computeCirclePoints(this._center, this._radius)[0]
this._computeCirclePoints(this._center, this._radius)[0],
]) ])
this._delegate.polygon.hierarchy = new Cesium.CallbackProperty(time => {
this._delegate.polygon.hierarchy = new Cesium.CallbackProperty((time) => {
if (this._positions.length > 1) { if (this._positions.length > 1) {
this._radius = Cesium.Cartesian3.distance( this._radius = Cesium.Cartesian3.distance(
this._positions[0], this._positions[0],
semiMajorAxis: radius, semiMajorAxis: radius,
semiMinorAxis: radius, semiMinorAxis: radius,
rotation: 0, rotation: 0,
granularity: 0.005
granularity: 0.005,
}, },
false, false,
true true
this.editTool.fire(PlotEventType.CREATE_ANCHOR, { this.editTool.fire(PlotEventType.CREATE_ANCHOR, {
position: item, position: item,
index: index, index: index,
isCenter: index % 2 === 0
isCenter: index % 2 === 0,
}) })
}) })
} }

+ 1
- 1
src/modules/plot/edit/EditDoubleArrow.js 查看文件

* @Date: 2020-08-30 23:46:07 * @Date: 2020-08-30 23:46:07
*/ */


import { Cesium } from '@dc-modules/namespace'
import { Cesium } from '../../../namespace'
import Edit from './Edit' import Edit from './Edit'
import DoubleArrowGraphics from '../graphics/DoubleArrowGraphics' import DoubleArrowGraphics from '../graphics/DoubleArrowGraphics'



+ 1
- 3
src/modules/plot/edit/EditFineArrow.js 查看文件

* @Date: 2020-08-30 23:46:07 * @Date: 2020-08-30 23:46:07
*/ */


import { Cesium } from '@dc-modules/namespace'
import { PlotEventType } from '@dc-modules/event'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Edit from './Edit' import Edit from './Edit'
import FineArrowGraphics from '../graphics/FineArrowGraphics' import FineArrowGraphics from '../graphics/FineArrowGraphics'



+ 1
- 1
src/modules/plot/edit/EditGatheringPlace.js 查看文件

* @Date: 2020-08-30 23:46:07 * @Date: 2020-08-30 23:46:07
*/ */


import { Cesium } from '@dc-modules/namespace'
import { Cesium } from '../../../namespace'
import Edit from './Edit' import Edit from './Edit'
import GatheringPlaceGraphics from '../graphics/GatheringPlaceGraphics' import GatheringPlaceGraphics from '../graphics/GatheringPlaceGraphics'



+ 2
- 2
src/modules/plot/edit/EditPoint.js 查看文件

* @Date: 2020-08-30 22:04:36 * @Date: 2020-08-30 22:04:36
*/ */


import { Cesium } from '@dc-modules/namespace'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Edit from './Edit' import Edit from './Edit'
import { Transform } from '../../transform'


class EditPoint extends Edit { class EditPoint extends Edit {
constructor(overlay) { constructor(overlay) {

+ 10
- 10
src/modules/plot/edit/EditPolygon.js 查看文件

* @Date: 2020-08-30 23:12:09 * @Date: 2020-08-30 23:12:09
*/ */


import { Cesium } from '@dc-modules/namespace'
import { PlotEventType } from '@dc-modules/event'
import { midCartesian } from '@dc-modules/math'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Edit from './Edit' import Edit from './Edit'
import { PlotEventType } from '../../event'
import { midCartesian } from '../../math'
import { Transform } from '../../transform'


class EditPolygon extends Edit { class EditPolygon extends Edit {
constructor(overlay) { constructor(overlay) {
* @private * @private
*/ */
_mountedHook() { _mountedHook() {
this._delegate.polygon.hierarchy = new Cesium.CallbackProperty(time => {
this._delegate.polygon.hierarchy = new Cesium.CallbackProperty((time) => {
if (this._positions.length > 2) { if (this._positions.length > 2) {
return new Cesium.PolygonHierarchy( return new Cesium.PolygonHierarchy(
this._positions.map(item => item.clone())
this._positions.map((item) => item.clone())
) )
} else { } else {
return null return null
this.editTool.fire(PlotEventType.CREATE_ANCHOR, { this.editTool.fire(PlotEventType.CREATE_ANCHOR, {
position: item, position: item,
index: index, index: index,
isMid: index % 2 !== 0
isMid: index % 2 !== 0,
}) })
}) })
} }
this.editTool.fire(PlotEventType.CREATE_ANCHOR, { this.editTool.fire(PlotEventType.CREATE_ANCHOR, {
position: item, position: item,
index: index, index: index,
isMid: index % 2 !== 0
isMid: index % 2 !== 0,
}) })
}) })
} }
this._positions[nextMidAnchorIndex] = nextMidPosition this._positions[nextMidAnchorIndex] = nextMidPosition
this.editTool.fire(PlotEventType.UPDATE_ANCHOR, { this.editTool.fire(PlotEventType.UPDATE_ANCHOR, {
index: preMidAnchorIndex, index: preMidAnchorIndex,
position: preMidPosition
position: preMidPosition,
}) })
this.editTool.fire(PlotEventType.UPDATE_ANCHOR, { this.editTool.fire(PlotEventType.UPDATE_ANCHOR, {
index: nextMidAnchorIndex, index: nextMidAnchorIndex,
position: nextMidPosition
position: nextMidPosition,
}) })
} }
} }

+ 8
- 8
src/modules/plot/edit/EditPolyline.js 查看文件

* @Date: 2020-08-30 22:39:34 * @Date: 2020-08-30 22:39:34
*/ */


import { Cesium } from '@dc-modules/namespace'
import { PlotEventType } from '@dc-modules/event'
import { midCartesian } from '@dc-modules/math'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Edit from './Edit' import Edit from './Edit'
import { PlotEventType } from '../../event'
import { midCartesian } from '../../math'
import { Transform } from '../../transform'


class EditPolyline extends Edit { class EditPolyline extends Edit {
constructor(overlay) { constructor(overlay) {
this.editTool.fire(PlotEventType.CREATE_ANCHOR, { this.editTool.fire(PlotEventType.CREATE_ANCHOR, {
position: item, position: item,
index: index, index: index,
isMid: index % 2 !== 0
isMid: index % 2 !== 0,
}) })
}) })
} }
this.editTool.fire(PlotEventType.CREATE_ANCHOR, { this.editTool.fire(PlotEventType.CREATE_ANCHOR, {
position: item, position: item,
index: index, index: index,
isMid: index % 2 !== 0
isMid: index % 2 !== 0,
}) })
}) })
} }
this._positions[preMidAnchorIndex] = preMidPosition this._positions[preMidAnchorIndex] = preMidPosition
this.editTool.fire(PlotEventType.UPDATE_ANCHOR, { this.editTool.fire(PlotEventType.UPDATE_ANCHOR, {
index: preMidAnchorIndex, index: preMidAnchorIndex,
position: preMidPosition
position: preMidPosition,
}) })
} }


this._positions[nextMidAnchorIndex] = nextMidPosition this._positions[nextMidAnchorIndex] = nextMidPosition
this.editTool.fire(PlotEventType.UPDATE_ANCHOR, { this.editTool.fire(PlotEventType.UPDATE_ANCHOR, {
index: nextMidAnchorIndex, index: nextMidAnchorIndex,
position: nextMidPosition
position: nextMidPosition,
}) })
} }
} }

+ 11
- 9
src/modules/plot/edit/EditRectangle.js 查看文件

* @Date: 2020-08-30 23:41:34 * @Date: 2020-08-30 23:41:34
*/ */


import { Cesium } from '@dc-modules/namespace'
import { Transform } from '@dc-modules/transform'
import { Cesium } from '../../../namespace'
import Edit from './Edit' import Edit from './Edit'


class EditRectangle extends Edit { class EditRectangle extends Edit {
* @private * @private
*/ */
_mountedHook() { _mountedHook() {
this._delegate.rectangle.coordinates = new Cesium.CallbackProperty(time => {
if (this._positions.length > 1) {
return Cesium.Rectangle.fromCartesianArray(this._positions)
} else {
return null
}
}, false)
this._delegate.rectangle.coordinates = new Cesium.CallbackProperty(
(time) => {
if (this._positions.length > 1) {
return Cesium.Rectangle.fromCartesianArray(this._positions)
} else {
return null
}
},
false
)
this._layer.entities.add(this._delegate) this._layer.entities.add(this._delegate)
} }
} }

+ 1
- 1
src/modules/plot/edit/EditTailedAttackArrow.js 查看文件

* @Date: 2020-08-30 23:46:07 * @Date: 2020-08-30 23:46:07
*/ */


import { Cesium } from '@dc-modules/namespace'
import { Cesium } from '../../../namespace'
import Edit from './Edit' import Edit from './Edit'
import TailedAttackArrowGraphics from '../graphics/TailedAttackArrowGraphics' import TailedAttackArrowGraphics from '../graphics/TailedAttackArrowGraphics'



+ 4
- 4
src/modules/plot/graphics/AttackArrowGraphics.js 查看文件

* @Date: 2020-08-30 16:22:50 * @Date: 2020-08-30 16:22:50
*/ */


import { Cesium } from '@dc-modules/namespace'
import Parse from '@dc-modules/parse/Parse'
import { Transform } from '@dc-modules/transform'
import { PlotUtil } from '@dc-modules/utils'
import { Cesium } from '../../../namespace'
import Parse from '../../parse/Parse'
import { Transform } from '../../transform'
import { PlotUtil } from '../../utils'


const HALF_PI = Math.PI / 2 const HALF_PI = Math.PI / 2



+ 4
- 4
src/modules/plot/graphics/DoubleArrowGraphics.js 查看文件

* @Date: 2020-08-30 16:27:29 * @Date: 2020-08-30 16:27:29
*/ */


import { Cesium } from '@dc-modules/namespace'
import Parse from '@dc-modules/parse/Parse'
import { Transform } from '@dc-modules/transform'
import { PlotUtil } from '@dc-modules/utils'
import { Cesium } from '../../../namespace'
import Parse from '../../parse/Parse'
import { Transform } from '../../transform'
import { PlotUtil } from '../../utils'


const HALF_PI = Math.PI / 2 const HALF_PI = Math.PI / 2



+ 0
- 0
src/modules/plot/graphics/FineArrowGraphics.js 查看文件


部分文件因文件數量過多而無法顯示

Loading…
取消
儲存