cesium_dev_kit 1.0.45 → 1.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +13582 -23
- package/dist/index.min.js +1 -0
- package/package.json +12 -5
- package/.babelrc +0 -13
- package/dist/ColorDeal.js +0 -59
- package/dist/common.js +0 -40
- package/dist/initConf.js +0 -210
- package/dist/libs/Analysis.js +0 -779
- package/dist/libs/Base.js +0 -950
- package/dist/libs/ChartLayer.js +0 -24
- package/dist/libs/Control.js +0 -947
- package/dist/libs/CustomCesiumPlugin.js +0 -92
- package/dist/libs/DomUtil.js +0 -105
- package/dist/libs/Draw.js +0 -704
- package/dist/libs/Graphics.js +0 -734
- package/dist/libs/MapvLayer.js +0 -26
- package/dist/libs/Material.js +0 -590
- package/dist/libs/Math2d.js +0 -559
- package/dist/libs/Math3d.js +0 -646
- package/dist/libs/PassEffect.js +0 -154
- package/dist/libs/Plugin.js +0 -751
- package/dist/libs/Primitive.js +0 -1559
- package/dist/libs/Shaders.js +0 -298
- package/dist/libs/ThreeJs.js +0 -190
- package/dist/libs/cesium-plugin.js +0 -3387
- package/dist/libs/index.js +0 -117
- package/dist/libs/plot/AttackArrow.js +0 -266
- package/dist/libs/plot/BasePlot.js +0 -41
- package/dist/libs/plot/PincerArrow.js +0 -278
- package/dist/libs/plot/StraightArrow.js +0 -244
- package/dist/libs/plot/algorithm.js +0 -315
- package/dist/libs/plot/index.js +0 -19
- package/dist/libs/plot/plotUtil.js +0 -242
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cesium_dev_kit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.47",
|
|
4
4
|
"description": "本项目是一个封装 Cesium 基本操作的工具包,提供简单的方法调用来实现复杂的 API 操作;节省阅读 Cesium 原文档时间,从而降低入门难度增加学习信心,同时也希望能提高工作效率",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
-
"
|
|
8
|
+
"build:prod": "rollup -c"
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -30,8 +30,15 @@
|
|
|
30
30
|
"cesium-navigation-es6": "^3.0.8"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@babel/
|
|
34
|
-
"@babel/
|
|
35
|
-
"@
|
|
33
|
+
"@babel/core": "^7.4.5",
|
|
34
|
+
"@babel/preset-env": "^7.4.5",
|
|
35
|
+
"@vue/component-compiler-utils": "^3.1.1",
|
|
36
|
+
"babel-plugin-external-helpers": "^6.22.0",
|
|
37
|
+
"rollup": "^1.20.0",
|
|
38
|
+
"rollup-plugin-babel": "^4.3.3",
|
|
39
|
+
"rollup-plugin-commonjs": "^10.0.0",
|
|
40
|
+
"rollup-plugin-node-resolve": "^5.2.0",
|
|
41
|
+
"rollup-plugin-terser": "^5.1.2",
|
|
42
|
+
"rollup-plugin-vue": "^5.1.9"
|
|
36
43
|
}
|
|
37
44
|
}
|
package/.babelrc
DELETED
package/dist/ColorDeal.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.colorRGB2Hex = colorRGB2Hex;
|
|
7
|
-
exports.colorRgb = colorRgb;
|
|
8
|
-
exports.colorRgb1 = colorRgb1;
|
|
9
|
-
exports.colorRgbString = colorRgbString;
|
|
10
|
-
// 输入16进制颜色值 转 rgb 的数组值 255
|
|
11
|
-
function colorRgb(inColor) {
|
|
12
|
-
// 16进制颜色值的正则
|
|
13
|
-
const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
|
|
14
|
-
// 把颜色值变成小写
|
|
15
|
-
let color = inColor.toLowerCase();
|
|
16
|
-
if (reg.test(color)) {
|
|
17
|
-
// 如果只有三位的值,需变成六位,如:#fff => #ffffff
|
|
18
|
-
if (color.length === 4) {
|
|
19
|
-
let colorNew = '#';
|
|
20
|
-
for (let i = 1; i < 4; i += 1) {
|
|
21
|
-
colorNew += color.slice(i, i + 1).concat(color.slice(i, i + 1));
|
|
22
|
-
}
|
|
23
|
-
color = colorNew;
|
|
24
|
-
}
|
|
25
|
-
// 处理六位的颜色值,转为RGB
|
|
26
|
-
const colorChange = [];
|
|
27
|
-
for (let i = 1; i < 7; i += 2) {
|
|
28
|
-
colorChange.push(parseInt('0x' + color.slice(i, i + 2)));
|
|
29
|
-
}
|
|
30
|
-
return colorChange;
|
|
31
|
-
}
|
|
32
|
-
return [];
|
|
33
|
-
}
|
|
34
|
-
// 输入16进制颜色值 转 rgb 的字符 255
|
|
35
|
-
function colorRgbString(inColor) {
|
|
36
|
-
let arr = colorRgb(inColor);
|
|
37
|
-
return 'rgb(' + arr[0] + ',' + arr[1] + ',' + arr[2] + ')';
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// 输入16进制颜色值 转 rgb 的数组值 0.0 - 1.0
|
|
41
|
-
function colorRgb1(inColor) {
|
|
42
|
-
const colorChange = colorRgb(inColor);
|
|
43
|
-
colorChange.forEach((ele, index) => {
|
|
44
|
-
colorChange[index] = (ele / 255.0).toFixed(2);
|
|
45
|
-
});
|
|
46
|
-
return colorChange;
|
|
47
|
-
}
|
|
48
|
-
// RGB转16进制(rgb2hex)
|
|
49
|
-
function colorRGB2Hex(color) {
|
|
50
|
-
const rgb = color.split(',');
|
|
51
|
-
if (rgb.length <= 1) {
|
|
52
|
-
return color;
|
|
53
|
-
}
|
|
54
|
-
const r = parseInt(rgb[0].split('(')[1]);
|
|
55
|
-
const g = parseInt(rgb[1]);
|
|
56
|
-
const b = parseInt(rgb[2].split(')')[0]);
|
|
57
|
-
const hex = '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
|
58
|
-
return hex;
|
|
59
|
-
}
|
package/dist/common.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.evil = evil;
|
|
7
|
-
exports.getUrlKey = getUrlKey;
|
|
8
|
-
exports.getUrlParma = getUrlParma;
|
|
9
|
-
exports.string_to_name = string_to_name;
|
|
10
|
-
// 函数
|
|
11
|
-
function evil(fn) {
|
|
12
|
-
const Fn = Function; // 一个变量指向Function,防止有些前端编译工具报错
|
|
13
|
-
// return new Fn('return ' + fn)()
|
|
14
|
-
return new Fn('return ' + fn)();
|
|
15
|
-
}
|
|
16
|
-
// 获得get参数
|
|
17
|
-
function getUrlKey(name, url) {
|
|
18
|
-
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(url) || [null, '', null])[1].replace(/\+/g, '%20')) || null;
|
|
19
|
-
}
|
|
20
|
-
// 获得格式化后的get参数
|
|
21
|
-
function getUrlParma(p, type = 'string') {
|
|
22
|
-
let UrlParma = getUrlKey(p, window.location.href);
|
|
23
|
-
if (type === 'int') {
|
|
24
|
-
return parseInt(UrlParma);
|
|
25
|
-
}
|
|
26
|
-
if (type === 'float') {
|
|
27
|
-
return parseFloat(UrlParma);
|
|
28
|
-
}
|
|
29
|
-
if (UrlParma && type === 'array') {
|
|
30
|
-
UrlParma = UrlParma.split(',');
|
|
31
|
-
return [parseFloat(UrlParma[0]), parseFloat(UrlParma[1]), parseFloat(UrlParma[2])];
|
|
32
|
-
}
|
|
33
|
-
return UrlParma;
|
|
34
|
-
}
|
|
35
|
-
// 将一个字符串转换为变量名
|
|
36
|
-
function string_to_name(string) {
|
|
37
|
-
let _name = 'let new_name = ' + string;
|
|
38
|
-
evil(_name);
|
|
39
|
-
return _name;
|
|
40
|
-
}
|
package/dist/initConf.js
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Controller = void 0;
|
|
7
|
-
var _ColorDeal = require("./ColorDeal");
|
|
8
|
-
var _common = require("./common");
|
|
9
|
-
var _cesiumNavigationEs = _interopRequireDefault(require("cesium-navigation-es6"));
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
let Cesium = null;
|
|
12
|
-
class Controller {
|
|
13
|
-
// 初始化 controller 类
|
|
14
|
-
constructor(cesiumGlobal) {
|
|
15
|
-
Cesium = cesiumGlobal;
|
|
16
|
-
this.init_data();
|
|
17
|
-
}
|
|
18
|
-
init_data() {
|
|
19
|
-
this.viewer = null;
|
|
20
|
-
}
|
|
21
|
-
init({
|
|
22
|
-
containerId,
|
|
23
|
-
viewerConfig,
|
|
24
|
-
extreaConfig,
|
|
25
|
-
MapImageryList
|
|
26
|
-
}) {
|
|
27
|
-
const mapID = containerId;
|
|
28
|
-
let imageryProviderConfig = new Cesium.SingleTileImageryProvider({
|
|
29
|
-
url: 'https://mapv-data.oss-cn-hangzhou.aliyuncs.com/Cesium-1.82-hawk/background.png'
|
|
30
|
-
});
|
|
31
|
-
if (MapImageryList.length !== 0) {
|
|
32
|
-
imageryProviderConfig = this.setOneimageryProvider(MapImageryList[0]);
|
|
33
|
-
}
|
|
34
|
-
let vConfig = {
|
|
35
|
-
// 加载单张影像 第一层最小最透明的
|
|
36
|
-
imageryProvider: imageryProviderConfig,
|
|
37
|
-
contextOptions: {
|
|
38
|
-
webgl: {
|
|
39
|
-
alpha: false
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
// 默认设置
|
|
43
|
-
animation: false,
|
|
44
|
-
//动画控件
|
|
45
|
-
timeline: false,
|
|
46
|
-
//时间线
|
|
47
|
-
fullscreenButton: false,
|
|
48
|
-
// 全屏按钮
|
|
49
|
-
geocoder: false,
|
|
50
|
-
//地名查找(依赖google服务)
|
|
51
|
-
homeButton: false,
|
|
52
|
-
//重置到初始焦点与缩放
|
|
53
|
-
selectionIndicator: false,
|
|
54
|
-
//
|
|
55
|
-
shadow: true,
|
|
56
|
-
sceneMode: Cesium.SceneMode.SCENE3D,
|
|
57
|
-
infoBox: false,
|
|
58
|
-
//消息框
|
|
59
|
-
sceneModePicker: false,
|
|
60
|
-
//场景模式选择
|
|
61
|
-
navigationHelpButton: false,
|
|
62
|
-
//导航帮助按钮
|
|
63
|
-
projectionPicker: false,
|
|
64
|
-
//投影方式选择(3D、2D、Columbus)
|
|
65
|
-
baseLayerPicker: false,
|
|
66
|
-
shouldAnimate: true,
|
|
67
|
-
navigation: false,
|
|
68
|
-
showRenderLoopErrors: true // 是否显示render异常信息
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
vConfig = Object.assign(vConfig, viewerConfig); // 后台接口配置 融合替换 默认配置
|
|
72
|
-
const viewer = new Cesium.Viewer(mapID, vConfig);
|
|
73
|
-
if (!extreaConfig['logo']) {
|
|
74
|
-
const cC = viewer.cesiumWidget.creditContainer;
|
|
75
|
-
cC.style.display = 'none'; // 影藏logo
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// 是否开启深度参数
|
|
79
|
-
if (extreaConfig['depthTest']) {
|
|
80
|
-
// 设置开启深度检测
|
|
81
|
-
viewer.scene.globe.depthTestAgainstTerrain = true;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// 显示 fps
|
|
85
|
-
// viewer.scene.debugShowFramesPerSecond = true
|
|
86
|
-
|
|
87
|
-
// 是否需要 初始化 cesium-navigation 控件
|
|
88
|
-
if (extreaConfig['initNavigate']) {
|
|
89
|
-
this.initCesiumNavigation(viewer);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// 增加配置图层
|
|
93
|
-
this.setConfigMapList(viewer, MapImageryList);
|
|
94
|
-
// 消除锯齿
|
|
95
|
-
this.removeJagged(viewer);
|
|
96
|
-
this.viewer = viewer;
|
|
97
|
-
return viewer;
|
|
98
|
-
}
|
|
99
|
-
initCesiumNavigation(viewer) {
|
|
100
|
-
const options = {};
|
|
101
|
-
// 用于在使用重置导航重置地图视图时设置默认视图控制。接受的值是Cesium.Cartographic 和 Cesium.Rectangle.
|
|
102
|
-
options.defaultResetView = new Cesium.Rectangle.fromDegrees(80, 22, 130, 50); // new Cesium.Rectangle.fromDegrees(113.8980, 22.4899, 113.9686, 22.5438)
|
|
103
|
-
// 用于启用或禁用罗盘。true是启用罗盘,false是禁用罗盘。默认值为true。如果将选项设置为false,则罗盘将不会添加到地图中。
|
|
104
|
-
options.enableCompass = true;
|
|
105
|
-
// 用于启用或禁用缩放控件。true是启用,false是禁用。默认值为true。如果将选项设置为false,则缩放控件将不会添加到地图中。
|
|
106
|
-
options.enableZoomControls = true;
|
|
107
|
-
// 用于启用或禁用距离图例。true是启用,false是禁用。默认值为true。如果将选项设置为false,距离图例将不会添加到地图中。
|
|
108
|
-
options.enableDistanceLegend = true;
|
|
109
|
-
// 用于启用或禁用指南针外环。true是启用,false是禁用。默认值为true。如果将选项设置为false,则该环将可见但无效。
|
|
110
|
-
options.enableCompassOuterRing = true;
|
|
111
|
-
// 注意需要new 否则Cannot set properties of undefined (setting 'terria')
|
|
112
|
-
new _cesiumNavigationEs.default(viewer, options);
|
|
113
|
-
}
|
|
114
|
-
setOneimageryProvider(MapImagery) {
|
|
115
|
-
if (MapImagery.classConfig.customTags) {
|
|
116
|
-
MapImagery.classConfig.customTags = (0, _common.evil)('(' + MapImagery.classConfig.customTags + ')');
|
|
117
|
-
}
|
|
118
|
-
return new Cesium[MapImagery.type](MapImagery.classConfig);
|
|
119
|
-
}
|
|
120
|
-
setConfigMapList(viewer, MapImageryList) {
|
|
121
|
-
const imageryLayers = viewer.imageryLayers;
|
|
122
|
-
MapImageryList.some((elem, index) => {
|
|
123
|
-
if (index === 0) {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
imageryLayers.addImageryProvider(this.setOneimageryProvider(elem));
|
|
127
|
-
});
|
|
128
|
-
// 设置具体的 ImageryLayer 参数
|
|
129
|
-
MapImageryList.some((elem, index) => {
|
|
130
|
-
const baseLayer = viewer.imageryLayers.get(index);
|
|
131
|
-
if (elem.interfaceConfig) {
|
|
132
|
-
Object.getOwnPropertyNames(elem.interfaceConfig).forEach(function (key) {
|
|
133
|
-
baseLayer[key] = elem.interfaceConfig[key];
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
// 设置 滤镜效果
|
|
137
|
-
baseLayer.invertColor = elem.invertswitch;
|
|
138
|
-
baseLayer.filterRGB = [255.0, 255.0, 255.0];
|
|
139
|
-
if (elem.filterRGB !== '#000000' && elem.filterRGB !== '#ffffff') {
|
|
140
|
-
baseLayer.filterRGB = (0, _ColorDeal.colorRgb)(elem.filterRGB);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// 设置 offset 偏移量
|
|
144
|
-
const offset = elem.offset.split(',');
|
|
145
|
-
if (offset.length === 2) {
|
|
146
|
-
try {
|
|
147
|
-
const oxy = [parseFloat(offset[0]), parseFloat(offset[1])];
|
|
148
|
-
baseLayer._imageryProvider._tilingScheme._rectangleNortheastInMeters.x += oxy[0];
|
|
149
|
-
baseLayer._imageryProvider._tilingScheme._rectangleNortheastInMeters.y += oxy[1];
|
|
150
|
-
} catch (error) {
|
|
151
|
-
console.log(error);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// 更改cesium的着色器代码 关于滤镜和反色的 [在不更改cesium源文件的情况下]
|
|
156
|
-
this.changeImageryProviderColors(viewer, baseLayer);
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
// 消除锯齿
|
|
160
|
-
removeJagged(viewer) {
|
|
161
|
-
viewer.scene.postProcessStages.fxaa.enabled = false;
|
|
162
|
-
viewer.scene.fxaa = false;
|
|
163
|
-
const supportsImageRenderingPixelated = viewer.cesiumWidget._supportsImageRenderingPixelated;
|
|
164
|
-
if (supportsImageRenderingPixelated) {
|
|
165
|
-
let vtxf_dpr = window.devicePixelRatio;
|
|
166
|
-
while (vtxf_dpr >= 2.0) {
|
|
167
|
-
vtxf_dpr /= 2.0;
|
|
168
|
-
}
|
|
169
|
-
viewer.resolutionScale = vtxf_dpr;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
// 更改 cesium 着色的方法
|
|
173
|
-
changeImageryProviderColors(viewer, baseLayer) {
|
|
174
|
-
// 更改底图的着色器 代码
|
|
175
|
-
const baseFragmentShaderSource = viewer.scene.globe._surfaceShaderSet.baseFragmentShaderSource.sources;
|
|
176
|
-
for (let i = 0; i < baseFragmentShaderSource.length; i++) {
|
|
177
|
-
const oneSource = baseFragmentShaderSource[i];
|
|
178
|
-
// 格式必须一致 不能多有空格 且保持版本一致性
|
|
179
|
-
const strS = 'color = czm_saturation(color, textureSaturation);\n#endif\n';
|
|
180
|
-
let strT = 'color = czm_saturation(color, textureSaturation);\n#endif\n';
|
|
181
|
-
if (baseLayer.invertColor) {
|
|
182
|
-
strT += `
|
|
183
|
-
color.r = 1.0 - color.r;
|
|
184
|
-
color.g = 1.0 - color.g;
|
|
185
|
-
color.b = 1.0 - color.b;
|
|
186
|
-
`;
|
|
187
|
-
strT += `
|
|
188
|
-
color.r = color.r * ${baseLayer.filterRGB[0]}.0/255.0;
|
|
189
|
-
color.g = color.g * ${baseLayer.filterRGB[1]}.0/255.0;
|
|
190
|
-
color.b = color.b * ${baseLayer.filterRGB[2]}.0/255.0;
|
|
191
|
-
`;
|
|
192
|
-
}
|
|
193
|
-
if (oneSource.indexOf(strS) !== -1) {
|
|
194
|
-
baseFragmentShaderSource[i] = baseFragmentShaderSource[i].replace(strS, strT);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
// 获取当前视图的中心经纬度
|
|
199
|
-
getCurCenterlonLat(viewer) {
|
|
200
|
-
let result = viewer.camera.pickEllipsoid(new Cesium.Cartesian2(viewer.canvas.clientWidth / 2, viewer.canvas.clientHeight / 2));
|
|
201
|
-
let curPosition = Cesium.Ellipsoid.WGS84.cartesianToCartographic(result);
|
|
202
|
-
let lon = curPosition.longitude * 180 / Math.PI;
|
|
203
|
-
let lat = curPosition.latitude * 180 / Math.PI;
|
|
204
|
-
return {
|
|
205
|
-
lon: lon,
|
|
206
|
-
lat: lat
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
exports.Controller = Controller;
|