deeptwins-engine-3d 0.1.47 → 0.1.49

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 (37) hide show
  1. package/dist/esm/analyze/ViewshedAnalysis.js +3 -2
  2. package/dist/esm/constant.d.ts +11 -0
  3. package/dist/esm/constant.js +26 -0
  4. package/dist/esm/graphicLayer/BaseLayer.js +6 -0
  5. package/dist/esm/graphicLayer/BasePrimitiveInstance.d.ts +2 -0
  6. package/dist/esm/graphicLayer/BasePrimitiveInstance.js +13 -5
  7. package/dist/esm/graphicLayer/BaseSource.d.ts +1 -1
  8. package/dist/esm/graphicLayer/BaseSource.js +6 -0
  9. package/dist/esm/graphicLayer/PolygonGroundPrimitiveImageMaterialInstance.d.ts +5 -0
  10. package/dist/esm/graphicLayer/PolygonGroundPrimitiveImageMaterialInstance.js +84 -0
  11. package/dist/esm/graphicLayer/PolygonPrimitive.js +6 -4
  12. package/dist/esm/graphicLayer/PolygonPrimitiveImageMaterialInstance.d.ts +5 -0
  13. package/dist/esm/graphicLayer/PolygonPrimitiveImageMaterialInstance.js +81 -0
  14. package/dist/esm/graphicLayer/PolygonPrimitiveInstance.d.ts +1 -1
  15. package/dist/esm/graphicLayer/PolygonPrimitiveInstance.js +8 -23
  16. package/dist/esm/graphicLayer/PolylineGroundPrimitiveInstance.js +1 -1
  17. package/dist/esm/index.d.ts +2 -1
  18. package/dist/esm/index.js +6 -4
  19. package/dist/esm/map/Map.js +1 -1
  20. package/dist/esm/material/primitive/BaseMaterialAppearance.d.ts +1 -0
  21. package/dist/esm/material/primitive/BaseMaterialAppearance.js +1 -0
  22. package/dist/esm/material/primitive/ImageMaterialAppearance.d.ts +10 -0
  23. package/dist/esm/material/primitive/ImageMaterialAppearance.js +77 -0
  24. package/dist/esm/material/shader/ImageShader.glsl +22 -0
  25. package/dist/esm/tool/BuildClampedPolygonGrid.d.ts +11 -0
  26. package/dist/esm/tool/BuildClampedPolygonGrid.js +151 -0
  27. package/dist/esm/tool/utils.d.ts +18 -1
  28. package/dist/esm/tool/utils.js +119 -44
  29. package/dist/esm/videoFusion/VideoProject.js +1 -1
  30. package/dist/esm/visualization/Frustum.d.ts +27 -2
  31. package/dist/esm/visualization/Frustum.js +158 -42
  32. package/dist/umd/deeptwins-engine-3d.min.js +1 -1
  33. package/package.json +8 -5
  34. package/dist/esm/visualization/BaseFrustum.d.ts +0 -14
  35. package/dist/esm/visualization/BaseFrustum.js +0 -96
  36. package/dist/esm/visualization/FrustumWithCamera.d.ts +0 -5
  37. package/dist/esm/visualization/FrustumWithCamera.js +0 -133
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deeptwins-engine-3d",
3
- "version": "0.1.47",
3
+ "version": "0.1.49",
4
4
  "description": "map for 3d",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -67,7 +67,7 @@
67
67
  "@umijs/lint": "^4.0.0",
68
68
  "babel-loader": "^9.2.1",
69
69
  "babel-plugin-inline-import": "^3.0.0",
70
- "copy-webpack-plugin": "^12.0.2",
70
+ "copy-webpack-plugin": "^13.0.1",
71
71
  "dumi": "^2.4.13",
72
72
  "eslint": "^8.57.1",
73
73
  "eslint-config-prettier": "^9.1.0",
@@ -87,19 +87,22 @@
87
87
  "webpack": "^5.97.1"
88
88
  },
89
89
  "dependencies": {
90
+ "@mapbox/vector-tile": "^2.0.4",
90
91
  "@turf/area": "^6.5.0",
91
92
  "@turf/helpers": "^6.5.0",
92
93
  "@turf/intersect": "^6.5.0",
93
94
  "@turf/random": "^6.5.0",
94
95
  "@turf/turf": "^6.5.0",
95
96
  "@turf/voronoi": "^6.5.0",
97
+ "@zip.js/zip.js": "2.7.34",
96
98
  "beidou-grid-location-codec": "^1.1.12",
97
- "deeptwins-cesium":"0.0.35",
99
+ "deeptwins-cesium": "0.0.35",
98
100
  "hls.js": "^1.5.20",
99
101
  "kdbush": "^4.0.2",
102
+ "lil-gui": "^0.21.0",
100
103
  "lodash": "^4.17.21",
104
+ "pbf": "^4.0.1",
101
105
  "uuid": "^11.0.3",
102
- "wellknown": "^0.5.0",
103
- "@zip.js/zip.js": "2.7.34"
106
+ "wellknown": "^0.5.0"
104
107
  }
105
108
  }
@@ -1,14 +0,0 @@
1
- import { MapContext } from '../map/Map';
2
- export default class BaseFrustum {
3
- _mapContext: MapContext | undefined;
4
- options: any;
5
- frustumPrimitive: any;
6
- frustumLinePrimitive: any;
7
- isDestroyed: boolean;
8
- constructor(map: any, options: any);
9
- getMap(): any;
10
- private _canOperate;
11
- getFrustumVertexPoints(): any;
12
- show(isShow: boolean): void;
13
- destroy(): void;
14
- }
@@ -1,96 +0,0 @@
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
- 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
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
- 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; }
6
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
- 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); }
8
- import * as Cesium from 'deeptwins-cesium';
9
- import * as utils from "../tool/utils";
10
-
11
- // 视锥体
12
- var BaseFrustum = /*#__PURE__*/function () {
13
- function BaseFrustum(map, options) {
14
- _classCallCheck(this, BaseFrustum);
15
- _defineProperty(this, "_mapContext", void 0);
16
- // 参数
17
- _defineProperty(this, "options", void 0);
18
- // 视锥面
19
- _defineProperty(this, "frustumPrimitive", void 0);
20
- // 视锥线
21
- _defineProperty(this, "frustumLinePrimitive", void 0);
22
- _defineProperty(this, "isDestroyed", false);
23
- this._mapContext = map._mapContext;
24
- this.options = options;
25
- }
26
- _createClass(BaseFrustum, [{
27
- key: "getMap",
28
- value: function getMap() {
29
- return this._mapContext && this._mapContext.getMap();
30
- }
31
-
32
- // 是否能进行操作
33
- }, {
34
- key: "_canOperate",
35
- value: function _canOperate() {
36
- if (this.isDestroyed) {
37
- utils.error('Frustum实例已销毁');
38
- return false;
39
- }
40
- return true;
41
- }
42
-
43
- // 获取顶点坐标
44
- }, {
45
- key: "getFrustumVertexPoints",
46
- value: function getFrustumVertexPoints() {
47
- if (!this._canOperate()) {
48
- return;
49
- }
50
- var geometry = Cesium.FrustumOutlineGeometry.createGeometry(this.frustumPrimitive.geometryInstances.geometry);
51
- var positions = geometry.attributes.position.values;
52
-
53
- // 获取模型变换矩阵
54
- var modelMatrix = this.frustumPrimitive.geometryInstances.modelMatrix;
55
- var result = [];
56
- for (var i = 0; i < positions.length; i += 3) {
57
- var localPosition = new Cesium.Cartesian3(positions[i], positions[i + 1], positions[i + 2]);
58
- // 转换为世界坐标
59
- var worldPosition = Cesium.Matrix4.multiplyByPoint(modelMatrix, localPosition, new Cesium.Cartesian3());
60
- var _utils$cartesian3ToLn = utils.cartesian3ToLngLatAlt(worldPosition),
61
- lng = _utils$cartesian3ToLn.lng,
62
- lat = _utils$cartesian3ToLn.lat,
63
- alt = _utils$cartesian3ToLn.alt;
64
- result.push([lng, lat, alt]);
65
- }
66
- return result;
67
- }
68
-
69
- // 显示隐藏
70
- }, {
71
- key: "show",
72
- value: function show(isShow) {
73
- if (!this._canOperate()) {
74
- return;
75
- }
76
- this.frustumPrimitive && (this.frustumPrimitive.show = isShow);
77
- this.frustumLinePrimitive && (this.frustumLinePrimitive.show = isShow);
78
- }
79
-
80
- // 销毁
81
- }, {
82
- key: "destroy",
83
- value: function destroy() {
84
- if (!this._canOperate()) {
85
- return;
86
- }
87
- this.isDestroyed = true;
88
- this.frustumPrimitive && this.getMap().scene.primitives.remove(this.frustumPrimitive);
89
- this.frustumPrimitive = null;
90
- this.frustumLinePrimitive && this.getMap().scene.primitives.remove(this.frustumLinePrimitive);
91
- this.frustumLinePrimitive = null;
92
- }
93
- }]);
94
- return BaseFrustum;
95
- }();
96
- export { BaseFrustum as default };
@@ -1,5 +0,0 @@
1
- import BaseFrustum from './BaseFrustum';
2
- export default class FrustumWithCamera extends BaseFrustum {
3
- constructor(map: any, options: any);
4
- private _addFrustum;
5
- }
@@ -1,133 +0,0 @@
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 _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
- 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); }
13
- 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); }
14
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
15
- 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); }; }
16
- 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); }
17
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18
- 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; } }
19
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
20
- import * as Cesium from 'deeptwins-cesium';
21
- import { v4 as uuidv4 } from 'uuid';
22
- import * as utils from "../tool/utils";
23
- import BaseFrustum from "./BaseFrustum";
24
-
25
- // 视锥体以当前camera为方向
26
- var FrustumWithCamera = /*#__PURE__*/function (_BaseFrustum) {
27
- _inherits(FrustumWithCamera, _BaseFrustum);
28
- var _super = _createSuper(FrustumWithCamera);
29
- function FrustumWithCamera(map, options) {
30
- var _this;
31
- _classCallCheck(this, FrustumWithCamera);
32
- _this = _super.call(this, map, options);
33
- _this._addFrustum();
34
- return _this;
35
- }
36
- _createClass(FrustumWithCamera, [{
37
- key: "_addFrustum",
38
- value: function _addFrustum() {
39
- var _this$options = this.options,
40
- _this$options$show = _this$options.show,
41
- show = _this$options$show === void 0 ? true : _this$options$show,
42
- _this$options$positio = _this$options.position,
43
- position = _this$options$positio === void 0 ? [] : _this$options$positio,
44
- fov = _this$options.fov,
45
- near = _this$options.near,
46
- far = _this$options.far,
47
- aspectRatio = _this$options.aspectRatio,
48
- _this$options$fill = _this$options.fill,
49
- fill = _this$options$fill === void 0 ? true : _this$options$fill,
50
- _this$options$color = _this$options.color,
51
- color = _this$options$color === void 0 ? 'rgba(255,0,0,0.3)' : _this$options$color,
52
- _this$options$outline = _this$options.outline,
53
- outline = _this$options$outline === void 0 ? true : _this$options$outline,
54
- _this$options$outline2 = _this$options.outlineColor,
55
- outlineColor = _this$options$outline2 === void 0 ? '#ffffff' : _this$options$outline2,
56
- _this$options$camera = _this$options.camera,
57
- camera = _this$options$camera === void 0 ? this.getMap().camera : _this$options$camera;
58
- var _position = _slicedToArray(position, 3),
59
- lng = _position[0],
60
- lat = _position[1],
61
- alt = _position[2];
62
- var positionCartesian3 = utils.lngLatAltToCartesian3(lng, lat, alt);
63
- var frustum = new Cesium.PerspectiveFrustum({
64
- // 查看的视场角,绕Z轴旋转,以弧度方式输入
65
- fov: fov ? utils.toRadians(fov) : camera.frustum.fov,
66
- // 视锥体的宽度/高度
67
- aspectRatio: aspectRatio ? aspectRatio : camera.frustum.aspectRatio,
68
- // 近面距视点的距离
69
- near: near ? near : camera.frustum.near,
70
- // 远面距视点的距离
71
- far: far ? far : camera.frustum.far
72
- });
73
-
74
- // 计算摄像机的方向四元数
75
- var direction = Cesium.Cartesian3.clone(camera.directionWC);
76
- var up = Cesium.Cartesian3.clone(camera.upWC);
77
- var right = Cesium.Cartesian3.clone(camera.rightWC);
78
- var rotationMatrix = new Cesium.Matrix3();
79
- Cesium.Matrix3.setColumn(rotationMatrix, 0, right, rotationMatrix); // X 轴
80
- Cesium.Matrix3.setColumn(rotationMatrix, 1, up, rotationMatrix); // Y 轴
81
- Cesium.Matrix3.setColumn(rotationMatrix, 2, direction, rotationMatrix); // Z 轴
82
- var modelMatrix = Cesium.Matrix4.fromRotationTranslation(rotationMatrix, positionCartesian3);
83
- this.frustumPrimitive = new Cesium.Primitive({
84
- geometryInstances: new Cesium.GeometryInstance({
85
- id: uuidv4(),
86
- geometry: new Cesium.FrustumGeometry({
87
- frustum: frustum,
88
- origin: Cesium.Cartesian3.ZERO,
89
- orientation: Cesium.Quaternion.IDENTITY
90
- }),
91
- modelMatrix: modelMatrix,
92
- attributes: {
93
- color: fill ? utils.colorInstanceString(color) : utils.colorInstanceString('rgba(0, 0, 0, 0)')
94
- }
95
- }),
96
- releaseGeometryInstances: false,
97
- appearance: new Cesium.PerInstanceColorAppearance({
98
- closed: true,
99
- flat: true
100
- }),
101
- asynchronous: false
102
- });
103
- this.frustumPrimitive.show = show;
104
- this.getMap().scene.primitives.add(this.frustumPrimitive);
105
- if (outline) {
106
- this.frustumLinePrimitive = new Cesium.Primitive({
107
- geometryInstances: new Cesium.GeometryInstance({
108
- id: uuidv4(),
109
- geometry: new Cesium.FrustumOutlineGeometry({
110
- frustum: frustum,
111
- origin: Cesium.Cartesian3.ZERO,
112
- orientation: Cesium.Quaternion.IDENTITY
113
- }),
114
- modelMatrix: modelMatrix,
115
- attributes: {
116
- color: utils.colorInstanceString(outlineColor)
117
- }
118
- }),
119
- releaseGeometryInstances: false,
120
- appearance: new Cesium.PerInstanceColorAppearance({
121
- closed: true,
122
- flat: true
123
- }),
124
- asynchronous: false
125
- });
126
- this.frustumLinePrimitive.show = show;
127
- this.getMap().scene.primitives.add(this.frustumLinePrimitive);
128
- }
129
- }
130
- }]);
131
- return FrustumWithCamera;
132
- }(BaseFrustum);
133
- export { FrustumWithCamera as default };