deeptwins-engine-3d 0.1.69 → 0.1.71

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 (41) hide show
  1. package/dist/assets/Build/DeepTwins/Image/fire.png +0 -0
  2. package/dist/assets/Build/DeepTwins/Image/fountain.png +0 -0
  3. package/dist/assets/Build/DeepTwins/Image/smoke.png +0 -0
  4. package/dist/esm/analyze/LineOfSightAnalysis.d.ts +44 -0
  5. package/dist/esm/analyze/LineOfSightAnalysis.js +326 -0
  6. package/dist/esm/analyze/TerrainExcavationAnalysis.d.ts +59 -0
  7. package/dist/esm/analyze/TerrainExcavationAnalysis.js +612 -0
  8. package/dist/esm/constant.d.ts +88 -0
  9. package/dist/esm/constant.js +132 -0
  10. package/dist/esm/drawCommand/viewShed/RectangularSensorPrimitive.d.ts +3 -0
  11. package/dist/esm/drawCommand/viewShed/RectangularSensorPrimitive.js +56 -21
  12. package/dist/esm/drawCommand/viewShed/config.d.ts +2 -2
  13. package/dist/esm/drawCommand/viewShed/config.js +2 -2
  14. package/dist/esm/drawer/index.d.ts +1 -1
  15. package/dist/esm/graphicLayer/BaseSource.d.ts +1 -1
  16. package/dist/esm/index.d.ts +15 -0
  17. package/dist/esm/index.js +24 -2
  18. package/dist/esm/map/Map.d.ts +1 -0
  19. package/dist/esm/map/Map.js +18 -0
  20. package/dist/esm/particle/BaseParticle.d.ts +61 -0
  21. package/dist/esm/particle/BaseParticle.js +196 -0
  22. package/dist/esm/particle/FireParticle.d.ts +8 -0
  23. package/dist/esm/particle/FireParticle.js +65 -0
  24. package/dist/esm/particle/FountainParticle.d.ts +10 -0
  25. package/dist/esm/particle/FountainParticle.js +80 -0
  26. package/dist/esm/particle/SmokeParticle.d.ts +8 -0
  27. package/dist/esm/particle/SmokeParticle.js +65 -0
  28. package/dist/esm/particle/common.d.ts +18 -0
  29. package/dist/esm/particle/common.js +23 -0
  30. package/dist/esm/particle/index.d.ts +5 -0
  31. package/dist/esm/particle/index.js +5 -0
  32. package/dist/esm/tileLayer/CustomRasterLayer.d.ts +188 -0
  33. package/dist/esm/tileLayer/CustomRasterLayer.js +776 -0
  34. package/dist/esm/visualization/DynamicWater.d.ts +39 -0
  35. package/dist/esm/visualization/DynamicWater.js +289 -0
  36. package/dist/esm/visualization/MigrationEffect.d.ts +36 -0
  37. package/dist/esm/visualization/MigrationEffect.js +397 -0
  38. package/dist/esm/visualization/RadarScan.d.ts +39 -0
  39. package/dist/esm/visualization/RadarScan.js +333 -0
  40. package/dist/umd/deeptwins-engine-3d.min.js +1 -1
  41. package/package.json +4 -2
@@ -0,0 +1,397 @@
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
6
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
7
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
+ 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; }
9
+ 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; }
10
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
+ 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); } }
12
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
13
+ 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; }
14
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
15
+ 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); }
16
+ import * as Cesium from 'deeptwins-cesium';
17
+ import { cloneDeep, merge } from 'lodash';
18
+ import { v4 as uuidv4 } from 'uuid';
19
+ import { DEFAULT_MIGRATION_EFFECT_STYLE } from "../constant";
20
+ import BaseSource from "../graphicLayer/BaseSource";
21
+ import PolylineTrailLinkMaterialProperty from "../material/entity/PolylineTrailLinkMaterialProperty";
22
+ import * as utils from "../tool/utils";
23
+ // 动态迁徙效果
24
+ var MigrationEffect = /*#__PURE__*/function () {
25
+ function MigrationEffect() {
26
+ var routes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
27
+ var style = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
28
+ _classCallCheck(this, MigrationEffect);
29
+ _defineProperty(this, "_mapContext", void 0);
30
+ _defineProperty(this, "id", void 0);
31
+ _defineProperty(this, "routes", void 0);
32
+ _defineProperty(this, "style", void 0);
33
+ _defineProperty(this, "lineLayer", void 0);
34
+ _defineProperty(this, "endpointEntities", []);
35
+ _defineProperty(this, "isDestroyed", false);
36
+ _defineProperty(this, "_routeSamples", []);
37
+ _defineProperty(this, "_isAdded", false);
38
+ this.id = uuidv4();
39
+ this.routes = routes;
40
+ this.style = merge(DEFAULT_MIGRATION_EFFECT_STYLE(), cloneDeep(style || {}));
41
+ this._routeSamples = this._buildRouteSamples(this.routes);
42
+ }
43
+ _createClass(MigrationEffect, [{
44
+ key: "getMap",
45
+ value: function getMap() {
46
+ var _this$_mapContext;
47
+ return (_this$_mapContext = this._mapContext) === null || _this$_mapContext === void 0 ? void 0 : _this$_mapContext.getMap();
48
+ }
49
+
50
+ // 添加到地图
51
+ }, {
52
+ key: "addToMap",
53
+ value: function addToMap(map) {
54
+ if (!this._canOperate()) {
55
+ return;
56
+ }
57
+ if (this._isAdded && this.getMap() === map) {
58
+ return this;
59
+ }
60
+ if (this._isAdded) {
61
+ this.remove();
62
+ }
63
+ this._mapContext = map._mapContext;
64
+ this._rebuild();
65
+ return this;
66
+ }
67
+
68
+ // 移除迁徙效果
69
+ }, {
70
+ key: "remove",
71
+ value: function remove() {
72
+ if (this.isDestroyed) {
73
+ return;
74
+ }
75
+ this._clearLayers();
76
+ this._isAdded = false;
77
+ return this;
78
+ }
79
+
80
+ // 显示隐藏
81
+ }, {
82
+ key: "show",
83
+ value: function show(isShow) {
84
+ var _this = this;
85
+ if (!this._canOperate()) {
86
+ return;
87
+ }
88
+ this.style.show = isShow;
89
+ this.lineLayer && this.lineLayer.show(isShow);
90
+ this.endpointEntities.forEach(function (entity) {
91
+ var _this$style$endpoint;
92
+ entity.show = isShow && ((_this$style$endpoint = _this.style.endpoint) === null || _this$style$endpoint === void 0 ? void 0 : _this$style$endpoint.show) !== false;
93
+ });
94
+ return this;
95
+ }
96
+
97
+ // 更新迁徙数据
98
+ }, {
99
+ key: "setData",
100
+ value: function setData() {
101
+ var routes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
102
+ if (!this._canOperate()) {
103
+ return;
104
+ }
105
+ this.routes = routes;
106
+ this._routeSamples = this._buildRouteSamples(routes);
107
+ if (this._isAdded) {
108
+ this._rebuild();
109
+ }
110
+ return this;
111
+ }
112
+
113
+ // 更新迁徙样式
114
+ }, {
115
+ key: "setStyle",
116
+ value: function setStyle() {
117
+ var style = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
118
+ if (!this._canOperate()) {
119
+ return;
120
+ }
121
+ this.style = merge(this.style, cloneDeep(style || {}));
122
+ this._routeSamples = this._buildRouteSamples(this.routes);
123
+ if (this._isAdded) {
124
+ this._rebuild();
125
+ }
126
+ return this;
127
+ }
128
+
129
+ // 飞行至迁徙范围
130
+ }, {
131
+ key: "flyTo",
132
+ value: function flyTo() {
133
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
134
+ if (!this._canOperate() || !this.getMap()) {
135
+ return;
136
+ }
137
+ var positions = this._routeSamples.flatMap(function (sample) {
138
+ return sample.positions;
139
+ });
140
+ if (!positions.length) {
141
+ return;
142
+ }
143
+ utils.cameraFlyToPositions(this.getMap().camera, positions, _objectSpread({
144
+ scale: 1.4
145
+ }, options));
146
+ }
147
+
148
+ // 销毁
149
+ }, {
150
+ key: "destroy",
151
+ value: function destroy() {
152
+ if (this.isDestroyed) {
153
+ return;
154
+ }
155
+ this.remove();
156
+ this.routes = [];
157
+ this._routeSamples = [];
158
+ this._mapContext = undefined;
159
+ this.isDestroyed = true;
160
+ }
161
+
162
+ // 是否能进行操作
163
+ }, {
164
+ key: "_canOperate",
165
+ value: function _canOperate() {
166
+ if (this.isDestroyed) {
167
+ utils.error('MigrationEffect实例已销毁');
168
+ return false;
169
+ }
170
+ return true;
171
+ }
172
+ }, {
173
+ key: "_rebuild",
174
+ value: function _rebuild() {
175
+ var map = this.getMap();
176
+ if (!map) {
177
+ return;
178
+ }
179
+ this._clearLayers();
180
+ this._routeSamples = this._buildRouteSamples(this.routes);
181
+ if (!this._routeSamples.length) {
182
+ utils.error('MigrationEffect至少需要1条有效迁徙路线');
183
+ this._isAdded = false;
184
+ return;
185
+ }
186
+ this._createLineLayer(map);
187
+ this._createEndpoints(map);
188
+ this._isAdded = true;
189
+ }
190
+ }, {
191
+ key: "_clearLayers",
192
+ value: function _clearLayers() {
193
+ var map = this.getMap();
194
+ if (this.lineLayer) {
195
+ this.lineLayer.remove();
196
+ this.lineLayer = null;
197
+ }
198
+ if (map) {
199
+ this.endpointEntities.forEach(function (entity) {
200
+ map.entities.remove(entity);
201
+ });
202
+ }
203
+ this.endpointEntities = [];
204
+ }
205
+ }, {
206
+ key: "_createLineLayer",
207
+ value: function _createLineLayer(map) {
208
+ var material = new PolylineTrailLinkMaterialProperty({
209
+ color: this.style.lineColor,
210
+ duration: this.style.duration,
211
+ repeat: this.style.repeat,
212
+ repeatPixel: this.style.repeatPixel,
213
+ image: this.style.image,
214
+ mixRatio: this.style.mixRatio
215
+ });
216
+ this.lineLayer = map.addGraphicLayer(this._buildLineGeoJson(), {
217
+ type: 'polyline',
218
+ style: {
219
+ show: this.style.show,
220
+ width: this.style.width,
221
+ material: material
222
+ }
223
+ });
224
+ material.dynamicsSize(map, this.lineLayer);
225
+ }
226
+ }, {
227
+ key: "_createEndpoints",
228
+ value: function _createEndpoints(map) {
229
+ var _this2 = this;
230
+ var endpointStyle = this.style.endpoint || {};
231
+ if (endpointStyle.show === false) {
232
+ return;
233
+ }
234
+ this._routeSamples.forEach(function (sample, index) {
235
+ if (endpointStyle.showStart !== false) {
236
+ _this2.endpointEntities.push(_this2._createEndpoint(map, sample, index, 'start'));
237
+ }
238
+ if (endpointStyle.showEnd !== false) {
239
+ _this2.endpointEntities.push(_this2._createEndpoint(map, sample, index, 'end'));
240
+ }
241
+ });
242
+ }
243
+ }, {
244
+ key: "_createEndpoint",
245
+ value: function _createEndpoint(map, sample, index, type) {
246
+ var endpointStyle = this.style.endpoint || {};
247
+ var position = this._getEndpointPosition(sample, type);
248
+ var pointColor = type === 'start' ? endpointStyle.startColor : endpointStyle.endColor;
249
+ return map.entities.add({
250
+ id: "".concat(this.id, "_endpoint_").concat(type, "_").concat(index),
251
+ show: this.style.show,
252
+ properties: _objectSpread(_objectSpread({}, sample.feature.properties || {}), {}, {
253
+ endpointType: type
254
+ }),
255
+ position: position,
256
+ point: {
257
+ pixelSize: endpointStyle.pixelSize,
258
+ color: utils.colorString(pointColor),
259
+ outlineColor: utils.colorString(endpointStyle.outlineColor),
260
+ outlineWidth: endpointStyle.outlineWidth,
261
+ disableDepthTestDistance: Number.POSITIVE_INFINITY
262
+ }
263
+ });
264
+ }
265
+ }, {
266
+ key: "_getEndpointPosition",
267
+ value: function _getEndpointPosition(sample, type) {
268
+ if (type === 'start') {
269
+ return sample.positions[0];
270
+ }
271
+ return sample.positions[sample.positions.length - 1];
272
+ }
273
+ }, {
274
+ key: "_buildLineGeoJson",
275
+ value: function _buildLineGeoJson() {
276
+ return {
277
+ type: 'FeatureCollection',
278
+ features: this._routeSamples.map(function (sample, index) {
279
+ return {
280
+ type: 'Feature',
281
+ properties: _objectSpread(_objectSpread({}, sample.feature.properties || {}), {}, {
282
+ migrationIndex: index
283
+ }),
284
+ geometry: {
285
+ type: 'LineString',
286
+ coordinates: sample.coordinates
287
+ }
288
+ };
289
+ })
290
+ };
291
+ }
292
+ }, {
293
+ key: "_buildRouteSamples",
294
+ value: function _buildRouteSamples(routes) {
295
+ var _this3 = this;
296
+ if (!routes) {
297
+ return [];
298
+ }
299
+ if (BaseSource.analysisSourceType(routes) !== 'geoJson') {
300
+ utils.error('MigrationEffect routes必须是GeoJSON Feature或FeatureCollection');
301
+ return [];
302
+ }
303
+ var features = [];
304
+ try {
305
+ features = BaseSource.geoJsonToGeoCartesian3Array(routes);
306
+ } catch (error) {
307
+ utils.error("MigrationEffect GeoJSON\u89E3\u6790\u5931\u8D25\uFF1A".concat(error.message));
308
+ return [];
309
+ }
310
+ var ignoredCount = 0;
311
+ var invalidCount = 0;
312
+ var samples = [];
313
+ features.forEach(function (feature) {
314
+ var _feature$geometry;
315
+ if ((feature === null || feature === void 0 || (_feature$geometry = feature.geometry) === null || _feature$geometry === void 0 ? void 0 : _feature$geometry.type) !== 'LineString') {
316
+ ignoredCount += 1;
317
+ return;
318
+ }
319
+ var sample = _this3._sampleRoute(feature);
320
+ if (sample) {
321
+ samples.push(sample);
322
+ } else {
323
+ invalidCount += 1;
324
+ }
325
+ });
326
+ if (ignoredCount) {
327
+ utils.warn("MigrationEffect\u4EC5\u652F\u6301LineString\u548CMultiLineString\uFF0C\u5DF2\u5FFD\u7565".concat(ignoredCount, "\u4E2A\u975E\u7EBF\u8981\u7D20"));
328
+ }
329
+ if (invalidCount) {
330
+ utils.warn("MigrationEffect\u5DF2\u5FFD\u7565".concat(invalidCount, "\u6761\u65E0\u6548\u8FC1\u5F99\u8DEF\u7EBF"));
331
+ }
332
+ return samples;
333
+ }
334
+ }, {
335
+ key: "_sampleRoute",
336
+ value: function _sampleRoute(feature) {
337
+ var sourceCoordinates = feature.geometry.coordinates || [];
338
+ var from = this._normalizeCoordinate(sourceCoordinates[0]);
339
+ var to = this._normalizeCoordinate(sourceCoordinates[sourceCoordinates.length - 1]);
340
+ if (!from || !to || this._isSamePosition(from, to)) {
341
+ return null;
342
+ }
343
+ var geodesic = new Cesium.EllipsoidGeodesic(Cesium.Cartographic.fromDegrees(from.lng, from.lat), Cesium.Cartographic.fromDegrees(to.lng, to.lat));
344
+ var segments = Math.max(2, Math.floor(this.style.segments || 64));
345
+ var arcHeight = Number(this.style.arcHeight) || 0;
346
+ var coordinates = [];
347
+ var positions = [];
348
+ for (var i = 0; i <= segments; i++) {
349
+ var ratio = i / segments;
350
+ var cartographic = geodesic.interpolateUsingFraction(ratio);
351
+ var lng = utils.toDegrees(cartographic.longitude);
352
+ var lat = utils.toDegrees(cartographic.latitude);
353
+ var alt = Cesium.Math.lerp(from.alt, to.alt, ratio) + Math.sin(Math.PI * ratio) * arcHeight;
354
+ coordinates.push([lng, lat, alt]);
355
+ positions.push(utils.lngLatAltToCartesian3(lng, lat, alt));
356
+ }
357
+ return {
358
+ feature: feature,
359
+ coordinates: coordinates,
360
+ positions: positions
361
+ };
362
+ }
363
+ }, {
364
+ key: "_normalizeCoordinate",
365
+ value: function _normalizeCoordinate(coordinate) {
366
+ if (Array.isArray(coordinate)) {
367
+ var _coordinate = _slicedToArray(coordinate, 3),
368
+ lng = _coordinate[0],
369
+ lat = _coordinate[1],
370
+ _coordinate$ = _coordinate[2],
371
+ alt = _coordinate$ === void 0 ? 0 : _coordinate$;
372
+ return this._createNormalizedPosition(lng, lat, alt);
373
+ }
374
+ return null;
375
+ }
376
+ }, {
377
+ key: "_createNormalizedPosition",
378
+ value: function _createNormalizedPosition(lng, lat) {
379
+ var alt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
380
+ if (!Number.isFinite(lng) || !Number.isFinite(lat)) {
381
+ return null;
382
+ }
383
+ return {
384
+ lng: lng,
385
+ lat: lat,
386
+ alt: Number.isFinite(alt) ? alt : 0
387
+ };
388
+ }
389
+ }, {
390
+ key: "_isSamePosition",
391
+ value: function _isSamePosition(from, to) {
392
+ return from.lng === to.lng && from.lat === to.lat && from.alt === to.alt;
393
+ }
394
+ }]);
395
+ return MigrationEffect;
396
+ }();
397
+ export { MigrationEffect as default };
@@ -0,0 +1,39 @@
1
+ import { MapContext } from '../map/Map';
2
+ type RadarScanPosition = [number, number] | [number, number, number] | {
3
+ lng: number;
4
+ lat: number;
5
+ alt?: number;
6
+ };
7
+ interface RadarScanOptions {
8
+ position?: RadarScanPosition;
9
+ style?: any;
10
+ }
11
+ export default class RadarScan {
12
+ _mapContext: MapContext | undefined;
13
+ id: string;
14
+ position: RadarScanPosition | undefined;
15
+ style: any;
16
+ primitive: any;
17
+ isDestroyed: boolean;
18
+ private _isAdded;
19
+ constructor(options?: RadarScanOptions);
20
+ getMap(): any;
21
+ addToMap(map: any): this | undefined;
22
+ remove(): this | undefined;
23
+ show(isShow: boolean): this | undefined;
24
+ setPosition(position: RadarScanPosition): this | undefined;
25
+ setStyle(style?: any): this | undefined;
26
+ flyTo(options?: any): this | undefined;
27
+ destroy(): void;
28
+ private _canOperate;
29
+ private _rebuildPrimitive;
30
+ private _createModelMatrix;
31
+ private _getCenterCartesian;
32
+ private _normalizePosition;
33
+ private _normalizeScanPlaneMode;
34
+ private _normalizeSlice;
35
+ private _normalizeHalfAngle;
36
+ private _normalizePositiveNumber;
37
+ private _normalizeNumber;
38
+ }
39
+ export {};