deeptwins-engine-3d 0.1.46 → 0.1.48

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.
Files changed (39) hide show
  1. package/dist/esm/analyze/ViewshedAnalysis.js +3 -2
  2. package/dist/esm/constant.d.ts +26 -0
  3. package/dist/esm/constant.js +53 -0
  4. package/dist/esm/graphicLayer/BaseLayer.js +3 -0
  5. package/dist/esm/graphicLayer/BaseSource.d.ts +1 -1
  6. package/dist/esm/graphicLayer/PolygonPrimitive.js +6 -4
  7. package/dist/esm/graphicLayer/PolygonPrimitiveImageMaterialInstance.d.ts +5 -0
  8. package/dist/esm/graphicLayer/PolygonPrimitiveImageMaterialInstance.js +75 -0
  9. package/dist/esm/graphicLayer/PolygonPrimitiveInstance.d.ts +1 -1
  10. package/dist/esm/graphicLayer/PolygonPrimitiveInstance.js +8 -23
  11. package/dist/esm/index.d.ts +1 -1
  12. package/dist/esm/index.js +4 -4
  13. package/dist/esm/lowAltitude/BaseGridMvtLayer.js +1 -1
  14. package/dist/esm/lowAltitude/FlightPlanning.d.ts +1 -1
  15. package/dist/esm/lowAltitude/FlightPlanning.js +6 -6
  16. package/dist/esm/lowAltitude/FlightRiskEvaluation.d.ts +10 -1
  17. package/dist/esm/lowAltitude/FlightRiskEvaluation.js +81 -90
  18. package/dist/esm/lowAltitude/GridDraw.js +1 -1
  19. package/dist/esm/lowAltitude/PoiLayer.js +1 -1
  20. package/dist/esm/map/Event.js +27 -1
  21. package/dist/esm/material/primitive/BaseMaterialAppearance.d.ts +1 -0
  22. package/dist/esm/material/primitive/BaseMaterialAppearance.js +1 -0
  23. package/dist/esm/material/primitive/ImageMaterialAppearance.d.ts +10 -0
  24. package/dist/esm/material/primitive/ImageMaterialAppearance.js +77 -0
  25. package/dist/esm/material/shader/ImageShader.glsl +22 -0
  26. package/dist/esm/tool/utils.d.ts +10 -1
  27. package/dist/esm/tool/utils.js +90 -44
  28. package/dist/esm/videoFusion/VideoProject.d.ts +1 -1
  29. package/dist/esm/videoFusion/VideoProject.js +4 -4
  30. package/dist/esm/videoFusion/VideoTexture.d.ts +1 -1
  31. package/dist/esm/videoFusion/VideoTexture.js +2 -2
  32. package/dist/esm/visualization/Frustum.d.ts +27 -2
  33. package/dist/esm/visualization/Frustum.js +158 -42
  34. package/dist/umd/deeptwins-engine-3d.min.js +1 -1
  35. package/package.json +7 -4
  36. package/dist/esm/visualization/BaseFrustum.d.ts +0 -14
  37. package/dist/esm/visualization/BaseFrustum.js +0 -96
  38. package/dist/esm/visualization/FrustumWithCamera.d.ts +0 -5
  39. package/dist/esm/visualization/FrustumWithCamera.js +0 -133
@@ -26,27 +26,11 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
26
26
  import { flatten, getCoords } from '@turf/turf';
27
27
  import * as Cesium from 'deeptwins-cesium';
28
28
  import { merge } from 'lodash';
29
- import { DEFAULT_GRID_VT_OPTIONS, LAYER_EVENT_TYPE } from "../constant";
29
+ import { DEFAULT_FLIGHT_RISK_EVALUATION_OPTIONS, LAYER_EVENT_TYPE } from "../constant";
30
30
  import BaseSource from "../graphicLayer/BaseSource";
31
31
  import { ShapeSection, translateSource } from "../tool/common";
32
32
  import fetch from "../tool/fetch";
33
33
  import * as utils from "../tool/utils";
34
- var API_HOST = 'https://els-yunjing.amap.com';
35
- var API_KEY = 'd1dc38f19b7bfc453e870a80be359cd5';
36
- // 接口定义 - 明确各接口职责
37
- var POINT_EVALUATION_URL = "".concat(API_HOST, "/data/risk/evaluation/point?key=").concat(API_KEY); // 风险点评估接口 - 用于创建风险点标记
38
- var SEGMENT_EVALUATION_URL = "".concat(API_HOST, "/data/risk/evaluation/segment?key=").concat(API_KEY); // 航段评估接口 - 用于管道颜色和绘制
39
- var ROUTE_EVALUATION_URL = "".concat(API_HOST, "/data/risk/evaluation/route?key=").concat(API_KEY); // 航线评估接口 - 用于右侧面板数据
40
- var GRID_RENDER_URL = "".concat(API_HOST, "/data/grid/render?key=").concat(API_KEY); // 网格渲染接口 - 用于航迹点网格
41
-
42
- var TYPE_COLOR_MAP = {
43
- START: '#00ff00',
44
- END: '#ff0000'
45
- }; // 点位颜色
46
- var TYPE_LABEL_MAP = {
47
- START: '起点',
48
- END: '终点'
49
- }; // 点位名称
50
34
 
51
35
  // 航线风险评估
52
36
  var FlightRiskEvaluation = /*#__PURE__*/function () {
@@ -72,8 +56,14 @@ var FlightRiskEvaluation = /*#__PURE__*/function () {
72
56
  _defineProperty(this, "riskPointsLabelLayer", null);
73
57
  // 网格
74
58
  _defineProperty(this, "gridsLayer", null);
59
+ // 点击航线段事件
60
+ _defineProperty(this, "_onClickSegmentEvent", null);
61
+ // 点击风险点事件
62
+ _defineProperty(this, "_onClickRiskPointEvent", null);
63
+ // 点击风险点文字事件
64
+ _defineProperty(this, "_onClickRiskPointLabelEvent", null);
75
65
  this._mapContext = map._mapContext;
76
- this.options = merge(DEFAULT_GRID_VT_OPTIONS(), options);
66
+ this.options = merge(DEFAULT_FLIGHT_RISK_EVALUATION_OPTIONS(), options);
77
67
  }
78
68
 
79
69
  // 是否能进行操作
@@ -81,7 +71,7 @@ var FlightRiskEvaluation = /*#__PURE__*/function () {
81
71
  key: "_canOperate",
82
72
  value: function _canOperate() {
83
73
  if (this.isDestroyed) {
84
- utils.error('SubmergenceAnalysis实例已销毁');
74
+ utils.error('FlightRiskEvaluation实例已销毁');
85
75
  return false;
86
76
  }
87
77
  return true;
@@ -96,33 +86,17 @@ var FlightRiskEvaluation = /*#__PURE__*/function () {
96
86
  }, {
97
87
  key: "start",
98
88
  value: function () {
99
- var _start = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
100
- var geoJson,
101
- translatedSource,
102
- points,
103
- _yield$Promise$all,
104
- _yield$Promise$all2,
105
- pointEvaluationData,
106
- segmentEvaluationData,
107
- routeEvaluationData,
108
- gridData,
109
- _args = arguments;
89
+ var _start = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(geoJson) {
90
+ var translatedSource, points, _yield$Promise$all, _yield$Promise$all2, pointEvaluationData, segmentEvaluationData, routeEvaluationData, gridData;
110
91
  return _regeneratorRuntime().wrap(function _callee$(_context) {
111
92
  while (1) switch (_context.prev = _context.next) {
112
93
  case 0:
113
- geoJson = _args.length > 0 && _args[0] !== undefined ? _args[0] : {
114
- type: 'Feature',
115
- geometry: {
116
- type: 'LineString',
117
- coordinates: [[114.269292, 22.692453, 95.75], [114.26916666666668, 22.693055555555556, 95.75], [114.27083333333334, 22.69472222222222, 95.75], [114.2713888888889, 22.69527777777778, 118.73], [114.27861111111112, 22.7025, 118.73], [114.28861111111111, 22.7025, 126.39], [114.28972222222222, 22.703611111111112, 118.73], [114.29583333333333, 22.703611111111112, 118.73], [114.302994, 22.707242, 80], [114.292009, 22.72269, 80], [114.27916666666667, 22.733055555555556, 80.43], [114.27665, 22.73299, 80]]
118
- }
119
- };
120
94
  if (this._canOperate()) {
121
- _context.next = 3;
95
+ _context.next = 2;
122
96
  break;
123
97
  }
124
98
  return _context.abrupt("return");
125
- case 3:
99
+ case 2:
126
100
  translatedSource = translateSource(geoJson);
127
101
  this.routeSource = flatten(translatedSource);
128
102
  points = [];
@@ -136,41 +110,48 @@ var FlightRiskEvaluation = /*#__PURE__*/function () {
136
110
  };
137
111
  })));
138
112
  });
139
- _context.next = 9;
140
- return Promise.all([fetch.post(POINT_EVALUATION_URL, {
113
+ _context.next = 8;
114
+ return Promise.all([fetch.post(this.options.POINT_EVALUATION_URL, {
141
115
  points: points
142
- }), fetch.post(SEGMENT_EVALUATION_URL, {
116
+ }), fetch.post(this.options.SEGMENT_EVALUATION_URL, {
143
117
  points: points
144
- }), fetch.post(ROUTE_EVALUATION_URL, {
118
+ }), fetch.post(this.options.ROUTE_EVALUATION_URL, {
145
119
  points: points
146
- }), fetch.post(GRID_RENDER_URL, {
120
+ }), fetch.post(this.options.GRID_RENDER_URL, {
147
121
  points: points,
148
122
  stepDistance: 30
149
123
  })]);
150
- case 9:
124
+ case 8:
151
125
  _yield$Promise$all = _context.sent;
152
126
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 4);
153
127
  pointEvaluationData = _yield$Promise$all2[0].data.data;
154
128
  segmentEvaluationData = _yield$Promise$all2[1].data.data;
155
129
  routeEvaluationData = _yield$Promise$all2[2].data.data;
156
130
  gridData = _yield$Promise$all2[3].data.data;
157
- this.routeResultSource = {
131
+ if (this.options.isDraw) {
132
+ this.routeResultSource = {
133
+ pointEvaluationData: pointEvaluationData,
134
+ segmentEvaluationData: segmentEvaluationData,
135
+ routeEvaluationData: routeEvaluationData,
136
+ gridData: gridData
137
+ };
138
+ this._createRoute();
139
+ this._createRiskPoints();
140
+ this._createGrids();
141
+ }
142
+ return _context.abrupt("return", {
158
143
  pointEvaluationData: pointEvaluationData,
159
144
  segmentEvaluationData: segmentEvaluationData,
160
145
  routeEvaluationData: routeEvaluationData,
161
146
  gridData: gridData
162
- };
163
- this._createRoute();
164
- this._createRiskPoints();
165
- this._createGrids();
166
- console.log(pointEvaluationData, segmentEvaluationData, routeEvaluationData, gridData);
167
- case 20:
147
+ });
148
+ case 16:
168
149
  case "end":
169
150
  return _context.stop();
170
151
  }
171
152
  }, _callee, this);
172
153
  }));
173
- function start() {
154
+ function start(_x) {
174
155
  return _start.apply(this, arguments);
175
156
  }
176
157
  return start;
@@ -178,8 +159,8 @@ var FlightRiskEvaluation = /*#__PURE__*/function () {
178
159
  }, {
179
160
  key: "_createRoute",
180
161
  value: function _createRoute() {
181
- var _this$routeResultSour,
182
- _this = this;
162
+ var _this = this,
163
+ _this$routeResultSour;
183
164
  if (!this._canOperate) return;
184
165
  this._clearRoute();
185
166
  var allPoints = [];
@@ -200,8 +181,8 @@ var FlightRiskEvaluation = /*#__PURE__*/function () {
200
181
  coordinates: point
201
182
  },
202
183
  properties: {
203
- text: TYPE_LABEL_MAP.START,
204
- color: TYPE_COLOR_MAP.START
184
+ text: _this.options.TYPE_LABEL_MAP.START,
185
+ color: _this.options.TYPE_COLOR_MAP.START
205
186
  }
206
187
  });
207
188
  }
@@ -213,8 +194,8 @@ var FlightRiskEvaluation = /*#__PURE__*/function () {
213
194
  coordinates: point
214
195
  },
215
196
  properties: {
216
- text: TYPE_LABEL_MAP.END,
217
- color: TYPE_COLOR_MAP.END
197
+ text: _this.options.TYPE_LABEL_MAP.END,
198
+ color: _this.options.TYPE_COLOR_MAP.END
218
199
  }
219
200
  });
220
201
  }
@@ -288,8 +269,8 @@ var FlightRiskEvaluation = /*#__PURE__*/function () {
288
269
  translucent: true
289
270
  }
290
271
  });
291
- this.routePipelineLayer.on(LAYER_EVENT_TYPE.LEFT_CLICK, function (e) {
292
- console.log(e);
272
+ this._onClickSegmentEvent = this.routePipelineLayer.on(LAYER_EVENT_TYPE.LEFT_CLICK, function (e) {
273
+ _this.options.onClickSegment && _this.options.onClickSegment(e);
293
274
  });
294
275
  }
295
276
  this.routePointsLayer.flyTo();
@@ -308,15 +289,19 @@ var FlightRiskEvaluation = /*#__PURE__*/function () {
308
289
  this.routePointsLabelLayer = null;
309
290
  }
310
291
 
311
- // 获取航段颜色使用segment接口返回的数据)
292
+ // 获取航段颜色 使用segment接口返回的数据
312
293
  }, {
313
294
  key: "_getSegmentColorFromEvaluation",
314
295
  value: function _getSegmentColorFromEvaluation(evaluation) {
315
296
  var confidence = evaluation === null || evaluation === void 0 ? void 0 : evaluation.confidence;
297
+ var step = -1;
298
+ for (var i = 0; i < this.options.segmentGradeColor.length; i++) {
299
+ if (confidence > this.options.segmentGradeColor[i].num) {
300
+ step = i;
301
+ }
302
+ }
316
303
  if (confidence == null) return 'rgba(6,182,212,0.95)';
317
- if (confidence < 0) return 'rgba(239,68,68,0.95)';
318
- if (confidence < 0.5) return 'rgba(245,158,11,0.95)';
319
- return 'rgba(16,185,129,0.95)';
304
+ return this.options.segmentGradeColor[step].color;
320
305
  }
321
306
 
322
307
  // 风险点聚合函数:将相近位置的风险点聚合在一起
@@ -378,11 +363,12 @@ var FlightRiskEvaluation = /*#__PURE__*/function () {
378
363
  }, {
379
364
  key: "_createRiskPoints",
380
365
  value: function _createRiskPoints() {
381
- var _this$routeResultSour2;
366
+ var _this$routeResultSour2,
367
+ _this2 = this;
382
368
  if (!this._canOperate()) return;
383
369
  this._clearRiskPoints();
384
370
  if ((_this$routeResultSour2 = this.routeResultSource) !== null && _this$routeResultSour2 !== void 0 && (_this$routeResultSour2 = _this$routeResultSour2.pointEvaluationData) !== null && _this$routeResultSour2 !== void 0 && _this$routeResultSour2.length) {
385
- var riskPoints = [];
371
+ // const riskPoints = [];
386
372
  var allRiskPoints = [];
387
373
  // 第一步:收集所有风险点
388
374
  this.routeResultSource.pointEvaluationData.forEach(function (item, idx) {
@@ -412,24 +398,9 @@ var FlightRiskEvaluation = /*#__PURE__*/function () {
412
398
  var clusters = this._clusterRiskPoints(allRiskPoints, 0.005); // 约55米聚合距离
413
399
  var clustersGeoJson = {
414
400
  type: 'FeatureCollection',
415
- features: clusters === null || clusters === void 0 ? void 0 : clusters.map(function (cluster, clusterIdx) {
401
+ features: clusters === null || clusters === void 0 ? void 0 : clusters.map(function (cluster) {
416
402
  var isClustered = cluster.points.length > 1;
417
403
  var displayHeight = cluster.centerAlt + 20; // 管道上方20米
418
- var clusterData = {
419
- index: clusterIdx,
420
- lng: cluster.centerLng,
421
- lat: cluster.centerLat,
422
- alt: cluster.centerAlt,
423
- displayHeight: displayHeight,
424
- riskCount: cluster.totalRiskCount,
425
- pointCount: cluster.points.length,
426
- // 聚合的点数量
427
- isClustered: isClustered,
428
- points: cluster.points,
429
- // 包含的所有风险点
430
- evaluation: cluster.evaluations[0] // 使用第一个点的评估数据
431
- };
432
- riskPoints.push(clusterData);
433
404
  // 创建聚合风险点标记
434
405
  // 如果是聚合点,使用更大的标记和不同的颜色
435
406
  var markerSize = isClustered ? 50 : 40;
@@ -441,13 +412,16 @@ var FlightRiskEvaluation = /*#__PURE__*/function () {
441
412
  type: 'Point',
442
413
  coordinates: [cluster.centerLng, cluster.centerLat, displayHeight]
443
414
  },
444
- properties: {
445
- totalRiskCount: cluster.totalRiskCount,
415
+ properties: _objectSpread({
446
416
  isClustered: isClustered,
447
417
  markerSize: markerSize,
448
418
  markerColor: markerColor,
449
- markerText: markerText
450
- }
419
+ markerText: markerText,
420
+ displayHeight: displayHeight,
421
+ riskCount: cluster.totalRiskCount,
422
+ // 风险数量
423
+ pointCount: cluster.points.length
424
+ }, cluster)
451
425
  };
452
426
  })
453
427
  };
@@ -462,6 +436,9 @@ var FlightRiskEvaluation = /*#__PURE__*/function () {
462
436
  disableDepthTestDistance: Number.POSITIVE_INFINITY
463
437
  }
464
438
  });
439
+ this._onClickRiskPointEvent = this.riskPointsLayer.on(LAYER_EVENT_TYPE.LEFT_CLICK, function (e) {
440
+ _this2.options.onClickRisk && _this2.options.onClickRisk(e);
441
+ });
465
442
  this.riskPointsLabelLayer = this.getMap().addGraphicLayer(clustersGeoJson, {
466
443
  type: 'labelP',
467
444
  style: {
@@ -482,6 +459,9 @@ var FlightRiskEvaluation = /*#__PURE__*/function () {
482
459
  disableDepthTestDistance: Number.POSITIVE_INFINITY
483
460
  }
484
461
  });
462
+ this._onClickRiskPointLabelEvent = this.riskPointsLabelLayer.on(LAYER_EVENT_TYPE.LEFT_CLICK, function (e) {
463
+ _this2.options.onClickRisk && _this2.options.onClickRisk(e);
464
+ });
485
465
  }
486
466
  }
487
467
 
@@ -536,14 +516,25 @@ var FlightRiskEvaluation = /*#__PURE__*/function () {
536
516
  });
537
517
  }
538
518
 
539
- // 销毁
519
+ // 清除
540
520
  }, {
541
- key: "destroy",
542
- value: function destroy() {
521
+ key: "clear",
522
+ value: function clear() {
543
523
  if (!this._canOperate()) return;
544
524
  this._clearRoute();
545
525
  this._clearRiskPoints();
546
526
  this.routeResultSource = null;
527
+ this._onClickSegmentEvent && this._onClickSegmentEvent.off();
528
+ this._onClickRiskPointEvent && this._onClickRiskPointEvent.off();
529
+ this._onClickRiskPointLabelEvent && this._onClickRiskPointLabelEvent.off();
530
+ }
531
+
532
+ // 销毁
533
+ }, {
534
+ key: "destroy",
535
+ value: function destroy() {
536
+ if (!this._canOperate()) return;
537
+ this.clear();
547
538
  this.isDestroyed = true;
548
539
  }
549
540
  }]);
@@ -46,7 +46,7 @@ var GridDraw = /*#__PURE__*/function () {
46
46
  key: "_canOperate",
47
47
  value: function _canOperate() {
48
48
  if (this.isDestroyed) {
49
- utils.error('Airspace实例已销毁');
49
+ utils.error('GridDraw实例已销毁');
50
50
  return false;
51
51
  }
52
52
  return true;
@@ -28,7 +28,7 @@ var PoiLayer = /*#__PURE__*/function () {
28
28
  key: "_canOperate",
29
29
  value: function _canOperate() {
30
30
  if (this.isDestroyed) {
31
- utils.error('SubmergenceAnalysis实例已销毁');
31
+ utils.error('PoiLayer实例已销毁');
32
32
  return false;
33
33
  }
34
34
  return true;
@@ -1,4 +1,6 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2
4
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
5
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
4
6
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -245,6 +247,7 @@ var Event = /*#__PURE__*/function () {
245
247
  var pickedObject = _this4._getPickedObject(position);
246
248
  if (pickedObject) {
247
249
  var currLayer;
250
+ var primitiveInstance;
248
251
  if (layer.isEntity) {
249
252
  currLayer = layer.layers.find(function (t) {
250
253
  var _pickedObject$id;
@@ -254,12 +257,35 @@ var Event = /*#__PURE__*/function () {
254
257
  currLayer = layer.layers.find(function (t) {
255
258
  return t.id === (pickedObject === null || pickedObject === void 0 ? void 0 : pickedObject.id);
256
259
  });
260
+ if (!['pointP', 'billboardP', 'labelP'].includes(layer.type)) {
261
+ var _layer$primitiveColle;
262
+ primitiveInstance = layer === null || layer === void 0 || (_layer$primitiveColle = layer.primitiveCollection) === null || _layer$primitiveColle === void 0 || (_layer$primitiveColle = _layer$primitiveColle.primitive) === null || _layer$primitiveColle === void 0 || (_layer$primitiveColle = _layer$primitiveColle.geometryInstances) === null || _layer$primitiveColle === void 0 ? void 0 : _layer$primitiveColle.find(function (t) {
263
+ return t.id === (pickedObject === null || pickedObject === void 0 ? void 0 : pickedObject.id);
264
+ });
265
+ } else if (layer.type === 'pointP') {
266
+ var _layer$primitiveColle2;
267
+ primitiveInstance = layer === null || layer === void 0 || (_layer$primitiveColle2 = layer.primitiveCollection) === null || _layer$primitiveColle2 === void 0 || (_layer$primitiveColle2 = _layer$primitiveColle2._pointPrimitives) === null || _layer$primitiveColle2 === void 0 ? void 0 : _layer$primitiveColle2.find(function (t) {
268
+ return t.id === (pickedObject === null || pickedObject === void 0 ? void 0 : pickedObject.id);
269
+ });
270
+ } else if (layer.type === 'billboardP') {
271
+ var _layer$primitiveColle3;
272
+ primitiveInstance = layer === null || layer === void 0 || (_layer$primitiveColle3 = layer.primitiveCollection) === null || _layer$primitiveColle3 === void 0 || (_layer$primitiveColle3 = _layer$primitiveColle3._billboards) === null || _layer$primitiveColle3 === void 0 ? void 0 : _layer$primitiveColle3.find(function (t) {
273
+ return t.id === (pickedObject === null || pickedObject === void 0 ? void 0 : pickedObject.id);
274
+ });
275
+ } else if (layer.type === 'labelP') {
276
+ var _layer$primitiveColle4;
277
+ primitiveInstance = layer === null || layer === void 0 || (_layer$primitiveColle4 = layer.primitiveCollection) === null || _layer$primitiveColle4 === void 0 || (_layer$primitiveColle4 = _layer$primitiveColle4._labels) === null || _layer$primitiveColle4 === void 0 ? void 0 : _layer$primitiveColle4.find(function (t) {
278
+ return t.id === (pickedObject === null || pickedObject === void 0 ? void 0 : pickedObject.id);
279
+ });
280
+ }
257
281
  }
258
282
  if (currLayer) {
259
283
  var result = {
260
284
  original: e,
261
285
  position: _this4._getPosition(position),
262
- layer: currLayer
286
+ layer: _objectSpread(_objectSpread({}, currLayer), {}, {
287
+ primitiveInstance: primitiveInstance
288
+ })
263
289
  };
264
290
  if (type === Cesium.ScreenSpaceEventType.MOUSE_MOVE) {
265
291
  result.mouseType = !isHoverLayer ? 'mouseEnter' : 'mouseMove';
@@ -1,4 +1,5 @@
1
1
  export default class BaseMaterialAppearance {
2
+ customMaterial: boolean;
2
3
  type: string;
3
4
  style: any;
4
5
  material: any;
@@ -9,6 +9,7 @@ import { v4 as uuidv4 } from 'uuid';
9
9
  var BaseMaterialAppearance = /*#__PURE__*/function () {
10
10
  function BaseMaterialAppearance(type, style) {
11
11
  _classCallCheck(this, BaseMaterialAppearance);
12
+ _defineProperty(this, "customMaterial", true);
12
13
  _defineProperty(this, "type", void 0);
13
14
  _defineProperty(this, "style", void 0);
14
15
  _defineProperty(this, "material", void 0);
@@ -0,0 +1,10 @@
1
+ import BaseMaterialAppearance from './BaseMaterialAppearance';
2
+ declare class ImageMaterialAppearance extends BaseMaterialAppearance {
3
+ private readonly currMaterial;
4
+ private readonly currAppearance;
5
+ constructor(material: any, appearance: any);
6
+ static handleMaterial(style: any): any;
7
+ private _createMaterial;
8
+ private _createAppearance;
9
+ }
10
+ export default ImageMaterialAppearance;
@@ -0,0 +1,77 @@
1
+ var _excluded = ["color"];
2
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
9
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
11
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
13
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
14
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
15
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
16
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
19
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
+ import * as Cesium from 'deeptwins-cesium';
21
+ import { cloneDeep, merge } from 'lodash';
22
+ import { DEFAULT_IMAGE_MATERIAL_STYLE, DEFAULT_MATERIAL_APPEARANCE } from "../../constant";
23
+ import * as utils from "../../tool/utils";
24
+ /* babel-plugin-inline-import '../shader/ImageShader.glsl' */
25
+ var ImageShader = "uniform sampler2D image;\nuniform vec4 color;\nuniform float mixRatio;\n\nczm_material czm_getMaterial(czm_materialInput materialInput) {\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n\n // \u91C7\u6837\u56FE\u7247\n vec4 texColor = texture(image, st);\n\n // \u989C\u8272\u6DF7\u5408\uFF1Amix(\u539F\u59CB\u989C\u8272, \u76EE\u6807\u989C\u8272, mixRatio)\n vec3 mixedColor = mix(texColor.rgb, texColor.rgb * color.rgb, mixRatio);\n\n // \u53D1\u5149\u589E\u5F3A\n material.diffuse = mixedColor * 2.0;\n\n // \u900F\u660E\u5EA6\u968F\u989C\u8272\u53D8\u5316\n material.alpha = texColor.a * mix(color.a, 1.0, 1.0 - mixRatio);\n\n return material;\n}\n";
26
+ import BaseMaterialAppearance from "./BaseMaterialAppearance";
27
+
28
+ // 图片材质 适用于primitive
29
+ var ImageMaterialAppearance = /*#__PURE__*/function (_BaseMaterialAppearan) {
30
+ _inherits(ImageMaterialAppearance, _BaseMaterialAppearan);
31
+ var _super = _createSuper(ImageMaterialAppearance);
32
+ function ImageMaterialAppearance(material, appearance) {
33
+ var _this;
34
+ _classCallCheck(this, ImageMaterialAppearance);
35
+ var mergeMaterial = merge(DEFAULT_IMAGE_MATERIAL_STYLE(), cloneDeep(material || {}));
36
+ _this = _super.call(this, 'ImageMaterialAsset', mergeMaterial);
37
+ _defineProperty(_assertThisInitialized(_this), "currMaterial", void 0);
38
+ _defineProperty(_assertThisInitialized(_this), "currAppearance", void 0);
39
+ _this.currMaterial = ImageMaterialAppearance.handleMaterial(mergeMaterial);
40
+ _this.currAppearance = merge(DEFAULT_MATERIAL_APPEARANCE(), appearance || {});
41
+ _this._createMaterial();
42
+ return _this;
43
+ }
44
+
45
+ // 处理参数
46
+ _createClass(ImageMaterialAppearance, [{
47
+ key: "_createMaterial",
48
+ value: function _createMaterial() {
49
+ this.material = new Cesium.Material({
50
+ fabric: {
51
+ type: this.type,
52
+ uniforms: _objectSpread({}, this.currMaterial),
53
+ source: ImageShader
54
+ }
55
+ });
56
+ this._createAppearance();
57
+ }
58
+ }, {
59
+ key: "_createAppearance",
60
+ value: function _createAppearance() {
61
+ this.appearance = new Cesium.MaterialAppearance(_objectSpread({
62
+ material: this.material
63
+ }, this.currAppearance));
64
+ }
65
+ }], [{
66
+ key: "handleMaterial",
67
+ value: function handleMaterial(style) {
68
+ var color = style.color,
69
+ options = _objectWithoutProperties(style, _excluded);
70
+ var backStyle = _objectSpread({}, options);
71
+ backStyle.color = utils.colorString(color);
72
+ return backStyle;
73
+ }
74
+ }]);
75
+ return ImageMaterialAppearance;
76
+ }(BaseMaterialAppearance);
77
+ export default ImageMaterialAppearance;
@@ -0,0 +1,22 @@
1
+ uniform sampler2D image;
2
+ uniform vec4 color;
3
+ uniform float mixRatio;
4
+
5
+ czm_material czm_getMaterial(czm_materialInput materialInput) {
6
+ czm_material material = czm_getDefaultMaterial(materialInput);
7
+ vec2 st = materialInput.st;
8
+
9
+ // 采样图片
10
+ vec4 texColor = texture(image, st);
11
+
12
+ // 颜色混合:mix(原始颜色, 目标颜色, mixRatio)
13
+ vec3 mixedColor = mix(texColor.rgb, texColor.rgb * color.rgb, mixRatio);
14
+
15
+ // 发光增强
16
+ material.diffuse = mixedColor * 2.0;
17
+
18
+ // 透明度随颜色变化
19
+ material.alpha = texColor.a * mix(color.a, 1.0, 1.0 - mixRatio);
20
+
21
+ return material;
22
+ }
@@ -42,13 +42,22 @@ export declare const getHeightCompensatedScale: (map: Cesium.Viewer, entityHeigh
42
42
  export declare function calculateLength(positions: any[]): number;
43
43
  export declare function warn(message: string): void;
44
44
  export declare function error(message: string): void;
45
+ /**
46
+ * 去除 Polygon ring 的闭合点(首尾重复)
47
+ */
48
+ export declare function normalizeRing(ring: Cesium.Cartesian3[]): Cesium.Cartesian3[];
49
+ /**
50
+ * 构建 Cesium 安全的 PolygonHierarchy
51
+ * 支持闭合 / 非闭合 / holes
52
+ */
53
+ export declare function buildPolygonHierarchy(positions: Cesium.Cartesian3[], holes?: Cesium.Cartesian3[][]): Cesium.PolygonHierarchy;
45
54
  /**
46
55
  * 沿多边形平面局部坐标系计算 ST
47
56
  * @param positions Cartesian3[] 多边形顶点
48
57
  * @param rotation number 旋转
49
58
  * @returns Float32Array ST 坐标
50
59
  */
51
- export declare function computeSTAlongPlane(positions: any, rotation?: number): Float32Array;
60
+ export declare function computeSTAlongPlane(positions: Cesium.Cartesian3[], rotation?: number): Float32Array;
52
61
  export declare function getMidpoint(position1: Cartesian3, position2: Cartesian3): {
53
62
  lng: number;
54
63
  lat: number;