Переглянути джерело

update project

tags/2.6.1
duanhuyin 4 роки тому
джерело
коміт
cfe5b43349
100 змінених файлів з 1411 додано та 271 видалено
  1. 1
    1
      .eslintignore
  2. 1
    1
      .github/FUNDING.yml
  3. 134
    0
      CHANGES_en.md
  4. 133
    5
      CHANGES_zh.md
  5. 4
    4
      README.md
  6. 4
    4
      README_zh.md
  7. 8
    0
      modules/animation/AnimationType.js
  8. 1
    0
      modules/animation/index.js
  9. 7
    1
      modules/animation/type/AroundPoint.js
  10. 15
    3
      modules/animation/type/AroundView.js
  11. 7
    1
      modules/animation/type/CircleScan.js
  12. 7
    1
      modules/animation/type/Flying.js
  13. 7
    1
      modules/animation/type/GlobeRotate.js
  14. 7
    1
      modules/animation/type/RadarScan.js
  15. 5
    2
      modules/chart/ChartLayer.js
  16. 9
    9
      modules/chart/extension/CoordinateSystem.js
  17. 1
    1
      modules/copy-right/index.js
  18. 4
    1
      modules/effect/type/BlackAndWhite.js
  19. 4
    1
      modules/effect/type/Bloom.js
  20. 4
    1
      modules/effect/type/Brightness.js
  21. 4
    1
      modules/effect/type/DepthOfField.js
  22. 4
    1
      modules/effect/type/LensFlare.js
  23. 4
    1
      modules/effect/type/NightVision.js
  24. 4
    1
      modules/effect/type/Silhouette.js
  25. 4
    0
      modules/effect/type/Sun.js
  26. 8
    2
      modules/event/Event.js
  27. 34
    2
      modules/event/EventType.js
  28. 5
    0
      modules/event/index.js
  29. 101
    23
      modules/event/type/MouseEvent.js
  30. 27
    0
      modules/event/type/PlotEvent.js
  31. 7
    3
      modules/heat/HeatLayer.js
  32. 94
    44
      modules/history-track/Track.js
  33. 2
    2
      modules/history-track/TrackController.js
  34. 40
    15
      modules/layer/Layer.js
  35. 4
    1
      modules/layer/LayerGroup.js
  36. 5
    1
      modules/layer/type/ClusterLayer.js
  37. 4
    1
      modules/layer/type/CzmlLayer.js
  38. 4
    1
      modules/layer/type/DynamicLayer.js
  39. 5
    2
      modules/layer/type/FeatureGridLayer.js
  40. 4
    1
      modules/layer/type/GeoJsonLayer.js
  41. 15
    4
      modules/layer/type/HtmlLayer.js
  42. 4
    1
      modules/layer/type/KmlLayer.js
  43. 4
    1
      modules/layer/type/LabelLayer.js
  44. 7
    1
      modules/layer/type/PrimitiveLayer.js
  45. 4
    1
      modules/layer/type/TilesetLayer.js
  46. 5
    1
      modules/layer/type/TopoJsonLayer.js
  47. 4
    1
      modules/layer/type/VectorLayer.js
  48. 12
    0
      modules/loader/Loader.js
  49. 4
    0
      modules/loader/index.js
  50. 18
    1
      modules/loader/type/ViewerLoader.js
  51. 4
    0
      modules/loader/type/WeatherLoader.js
  52. 5
    1
      modules/mapv/MapvLayer.js
  53. 3
    0
      modules/material/shader/polyline/PolylineImageTrailMaterial.glsl
  54. 50
    9
      modules/math/area.js
  55. 3
    2
      modules/math/index.js
  56. 13
    0
      modules/math/midCartesian.js
  57. 1
    2
      modules/math/midPosition.js
  58. 4
    1
      modules/option/ViewerOption.js
  59. 1
    0
      modules/option/index.js
  60. 13
    8
      modules/overlay/Overlay.js
  61. 5
    2
      modules/overlay/custom/CustomBillboard.js
  62. 5
    2
      modules/overlay/custom/CustomLabel.js
  63. 7
    4
      modules/overlay/dynamic/DynamicBillboard.js
  64. 8
    5
      modules/overlay/dynamic/DynamicModel.js
  65. 4
    6
      modules/overlay/dynamic/DynamicOverlay.js
  66. 34
    20
      modules/overlay/html/DivIcon.js
  67. 3
    0
      modules/overlay/index.js
  68. 5
    2
      modules/overlay/model/Model.js
  69. 4
    1
      modules/overlay/model/Tileset.js
  70. 4
    1
      modules/overlay/plot/AttackArrow.js
  71. 4
    1
      modules/overlay/plot/DoubleArrow.js
  72. 4
    1
      modules/overlay/plot/FineArrow.js
  73. 4
    1
      modules/overlay/plot/GatheringPlace.js
  74. 4
    1
      modules/overlay/plot/TailedAttackArrow.js
  75. 4
    1
      modules/overlay/primitive/BillboardPrimitive.js
  76. 73
    0
      modules/overlay/primitive/BounceBillboardPrimitive.js
  77. 73
    0
      modules/overlay/primitive/BounceLabelPrimitive.js
  78. 13
    28
      modules/overlay/primitive/DiffuseWallPrimitive.js
  79. 4
    1
      modules/overlay/primitive/ElecEllipsoidPrimitive.js
  80. 4
    1
      modules/overlay/primitive/FlowLinePrimitive.js
  81. 4
    1
      modules/overlay/primitive/LabelPrimitive.js
  82. 133
    0
      modules/overlay/primitive/ModelCollectionPrimitive.js
  83. 41
    1
      modules/overlay/primitive/ModelPrimitive.js
  84. 5
    1
      modules/overlay/primitive/PointPrimitive.js
  85. 4
    1
      modules/overlay/primitive/PolylinePrimitive.js
  86. 4
    1
      modules/overlay/primitive/ScanCirclePrimitive.js
  87. 4
    1
      modules/overlay/primitive/TrailLinePrimitive.js
  88. 4
    1
      modules/overlay/primitive/VideoPrimitive.js
  89. 4
    1
      modules/overlay/primitive/WaterPrimitive.js
  90. 4
    1
      modules/overlay/vector/Billboard.js
  91. 4
    1
      modules/overlay/vector/Box.js
  92. 5
    2
      modules/overlay/vector/Circle.js
  93. 4
    1
      modules/overlay/vector/Corridor.js
  94. 4
    1
      modules/overlay/vector/Cylinder.js
  95. 4
    1
      modules/overlay/vector/Ellipse.js
  96. 4
    1
      modules/overlay/vector/Ellipsoid.js
  97. 4
    1
      modules/overlay/vector/Label.js
  98. 4
    1
      modules/overlay/vector/Plane.js
  99. 4
    1
      modules/overlay/vector/Point.js
  100. 0
    0
      modules/overlay/vector/Polygon.js

+ 1
- 1
.eslintignore Переглянути файл

@@ -1,4 +1,4 @@
/libs/
/web/
/pack/
dist/*

+ 1
- 1
.github/FUNDING.yml Переглянути файл

@@ -1 +1 @@
custom: ["https://www.paypal.com/paypalme/cavencj","https://www.dvgis.cn","https://www.cavencj.cn"]
custom: ["https://resource.dvgis.cn/dc-docs/v2.x/zh/introduction/#%E6%94%AF%E6%8C%81","https://www.paypal.com/paypalme/cavencj","https://www.dvgis.cn","https://www.cavencj.cn"]

+ 134
- 0
CHANGES_en.md Переглянути файл

@@ -1,5 +1,139 @@
# Change Log

### 2.6.0 - 2021-10-10

#### Breaking Changes 📣

- Upgrade Cesium to version 1.86.0

#### Fixes 🔧

- Improve the MapSwitch [#70](https://github.com/dvgis/dc-sdk/issues/70)
- Improve the AroundView [#72](https://github.com/dvgis/dc-sdk/issues/72)

### 2.5.0 - 2021-09-04

#### Breaking Changes 📣

- Upgrade Cesium to version 1.85.0

#### Fixes 🔧

- Fix the problem that roaming cannot set parameters and the failed camera cannot move [#65](https://github.com/dvgis/dc-sdk/issues/65)
- Fix the problem that the gradient setting of heat layer [#66](https://github.com/dvgis/dc-sdk/issues/66)
- Improve the DivIcon style

### 2.4.2 - 2021-08-28

#### Fixes 🔧

- Hide the chart layer at the back [#55](https://github.com/dvgis/dc-sdk/issues/55)
- Hide the div icon at the back [#56](https://github.com/dvgis/dc-sdk/issues/56)
- Improve the position editor [#57](https://github.com/dvgis/dc-sdk/issues/57)
- Improve the terrain clipping [#58](https://github.com/dvgis/dc-sdk/issues/58)

### 2.4.1 - 2021-08-21

#### Additions 🎉

- Added support for layer mouse events [#53](https://github.com/dvgis/dc-sdk/issues/54)
- Add partial mouse default events [#54](https://github.com/dvgis/dc-sdk/issues/54)
- Add function to get tile information

#### Fixes 🔧

- Improve the plot function

### 2.4.0 - 2021-08-07

#### Breaking Changes 📣

- Upgrade Cesium to version 1.84.0

#### Additions 🎉

- Add bounce primitive overlays
- Add model collection primitive

#### Fixes 🔧

- Refine type property
- Improve mouse event
- Improve once event

### 2.3.2 - 2021-07-25

#### Additions 🎉

- Add model primitive to get node-related functions [#51](https://github.com/dvgis/dc-sdk/issues/51)

#### Fixes 🔧

- Improve the history track restore function [#50](https://github.com/dvgis/dc-sdk/issues/50)

### 2.3.1 - 2021-07-19

#### Breaking Changes 📣

- Refactored plotting function
- Remove Position rounding function
- Refine the infrastructure part of the script

#### Additions 🎉

- Add spatial measurement tools
- Add the plotting tool module
- Add function midCartesian to calculate the middle point of Cartesian3

#### Fixes 🔧

- Improve the Position copy function
- Improve the model editing tool for 3dtiles position editing function
- Improve the function area
- Improve the function of calculating the point position of a sector


### 2.3.0 - 2021-07-03

#### Breaking Changes 📣

- Upgrade Cesium to version 1.83.0

#### Additions 🎉

- Add constants for mouse mode
- Add property settings for globe terrain exaggeration

#### Fixes 🔧

- Improve the parsePositions for string coords

### 2.2.5 - 2021-06-26

#### Additions 🎉

- Adds line and face rotation conversion calculations

#### Fixes 🔧

- Improve the interpolation of history track
- Improve the function of plot for above the overlay
- Fix the problem of flickering when analyzing transformation parameters in the viewable field [#37](https://github.com/dvgis/dc-sdk/issues/37)
- Fix the problem that DivIcon cannot get the current coordinates set to (0,0,0) by default [#38](https://github.com/dvgis/dc-sdk/issues/38)

### 2.2.4 - 2021-06-12

#### Breaking Changes 📣

- Refactored the roaming function into first-person roaming and keyboard roaming [#34](https://github.com/dvgis/dc-sdk/issues/34)
- Original roaming function becomes history track, refine its pause and play [#35](https://github.com/dvgis/dc-sdk/issues/35)

#### Fixes 🔧

- Improve heading function
- Improve diffuse wall primitive
- Fixes RadarScan missing Cesium issue [#33](https://github.com/dvgis/dc-sdk/issues/33)

### 2.2.3 - 2021-06-05

#### Breaking Changes 📣

+ 133
- 5
CHANGES_zh.md Переглянути файл

@@ -1,5 +1,138 @@
# Change Log

### 2.6.0 - 2021-10-10

#### Breaking Changes 📣

- 升级 Cesium 到 1.86.0 版本

#### Fixes 🔧

- 完善地图切换组件样式 [#70](https://github.com/dvgis/dc-sdk/issues/70)
- 完善相机环绕功能 [#72](https://github.com/dvgis/dc-sdk/issues/72)

### 2.5.0 - 2021-09-04

#### Breaking Changes 📣

- 升级 Cesium 到 1.85.0 版本

#### Fixes 🔧

- 修复漫游无法设置参数以及失效相机无法移动的问题 [#65](https://github.com/dvgis/dc-sdk/issues/65)
- 修复热区图层渐变设置失效的问题 [#66](https://github.com/dvgis/dc-sdk/issues/66)
- 完善DivIcon的样式设定

### 2.4.2 - 2021-08-28

#### Fixes 🔧

- 隐藏图表图层当在地球背面 [#55](https://github.com/dvgis/dc-sdk/issues/55)
- 隐藏DivIcon当在地球背面时 [#56](https://github.com/dvgis/dc-sdk/issues/56)
- 完善模型位置编辑工具 [#57](https://github.com/dvgis/dc-sdk/issues/57)
- 完善地形裁剪分析 [#58](https://github.com/dvgis/dc-sdk/issues/58)

### 2.4.1 - 2021-08-21

#### Additions 🎉

- 添加图层鼠标事件的支持 [#53](https://github.com/dvgis/dc-sdk/issues/54)
- 添加部分鼠标默认事件 [#54](https://github.com/dvgis/dc-sdk/issues/54)
- 添加获取瓦片信息的函数

#### Fixes 🔧

- 完善标绘功能

### 2.4.0 - 2021-08-07

#### Breaking Changes 📣

- 升级 Cesium 到 1.84.0 版本

#### Additions 🎉

- 添加跳动图元覆盖物
- 添加模型集合图元

#### Fixes 🔧

- 完善类型属性
- 完善鼠标事件的管理
- 完善 once 事件

### 2.3.2 - 2021-07-25

#### Additions 🎉

- 添加模型图元获取节点相关函数 [#51](https://github.com/dvgis/dc-sdk/issues/51)

#### Fixes 🔧

- 完善历史轨迹恢复功能 [#50](https://github.com/dvgis/dc-sdk/issues/50)

### 2.3.1 - 2021-07-19

#### Breaking Changes 📣

- 重构标绘功能
- 移除Position舍弃函数
- 完善基础架构部分脚本

#### Additions 🎉

- 添加空间测量工具
- 添加标绘工具模块
- 添加函数 midCartesian,计算笛卡尔坐标系的中间点位

#### Fixes 🔧

- 完善Position复制功能
- 完善模型编辑工具对于3dtiles的位置编辑功能
- 完善函数 area
- 完善扇形的点位计算功能

### 2.3.0 - 2021-07-03

#### Breaking Changes 📣

- 升级 Cesium 到 1.83.0 版本

#### Additions 🎉

- 添加鼠标模式的常量
- 添加地球地形夸张的属性设置

#### Fixes 🔧

- 完善字符串坐标转换功能

### 2.2.5 - 2021-06-26

#### Additions 🎉

- 添加线和面的旋转转换计算

#### Fixes 🔧

- 完善历史轨迹的插值方式
- 完善标绘模块在模型上标绘的功能
- 修复可视域分析变换参数时闪烁的问题[#37](https://github.com/dvgis/dc-sdk/issues/37)
- 修复 DivIcon 无法获取当前坐标默认设置为 (0,0,0) 的问题[#38](https://github.com/dvgis/dc-sdk/issues/38)

### 2.2.4 - 2021-06-12

#### Breaking Changes 📣

- 重构漫游功能,漫游功能分为第一人称漫游和键盘漫游[#34](https://github.com/dvgis/dc-sdk/issues/34)
- 原有的漫游功能变为历史轨迹,完善其暂停和播放[#35](https://github.com/dvgis/dc-sdk/issues/35)

#### Fixes 🔧

- 完善 heading 函数
- 完善扩散墙功能
- 修复 RadarScan 缺少 Cesium 的问题[#33](https://github.com/dvgis/dc-sdk/issues/33)

### 2.2.3 - 2021-06-05

#### Breaking Changes 📣
@@ -79,11 +212,6 @@
- 开放部分 Cesium 内部函数
- 添加 FeatureGridLayer

#### Additions 🎉

- 添加 DivIcon 鼠标移入和移出功能
- 添加地图当前分辨率和视野范围属性

#### Fixes 🔧

- 修复部分军标无法使用的问题[#24](https://github.com/dvgis/dc-sdk/issues/24)

+ 4
- 4
README.md Переглянути файл

@@ -19,7 +19,7 @@

[**🇨🇳 中文**](./README_zh.md) | [**🇬🇧English**](./README.md)

**_`DC-SDK`_** is based on the open source project **_`Cesium`_** for the second development of two three-dimensional **_`WebGis`_** application framework , the framework optimizes the use of **_`Cesium`_** and adds some additional features , designed for developers to quickly build **_`WebGis`_** application.
`DC-SDK` is based on the open source project `Cesium` for the second development of two three-dimensional `WebGis` application framework , the framework optimizes the use of `Cesium` and adds some additional features , designed for developers to quickly build `WebGis` application.

```warning
Tips:This SDK is JS+GIS framework package. Developers need to have some front-end technology and GIS related technology
@@ -91,7 +91,7 @@ Please put the resources in the project root directory libs/dc-sdk, if you put i

> The configuration is mainly used in the `NPM / YARN` way

Since the DC framework sets `CESIUM_BASE_URL` to `JSON.stringify('. /libs/dc-sdk/resources/')`, you need to copy `Cesium` static resource files: `Assets`, `Workers`, `ThirdParty` to the `libs/dc-sdk/resources` directory of the project to ensure that the 3D scene can be rendered properly.
Since the `DC` framework sets `CESIUM_BASE_URL` to `./libs/dc-sdk/resources/` , you need to copy `Cesium` related static resources files: `Assets` , `Workers` , `ThirdParty `to `libs/dc-sdk/resources` directory of the project to ensure that the 3D scene can be rendered properly. You can also use `DC.baseUrl` to set the static resource base related to `Cesium` .

`Webpack`

@@ -176,10 +176,10 @@ DC.ready(() => {

## Demo

| ![picture](http://dc.dvgis.cn/examples/images/baselayer/baidu.png?v=2) | ![picture](http://dc.dvgis.cn/examples/images/baselayer/tdt.png?v=1) | ![picture](http://dc.dvgis.cn/examples/images/baselayer/arcgis.png?v=2) | ![picture](http://dc.dvgis.cn/examples/images/mini-scene/china.gif) |
| ![picture](http://dc.dvgis.cn/examples/images/baselayer/baidu.png?v=3) | ![picture](http://dc.dvgis.cn/examples/images/baselayer/tdt.png?v=2) | ![picture](http://dc.dvgis.cn/examples/images/baselayer/arcgis.png?v=3) | ![picture](http://dc.dvgis.cn/examples/images/mini-scene/china.gif) |
| :-----------------------------------------------------------: | :-----------------------------------------------------------: | :------------------------------------------------------------------: | :--------------------------------------------------------------: |
| ![picture](http://dc.dvgis.cn/examples/images/mini-scene/dfmz.gif) | ![picture](http://dc.dvgis.cn/examples/images/mini-scene/factory.gif?v=1) | ![picture](http://dc.dvgis.cn/examples/images/layer/cluster_circle.gif) | ![picture](http://dc.dvgis.cn/examples/images/model/shp_custom_shader.gif) |
| ![picture](http://dc.dvgis.cn/examples/images/overlay/polyline_image_trail.gif) | ![picture](http://dc.dvgis.cn/examples/images/overlay/wall_trail.gif?v=1) | ![picture](http://dc.dvgis.cn/examples/images/overlay/water.gif?v=2) | ![picture](http://dc.dvgis.cn/examples/images/overlay/plot-overlay.png) |
| ![picture](http://dc.dvgis.cn/examples/images/overlay/polyline_image_trail.gif) | ![picture](http://dc.dvgis.cn/examples/images/overlay/wall_trail.gif?v=1) | ![picture](http://dc.dvgis.cn/examples/images/overlay/water.gif?v=4) | ![picture](http://dc.dvgis.cn/examples/images/overlay/plot-overlay.png?v=4) |

[More>>](http://dc.dvgis.cn/#/examples)


+ 4
- 4
README_zh.md Переглянути файл

@@ -19,7 +19,7 @@

[**🇨🇳 中文**](./README_zh.md) | [**🇬🇧English**](./README.md)

> DC-SDK 是基于 Cesium 进行二次开发的2、3D一体 WebGis 应用框架,该框架优化了 Cesium 的使用方式和增添了一些额外功能,旨在为开发者快速构建 WebGis 应用。
> `DC-SDK` 是基于开源项目 `Cesium` 进行二次开发的二三维一体的 `WebGis` 应用框架,该框架优化了部分 `Cesium` 的使用方式和增添一些通用功能,旨在为开发者快速构建 `WebGis` 应用。

```warning
Tips:本框架是 JS+GIS 的框架包。开发者需要有一定的前端技术和 GIS 相关技术
@@ -96,7 +96,7 @@ import '@dvgis/dc-core/dist/dc.core.min.css' // 主要样式

> 配置主要用于 `NPM / YARN` 的方式

由于 DC 框架中将 `CESIUM_BASE_URL` 设置为 `JSON.stringify('./libs/dc-sdk/resources/')`,这样需将 `Cesium` 相关的静态资源文件: `Assets`、`Workers` 、`ThirdParty` 复制到工程的 `libs/dc-sdk/resources` 目录下以保证三维场景能够正常呈现
由于 `DC` 框架中将 `CESIUM_BASE_URL` 设置为 `./libs/dc-sdk/resources/` ,这样需将 Cesium 相关的静态资源文件: `Assets` 、`Workers` 、`ThirdParty` 复制到工程的 `libs/dc-sdk/resources` 目录下以保证三维场景能够正常呈现,也可通过 `DC.baseUrl` 进行 `Cesium` 相关的静态资源路基设置

`Webpack`

@@ -188,10 +188,10 @@ DC.ready(() => {

## 示例

| ![picture](http://dc.dvgis.cn/examples/images/baselayer/baidu.png?v=2) | ![picture](http://dc.dvgis.cn/examples/images/baselayer/tdt.png?v=1) | ![picture](http://dc.dvgis.cn/examples/images/baselayer/arcgis.png?v=2) | ![picture](http://dc.dvgis.cn/examples/images/mini-scene/china.gif) |
| ![picture](http://dc.dvgis.cn/examples/images/baselayer/baidu.png?v=3) | ![picture](http://dc.dvgis.cn/examples/images/baselayer/tdt.png?v=2) | ![picture](http://dc.dvgis.cn/examples/images/baselayer/arcgis.png?v=3) | ![picture](http://dc.dvgis.cn/examples/images/mini-scene/china.gif) |
| :-----------------------------------------------------------: | :-----------------------------------------------------------: | :------------------------------------------------------------------: | :--------------------------------------------------------------: |
| ![picture](http://dc.dvgis.cn/examples/images/mini-scene/dfmz.gif) | ![picture](http://dc.dvgis.cn/examples/images/mini-scene/factory.gif?v=1) | ![picture](http://dc.dvgis.cn/examples/images/layer/cluster_circle.gif) | ![picture](http://dc.dvgis.cn/examples/images/model/shp_custom_shader.gif) |
| ![picture](http://dc.dvgis.cn/examples/images/overlay/polyline_image_trail.gif) | ![picture](http://dc.dvgis.cn/examples/images/overlay/wall_trail.gif?v=1) | ![picture](http://dc.dvgis.cn/examples/images/overlay/water.gif?v=2) | ![picture](http://dc.dvgis.cn/examples/images/overlay/plot-overlay.png) |
| ![picture](http://dc.dvgis.cn/examples/images/overlay/polyline_image_trail.gif) | ![picture](http://dc.dvgis.cn/examples/images/overlay/wall_trail.gif?v=1) | ![picture](http://dc.dvgis.cn/examples/images/overlay/water.gif?v=2) | ![picture](http://dc.dvgis.cn/examples/images/overlay/plot-overlay.png?v=3) |

[更多>>](http://dc.dvgis.cn/#/examples)


+ 8
- 0
modules/animation/AnimationType.js Переглянути файл

@@ -0,0 +1,8 @@
/**
* @Author: Caven
* @Date: 2021-08-01 00:12:06
*/

let AnimationType = {}

export default AnimationType

+ 1
- 0
modules/animation/index.js Переглянути файл

@@ -4,6 +4,7 @@
*/

export { default as Animation } from './Animation'
export { default as AnimationType } from './AnimationType'

/**
* types

+ 7
- 1
modules/animation/type/AroundPoint.js Переглянути файл

@@ -6,6 +6,7 @@
import { Cesium } from '@dc-modules/namespace'
import { Transform } from '@dc-modules/transform'
import Parse from '@dc-modules/parse/Parse'
import AnimationType from '../AnimationType'

import Animation from '../Animation'

@@ -16,7 +17,10 @@ class AroundPoint extends Animation {
this._options = options
this._heading = viewer.camera.heading
this._aroundAmount = 0.2
this.type = 'around_point'
}

get type() {
return AnimationType.AROUND_POINT
}

set position(position) {
@@ -68,4 +72,6 @@ class AroundPoint extends Animation {
}
}

AnimationType.AROUND_POINT = 'around_point'

export default AroundPoint

+ 15
- 3
modules/animation/type/AroundView.js Переглянути файл

@@ -5,6 +5,7 @@

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

class AroundView extends Animation {
constructor(viewer, options = {}) {
@@ -12,7 +13,10 @@ class AroundView extends Animation {
this._options = options
this._heading = viewer.camera.heading
this._aroundAmount = 0.2
this.type = 'around_view'
}

get type() {
return AnimationType.AROUND_VIEW
}

set aroundAmount(aroundAmount) {
@@ -48,12 +52,20 @@ class AroundView extends Animation {
if (this._heading >= Math.PI * 2 || this._heading <= -Math.PI * 2) {
this._heading = 0
}
this._viewer.scene.camera.setView({
this._viewer.camera.setView({
orientation: {
heading: this._heading
heading: this._heading,
pitch: this._options.pitch
? Cesium.Math.toRadians(this._options.pitch)
: this._viewer.camera.pitch,
roll: this._options.roll
? Cesium.Math.toRadians(this._options.roll)
: this._viewer.camera.roll
}
})
}
}

AnimationType.AROUND_VIEW = 'around_view'

export default AroundView

+ 7
- 1
modules/animation/type/CircleScan.js Переглянути файл

@@ -8,6 +8,7 @@ import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import Animation from '../Animation'
import AnimationType from '../AnimationType'

const CircleScanShader = require('@dc-modules/material/shader/circle/CircleScanShader.glsl')

@@ -19,7 +20,10 @@ class CircleScan extends Animation {
this._radius = radius || 100
this._color = options.color || Cesium.Color.RED
this._speed = options.speed || 2
this.type = 'circle_scan'
}

get type() {
return AnimationType.CIRCLE_SCAN
}

/**
@@ -78,4 +82,6 @@ class CircleScan extends Animation {
}
}

AnimationType.CIRCLE_SCAN = 'circle_scan'

export default CircleScan

+ 7
- 1
modules/animation/type/Flying.js Переглянути файл

@@ -7,6 +7,7 @@ import { Cesium } from '@dc-modules/namespace'
import Parse from '@dc-modules/parse/Parse'
import { Transform } from '@dc-modules/transform'
import Animation from '../Animation'
import AnimationType from '../AnimationType'

class Flying extends Animation {
constructor(viewer, options = {}) {
@@ -15,10 +16,13 @@ class Flying extends Animation {
this._positions = []
this._durations = [3]
this._currentIndex = 0

this._timer = undefined
}

get type() {
return AnimationType.FLYING
}

set positions(positions) {
this._positions = Parse.parsePositions(positions)
return this
@@ -113,4 +117,6 @@ class Flying extends Animation {
}
}

AnimationType.FLYING = 'flying'

export default Flying

+ 7
- 1
modules/animation/type/GlobeRotate.js Переглянути файл

@@ -5,12 +5,16 @@

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

class GlobeRotate extends Animation {
constructor(viewer, options = {}) {
super(viewer)
this._options = options
this.type = 'globe_rotate'
}

get type() {
return AnimationType.GLOBE_ROTATE
}

/**
@@ -53,4 +57,6 @@ class GlobeRotate extends Animation {
}
}

AnimationType.GLOBE_ROTATE = 'globe_rotate'

export default GlobeRotate

+ 7
- 1
modules/animation/type/RadarScan.js Переглянути файл

@@ -8,6 +8,7 @@ import Parse from '@dc-modules/parse/Parse'
import { Util } from '@dc-modules/utils'
import { Transform } from '@dc-modules/transform'
import Animation from '../Animation'
import AnimationType from '../AnimationType'

const RadarScanShader = require('@dc-modules/material/shader/radar/RadarScanShader.glsl')

@@ -19,7 +20,10 @@ class RadarScan extends Animation {
this._color = options.color || Cesium.Color.BLUE
this._speed = options.speed || 3
this._delegate = undefined
this.type = 'radar_scan'
}

get type() {
return AnimationType.RADAR_SCAN
}

/**
@@ -92,4 +96,6 @@ class RadarScan extends Animation {
}
}

AnimationType.RADAR_SCAN = 'radar_scan'

export default RadarScan

+ 5
- 2
modules/chart/ChartLayer.js Переглянути файл

@@ -12,12 +12,15 @@ class ChartLayer extends Layer {
super(id)
this._option = option
this._delegate = DomUtil.create('div', 'dc-chart')
this._setWrapperStyle()
this._chart = undefined
this.type = Layer.getLayerType('chart')
this._setWrapperStyle()
this._state = State.INITIALIZED
}

get type() {
return Layer.getLayerType('chart')
}

get chart() {
return this._chart
}

+ 9
- 9
modules/chart/extension/CoordinateSystem.js Переглянути файл

@@ -23,20 +23,20 @@ class CoordinateSystem {
}

dataToPoint(data) {
let scene = this._viewer.scene
let result = [0, 0]
let result = []
let cartesian3 = Cesium.Cartesian3.fromDegrees(data[0], data[1])
if (!cartesian3) {
return result
}
if (
scene.mode === Cesium.SceneMode.SCENE3D &&
Cesium.Cartesian3.angleBetween(scene.camera.position, cartesian3) >
Cesium.Math.toRadians(80)
) {
return false
let up = Cesium.Ellipsoid.WGS84.geodeticSurfaceNormal(
cartesian3,
new Cesium.Cartesian3()
)
let cd = this._viewer.camera.direction
if (Cesium.Cartesian3.dot(up, cd) >= 0) {
return result
}
let coords = scene.cartesianToCanvasCoordinates(cartesian3)
let coords = this._viewer.scene.cartesianToCanvasCoordinates(cartesian3)
if (!coords) {
return result
}

+ 1
- 1
modules/copy-right/index.js Переглянути файл

@@ -10,7 +10,7 @@ console.clear()
console.log(
`%c \n DC-SDK \n %c \n 用数字描绘世界之美 %c \n
版本:${__VERSION__} - ${__TIME__}
Cesium版本:1.81.0
Cesium版本:1.86.0
开发作者:${__AUTHOR__}
网站主页: ${__HOME_PAGE__}
github:${__REPOSITORY__}

+ 4
- 1
modules/effect/type/BlackAndWhite.js Переглянути файл

@@ -13,10 +13,13 @@ class BlackAndWhite {
this._enable = false
this._gradations = 1
this._selected = []
this.type = 'black_and_white'
this._state = State.INITIALIZED
}

get type() {
return 'black_and_white'
}

set enable(enable) {
this._enable = enable
if (enable && this._viewer && !this._delegate) {

+ 4
- 1
modules/effect/type/Bloom.js Переглянути файл

@@ -16,10 +16,13 @@ class Bloom {
this._sigma = 3.8
this._stepSize = 5
this._selected = []
this.type = 'bloom'
this._state = State.INITIALIZED
}

get type() {
return 'bloom'
}

set enable(enable) {
this._enable = enable
if (enable && this._viewer && !this._delegate) {

+ 4
- 1
modules/effect/type/Brightness.js Переглянути файл

@@ -13,10 +13,13 @@ class Brightness {
this._enable = false
this._intensity = 1
this._selected = []
this.type = 'brightness'
this._state = State.INITIALIZED
}

get type() {
return 'brightness'
}

set enable(enable) {
this._enable = enable
if (enable && this._viewer && !this._delegate) {

+ 4
- 1
modules/effect/type/DepthOfField.js Переглянути файл

@@ -16,10 +16,13 @@ class DepthOfField {
this._sigma = 3.8
this._stepSize = 2.5
this._selected = []
this.type = 'depth_of_field'
this._state = State.INITIALIZED
}

get type() {
return 'depth_of_field'
}

set enable(enable) {
this._enable = enable
if (

+ 4
- 1
modules/effect/type/LensFlare.js Переглянути файл

@@ -16,10 +16,13 @@ class LensFlare {
this._dirtAmount = 0.4
this._haloWidth = 0.4
this._selected = []
this.type = 'lens_flare'
this._state = State.INITIALIZED
}

get type() {
return 'lens_flare'
}

set enable(enable) {
this._enable = enable
if (enable && this._viewer && !this._delegate) {

+ 4
- 1
modules/effect/type/NightVision.js Переглянути файл

@@ -10,10 +10,13 @@ class NightVision {
constructor() {
this._enable = false
this._selected = []
this.type = 'night'
this._state = State.INITIALIZED
}

get type() {
return 'night'
}

set enable(enable) {
this._enable = enable
if (enable && this._viewer && !this._delegate) {

+ 4
- 1
modules/effect/type/Silhouette.js Переглянути файл

@@ -14,10 +14,13 @@ class Silhouette {
this._color = Cesium.Color.GREEN
this._length = 0.5
this._selected = []
this.type = 'silhouette'
this._state = State.INITIALIZED
}

get type() {
return 'silhouette'
}

set enable(enable) {
this._enable = enable
if (

+ 4
- 0
modules/effect/type/Sun.js Переглянути файл

@@ -0,0 +1,4 @@
/**
* @Author: Caven
* @Date: 2021-08-01 00:22:00
*/

+ 8
- 2
modules/event/Event.js Переглянути файл

@@ -78,8 +78,14 @@ class Event {
* @param context
*/
once(type, callback, context) {
let removeCallback = this._on(type, callback, context)
removeCallback && removeCallback()
let removeCallback = this._on(
type,
e => {
callback(e)
removeCallback && removeCallback()
},
context
)
}

/**

+ 34
- 2
modules/event/EventType.js Переглянути файл

@@ -11,7 +11,11 @@ const BaseEventType = {
}

const MouseEventType = {
LEFT_DOWN: Cesium.ScreenSpaceEventType.LEFT_DOWN,
LEFT_UP: Cesium.ScreenSpaceEventType.LEFT_UP,
CLICK: Cesium.ScreenSpaceEventType.LEFT_CLICK,
RIGHT_DOWN: Cesium.ScreenSpaceEventType.RIGHT_DOWN,
RIGHT_UP: Cesium.ScreenSpaceEventType.RIGHT_UP,
RIGHT_CLICK: Cesium.ScreenSpaceEventType.RIGHT_CLICK,
DB_CLICK: Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
MOUSE_MOVE: Cesium.ScreenSpaceEventType.MOUSE_MOVE,
@@ -25,7 +29,11 @@ const ViewerEventType = {
REMOVE_LAYER: 'removeLayer',
ADD_EFFECT: 'addEffect',
REMOVE_EFFECT: 'removeEffect',
LEFT_DOWN: Cesium.ScreenSpaceEventType.LEFT_DOWN,
LEFT_UP: Cesium.ScreenSpaceEventType.LEFT_UP,
CLICK: Cesium.ScreenSpaceEventType.LEFT_CLICK,
RIGHT_DOWN: Cesium.ScreenSpaceEventType.RIGHT_DOWN,
RIGHT_UP: Cesium.ScreenSpaceEventType.RIGHT_UP,
RIGHT_CLICK: Cesium.ScreenSpaceEventType.RIGHT_CLICK,
DB_CLICK: Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
MOUSE_MOVE: Cesium.ScreenSpaceEventType.MOUSE_MOVE,
@@ -45,7 +53,11 @@ const SceneEventType = {

const OverlayEventType = {
...BaseEventType,
LEFT_DOWN: Cesium.ScreenSpaceEventType.LEFT_DOWN,
LEFT_UP: Cesium.ScreenSpaceEventType.LEFT_UP,
CLICK: Cesium.ScreenSpaceEventType.LEFT_CLICK,
RIGHT_DOWN: Cesium.ScreenSpaceEventType.RIGHT_DOWN,
RIGHT_UP: Cesium.ScreenSpaceEventType.RIGHT_UP,
RIGHT_CLICK: Cesium.ScreenSpaceEventType.RIGHT_CLICK,
DB_CLICK: Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
MOUSE_MOVE: Cesium.ScreenSpaceEventType.MOUSE_MOVE,
@@ -58,7 +70,13 @@ const LayerGroupEventType = BaseEventType

const LayerEventType = {
...BaseEventType,
CLICK: Cesium.ScreenSpaceEventType.LEFT_CLICK
LEFT_DOWN: Cesium.ScreenSpaceEventType.LEFT_DOWN,
LEFT_UP: Cesium.ScreenSpaceEventType.LEFT_UP,
CLICK: Cesium.ScreenSpaceEventType.LEFT_CLICK,
RIGHT_DOWN: Cesium.ScreenSpaceEventType.RIGHT_DOWN,
RIGHT_UP: Cesium.ScreenSpaceEventType.RIGHT_UP,
RIGHT_CLICK: Cesium.ScreenSpaceEventType.RIGHT_CLICK,
DB_CLICK: Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK
}

const TrackEventType = {
@@ -75,6 +93,19 @@ const PathEventType = {
RESET_TIME_LINE: 'restTimeLine'
}

const PlotEventType = {
DRAW_START: 'drawStart',
DRAW_STOP: 'drawStop',
EDIT_START: 'editStart',
EDIT_STOP: 'editEnd',
DRAW_ANCHOR: 'drawAnchor',
CREATE_ANCHOR: 'createAnchor',
UPDATE_ANCHOR: 'updateAnchor',
ANCHOR_MOVING: 'anchorMoving',
EDIT_ANCHOR_STOP: 'editAnchorStop',
CLEAR_ANCHOR: 'clearAnchor'
}

export {
MouseEventType,
ViewerEventType,
@@ -83,5 +114,6 @@ export {
LayerEventType,
OverlayEventType,
TrackEventType,
PathEventType
PathEventType,
PlotEventType
}

+ 5
- 0
modules/event/index.js Переглянути файл

@@ -25,3 +25,8 @@ export { default as OverlayEvent } from './type/OverlayEvent'
*/
export { default as TrackEvent } from './type/TrackEvent'
export { default as PathEvent } from './type/PathEvent'

/**
* plot
*/
export { default as PlotEvent } from './type/PlotEvent'

+ 101
- 23
modules/event/type/MouseEvent.js Переглянути файл

@@ -16,8 +16,12 @@ class MouseEvent extends Event {
this._viewer = viewer
this._selected = undefined
this._setInputAction()
this.on(MouseEventType.LEFT_DOWN, this._leftDownHandler, this)
this.on(MouseEventType.LEFT_UP, this._leftUpHandler, this)
this.on(MouseEventType.CLICK, this._clickHandler, this)
this.on(MouseEventType.DB_CLICK, this._dbClickHandler, this)
this.on(MouseEventType.RIGHT_DOWN, this._rightDownHandler, this)
this.on(MouseEventType.RIGHT_UP, this._rightUpHandler, this)
this.on(MouseEventType.RIGHT_CLICK, this._rightClickHandler, this)
this.on(MouseEventType.MOUSE_MOVE, this._mouseMoveHandler, this)
this.on(MouseEventType.WHEEL, this._mouseWheelHandler, this)
@@ -126,22 +130,32 @@ class MouseEvent extends Event {
let overlayId = undefined

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

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

// for Cesium3DTileset
else if (target?.primitive instanceof Cesium.Cesium3DTileset) {
overlayId = target.primitive.overlayId
}

// for Primitve
else if (target?.primitive) {
overlayId = target.primitive.overlayId
}

return overlayId
}

/**
* Returns the target information for the mouse event
* @param target
* @returns {{overlay: any, feature: any, layer: any}}
* @returns {{instanceId: *, overlay: undefined, feature: undefined, layer: undefined}}
* @private
*/
_getTargetInfo(target) {
@@ -150,22 +164,22 @@ class MouseEvent extends Event {
let feature = undefined

// for Entity
if (target && target.id && target.id instanceof Cesium.Entity) {
if (target?.id instanceof Cesium.Entity) {
layer = this._viewer
.getLayers()
.filter(item => item.layerId === target.id.layerId)[0]
if (layer && layer.getOverlay) {
if (layer?.getOverlay) {
overlay = layer.getOverlay(target.id.overlayId)
}
}

// for Cesium3DTileFeature
else if (target && target instanceof Cesium.Cesium3DTileFeature) {
else if (target instanceof Cesium.Cesium3DTileFeature) {
layer = this._viewer
.getLayers()
.filter(item => item.layerId === target.tileset.layerId)[0]
feature = target
if (layer && layer.getOverlay) {
if (layer?.getOverlay) {
overlay = layer.getOverlay(target.tileset.overlayId)
if (feature && feature.getPropertyNames) {
let propertyNames = feature.getPropertyNames()
@@ -177,30 +191,31 @@ class MouseEvent extends Event {
}

// for Cesium3DTileset
else if (
target &&
target.primitive &&
target.primitive instanceof Cesium.Cesium3DTileset
) {
else if (target?.primitive instanceof Cesium.Cesium3DTileset) {
layer = this._viewer
.getLayers()
.filter(item => item.layerId === target.primitive.layerId)[0]
if (layer && layer.getOverlay) {
if (layer?.getOverlay) {
overlay = layer.getOverlay(target.primitive.overlayId)
}
}

// for Primitve
else if (target && target.primitive) {
else if (target?.primitive) {
layer = this._viewer
.getLayers()
.filter(item => item.layerId === target.primitive.layerId)[0]
if (layer && layer.getOverlay) {
if (layer?.getOverlay) {
overlay = layer.getOverlay(target.primitive.overlayId)
}
}

return { layer: layer, overlay: overlay, feature: feature }
return {
layer: layer,
overlay: overlay,
feature: feature,
instanceId: target?.instanceId
}
}

/**
@@ -213,15 +228,25 @@ class MouseEvent extends Event {
let event = undefined
let targetInfo = this._getTargetInfo(mouseInfo.target)
let overlay = targetInfo?.overlay
let layer = targetInfo?.layer
// get Overlay Event
if (overlay && overlay.overlayEvent) {
if (overlay?.overlayEvent) {
event = overlay.overlayEvent.getEvent(type)
}

// get Layer Event
if ((!event || event.numberOfListeners === 0) && layer?.layerEvent) {
event = layer.layerEvent.getEvent(type)
}

// get Viewer Event
if (!event || event.numberOfListeners === 0) {
if (
(!event || event.numberOfListeners === 0) &&
this._viewer?.viewerEvent
) {
event = this._viewer.viewerEvent.getEvent(type)
}

event &&
event.numberOfListeners > 0 &&
event.raiseEvent({
@@ -230,15 +255,24 @@ class MouseEvent extends Event {
})

// get Drill Pick Event
if (overlay && overlay.allowDrillPicking) {
if (overlay?.allowDrillPicking) {
let drillInfos = this._getDrillInfos(mouseInfo.windowPosition)
drillInfos.forEach(drillInfo => {
let dillOverlay = drillInfo?.overlay
let dillLayer = drillInfo?.layer
if (
dillOverlay?.overlayId !== overlay.overlayId &&
dillOverlay?.overlayEvent
) {
// get Overlay Event
event = dillOverlay.overlayEvent.getEvent(type)
// get Layer Event
if (
(!event || event.numberOfListeners === 0) &&
dillLayer?.layerEvent
) {
event = dillLayer.layerEvent.getEvent(type)
}
event &&
event.numberOfListeners > 0 &&
event.raiseEvent({
@@ -257,7 +291,7 @@ class MouseEvent extends Event {
* @private
*/
_clickHandler(movement) {
if (!movement || !movement.position) {
if (!movement?.position) {
return false
}
let mouseInfo = this._getMouseInfo(movement.position)
@@ -271,7 +305,7 @@ class MouseEvent extends Event {
* @private
*/
_dbClickHandler(movement) {
if (!movement || !movement.position) {
if (!movement?.position) {
return false
}
let mouseInfo = this._getMouseInfo(movement.position)
@@ -285,7 +319,7 @@ class MouseEvent extends Event {
* @private
*/
_rightClickHandler(movement) {
if (!movement || !movement.position) {
if (!movement?.position) {
return false
}
let mouseInfo = this._getMouseInfo(movement.position)
@@ -299,7 +333,7 @@ class MouseEvent extends Event {
* @private
*/
_mouseMoveHandler(movement) {
if (!movement || !movement.endPosition) {
if (!movement?.endPosition) {
return false
}
let mouseInfo = this._getMouseInfo(movement.endPosition)
@@ -318,6 +352,50 @@ class MouseEvent extends Event {
}
}

/**
* Default mouse left down event handler
* @param movement
* @private
*/
_leftDownHandler(movement) {
if (!movement?.position) {
return false
}
let mouseInfo = this._getMouseInfo(movement.position)
this._raiseEvent(MouseEventType.LEFT_DOWN, mouseInfo)
}

/**
* Default mouse left up event handler
* @param movement
* @private
*/
_leftUpHandler(movement) {
this._raiseEvent(MouseEventType.LEFT_UP, { movement })
}

/**
* Default mouse right down event handler
* @param movement
* @private
*/
_rightDownHandler(movement) {
if (!movement?.position) {
return false
}
let mouseInfo = this._getMouseInfo(movement.position)
this._raiseEvent(MouseEventType.RIGHT_DOWN, mouseInfo)
}

/**
* Default mouse right up event handler
* @param movement
* @private
*/
_rightUpHandler(movement) {
this._raiseEvent(MouseEventType.RIGHT_UP, { movement })
}

/**
* Default mouse wheel event handler
* @param movement

+ 27
- 0
modules/event/type/PlotEvent.js Переглянути файл

@@ -0,0 +1,27 @@
/**
* @Author: Caven
* @Date: 2020-05-11 23:28:13
*/

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

class PlotEvent extends Event {
constructor() {
super()
}

/**
*
* @private
*/
_registerEvent() {
Object.keys(PlotEventType).forEach(key => {
let type = PlotEventType[key]
this._cache[type] = new Cesium.Event()
})
}
}

export default PlotEvent

+ 7
- 3
modules/heat/HeatLayer.js Переглянути файл

@@ -42,6 +42,10 @@ class HeatLayer extends Layer {
this._state = State.INITIALIZED
}

get type() {
return Layer.getLayerType('heat')
}

/**
*
* @private
@@ -57,7 +61,7 @@ class HeatLayer extends Layer {

/**
*
* @returns {string|undefined}
* @returns {HTMLCanvasElement|undefined}
* @private
*/
_createGradientTexture() {
@@ -70,11 +74,11 @@ class HeatLayer extends Layer {
let ctx = canvas.getContext('2d')
let grd = ctx.createLinearGradient(0, 0, 200, 0)
for (let key in this._options.gradient) {
grd.addColorStop(+key, this._options.gradient[+key])
grd.addColorStop(+key, this._options.gradient[key])
}
ctx.fillStyle = grd
ctx.fillRect(0, 0, 200, 10)
return canvas.toDataURL()
return canvas
}

/**

+ 94
- 44
modules/history-track/Track.js Переглянути файл

@@ -13,12 +13,17 @@ import { heading, distance } from '@dc-modules/math'
import TrackViewMode from './TrackViewMode'

const DEF_OPTS = {
showPath: false,
pathWidth: 1,
pathMaterial: Cesium.Color.ORANGE.withAlpha(0.8),
pathLeadTime: 1,
clampToGround: false,
clampToTileset: false
clampToTileset: false,
interpolationType: 'Linear',
interpolationDegree: 2
}

const DEF_PATH_STYLE = {
width: 2,
material: Cesium.Color.ORANGE,
clampToGround: true,
depthFailMaterial: Cesium.Color.ORANGE.withAlpha(0.8)
}

class Track {
@@ -33,8 +38,19 @@ class Track {
...options
}
this._controller = undefined
this._sampledPosition = undefined
this._velocityOrientation = undefined
this._viewed = false
this._delegate = new Cesium.Entity()
this._pathPositions = []
this._path = new Cesium.Entity({
show: false,
polyline: {
positions: new Cesium.CallbackProperty(() => {
return this._pathPositions
})
}
})
this._positionIndex = 0
this._timeLine = []
this._startTime = undefined
@@ -43,6 +59,11 @@ class Track {
this._trackEvent.on(TrackEventType.POST_RENDER, this._onPostRender, this)
this._trackEvent.on(TrackEventType.ADD, this._onAdd, this)
this._trackEvent.on(TrackEventType.REMOVE, this._onRemove, this)
this._trackEvent.on(
TrackEventType.RESET_TIME_LINE,
this._resetTimeLine,
this
)
this._state = State.INITIALIZED
}

@@ -61,7 +82,7 @@ class Track {

set positions(postions) {
this._positions = Parse.parsePositions(postions)
this._resetTimeLine()
this._resetTimeLine({})
return this
}

@@ -71,7 +92,7 @@ class Track {

set duration(duration) {
this._duration = duration
this._resetTimeLine()
this._resetTimeLine({})
return this
}

@@ -85,7 +106,7 @@ class Track {
} else {
this._startTime = startTime
}
this._resetTimeLine()
this._resetTimeLine({})
return this
}

@@ -121,6 +142,7 @@ class Track {
}
this._controller = controller
this._controller.delegate.add(this._delegate)
this._controller.delegate.add(this._path)
!this._startTime && (this._startTime = Cesium.JulianDate.now())
this._state = State.ADDED
}
@@ -130,10 +152,13 @@ class Track {
* @private
*/
_onRemove() {
if (this._controller) {
this._controller.delegate.remove(this._delegate)
if (!this._controller) {
return false
}
this._controller.delegate.remove(this._delegate)
this._controller.delegate.remove(this._path)
this._viewed = false
this._startTime = undefined
this._state = State.REMOVED
}

@@ -148,28 +173,28 @@ class Track {
return false
}
let now = Cesium.JulianDate.now()
if (Cesium.JulianDate.lessThan(now, this._endTime)) {
if (Cesium.JulianDate.lessThanOrEquals(now, this._endTime)) {
let p = this._sampledPosition.getValue(now)
this._pathPositions.push(p)
if (this._options.clampToTileset) {
this._delegate.position = viewer.scene.clampToHeight(
this._sampledPosition.getValue(now),
[this._delegate]
)
this._delegate.position = viewer.scene.clampToHeight(p, [
this._delegate
])
} else {
this._delegate.position = this._sampledPosition.getValue(now)
this._delegate.position = p
}
let orientation = this._velocityOrientation.getValue(now)
if (orientation) {
this._delegate.orientation = orientation
}
let time = this._timeLine[this._positionIndex]
if (time) {
let timeDiff = Cesium.JulianDate.secondsDifference(now, time)
if (timeDiff >= 0 && timeDiff <= 1) {
let position = this._positions[this._positionIndex] || undefined
if (position) {
let mat = Cesium.Matrix3.fromQuaternion(
this._delegate.orientation.getValue(now)
)
let mat4 = Cesium.Matrix4.fromRotationTranslation(
mat,
this._sampledPosition.getValue(now)
)
if (position && orientation) {
let mat = Cesium.Matrix3.fromQuaternion(orientation)
let mat4 = Cesium.Matrix4.fromRotationTranslation(mat, p)
let hpr = Cesium.Transforms.fixedFrameToHeadingPitchRoll(mat4)
position.heading = Cesium.Math.toDegrees(hpr.heading)
position.pitch = Cesium.Math.toDegrees(hpr.pitch)
@@ -248,24 +273,26 @@ class Track {
return false
}
let interval = 0
let v = distance(this._positions) / this._duration
this._timeLine = this._positions.map((item, index, arr) => {
if (index !== 0) {
interval += distance([arr[index - 1], item]) / v
}
return Cesium.JulianDate.addSeconds(
this._startTime,
interval,
new Cesium.JulianDate()
)
})
if (params?.stopTime && params?.duration) {
if (!params?.stopTime && !params?.duration) {
let v = distance(this._positions) / this._duration
this._timeLine = this._positions.map((item, index, arr) => {
if (index !== 0) {
interval += distance([arr[index - 1], item]) / v
}
return Cesium.JulianDate.addSeconds(
this._startTime,
interval,
new Cesium.JulianDate()
)
})
this._pathPositions = []
} else if (params?.stopTime && params?.duration) {
this._duration += params.duration
this._timeLine = this._timeLine.map(item => {
if (Cesium.JulianDate.greaterThan(item, params.stopTime)) {
item = Cesium.JulianDate.addSeconds(
item,
params.stopTime,
params.duration,
new Cesium.JulianDate()
)
}
@@ -279,11 +306,24 @@ class Track {
)
this._sampledPosition.forwardExtrapolationType =
Cesium.ExtrapolationType.HOLD
this._sampledPosition.setInterpolationOptions({
interpolationDegree: 5,
interpolationAlgorithm: Cesium.HermitePolynomialApproximation
})
this._delegate.orientation = new Cesium.VelocityOrientationProperty(
/// setInterpolationOptions
if (this._options.interpolationType === 'Hermite') {
this._sampledPosition.setInterpolationOptions({
interpolationDegree: this._options.interpolationDegree || 2,
interpolationAlgorithm: Cesium.HermitePolynomialApproximation
})
} else if (this._options.interpolationType === 'Linear') {
this._sampledPosition.setInterpolationOptions({
interpolationDegree: this._options.interpolationDegree || 1,
interpolationAlgorithm: Cesium.LinearApproximation
})
} else if (this._options.interpolationType === 'Lagrange') {
this._sampledPosition.setInterpolationOptions({
interpolationDegree: this._options.interpolationDegree || 5,
interpolationAlgorithm: Cesium.LagrangePolynomialApproximation
})
}
this._velocityOrientation = new Cesium.VelocityOrientationProperty(
this._sampledPosition
)
this._endTime = this._timeLine[this._timeLine.length - 1]
@@ -298,7 +338,7 @@ class Track {
addPosition(position, duration) {
this._positions.push(Parse.parsePosition(position))
this._duration += duration
this._resetTimeLine()
this._resetTimeLine({})
return this
}

@@ -353,7 +393,17 @@ class Track {
return this
}

setPath() {}
/**
*
* @param visible
* @param style
* @returns {Track}
*/
setPath(visible, style = {}) {
this._path.show = !!visible
Util.merge(this._path.polyline, DEF_PATH_STYLE, style)
return this
}
}

export default Track

+ 2
- 2
modules/history-track/TrackController.js Переглянути файл

@@ -12,7 +12,7 @@ class TrackController {
this._viewer = viewer
this._cache = {}
this._delegete = new Cesium.CustomDataSource('history-track-layer')
viewer.dataSources.add(this._delegete)
this._viewer.dataSources.add(this._delegete)
this._activedTrack = undefined
this._viewMode = undefined
this._viewOption = {}
@@ -147,7 +147,7 @@ class TrackController {
let track = this._cache[key]
track.trackEvent.fire(TrackEventType.RESET_TIME_LINE, {
stopTime: this._stopTime,
duration: Cesium.JulianDate.secondsDifference(this._stopTime, now)
duration: Cesium.JulianDate.secondsDifference(now, this._stopTime)
})
})
}

+ 40
- 15
modules/layer/Layer.js Переглянути файл

@@ -22,8 +22,6 @@ class Layer {
this._layerEvent = new LayerEvent()
this._layerEvent.on(LayerEventType.ADD, this._onAdd, this)
this._layerEvent.on(LayerEventType.REMOVE, this._onRemove, this)
this._state = undefined
this.type = undefined
}

get layerId() {
@@ -129,13 +127,9 @@ class Layer {
* @private
*/
_addOverlay(overlay) {
if (
overlay &&
overlay.overlayEvent &&
!this._cache.hasOwnProperty(overlay.overlayId)
) {
if (!this._cache.hasOwnProperty(overlay.overlayId)) {
this._cache[overlay.overlayId] = overlay
this._delegate && overlay.overlayEvent.fire(OverlayEventType.ADD, this)
this._delegate && overlay.fire(OverlayEventType.ADD, this)
if (this._state === State.CLEARED) {
this._state = State.ADDED
}
@@ -148,12 +142,8 @@ class Layer {
* @private
*/
_removeOverlay(overlay) {
if (
overlay &&
overlay.overlayEvent &&
this._cache.hasOwnProperty(overlay.overlayId)
) {
this._delegate && overlay.overlayEvent.fire(OverlayEventType.REMOVE, this)
if (this._cache.hasOwnProperty(overlay.overlayId)) {
this._delegate && overlay.fire(OverlayEventType.REMOVE, this)
delete this._cache[overlay.overlayId]
}
}
@@ -278,7 +268,7 @@ class Layer {
* @returns {Layer}
*/
addTo(viewer) {
if (viewer && viewer.addLayer) {
if (viewer?.addLayer) {
viewer.addLayer(this)
}
return this
@@ -291,6 +281,41 @@ class Layer {
*/
setStyle(style) {}

/**
* Subscribe event
* @param type
* @param callback
* @param context
* @returns {Layer}
*/
on(type, callback, context) {
this._layerEvent.on(type, callback, context || this)
return this
}

/**
* Unsubscribe event
* @param type
* @param callback
* @param context
* @returns {Layer}
*/
off(type, callback, context) {
this._layerEvent.off(type, callback, context || this)
return this
}

/**
* Trigger subscription event
* @param type
* @param params
* @returns {Layer}
*/
fire(type, params) {
this._layerEvent.fire(type, params)
return this
}

/**
* Registers Type
* @param type

+ 4
- 1
modules/layer/LayerGroup.js Переглянути файл

@@ -17,7 +17,6 @@ class LayerGroup {
this._layerGroupEvent = new LayerGroupEvent()
this._layerGroupEvent.on(LayerGroupEventType.ADD, this._onAdd, this)
this._layerGroupEvent.on(LayerGroupEventType.REMOVE, this._onRemove, this)
this.type = Layer.getLayerType('layer_group')
this._state = State.INITIALIZED
}

@@ -25,6 +24,10 @@ class LayerGroup {
return this._id
}

get type() {
return Layer.getLayerType('layer_group')
}

set show(show) {
this._show = show
Object.keys(this._cache).forEach(key => {

+ 5
- 1
modules/layer/type/ClusterLayer.js Переглянути файл

@@ -35,10 +35,14 @@ class ClusterLayer extends Layer {
this
)
this._delegate.clustering.pixelRange = this._options.pixelRange
this.type = Layer.getLayerType('cluster')
this._state = State.INITIALIZED
}

get type() {
return Layer.getLayerType('cluster')
}

set enableCluster(enableCluster) {
this._delegate.clustering.enabled = enableCluster
return this

+ 4
- 1
modules/layer/type/CzmlLayer.js Переглянути файл

@@ -11,10 +11,13 @@ class CzmlLayer extends Layer {
constructor(id, url = '', options = {}) {
super(id)
this._delegate = Cesium.CzmlDataSource.load(url, options)
this.type = Layer.getLayerType('czml')
this._state = State.INITIALIZED
}

get type() {
return Layer.getLayerType('czml')
}

set show(show) {
this._show = show
this._delegate &&

+ 4
- 1
modules/layer/type/DynamicLayer.js Переглянути файл

@@ -11,10 +11,13 @@ class DynamicLayer extends Layer {
constructor(id) {
super(id)
this._delegate = new Cesium.CustomDataSource(id)
this.type = Layer.getLayerType('dynamic')
this._state = State.INITIALIZED
}

get type() {
return Layer.getLayerType('dynamic')
}

/**
* Clears all entities
* @returns {DynamicLayer}

+ 5
- 2
modules/layer/type/FeatureGridLayer.js Переглянути файл

@@ -13,7 +13,7 @@ const DEF_OPTS = {
count: 10,
maximumLevel: 21,
dataProperty: '',
callback: record => {
callback: () => {
return null
}
}
@@ -35,7 +35,6 @@ class FeatureGridLayer extends Layer {
this._rectangle = this._tilingScheme.rectangle
this._credit = undefined
this._token = undefined
this.type = Layer.getLayerType('feature_grid')
for (let i = 0; i < this.maximumLevel; i++) {
this._levelLayers[String(i)] = new VectorLayer(id + '-grid-' + i)
}
@@ -47,6 +46,10 @@ class FeatureGridLayer extends Layer {
this._state = State.INITIALIZED
}

get type() {
return Layer.getLayerType('feature_grid')
}

get url() {
return this._url
}

+ 4
- 1
modules/layer/type/GeoJsonLayer.js Переглянути файл

@@ -16,10 +16,13 @@ class GeoJsonLayer extends Layer {
}
super(id)
this._delegate = Cesium.GeoJsonDataSource.load(url, options)
this.type = Layer.getLayerType('geojson')
this._state = State.INITIALIZED
}

get type() {
return Layer.getLayerType('geojson')
}

set show(show) {
this._show = show
this._delegate &&

+ 15
- 4
modules/layer/type/HtmlLayer.js Переглянути файл

@@ -15,10 +15,13 @@ class HtmlLayer extends Layer {
this._delegate = DomUtil.create('div', 'html-layer', undefined)
this._delegate.setAttribute('id', this._id)
this._renderRemoveCallback = undefined
this.type = Layer.getLayerType('html')
this._state = State.INITIALIZED
}

get type() {
return Layer.getLayerType('html')
}

set show(show) {
this._show = show
this._delegate.style.visibility = this._show ? 'visible' : 'hidden'
@@ -42,16 +45,24 @@ class HtmlLayer extends Layer {
this._viewer.dcContainer.appendChild(this._delegate)
let scene = this._viewer.scene
this._renderRemoveCallback = scene.postRender.addEventListener(() => {
let cameraPosition = this._viewer.camera.positionWC
let cp = this._viewer.camera.positionWC
let cd = this._viewer.camera.direction
this.eachOverlay(item => {
if (item && item.position) {
let position = Transform.transformWGS84ToCartesian(item.position)
let up = scene.globe.ellipsoid.geodeticSurfaceNormal(
position,
new Cesium.Cartesian3()
)
let windowCoord = Cesium.SceneTransforms.wgs84ToWindowCoordinates(
scene,
position
)
let distance = Cesium.Cartesian3.distance(position, cameraPosition)
item._updateStyle({ transform: windowCoord }, distance)
item._updateStyle(
windowCoord,
Cesium.Cartesian3.distance(position, cp),
Cesium.Cartesian3.dot(cd, up) <= 0
)
}
}, this)
}, this)

+ 4
- 1
modules/layer/type/KmlLayer.js Переглянути файл

@@ -14,10 +14,13 @@ class KmlLayer extends Layer {
}
super(id)
this._delegate = Cesium.KmlDataSource.load(url, options)
this.type = Layer.getLayerType('kml')
this._state = State.INITIALIZED
}

get type() {
return Layer.getLayerType('kml')
}

set show(show) {
this._show = show
this._delegate &&

+ 4
- 1
modules/layer/type/LabelLayer.js Переглянути файл

@@ -14,10 +14,13 @@ class LabelLayer extends Layer {
this._dataSource = Cesium.GeoJsonDataSource.load(url)
this._delegate = new Cesium.CustomDataSource(id)
this._initLabel()
this.type = Layer.registerType('label')
this._state = State.INITIALIZED
}

get type() {
return Layer.getLayerType('label')
}

_createLabel(entity) {
if (entity.position && entity.name) {
return Label.fromEntity(entity)

+ 7
- 1
modules/layer/type/PrimitiveLayer.js Переглянути файл

@@ -7,6 +7,9 @@ import { Cesium } from '@dc-modules/namespace'
import State from '@dc-modules/state/State'
import Layer from '../Layer'

/**
* PrimitiveLayer is used to add primitve
*/
class PrimitiveLayer extends Layer {
constructor(id) {
super(id)
@@ -15,10 +18,13 @@ class PrimitiveLayer extends Layer {
this._labels = this._delegate.add(new Cesium.LabelCollection())
this._billboards = this._delegate.add(new Cesium.BillboardCollection())
this._polylines = this._delegate.add(new Cesium.PolylineCollection())
this.type = Layer.getLayerType('primitive')
this._state = State.INITIALIZED
}

get type() {
return Layer.getLayerType('primitive')
}

get points() {
return this._points
}

+ 4
- 1
modules/layer/type/TilesetLayer.js Переглянути файл

@@ -14,10 +14,13 @@ class TilesetLayer extends Layer {
constructor(id) {
super(id)
this._delegate = new Cesium.PrimitiveCollection()
this.type = Layer.getLayerType('tileset')
this._state = State.INITIALIZED
}

get type() {
return Layer.getLayerType('tileset')
}

/**
* Clear all tileset
* @returns {TilesetLayer}

+ 5
- 1
modules/layer/type/TopoJsonLayer.js Переглянути файл

@@ -5,6 +5,7 @@

import State from '@dc-modules/state/State'
import GeoJsonLayer from './GeoJsonLayer'
import Layer from '../Layer'

class TopoJsonLayer extends GeoJsonLayer {
constructor(id, url, options = {}) {
@@ -12,9 +13,12 @@ class TopoJsonLayer extends GeoJsonLayer {
throw new Error('TopoJsonLayer:the url invalid')
}
super(id, url, options)
this.type = GeoJsonLayer.getLayerType('topojson')
this._state = State.INITIALIZED
}

get type() {
return Layer.getLayerType('topojson')
}
}

GeoJsonLayer.registerType('topojson')

+ 4
- 1
modules/layer/type/VectorLayer.js Переглянути файл

@@ -15,10 +15,13 @@ class VectorLayer extends Layer {
constructor(id) {
super(id)
this._delegate = new Cesium.CustomDataSource(id)
this.type = Layer.getLayerType('vector')
this._state = State.INITIALIZED
}

get type() {
return Layer.getLayerType('vector')
}

/**
* Clears all entities
* @returns {VectorLayer}

+ 12
- 0
modules/loader/Loader.js Переглянути файл

@@ -0,0 +1,12 @@
/**
* @Author: Caven
* @Date: 2021-08-17 20:43:05
*/

class Loader {
static loadDCP() {}

static loadDPS(fileName, is) {}
}

export default Loader

+ 4
- 0
modules/loader/index.js Переглянути файл

@@ -0,0 +1,4 @@
/**
* @Author: Caven
* @Date: 2021-08-17 20:42:39
*/

+ 18
- 1
modules/loader/type/ViewerLoader.js Переглянути файл

@@ -1,4 +1,21 @@
/**
* @Author: Caven
* @Date: 2021-03-15 10:56:54
* @Date: 2021-08-17 20:41:50
*/

class ViewerLoader {
constructor() {}

/**
*
* @param options
* @returns {DC.Viewer}
*/
loader(options = {}) {
let viewer = new DC.Viewer(options.container || 'viewer-container')
viewer.setOptions(options)
return viewer
}
}

export default ViewerLoader

+ 4
- 0
modules/loader/type/WeatherLoader.js Переглянути файл

@@ -0,0 +1,4 @@
/**
* @Author: Caven
* @Date: 2021-08-17 20:52:16
*/

+ 5
- 1
modules/mapv/MapvLayer.js Переглянути файл

@@ -16,7 +16,11 @@ class MapvLayer extends Layer {
this._option = option
this._dataSet = undefined
this._delegate = undefined
this.type = Layer.getLayerType('mapv')
this._state = State.INITIALIZED
}

get type() {
return Layer.getLayerType('mapv')
}

set show(show) {

+ 3
- 0
modules/material/shader/polyline/PolylineImageTrailMaterial.glsl Переглянути файл

@@ -9,6 +9,9 @@ czm_material czm_getMaterial(czm_materialInput materialInput){
float time = fract(czm_frameNumber * speed / 1000.0);
vec4 colorImage = texture2D(image, vec2(fract(st.s - time), st.t));
if(color.a == 0.0){
if(colorImage.rgb == vec3(1.0) || colorImage.rgb == vec3(0.0)){
discard;
}
material.alpha = colorImage.a;
material.diffuse = colorImage.rgb;
}else{

+ 50
- 9
modules/math/area.js Переглянути файл

@@ -3,19 +3,60 @@
* @Date: 2020-04-24 14:49:37
*/

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

/**
*
* @param p0
* @param p1
* @param p2
* @returns {number}
* @private
*/
function triangleArea(p0, p1, p2) {
let v0 = Cesium.Cartesian3.subtract(p0, p1, new Cesium.Cartesian3())
let v1 = Cesium.Cartesian3.subtract(p2, p1, new Cesium.Cartesian3())
let cross = Cesium.Cartesian3.cross(v0, v1, v0)
return Cesium.Cartesian3.magnitude(cross) * 0.5
}

export default function area(positions) {
let result = 0
if (positions && Array.isArray(positions)) {
let h = 0
let pos = positions.concat(positions[0])
for (let i = 1; i < pos.length; i++) {
let oel = Transform.transformWGS84ToCartesian(pos[i - 1])
let el = Transform.transformWGS84ToCartesian(pos[i])
h += oel.x * el.y - el.x * oel.y
}
result = Math.abs(h).toFixed(2)
if (!Array.isArray(positions)) {
return result
}
if (!(positions[0] instanceof Cesium.Cartesian3)) {
positions = Transform.transformWGS84ArrayToCartesianArray(positions)
}
let geometry = Cesium.CoplanarPolygonGeometry.createGeometry(
Cesium.CoplanarPolygonGeometry.fromPositions({
positions: positions,
vertexFormat: Cesium.VertexFormat.POSITION_ONLY
})
)
if (!geometry) {
return result
}
let flatPositions = geometry.attributes.position.values
let indices = geometry.indices
for (let i = 0; i < indices.length; i += 3) {
let p0 = Cesium.Cartesian3.unpack(
flatPositions,
indices[i] * 3,
new Cesium.Cartesian3()
)
let p1 = Cesium.Cartesian3.unpack(
flatPositions,
indices[i + 1] * 3,
new Cesium.Cartesian3()
)
let p2 = Cesium.Cartesian3.unpack(
flatPositions,
indices[i + 2] * 3,
new Cesium.Cartesian3()
)
result += triangleArea(p0, p1, p2)
}
return result
}

+ 3
- 2
modules/math/index.js Переглянути файл

@@ -5,10 +5,11 @@

export { default as area } from './area'
export { default as bounds } from './bounds'
export { default as mid } from './mid'
export { default as center } from './center'
export { default as curve } from './curve'
export { default as distance } from './distance'
export { default as heading } from './heading'
export { default as isBetween } from './isBetween'
export { default as midCartesian } from './midCartesian'
export { default as midPosition } from './midPosition'
export { default as parabola } from './parabola'
export { default as curve } from './curve'

+ 13
- 0
modules/math/midCartesian.js Переглянути файл

@@ -0,0 +1,13 @@
/**
* @Author: Caven
* @Date: 2020-08-21 18:16:52
*/

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

export default function midCartesian(start, end) {
let c1 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(start)
let c2 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(end)
let cm = new Cesium.EllipsoidGeodesic(c1, c2).interpolateUsingFraction(0.5)
return Cesium.Ellipsoid.WGS84.cartographicToCartesian(cm)
}

modules/math/mid.js → modules/math/midPosition.js Переглянути файл

@@ -8,12 +8,11 @@ import { Transform } from '@dc-modules/transform'
import Parse from '@dc-modules/parse/Parse'
import Position from '@dc-modules/position/Position'

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

let mc = new Cesium.EllipsoidGeodesic(
startPosition,
endPosition

+ 4
- 1
modules/option/ViewerOption.js Переглянути файл

@@ -114,7 +114,10 @@ class ViewerOption {
depthTestAgainstTerrain: globeOption?.depthTestAgainstTerrain ?? false,
tileCacheSize: +globeOption?.tileCacheSize || 100,
preloadSiblings: globeOption?.enableLighting ?? false,
baseColor: globeOption?.baseColor || new Cesium.Color(0, 0, 0.5, 1)
baseColor: globeOption?.baseColor || new Cesium.Color(0, 0, 0.5, 1),
terrainExaggeration: globeOption?.terrainExaggeration || 1,
terrainExaggerationRelativeHeight:
globeOption?.terrainExaggerationRelativeHeight || 0
})

Util.merge(globe.translucency, {

+ 1
- 0
modules/option/index.js Переглянути файл

@@ -3,5 +3,6 @@
* @Date: 2020-03-05 22:00:17
*/

export { default as MouseMode } from './MouseMode'
export { default as ViewerOption } from './ViewerOption'
export { default as CameraOption } from './CameraOption'

+ 13
- 8
modules/overlay/Overlay.js Переглянути файл

@@ -22,9 +22,8 @@ class Overlay {
this._allowDrillPicking = false
this._contextMenu = []
this._overlayEvent = new OverlayEvent()
this.type = undefined
this.on(OverlayEventType.ADD, this._onAdd, this)
this.on(OverlayEventType.REMOVE, this._onRemove, this)
this._overlayEvent.on(OverlayEventType.ADD, this._onAdd, this)
this._overlayEvent.on(OverlayEventType.REMOVE, this._onRemove, this)
}

get overlayId() {
@@ -132,16 +131,19 @@ class Overlay {
this._layer.delegate.entities.add(this._delegate)
} else if (this._layer?.delegate?.add && this._delegate) {
// for Primitive
if (this.type === 'point_primitive' && this._layer.points) {
if (this.type && this.type === 'point_primitive' && this._layer.points) {
this._delegate = this._layer.points.add(this._delegate)
} else if (
this.type === 'billboard_primitive' &&
this.type.indexOf('billboard_primitive') >= 0 &&
this._layer.billboards
) {
this._delegate = this._layer.billboards.add(this._delegate)
} else if (this.type === 'polyline_primitive' && this._layer.polylines) {
this._delegate = this._layer.polylines.add(this._delegate)
} else if (this.type === 'label_primitive' && this._layer.labels) {
} else if (
this.type.indexOf('label_primitive') >= 0 &&
this._layer.labels
) {
this._delegate = this._layer.labels.add(this._delegate)
} else {
this._layer.delegate.add(this._delegate)
@@ -167,13 +169,16 @@ class Overlay {
if (this.type === 'point_primitive' && this._layer.points) {
this._layer.points.remove(this._delegate)
} else if (
this.type === 'billboard_primitive' &&
this.type.indexOf('billboard_primitive') >= 0 &&
this._layer.billboards
) {
this._layer.billboards.remove(this._delegate)
} else if (this.type === 'polyline_primitive' && this._layer.polylines) {
this._layer.polylines.remove(this._delegate)
} else if (this.type === 'label_primitive' && this._layer.labels) {
} else if (
this.type.indexOf('label_primitive') >= 0 &&
this._layer.labels
) {
this._layer.labels.remove(this._delegate)
} else {
this._layer.delegate.remove(this._delegate)

+ 5
- 2
modules/overlay/custom/CustomBillboard.js Переглянути файл

@@ -17,10 +17,13 @@ class CustomBillboard extends Overlay {
this._position = Parse.parsePosition(position)
this._icon = icon
this._size = [32, 32]
this.type = Overlay.getOverlayType('custom_billboard')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('custom_billboard')
}

set position(position) {
this._position = Parse.parsePosition(position)
this._delegate.position = Transform.transformWGS84ToCartesian(
@@ -130,7 +133,7 @@ class CustomBillboard extends Overlay {
...style,
semiMajorAxis: radius,
semiMinorAxis: radius,
stRotation: new Cesium.CallbackProperty(time => {
stRotation: new Cesium.CallbackProperty(() => {
stRotation += amount
if (stRotation >= 360 || stRotation <= -360) {
stRotation = 0

+ 5
- 2
modules/overlay/custom/CustomLabel.js Переглянути файл

@@ -16,10 +16,13 @@ class CustomLabel extends Overlay {
this._delegate = new Cesium.Entity({ label: {} })
this._position = Parse.parsePosition(position)
this._text = text
this.type = Overlay.getOverlayType('custom_label')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('custom_label')
}

set position(position) {
this._position = Parse.parsePosition(position)
this._delegate.position = Transform.transformWGS84ToCartesian(
@@ -101,7 +104,7 @@ class CustomLabel extends Overlay {
...style,
semiMajorAxis: radius,
semiMinorAxis: radius,
stRotation: new Cesium.CallbackProperty(time => {
stRotation: new Cesium.CallbackProperty(() => {
stRotation += amount
if (stRotation >= 360 || stRotation <= -360) {
stRotation = 0

+ 7
- 4
modules/overlay/dynamic/DynamicBillboard.js Переглянути файл

@@ -17,10 +17,13 @@ class DynamicBillboard extends DynamicOverlay {
this._posistion = Parse.parsePosition(position)
this._icon = icon
this._delegate = new Cesium.Entity({ billboard: {} })
this.type = Overlay.getOverlayType('dynamic_billboard')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('dynamic_billboard')
}

set icon(icon) {
this._icon = icon
this._delegate.billboard.image = this._icon
@@ -49,14 +52,14 @@ class DynamicBillboard extends DynamicOverlay {
/**
* set the location
*/
this._samplePosition.forwardExtrapolationType =
this._sampledPosition.forwardExtrapolationType =
Cesium.ExtrapolationType.HOLD
this._startTime = Cesium.JulianDate.now()
this._samplePosition.addSample(
this._sampledPosition.addSample(
this._startTime,
Transform.transformWGS84ToCartesian(this._posistion)
)
this._delegate.position = this._samplePosition
this._delegate.position = this._sampledPosition
this._cache.push(this._startTime)
/**
* initialize the Overlay parameter

+ 8
- 5
modules/overlay/dynamic/DynamicModel.js Переглянути файл

@@ -17,10 +17,13 @@ class DynamicModel extends DynamicOverlay {
this._posistion = Parse.parsePosition(position)
this._modelUrl = modelUrl
this._delegate = new Cesium.Entity({ model: {} })
this.type = Overlay.getOverlayType('dynamic_model')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('dynamic_model')
}

set modelUrl(modelUrl) {
this._modelUrl = modelUrl
this._delegate.model.uri = this._modelUrl
@@ -35,16 +38,16 @@ class DynamicModel extends DynamicOverlay {
/**
* set the location
*/
this._samplePosition.forwardExtrapolationType =
this._sampledPosition.forwardExtrapolationType =
Cesium.ExtrapolationType.HOLD
this._startTime = Cesium.JulianDate.now()
this._samplePosition.addSample(
this._sampledPosition.addSample(
this._startTime,
Transform.transformWGS84ToCartesian(this._posistion)
)
this._delegate.position = this._samplePosition
this._delegate.position = this._sampledPosition
this._delegate.orientation = new Cesium.VelocityOrientationProperty(
this._samplePosition
this._sampledPosition
)
this._cache.push(this._startTime)
/**

+ 4
- 6
modules/overlay/dynamic/DynamicOverlay.js Переглянути файл

@@ -14,7 +14,7 @@ class DynamicOverlay extends Overlay {
super()
this._startTime = undefined
this._lastTime = undefined
this._samplePosition = new Cesium.SampledPositionProperty()
this._sampledPosition = new Cesium.SampledPositionProperty()
this._cache = []
this._maxCacheSize = 10
this._state = State.INITIALIZED
@@ -31,7 +31,7 @@ class DynamicOverlay extends Overlay {

get position() {
return Transform.transformCartesianToWGS84(
this._samplePosition.getValue(Cesium.JulianDate.now())
this._sampledPosition.getValue(Cesium.JulianDate.now())
)
}

@@ -51,7 +51,7 @@ class DynamicOverlay extends Overlay {
-0.2,
new Cesium.JulianDate()
)
this._samplePosition.removeSamples(
this._sampledPosition.removeSamples(
new Cesium.TimeInterval({
start: start,
stop: stop
@@ -75,7 +75,7 @@ class DynamicOverlay extends Overlay {
interval,
new Cesium.JulianDate()
)
this._samplePosition.addSample(
this._sampledPosition.addSample(
time,
Transform.transformWGS84ToCartesian(Parse.parsePosition(position))
)
@@ -94,6 +94,4 @@ class DynamicOverlay extends Overlay {
}
}

Overlay.registerType('dynamic-model')

export default DynamicOverlay

+ 34
- 20
modules/overlay/html/DivIcon.js Переглянути файл

@@ -24,10 +24,13 @@ class DivIcon extends Overlay {
left: '0'
})
this.content = content
this.type = Overlay.getOverlayType('div_icon')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('div_icon')
}

set show(show) {
this._show = show
this._delegate.style.visibility = this._show ? 'visible' : 'hidden'
@@ -65,27 +68,33 @@ class DivIcon extends Overlay {

/**
* Updates style
* @param style
* @param windowCoord
* @param distance
* @param isFront
* @private
*/
_updateStyle(style, distance) {
let translate3d = 'translate3d(0,0,0)'
if (style.transform) {
let x = style.transform.x - this._delegate.offsetWidth / 2
let y = style.transform.y - this._delegate.offsetHeight / 2
translate3d = `translate3d(${Math.round(x)}px,${Math.round(y)}px, 0)`
_updateStyle(windowCoord, distance, isFront) {
if (!this._show || !windowCoord) {
return
}

// set translate
let x = windowCoord.x - this._delegate.offsetWidth / 2
let y = windowCoord.y - this._delegate.offsetHeight / 2
let translate3d = `translate3d(${Math.round(x)}px,${Math.round(y)}px, 0)`

// set scale
let scale3d = 'scale3d(1,1,1)'
let scaleByDistance = this._style.scaleByDistance
if (distance && scaleByDistance) {
let nearValue = scaleByDistance.nearValue
let farValue = scaleByDistance.farValue
let f = distance / scaleByDistance.far
if (distance < scaleByDistance.near) {
let near = scaleByDistance.near || 0.0
let nearValue = scaleByDistance.nearValue || 1.0
let far = scaleByDistance.far || Number.MAX_VALUE
let farValue = scaleByDistance.farValue || 0.0
let f = distance / far
if (distance < near) {
scale3d = `scale3d(${nearValue},${nearValue},1)`
} else if (distance > scaleByDistance.far) {
} else if (distance > far) {
scale3d = `scale3d(${farValue},${farValue},1)`
} else {
let scale = farValue + f * (nearValue - farValue)
@@ -93,17 +102,21 @@ class DivIcon extends Overlay {
}
}

// set condition
let isDisplay = true
let distanceDisplayCondition = this._style.distanceDisplayCondition
if (distance && distanceDisplayCondition) {
this.show =
this._show &&
isBetween(
distance,
distanceDisplayCondition.near,
distanceDisplayCondition.far
)
isDisplay = isBetween(
distance,
distanceDisplayCondition.near || 0.0,
distanceDisplayCondition.far || Number.MAX_VALUE
)
}

// update style
this._delegate.style.transform = `${translate3d} ${scale3d}`
this._delegate.style.visibility =
isDisplay && isFront ? 'visible' : 'hidden'
}

/**
@@ -120,6 +133,7 @@ class DivIcon extends Overlay {
overlay: this,
position: Transform.transformWGS84ToCartesian(this._position)
}

this._delegate.addEventListener('click', () => {
this._overlayEvent.fire(MouseEventType.CLICK, params)
})

+ 3
- 0
modules/overlay/index.js Переглянути файл

@@ -42,10 +42,13 @@ export { default as TailedAttackArrow } from './plot/TailedAttackArrow'
* primitive
*/
export { default as BillboardPrimitive } from './primitive/BillboardPrimitive.js'
export { default as BounceBillboardPrimitive } from './primitive/BounceBillboardPrimitive'
export { default as BounceLabelPrimitive } from './primitive/BounceLabelPrimitive'
export { default as DiffuseWallPrimitive } from './primitive/DiffuseWallPrimitive.js'
export { default as ElecEllipsoidPrimitive } from './primitive/ElecEllipsoidPrimitive'
export { default as FlowLinePrimitive } from './primitive/FlowLinePrimitive'
export { default as LabelPrimitive } from './primitive/LabelPrimitive'
export { default as ModelCollectionPrimitive } from './primitive/ModelCollectionPrimitive'
export { default as ModelPrimitive } from './primitive/ModelPrimitive'
export { default as PointPrimitive } from './primitive/PointPrimitive.js'
export { default as PolylinePrimitive } from './primitive/PolylinePrimitive.js'

+ 5
- 2
modules/overlay/model/Model.js Переглянути файл

@@ -17,10 +17,13 @@ class Model extends Overlay {
this._position = Parse.parsePosition(position)
this._modelUrl = modelUrl
this._rotateAmount = 0
this.type = Overlay.getOverlayType('model')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('model')
}

set position(position) {
this._position = Parse.parsePosition(position)
this._delegate.position = Transform.transformWGS84ToCartesian(
@@ -55,7 +58,7 @@ class Model extends Overlay {

set rotateAmount(amount) {
this._rotateAmount = +amount
this._delegate.orientation = new Cesium.CallbackProperty(time => {
this._delegate.orientation = new Cesium.CallbackProperty(() => {
this._position.heading += this._rotateAmount
if (this._position.heading >= 360 || this._position.heading <= -360) {
this._position.heading = 0

+ 4
- 1
modules/overlay/model/Tileset.js Переглянути файл

@@ -18,10 +18,13 @@ class Tileset extends Overlay {
this._tileVisibleCallback = undefined
this._properties = undefined
this._customShader = undefined
this.type = Overlay.getOverlayType('tileset')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('tileset')
}

get readyPromise() {
return this._delegate.readyPromise
}

+ 4
- 1
modules/overlay/plot/AttackArrow.js Переглянути файл

@@ -22,10 +22,13 @@ class AttackArrow extends Overlay {
this.neckHeightFactor = 0.85
this.neckWidthFactor = 0.15
this.headTailFactor = 0.8
this.type = Overlay.getOverlayType('attack_arrow')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('attack_arrow')
}

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

+ 4
- 1
modules/overlay/plot/DoubleArrow.js Переглянути файл

@@ -21,10 +21,13 @@ class DoubleArrow extends Overlay {
this.headWidthFactor = 0.3
this.neckHeightFactor = 0.85
this.neckWidthFactor = 0.15
this.type = Overlay.getOverlayType('double_arrow')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('double_arrow')
}

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

+ 4
- 1
modules/overlay/plot/FineArrow.js Переглянути файл

@@ -22,10 +22,13 @@ class FineArrow extends Overlay {
this.headWidthFactor = 0.25
this.headAngle = Math.PI / 8.5
this.neckAngle = Math.PI / 13
this.type = Overlay.getOverlayType('fine_arrow')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('fine_arrow')
}

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

+ 4
- 1
modules/overlay/plot/GatheringPlace.js Переглянути файл

@@ -20,10 +20,13 @@ class GatheringPlace extends Overlay {
this._positions = Parse.parsePositions(positions)
this._delegate = new Cesium.Entity({ polygon: {} })
this.t = 0.4
this.type = Overlay.getOverlayType('gathering_place')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('gathering_place')
}

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

+ 4
- 1
modules/overlay/plot/TailedAttackArrow.js Переглянути файл

@@ -22,10 +22,13 @@ class TailedAttackArrow extends AttackArrow {
this.tailWidthFactor = 0.1
this.headTailFactor = 0.8
this.swallowTailFactor = 1
this.type = Overlay.getOverlayType('tailed_attack_arrow')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('tailed_attack_arrow')
}

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

+ 4
- 1
modules/overlay/primitive/BillboardPrimitive.js Переглянути файл

@@ -21,10 +21,13 @@ class BillboardPrimitive extends Overlay {
width: 0,
height: 0
}
this.type = Overlay.getOverlayType('billboard_primitive')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('billboard_primitive')
}

set position(position) {
this._position = Parse.parsePosition(position)
this._delegate.position = Transform.transformWGS84ToCartesian(

+ 73
- 0
modules/overlay/primitive/BounceBillboardPrimitive.js Переглянути файл

@@ -0,0 +1,73 @@
/**
* @Author: Caven
* @Date: 2021-06-03 21:06:17
*/

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

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

class BounceBillboardPrimitive extends BillboardPrimitive {
constructor(position, icon) {
super(position, icon)
this._currentOffset = new Cesium.Cartesian2(0, 0)
this._isUp = true
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('bounce_billboard_primitive')
}

/**
*
* @private
*/
_addedHook() {
if (!this._delegate || !this._layer) {
return
}
this._delegate.layerId = this._layer?.layerId
this._delegate.overlayId = this._id
this._layer.delegate.add(this)
}

/**
*
* @private
*/
_removedHook() {
if (!this._layer) {
return
}
this._layer.delegate.remove(this)
}

/**
*
*/
update() {
if (!this._show) {
return
}
let maxOffsetY = this._style?.maxOffsetY || DEF_STYLE.maxOffsetY
let offsetAmount = this._style?.offsetAmount || DEF_STYLE.offsetAmount
if (this._currentOffset.y >= 0) {
this._isUp = true
} else if (this._currentOffset.y <= -maxOffsetY) {
this._isUp = false
}
this._currentOffset.y += offsetAmount * (this._isUp ? -1 : 1)
this._delegate.pixelOffset = this._currentOffset
}
}

Overlay.registerType('bounce_billboard_primitive')

export default BounceBillboardPrimitive

+ 73
- 0
modules/overlay/primitive/BounceLabelPrimitive.js Переглянути файл

@@ -0,0 +1,73 @@
/**
* @Author: Caven
* @Date: 2021-06-03 21:06:17
*/

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

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

class BounceLabelPrimitive extends LabelPrimitive {
constructor(position, text) {
super(position, text)
this._currentOffset = new Cesium.Cartesian2(0, 0)
this._isUp = true
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('bounce_label_primitive')
}

/**
*
* @private
*/
_addedHook() {
if (!this._delegate || !this._layer) {
return
}
this._delegate.layerId = this._layer?.layerId
this._delegate.overlayId = this._id
this._layer.delegate.add(this)
}

/**
*
* @private
*/
_removedHook() {
if (!this._layer) {
return
}
this._layer.delegate.remove(this)
}

/**
*
*/
update() {
if (!this._show) {
return
}
let maxOffsetY = this._style?.maxOffsetY || DEF_STYLE.maxOffsetY
let offsetAmount = this._style?.offsetAmount || DEF_STYLE.offsetAmount
if (this._currentOffset.y >= 0) {
this._isUp = true
} else if (this._currentOffset.y <= -maxOffsetY) {
this._isUp = false
}
this._currentOffset.y += offsetAmount * (this._isUp ? -1 : 1)
this._delegate.pixelOffset = this._currentOffset
}
}

Overlay.registerType('bounce_label_primitive')

export default BounceLabelPrimitive

+ 13
- 28
modules/overlay/primitive/DiffuseWallPrimitive.js Переглянути файл

@@ -13,25 +13,28 @@ import Overlay from '../Overlay'
const DEF_STYLE = {
minRadius: 10,
minHeight: 30,
color: Cesium.Color.RED
color: Cesium.Color.RED,
slices: 128,
speed: 10
}

class DiffuseWallPrimitive extends Overlay {
constructor(center, radius, height, slices, speed) {
constructor(center, radius, height) {
super()
this._center = Parse.parsePosition(center)
this._delegate = undefined
this._height = height
this._radius = radius
this._slices = slices || 128
this._speed = speed || 10
this._currentHeight = height || 0
this._currentRadius = 10
this._style = { ...DEF_STYLE }
this.type = Overlay.getOverlayType('diffuse_wall_primitive')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('diffuse_wall_primitive')
}

set center(position) {
this._center = Parse.parsePosition(position)
return this
@@ -59,24 +62,6 @@ class DiffuseWallPrimitive extends Overlay {
return this._height
}

set slices(slices) {
this._slices = slices
return this
}

get slices() {
return this._slices
}

set speed(speed) {
this._speed = speed
return this
}

get speed() {
return this._speed
}

/**
*
* @returns {*}
@@ -87,8 +72,8 @@ class DiffuseWallPrimitive extends Overlay {
let modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
Transform.transformWGS84ToCartesian(this._center)
)
for (let i = 0; i < this._slices; i++) {
let angle = (i / this._slices) * Cesium.Math.TWO_PI
for (let i = 0; i < this._style.slices; i++) {
let angle = (i / this._style.slices) * Cesium.Math.TWO_PI
let x = Math.cos(angle)
let y = Math.sin(angle)
let point = new Cesium.Cartesian3(
@@ -161,8 +146,8 @@ class DiffuseWallPrimitive extends Overlay {
*/
update(frameState) {
this._delegate = this._delegate && this._delegate.destroy()
this._currentRadius += this._radius / this._speed / 20
this._currentHeight -= this._height / this._speed / 20
this._currentRadius += this._radius / this._style.speed / 20
this._currentHeight -= this._height / this._style.speed / 20
if (
this._currentRadius > this._radius ||
this._currentHeight < this._style.minHeight
@@ -170,7 +155,7 @@ class DiffuseWallPrimitive extends Overlay {
this._currentRadius = this._style.minRadius
this._currentHeight = this._height
}
if (!this._slices || this._slices < 3) {
if (!this._style.slices || this._style.slices < 3) {
return false
}
let positions = this._getPositions()

+ 4
- 1
modules/overlay/primitive/ElecEllipsoidPrimitive.js Переглянути файл

@@ -19,10 +19,13 @@ class ElecEllipsoidPrimitive extends Overlay {
geometry: {}
})
})
this.type = Overlay.getOverlayType('elec_ellipsoid_primitive')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('elec_ellipsoid_primitive')
}

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

+ 4
- 1
modules/overlay/primitive/FlowLinePrimitive.js Переглянути файл

@@ -19,10 +19,13 @@ class FlowLinePrimitive extends Overlay {
geometry: {}
})
})
this.type = Overlay.getOverlayType('flow_line_primitive')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('flow_line_primitive')
}

set positions(positions) {
this._positions = Parse.parsePositions(positions)
this._delegate.geometryInstances.geometry = new Cesium.PolylineGeometry({

+ 4
- 1
modules/overlay/primitive/LabelPrimitive.js Переглянути файл

@@ -18,10 +18,13 @@ class LabelPrimitive extends Overlay {
position: undefined,
text: undefined
}
this.type = Overlay.getOverlayType('label_primitive')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('label_primitive')
}

set position(position) {
this._position = Parse.parsePosition(position)
this._delegate.position = Transform.transformWGS84ToCartesian(

+ 133
- 0
modules/overlay/primitive/ModelCollectionPrimitive.js Переглянути файл

@@ -0,0 +1,133 @@
/**
* @Author: Caven
* @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 { Transform } from '@dc-modules/transform'
import Overlay from '../Overlay'

class ModelCollectionPrimitive extends Overlay {
constructor(positions, modelUrl) {
super()
this._positions = Parse.parsePositions(positions)
this._modelUrl = modelUrl
this._attrs = []
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('model_collection_primitive')
}

get readyPromise() {
return this._delegate.readyPromise
}

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

get attrs() {
return this._attrs
}

set positions(positions) {
this._positions = Parse.parsePositions(positions)
if (this._layer) {
this._resetDelegate()
this._layer.delegate.add(this._delegate)
}
return this
}

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

get modelUrl() {
return this._modelUrl
}

_resetDelegate() {
this._delegate = this._delegate && this._delegate.destroy()
this._delegate = new Cesium.ModelInstanceCollection({
url: this._modelUrl,
instances: this._positions.map(item => {
let origin = Transform.transformWGS84ToCartesian(item)
let modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(
origin,
new Cesium.HeadingPitchRoll(
Cesium.Math.toRadians(item.heading),
Cesium.Math.toRadians(item.pitch),
Cesium.Math.toRadians(item.roll)
)
)
this._style?.scale &&
Cesium.Matrix4.multiplyByUniformScale(
modelMatrix,
this._style?.scale,
modelMatrix
)
return {
modelMatrix
}
}),
...this._style
})
this._delegate.layerId = this._layer?.layerId
this._delegate.overlayId = this._id
}

_mountedHook() {
this._resetDelegate()
}

/**
*
* @param instanceId
* @returns {undefined}
*/
getModelInstance(instanceId) {
return this._delegate._instances[instanceId] || undefined
}

/**
*
* @param instanceId
* @returns {*|{}}
*/
getAttrByInstanceId(instanceId) {
return this._attrs[instanceId] || {}
}

/**
*
* @param style
* @returns {ModelCollectionPrimitive}
*/
setStyle(style) {
if (!style || Object.keys(style).length === 0) {
return this
}
delete style['instances'] && delete style['url']
this._style = style
if (this._layer) {
this._resetDelegate()
this._layer.delegate.add(this._delegate)
}
return this
}
}

Overlay.registerType('model_collection_primitive')

export default ModelCollectionPrimitive

+ 41
- 1
modules/overlay/primitive/ModelPrimitive.js Переглянути файл

@@ -16,10 +16,17 @@ class ModelPrimitive extends Overlay {
this._position = Parse.parsePosition(position)
this._modelUrl = modelUrl
this._delegate = Cesium.Model.fromGltf({ url: modelUrl })
this.type = Overlay.getOverlayType('model_primitive')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('model_primitive')
}

get readyPromise() {
return this._delegate.readyPromise
}

set position(position) {
this._position = Parse.parsePosition(position)
let origin = Transform.transformWGS84ToCartesian(this._position)
@@ -60,6 +67,39 @@ class ModelPrimitive extends Overlay {
this.position = this._position
}

/**
*
* @param name
*/
getMaterial(name) {
return this._delegate.getMaterial(name)
}

/**
*
* @param name
*/
getMesh(name) {
return this._delegate.getMesh(name)
}

/**
*
* @param name
* @returns {*}
*/
getNode(name) {
return this._delegate.getNode(name)
}

/**
*
* @returns {*}
*/
getNodes() {
return this._delegate._runtime.nodes
}

/**
* Sets style
* @param style

+ 5
- 1
modules/overlay/primitive/PointPrimitive.js Переглянути файл

@@ -20,13 +20,17 @@ class PointPrimitive extends Overlay {
constructor(position) {
super()
this._position = Parse.parsePosition(position)
this.type = Overlay.getOverlayType('point_primitive')
this._delegate = {
position: undefined
}
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('point_primitive')
}

set position(position) {
this._position = Parse.parsePosition(position)
this._delegate.position = Transform.transformWGS84ToCartesian(

+ 4
- 1
modules/overlay/primitive/PolylinePrimitive.js Переглянути файл

@@ -17,10 +17,13 @@ class PolylinePrimitive extends Overlay {
this._delegate = {
positions: []
}
this.type = Overlay.getOverlayType('polyline_primitive')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('polyline_primitive')
}

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

+ 4
- 1
modules/overlay/primitive/ScanCirclePrimitive.js Переглянути файл

@@ -19,10 +19,13 @@ class ScanCirclePrimitive extends Overlay {
geometry: {}
})
})
this.type = Overlay.getOverlayType('scan_circle_primitive')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('scan_circle_primitive')
}

set position(position) {
this._position = Parse.parsePosition(position)
this._delegate.geometryInstances.geometry = new Cesium.EllipseGeometry({

+ 4
- 1
modules/overlay/primitive/TrailLinePrimitive.js Переглянути файл

@@ -19,10 +19,13 @@ class TrailLinePrimitive extends Overlay {
geometry: {}
})
})
this.type = Overlay.getOverlayType('trail_line_primitive')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('trail_line_primitive')
}

set positions(positions) {
this._positions = Parse.parsePositions(positions)
this._delegate.geometryInstances.geometry = new Cesium.PolylineGeometry({

+ 4
- 1
modules/overlay/primitive/VideoPrimitive.js Переглянути файл

@@ -19,10 +19,13 @@ class VideoPrimitive extends Overlay {
})
})
this._video = video
this.type = Overlay.getOverlayType('video_primitive')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('video_primitive')
}

set positions(positions) {
this._positions = Parse.parsePositions(positions)
this._delegate.geometryInstances.geometry = Cesium.PolygonGeometry.fromPositions(

+ 4
- 1
modules/overlay/primitive/WaterPrimitive.js Переглянути файл

@@ -19,10 +19,13 @@ class WaterPrimitive extends Overlay {
}),
asynchronous: true
})
this.type = Overlay.getOverlayType('water_primitive')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('water_primitive')
}

set positions(positions) {
this._positions = Parse.parsePositions(positions)
this._delegate.geometryInstances.geometry = Cesium.PolygonGeometry.fromPositions(

+ 4
- 1
modules/overlay/vector/Billboard.js Переглянути файл

@@ -17,10 +17,13 @@ class Billboard extends Overlay {
this._position = Parse.parsePosition(position)
this._icon = icon
this._size = [32, 32]
this.type = Overlay.getOverlayType('billboard')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('billboard')
}

set position(position) {
this._position = Parse.parsePosition(position)
this._delegate.position = Transform.transformWGS84ToCartesian(

+ 4
- 1
modules/overlay/vector/Box.js Переглянути файл

@@ -26,10 +26,13 @@ class Box extends Overlay {
}
}
})
this.type = Overlay.getOverlayType('box')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('box')
}

/**
*
* @param position

+ 5
- 2
modules/overlay/vector/Circle.js Переглянути файл

@@ -18,10 +18,13 @@ class Circle extends Overlay {
this._radius = +radius || 0
this._rotateAmount = 0
this._stRotation = 0
this.type = Overlay.getOverlayType('circle')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('circle')
}

set center(center) {
this._center = Parse.parsePosition(center)
this._delegate.polygon.hierarchy = this._computeHierarchy()
@@ -44,7 +47,7 @@ class Circle extends Overlay {

set rotateAmount(amount) {
this._rotateAmount = +amount
this._delegate.polygon.stRotation = new Cesium.CallbackProperty(time => {
this._delegate.polygon.stRotation = new Cesium.CallbackProperty(() => {
this._stRotation += this._rotateAmount
if (this._stRotation >= 360 || this._stRotation <= -360) {
this._stRotation = 0

+ 4
- 1
modules/overlay/vector/Corridor.js Переглянути файл

@@ -15,10 +15,13 @@ class Corridor extends Overlay {
super()
this._positions = Parse.parsePositions(positions)
this._delegate = new Cesium.Entity({ corridor: {} })
this.type = Overlay.getOverlayType('corridor')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('corridor')
}

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

+ 4
- 1
modules/overlay/vector/Cylinder.js Переглянути файл

@@ -18,10 +18,13 @@ class Cylinder extends Overlay {
this._topRadius = +topRadius || 0
this._bottomRadius = +bottomRadius || 0
this._delegate = new Cesium.Entity({ cylinder: {} })
this.type = Overlay.getOverlayType('cylinder')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('cylinder')
}

set position(position) {
this._position = Parse.parsePosition(position)
this._delegate.position = Transform.transformWGS84ToCartesian(

+ 4
- 1
modules/overlay/vector/Ellipse.js Переглянути файл

@@ -17,10 +17,13 @@ class Ellipse extends Overlay {
this._semiMajorAxis = +semiMajorAxis || 0
this._semiMinorAxis = +semiMinorAxis || 0
this._delegate = new Cesium.Entity({ ellipse: {} })
this.type = Overlay.getOverlayType('ellipse')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('ellipse')
}

set position(position) {
this._position = Parse.parsePosition(position)
this._delegate.position = Transform.transformWGS84ToCartesian(

+ 4
- 1
modules/overlay/vector/Ellipsoid.js Переглянути файл

@@ -16,10 +16,13 @@ class Ellipsoid extends Overlay {
this._position = Parse.parsePosition(position)
this._radius = radius || { x: 10, y: 10, z: 10 }
this._delegate = new Cesium.Entity({ ellipsoid: {} })
this.type = Overlay.getOverlayType('ellipsoid')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('ellipsoid')
}

set position(position) {
this._position = Parse.parsePosition(position)
this._delegate.position = Transform.transformWGS84ToCartesian(

+ 4
- 1
modules/overlay/vector/Label.js Переглянути файл

@@ -16,10 +16,13 @@ class Label extends Overlay {
this._delegate = new Cesium.Entity({ label: {} })
this._position = Parse.parsePosition(position)
this._text = text
this.type = Overlay.getOverlayType('label')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('label')
}

set position(position) {
this._position = Parse.parsePosition(position)
this._delegate.position = Transform.transformWGS84ToCartesian(

+ 4
- 1
modules/overlay/vector/Plane.js Переглянути файл

@@ -38,10 +38,13 @@ class Plane extends Overlay {
plane: new Cesium.Plane(this._normal, this._distance)
}
})
this.type = Overlay.getOverlayType('plane')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('plane')
}

set position(position) {
this._position = Parse.parsePosition(position)
this._delegate.position = Transform.transformWGS84ToCartesian(

+ 4
- 1
modules/overlay/vector/Point.js Переглянути файл

@@ -21,10 +21,13 @@ class Point extends Overlay {
super()
this._delegate = new Cesium.Entity({ point: {} })
this._position = Parse.parsePosition(position)
this.type = Overlay.getOverlayType('point')
this._state = State.INITIALIZED
}

get type() {
return Overlay.getOverlayType('point')
}

set position(position) {
this._position = Parse.parsePosition(position)
this._delegate.position = Transform.transformWGS84ToCartesian(

+ 0
- 0
modules/overlay/vector/Polygon.js Переглянути файл


Деякі файли не було показано, через те що забагато файлів було змінено

Завантаження…
Відмінити
Зберегти