deeptwins-engine-3d 0.1.43 → 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.
- package/dist/esm/graphicLayer/BaseSource.d.ts +1 -1
- package/dist/esm/index.js +3 -2
- package/dist/esm/lowAltitude/FlightPlanning.js +10 -25
- package/dist/esm/lowAltitude/FlightRiskEvaluation.js +383 -0
- package/dist/esm/tool/common.d.ts +1 -0
- package/dist/esm/tool/common.js +13 -1
- package/dist/esm/tool/fetch.d.ts +51 -0
- package/dist/esm/tool/fetch.js +222 -0
- package/dist/esm/videoFusion/BaseVideo.d.ts +1 -1
- package/dist/esm/videoFusion/BaseVideo.js +47 -2
- package/dist/esm/videoFusion/VideoProject.js +3 -0
- package/dist/esm/videoFusion/VideoTexture.js +3 -0
- package/dist/umd/deeptwins-engine-3d.min.js +1 -1
- package/package.json +2 -2
- package/dist/esm/lowAltitude/RiskEvaluation.js +0 -0
- /package/dist/esm/lowAltitude/{RiskEvaluation.d.ts → FlightRiskEvaluation.d.ts} +0 -0
|
@@ -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
|
-
|
|
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
|