| /libs/ | /libs/ | ||||
| /web/ | /web/ | ||||
| /pack/ | /pack/ | ||||
| dist/* |
| 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"] |
| # Change Log | # 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 | ### 2.2.3 - 2021-06-05 | ||||
| #### Breaking Changes 📣 | #### Breaking Changes 📣 |
| # Change Log | # 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 | ### 2.2.3 - 2021-06-05 | ||||
| #### Breaking Changes 📣 | #### Breaking Changes 📣 | ||||
| - 开放部分 Cesium 内部函数 | - 开放部分 Cesium 内部函数 | ||||
| - 添加 FeatureGridLayer | - 添加 FeatureGridLayer | ||||
| #### Additions 🎉 | |||||
| - 添加 DivIcon 鼠标移入和移出功能 | |||||
| - 添加地图当前分辨率和视野范围属性 | |||||
| #### Fixes 🔧 | #### Fixes 🔧 | ||||
| - 修复部分军标无法使用的问题[#24](https://github.com/dvgis/dc-sdk/issues/24) | - 修复部分军标无法使用的问题[#24](https://github.com/dvgis/dc-sdk/issues/24) |
| [**🇨🇳 中文**](./README_zh.md) | [**🇬🇧English**](./README.md) | [**🇨🇳 中文**](./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 | ```warning | ||||
| Tips:This SDK is JS+GIS framework package. Developers need to have some front-end technology and GIS related technology | Tips:This SDK is JS+GIS framework package. Developers need to have some front-end technology and GIS related technology | ||||
| > The configuration is mainly used in the `NPM / YARN` way | > 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` | `Webpack` | ||||
| ## Demo | ## Demo | ||||
| |  |  |  |  | | |||||
| |  |  |  |  | | |||||
| | :-----------------------------------------------------------: | :-----------------------------------------------------------: | :------------------------------------------------------------------: | :--------------------------------------------------------------: | | | :-----------------------------------------------------------: | :-----------------------------------------------------------: | :------------------------------------------------------------------: | :--------------------------------------------------------------: | | ||||
| |  |  |  |  | | |  |  |  |  | | ||||
| |  |  |  |  | | |||||
| |  |  |  |  | | |||||
| [More>>](http://dc.dvgis.cn/#/examples) | [More>>](http://dc.dvgis.cn/#/examples) | ||||
| [**🇨🇳 中文**](./README_zh.md) | [**🇬🇧English**](./README.md) | [**🇨🇳 中文**](./README_zh.md) | [**🇬🇧English**](./README.md) | ||||
| > DC-SDK 是基于 Cesium 进行二次开发的2、3D一体 WebGis 应用框架,该框架优化了 Cesium 的使用方式和增添了一些额外功能,旨在为开发者快速构建 WebGis 应用。 | |||||
| > `DC-SDK` 是基于开源项目 `Cesium` 进行二次开发的二三维一体的 `WebGis` 应用框架,该框架优化了部分 `Cesium` 的使用方式和增添一些通用功能,旨在为开发者快速构建 `WebGis` 应用。 | |||||
| ```warning | ```warning | ||||
| Tips:本框架是 JS+GIS 的框架包。开发者需要有一定的前端技术和 GIS 相关技术 | Tips:本框架是 JS+GIS 的框架包。开发者需要有一定的前端技术和 GIS 相关技术 | ||||
| > 配置主要用于 `NPM / YARN` 的方式 | > 配置主要用于 `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` | `Webpack` | ||||
| ## 示例 | ## 示例 | ||||
| |  |  |  |  | | |||||
| |  |  |  |  | | |||||
| | :-----------------------------------------------------------: | :-----------------------------------------------------------: | :------------------------------------------------------------------: | :--------------------------------------------------------------: | | | :-----------------------------------------------------------: | :-----------------------------------------------------------: | :------------------------------------------------------------------: | :--------------------------------------------------------------: | | ||||
| |  |  |  |  | | |  |  |  |  | | ||||
| |  |  |  |  | | |||||
| |  |  |  |  | | |||||
| [更多>>](http://dc.dvgis.cn/#/examples) | [更多>>](http://dc.dvgis.cn/#/examples) | ||||
| /** | |||||
| * @Author: Caven | |||||
| * @Date: 2021-08-01 00:12:06 | |||||
| */ | |||||
| let AnimationType = {} | |||||
| export default AnimationType |
| */ | */ | ||||
| export { default as Animation } from './Animation' | export { default as Animation } from './Animation' | ||||
| export { default as AnimationType } from './AnimationType' | |||||
| /** | /** | ||||
| * types | * types |
| import { Cesium } from '@dc-modules/namespace' | import { Cesium } from '@dc-modules/namespace' | ||||
| import { Transform } from '@dc-modules/transform' | import { Transform } from '@dc-modules/transform' | ||||
| import Parse from '@dc-modules/parse/Parse' | import Parse from '@dc-modules/parse/Parse' | ||||
| import AnimationType from '../AnimationType' | |||||
| import Animation from '../Animation' | import Animation from '../Animation' | ||||
| this._options = options | this._options = options | ||||
| this._heading = viewer.camera.heading | this._heading = viewer.camera.heading | ||||
| this._aroundAmount = 0.2 | this._aroundAmount = 0.2 | ||||
| this.type = 'around_point' | |||||
| } | |||||
| get type() { | |||||
| return AnimationType.AROUND_POINT | |||||
| } | } | ||||
| set position(position) { | set position(position) { | ||||
| } | } | ||||
| } | } | ||||
| AnimationType.AROUND_POINT = 'around_point' | |||||
| export default AroundPoint | export default AroundPoint |
| import { Cesium } from '@dc-modules/namespace' | import { Cesium } from '@dc-modules/namespace' | ||||
| import Animation from '../Animation' | import Animation from '../Animation' | ||||
| import AnimationType from '../AnimationType' | |||||
| class AroundView extends Animation { | class AroundView extends Animation { | ||||
| constructor(viewer, options = {}) { | constructor(viewer, options = {}) { | ||||
| this._options = options | this._options = options | ||||
| this._heading = viewer.camera.heading | this._heading = viewer.camera.heading | ||||
| this._aroundAmount = 0.2 | this._aroundAmount = 0.2 | ||||
| this.type = 'around_view' | |||||
| } | |||||
| get type() { | |||||
| return AnimationType.AROUND_VIEW | |||||
| } | } | ||||
| set aroundAmount(aroundAmount) { | set aroundAmount(aroundAmount) { | ||||
| if (this._heading >= Math.PI * 2 || this._heading <= -Math.PI * 2) { | if (this._heading >= Math.PI * 2 || this._heading <= -Math.PI * 2) { | ||||
| this._heading = 0 | this._heading = 0 | ||||
| } | } | ||||
| this._viewer.scene.camera.setView({ | |||||
| this._viewer.camera.setView({ | |||||
| orientation: { | 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 | export default AroundView |
| import { Util } from '@dc-modules/utils' | import { Util } from '@dc-modules/utils' | ||||
| import { Transform } from '@dc-modules/transform' | import { Transform } from '@dc-modules/transform' | ||||
| import Animation from '../Animation' | import Animation from '../Animation' | ||||
| import AnimationType from '../AnimationType' | |||||
| const CircleScanShader = require('@dc-modules/material/shader/circle/CircleScanShader.glsl') | const CircleScanShader = require('@dc-modules/material/shader/circle/CircleScanShader.glsl') | ||||
| this._radius = radius || 100 | this._radius = radius || 100 | ||||
| this._color = options.color || Cesium.Color.RED | this._color = options.color || Cesium.Color.RED | ||||
| this._speed = options.speed || 2 | this._speed = options.speed || 2 | ||||
| this.type = 'circle_scan' | |||||
| } | |||||
| get type() { | |||||
| return AnimationType.CIRCLE_SCAN | |||||
| } | } | ||||
| /** | /** | ||||
| } | } | ||||
| } | } | ||||
| AnimationType.CIRCLE_SCAN = 'circle_scan' | |||||
| export default CircleScan | export default CircleScan |
| import Parse from '@dc-modules/parse/Parse' | import Parse from '@dc-modules/parse/Parse' | ||||
| import { Transform } from '@dc-modules/transform' | import { Transform } from '@dc-modules/transform' | ||||
| import Animation from '../Animation' | import Animation from '../Animation' | ||||
| import AnimationType from '../AnimationType' | |||||
| class Flying extends Animation { | class Flying extends Animation { | ||||
| constructor(viewer, options = {}) { | constructor(viewer, options = {}) { | ||||
| this._positions = [] | this._positions = [] | ||||
| this._durations = [3] | this._durations = [3] | ||||
| this._currentIndex = 0 | this._currentIndex = 0 | ||||
| this._timer = undefined | this._timer = undefined | ||||
| } | } | ||||
| get type() { | |||||
| return AnimationType.FLYING | |||||
| } | |||||
| set positions(positions) { | set positions(positions) { | ||||
| this._positions = Parse.parsePositions(positions) | this._positions = Parse.parsePositions(positions) | ||||
| return this | return this | ||||
| } | } | ||||
| } | } | ||||
| AnimationType.FLYING = 'flying' | |||||
| export default Flying | export default Flying |
| import { Cesium } from '@dc-modules/namespace' | import { Cesium } from '@dc-modules/namespace' | ||||
| import Animation from '../Animation' | import Animation from '../Animation' | ||||
| import AnimationType from '../AnimationType' | |||||
| class GlobeRotate extends Animation { | class GlobeRotate extends Animation { | ||||
| constructor(viewer, options = {}) { | constructor(viewer, options = {}) { | ||||
| super(viewer) | super(viewer) | ||||
| this._options = options | this._options = options | ||||
| this.type = 'globe_rotate' | |||||
| } | |||||
| get type() { | |||||
| return AnimationType.GLOBE_ROTATE | |||||
| } | } | ||||
| /** | /** | ||||
| } | } | ||||
| } | } | ||||
| AnimationType.GLOBE_ROTATE = 'globe_rotate' | |||||
| export default GlobeRotate | export default GlobeRotate |
| import { Util } from '@dc-modules/utils' | import { Util } from '@dc-modules/utils' | ||||
| import { Transform } from '@dc-modules/transform' | import { Transform } from '@dc-modules/transform' | ||||
| import Animation from '../Animation' | import Animation from '../Animation' | ||||
| import AnimationType from '../AnimationType' | |||||
| const RadarScanShader = require('@dc-modules/material/shader/radar/RadarScanShader.glsl') | const RadarScanShader = require('@dc-modules/material/shader/radar/RadarScanShader.glsl') | ||||
| this._color = options.color || Cesium.Color.BLUE | this._color = options.color || Cesium.Color.BLUE | ||||
| this._speed = options.speed || 3 | this._speed = options.speed || 3 | ||||
| this._delegate = undefined | this._delegate = undefined | ||||
| this.type = 'radar_scan' | |||||
| } | |||||
| get type() { | |||||
| return AnimationType.RADAR_SCAN | |||||
| } | } | ||||
| /** | /** | ||||
| } | } | ||||
| } | } | ||||
| AnimationType.RADAR_SCAN = 'radar_scan' | |||||
| export default RadarScan | export default RadarScan |
| super(id) | super(id) | ||||
| this._option = option | this._option = option | ||||
| this._delegate = DomUtil.create('div', 'dc-chart') | this._delegate = DomUtil.create('div', 'dc-chart') | ||||
| this._setWrapperStyle() | |||||
| this._chart = undefined | this._chart = undefined | ||||
| this.type = Layer.getLayerType('chart') | |||||
| this._setWrapperStyle() | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Layer.getLayerType('chart') | |||||
| } | |||||
| get chart() { | get chart() { | ||||
| return this._chart | return this._chart | ||||
| } | } |
| } | } | ||||
| dataToPoint(data) { | dataToPoint(data) { | ||||
| let scene = this._viewer.scene | |||||
| let result = [0, 0] | |||||
| let result = [] | |||||
| let cartesian3 = Cesium.Cartesian3.fromDegrees(data[0], data[1]) | let cartesian3 = Cesium.Cartesian3.fromDegrees(data[0], data[1]) | ||||
| if (!cartesian3) { | if (!cartesian3) { | ||||
| return result | 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) { | if (!coords) { | ||||
| return result | return result | ||||
| } | } |
| console.log( | console.log( | ||||
| `%c \n DC-SDK \n %c \n 用数字描绘世界之美 %c \n | `%c \n DC-SDK \n %c \n 用数字描绘世界之美 %c \n | ||||
| 版本:${__VERSION__} - ${__TIME__} | 版本:${__VERSION__} - ${__TIME__} | ||||
| Cesium版本:1.81.0 | |||||
| Cesium版本:1.86.0 | |||||
| 开发作者:${__AUTHOR__} | 开发作者:${__AUTHOR__} | ||||
| 网站主页: ${__HOME_PAGE__} | 网站主页: ${__HOME_PAGE__} | ||||
| github:${__REPOSITORY__} | github:${__REPOSITORY__} |
| this._enable = false | this._enable = false | ||||
| this._gradations = 1 | this._gradations = 1 | ||||
| this._selected = [] | this._selected = [] | ||||
| this.type = 'black_and_white' | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return 'black_and_white' | |||||
| } | |||||
| set enable(enable) { | set enable(enable) { | ||||
| this._enable = enable | this._enable = enable | ||||
| if (enable && this._viewer && !this._delegate) { | if (enable && this._viewer && !this._delegate) { |
| this._sigma = 3.8 | this._sigma = 3.8 | ||||
| this._stepSize = 5 | this._stepSize = 5 | ||||
| this._selected = [] | this._selected = [] | ||||
| this.type = 'bloom' | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return 'bloom' | |||||
| } | |||||
| set enable(enable) { | set enable(enable) { | ||||
| this._enable = enable | this._enable = enable | ||||
| if (enable && this._viewer && !this._delegate) { | if (enable && this._viewer && !this._delegate) { |
| this._enable = false | this._enable = false | ||||
| this._intensity = 1 | this._intensity = 1 | ||||
| this._selected = [] | this._selected = [] | ||||
| this.type = 'brightness' | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return 'brightness' | |||||
| } | |||||
| set enable(enable) { | set enable(enable) { | ||||
| this._enable = enable | this._enable = enable | ||||
| if (enable && this._viewer && !this._delegate) { | if (enable && this._viewer && !this._delegate) { |
| this._sigma = 3.8 | this._sigma = 3.8 | ||||
| this._stepSize = 2.5 | this._stepSize = 2.5 | ||||
| this._selected = [] | this._selected = [] | ||||
| this.type = 'depth_of_field' | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return 'depth_of_field' | |||||
| } | |||||
| set enable(enable) { | set enable(enable) { | ||||
| this._enable = enable | this._enable = enable | ||||
| if ( | if ( |
| this._dirtAmount = 0.4 | this._dirtAmount = 0.4 | ||||
| this._haloWidth = 0.4 | this._haloWidth = 0.4 | ||||
| this._selected = [] | this._selected = [] | ||||
| this.type = 'lens_flare' | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return 'lens_flare' | |||||
| } | |||||
| set enable(enable) { | set enable(enable) { | ||||
| this._enable = enable | this._enable = enable | ||||
| if (enable && this._viewer && !this._delegate) { | if (enable && this._viewer && !this._delegate) { |
| constructor() { | constructor() { | ||||
| this._enable = false | this._enable = false | ||||
| this._selected = [] | this._selected = [] | ||||
| this.type = 'night' | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return 'night' | |||||
| } | |||||
| set enable(enable) { | set enable(enable) { | ||||
| this._enable = enable | this._enable = enable | ||||
| if (enable && this._viewer && !this._delegate) { | if (enable && this._viewer && !this._delegate) { |
| this._color = Cesium.Color.GREEN | this._color = Cesium.Color.GREEN | ||||
| this._length = 0.5 | this._length = 0.5 | ||||
| this._selected = [] | this._selected = [] | ||||
| this.type = 'silhouette' | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return 'silhouette' | |||||
| } | |||||
| set enable(enable) { | set enable(enable) { | ||||
| this._enable = enable | this._enable = enable | ||||
| if ( | if ( |
| /** | |||||
| * @Author: Caven | |||||
| * @Date: 2021-08-01 00:22:00 | |||||
| */ |
| * @param context | * @param context | ||||
| */ | */ | ||||
| once(type, callback, 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 | |||||
| ) | |||||
| } | } | ||||
| /** | /** |
| } | } | ||||
| const MouseEventType = { | const MouseEventType = { | ||||
| LEFT_DOWN: Cesium.ScreenSpaceEventType.LEFT_DOWN, | |||||
| LEFT_UP: Cesium.ScreenSpaceEventType.LEFT_UP, | |||||
| CLICK: Cesium.ScreenSpaceEventType.LEFT_CLICK, | CLICK: Cesium.ScreenSpaceEventType.LEFT_CLICK, | ||||
| RIGHT_DOWN: Cesium.ScreenSpaceEventType.RIGHT_DOWN, | |||||
| RIGHT_UP: Cesium.ScreenSpaceEventType.RIGHT_UP, | |||||
| RIGHT_CLICK: Cesium.ScreenSpaceEventType.RIGHT_CLICK, | RIGHT_CLICK: Cesium.ScreenSpaceEventType.RIGHT_CLICK, | ||||
| DB_CLICK: Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK, | DB_CLICK: Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK, | ||||
| MOUSE_MOVE: Cesium.ScreenSpaceEventType.MOUSE_MOVE, | MOUSE_MOVE: Cesium.ScreenSpaceEventType.MOUSE_MOVE, | ||||
| REMOVE_LAYER: 'removeLayer', | REMOVE_LAYER: 'removeLayer', | ||||
| ADD_EFFECT: 'addEffect', | ADD_EFFECT: 'addEffect', | ||||
| REMOVE_EFFECT: 'removeEffect', | REMOVE_EFFECT: 'removeEffect', | ||||
| LEFT_DOWN: Cesium.ScreenSpaceEventType.LEFT_DOWN, | |||||
| LEFT_UP: Cesium.ScreenSpaceEventType.LEFT_UP, | |||||
| CLICK: Cesium.ScreenSpaceEventType.LEFT_CLICK, | CLICK: Cesium.ScreenSpaceEventType.LEFT_CLICK, | ||||
| RIGHT_DOWN: Cesium.ScreenSpaceEventType.RIGHT_DOWN, | |||||
| RIGHT_UP: Cesium.ScreenSpaceEventType.RIGHT_UP, | |||||
| RIGHT_CLICK: Cesium.ScreenSpaceEventType.RIGHT_CLICK, | RIGHT_CLICK: Cesium.ScreenSpaceEventType.RIGHT_CLICK, | ||||
| DB_CLICK: Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK, | DB_CLICK: Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK, | ||||
| MOUSE_MOVE: Cesium.ScreenSpaceEventType.MOUSE_MOVE, | MOUSE_MOVE: Cesium.ScreenSpaceEventType.MOUSE_MOVE, | ||||
| const OverlayEventType = { | const OverlayEventType = { | ||||
| ...BaseEventType, | ...BaseEventType, | ||||
| LEFT_DOWN: Cesium.ScreenSpaceEventType.LEFT_DOWN, | |||||
| LEFT_UP: Cesium.ScreenSpaceEventType.LEFT_UP, | |||||
| CLICK: Cesium.ScreenSpaceEventType.LEFT_CLICK, | CLICK: Cesium.ScreenSpaceEventType.LEFT_CLICK, | ||||
| RIGHT_DOWN: Cesium.ScreenSpaceEventType.RIGHT_DOWN, | |||||
| RIGHT_UP: Cesium.ScreenSpaceEventType.RIGHT_UP, | |||||
| RIGHT_CLICK: Cesium.ScreenSpaceEventType.RIGHT_CLICK, | RIGHT_CLICK: Cesium.ScreenSpaceEventType.RIGHT_CLICK, | ||||
| DB_CLICK: Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK, | DB_CLICK: Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK, | ||||
| MOUSE_MOVE: Cesium.ScreenSpaceEventType.MOUSE_MOVE, | MOUSE_MOVE: Cesium.ScreenSpaceEventType.MOUSE_MOVE, | ||||
| const LayerEventType = { | const LayerEventType = { | ||||
| ...BaseEventType, | ...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 = { | const TrackEventType = { | ||||
| RESET_TIME_LINE: 'restTimeLine' | 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 { | export { | ||||
| MouseEventType, | MouseEventType, | ||||
| ViewerEventType, | ViewerEventType, | ||||
| LayerEventType, | LayerEventType, | ||||
| OverlayEventType, | OverlayEventType, | ||||
| TrackEventType, | TrackEventType, | ||||
| PathEventType | |||||
| PathEventType, | |||||
| PlotEventType | |||||
| } | } |
| */ | */ | ||||
| export { default as TrackEvent } from './type/TrackEvent' | export { default as TrackEvent } from './type/TrackEvent' | ||||
| export { default as PathEvent } from './type/PathEvent' | export { default as PathEvent } from './type/PathEvent' | ||||
| /** | |||||
| * plot | |||||
| */ | |||||
| export { default as PlotEvent } from './type/PlotEvent' |
| this._viewer = viewer | this._viewer = viewer | ||||
| this._selected = undefined | this._selected = undefined | ||||
| this._setInputAction() | 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.CLICK, this._clickHandler, this) | ||||
| this.on(MouseEventType.DB_CLICK, this._dbClickHandler, 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.RIGHT_CLICK, this._rightClickHandler, this) | ||||
| this.on(MouseEventType.MOUSE_MOVE, this._mouseMoveHandler, this) | this.on(MouseEventType.MOUSE_MOVE, this._mouseMoveHandler, this) | ||||
| this.on(MouseEventType.WHEEL, this._mouseWheelHandler, this) | this.on(MouseEventType.WHEEL, this._mouseWheelHandler, this) | ||||
| let overlayId = undefined | let overlayId = undefined | ||||
| // for Entity | // for Entity | ||||
| if (target && target.id && target.id instanceof Cesium.Entity) { | |||||
| if (target?.id instanceof Cesium.Entity) { | |||||
| overlayId = target.id.overlayId | overlayId = target.id.overlayId | ||||
| } | } | ||||
| // for Cesium3DTileFeature | // for Cesium3DTileFeature | ||||
| if (target && target instanceof Cesium.Cesium3DTileFeature) { | |||||
| else if (target instanceof Cesium.Cesium3DTileFeature) { | |||||
| overlayId = target.tileset.overlayId | 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 | return overlayId | ||||
| } | } | ||||
| /** | /** | ||||
| * Returns the target information for the mouse event | * Returns the target information for the mouse event | ||||
| * @param target | * @param target | ||||
| * @returns {{overlay: any, feature: any, layer: any}} | |||||
| * @returns {{instanceId: *, overlay: undefined, feature: undefined, layer: undefined}} | |||||
| * @private | * @private | ||||
| */ | */ | ||||
| _getTargetInfo(target) { | _getTargetInfo(target) { | ||||
| let feature = undefined | let feature = undefined | ||||
| // for Entity | // for Entity | ||||
| if (target && target.id && target.id instanceof Cesium.Entity) { | |||||
| if (target?.id instanceof Cesium.Entity) { | |||||
| layer = this._viewer | layer = this._viewer | ||||
| .getLayers() | .getLayers() | ||||
| .filter(item => item.layerId === target.id.layerId)[0] | .filter(item => item.layerId === target.id.layerId)[0] | ||||
| if (layer && layer.getOverlay) { | |||||
| if (layer?.getOverlay) { | |||||
| overlay = layer.getOverlay(target.id.overlayId) | overlay = layer.getOverlay(target.id.overlayId) | ||||
| } | } | ||||
| } | } | ||||
| // for Cesium3DTileFeature | // for Cesium3DTileFeature | ||||
| else if (target && target instanceof Cesium.Cesium3DTileFeature) { | |||||
| else if (target instanceof Cesium.Cesium3DTileFeature) { | |||||
| layer = this._viewer | layer = this._viewer | ||||
| .getLayers() | .getLayers() | ||||
| .filter(item => item.layerId === target.tileset.layerId)[0] | .filter(item => item.layerId === target.tileset.layerId)[0] | ||||
| feature = target | feature = target | ||||
| if (layer && layer.getOverlay) { | |||||
| if (layer?.getOverlay) { | |||||
| overlay = layer.getOverlay(target.tileset.overlayId) | overlay = layer.getOverlay(target.tileset.overlayId) | ||||
| if (feature && feature.getPropertyNames) { | if (feature && feature.getPropertyNames) { | ||||
| let propertyNames = feature.getPropertyNames() | let propertyNames = feature.getPropertyNames() | ||||
| } | } | ||||
| // for Cesium3DTileset | // for Cesium3DTileset | ||||
| else if ( | |||||
| target && | |||||
| target.primitive && | |||||
| target.primitive instanceof Cesium.Cesium3DTileset | |||||
| ) { | |||||
| else if (target?.primitive instanceof Cesium.Cesium3DTileset) { | |||||
| layer = this._viewer | layer = this._viewer | ||||
| .getLayers() | .getLayers() | ||||
| .filter(item => item.layerId === target.primitive.layerId)[0] | .filter(item => item.layerId === target.primitive.layerId)[0] | ||||
| if (layer && layer.getOverlay) { | |||||
| if (layer?.getOverlay) { | |||||
| overlay = layer.getOverlay(target.primitive.overlayId) | overlay = layer.getOverlay(target.primitive.overlayId) | ||||
| } | } | ||||
| } | } | ||||
| // for Primitve | // for Primitve | ||||
| else if (target && target.primitive) { | |||||
| else if (target?.primitive) { | |||||
| layer = this._viewer | layer = this._viewer | ||||
| .getLayers() | .getLayers() | ||||
| .filter(item => item.layerId === target.primitive.layerId)[0] | .filter(item => item.layerId === target.primitive.layerId)[0] | ||||
| if (layer && layer.getOverlay) { | |||||
| if (layer?.getOverlay) { | |||||
| overlay = layer.getOverlay(target.primitive.overlayId) | overlay = layer.getOverlay(target.primitive.overlayId) | ||||
| } | } | ||||
| } | } | ||||
| return { layer: layer, overlay: overlay, feature: feature } | |||||
| return { | |||||
| layer: layer, | |||||
| overlay: overlay, | |||||
| feature: feature, | |||||
| instanceId: target?.instanceId | |||||
| } | |||||
| } | } | ||||
| /** | /** | ||||
| let event = undefined | let event = undefined | ||||
| let targetInfo = this._getTargetInfo(mouseInfo.target) | let targetInfo = this._getTargetInfo(mouseInfo.target) | ||||
| let overlay = targetInfo?.overlay | let overlay = targetInfo?.overlay | ||||
| let layer = targetInfo?.layer | |||||
| // get Overlay Event | // get Overlay Event | ||||
| if (overlay && overlay.overlayEvent) { | |||||
| if (overlay?.overlayEvent) { | |||||
| event = overlay.overlayEvent.getEvent(type) | event = overlay.overlayEvent.getEvent(type) | ||||
| } | } | ||||
| // get Layer Event | |||||
| if ((!event || event.numberOfListeners === 0) && layer?.layerEvent) { | |||||
| event = layer.layerEvent.getEvent(type) | |||||
| } | |||||
| // get Viewer Event | // get Viewer Event | ||||
| if (!event || event.numberOfListeners === 0) { | |||||
| if ( | |||||
| (!event || event.numberOfListeners === 0) && | |||||
| this._viewer?.viewerEvent | |||||
| ) { | |||||
| event = this._viewer.viewerEvent.getEvent(type) | event = this._viewer.viewerEvent.getEvent(type) | ||||
| } | } | ||||
| event && | event && | ||||
| event.numberOfListeners > 0 && | event.numberOfListeners > 0 && | ||||
| event.raiseEvent({ | event.raiseEvent({ | ||||
| }) | }) | ||||
| // get Drill Pick Event | // get Drill Pick Event | ||||
| if (overlay && overlay.allowDrillPicking) { | |||||
| if (overlay?.allowDrillPicking) { | |||||
| let drillInfos = this._getDrillInfos(mouseInfo.windowPosition) | let drillInfos = this._getDrillInfos(mouseInfo.windowPosition) | ||||
| drillInfos.forEach(drillInfo => { | drillInfos.forEach(drillInfo => { | ||||
| let dillOverlay = drillInfo?.overlay | let dillOverlay = drillInfo?.overlay | ||||
| let dillLayer = drillInfo?.layer | |||||
| if ( | if ( | ||||
| dillOverlay?.overlayId !== overlay.overlayId && | dillOverlay?.overlayId !== overlay.overlayId && | ||||
| dillOverlay?.overlayEvent | dillOverlay?.overlayEvent | ||||
| ) { | ) { | ||||
| // get Overlay Event | |||||
| event = dillOverlay.overlayEvent.getEvent(type) | event = dillOverlay.overlayEvent.getEvent(type) | ||||
| // get Layer Event | |||||
| if ( | |||||
| (!event || event.numberOfListeners === 0) && | |||||
| dillLayer?.layerEvent | |||||
| ) { | |||||
| event = dillLayer.layerEvent.getEvent(type) | |||||
| } | |||||
| event && | event && | ||||
| event.numberOfListeners > 0 && | event.numberOfListeners > 0 && | ||||
| event.raiseEvent({ | event.raiseEvent({ | ||||
| * @private | * @private | ||||
| */ | */ | ||||
| _clickHandler(movement) { | _clickHandler(movement) { | ||||
| if (!movement || !movement.position) { | |||||
| if (!movement?.position) { | |||||
| return false | return false | ||||
| } | } | ||||
| let mouseInfo = this._getMouseInfo(movement.position) | let mouseInfo = this._getMouseInfo(movement.position) | ||||
| * @private | * @private | ||||
| */ | */ | ||||
| _dbClickHandler(movement) { | _dbClickHandler(movement) { | ||||
| if (!movement || !movement.position) { | |||||
| if (!movement?.position) { | |||||
| return false | return false | ||||
| } | } | ||||
| let mouseInfo = this._getMouseInfo(movement.position) | let mouseInfo = this._getMouseInfo(movement.position) | ||||
| * @private | * @private | ||||
| */ | */ | ||||
| _rightClickHandler(movement) { | _rightClickHandler(movement) { | ||||
| if (!movement || !movement.position) { | |||||
| if (!movement?.position) { | |||||
| return false | return false | ||||
| } | } | ||||
| let mouseInfo = this._getMouseInfo(movement.position) | let mouseInfo = this._getMouseInfo(movement.position) | ||||
| * @private | * @private | ||||
| */ | */ | ||||
| _mouseMoveHandler(movement) { | _mouseMoveHandler(movement) { | ||||
| if (!movement || !movement.endPosition) { | |||||
| if (!movement?.endPosition) { | |||||
| return false | return false | ||||
| } | } | ||||
| let mouseInfo = this._getMouseInfo(movement.endPosition) | let mouseInfo = this._getMouseInfo(movement.endPosition) | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * 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 | * Default mouse wheel event handler | ||||
| * @param movement | * @param movement |
| /** | |||||
| * @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 |
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Layer.getLayerType('heat') | |||||
| } | |||||
| /** | /** | ||||
| * | * | ||||
| * @private | * @private | ||||
| /** | /** | ||||
| * | * | ||||
| * @returns {string|undefined} | |||||
| * @returns {HTMLCanvasElement|undefined} | |||||
| * @private | * @private | ||||
| */ | */ | ||||
| _createGradientTexture() { | _createGradientTexture() { | ||||
| let ctx = canvas.getContext('2d') | let ctx = canvas.getContext('2d') | ||||
| let grd = ctx.createLinearGradient(0, 0, 200, 0) | let grd = ctx.createLinearGradient(0, 0, 200, 0) | ||||
| for (let key in this._options.gradient) { | 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.fillStyle = grd | ||||
| ctx.fillRect(0, 0, 200, 10) | ctx.fillRect(0, 0, 200, 10) | ||||
| return canvas.toDataURL() | |||||
| return canvas | |||||
| } | } | ||||
| /** | /** |
| import TrackViewMode from './TrackViewMode' | import TrackViewMode from './TrackViewMode' | ||||
| const DEF_OPTS = { | const DEF_OPTS = { | ||||
| showPath: false, | |||||
| pathWidth: 1, | |||||
| pathMaterial: Cesium.Color.ORANGE.withAlpha(0.8), | |||||
| pathLeadTime: 1, | |||||
| clampToGround: false, | 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 { | class Track { | ||||
| ...options | ...options | ||||
| } | } | ||||
| this._controller = undefined | this._controller = undefined | ||||
| this._sampledPosition = undefined | |||||
| this._velocityOrientation = undefined | |||||
| this._viewed = false | this._viewed = false | ||||
| this._delegate = new Cesium.Entity() | 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._positionIndex = 0 | ||||
| this._timeLine = [] | this._timeLine = [] | ||||
| this._startTime = undefined | this._startTime = undefined | ||||
| this._trackEvent.on(TrackEventType.POST_RENDER, this._onPostRender, this) | this._trackEvent.on(TrackEventType.POST_RENDER, this._onPostRender, this) | ||||
| this._trackEvent.on(TrackEventType.ADD, this._onAdd, this) | this._trackEvent.on(TrackEventType.ADD, this._onAdd, this) | ||||
| this._trackEvent.on(TrackEventType.REMOVE, this._onRemove, this) | this._trackEvent.on(TrackEventType.REMOVE, this._onRemove, this) | ||||
| this._trackEvent.on( | |||||
| TrackEventType.RESET_TIME_LINE, | |||||
| this._resetTimeLine, | |||||
| this | |||||
| ) | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| set positions(postions) { | set positions(postions) { | ||||
| this._positions = Parse.parsePositions(postions) | this._positions = Parse.parsePositions(postions) | ||||
| this._resetTimeLine() | |||||
| this._resetTimeLine({}) | |||||
| return this | return this | ||||
| } | } | ||||
| set duration(duration) { | set duration(duration) { | ||||
| this._duration = duration | this._duration = duration | ||||
| this._resetTimeLine() | |||||
| this._resetTimeLine({}) | |||||
| return this | return this | ||||
| } | } | ||||
| } else { | } else { | ||||
| this._startTime = startTime | this._startTime = startTime | ||||
| } | } | ||||
| this._resetTimeLine() | |||||
| this._resetTimeLine({}) | |||||
| return this | return this | ||||
| } | } | ||||
| } | } | ||||
| this._controller = controller | this._controller = controller | ||||
| this._controller.delegate.add(this._delegate) | this._controller.delegate.add(this._delegate) | ||||
| this._controller.delegate.add(this._path) | |||||
| !this._startTime && (this._startTime = Cesium.JulianDate.now()) | !this._startTime && (this._startTime = Cesium.JulianDate.now()) | ||||
| this._state = State.ADDED | this._state = State.ADDED | ||||
| } | } | ||||
| * @private | * @private | ||||
| */ | */ | ||||
| _onRemove() { | _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._viewed = false | ||||
| this._startTime = undefined | |||||
| this._state = State.REMOVED | this._state = State.REMOVED | ||||
| } | } | ||||
| return false | return false | ||||
| } | } | ||||
| let now = Cesium.JulianDate.now() | 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) { | 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 { | } 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] | let time = this._timeLine[this._positionIndex] | ||||
| if (time) { | if (time) { | ||||
| let timeDiff = Cesium.JulianDate.secondsDifference(now, time) | let timeDiff = Cesium.JulianDate.secondsDifference(now, time) | ||||
| if (timeDiff >= 0 && timeDiff <= 1) { | if (timeDiff >= 0 && timeDiff <= 1) { | ||||
| let position = this._positions[this._positionIndex] || undefined | 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) | let hpr = Cesium.Transforms.fixedFrameToHeadingPitchRoll(mat4) | ||||
| position.heading = Cesium.Math.toDegrees(hpr.heading) | position.heading = Cesium.Math.toDegrees(hpr.heading) | ||||
| position.pitch = Cesium.Math.toDegrees(hpr.pitch) | position.pitch = Cesium.Math.toDegrees(hpr.pitch) | ||||
| return false | return false | ||||
| } | } | ||||
| let interval = 0 | 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._duration += params.duration | ||||
| this._timeLine = this._timeLine.map(item => { | this._timeLine = this._timeLine.map(item => { | ||||
| if (Cesium.JulianDate.greaterThan(item, params.stopTime)) { | if (Cesium.JulianDate.greaterThan(item, params.stopTime)) { | ||||
| item = Cesium.JulianDate.addSeconds( | item = Cesium.JulianDate.addSeconds( | ||||
| item, | item, | ||||
| params.stopTime, | |||||
| params.duration, | |||||
| new Cesium.JulianDate() | new Cesium.JulianDate() | ||||
| ) | ) | ||||
| } | } | ||||
| ) | ) | ||||
| this._sampledPosition.forwardExtrapolationType = | this._sampledPosition.forwardExtrapolationType = | ||||
| Cesium.ExtrapolationType.HOLD | 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._sampledPosition | ||||
| ) | ) | ||||
| this._endTime = this._timeLine[this._timeLine.length - 1] | this._endTime = this._timeLine[this._timeLine.length - 1] | ||||
| addPosition(position, duration) { | addPosition(position, duration) { | ||||
| this._positions.push(Parse.parsePosition(position)) | this._positions.push(Parse.parsePosition(position)) | ||||
| this._duration += duration | this._duration += duration | ||||
| this._resetTimeLine() | |||||
| this._resetTimeLine({}) | |||||
| return this | return this | ||||
| } | } | ||||
| return this | 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 | export default Track |
| this._viewer = viewer | this._viewer = viewer | ||||
| this._cache = {} | this._cache = {} | ||||
| this._delegete = new Cesium.CustomDataSource('history-track-layer') | this._delegete = new Cesium.CustomDataSource('history-track-layer') | ||||
| viewer.dataSources.add(this._delegete) | |||||
| this._viewer.dataSources.add(this._delegete) | |||||
| this._activedTrack = undefined | this._activedTrack = undefined | ||||
| this._viewMode = undefined | this._viewMode = undefined | ||||
| this._viewOption = {} | this._viewOption = {} | ||||
| let track = this._cache[key] | let track = this._cache[key] | ||||
| track.trackEvent.fire(TrackEventType.RESET_TIME_LINE, { | track.trackEvent.fire(TrackEventType.RESET_TIME_LINE, { | ||||
| stopTime: this._stopTime, | stopTime: this._stopTime, | ||||
| duration: Cesium.JulianDate.secondsDifference(this._stopTime, now) | |||||
| duration: Cesium.JulianDate.secondsDifference(now, this._stopTime) | |||||
| }) | }) | ||||
| }) | }) | ||||
| } | } |
| this._layerEvent = new LayerEvent() | this._layerEvent = new LayerEvent() | ||||
| this._layerEvent.on(LayerEventType.ADD, this._onAdd, this) | this._layerEvent.on(LayerEventType.ADD, this._onAdd, this) | ||||
| this._layerEvent.on(LayerEventType.REMOVE, this._onRemove, this) | this._layerEvent.on(LayerEventType.REMOVE, this._onRemove, this) | ||||
| this._state = undefined | |||||
| this.type = undefined | |||||
| } | } | ||||
| get layerId() { | get layerId() { | ||||
| * @private | * @private | ||||
| */ | */ | ||||
| _addOverlay(overlay) { | _addOverlay(overlay) { | ||||
| if ( | |||||
| overlay && | |||||
| overlay.overlayEvent && | |||||
| !this._cache.hasOwnProperty(overlay.overlayId) | |||||
| ) { | |||||
| if (!this._cache.hasOwnProperty(overlay.overlayId)) { | |||||
| this._cache[overlay.overlayId] = overlay | 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) { | if (this._state === State.CLEARED) { | ||||
| this._state = State.ADDED | this._state = State.ADDED | ||||
| } | } | ||||
| * @private | * @private | ||||
| */ | */ | ||||
| _removeOverlay(overlay) { | _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] | delete this._cache[overlay.overlayId] | ||||
| } | } | ||||
| } | } | ||||
| * @returns {Layer} | * @returns {Layer} | ||||
| */ | */ | ||||
| addTo(viewer) { | addTo(viewer) { | ||||
| if (viewer && viewer.addLayer) { | |||||
| if (viewer?.addLayer) { | |||||
| viewer.addLayer(this) | viewer.addLayer(this) | ||||
| } | } | ||||
| return this | return this | ||||
| */ | */ | ||||
| setStyle(style) {} | 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 | * Registers Type | ||||
| * @param type | * @param type |
| this._layerGroupEvent = new LayerGroupEvent() | this._layerGroupEvent = new LayerGroupEvent() | ||||
| this._layerGroupEvent.on(LayerGroupEventType.ADD, this._onAdd, this) | this._layerGroupEvent.on(LayerGroupEventType.ADD, this._onAdd, this) | ||||
| this._layerGroupEvent.on(LayerGroupEventType.REMOVE, this._onRemove, this) | this._layerGroupEvent.on(LayerGroupEventType.REMOVE, this._onRemove, this) | ||||
| this.type = Layer.getLayerType('layer_group') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| return this._id | return this._id | ||||
| } | } | ||||
| get type() { | |||||
| return Layer.getLayerType('layer_group') | |||||
| } | |||||
| set show(show) { | set show(show) { | ||||
| this._show = show | this._show = show | ||||
| Object.keys(this._cache).forEach(key => { | Object.keys(this._cache).forEach(key => { |
| this | this | ||||
| ) | ) | ||||
| this._delegate.clustering.pixelRange = this._options.pixelRange | this._delegate.clustering.pixelRange = this._options.pixelRange | ||||
| this.type = Layer.getLayerType('cluster') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Layer.getLayerType('cluster') | |||||
| } | |||||
| set enableCluster(enableCluster) { | set enableCluster(enableCluster) { | ||||
| this._delegate.clustering.enabled = enableCluster | this._delegate.clustering.enabled = enableCluster | ||||
| return this | return this |
| constructor(id, url = '', options = {}) { | constructor(id, url = '', options = {}) { | ||||
| super(id) | super(id) | ||||
| this._delegate = Cesium.CzmlDataSource.load(url, options) | this._delegate = Cesium.CzmlDataSource.load(url, options) | ||||
| this.type = Layer.getLayerType('czml') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Layer.getLayerType('czml') | |||||
| } | |||||
| set show(show) { | set show(show) { | ||||
| this._show = show | this._show = show | ||||
| this._delegate && | this._delegate && |
| constructor(id) { | constructor(id) { | ||||
| super(id) | super(id) | ||||
| this._delegate = new Cesium.CustomDataSource(id) | this._delegate = new Cesium.CustomDataSource(id) | ||||
| this.type = Layer.getLayerType('dynamic') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Layer.getLayerType('dynamic') | |||||
| } | |||||
| /** | /** | ||||
| * Clears all entities | * Clears all entities | ||||
| * @returns {DynamicLayer} | * @returns {DynamicLayer} |
| count: 10, | count: 10, | ||||
| maximumLevel: 21, | maximumLevel: 21, | ||||
| dataProperty: '', | dataProperty: '', | ||||
| callback: record => { | |||||
| callback: () => { | |||||
| return null | return null | ||||
| } | } | ||||
| } | } | ||||
| this._rectangle = this._tilingScheme.rectangle | this._rectangle = this._tilingScheme.rectangle | ||||
| this._credit = undefined | this._credit = undefined | ||||
| this._token = undefined | this._token = undefined | ||||
| this.type = Layer.getLayerType('feature_grid') | |||||
| for (let i = 0; i < this.maximumLevel; i++) { | for (let i = 0; i < this.maximumLevel; i++) { | ||||
| this._levelLayers[String(i)] = new VectorLayer(id + '-grid-' + i) | this._levelLayers[String(i)] = new VectorLayer(id + '-grid-' + i) | ||||
| } | } | ||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Layer.getLayerType('feature_grid') | |||||
| } | |||||
| get url() { | get url() { | ||||
| return this._url | return this._url | ||||
| } | } |
| } | } | ||||
| super(id) | super(id) | ||||
| this._delegate = Cesium.GeoJsonDataSource.load(url, options) | this._delegate = Cesium.GeoJsonDataSource.load(url, options) | ||||
| this.type = Layer.getLayerType('geojson') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Layer.getLayerType('geojson') | |||||
| } | |||||
| set show(show) { | set show(show) { | ||||
| this._show = show | this._show = show | ||||
| this._delegate && | this._delegate && |
| this._delegate = DomUtil.create('div', 'html-layer', undefined) | this._delegate = DomUtil.create('div', 'html-layer', undefined) | ||||
| this._delegate.setAttribute('id', this._id) | this._delegate.setAttribute('id', this._id) | ||||
| this._renderRemoveCallback = undefined | this._renderRemoveCallback = undefined | ||||
| this.type = Layer.getLayerType('html') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Layer.getLayerType('html') | |||||
| } | |||||
| set show(show) { | set show(show) { | ||||
| this._show = show | this._show = show | ||||
| this._delegate.style.visibility = this._show ? 'visible' : 'hidden' | this._delegate.style.visibility = this._show ? 'visible' : 'hidden' | ||||
| this._viewer.dcContainer.appendChild(this._delegate) | this._viewer.dcContainer.appendChild(this._delegate) | ||||
| let scene = this._viewer.scene | let scene = this._viewer.scene | ||||
| this._renderRemoveCallback = scene.postRender.addEventListener(() => { | 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 => { | this.eachOverlay(item => { | ||||
| if (item && item.position) { | if (item && item.position) { | ||||
| let position = Transform.transformWGS84ToCartesian(item.position) | let position = Transform.transformWGS84ToCartesian(item.position) | ||||
| let up = scene.globe.ellipsoid.geodeticSurfaceNormal( | |||||
| position, | |||||
| new Cesium.Cartesian3() | |||||
| ) | |||||
| let windowCoord = Cesium.SceneTransforms.wgs84ToWindowCoordinates( | let windowCoord = Cesium.SceneTransforms.wgs84ToWindowCoordinates( | ||||
| scene, | scene, | ||||
| position | 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) | ||||
| }, this) | }, this) |
| } | } | ||||
| super(id) | super(id) | ||||
| this._delegate = Cesium.KmlDataSource.load(url, options) | this._delegate = Cesium.KmlDataSource.load(url, options) | ||||
| this.type = Layer.getLayerType('kml') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Layer.getLayerType('kml') | |||||
| } | |||||
| set show(show) { | set show(show) { | ||||
| this._show = show | this._show = show | ||||
| this._delegate && | this._delegate && |
| this._dataSource = Cesium.GeoJsonDataSource.load(url) | this._dataSource = Cesium.GeoJsonDataSource.load(url) | ||||
| this._delegate = new Cesium.CustomDataSource(id) | this._delegate = new Cesium.CustomDataSource(id) | ||||
| this._initLabel() | this._initLabel() | ||||
| this.type = Layer.registerType('label') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Layer.getLayerType('label') | |||||
| } | |||||
| _createLabel(entity) { | _createLabel(entity) { | ||||
| if (entity.position && entity.name) { | if (entity.position && entity.name) { | ||||
| return Label.fromEntity(entity) | return Label.fromEntity(entity) |
| import State from '@dc-modules/state/State' | import State from '@dc-modules/state/State' | ||||
| import Layer from '../Layer' | import Layer from '../Layer' | ||||
| /** | |||||
| * PrimitiveLayer is used to add primitve | |||||
| */ | |||||
| class PrimitiveLayer extends Layer { | class PrimitiveLayer extends Layer { | ||||
| constructor(id) { | constructor(id) { | ||||
| super(id) | super(id) | ||||
| this._labels = this._delegate.add(new Cesium.LabelCollection()) | this._labels = this._delegate.add(new Cesium.LabelCollection()) | ||||
| this._billboards = this._delegate.add(new Cesium.BillboardCollection()) | this._billboards = this._delegate.add(new Cesium.BillboardCollection()) | ||||
| this._polylines = this._delegate.add(new Cesium.PolylineCollection()) | this._polylines = this._delegate.add(new Cesium.PolylineCollection()) | ||||
| this.type = Layer.getLayerType('primitive') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Layer.getLayerType('primitive') | |||||
| } | |||||
| get points() { | get points() { | ||||
| return this._points | return this._points | ||||
| } | } |
| constructor(id) { | constructor(id) { | ||||
| super(id) | super(id) | ||||
| this._delegate = new Cesium.PrimitiveCollection() | this._delegate = new Cesium.PrimitiveCollection() | ||||
| this.type = Layer.getLayerType('tileset') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Layer.getLayerType('tileset') | |||||
| } | |||||
| /** | /** | ||||
| * Clear all tileset | * Clear all tileset | ||||
| * @returns {TilesetLayer} | * @returns {TilesetLayer} |
| import State from '@dc-modules/state/State' | import State from '@dc-modules/state/State' | ||||
| import GeoJsonLayer from './GeoJsonLayer' | import GeoJsonLayer from './GeoJsonLayer' | ||||
| import Layer from '../Layer' | |||||
| class TopoJsonLayer extends GeoJsonLayer { | class TopoJsonLayer extends GeoJsonLayer { | ||||
| constructor(id, url, options = {}) { | constructor(id, url, options = {}) { | ||||
| throw new Error('TopoJsonLayer:the url invalid') | throw new Error('TopoJsonLayer:the url invalid') | ||||
| } | } | ||||
| super(id, url, options) | super(id, url, options) | ||||
| this.type = GeoJsonLayer.getLayerType('topojson') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Layer.getLayerType('topojson') | |||||
| } | |||||
| } | } | ||||
| GeoJsonLayer.registerType('topojson') | GeoJsonLayer.registerType('topojson') |
| constructor(id) { | constructor(id) { | ||||
| super(id) | super(id) | ||||
| this._delegate = new Cesium.CustomDataSource(id) | this._delegate = new Cesium.CustomDataSource(id) | ||||
| this.type = Layer.getLayerType('vector') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Layer.getLayerType('vector') | |||||
| } | |||||
| /** | /** | ||||
| * Clears all entities | * Clears all entities | ||||
| * @returns {VectorLayer} | * @returns {VectorLayer} |
| /** | |||||
| * @Author: Caven | |||||
| * @Date: 2021-08-17 20:43:05 | |||||
| */ | |||||
| class Loader { | |||||
| static loadDCP() {} | |||||
| static loadDPS(fileName, is) {} | |||||
| } | |||||
| export default Loader |
| /** | |||||
| * @Author: Caven | |||||
| * @Date: 2021-08-17 20:42:39 | |||||
| */ |
| /** | /** | ||||
| * @Author: Caven | * @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 |
| /** | |||||
| * @Author: Caven | |||||
| * @Date: 2021-08-17 20:52:16 | |||||
| */ |
| this._option = option | this._option = option | ||||
| this._dataSet = undefined | this._dataSet = undefined | ||||
| this._delegate = undefined | this._delegate = undefined | ||||
| this.type = Layer.getLayerType('mapv') | |||||
| this._state = State.INITIALIZED | |||||
| } | |||||
| get type() { | |||||
| return Layer.getLayerType('mapv') | |||||
| } | } | ||||
| set show(show) { | set show(show) { |
| float time = fract(czm_frameNumber * speed / 1000.0); | float time = fract(czm_frameNumber * speed / 1000.0); | ||||
| vec4 colorImage = texture2D(image, vec2(fract(st.s - time), st.t)); | vec4 colorImage = texture2D(image, vec2(fract(st.s - time), st.t)); | ||||
| if(color.a == 0.0){ | if(color.a == 0.0){ | ||||
| if(colorImage.rgb == vec3(1.0) || colorImage.rgb == vec3(0.0)){ | |||||
| discard; | |||||
| } | |||||
| material.alpha = colorImage.a; | material.alpha = colorImage.a; | ||||
| material.diffuse = colorImage.rgb; | material.diffuse = colorImage.rgb; | ||||
| }else{ | }else{ |
| * @Date: 2020-04-24 14:49:37 | * @Date: 2020-04-24 14:49:37 | ||||
| */ | */ | ||||
| import { Cesium } from '@dc-modules/namespace' | |||||
| import { Transform } from '@dc-modules/transform' | 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) { | export default function area(positions) { | ||||
| let result = 0 | 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 | return result | ||||
| } | } |
| export { default as area } from './area' | export { default as area } from './area' | ||||
| export { default as bounds } from './bounds' | export { default as bounds } from './bounds' | ||||
| export { default as mid } from './mid' | |||||
| export { default as center } from './center' | export { default as center } from './center' | ||||
| export { default as curve } from './curve' | |||||
| export { default as distance } from './distance' | export { default as distance } from './distance' | ||||
| export { default as heading } from './heading' | export { default as heading } from './heading' | ||||
| export { default as isBetween } from './isBetween' | 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 parabola } from './parabola' | ||||
| export { default as curve } from './curve' |
| /** | |||||
| * @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) | |||||
| } |
| import Parse from '@dc-modules/parse/Parse' | import Parse from '@dc-modules/parse/Parse' | ||||
| import Position from '@dc-modules/position/Position' | 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 startPosition = Parse.parsePosition(start) | ||||
| let endPosition = Parse.parsePosition(end) | let endPosition = Parse.parsePosition(end) | ||||
| startPosition = Transform.transformWGS84ToCartographic(startPosition) | startPosition = Transform.transformWGS84ToCartographic(startPosition) | ||||
| endPosition = Transform.transformWGS84ToCartographic(endPosition) | endPosition = Transform.transformWGS84ToCartographic(endPosition) | ||||
| let mc = new Cesium.EllipsoidGeodesic( | let mc = new Cesium.EllipsoidGeodesic( | ||||
| startPosition, | startPosition, | ||||
| endPosition | endPosition |
| depthTestAgainstTerrain: globeOption?.depthTestAgainstTerrain ?? false, | depthTestAgainstTerrain: globeOption?.depthTestAgainstTerrain ?? false, | ||||
| tileCacheSize: +globeOption?.tileCacheSize || 100, | tileCacheSize: +globeOption?.tileCacheSize || 100, | ||||
| preloadSiblings: globeOption?.enableLighting ?? false, | 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, { | Util.merge(globe.translucency, { |
| * @Date: 2020-03-05 22:00:17 | * @Date: 2020-03-05 22:00:17 | ||||
| */ | */ | ||||
| export { default as MouseMode } from './MouseMode' | |||||
| export { default as ViewerOption } from './ViewerOption' | export { default as ViewerOption } from './ViewerOption' | ||||
| export { default as CameraOption } from './CameraOption' | export { default as CameraOption } from './CameraOption' |
| this._allowDrillPicking = false | this._allowDrillPicking = false | ||||
| this._contextMenu = [] | this._contextMenu = [] | ||||
| this._overlayEvent = new OverlayEvent() | 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() { | get overlayId() { | ||||
| this._layer.delegate.entities.add(this._delegate) | this._layer.delegate.entities.add(this._delegate) | ||||
| } else if (this._layer?.delegate?.add && this._delegate) { | } else if (this._layer?.delegate?.add && this._delegate) { | ||||
| // for Primitive | // 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) | this._delegate = this._layer.points.add(this._delegate) | ||||
| } else if ( | } else if ( | ||||
| this.type === 'billboard_primitive' && | |||||
| this.type.indexOf('billboard_primitive') >= 0 && | |||||
| this._layer.billboards | this._layer.billboards | ||||
| ) { | ) { | ||||
| this._delegate = this._layer.billboards.add(this._delegate) | this._delegate = this._layer.billboards.add(this._delegate) | ||||
| } else if (this.type === 'polyline_primitive' && this._layer.polylines) { | } else if (this.type === 'polyline_primitive' && this._layer.polylines) { | ||||
| this._delegate = this._layer.polylines.add(this._delegate) | 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) | this._delegate = this._layer.labels.add(this._delegate) | ||||
| } else { | } else { | ||||
| this._layer.delegate.add(this._delegate) | this._layer.delegate.add(this._delegate) | ||||
| if (this.type === 'point_primitive' && this._layer.points) { | if (this.type === 'point_primitive' && this._layer.points) { | ||||
| this._layer.points.remove(this._delegate) | this._layer.points.remove(this._delegate) | ||||
| } else if ( | } else if ( | ||||
| this.type === 'billboard_primitive' && | |||||
| this.type.indexOf('billboard_primitive') >= 0 && | |||||
| this._layer.billboards | this._layer.billboards | ||||
| ) { | ) { | ||||
| this._layer.billboards.remove(this._delegate) | this._layer.billboards.remove(this._delegate) | ||||
| } else if (this.type === 'polyline_primitive' && this._layer.polylines) { | } else if (this.type === 'polyline_primitive' && this._layer.polylines) { | ||||
| this._layer.polylines.remove(this._delegate) | 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) | this._layer.labels.remove(this._delegate) | ||||
| } else { | } else { | ||||
| this._layer.delegate.remove(this._delegate) | this._layer.delegate.remove(this._delegate) |
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._icon = icon | this._icon = icon | ||||
| this._size = [32, 32] | this._size = [32, 32] | ||||
| this.type = Overlay.getOverlayType('custom_billboard') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('custom_billboard') | |||||
| } | |||||
| set position(position) { | set position(position) { | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._delegate.position = Transform.transformWGS84ToCartesian( | this._delegate.position = Transform.transformWGS84ToCartesian( | ||||
| ...style, | ...style, | ||||
| semiMajorAxis: radius, | semiMajorAxis: radius, | ||||
| semiMinorAxis: radius, | semiMinorAxis: radius, | ||||
| stRotation: new Cesium.CallbackProperty(time => { | |||||
| stRotation: new Cesium.CallbackProperty(() => { | |||||
| stRotation += amount | stRotation += amount | ||||
| if (stRotation >= 360 || stRotation <= -360) { | if (stRotation >= 360 || stRotation <= -360) { | ||||
| stRotation = 0 | stRotation = 0 |
| this._delegate = new Cesium.Entity({ label: {} }) | this._delegate = new Cesium.Entity({ label: {} }) | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._text = text | this._text = text | ||||
| this.type = Overlay.getOverlayType('custom_label') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('custom_label') | |||||
| } | |||||
| set position(position) { | set position(position) { | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._delegate.position = Transform.transformWGS84ToCartesian( | this._delegate.position = Transform.transformWGS84ToCartesian( | ||||
| ...style, | ...style, | ||||
| semiMajorAxis: radius, | semiMajorAxis: radius, | ||||
| semiMinorAxis: radius, | semiMinorAxis: radius, | ||||
| stRotation: new Cesium.CallbackProperty(time => { | |||||
| stRotation: new Cesium.CallbackProperty(() => { | |||||
| stRotation += amount | stRotation += amount | ||||
| if (stRotation >= 360 || stRotation <= -360) { | if (stRotation >= 360 || stRotation <= -360) { | ||||
| stRotation = 0 | stRotation = 0 |
| this._posistion = Parse.parsePosition(position) | this._posistion = Parse.parsePosition(position) | ||||
| this._icon = icon | this._icon = icon | ||||
| this._delegate = new Cesium.Entity({ billboard: {} }) | this._delegate = new Cesium.Entity({ billboard: {} }) | ||||
| this.type = Overlay.getOverlayType('dynamic_billboard') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('dynamic_billboard') | |||||
| } | |||||
| set icon(icon) { | set icon(icon) { | ||||
| this._icon = icon | this._icon = icon | ||||
| this._delegate.billboard.image = this._icon | this._delegate.billboard.image = this._icon | ||||
| /** | /** | ||||
| * set the location | * set the location | ||||
| */ | */ | ||||
| this._samplePosition.forwardExtrapolationType = | |||||
| this._sampledPosition.forwardExtrapolationType = | |||||
| Cesium.ExtrapolationType.HOLD | Cesium.ExtrapolationType.HOLD | ||||
| this._startTime = Cesium.JulianDate.now() | this._startTime = Cesium.JulianDate.now() | ||||
| this._samplePosition.addSample( | |||||
| this._sampledPosition.addSample( | |||||
| this._startTime, | this._startTime, | ||||
| Transform.transformWGS84ToCartesian(this._posistion) | Transform.transformWGS84ToCartesian(this._posistion) | ||||
| ) | ) | ||||
| this._delegate.position = this._samplePosition | |||||
| this._delegate.position = this._sampledPosition | |||||
| this._cache.push(this._startTime) | this._cache.push(this._startTime) | ||||
| /** | /** | ||||
| * initialize the Overlay parameter | * initialize the Overlay parameter |
| this._posistion = Parse.parsePosition(position) | this._posistion = Parse.parsePosition(position) | ||||
| this._modelUrl = modelUrl | this._modelUrl = modelUrl | ||||
| this._delegate = new Cesium.Entity({ model: {} }) | this._delegate = new Cesium.Entity({ model: {} }) | ||||
| this.type = Overlay.getOverlayType('dynamic_model') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('dynamic_model') | |||||
| } | |||||
| set modelUrl(modelUrl) { | set modelUrl(modelUrl) { | ||||
| this._modelUrl = modelUrl | this._modelUrl = modelUrl | ||||
| this._delegate.model.uri = this._modelUrl | this._delegate.model.uri = this._modelUrl | ||||
| /** | /** | ||||
| * set the location | * set the location | ||||
| */ | */ | ||||
| this._samplePosition.forwardExtrapolationType = | |||||
| this._sampledPosition.forwardExtrapolationType = | |||||
| Cesium.ExtrapolationType.HOLD | Cesium.ExtrapolationType.HOLD | ||||
| this._startTime = Cesium.JulianDate.now() | this._startTime = Cesium.JulianDate.now() | ||||
| this._samplePosition.addSample( | |||||
| this._sampledPosition.addSample( | |||||
| this._startTime, | this._startTime, | ||||
| Transform.transformWGS84ToCartesian(this._posistion) | Transform.transformWGS84ToCartesian(this._posistion) | ||||
| ) | ) | ||||
| this._delegate.position = this._samplePosition | |||||
| this._delegate.position = this._sampledPosition | |||||
| this._delegate.orientation = new Cesium.VelocityOrientationProperty( | this._delegate.orientation = new Cesium.VelocityOrientationProperty( | ||||
| this._samplePosition | |||||
| this._sampledPosition | |||||
| ) | ) | ||||
| this._cache.push(this._startTime) | this._cache.push(this._startTime) | ||||
| /** | /** |
| super() | super() | ||||
| this._startTime = undefined | this._startTime = undefined | ||||
| this._lastTime = undefined | this._lastTime = undefined | ||||
| this._samplePosition = new Cesium.SampledPositionProperty() | |||||
| this._sampledPosition = new Cesium.SampledPositionProperty() | |||||
| this._cache = [] | this._cache = [] | ||||
| this._maxCacheSize = 10 | this._maxCacheSize = 10 | ||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| get position() { | get position() { | ||||
| return Transform.transformCartesianToWGS84( | return Transform.transformCartesianToWGS84( | ||||
| this._samplePosition.getValue(Cesium.JulianDate.now()) | |||||
| this._sampledPosition.getValue(Cesium.JulianDate.now()) | |||||
| ) | ) | ||||
| } | } | ||||
| -0.2, | -0.2, | ||||
| new Cesium.JulianDate() | new Cesium.JulianDate() | ||||
| ) | ) | ||||
| this._samplePosition.removeSamples( | |||||
| this._sampledPosition.removeSamples( | |||||
| new Cesium.TimeInterval({ | new Cesium.TimeInterval({ | ||||
| start: start, | start: start, | ||||
| stop: stop | stop: stop | ||||
| interval, | interval, | ||||
| new Cesium.JulianDate() | new Cesium.JulianDate() | ||||
| ) | ) | ||||
| this._samplePosition.addSample( | |||||
| this._sampledPosition.addSample( | |||||
| time, | time, | ||||
| Transform.transformWGS84ToCartesian(Parse.parsePosition(position)) | Transform.transformWGS84ToCartesian(Parse.parsePosition(position)) | ||||
| ) | ) | ||||
| } | } | ||||
| } | } | ||||
| Overlay.registerType('dynamic-model') | |||||
| export default DynamicOverlay | export default DynamicOverlay |
| left: '0' | left: '0' | ||||
| }) | }) | ||||
| this.content = content | this.content = content | ||||
| this.type = Overlay.getOverlayType('div_icon') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('div_icon') | |||||
| } | |||||
| set show(show) { | set show(show) { | ||||
| this._show = show | this._show = show | ||||
| this._delegate.style.visibility = this._show ? 'visible' : 'hidden' | this._delegate.style.visibility = this._show ? 'visible' : 'hidden' | ||||
| /** | /** | ||||
| * Updates style | * Updates style | ||||
| * @param style | |||||
| * @param windowCoord | |||||
| * @param distance | * @param distance | ||||
| * @param isFront | |||||
| * @private | * @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 scale3d = 'scale3d(1,1,1)' | ||||
| let scaleByDistance = this._style.scaleByDistance | let scaleByDistance = this._style.scaleByDistance | ||||
| if (distance && 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)` | scale3d = `scale3d(${nearValue},${nearValue},1)` | ||||
| } else if (distance > scaleByDistance.far) { | |||||
| } else if (distance > far) { | |||||
| scale3d = `scale3d(${farValue},${farValue},1)` | scale3d = `scale3d(${farValue},${farValue},1)` | ||||
| } else { | } else { | ||||
| let scale = farValue + f * (nearValue - farValue) | let scale = farValue + f * (nearValue - farValue) | ||||
| } | } | ||||
| } | } | ||||
| // set condition | |||||
| let isDisplay = true | |||||
| let distanceDisplayCondition = this._style.distanceDisplayCondition | let distanceDisplayCondition = this._style.distanceDisplayCondition | ||||
| if (distance && 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.transform = `${translate3d} ${scale3d}` | ||||
| this._delegate.style.visibility = | |||||
| isDisplay && isFront ? 'visible' : 'hidden' | |||||
| } | } | ||||
| /** | /** | ||||
| overlay: this, | overlay: this, | ||||
| position: Transform.transformWGS84ToCartesian(this._position) | position: Transform.transformWGS84ToCartesian(this._position) | ||||
| } | } | ||||
| this._delegate.addEventListener('click', () => { | this._delegate.addEventListener('click', () => { | ||||
| this._overlayEvent.fire(MouseEventType.CLICK, params) | this._overlayEvent.fire(MouseEventType.CLICK, params) | ||||
| }) | }) |
| * primitive | * primitive | ||||
| */ | */ | ||||
| export { default as BillboardPrimitive } from './primitive/BillboardPrimitive.js' | 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 DiffuseWallPrimitive } from './primitive/DiffuseWallPrimitive.js' | ||||
| export { default as ElecEllipsoidPrimitive } from './primitive/ElecEllipsoidPrimitive' | export { default as ElecEllipsoidPrimitive } from './primitive/ElecEllipsoidPrimitive' | ||||
| export { default as FlowLinePrimitive } from './primitive/FlowLinePrimitive' | export { default as FlowLinePrimitive } from './primitive/FlowLinePrimitive' | ||||
| export { default as LabelPrimitive } from './primitive/LabelPrimitive' | export { default as LabelPrimitive } from './primitive/LabelPrimitive' | ||||
| export { default as ModelCollectionPrimitive } from './primitive/ModelCollectionPrimitive' | |||||
| export { default as ModelPrimitive } from './primitive/ModelPrimitive' | export { default as ModelPrimitive } from './primitive/ModelPrimitive' | ||||
| export { default as PointPrimitive } from './primitive/PointPrimitive.js' | export { default as PointPrimitive } from './primitive/PointPrimitive.js' | ||||
| export { default as PolylinePrimitive } from './primitive/PolylinePrimitive.js' | export { default as PolylinePrimitive } from './primitive/PolylinePrimitive.js' |
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._modelUrl = modelUrl | this._modelUrl = modelUrl | ||||
| this._rotateAmount = 0 | this._rotateAmount = 0 | ||||
| this.type = Overlay.getOverlayType('model') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('model') | |||||
| } | |||||
| set position(position) { | set position(position) { | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._delegate.position = Transform.transformWGS84ToCartesian( | this._delegate.position = Transform.transformWGS84ToCartesian( | ||||
| set rotateAmount(amount) { | set rotateAmount(amount) { | ||||
| this._rotateAmount = +amount | this._rotateAmount = +amount | ||||
| this._delegate.orientation = new Cesium.CallbackProperty(time => { | |||||
| this._delegate.orientation = new Cesium.CallbackProperty(() => { | |||||
| this._position.heading += this._rotateAmount | this._position.heading += this._rotateAmount | ||||
| if (this._position.heading >= 360 || this._position.heading <= -360) { | if (this._position.heading >= 360 || this._position.heading <= -360) { | ||||
| this._position.heading = 0 | this._position.heading = 0 |
| this._tileVisibleCallback = undefined | this._tileVisibleCallback = undefined | ||||
| this._properties = undefined | this._properties = undefined | ||||
| this._customShader = undefined | this._customShader = undefined | ||||
| this.type = Overlay.getOverlayType('tileset') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('tileset') | |||||
| } | |||||
| get readyPromise() { | get readyPromise() { | ||||
| return this._delegate.readyPromise | return this._delegate.readyPromise | ||||
| } | } |
| this.neckHeightFactor = 0.85 | this.neckHeightFactor = 0.85 | ||||
| this.neckWidthFactor = 0.15 | this.neckWidthFactor = 0.15 | ||||
| this.headTailFactor = 0.8 | this.headTailFactor = 0.8 | ||||
| this.type = Overlay.getOverlayType('attack_arrow') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('attack_arrow') | |||||
| } | |||||
| set positions(positions) { | set positions(positions) { | ||||
| this._positions = Parse.parsePositions(positions) | this._positions = Parse.parsePositions(positions) | ||||
| this._delegate.polygon.hierarchy = this._getHierarchy() | this._delegate.polygon.hierarchy = this._getHierarchy() |
| this.headWidthFactor = 0.3 | this.headWidthFactor = 0.3 | ||||
| this.neckHeightFactor = 0.85 | this.neckHeightFactor = 0.85 | ||||
| this.neckWidthFactor = 0.15 | this.neckWidthFactor = 0.15 | ||||
| this.type = Overlay.getOverlayType('double_arrow') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('double_arrow') | |||||
| } | |||||
| set positions(positions) { | set positions(positions) { | ||||
| this._positions = Parse.parsePositions(positions) | this._positions = Parse.parsePositions(positions) | ||||
| this._delegate.polygon.hierarchy = this._getHierarchy() | this._delegate.polygon.hierarchy = this._getHierarchy() |
| this.headWidthFactor = 0.25 | this.headWidthFactor = 0.25 | ||||
| this.headAngle = Math.PI / 8.5 | this.headAngle = Math.PI / 8.5 | ||||
| this.neckAngle = Math.PI / 13 | this.neckAngle = Math.PI / 13 | ||||
| this.type = Overlay.getOverlayType('fine_arrow') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('fine_arrow') | |||||
| } | |||||
| set positions(positions) { | set positions(positions) { | ||||
| this._positions = Parse.parsePositions(positions) | this._positions = Parse.parsePositions(positions) | ||||
| this._delegate.polygon.hierarchy = this._getHierarchy() | this._delegate.polygon.hierarchy = this._getHierarchy() |
| this._positions = Parse.parsePositions(positions) | this._positions = Parse.parsePositions(positions) | ||||
| this._delegate = new Cesium.Entity({ polygon: {} }) | this._delegate = new Cesium.Entity({ polygon: {} }) | ||||
| this.t = 0.4 | this.t = 0.4 | ||||
| this.type = Overlay.getOverlayType('gathering_place') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('gathering_place') | |||||
| } | |||||
| set positions(positions) { | set positions(positions) { | ||||
| this._positions = Parse.parsePositions(positions) | this._positions = Parse.parsePositions(positions) | ||||
| this._delegate.polygon.hierarchy = this._getHierarchy() | this._delegate.polygon.hierarchy = this._getHierarchy() |
| this.tailWidthFactor = 0.1 | this.tailWidthFactor = 0.1 | ||||
| this.headTailFactor = 0.8 | this.headTailFactor = 0.8 | ||||
| this.swallowTailFactor = 1 | this.swallowTailFactor = 1 | ||||
| this.type = Overlay.getOverlayType('tailed_attack_arrow') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('tailed_attack_arrow') | |||||
| } | |||||
| set positions(positions) { | set positions(positions) { | ||||
| this._positions = Parse.parsePositions(positions) | this._positions = Parse.parsePositions(positions) | ||||
| this._delegate.polygon.hierarchy = this._getHierarchy() | this._delegate.polygon.hierarchy = this._getHierarchy() |
| width: 0, | width: 0, | ||||
| height: 0 | height: 0 | ||||
| } | } | ||||
| this.type = Overlay.getOverlayType('billboard_primitive') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('billboard_primitive') | |||||
| } | |||||
| set position(position) { | set position(position) { | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._delegate.position = Transform.transformWGS84ToCartesian( | this._delegate.position = Transform.transformWGS84ToCartesian( |
| /** | |||||
| * @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 |
| /** | |||||
| * @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 |
| const DEF_STYLE = { | const DEF_STYLE = { | ||||
| minRadius: 10, | minRadius: 10, | ||||
| minHeight: 30, | minHeight: 30, | ||||
| color: Cesium.Color.RED | |||||
| color: Cesium.Color.RED, | |||||
| slices: 128, | |||||
| speed: 10 | |||||
| } | } | ||||
| class DiffuseWallPrimitive extends Overlay { | class DiffuseWallPrimitive extends Overlay { | ||||
| constructor(center, radius, height, slices, speed) { | |||||
| constructor(center, radius, height) { | |||||
| super() | super() | ||||
| this._center = Parse.parsePosition(center) | this._center = Parse.parsePosition(center) | ||||
| this._delegate = undefined | this._delegate = undefined | ||||
| this._height = height | this._height = height | ||||
| this._radius = radius | this._radius = radius | ||||
| this._slices = slices || 128 | |||||
| this._speed = speed || 10 | |||||
| this._currentHeight = height || 0 | this._currentHeight = height || 0 | ||||
| this._currentRadius = 10 | this._currentRadius = 10 | ||||
| this._style = { ...DEF_STYLE } | this._style = { ...DEF_STYLE } | ||||
| this.type = Overlay.getOverlayType('diffuse_wall_primitive') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('diffuse_wall_primitive') | |||||
| } | |||||
| set center(position) { | set center(position) { | ||||
| this._center = Parse.parsePosition(position) | this._center = Parse.parsePosition(position) | ||||
| return this | return this | ||||
| return this._height | 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 {*} | * @returns {*} | ||||
| let modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame( | let modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame( | ||||
| Transform.transformWGS84ToCartesian(this._center) | 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 x = Math.cos(angle) | ||||
| let y = Math.sin(angle) | let y = Math.sin(angle) | ||||
| let point = new Cesium.Cartesian3( | let point = new Cesium.Cartesian3( | ||||
| */ | */ | ||||
| update(frameState) { | update(frameState) { | ||||
| this._delegate = this._delegate && this._delegate.destroy() | 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 ( | if ( | ||||
| this._currentRadius > this._radius || | this._currentRadius > this._radius || | ||||
| this._currentHeight < this._style.minHeight | this._currentHeight < this._style.minHeight | ||||
| this._currentRadius = this._style.minRadius | this._currentRadius = this._style.minRadius | ||||
| this._currentHeight = this._height | this._currentHeight = this._height | ||||
| } | } | ||||
| if (!this._slices || this._slices < 3) { | |||||
| if (!this._style.slices || this._style.slices < 3) { | |||||
| return false | return false | ||||
| } | } | ||||
| let positions = this._getPositions() | let positions = this._getPositions() |
| geometry: {} | geometry: {} | ||||
| }) | }) | ||||
| }) | }) | ||||
| this.type = Overlay.getOverlayType('elec_ellipsoid_primitive') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('elec_ellipsoid_primitive') | |||||
| } | |||||
| set position(position) { | set position(position) { | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._delegate.geometryInstances.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame( | this._delegate.geometryInstances.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame( |
| geometry: {} | geometry: {} | ||||
| }) | }) | ||||
| }) | }) | ||||
| this.type = Overlay.getOverlayType('flow_line_primitive') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('flow_line_primitive') | |||||
| } | |||||
| set positions(positions) { | set positions(positions) { | ||||
| this._positions = Parse.parsePositions(positions) | this._positions = Parse.parsePositions(positions) | ||||
| this._delegate.geometryInstances.geometry = new Cesium.PolylineGeometry({ | this._delegate.geometryInstances.geometry = new Cesium.PolylineGeometry({ |
| position: undefined, | position: undefined, | ||||
| text: undefined | text: undefined | ||||
| } | } | ||||
| this.type = Overlay.getOverlayType('label_primitive') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('label_primitive') | |||||
| } | |||||
| set position(position) { | set position(position) { | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._delegate.position = Transform.transformWGS84ToCartesian( | this._delegate.position = Transform.transformWGS84ToCartesian( |
| /** | |||||
| * @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 |
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._modelUrl = modelUrl | this._modelUrl = modelUrl | ||||
| this._delegate = Cesium.Model.fromGltf({ url: modelUrl }) | this._delegate = Cesium.Model.fromGltf({ url: modelUrl }) | ||||
| this.type = Overlay.getOverlayType('model_primitive') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('model_primitive') | |||||
| } | |||||
| get readyPromise() { | |||||
| return this._delegate.readyPromise | |||||
| } | |||||
| set position(position) { | set position(position) { | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| let origin = Transform.transformWGS84ToCartesian(this._position) | let origin = Transform.transformWGS84ToCartesian(this._position) | ||||
| this.position = this._position | 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 | * Sets style | ||||
| * @param style | * @param style |
| constructor(position) { | constructor(position) { | ||||
| super() | super() | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this.type = Overlay.getOverlayType('point_primitive') | |||||
| this._delegate = { | this._delegate = { | ||||
| position: undefined | position: undefined | ||||
| } | } | ||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('point_primitive') | |||||
| } | |||||
| set position(position) { | set position(position) { | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._delegate.position = Transform.transformWGS84ToCartesian( | this._delegate.position = Transform.transformWGS84ToCartesian( |
| this._delegate = { | this._delegate = { | ||||
| positions: [] | positions: [] | ||||
| } | } | ||||
| this.type = Overlay.getOverlayType('polyline_primitive') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('polyline_primitive') | |||||
| } | |||||
| set positions(positions) { | set positions(positions) { | ||||
| this._positions = Parse.parsePositions(positions) | this._positions = Parse.parsePositions(positions) | ||||
| this._delegate.positions = Transform.transformWGS84ArrayToCartesianArray( | this._delegate.positions = Transform.transformWGS84ArrayToCartesianArray( |
| geometry: {} | geometry: {} | ||||
| }) | }) | ||||
| }) | }) | ||||
| this.type = Overlay.getOverlayType('scan_circle_primitive') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('scan_circle_primitive') | |||||
| } | |||||
| set position(position) { | set position(position) { | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._delegate.geometryInstances.geometry = new Cesium.EllipseGeometry({ | this._delegate.geometryInstances.geometry = new Cesium.EllipseGeometry({ |
| geometry: {} | geometry: {} | ||||
| }) | }) | ||||
| }) | }) | ||||
| this.type = Overlay.getOverlayType('trail_line_primitive') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('trail_line_primitive') | |||||
| } | |||||
| set positions(positions) { | set positions(positions) { | ||||
| this._positions = Parse.parsePositions(positions) | this._positions = Parse.parsePositions(positions) | ||||
| this._delegate.geometryInstances.geometry = new Cesium.PolylineGeometry({ | this._delegate.geometryInstances.geometry = new Cesium.PolylineGeometry({ |
| }) | }) | ||||
| }) | }) | ||||
| this._video = video | this._video = video | ||||
| this.type = Overlay.getOverlayType('video_primitive') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('video_primitive') | |||||
| } | |||||
| set positions(positions) { | set positions(positions) { | ||||
| this._positions = Parse.parsePositions(positions) | this._positions = Parse.parsePositions(positions) | ||||
| this._delegate.geometryInstances.geometry = Cesium.PolygonGeometry.fromPositions( | this._delegate.geometryInstances.geometry = Cesium.PolygonGeometry.fromPositions( |
| }), | }), | ||||
| asynchronous: true | asynchronous: true | ||||
| }) | }) | ||||
| this.type = Overlay.getOverlayType('water_primitive') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('water_primitive') | |||||
| } | |||||
| set positions(positions) { | set positions(positions) { | ||||
| this._positions = Parse.parsePositions(positions) | this._positions = Parse.parsePositions(positions) | ||||
| this._delegate.geometryInstances.geometry = Cesium.PolygonGeometry.fromPositions( | this._delegate.geometryInstances.geometry = Cesium.PolygonGeometry.fromPositions( |
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._icon = icon | this._icon = icon | ||||
| this._size = [32, 32] | this._size = [32, 32] | ||||
| this.type = Overlay.getOverlayType('billboard') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('billboard') | |||||
| } | |||||
| set position(position) { | set position(position) { | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._delegate.position = Transform.transformWGS84ToCartesian( | this._delegate.position = Transform.transformWGS84ToCartesian( |
| } | } | ||||
| } | } | ||||
| }) | }) | ||||
| this.type = Overlay.getOverlayType('box') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('box') | |||||
| } | |||||
| /** | /** | ||||
| * | * | ||||
| * @param position | * @param position |
| this._radius = +radius || 0 | this._radius = +radius || 0 | ||||
| this._rotateAmount = 0 | this._rotateAmount = 0 | ||||
| this._stRotation = 0 | this._stRotation = 0 | ||||
| this.type = Overlay.getOverlayType('circle') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('circle') | |||||
| } | |||||
| set center(center) { | set center(center) { | ||||
| this._center = Parse.parsePosition(center) | this._center = Parse.parsePosition(center) | ||||
| this._delegate.polygon.hierarchy = this._computeHierarchy() | this._delegate.polygon.hierarchy = this._computeHierarchy() | ||||
| set rotateAmount(amount) { | set rotateAmount(amount) { | ||||
| this._rotateAmount = +amount | this._rotateAmount = +amount | ||||
| this._delegate.polygon.stRotation = new Cesium.CallbackProperty(time => { | |||||
| this._delegate.polygon.stRotation = new Cesium.CallbackProperty(() => { | |||||
| this._stRotation += this._rotateAmount | this._stRotation += this._rotateAmount | ||||
| if (this._stRotation >= 360 || this._stRotation <= -360) { | if (this._stRotation >= 360 || this._stRotation <= -360) { | ||||
| this._stRotation = 0 | this._stRotation = 0 |
| super() | super() | ||||
| this._positions = Parse.parsePositions(positions) | this._positions = Parse.parsePositions(positions) | ||||
| this._delegate = new Cesium.Entity({ corridor: {} }) | this._delegate = new Cesium.Entity({ corridor: {} }) | ||||
| this.type = Overlay.getOverlayType('corridor') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('corridor') | |||||
| } | |||||
| set positions(positions) { | set positions(positions) { | ||||
| this._positions = Parse.parsePositions(positions) | this._positions = Parse.parsePositions(positions) | ||||
| this._delegate.corridor.positions = Transform.transformWGS84ArrayToCartesianArray( | this._delegate.corridor.positions = Transform.transformWGS84ArrayToCartesianArray( |
| this._topRadius = +topRadius || 0 | this._topRadius = +topRadius || 0 | ||||
| this._bottomRadius = +bottomRadius || 0 | this._bottomRadius = +bottomRadius || 0 | ||||
| this._delegate = new Cesium.Entity({ cylinder: {} }) | this._delegate = new Cesium.Entity({ cylinder: {} }) | ||||
| this.type = Overlay.getOverlayType('cylinder') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('cylinder') | |||||
| } | |||||
| set position(position) { | set position(position) { | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._delegate.position = Transform.transformWGS84ToCartesian( | this._delegate.position = Transform.transformWGS84ToCartesian( |
| this._semiMajorAxis = +semiMajorAxis || 0 | this._semiMajorAxis = +semiMajorAxis || 0 | ||||
| this._semiMinorAxis = +semiMinorAxis || 0 | this._semiMinorAxis = +semiMinorAxis || 0 | ||||
| this._delegate = new Cesium.Entity({ ellipse: {} }) | this._delegate = new Cesium.Entity({ ellipse: {} }) | ||||
| this.type = Overlay.getOverlayType('ellipse') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('ellipse') | |||||
| } | |||||
| set position(position) { | set position(position) { | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._delegate.position = Transform.transformWGS84ToCartesian( | this._delegate.position = Transform.transformWGS84ToCartesian( |
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._radius = radius || { x: 10, y: 10, z: 10 } | this._radius = radius || { x: 10, y: 10, z: 10 } | ||||
| this._delegate = new Cesium.Entity({ ellipsoid: {} }) | this._delegate = new Cesium.Entity({ ellipsoid: {} }) | ||||
| this.type = Overlay.getOverlayType('ellipsoid') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('ellipsoid') | |||||
| } | |||||
| set position(position) { | set position(position) { | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._delegate.position = Transform.transformWGS84ToCartesian( | this._delegate.position = Transform.transformWGS84ToCartesian( |
| this._delegate = new Cesium.Entity({ label: {} }) | this._delegate = new Cesium.Entity({ label: {} }) | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._text = text | this._text = text | ||||
| this.type = Overlay.getOverlayType('label') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('label') | |||||
| } | |||||
| set position(position) { | set position(position) { | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._delegate.position = Transform.transformWGS84ToCartesian( | this._delegate.position = Transform.transformWGS84ToCartesian( |
| plane: new Cesium.Plane(this._normal, this._distance) | plane: new Cesium.Plane(this._normal, this._distance) | ||||
| } | } | ||||
| }) | }) | ||||
| this.type = Overlay.getOverlayType('plane') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('plane') | |||||
| } | |||||
| set position(position) { | set position(position) { | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._delegate.position = Transform.transformWGS84ToCartesian( | this._delegate.position = Transform.transformWGS84ToCartesian( |
| super() | super() | ||||
| this._delegate = new Cesium.Entity({ point: {} }) | this._delegate = new Cesium.Entity({ point: {} }) | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this.type = Overlay.getOverlayType('point') | |||||
| this._state = State.INITIALIZED | this._state = State.INITIALIZED | ||||
| } | } | ||||
| get type() { | |||||
| return Overlay.getOverlayType('point') | |||||
| } | |||||
| set position(position) { | set position(position) { | ||||
| this._position = Parse.parsePosition(position) | this._position = Parse.parsePosition(position) | ||||
| this._delegate.position = Transform.transformWGS84ToCartesian( | this._delegate.position = Transform.transformWGS84ToCartesian( |