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,44 @@
1
+ type LngLatAlt = [number, number, number];
2
+ export interface LineOfSightAnalysisResult {
3
+ visible: boolean;
4
+ distance: number;
5
+ position: LngLatAlt;
6
+ positionEnd: LngLatAlt;
7
+ obstructionDistance?: number;
8
+ obstructionPosition?: {
9
+ lng: number;
10
+ lat: number;
11
+ alt: number;
12
+ };
13
+ pickedObject?: any;
14
+ }
15
+ declare class LineOfSightAnalysis {
16
+ private readonly _mapContext;
17
+ options: any;
18
+ isDestroyed: boolean;
19
+ private _lineLayer;
20
+ private _pointLayer;
21
+ private _result;
22
+ constructor(map: any, options?: any);
23
+ private _canOperate;
24
+ private _replaceArrayOptions;
25
+ private _normalizePosition;
26
+ private _toCartesian;
27
+ private _getPositionPair;
28
+ getMap(): any;
29
+ create(): LineOfSightAnalysisResult | null;
30
+ update(options?: any): LineOfSightAnalysisResult | null;
31
+ setPositions(position: any, positionEnd: any): LineOfSightAnalysisResult | null;
32
+ getResult(): LineOfSightAnalysisResult | null;
33
+ private _analyze;
34
+ private _buildLineGeoJson;
35
+ private _buildPointGeoJson;
36
+ private _lineFeature;
37
+ private _pointFeature;
38
+ private _draw;
39
+ private _clearLayers;
40
+ flyTo(): void;
41
+ clear(): void;
42
+ destroy(): void;
43
+ }
44
+ export default LineOfSightAnalysis;
@@ -0,0 +1,326 @@
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
+ 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); } }
10
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
+ 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; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
13
+ 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); }
14
+ import * as Cesium from 'deeptwins-cesium';
15
+ import { merge } from 'lodash';
16
+ import { DEFAULT_LINE_OF_SIGHT_ANALYSIS_OPTIONS } from "../constant";
17
+ import * as utils from "../tool/utils";
18
+ // 通视分析。
19
+ var LineOfSightAnalysis = /*#__PURE__*/function () {
20
+ function LineOfSightAnalysis(map) {
21
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
22
+ _classCallCheck(this, LineOfSightAnalysis);
23
+ _defineProperty(this, "_mapContext", void 0);
24
+ _defineProperty(this, "options", void 0);
25
+ _defineProperty(this, "isDestroyed", false);
26
+ _defineProperty(this, "_lineLayer", null);
27
+ _defineProperty(this, "_pointLayer", null);
28
+ _defineProperty(this, "_result", null);
29
+ this._mapContext = map._mapContext;
30
+ this.options = merge(DEFAULT_LINE_OF_SIGHT_ANALYSIS_OPTIONS(), options);
31
+ this._replaceArrayOptions(options);
32
+ if (this.options.position && this.options.positionEnd) {
33
+ this.create();
34
+ }
35
+ }
36
+
37
+ // 是否能进行操作
38
+ _createClass(LineOfSightAnalysis, [{
39
+ key: "_canOperate",
40
+ value: function _canOperate() {
41
+ if (this.isDestroyed) {
42
+ utils.error('LineOfSightAnalysis实例已销毁');
43
+ return false;
44
+ }
45
+ return true;
46
+ }
47
+ }, {
48
+ key: "_replaceArrayOptions",
49
+ value: function _replaceArrayOptions() {
50
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
51
+ if (Object.prototype.hasOwnProperty.call(options, 'position')) {
52
+ this.options.position = options.position;
53
+ }
54
+ if (Object.prototype.hasOwnProperty.call(options, 'positionEnd')) {
55
+ this.options.positionEnd = options.positionEnd;
56
+ }
57
+ if (Object.prototype.hasOwnProperty.call(options, 'objectsToExclude')) {
58
+ this.options.objectsToExclude = options.objectsToExclude;
59
+ }
60
+ }
61
+ }, {
62
+ key: "_normalizePosition",
63
+ value: function _normalizePosition(position) {
64
+ if (!Array.isArray(position) || position.length < 2) {
65
+ return null;
66
+ }
67
+ var _position = _slicedToArray(position, 3),
68
+ lng = _position[0],
69
+ lat = _position[1],
70
+ _position$ = _position[2],
71
+ alt = _position$ === void 0 ? 0 : _position$;
72
+ if (!Number.isFinite(lng) || !Number.isFinite(lat) || !Number.isFinite(alt)) {
73
+ return null;
74
+ }
75
+ return [lng, lat, alt];
76
+ }
77
+ }, {
78
+ key: "_toCartesian",
79
+ value: function _toCartesian(position) {
80
+ var _position2 = _slicedToArray(position, 3),
81
+ lng = _position2[0],
82
+ lat = _position2[1],
83
+ alt = _position2[2];
84
+ return utils.lngLatAltToCartesian3(lng, lat, alt);
85
+ }
86
+ }, {
87
+ key: "_getPositionPair",
88
+ value: function _getPositionPair() {
89
+ var position = this._normalizePosition(this.options.position);
90
+ var positionEnd = this._normalizePosition(this.options.positionEnd);
91
+ if (!position || !positionEnd) {
92
+ return null;
93
+ }
94
+ return {
95
+ position: position,
96
+ positionEnd: positionEnd
97
+ };
98
+ }
99
+ }, {
100
+ key: "getMap",
101
+ value: function getMap() {
102
+ return this._mapContext && this._mapContext.getMap();
103
+ }
104
+ }, {
105
+ key: "create",
106
+ value: function create() {
107
+ if (!this._canOperate()) return null;
108
+ this._clearLayers();
109
+ var result = this._analyze();
110
+ this._result = result;
111
+ if (result) {
112
+ this._draw(result);
113
+ this.options.onComplete && this.options.onComplete(result);
114
+ }
115
+ return result;
116
+ }
117
+ }, {
118
+ key: "update",
119
+ value: function update() {
120
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
121
+ if (!this._canOperate()) return null;
122
+ this.options = merge({}, this.options, options);
123
+ this._replaceArrayOptions(options);
124
+ return this.create();
125
+ }
126
+ }, {
127
+ key: "setPositions",
128
+ value: function setPositions(position, positionEnd) {
129
+ if (!this._canOperate()) return null;
130
+ this.options.position = position;
131
+ this.options.positionEnd = positionEnd;
132
+ return this.create();
133
+ }
134
+ }, {
135
+ key: "getResult",
136
+ value: function getResult() {
137
+ return this._result;
138
+ }
139
+ }, {
140
+ key: "_analyze",
141
+ value: function _analyze() {
142
+ var _this$getMap;
143
+ var positionPair = this._getPositionPair();
144
+ if (!positionPair) {
145
+ return null;
146
+ }
147
+ var position = positionPair.position,
148
+ positionEnd = positionPair.positionEnd;
149
+ var start = this._toCartesian(position);
150
+ var end = this._toCartesian(positionEnd);
151
+ var direction = Cesium.Cartesian3.subtract(end, start, new Cesium.Cartesian3());
152
+ var distance = Cesium.Cartesian3.magnitude(direction);
153
+ if (distance <= 0) {
154
+ return {
155
+ visible: true,
156
+ distance: 0,
157
+ position: position,
158
+ positionEnd: positionEnd
159
+ };
160
+ }
161
+ Cesium.Cartesian3.normalize(direction, direction);
162
+ var scene = (_this$getMap = this.getMap()) === null || _this$getMap === void 0 ? void 0 : _this$getMap.scene;
163
+ if (!scene || typeof scene.pickFromRay !== 'function') {
164
+ utils.error('当前场景不支持pickFromRay,无法进行通视分析');
165
+ return null;
166
+ }
167
+ var ray = new Cesium.Ray(start, direction);
168
+ var pickResult = scene.pickFromRay(ray, this.options.objectsToExclude, this.options.pickWidth);
169
+ var obstructionCartesian = pickResult === null || pickResult === void 0 ? void 0 : pickResult.position;
170
+ if (!obstructionCartesian) {
171
+ return {
172
+ visible: true,
173
+ distance: distance,
174
+ position: position,
175
+ positionEnd: positionEnd
176
+ };
177
+ }
178
+ var obstructionDistance = Cesium.Cartesian3.distance(start, obstructionCartesian);
179
+ var tolerance = Math.max(Number(this.options.tolerance) || 0, 0);
180
+ var visible = obstructionDistance >= distance - tolerance;
181
+ var obstructionPosition = utils.cartesian3ToLngLatAlt(obstructionCartesian);
182
+ return {
183
+ visible: visible,
184
+ distance: distance,
185
+ position: position,
186
+ positionEnd: positionEnd,
187
+ obstructionDistance: obstructionDistance,
188
+ obstructionPosition: obstructionPosition,
189
+ pickedObject: pickResult.object
190
+ };
191
+ }
192
+ }, {
193
+ key: "_buildLineGeoJson",
194
+ value: function _buildLineGeoJson(result) {
195
+ var features = [];
196
+ var position = result.position,
197
+ positionEnd = result.positionEnd,
198
+ obstructionPosition = result.obstructionPosition;
199
+ var obstruction = obstructionPosition ? [obstructionPosition.lng, obstructionPosition.lat, obstructionPosition.alt] : null;
200
+ if (result.visible || !obstruction) {
201
+ features.push(this._lineFeature(position, positionEnd, true));
202
+ } else {
203
+ features.push(this._lineFeature(position, obstruction, true));
204
+ features.push(this._lineFeature(obstruction, positionEnd, false));
205
+ }
206
+ return {
207
+ type: 'FeatureCollection',
208
+ features: features
209
+ };
210
+ }
211
+ }, {
212
+ key: "_buildPointGeoJson",
213
+ value: function _buildPointGeoJson(result) {
214
+ var features = [this._pointFeature(result.position, 'start'), this._pointFeature(result.positionEnd, 'end')];
215
+ if (this.options.showObstructionPoint && !result.visible && result.obstructionPosition) {
216
+ features.push(this._pointFeature([result.obstructionPosition.lng, result.obstructionPosition.lat, result.obstructionPosition.alt], 'obstruction'));
217
+ }
218
+ return {
219
+ type: 'FeatureCollection',
220
+ features: features
221
+ };
222
+ }
223
+ }, {
224
+ key: "_lineFeature",
225
+ value: function _lineFeature(start, end, visible) {
226
+ return {
227
+ type: 'Feature',
228
+ properties: {
229
+ visible: visible
230
+ },
231
+ geometry: {
232
+ type: 'LineString',
233
+ coordinates: [start, end]
234
+ }
235
+ };
236
+ }
237
+ }, {
238
+ key: "_pointFeature",
239
+ value: function _pointFeature(position, type) {
240
+ return {
241
+ type: 'Feature',
242
+ properties: {
243
+ type: type
244
+ },
245
+ geometry: {
246
+ type: 'Point',
247
+ coordinates: position
248
+ }
249
+ };
250
+ }
251
+ }, {
252
+ key: "_draw",
253
+ value: function _draw(result) {
254
+ var _this = this;
255
+ if (this.options.showLine) {
256
+ this._lineLayer = this.getMap().addGraphicLayer(this._buildLineGeoJson(result), {
257
+ type: 'polyline',
258
+ style: {
259
+ width: this.options.lineWidth,
260
+ material: function material(properties) {
261
+ return properties.visible ? _this.options.visibleColor : _this.options.invisibleColor;
262
+ },
263
+ depthFailMaterial: function depthFailMaterial(properties) {
264
+ return properties.visible ? _this.options.visibleColor : _this.options.invisibleColor;
265
+ },
266
+ clampToGround: false
267
+ }
268
+ });
269
+ }
270
+ if (this.options.showPoint) {
271
+ this._pointLayer = this.getMap().addGraphicLayer(this._buildPointGeoJson(result), {
272
+ type: 'point',
273
+ style: {
274
+ pixelSize: this.options.pointPixelSize,
275
+ color: function color(properties) {
276
+ return properties.type === 'obstruction' ? _this.options.obstructionPointColor : _this.options.pointColor;
277
+ },
278
+ outlineColor: '#ffffff',
279
+ outlineWidth: 2
280
+ }
281
+ });
282
+ }
283
+ }
284
+ }, {
285
+ key: "_clearLayers",
286
+ value: function _clearLayers() {
287
+ if (this._lineLayer) {
288
+ this._lineLayer.remove();
289
+ this._lineLayer = null;
290
+ }
291
+ if (this._pointLayer) {
292
+ this._pointLayer.remove();
293
+ this._pointLayer = null;
294
+ }
295
+ }
296
+ }, {
297
+ key: "flyTo",
298
+ value: function flyTo() {
299
+ if (!this._canOperate()) return;
300
+ if (this._lineLayer) {
301
+ this._lineLayer.flyTo();
302
+ return;
303
+ }
304
+ if (this._pointLayer) {
305
+ this._pointLayer.flyTo();
306
+ }
307
+ }
308
+ }, {
309
+ key: "clear",
310
+ value: function clear() {
311
+ if (!this._canOperate()) return;
312
+ this._clearLayers();
313
+ this._result = null;
314
+ }
315
+ }, {
316
+ key: "destroy",
317
+ value: function destroy() {
318
+ if (!this._canOperate()) return;
319
+ this._clearLayers();
320
+ this._result = null;
321
+ this.isDestroyed = true;
322
+ }
323
+ }]);
324
+ return LineOfSightAnalysis;
325
+ }();
326
+ export default LineOfSightAnalysis;
@@ -0,0 +1,59 @@
1
+ /// <reference path="../typings.d.ts" />
2
+ import * as Cesium from 'deeptwins-cesium';
3
+ type LngLatAlt = [number, number, number];
4
+ export interface TerrainExcavationAnalysisResult {
5
+ extent: any;
6
+ coordinates: LngLatAlt[];
7
+ sampledCoordinates: LngLatAlt[];
8
+ bottomHeight: number;
9
+ minHeight: number;
10
+ maxHeight: number;
11
+ depth: number;
12
+ clippingPlanes: Cesium.ClippingPlaneCollection;
13
+ }
14
+ declare class TerrainExcavationAnalysis {
15
+ private readonly _mapContext;
16
+ options: any;
17
+ isDestroyed: boolean;
18
+ extent: any;
19
+ private _bottomLayer;
20
+ private _wallLayer;
21
+ private _edgeLayer;
22
+ private _clippingPlanes;
23
+ private _previousClippingPlanes;
24
+ private _result;
25
+ private _createToken;
26
+ constructor(map: any, extent: any, options?: any);
27
+ private _canOperate;
28
+ private _replaceNullableOptions;
29
+ private _toFiniteNumber;
30
+ private _isSamePosition;
31
+ private _normalizeCoordinate;
32
+ private _getPolygonGeometry;
33
+ private _getOuterRing;
34
+ private _closeRing;
35
+ private _densifyRing;
36
+ private _sampleTerrain;
37
+ private _getBottomHeight;
38
+ private _getCenterPosition;
39
+ private _getLocalPositions;
40
+ private _getLocalCenter;
41
+ private _createPlane;
42
+ private _createClippingPlanes;
43
+ private _setClippingPlanes;
44
+ private _restoreClippingPlanes;
45
+ private _buildPolygonGeoJson;
46
+ private _buildLineGeoJson;
47
+ private _draw;
48
+ private _clearLayers;
49
+ getMap(): any;
50
+ create(): Promise<TerrainExcavationAnalysisResult | null>;
51
+ update(options?: any): Promise<TerrainExcavationAnalysisResult | null>;
52
+ setExtent(extent: any): Promise<TerrainExcavationAnalysisResult | null>;
53
+ setDepth(depth: number): Promise<TerrainExcavationAnalysisResult | null>;
54
+ getResult(): TerrainExcavationAnalysisResult | null;
55
+ flyTo(): void;
56
+ clear(): void;
57
+ destroy(): void;
58
+ }
59
+ export default TerrainExcavationAnalysis;