cesium_dev_kit 1.0.48 → 1.0.50
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/.babelrc +13 -0
- package/dist/ColorDeal.js +59 -0
- package/dist/common.js +40 -0
- package/dist/index.js +23 -13561
- package/dist/initConf.js +188 -0
- package/dist/libs/Analysis.js +779 -0
- package/dist/libs/Base.js +950 -0
- package/dist/libs/ChartLayer.js +24 -0
- package/dist/libs/Control.js +947 -0
- package/dist/libs/CustomCesiumPlugin.js +92 -0
- package/dist/libs/DomUtil.js +105 -0
- package/dist/libs/Draw.js +704 -0
- package/dist/libs/Graphics.js +734 -0
- package/dist/libs/MapvLayer.js +26 -0
- package/dist/libs/Material.js +590 -0
- package/dist/libs/Math2d.js +559 -0
- package/dist/libs/Math3d.js +646 -0
- package/dist/libs/PassEffect.js +154 -0
- package/dist/libs/Plugin.js +751 -0
- package/dist/libs/Primitive.js +1559 -0
- package/dist/libs/Shaders.js +298 -0
- package/dist/libs/ThreeJs.js +190 -0
- package/dist/libs/cesium-plugin.js +3387 -0
- package/dist/libs/index.js +117 -0
- package/dist/libs/plot/AttackArrow.js +266 -0
- package/dist/libs/plot/BasePlot.js +41 -0
- package/dist/libs/plot/PincerArrow.js +278 -0
- package/dist/libs/plot/StraightArrow.js +244 -0
- package/dist/libs/plot/algorithm.js +315 -0
- package/dist/libs/plot/index.js +19 -0
- package/dist/libs/plot/plotUtil.js +242 -0
- package/index.js +1 -1
- package/package.json +5 -12
- package/dist/index.min.js +0 -1
|
@@ -0,0 +1,734 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Graphics = Graphics;
|
|
7
|
+
var _libgif = _interopRequireDefault(require("libgif"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
let Cesium = null;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 图形模块
|
|
13
|
+
* 用于向地图加载各种实体对象
|
|
14
|
+
*
|
|
15
|
+
* @param {*} viewer
|
|
16
|
+
*/
|
|
17
|
+
function Graphics(viewer, cesiumGlobal) {
|
|
18
|
+
if (viewer) {
|
|
19
|
+
Cesium = cesiumGlobal;
|
|
20
|
+
this._graphicsLayer = new Cesium.CustomDataSource('graphicsLayer');
|
|
21
|
+
viewer && viewer.dataSources.add(this._graphicsLayer);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
Graphics.prototype = {
|
|
25
|
+
//点
|
|
26
|
+
getPointGraphics: function (options) {
|
|
27
|
+
options = options || {};
|
|
28
|
+
if (options) {
|
|
29
|
+
return new Cesium.PointGraphics({
|
|
30
|
+
color: options.color || Cesium.Color.GREEN,
|
|
31
|
+
pixelSize: options.pixelSize || 5,
|
|
32
|
+
outlineColor: options.outlineColor || Cesium.Color.WHITE,
|
|
33
|
+
outlineWidth: options.outlineWidth || 1
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
//线
|
|
38
|
+
getLineGraphics: function (options) {
|
|
39
|
+
options = options || {};
|
|
40
|
+
if (options && options.positions) {
|
|
41
|
+
return new Cesium.PolylineGraphics({
|
|
42
|
+
show: true,
|
|
43
|
+
positions: options.positions,
|
|
44
|
+
material: options.material || Cesium.Color.YELLOW,
|
|
45
|
+
width: options.width || 1,
|
|
46
|
+
clampToGround: options.clampToGround || false
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
// 面
|
|
51
|
+
getPolygonGraphics: function (options) {
|
|
52
|
+
options = options || {};
|
|
53
|
+
if (options && options.positions) {
|
|
54
|
+
return new Cesium.PolygonGraphics({
|
|
55
|
+
hierarchy: {
|
|
56
|
+
positions: options.positions
|
|
57
|
+
},
|
|
58
|
+
material: options.material || Cesium.Color.RED.withAlpha(0.2),
|
|
59
|
+
clampToGround: options.clampToGround || false
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
//标签
|
|
64
|
+
getLabelGraphics: function (options) {
|
|
65
|
+
options = options || {};
|
|
66
|
+
if (options && options.l_text) {
|
|
67
|
+
return new Cesium.LabelGraphics({
|
|
68
|
+
//文字标签
|
|
69
|
+
text: options.l_text,
|
|
70
|
+
font: options.l_font || '14px sans-serif',
|
|
71
|
+
fillColor: options.l_fillColor || Cesium.Color.GOLD,
|
|
72
|
+
style: options.l_style || Cesium.LabelStyle.FILL_AND_OUTLINE,
|
|
73
|
+
outlineWidth: options.l_outlineWidth || 2,
|
|
74
|
+
showBackground: options.l_showBackground || false,
|
|
75
|
+
backgroundColor: options.l_backgroundColor || new Cesium.Color(0.165, 0.165, 0.165, 0.8),
|
|
76
|
+
verticalOrigin: options.l_verticalOrigin || Cesium.VerticalOrigin.BOTTOM,
|
|
77
|
+
pixelOffset: options.l_pixelOffset || new Cesium.Cartesian2(0, -30)
|
|
78
|
+
//heightReference:Cesium.HeightReference.RELATIVE_TO_GROUND
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
//广告牌
|
|
84
|
+
getBillboardGraphics: function (options) {
|
|
85
|
+
options = options || {};
|
|
86
|
+
if (options && options.b_img) {
|
|
87
|
+
return new Cesium.BillboardGraphics({
|
|
88
|
+
image: options.b_img,
|
|
89
|
+
width: options.b_width || 35,
|
|
90
|
+
height: options.b_height || 35,
|
|
91
|
+
clampToGround: options.b_clampToGround || true,
|
|
92
|
+
scale: options.b_scale || 1,
|
|
93
|
+
// eyeOffset :new Cesium.Cartesian2(0, -20),
|
|
94
|
+
pixelOffset: options.b_pixelOffset || new Cesium.Cartesian2(0, -20),
|
|
95
|
+
scaleByDistance: options.b_scaleByDistance || undefined
|
|
96
|
+
// heightReference:Cesium.HeightReference.RELATIVE_TO_GROUND
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
//路径
|
|
102
|
+
getPathGraphics: function (options) {
|
|
103
|
+
options = options || {};
|
|
104
|
+
if (options) {
|
|
105
|
+
return new Cesium.PathGraphics({
|
|
106
|
+
resolution: options.resolution || 1,
|
|
107
|
+
//设置航线样式,线条颜色,内发光粗细,航线宽度等
|
|
108
|
+
material: new Cesium.PolylineGlowMaterialProperty({
|
|
109
|
+
glowPower: options.glowPower || 0.1,
|
|
110
|
+
color: options.color || Cesium.Color.YELLOW
|
|
111
|
+
}),
|
|
112
|
+
width: options.width || 30
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
//模型
|
|
117
|
+
getModelGraphics: function (options) {
|
|
118
|
+
options = options || {};
|
|
119
|
+
if (options) {
|
|
120
|
+
return new Cesium.ModelGraphics({
|
|
121
|
+
uri: options.m_url,
|
|
122
|
+
scale: options.m_scale || 28,
|
|
123
|
+
minimumPixelSize: options.m_minimumPixelSize || 30,
|
|
124
|
+
color: options.m_color || Cesium.Color.WHITE
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
//椭圆
|
|
129
|
+
getEllipseGraphics: function (options) {
|
|
130
|
+
options = options || {};
|
|
131
|
+
if (options) {
|
|
132
|
+
return new Cesium.EllipseGraphics({
|
|
133
|
+
semiMajorAxis: options.e_semiMinorAxis || 1000000.0,
|
|
134
|
+
semiMinorAxis: options.e_semiMinorAxis || 1000000.0,
|
|
135
|
+
metarial: options.e_metarial || Cesium.Color.RED.withAlpha(0.5),
|
|
136
|
+
outline: options.e_outline || true
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
//球
|
|
141
|
+
getEllipsoidGraphics: function (options) {
|
|
142
|
+
options = options || {};
|
|
143
|
+
if (options) {
|
|
144
|
+
var r = options.radii || 1000000.0; //默认100公里
|
|
145
|
+
return new Cesium.EllipsoidGraphics({
|
|
146
|
+
radii: new Cesium.Cartesian3(r, r, r),
|
|
147
|
+
//单位 米
|
|
148
|
+
// innerRadii : options.innerRadii || new Cesium.Cartesian3(r /1.5, r /1.5, r /1.5),
|
|
149
|
+
maximumCone: options.maximumCone || Cesium.Math.PI_OVER_TWO,
|
|
150
|
+
stackPartitions: options.stackPartitions || 56,
|
|
151
|
+
slicePartitions: options.slicePartitions || 56,
|
|
152
|
+
outlineWidth: options.outlineWidth || 2.0,
|
|
153
|
+
outlineColor: options.outlineColor || Cesium.Color.YELLOW,
|
|
154
|
+
outline: options.outline || true,
|
|
155
|
+
fill: options.fill || true,
|
|
156
|
+
material: options.material || Cesium.Color.RED.withAlpha(0.1)
|
|
157
|
+
//heightReference:Cesium.HeightReference.NONE,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
// box
|
|
163
|
+
getBoxGraphics: function (options) {
|
|
164
|
+
options = options || {
|
|
165
|
+
show: true,
|
|
166
|
+
outline: false,
|
|
167
|
+
fill: true
|
|
168
|
+
};
|
|
169
|
+
if (options) {
|
|
170
|
+
return new Cesium.BoxGraphics({
|
|
171
|
+
show: options.show,
|
|
172
|
+
fill: options.fill,
|
|
173
|
+
dimensions: options.dimensions || new Cesium.Cartesian3(0, 0, 0),
|
|
174
|
+
material: options.material,
|
|
175
|
+
outline: options.outline,
|
|
176
|
+
outlineColor: options.outlineColor || Cesium.Color.BLACK,
|
|
177
|
+
distanceDisplayCondition: options.distanceDisplayCondition || undefined
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
// 面
|
|
182
|
+
getPlaneGraphics: function (options) {
|
|
183
|
+
options = options || {};
|
|
184
|
+
if (options) {
|
|
185
|
+
return new Cesium.PlaneGraphics({
|
|
186
|
+
plane: options.plane || new Cesium.Plane(Cesium.Cartesian3.UNIT_Y, 0.0),
|
|
187
|
+
dimensions: options.dimensions || new Cesium.Cartesian2(170.0, 130.0),
|
|
188
|
+
material: options.material || Cesium.Color.BLUE
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
// 锥体
|
|
193
|
+
getCylinderGraphics: function (options) {
|
|
194
|
+
options = options || {};
|
|
195
|
+
if (options) {
|
|
196
|
+
return new Cesium.CylinderGraphics({
|
|
197
|
+
HeightReference: Cesium.HeightReference.RELATIVE_TO_GROUND,
|
|
198
|
+
length: options.length || 500 / 2,
|
|
199
|
+
topRadius: options.topRadius || 0,
|
|
200
|
+
bottomRadius: options.bottomRadius || 0,
|
|
201
|
+
material: options.material || new Cesium.Color(0, 1, 1, .4),
|
|
202
|
+
slices: options.slices || 128
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
//创建点信息
|
|
207
|
+
createPointsGraphics: function (options) {
|
|
208
|
+
if (options && options.positions) {
|
|
209
|
+
let positions = [];
|
|
210
|
+
for (let i in options.positions) {
|
|
211
|
+
let position = options.positions[i];
|
|
212
|
+
let entity = this.createGraphics();
|
|
213
|
+
entity.name = options.name || '';
|
|
214
|
+
entity.oid = options.oid || 'point';
|
|
215
|
+
entity.position = position;
|
|
216
|
+
if (options.point) entity.point = this.getPointGraphics();
|
|
217
|
+
if (options.billboard) entity.billboard = this.getBillboardGraphics(options.billboard);
|
|
218
|
+
if (options.label) entity.label = this.getLabelGraphics(options.label);
|
|
219
|
+
positions.push(this._graphicsLayer.entities.add(entity));
|
|
220
|
+
}
|
|
221
|
+
return positions;
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
//创建线
|
|
225
|
+
createLineGraphics: function (options) {
|
|
226
|
+
if (options && options.positions) {
|
|
227
|
+
var entity = this.createGraphics();
|
|
228
|
+
entity.name = options.name || '';
|
|
229
|
+
entity.oid = options.oid || 'line';
|
|
230
|
+
entity.position = options.positions;
|
|
231
|
+
entity.polyline = this.getLineGraphics(options);
|
|
232
|
+
return this._graphicsLayer.entities.add(entity);
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
//创建面
|
|
236
|
+
createPolygonGraphics: function (options) {
|
|
237
|
+
options = options || {};
|
|
238
|
+
if (options) {
|
|
239
|
+
var entity = this.createGraphics();
|
|
240
|
+
entity.polygon = this.getPolygonGraphics(options);
|
|
241
|
+
entity.clampToS3M = options.clampToS3M || false;
|
|
242
|
+
return this._graphicsLayer.entities.add(entity);
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
// 创建box
|
|
246
|
+
createBoxGraphics: function (options) {
|
|
247
|
+
options = options || {};
|
|
248
|
+
if (options) {
|
|
249
|
+
var entity = this.createGraphics();
|
|
250
|
+
entity.position = options.position;
|
|
251
|
+
entity.name = options.name || 'box_graphic';
|
|
252
|
+
entity.box = this.getBoxGraphics(options.box);
|
|
253
|
+
return this._graphicsLayer.entities.add(entity);
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
//创建模型
|
|
257
|
+
createModelGraphics: function (options) {
|
|
258
|
+
if (options && options.position) {
|
|
259
|
+
var entity = this.createGraphics();
|
|
260
|
+
entity.model = this.getModelGraphics(options);
|
|
261
|
+
entity.position = options.position;
|
|
262
|
+
return this._graphicsLayer.entities.add(entity);
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
// 创建地面指示
|
|
266
|
+
craeteCorridorGraphics: function (options) {
|
|
267
|
+
if (options && options.positions) {
|
|
268
|
+
var entity = this.createGraphics();
|
|
269
|
+
entity.corridor = {
|
|
270
|
+
positions: options.positions,
|
|
271
|
+
height: options.height || 6.0,
|
|
272
|
+
width: options.width || 15.0,
|
|
273
|
+
material: options.material || new Cesium.Scene.WarnLinkMaterialProperty({
|
|
274
|
+
freely: 'cross',
|
|
275
|
+
color: Cesium.Color.YELLOW,
|
|
276
|
+
duration: 1000,
|
|
277
|
+
count: 1.0,
|
|
278
|
+
direction: '+'
|
|
279
|
+
})
|
|
280
|
+
};
|
|
281
|
+
return this._graphicsLayer.entities.add(entity);
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
//构建动态线
|
|
285
|
+
craeteDynamicPolyLineGraphics: function (options) {
|
|
286
|
+
if (options && options.positions) {
|
|
287
|
+
var entity = this.createGraphics();
|
|
288
|
+
entity.polyline = {
|
|
289
|
+
show: true,
|
|
290
|
+
positions: [],
|
|
291
|
+
material: options.material || Cesium.Color.CHARTREUSE,
|
|
292
|
+
width: options.width || 5,
|
|
293
|
+
clampToGround: options.clampToGround || false
|
|
294
|
+
};
|
|
295
|
+
entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
|
296
|
+
return options.positions;
|
|
297
|
+
}, false);
|
|
298
|
+
return this._graphicsLayer.entities.add(entity);
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
//动态椎体
|
|
302
|
+
craeteDynamicCylinderGraphics: function (options) {
|
|
303
|
+
var param = {};
|
|
304
|
+
if (options && options.cylinder) {
|
|
305
|
+
var entity = options.entity,
|
|
306
|
+
cylinder = options.cylinder,
|
|
307
|
+
$this = this;
|
|
308
|
+
param.cylinder = this.getCylinderGraphics(cylinder);
|
|
309
|
+
param.position = new Cesium.CallbackProperty(function () {
|
|
310
|
+
var positions = entity.position.getValue($this._viewer.clock.currentTime);
|
|
311
|
+
var cartographic = $this._viewer.scene.globe.ellipsoid.cartesianToCartographic(positions);
|
|
312
|
+
var lat = Cesium.Math.toDegrees(cartographic.latitude),
|
|
313
|
+
lng = Cesium.Math.toDegrees(cartographic.longitude);
|
|
314
|
+
// hei = parseFloat(cartographic.height / 4)
|
|
315
|
+
return Cesium.Cartesian3.fromDegrees(lng, lat, 0);
|
|
316
|
+
}, false);
|
|
317
|
+
param.cylinder.length = new Cesium.CallbackProperty(function () {
|
|
318
|
+
var positions = entity.position.getValue($this._viewer.clock.currentTime);
|
|
319
|
+
var cartographic = $this._viewer.scene.globe.ellipsoid.cartesianToCartographic(positions);
|
|
320
|
+
return cartographic.height * 2;
|
|
321
|
+
}, false);
|
|
322
|
+
return param;
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
// 创建渐变锥体
|
|
326
|
+
createFadeCylinderGraphics: function (options) {
|
|
327
|
+
options = options || {};
|
|
328
|
+
if (options && options.position) {
|
|
329
|
+
let entity = this.createGraphics();
|
|
330
|
+
entity.position = options.position;
|
|
331
|
+
options.material = new Cesium.Scene.CircleFadeMaterialProperty({
|
|
332
|
+
color: options.color || Cesium.Color.fromCssColorString('#02ff00'),
|
|
333
|
+
duration: options.duration || 2000
|
|
334
|
+
});
|
|
335
|
+
entity.cylinder = this.getCylinderGraphics(options);
|
|
336
|
+
return this._drawLayer.entities.add(entity);
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
// 创建旋转圆柱
|
|
340
|
+
craeteRotateCylinderGraphics: function (options) {
|
|
341
|
+
if (options && options.position) {
|
|
342
|
+
var cylinderEntity = this.createGraphics();
|
|
343
|
+
cylinderEntity.cylinder = {
|
|
344
|
+
HeightReference: Cesium.HeightReference.RELATIVE_TO_GROUND,
|
|
345
|
+
length: options.length || 500,
|
|
346
|
+
topRadius: options.topRadius || 500,
|
|
347
|
+
bottomRadius: options.bottomRadius || 500,
|
|
348
|
+
material: options.material || new Cesium.ImageMaterialProperty({
|
|
349
|
+
image: options.imge || 'static/data/images/file/cc2.png',
|
|
350
|
+
transparent: true,
|
|
351
|
+
repeat: {
|
|
352
|
+
x: 1,
|
|
353
|
+
y: -1
|
|
354
|
+
}
|
|
355
|
+
}),
|
|
356
|
+
slices: options.slices || 128
|
|
357
|
+
};
|
|
358
|
+
cylinderEntity.position = options.position;
|
|
359
|
+
this.setGraphicsRotate({
|
|
360
|
+
entity: cylinderEntity,
|
|
361
|
+
position: this.transformCartesianToWGS84(options.position),
|
|
362
|
+
rotateAmount: 4
|
|
363
|
+
});
|
|
364
|
+
return this._graphicsLayer.entities.add(cylinderEntity);
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
//闪烁圆
|
|
368
|
+
craeteDynamicBlinkCircleGraphics: function (options) {
|
|
369
|
+
if (options && options.position) {
|
|
370
|
+
var entity = this.createGraphics(),
|
|
371
|
+
alp = options.alp || 1,
|
|
372
|
+
flog = options.flog || true;
|
|
373
|
+
entity.position = options.position;
|
|
374
|
+
entity.ellipse = {
|
|
375
|
+
semiMinorAxis: options.semiMinorAxis || 2000.0,
|
|
376
|
+
semiMajorAxis: options.semiMajorAxis || 2000.0,
|
|
377
|
+
height: options.height || 10,
|
|
378
|
+
material: new Cesium.ColorMaterialProperty(new Cesium.CallbackProperty(function () {
|
|
379
|
+
if (flog) {
|
|
380
|
+
alp = alp - 0.05;
|
|
381
|
+
if (alp <= 0) {
|
|
382
|
+
flog = false; // hide
|
|
383
|
+
}
|
|
384
|
+
} else {
|
|
385
|
+
alp = alp + 0.05;
|
|
386
|
+
if (alp >= 1) {
|
|
387
|
+
flog = true; // show
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return Cesium.Color.RED.withAlpha(alp);
|
|
392
|
+
}, false))
|
|
393
|
+
};
|
|
394
|
+
return this._graphicsLayer.entities.add(entity);
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
//动态旋转圆
|
|
398
|
+
craeteDynamicCricleGraphics: function (options) {
|
|
399
|
+
if (options && options.center) {
|
|
400
|
+
var entity = this.createGraphics(),
|
|
401
|
+
$this = this,
|
|
402
|
+
_center = options.center,
|
|
403
|
+
_radius = options.radius || 800,
|
|
404
|
+
_rotateAmount = options.rotateAmount || 0.05,
|
|
405
|
+
_stRotation = 0,
|
|
406
|
+
_height = options.height || 1,
|
|
407
|
+
heading = 0,
|
|
408
|
+
pitch = 0,
|
|
409
|
+
roll = 0,
|
|
410
|
+
_scale = options.scale || null,
|
|
411
|
+
_scale2 = options.scale2 || null,
|
|
412
|
+
_material = options.material || new Cesium.ImageMaterialProperty({
|
|
413
|
+
image: options.imge || 'static/data/images/Textures/circle_bg.png',
|
|
414
|
+
transparent: true
|
|
415
|
+
});
|
|
416
|
+
entity.position = new Cesium.CallbackProperty(function () {
|
|
417
|
+
return $this.transformWGS84ToCartesian(_center);
|
|
418
|
+
}, false);
|
|
419
|
+
entity.orientation = new Cesium.CallbackProperty(function () {
|
|
420
|
+
return Cesium.Transforms.headingPitchRollQuaternion($this.transformWGS84ToCartesian(_center), new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(heading), Cesium.Math.toRadians(pitch), Cesium.Math.toRadians(roll)));
|
|
421
|
+
}, false);
|
|
422
|
+
let bg_scale = _radius,
|
|
423
|
+
flag = false;
|
|
424
|
+
var updateScalerAxis = () => {
|
|
425
|
+
if (_radius >= _scale || _radius <= bg_scale) {
|
|
426
|
+
flag = !flag;
|
|
427
|
+
}
|
|
428
|
+
flag ? _radius += 2 : _radius -= 2;
|
|
429
|
+
};
|
|
430
|
+
var updateScalerAxis2 = () => {
|
|
431
|
+
_scale2 >= _radius ? _radius += 2 : _radius = bg_scale;
|
|
432
|
+
};
|
|
433
|
+
entity.ellipse = {
|
|
434
|
+
material: _material,
|
|
435
|
+
height: _height,
|
|
436
|
+
semiMajorAxis: new Cesium.CallbackProperty(function () {
|
|
437
|
+
return _radius;
|
|
438
|
+
}, false),
|
|
439
|
+
semiMinorAxis: new Cesium.CallbackProperty(function () {
|
|
440
|
+
return _radius;
|
|
441
|
+
}, false),
|
|
442
|
+
stRotation: new Cesium.CallbackProperty(function () {
|
|
443
|
+
if (_rotateAmount > 0) {
|
|
444
|
+
_stRotation += _rotateAmount;
|
|
445
|
+
if (_stRotation >= 360) {
|
|
446
|
+
_stRotation = 0;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
if (_scale) updateScalerAxis();
|
|
450
|
+
if (_scale2) updateScalerAxis2();
|
|
451
|
+
return _stRotation;
|
|
452
|
+
}, false)
|
|
453
|
+
};
|
|
454
|
+
return this._graphicsLayer.entities.add(entity);
|
|
455
|
+
}
|
|
456
|
+
},
|
|
457
|
+
//动态渐变墙
|
|
458
|
+
craeteDynamicShadeWallGraphics: function (options) {
|
|
459
|
+
if (options && options.positions) {
|
|
460
|
+
var alp = options.alp || 1,
|
|
461
|
+
num = options.num || 20,
|
|
462
|
+
color = options.color || Cesium.Color.RED,
|
|
463
|
+
speed = options.speed || 0.003;
|
|
464
|
+
var wallEntity = this.createGraphics();
|
|
465
|
+
wallEntity.wall = {
|
|
466
|
+
positions: options.positions,
|
|
467
|
+
material: new Cesium.ImageMaterialProperty({
|
|
468
|
+
image: 'static/data/images/Textures/fence.png',
|
|
469
|
+
transparent: true,
|
|
470
|
+
color: new Cesium.CallbackProperty(function () {
|
|
471
|
+
if (num % 2 === 0) {
|
|
472
|
+
alp -= speed;
|
|
473
|
+
} else {
|
|
474
|
+
alp += speed;
|
|
475
|
+
}
|
|
476
|
+
if (alp <= 0.1) {
|
|
477
|
+
num++;
|
|
478
|
+
} else if (alp >= 1) {
|
|
479
|
+
num++;
|
|
480
|
+
}
|
|
481
|
+
return color.withAlpha(alp);
|
|
482
|
+
}, false)
|
|
483
|
+
})
|
|
484
|
+
};
|
|
485
|
+
return this._graphicsLayer.entities.add(wallEntity);
|
|
486
|
+
}
|
|
487
|
+
},
|
|
488
|
+
// 默认自定义标牌气泡框
|
|
489
|
+
createCustomDefBillboardGraphics: function (options) {
|
|
490
|
+
if (options && options.position) {
|
|
491
|
+
var $this = this,
|
|
492
|
+
img = document.createElement('img');
|
|
493
|
+
img.src = options.img || 'static/data/images/file/div1.png';
|
|
494
|
+
|
|
495
|
+
// 绘制canvas
|
|
496
|
+
const drawCompanyTip = function (options) {
|
|
497
|
+
if (!options.image) return;
|
|
498
|
+
var canvas = document.createElement('canvas');
|
|
499
|
+
canvas.width = options.width || 150;
|
|
500
|
+
canvas.height = options.height || 80;
|
|
501
|
+
var context = canvas.getContext('2d');
|
|
502
|
+
context.drawImage(options.image, 0, 0);
|
|
503
|
+
var dom = options.text;
|
|
504
|
+
context.font = '15px bold 宋体';
|
|
505
|
+
context.fillStyle = '#f4fff0';
|
|
506
|
+
context.fillText(dom, 55, 36);
|
|
507
|
+
return canvas;
|
|
508
|
+
};
|
|
509
|
+
img.onload = function () {
|
|
510
|
+
options.image = img;
|
|
511
|
+
var entity = $this._graphicsLayer.entities.add({
|
|
512
|
+
position: options.position,
|
|
513
|
+
billboard: {
|
|
514
|
+
image: drawCompanyTip(options),
|
|
515
|
+
scaleByDistance: new Cesium.NearFarScalar(1.5e2, 0.7, 1.5e7, 0.5),
|
|
516
|
+
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
|
517
|
+
pixelOffset: options.b_pixelOffset || new Cesium.Cartesian2(80, -35),
|
|
518
|
+
width: 140,
|
|
519
|
+
height: 100,
|
|
520
|
+
scale: options.b_scale || 1.5,
|
|
521
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
522
|
+
imageSubRegion: {
|
|
523
|
+
x: 0,
|
|
524
|
+
y: 0,
|
|
525
|
+
width: 200,
|
|
526
|
+
height: 150
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
if (typeof options.callback === 'function') {
|
|
531
|
+
options.callback(entity);
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
},
|
|
536
|
+
// 旋转面
|
|
537
|
+
craeteRotatePlaneGraphics: function (options) {
|
|
538
|
+
if (options && options.center && options.positions) {
|
|
539
|
+
var entity = this.createGraphics(),
|
|
540
|
+
index = 0,
|
|
541
|
+
positions = options.positions,
|
|
542
|
+
_position = positions[0];
|
|
543
|
+
entity.position = new Cesium.CallbackProperty(function () {
|
|
544
|
+
if (index == 0) {
|
|
545
|
+
_position = positions[0], index += 1;
|
|
546
|
+
} else if (index < positions.length - 1) {
|
|
547
|
+
_position = positions[index], index += 1;
|
|
548
|
+
} else if (index == positions.length - 1) {
|
|
549
|
+
_position = positions[index], index = 0;
|
|
550
|
+
}
|
|
551
|
+
return _position;
|
|
552
|
+
}, false);
|
|
553
|
+
entity.plane = {
|
|
554
|
+
// plane: new Cesium.CallbackProperty(function () {
|
|
555
|
+
// var normaB = Cesium.Cartesian3.normalize(Cesium.Cartesian3.subtract(_center, _position, new Cesium.Cartesian3()), new Cesium.Cartesian3())
|
|
556
|
+
// _plane = new Cesium.Plane(Cesium.Cartesian3.normalize(Cesium.Cartesian3.add(normaB, _center, new Cesium.Cartesian3()), new Cesium.Cartesian3()), 0.0)
|
|
557
|
+
|
|
558
|
+
// _plane = Cesium.Plane.fromPointNormal(coefficients, result)
|
|
559
|
+
// return _plane;
|
|
560
|
+
// }, false),
|
|
561
|
+
plane: new Cesium.Plane(Cesium.Cartesian3.UNIT_Y, 0.0),
|
|
562
|
+
dimensions: options.dimensions || new Cesium.Cartesian2(200.0, 150.0),
|
|
563
|
+
material: new Cesium.ImageMaterialProperty({
|
|
564
|
+
image: options.image
|
|
565
|
+
})
|
|
566
|
+
};
|
|
567
|
+
return this._graphicsLayer.entities.add(entity);
|
|
568
|
+
}
|
|
569
|
+
},
|
|
570
|
+
// 视频投放
|
|
571
|
+
createVideoPlaneGraphics: function (options) {
|
|
572
|
+
if (options && options.position) {
|
|
573
|
+
var entity = this.createGraphics();
|
|
574
|
+
entity.position = options.position;
|
|
575
|
+
entity.plane = {
|
|
576
|
+
plane: new Cesium.Plane(options.normal || Cesium.Cartesian3.UNIT_Y, 0.0),
|
|
577
|
+
dimensions: options.dimensions || new Cesium.Cartesian2(200.0, 150.0),
|
|
578
|
+
material: new Cesium.ImageMaterialProperty({
|
|
579
|
+
image: options.videoElement
|
|
580
|
+
})
|
|
581
|
+
};
|
|
582
|
+
return this._graphicsLayer.entities.add(entity);
|
|
583
|
+
}
|
|
584
|
+
},
|
|
585
|
+
//gif 图片投影
|
|
586
|
+
createGifBillboardGraphics: function (options) {
|
|
587
|
+
if (_libgif.default && options && options.position) {
|
|
588
|
+
var gif = [],
|
|
589
|
+
url = options.url,
|
|
590
|
+
i = 0,
|
|
591
|
+
speed = 6;
|
|
592
|
+
|
|
593
|
+
// 遍历gif的每一帧
|
|
594
|
+
const parseGifImages = function (url, imageArr) {
|
|
595
|
+
var img = document.createElement('img');
|
|
596
|
+
img.src = url;
|
|
597
|
+
img.setAttribute('rel:animated_src', url); // gif库需要img标签配置下面两个属性
|
|
598
|
+
img.setAttribute('rel:auto_play', '0');
|
|
599
|
+
document.body.appendChild(img);
|
|
600
|
+
// 新建gif实例
|
|
601
|
+
var rub = new _libgif.default({
|
|
602
|
+
gif: img
|
|
603
|
+
});
|
|
604
|
+
return new Promise(resolve => {
|
|
605
|
+
rub.load(() => {
|
|
606
|
+
for (let i = 1; i <= rub.get_length(); i++) {
|
|
607
|
+
rub.move_to(i); // 遍历gif实例的每一帧
|
|
608
|
+
imageArr.push(rub.get_canvas().toDataURL());
|
|
609
|
+
}
|
|
610
|
+
resolve(imageArr);
|
|
611
|
+
// document.body.removeChild(img)
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
parseGifImages(url, gif);
|
|
617
|
+
return this._graphicsLayer.entities.add({
|
|
618
|
+
position: options.position,
|
|
619
|
+
billboard: {
|
|
620
|
+
verticalOrigin: Cesium.VerticalOrigin.BASELINE,
|
|
621
|
+
image: new Cesium.CallbackProperty(function () {
|
|
622
|
+
if (gif.length) {
|
|
623
|
+
// 解析每一帧
|
|
624
|
+
if (i < speed * (gif.length - 1)) {
|
|
625
|
+
i++;
|
|
626
|
+
} else {
|
|
627
|
+
i = 0;
|
|
628
|
+
}
|
|
629
|
+
return gif[Math.floor(i / speed)];
|
|
630
|
+
} else {
|
|
631
|
+
return url; //因为loadGif是异步的,在解析完成之前先使用原图
|
|
632
|
+
}
|
|
633
|
+
}, false),
|
|
634
|
+
scale: 0.2
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
},
|
|
639
|
+
//图形旋转
|
|
640
|
+
setGraphicsRotate: function (options) {
|
|
641
|
+
if (options && options.entity && options.rotateAmount) {
|
|
642
|
+
var entity = options.entity,
|
|
643
|
+
rotateAmount = options.rotateAmount,
|
|
644
|
+
_position = options.position,
|
|
645
|
+
$this = this;
|
|
646
|
+
_position.heading = 0, _position.pitch = 0, _position.roll = 0;
|
|
647
|
+
entity.position = new Cesium.CallbackProperty(function () {
|
|
648
|
+
return $this.transformWGS84ToCartesian(_position);
|
|
649
|
+
}, false);
|
|
650
|
+
entity.orientation = new Cesium.CallbackProperty(function () {
|
|
651
|
+
if (rotateAmount > 0) {
|
|
652
|
+
_position.heading += rotateAmount;
|
|
653
|
+
if (_position.heading === 360) {
|
|
654
|
+
_position.heading = 0;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
return Cesium.Transforms.headingPitchRollQuaternion($this.transformWGS84ToCartesian(_position), new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(_position.heading), Cesium.Math.toRadians(_position.pitch), Cesium.Math.toRadians(_position.roll)));
|
|
658
|
+
}, false);
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
// 图形浮动
|
|
662
|
+
setGraphicsFloat: function (options) {
|
|
663
|
+
if (options && options.entity && options.maxHeiht) {
|
|
664
|
+
try {
|
|
665
|
+
var entity = options.entity,
|
|
666
|
+
minHeiht = options.minHeiht || 5,
|
|
667
|
+
maxHeiht = options.maxHeiht || 100,
|
|
668
|
+
cartesians = options.cartesians,
|
|
669
|
+
speed = options.speed || 0.06,
|
|
670
|
+
$this = this,
|
|
671
|
+
bg_minHeiht = minHeiht,
|
|
672
|
+
flag = false;
|
|
673
|
+
if (cartesians.length) {
|
|
674
|
+
entity.positions = new Cesium.CallbackProperty(function () {
|
|
675
|
+
var positions = $this.transformCartesianArrayToWGS84Array(cartesians);
|
|
676
|
+
for (var i in positions) {
|
|
677
|
+
var position = positions[i];
|
|
678
|
+
if (minHeiht >= maxHeiht || minHeiht <= bg_minHeiht) {
|
|
679
|
+
flag = !flag;
|
|
680
|
+
}
|
|
681
|
+
flag ? minHeiht += speed : minHeiht -= speed;
|
|
682
|
+
position.alt = minHeiht;
|
|
683
|
+
}
|
|
684
|
+
return $this.transformWGS84ArrayToCartesianArray(positions);
|
|
685
|
+
}, false);
|
|
686
|
+
} else {
|
|
687
|
+
entity.position = new Cesium.CallbackProperty(function () {
|
|
688
|
+
var position = $this.transformCartesianToWGS84(cartesians);
|
|
689
|
+
if (minHeiht >= maxHeiht || minHeiht <= bg_minHeiht) {
|
|
690
|
+
flag = !flag;
|
|
691
|
+
}
|
|
692
|
+
flag ? minHeiht += speed : minHeiht -= speed;
|
|
693
|
+
position.alt = minHeiht;
|
|
694
|
+
return $this.transformWGS84ToCartesian(position);
|
|
695
|
+
}, false);
|
|
696
|
+
}
|
|
697
|
+
} catch (error) {
|
|
698
|
+
console.log(error);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
},
|
|
702
|
+
//canvas 贴图
|
|
703
|
+
createCanvasGraphics: function (options) {
|
|
704
|
+
if (options && options.positions) {
|
|
705
|
+
const drawCanvasImage = function () {
|
|
706
|
+
var i = 0;
|
|
707
|
+
var canvas = document.createElement('canvas');
|
|
708
|
+
var ctx = canvas.getContext('2d');
|
|
709
|
+
var img = new Image();
|
|
710
|
+
img.src = options.img || '../../images/ysCesium/logo.png';
|
|
711
|
+
ctx.clearRect(0, 0, options.cwidth, options.cheight);
|
|
712
|
+
if (i <= options.cwidth) {
|
|
713
|
+
ctx.drawImage(img, i, 0);
|
|
714
|
+
} else {
|
|
715
|
+
i = 0;
|
|
716
|
+
i += 3;
|
|
717
|
+
return canvas;
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
this._graphicsLayer.entities.add({
|
|
721
|
+
rectangle: {
|
|
722
|
+
coordinates: options.positions,
|
|
723
|
+
material: new Cesium.ImageMaterialProperty({
|
|
724
|
+
image: new Cesium.CallbackProperty(drawCanvasImage, false),
|
|
725
|
+
transparent: true
|
|
726
|
+
})
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
if (typeof options.callback === 'function') {
|
|
730
|
+
options.callback();
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
};
|