deeptwins-engine-3d 0.1.42 → 0.1.44

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 (35) hide show
  1. package/dist/esm/analyze/ViewshedAnalysis.d.ts +8 -8
  2. package/dist/esm/analyze/ViewshedAnalysis.js +76 -90
  3. package/dist/esm/constant.d.ts +44 -6
  4. package/dist/esm/constant.js +86 -7
  5. package/dist/esm/deepTwins/index.js +2 -1
  6. package/dist/esm/drawer/index.d.ts +1 -1
  7. package/dist/esm/index.d.ts +4 -1
  8. package/dist/esm/index.js +12 -5
  9. package/dist/esm/lowAltitude/BarrierLayer.d.ts +29 -0
  10. package/dist/esm/{tileLayer → lowAltitude}/BarrierLayer.js +39 -165
  11. package/dist/esm/lowAltitude/BaseGridMvtLayer.d.ts +34 -0
  12. package/dist/esm/lowAltitude/BaseGridMvtLayer.js +122 -0
  13. package/dist/esm/lowAltitude/FlightPlanning.d.ts +27 -0
  14. package/dist/esm/lowAltitude/FlightPlanning.js +411 -0
  15. package/dist/esm/lowAltitude/FlightRiskEvaluation.d.ts +0 -0
  16. package/dist/esm/lowAltitude/FlightRiskEvaluation.js +383 -0
  17. package/dist/esm/{visualization/Airspace.d.ts → lowAltitude/GridDraw.d.ts} +2 -1
  18. package/dist/esm/{visualization/Airspace.js → lowAltitude/GridDraw.js} +9 -9
  19. package/dist/esm/lowAltitude/PoiLayer.d.ts +13 -0
  20. package/dist/esm/lowAltitude/PoiLayer.js +74 -0
  21. package/dist/esm/lowAltitude/VisitLayer.d.ts +26 -0
  22. package/dist/esm/lowAltitude/VisitLayer.js +180 -0
  23. package/dist/esm/map/Map.js +3 -3
  24. package/dist/esm/tool/common.d.ts +2 -1
  25. package/dist/esm/tool/common.js +14 -2
  26. package/dist/esm/tool/fetch.d.ts +51 -0
  27. package/dist/esm/tool/fetch.js +222 -0
  28. package/dist/esm/videoFusion/BaseVideo.d.ts +1 -1
  29. package/dist/esm/videoFusion/BaseVideo.js +47 -2
  30. package/dist/esm/videoFusion/VideoProject.js +3 -0
  31. package/dist/esm/videoFusion/VideoTexture.js +3 -0
  32. package/dist/esm/visualization/FrustumWithCamera.js +10 -8
  33. package/dist/umd/deeptwins-engine-3d.min.js +1 -1
  34. package/package.json +2 -2
  35. package/dist/esm/tileLayer/BarrierLayer.d.ts +0 -76
@@ -0,0 +1,180 @@
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; }
4
+ 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; }
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
+ 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); } }
7
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
+ 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); }
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
+ import * as Cesium from 'deeptwins-cesium';
18
+ import BaseGridMvtLayer from "./BaseGridMvtLayer";
19
+
20
+ // 客流图层 - 基于MVT数据渲染网格
21
+ var VisitLayer = /*#__PURE__*/function (_BaseGridMvtLayer) {
22
+ _inherits(VisitLayer, _BaseGridMvtLayer);
23
+ var _super = _createSuper(VisitLayer);
24
+ function VisitLayer(map) {
25
+ var _this;
26
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
27
+ _classCallCheck(this, VisitLayer);
28
+ _this = _super.call(this, map, _objectSpread({
29
+ dataType: 'flow'
30
+ }, options));
31
+ _this.createMvtLayer({
32
+ createPrimitives: function createPrimitives(tileNum, renderData, viewer) {
33
+ var targetViewer = viewer || _this.getMap();
34
+ return _this._createPrimitives(tileNum, renderData, targetViewer);
35
+ },
36
+ destroyPrimitives: function destroyPrimitives(tileNum, primitives) {
37
+ return _this._destroyPrimitives(tileNum, primitives);
38
+ },
39
+ showPrimitives: function showPrimitives(tileNum, primitives) {
40
+ return _this._showPrimitives(tileNum, primitives);
41
+ },
42
+ hidePrimitives: function hidePrimitives(tileNum, primitives) {
43
+ return _this._hidePrimitives(tileNum, primitives);
44
+ },
45
+ updatePrimitives: function updatePrimitives(tileNum, primitives) {
46
+ return _this._updatePrimitives(tileNum, primitives);
47
+ }
48
+ });
49
+ return _this;
50
+ }
51
+
52
+ /**
53
+ * 创建primitives
54
+ * 按照示例代码的逻辑实现,每个feature创建一个障碍物实例
55
+ */
56
+ _createClass(VisitLayer, [{
57
+ key: "_createPrimitives",
58
+ value: function _createPrimitives(tileNum, renderData, viewer) {
59
+ if (!this._isViewerReady()) {
60
+ return [];
61
+ }
62
+ var heightColors = this.options.heightColors;
63
+ var features = (renderData === null || renderData === void 0 ? void 0 : renderData.default) || [];
64
+ var instances = [];
65
+ for (var i = 0; i < features.length; i++) {
66
+ var _feature$properties;
67
+ var feature = features[i];
68
+ if (!feature || !feature.lnglat || !feature.gridSize) {
69
+ continue;
70
+ }
71
+ if (!this._isViewerReady()) {
72
+ return [];
73
+ }
74
+ var lnglat = [feature.lnglat[0], feature.lnglat[1], 100];
75
+ var modelMatrix = Cesium.Matrix4.multiplyByTranslation(Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(lnglat[0], lnglat[1], lnglat[2])), new Cesium.Cartesian3(0, 0, 0), new Cesium.Matrix4());
76
+ var flowValue = ((_feature$properties = feature.properties) === null || _feature$properties === void 0 ? void 0 : _feature$properties.flow) || 0;
77
+ var colorIndex = Math.floor(flowValue / 150);
78
+ var color = heightColors[colorIndex] || '#d8daeb';
79
+ var instance = new Cesium.GeometryInstance({
80
+ geometry: Cesium.BoxGeometry.fromDimensions({
81
+ vertexFormat: Cesium.VertexFormat.POSITION_AND_NORMAL,
82
+ dimensions: new Cesium.Cartesian3(feature.gridSize[0], feature.gridSize[1], feature.gridSize[1])
83
+ }),
84
+ modelMatrix: modelMatrix,
85
+ attributes: {
86
+ color: Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.fromCssColorString(color))
87
+ }
88
+ });
89
+ instances.push(instance);
90
+ }
91
+ if (!this._isViewerReady() || instances.length === 0) {
92
+ return [];
93
+ }
94
+ var primitive = new Cesium.Primitive({
95
+ geometryInstances: instances,
96
+ appearance: new Cesium.PerInstanceColorAppearance({
97
+ translucent: false,
98
+ closed: true
99
+ })
100
+ });
101
+ if (this._isViewerReady()) {
102
+ viewer.scene.primitives.add(primitive);
103
+ }
104
+ return [primitive];
105
+ }
106
+
107
+ /**
108
+ * 销毁primitives
109
+ */
110
+ }, {
111
+ key: "_destroyPrimitives",
112
+ value: function _destroyPrimitives(tileNum, primitives) {
113
+ var _this2 = this;
114
+ if (!(primitives !== null && primitives !== void 0 && primitives.length)) return;
115
+ primitives.forEach(function (primitive) {
116
+ if (!primitive) {
117
+ return;
118
+ }
119
+ try {
120
+ primitive.show = false;
121
+ if (_this2._isViewerReady()) {
122
+ var isDestroyed = typeof primitive.isDestroyed === 'function' ? primitive.isDestroyed() : false;
123
+ if (!isDestroyed) {
124
+ _this2.getMap().scene.primitives.remove(primitive);
125
+ }
126
+ if (typeof primitive.destroy === 'function' && !isDestroyed) {
127
+ primitive.destroy();
128
+ }
129
+ }
130
+ } catch (error) {
131
+ console.warn('销毁 primitive 失败', error);
132
+ }
133
+ });
134
+ primitives.length = 0;
135
+ }
136
+
137
+ /**
138
+ * 显示primitives
139
+ */
140
+ }, {
141
+ key: "_showPrimitives",
142
+ value: function _showPrimitives(tileNum, primitives) {
143
+ if (!(primitives !== null && primitives !== void 0 && primitives.length)) {
144
+ return;
145
+ }
146
+ primitives.forEach(function (primitive) {
147
+ if (primitive && typeof primitive.isDestroyed === 'function' && !primitive.isDestroyed()) {
148
+ primitive.show = true;
149
+ }
150
+ });
151
+ }
152
+
153
+ /**
154
+ * 隐藏primitives
155
+ */
156
+ }, {
157
+ key: "_hidePrimitives",
158
+ value: function _hidePrimitives(tileNum, primitives) {
159
+ if (!(primitives !== null && primitives !== void 0 && primitives.length)) {
160
+ return;
161
+ }
162
+ primitives.forEach(function (primitive) {
163
+ if (primitive && typeof primitive.isDestroyed === 'function' && !primitive.isDestroyed()) {
164
+ primitive.show = false;
165
+ }
166
+ });
167
+ }
168
+
169
+ /**
170
+ * 更新primitives
171
+ */
172
+ }, {
173
+ key: "_updatePrimitives",
174
+ value: function _updatePrimitives(_tileNum, _primitives) {
175
+ // 预留接口,可根据需要实现更新逻辑
176
+ }
177
+ }]);
178
+ return VisitLayer;
179
+ }(BaseGridMvtLayer);
180
+ export default VisitLayer;
@@ -80,11 +80,11 @@ var Map = /*#__PURE__*/function (_Cesium$Viewer) {
80
80
  _defineProperty(_assertThisInitialized(_this), "_event", void 0);
81
81
  // 默认的事件监听
82
82
  _defineProperty(_assertThisInitialized(_this), "_eventTrick", []);
83
- // 添加yunjing module
83
+ // 添加yunjing 模型
84
84
  _defineProperty(_assertThisInitialized(_this), "addModuleLayer", function (moduleLayer) {
85
- _this._yunjing = _this._yunjing || moduleLayer.addToMap(_assertThisInitialized(_this));
85
+ var yunjing = moduleLayer.addToMap(_assertThisInitialized(_this));
86
86
  common.removeYjIcon();
87
- return _this._yunjing;
87
+ return yunjing;
88
88
  });
89
89
  _this._mapContext = {
90
90
  getMap: _this.getMap.bind(_assertThisInitialized(_this))
@@ -17,7 +17,7 @@ export declare const lineClampToGroundSplit: ({ map, pos1, pos2, splitNum, }: {
17
17
  */
18
18
  export declare const findWindowPositionByPixelInterval: (startPosition: Cartesian2, endPosition: Cartesian2, interval: number) => Cartesian2;
19
19
  export declare class ShapeSection {
20
- static circleSection(radius: number): Cesium.Cartesian2[];
20
+ static circleSection(radius: number, segments?: number): Cesium.Cartesian2[];
21
21
  static rectangleSection(width: number, height: number): Cesium.Cartesian2[];
22
22
  static triangleSection(base: number, height: number): Cesium.Cartesian2[];
23
23
  }
@@ -36,3 +36,4 @@ export declare class ClampToGround {
36
36
  features: any[];
37
37
  }>;
38
38
  }
39
+ export declare function translateSource(source: any): any;
@@ -81,8 +81,8 @@ export var ShapeSection = /*#__PURE__*/function () {
81
81
  value:
82
82
  // 圆形截面(单位米)
83
83
  function circleSection(radius) {
84
+ var segments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 360;
84
85
  var shape = [];
85
- var segments = 360;
86
86
  for (var i = 0; i < segments; i++) {
87
87
  var angle = i / segments * Math.PI * 2; // 角度
88
88
  shape.push(new Cesium.Cartesian2(Math.cos(angle) * radius, Math.sin(angle) * radius));
@@ -390,4 +390,16 @@ export var ClampToGround = /*#__PURE__*/function () {
390
390
  }()
391
391
  }]);
392
392
  return ClampToGround;
393
- }();
393
+ }();
394
+
395
+ // 数据类型转换
396
+ export function translateSource(source) {
397
+ var sourceType = BaseSource.analysisSourceType(source);
398
+ if (sourceType === 'geoJson') {
399
+ return source;
400
+ } else if (sourceType === 'wkt') {
401
+ return BaseSource.wktToGeoJon(source);
402
+ } else {
403
+ throw new Error('数据格式错误');
404
+ }
405
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Fetch 请求配置选项
3
+ */
4
+ export interface FetchUrlOptions {
5
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
6
+ headers?: Record<string, string>;
7
+ body?: any;
8
+ timeout?: number;
9
+ params?: Record<string, any>;
10
+ responseType?: 'json' | 'text' | 'blob' | 'arrayBuffer';
11
+ credentials?: RequestCredentials;
12
+ }
13
+ /**
14
+ * Fetch 请求响应
15
+ */
16
+ export interface FetchUrlResponse<T = any> {
17
+ data: T;
18
+ status: number;
19
+ statusText: string;
20
+ headers: Headers;
21
+ }
22
+ /**
23
+ * 封装的 fetch 请求函数
24
+ * @param url 请求地址
25
+ * @param options 请求配置
26
+ * @returns Promise<FetchUrlResponse>
27
+ */
28
+ export declare function fetchUrl<T = any>(url: string, options?: FetchUrlOptions): Promise<FetchUrlResponse<T>>;
29
+ /**
30
+ * GET 请求快捷方法
31
+ */
32
+ export declare function get<T = any>(url: string, params?: Record<string, any>, options?: Omit<FetchUrlOptions, 'method' | 'body' | 'params'>): Promise<FetchUrlResponse<T>>;
33
+ /**
34
+ * POST 请求快捷方法
35
+ */
36
+ export declare function post<T = any>(url: string, body?: any, options?: Omit<FetchUrlOptions, 'method' | 'body'>): Promise<FetchUrlResponse<T>>;
37
+ /**
38
+ * PUT 请求快捷方法
39
+ */
40
+ export declare function put<T = any>(url: string, body?: any, options?: Omit<FetchUrlOptions, 'method' | 'body'>): Promise<FetchUrlResponse<T>>;
41
+ /**
42
+ * DELETE 请求快捷方法
43
+ */
44
+ export declare function del<T = any>(url: string, body?: any, options?: Omit<FetchUrlOptions, 'method' | 'body'>): Promise<FetchUrlResponse<T>>;
45
+ declare const _default: {
46
+ get: typeof get;
47
+ post: typeof post;
48
+ put: typeof put;
49
+ delete: typeof del;
50
+ };
51
+ export default _default;
@@ -0,0 +1,222 @@
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 _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ 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; }
4
+ 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; }
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
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
9
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
10
+ /**
11
+ * Fetch 请求配置选项
12
+ */
13
+
14
+ /**
15
+ * Fetch 请求响应
16
+ */
17
+
18
+ /**
19
+ * 封装的 fetch 请求函数
20
+ * @param url 请求地址
21
+ * @param options 请求配置
22
+ * @returns Promise<FetchUrlResponse>
23
+ */
24
+ export function fetchUrl(_x) {
25
+ return _fetchUrl.apply(this, arguments);
26
+ }
27
+
28
+ /**
29
+ * GET 请求快捷方法
30
+ */
31
+ function _fetchUrl() {
32
+ _fetchUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
33
+ var options,
34
+ _options$method,
35
+ method,
36
+ _options$headers,
37
+ headers,
38
+ body,
39
+ _options$timeout,
40
+ timeout,
41
+ params,
42
+ _options$responseType,
43
+ responseType,
44
+ _options$credentials,
45
+ credentials,
46
+ requestUrl,
47
+ urlObj,
48
+ config,
49
+ controller,
50
+ timeoutId,
51
+ response,
52
+ data,
53
+ _data,
54
+ error,
55
+ timeoutError,
56
+ networkError,
57
+ _args = arguments;
58
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
59
+ while (1) switch (_context.prev = _context.next) {
60
+ case 0:
61
+ options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
62
+ _options$method = options.method, method = _options$method === void 0 ? 'GET' : _options$method, _options$headers = options.headers, headers = _options$headers === void 0 ? {} : _options$headers, body = options.body, _options$timeout = options.timeout, timeout = _options$timeout === void 0 ? 30000 : _options$timeout, params = options.params, _options$responseType = options.responseType, responseType = _options$responseType === void 0 ? 'json' : _options$responseType, _options$credentials = options.credentials, credentials = _options$credentials === void 0 ? 'same-origin' : _options$credentials; // 构建 URL 和查询参数
63
+ requestUrl = url;
64
+ if (params && Object.keys(params).length > 0) {
65
+ urlObj = new URL(url, window.location.href);
66
+ Object.keys(params).forEach(function (key) {
67
+ var value = params[key];
68
+ if (value !== null && value !== undefined) {
69
+ urlObj.searchParams.append(key, String(value));
70
+ }
71
+ });
72
+ requestUrl = urlObj.toString();
73
+ }
74
+
75
+ // 构建请求配置
76
+ config = {
77
+ method: method,
78
+ headers: _objectSpread({
79
+ 'Content-Type': 'application/json'
80
+ }, headers),
81
+ credentials: credentials
82
+ }; // 添加请求体
83
+ if (body && ['POST', 'PUT', 'PATCH'].includes(method)) {
84
+ if (typeof body === 'string') {
85
+ config.body = body;
86
+ } else {
87
+ config.body = JSON.stringify(body);
88
+ }
89
+ }
90
+
91
+ // 创建超时控制
92
+ controller = new AbortController();
93
+ timeoutId = setTimeout(function () {
94
+ return controller.abort();
95
+ }, timeout);
96
+ config.signal = controller.signal;
97
+ _context.prev = 9;
98
+ _context.next = 12;
99
+ return fetch(requestUrl, config);
100
+ case 12:
101
+ response = _context.sent;
102
+ clearTimeout(timeoutId);
103
+
104
+ // 获取响应数据
105
+ _context.t0 = responseType;
106
+ _context.next = _context.t0 === 'json' ? 17 : _context.t0 === 'text' ? 21 : _context.t0 === 'blob' ? 25 : _context.t0 === 'arrayBuffer' ? 29 : 33;
107
+ break;
108
+ case 17:
109
+ _context.next = 19;
110
+ return response.json();
111
+ case 19:
112
+ data = _context.sent;
113
+ return _context.abrupt("break", 36);
114
+ case 21:
115
+ _context.next = 23;
116
+ return response.text();
117
+ case 23:
118
+ data = _context.sent;
119
+ return _context.abrupt("break", 36);
120
+ case 25:
121
+ _context.next = 27;
122
+ return response.blob();
123
+ case 27:
124
+ data = _context.sent;
125
+ return _context.abrupt("break", 36);
126
+ case 29:
127
+ _context.next = 31;
128
+ return response.arrayBuffer();
129
+ case 31:
130
+ data = _context.sent;
131
+ return _context.abrupt("break", 36);
132
+ case 33:
133
+ _context.next = 35;
134
+ return response.json();
135
+ case 35:
136
+ data = _context.sent;
137
+ case 36:
138
+ if (response.ok) {
139
+ _context.next = 41;
140
+ break;
141
+ }
142
+ error = new Error(((_data = data) === null || _data === void 0 ? void 0 : _data.message) || "HTTP ".concat(response.status, ": ").concat(response.statusText));
143
+ error.status = response.status;
144
+ error.data = data;
145
+ throw error;
146
+ case 41:
147
+ return _context.abrupt("return", {
148
+ data: data,
149
+ status: response.status,
150
+ statusText: response.statusText,
151
+ headers: response.headers
152
+ });
153
+ case 44:
154
+ _context.prev = 44;
155
+ _context.t1 = _context["catch"](9);
156
+ if (!(_context.t1.name === 'AbortError')) {
157
+ _context.next = 50;
158
+ break;
159
+ }
160
+ timeoutError = new Error("\u8BF7\u6C42\u8D85\u65F6\uFF08".concat(timeout, "ms\uFF09"));
161
+ timeoutError.code = 'TIMEOUT';
162
+ throw timeoutError;
163
+ case 50:
164
+ if (!(_context.t1 instanceof TypeError)) {
165
+ _context.next = 54;
166
+ break;
167
+ }
168
+ networkError = new Error('网络连接失败,请检查网络设置');
169
+ networkError.code = 'NETWORK_ERROR';
170
+ throw networkError;
171
+ case 54:
172
+ throw _context.t1;
173
+ case 55:
174
+ case "end":
175
+ return _context.stop();
176
+ }
177
+ }, _callee, null, [[9, 44]]);
178
+ }));
179
+ return _fetchUrl.apply(this, arguments);
180
+ }
181
+ export function get(url, params, options) {
182
+ return fetchUrl(url, _objectSpread(_objectSpread({}, options), {}, {
183
+ method: 'GET',
184
+ params: params
185
+ }));
186
+ }
187
+
188
+ /**
189
+ * POST 请求快捷方法
190
+ */
191
+ export function post(url, body, options) {
192
+ return fetchUrl(url, _objectSpread(_objectSpread({}, options), {}, {
193
+ method: 'POST',
194
+ body: body
195
+ }));
196
+ }
197
+
198
+ /**
199
+ * PUT 请求快捷方法
200
+ */
201
+ export function put(url, body, options) {
202
+ return fetchUrl(url, _objectSpread(_objectSpread({}, options), {}, {
203
+ method: 'PUT',
204
+ body: body
205
+ }));
206
+ }
207
+
208
+ /**
209
+ * DELETE 请求快捷方法
210
+ */
211
+ export function del(url, body, options) {
212
+ return fetchUrl(url, _objectSpread(_objectSpread({}, options), {}, {
213
+ method: 'DELETE',
214
+ body: body
215
+ }));
216
+ }
217
+ export default {
218
+ get: get,
219
+ post: post,
220
+ put: put,
221
+ delete: del
222
+ };
@@ -5,7 +5,7 @@ export default class BaseVideo {
5
5
  videoElement: any;
6
6
  videoPolygonLayer: any;
7
7
  isDestroyed: boolean;
8
- videoType: 'video' | 'hls' | '';
8
+ videoType: 'video' | 'hls' | 'custom' | '';
9
9
  status: 'PREPARE' | 'READY' | 'START' | 'PLAYING' | 'PAUSE';
10
10
  synchronizer: any;
11
11
  hls: any;
@@ -35,6 +35,9 @@ var BaseVideo = /*#__PURE__*/function () {
35
35
  if (options.hls) {
36
36
  this.videoType = 'hls';
37
37
  }
38
+ if (options.custom) {
39
+ this.videoType = 'custom';
40
+ }
38
41
  this._init();
39
42
  this._initMaskImage();
40
43
  }
@@ -124,6 +127,18 @@ var BaseVideo = /*#__PURE__*/function () {
124
127
  }
125
128
  });
126
129
  }
130
+ } else if (this.videoType === 'custom') {
131
+ var _this$options$custom = this.options.custom,
132
+ _width2 = _this$options$custom.width,
133
+ _height2 = _this$options$custom.height,
134
+ onReady = _this$options$custom.onReady;
135
+ this.videoElement.width = _width2;
136
+ this.videoElement.height = _height2;
137
+ videoContainer.appendChild(this.videoElement);
138
+ if (onReady) {
139
+ this.status = 'READY';
140
+ onReady(this.videoElement, this.play, this.pause);
141
+ }
127
142
  }
128
143
  }
129
144
 
@@ -142,17 +157,30 @@ var BaseVideo = /*#__PURE__*/function () {
142
157
  key: "_drawCanvas",
143
158
  value: function _drawCanvas(options) {
144
159
  var width = options.width,
145
- height = options.height;
160
+ height = options.height,
161
+ _options$featherSize = options.featherSize,
162
+ featherSize = _options$featherSize === void 0 ? 100 : _options$featherSize;
146
163
  var canvas = document.createElement('canvas');
147
164
  canvas.width = width;
148
165
  canvas.height = height;
149
166
  var ctx = canvas.getContext('2d');
167
+
150
168
  // 1. 叠加当前视频帧
151
169
  ctx.globalAlpha = 1.0; // 确保视频帧不透明
152
170
  ctx.drawImage(this.videoElement, 0, 0, width, height);
171
+
153
172
  // 2. 应用羽化遮罩
154
173
  ctx.globalCompositeOperation = 'destination-in'; // 使用遮罩影响透明度
155
- ctx.drawImage(this._maskImage, 0, 0, width, height);
174
+
175
+ var maskCanvas = document.createElement('canvas');
176
+ maskCanvas.width = width;
177
+ maskCanvas.height = height;
178
+ var maskCtx = maskCanvas.getContext('2d');
179
+ if (maskCtx && this._maskImage) {
180
+ // 绘制并拉伸遮罩图片到整个画布
181
+ maskCtx.drawImage(this._maskImage, 0, 0, width, height);
182
+ ctx.drawImage(maskCanvas, 0, 0);
183
+ }
156
184
  ctx.globalCompositeOperation = 'source-over'; // 还原默认混合模式
157
185
  return canvas;
158
186
  }
@@ -213,6 +241,16 @@ var BaseVideo = /*#__PURE__*/function () {
213
241
  });
214
242
  }
215
243
  }
244
+ if (this.synchronizer && this.videoType === 'custom') {
245
+ this.getMap().clock.shouldAnimate = true;
246
+ }
247
+ if (!this.synchronizer && this.videoType === 'custom') {
248
+ this.synchronizer = new Cesium.VideoSynchronizer({
249
+ clock: this.getMap().clock,
250
+ element: this.videoElement
251
+ });
252
+ this.getMap().clock.shouldAnimate = true;
253
+ }
216
254
  }
217
255
 
218
256
  // 监听错误
@@ -234,6 +272,9 @@ var BaseVideo = /*#__PURE__*/function () {
234
272
  this.hls.stopLoad();
235
273
  this.getMap().clock.shouldAnimate = false;
236
274
  }
275
+ if (this.videoType === 'custom') {
276
+ this.getMap().clock.shouldAnimate = false;
277
+ }
237
278
  this.videoElement.pause();
238
279
  }
239
280
 
@@ -277,6 +318,10 @@ var BaseVideo = /*#__PURE__*/function () {
277
318
  this.hls && this.hls.destroyed();
278
319
  this.getMap().clock.shouldAnimate = false;
279
320
  }
321
+ if (this.videoType === 'custom') {
322
+ this.synchronizer && this.synchronizer.destroy();
323
+ this.getMap().clock.shouldAnimate = false;
324
+ }
280
325
  this.videoElement.remove();
281
326
  this.videoPolygonLayer.remove();
282
327
  }
@@ -50,6 +50,9 @@ var VideoProject = /*#__PURE__*/function (_BaseVideo) {
50
50
  this.options.hls.autoPlay && this.status === 'READY' && this.play();
51
51
  videoOptions = merge(DEFAULT_VIDEO_TEXTURE_HLS(), this.options.hls);
52
52
  }
53
+ if (this.videoType === 'custom') {
54
+ videoOptions = merge({}, this.options.custom);
55
+ }
53
56
  var _this$options = this.options,
54
57
  _this$options$type = _this$options.type,
55
58
  type = _this$options$type === void 0 ? 'fixed' : _this$options$type,
@@ -46,6 +46,9 @@ var VideoTexture = /*#__PURE__*/function (_BaseVideo) {
46
46
  this.options.hls.autoPlay && this.status === 'READY' && this.play();
47
47
  videoOptions = merge(DEFAULT_VIDEO_TEXTURE_HLS(), this.options.hls);
48
48
  }
49
+ if (this.videoType === 'custom') {
50
+ videoOptions = merge({}, this.options.custom);
51
+ }
49
52
  var _this$options$style = this.options.style,
50
53
  _this$options$style2 = _this$options$style === void 0 ? {
51
54
  edgeFeather: false