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.
- package/dist/esm/analyze/ViewshedAnalysis.js +3 -2
- package/dist/esm/constant.d.ts +11 -0
- package/dist/esm/constant.js +26 -0
- package/dist/esm/graphicLayer/BaseLayer.js +6 -0
- package/dist/esm/graphicLayer/BasePrimitiveInstance.d.ts +2 -0
- package/dist/esm/graphicLayer/BasePrimitiveInstance.js +13 -5
- package/dist/esm/graphicLayer/BaseSource.d.ts +1 -1
- package/dist/esm/graphicLayer/BaseSource.js +6 -0
- package/dist/esm/graphicLayer/PolygonGroundPrimitiveImageMaterialInstance.d.ts +5 -0
- package/dist/esm/graphicLayer/PolygonGroundPrimitiveImageMaterialInstance.js +84 -0
- package/dist/esm/graphicLayer/PolygonPrimitive.js +6 -4
- package/dist/esm/graphicLayer/PolygonPrimitiveImageMaterialInstance.d.ts +5 -0
- package/dist/esm/graphicLayer/PolygonPrimitiveImageMaterialInstance.js +81 -0
- package/dist/esm/graphicLayer/PolygonPrimitiveInstance.d.ts +1 -1
- package/dist/esm/graphicLayer/PolygonPrimitiveInstance.js +8 -23
- package/dist/esm/graphicLayer/PolylineGroundPrimitiveInstance.js +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +6 -4
- package/dist/esm/map/Map.js +1 -1
- package/dist/esm/material/primitive/BaseMaterialAppearance.d.ts +1 -0
- package/dist/esm/material/primitive/BaseMaterialAppearance.js +1 -0
- package/dist/esm/material/primitive/ImageMaterialAppearance.d.ts +10 -0
- package/dist/esm/material/primitive/ImageMaterialAppearance.js +77 -0
- package/dist/esm/material/shader/ImageShader.glsl +22 -0
- package/dist/esm/tool/BuildClampedPolygonGrid.d.ts +11 -0
- package/dist/esm/tool/BuildClampedPolygonGrid.js +151 -0
- package/dist/esm/tool/utils.d.ts +18 -1
- package/dist/esm/tool/utils.js +119 -44
- package/dist/esm/videoFusion/VideoProject.js +1 -1
- package/dist/esm/visualization/Frustum.d.ts +27 -2
- package/dist/esm/visualization/Frustum.js +158 -42
- package/dist/umd/deeptwins-engine-3d.min.js +1 -1
- package/package.json +8 -5
- package/dist/esm/visualization/BaseFrustum.d.ts +0 -14
- package/dist/esm/visualization/BaseFrustum.js +0 -96
- package/dist/esm/visualization/FrustumWithCamera.d.ts +0 -5
- package/dist/esm/visualization/FrustumWithCamera.js +0 -133
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var _excluded = ["color"];
|
|
2
|
+
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); }
|
|
3
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
+
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); } }
|
|
9
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
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
|
+
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; }
|
|
18
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
19
|
+
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); }
|
|
20
|
+
import * as Cesium from 'deeptwins-cesium';
|
|
21
|
+
import { cloneDeep, merge } from 'lodash';
|
|
22
|
+
import { DEFAULT_IMAGE_MATERIAL_STYLE, DEFAULT_MATERIAL_APPEARANCE } from "../../constant";
|
|
23
|
+
import * as utils from "../../tool/utils";
|
|
24
|
+
/* babel-plugin-inline-import '../shader/ImageShader.glsl' */
|
|
25
|
+
var ImageShader = "uniform sampler2D image;\nuniform vec4 color;\nuniform float mixRatio;\n\nczm_material czm_getMaterial(czm_materialInput materialInput) {\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n\n // \u91C7\u6837\u56FE\u7247\n vec4 texColor = texture(image, st);\n\n // \u989C\u8272\u6DF7\u5408\uFF1Amix(\u539F\u59CB\u989C\u8272, \u76EE\u6807\u989C\u8272, mixRatio)\n vec3 mixedColor = mix(texColor.rgb, texColor.rgb * color.rgb, mixRatio);\n\n // \u53D1\u5149\u589E\u5F3A\n material.diffuse = mixedColor * 2.0;\n\n // \u900F\u660E\u5EA6\u968F\u989C\u8272\u53D8\u5316\n material.alpha = texColor.a * mix(color.a, 1.0, 1.0 - mixRatio);\n\n return material;\n}\n";
|
|
26
|
+
import BaseMaterialAppearance from "./BaseMaterialAppearance";
|
|
27
|
+
|
|
28
|
+
// 图片材质 适用于primitive
|
|
29
|
+
var ImageMaterialAppearance = /*#__PURE__*/function (_BaseMaterialAppearan) {
|
|
30
|
+
_inherits(ImageMaterialAppearance, _BaseMaterialAppearan);
|
|
31
|
+
var _super = _createSuper(ImageMaterialAppearance);
|
|
32
|
+
function ImageMaterialAppearance(material, appearance) {
|
|
33
|
+
var _this;
|
|
34
|
+
_classCallCheck(this, ImageMaterialAppearance);
|
|
35
|
+
var mergeMaterial = merge(DEFAULT_IMAGE_MATERIAL_STYLE(), cloneDeep(material || {}));
|
|
36
|
+
_this = _super.call(this, 'ImageMaterialAsset', mergeMaterial);
|
|
37
|
+
_defineProperty(_assertThisInitialized(_this), "currMaterial", void 0);
|
|
38
|
+
_defineProperty(_assertThisInitialized(_this), "currAppearance", void 0);
|
|
39
|
+
_this.currMaterial = ImageMaterialAppearance.handleMaterial(mergeMaterial);
|
|
40
|
+
_this.currAppearance = merge(DEFAULT_MATERIAL_APPEARANCE(), appearance || {});
|
|
41
|
+
_this._createMaterial();
|
|
42
|
+
return _this;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 处理参数
|
|
46
|
+
_createClass(ImageMaterialAppearance, [{
|
|
47
|
+
key: "_createMaterial",
|
|
48
|
+
value: function _createMaterial() {
|
|
49
|
+
this.material = new Cesium.Material({
|
|
50
|
+
fabric: {
|
|
51
|
+
type: this.type,
|
|
52
|
+
uniforms: _objectSpread({}, this.currMaterial),
|
|
53
|
+
source: ImageShader
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
this._createAppearance();
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "_createAppearance",
|
|
60
|
+
value: function _createAppearance() {
|
|
61
|
+
this.appearance = new Cesium.MaterialAppearance(_objectSpread({
|
|
62
|
+
material: this.material
|
|
63
|
+
}, this.currAppearance));
|
|
64
|
+
}
|
|
65
|
+
}], [{
|
|
66
|
+
key: "handleMaterial",
|
|
67
|
+
value: function handleMaterial(style) {
|
|
68
|
+
var color = style.color,
|
|
69
|
+
options = _objectWithoutProperties(style, _excluded);
|
|
70
|
+
var backStyle = _objectSpread({}, options);
|
|
71
|
+
backStyle.color = utils.colorString(color);
|
|
72
|
+
return backStyle;
|
|
73
|
+
}
|
|
74
|
+
}]);
|
|
75
|
+
return ImageMaterialAppearance;
|
|
76
|
+
}(BaseMaterialAppearance);
|
|
77
|
+
export default ImageMaterialAppearance;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
uniform sampler2D image;
|
|
2
|
+
uniform vec4 color;
|
|
3
|
+
uniform float mixRatio;
|
|
4
|
+
|
|
5
|
+
czm_material czm_getMaterial(czm_materialInput materialInput) {
|
|
6
|
+
czm_material material = czm_getDefaultMaterial(materialInput);
|
|
7
|
+
vec2 st = materialInput.st;
|
|
8
|
+
|
|
9
|
+
// 采样图片
|
|
10
|
+
vec4 texColor = texture(image, st);
|
|
11
|
+
|
|
12
|
+
// 颜色混合:mix(原始颜色, 目标颜色, mixRatio)
|
|
13
|
+
vec3 mixedColor = mix(texColor.rgb, texColor.rgb * color.rgb, mixRatio);
|
|
14
|
+
|
|
15
|
+
// 发光增强
|
|
16
|
+
material.diffuse = mixedColor * 2.0;
|
|
17
|
+
|
|
18
|
+
// 透明度随颜色变化
|
|
19
|
+
material.alpha = texColor.a * mix(color.a, 1.0, 1.0 - mixRatio);
|
|
20
|
+
|
|
21
|
+
return material;
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as Cesium from 'deeptwins-cesium';
|
|
2
|
+
/**
|
|
3
|
+
* 构建贴地的多边形网格
|
|
4
|
+
*/
|
|
5
|
+
export default function BuildClampedPolygonGrid(map: any, geoJson: any, gridSize?: number, heightBuffer?: number): Promise<{
|
|
6
|
+
type: string;
|
|
7
|
+
source: {
|
|
8
|
+
positions: Cesium.Cartesian3[];
|
|
9
|
+
indices: number[];
|
|
10
|
+
}[];
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,151 @@
|
|
|
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 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); } }
|
|
4
|
+
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); }); }; }
|
|
5
|
+
import * as Cesium from 'deeptwins-cesium';
|
|
6
|
+
import BaseSource from "../graphicLayer/BaseSource";
|
|
7
|
+
import { translateSource } from "../tool/common";
|
|
8
|
+
import * as utils from "./utils";
|
|
9
|
+
function pointInPolygon(pt, polygon) {
|
|
10
|
+
var inside = false;
|
|
11
|
+
for (var i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
12
|
+
var xi = polygon[i].x,
|
|
13
|
+
yi = polygon[i].y;
|
|
14
|
+
var xj = polygon[j].x,
|
|
15
|
+
yj = polygon[j].y;
|
|
16
|
+
var intersect = yi > pt.y !== yj > pt.y && pt.x < (xj - xi) * (pt.y - yi) / (yj - yi) + xi;
|
|
17
|
+
if (intersect) inside = !inside;
|
|
18
|
+
}
|
|
19
|
+
return inside;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// 修改 buildGridIndices:不删顶点,只生成 polygon 内部三角形索引
|
|
23
|
+
function buildGridIndices(cols, rows, polygon, gridPoints2D, step) {
|
|
24
|
+
var indices = [];
|
|
25
|
+
for (var y = 0; y < rows - 1; y++) {
|
|
26
|
+
for (var x = 0; x < cols - 1; x++) {
|
|
27
|
+
var i0 = y * cols + x;
|
|
28
|
+
var i1 = i0 + 1;
|
|
29
|
+
var i2 = i0 + cols;
|
|
30
|
+
var i3 = i2 + 1;
|
|
31
|
+
|
|
32
|
+
// 三角形中心点,判断是否在 polygon 内
|
|
33
|
+
var cx = (x + 0.5) * step + gridPoints2D[0].x; // 这里偏移加上最小X
|
|
34
|
+
var cy = (y + 0.5) * step + gridPoints2D[0].y; // 偏移加上最小Y
|
|
35
|
+
if (pointInPolygon(new Cesium.Cartesian2(cx, cy), polygon)) {
|
|
36
|
+
indices.push(i0, i1, i2);
|
|
37
|
+
indices.push(i1, i3, i2);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return indices;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 构建贴地的多边形网格
|
|
46
|
+
*/
|
|
47
|
+
export default function BuildClampedPolygonGrid(_x, _x2) {
|
|
48
|
+
return _BuildClampedPolygonGrid.apply(this, arguments);
|
|
49
|
+
}
|
|
50
|
+
function _BuildClampedPolygonGrid() {
|
|
51
|
+
_BuildClampedPolygonGrid = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(map, geoJson) {
|
|
52
|
+
var gridSize,
|
|
53
|
+
heightBuffer,
|
|
54
|
+
translatedSource,
|
|
55
|
+
source,
|
|
56
|
+
finalSource,
|
|
57
|
+
_loop,
|
|
58
|
+
i,
|
|
59
|
+
_args2 = arguments;
|
|
60
|
+
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
61
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
62
|
+
case 0:
|
|
63
|
+
gridSize = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : 10;
|
|
64
|
+
heightBuffer = _args2.length > 3 && _args2[3] !== undefined ? _args2[3] : 0.5;
|
|
65
|
+
if (!(!map.terrainProvider || map.terrainProvider instanceof Cesium.EllipsoidTerrainProvider)) {
|
|
66
|
+
_context2.next = 4;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
throw new Error('请设置地形');
|
|
70
|
+
case 4:
|
|
71
|
+
translatedSource = translateSource(geoJson);
|
|
72
|
+
source = BaseSource.geoJsonToGeoCartesian3Array(translatedSource);
|
|
73
|
+
finalSource = [];
|
|
74
|
+
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
75
|
+
var positions, ring, center, plane, poly2D, minX, minY, maxX, maxY, cols, rows, gridPoints2D, y, x, indices, positions3D, cartographics, clamped, finalPositions;
|
|
76
|
+
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
77
|
+
while (1) switch (_context.prev = _context.next) {
|
|
78
|
+
case 0:
|
|
79
|
+
positions = source[i].positions; // 1️⃣ 去闭合
|
|
80
|
+
ring = utils.buildPolygonHierarchy(positions).positions; // 2️⃣ 局部切平面
|
|
81
|
+
center = Cesium.BoundingSphere.fromPoints(ring).center;
|
|
82
|
+
plane = new Cesium.EllipsoidTangentPlane(center, Cesium.Ellipsoid.WGS84); // 3️⃣ 投影到 2D
|
|
83
|
+
poly2D = ring.map(function (p) {
|
|
84
|
+
return plane.projectPointOntoPlane(p);
|
|
85
|
+
}); // 4️⃣ 包围盒
|
|
86
|
+
minX = Infinity, minY = Infinity;
|
|
87
|
+
maxX = -Infinity, maxY = -Infinity;
|
|
88
|
+
poly2D.forEach(function (p) {
|
|
89
|
+
minX = Math.min(minX, p.x);
|
|
90
|
+
minY = Math.min(minY, p.y);
|
|
91
|
+
maxX = Math.max(maxX, p.x);
|
|
92
|
+
maxY = Math.max(maxY, p.y);
|
|
93
|
+
});
|
|
94
|
+
cols = Math.floor((maxX - minX) / gridSize) + 1;
|
|
95
|
+
rows = Math.floor((maxY - minY) / gridSize) + 1; // 5️⃣ 生成完整规则网格点(不删点)
|
|
96
|
+
gridPoints2D = [];
|
|
97
|
+
for (y = 0; y < rows; y++) {
|
|
98
|
+
for (x = 0; x < cols; x++) {
|
|
99
|
+
gridPoints2D.push(new Cesium.Cartesian2(minX + x * gridSize, minY + y * gridSize));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// 6️⃣ 生成三角形索引(只保留 polygon 内部三角形)
|
|
104
|
+
indices = buildGridIndices(cols, rows, poly2D, gridPoints2D, gridSize); // 7️⃣ 回投 3D
|
|
105
|
+
positions3D = gridPoints2D.map(function (p) {
|
|
106
|
+
return plane.projectPointOntoEllipsoid(p);
|
|
107
|
+
}); // 8️⃣ 贴地
|
|
108
|
+
cartographics = positions3D.map(function (p) {
|
|
109
|
+
return Cesium.Cartographic.fromCartesian(p);
|
|
110
|
+
});
|
|
111
|
+
_context.next = 17;
|
|
112
|
+
return Cesium.sampleTerrainMostDetailed(map.terrainProvider, cartographics);
|
|
113
|
+
case 17:
|
|
114
|
+
clamped = _context.sent;
|
|
115
|
+
finalPositions = clamped.map(function (c) {
|
|
116
|
+
return Cesium.Cartesian3.fromRadians(c.longitude, c.latitude, c.height + heightBuffer);
|
|
117
|
+
});
|
|
118
|
+
finalSource.push({
|
|
119
|
+
positions: finalPositions,
|
|
120
|
+
indices: indices
|
|
121
|
+
});
|
|
122
|
+
case 20:
|
|
123
|
+
case "end":
|
|
124
|
+
return _context.stop();
|
|
125
|
+
}
|
|
126
|
+
}, _loop);
|
|
127
|
+
});
|
|
128
|
+
i = 0;
|
|
129
|
+
case 9:
|
|
130
|
+
if (!(i < source.length)) {
|
|
131
|
+
_context2.next = 14;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
return _context2.delegateYield(_loop(), "t0", 11);
|
|
135
|
+
case 11:
|
|
136
|
+
i++;
|
|
137
|
+
_context2.next = 9;
|
|
138
|
+
break;
|
|
139
|
+
case 14:
|
|
140
|
+
return _context2.abrupt("return", {
|
|
141
|
+
type: 'clampedPolygonGrid',
|
|
142
|
+
source: finalSource
|
|
143
|
+
});
|
|
144
|
+
case 15:
|
|
145
|
+
case "end":
|
|
146
|
+
return _context2.stop();
|
|
147
|
+
}
|
|
148
|
+
}, _callee);
|
|
149
|
+
}));
|
|
150
|
+
return _BuildClampedPolygonGrid.apply(this, arguments);
|
|
151
|
+
}
|
package/dist/esm/tool/utils.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ export declare const arrCartesian3: (data: any[]) => Cesium.Cartesian3;
|
|
|
11
11
|
export declare const toDegrees: (radians: number, precision?: number) => number;
|
|
12
12
|
export declare const toRadians: (degrees: number) => number;
|
|
13
13
|
export declare const lngLatAltToCartographic: (lng: number, lat: number, alt?: number) => Cesium.Cartographic;
|
|
14
|
+
export declare const cartographicToLngLatAlt: (cartographic: any) => {
|
|
15
|
+
lng: number;
|
|
16
|
+
lat: number;
|
|
17
|
+
alt: any;
|
|
18
|
+
};
|
|
14
19
|
export declare const cartesian3ToLngLatAlt: (cartesian3: any) => {
|
|
15
20
|
lng: number;
|
|
16
21
|
lat: number;
|
|
@@ -18,6 +23,8 @@ export declare const cartesian3ToLngLatAlt: (cartesian3: any) => {
|
|
|
18
23
|
};
|
|
19
24
|
export declare const lngLatAltToCartesian3: (lng: number, lat: number, alt?: number) => Cesium.Cartesian3;
|
|
20
25
|
export declare const lngLatAltArrayToCartesian3Array: (lngLatAltArray: any[]) => Cesium.Cartesian3[];
|
|
26
|
+
export declare const cartesian3ToCartographic: (cartesian3: any) => Cesium.Cartographic;
|
|
27
|
+
export declare const cartographicToCartesian3: (cartographic: any) => Cesium.Cartesian3;
|
|
21
28
|
export declare const isWKT: (str: string) => boolean;
|
|
22
29
|
export declare const styleFun: (style: any, properties: any) => any;
|
|
23
30
|
export declare const dateToJulianDate: (date: Date) => Cesium.JulianDate;
|
|
@@ -42,15 +49,25 @@ export declare const getHeightCompensatedScale: (map: Cesium.Viewer, entityHeigh
|
|
|
42
49
|
export declare function calculateLength(positions: any[]): number;
|
|
43
50
|
export declare function warn(message: string): void;
|
|
44
51
|
export declare function error(message: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* 去除 Polygon ring 的闭合点(首尾重复)
|
|
54
|
+
*/
|
|
55
|
+
export declare function normalizeRing(ring: Cesium.Cartesian3[]): Cesium.Cartesian3[];
|
|
56
|
+
/**
|
|
57
|
+
* 构建 Cesium 安全的 PolygonHierarchy
|
|
58
|
+
* 支持闭合 / 非闭合 / holes
|
|
59
|
+
*/
|
|
60
|
+
export declare function buildPolygonHierarchy(positions: Cesium.Cartesian3[], holes?: Cesium.Cartesian3[][]): Cesium.PolygonHierarchy;
|
|
45
61
|
/**
|
|
46
62
|
* 沿多边形平面局部坐标系计算 ST
|
|
47
63
|
* @param positions Cartesian3[] 多边形顶点
|
|
48
64
|
* @param rotation number 旋转
|
|
49
65
|
* @returns Float32Array ST 坐标
|
|
50
66
|
*/
|
|
51
|
-
export declare function computeSTAlongPlane(positions:
|
|
67
|
+
export declare function computeSTAlongPlane(positions: Cesium.Cartesian3[], rotation?: number): Float32Array;
|
|
52
68
|
export declare function getMidpoint(position1: Cartesian3, position2: Cartesian3): {
|
|
53
69
|
lng: number;
|
|
54
70
|
lat: number;
|
|
55
71
|
alt: number;
|
|
56
72
|
};
|
|
73
|
+
export declare function densifyLine(p1: Cartesian3, p2: Cartesian3, count?: number): Cesium.Cartesian3[];
|
package/dist/esm/tool/utils.js
CHANGED
|
@@ -149,6 +149,15 @@ export var lngLatAltToCartographic = function lngLatAltToCartographic(lng, lat)
|
|
|
149
149
|
return Cesium.Cartographic.fromDegrees(lng, lat, alt);
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
+
// Cartographic转经纬度
|
|
153
|
+
export var cartographicToLngLatAlt = function cartographicToLngLatAlt(cartographic) {
|
|
154
|
+
return {
|
|
155
|
+
lng: toDegrees(cartographic.longitude),
|
|
156
|
+
lat: toDegrees(cartographic.latitude),
|
|
157
|
+
alt: cartographic.height || 0
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
|
|
152
161
|
// Cartesian3转经纬度
|
|
153
162
|
export var cartesian3ToLngLatAlt = function cartesian3ToLngLatAlt(cartesian3) {
|
|
154
163
|
var cartographic = Cesium.Cartographic.fromCartesian(cartesian3);
|
|
@@ -178,6 +187,16 @@ export var lngLatAltArrayToCartesian3Array = function lngLatAltArrayToCartesian3
|
|
|
178
187
|
return Cesium.Cartesian3.fromDegreesArrayHeights(lngLatAltArrayString);
|
|
179
188
|
};
|
|
180
189
|
|
|
190
|
+
// Cartesian3转Cartographic
|
|
191
|
+
export var cartesian3ToCartographic = function cartesian3ToCartographic(cartesian3) {
|
|
192
|
+
return Cesium.Cartographic.fromCartesian(cartesian3);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// Cartographic转Cartesian3
|
|
196
|
+
export var cartographicToCartesian3 = function cartographicToCartesian3(cartographic) {
|
|
197
|
+
return Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, cartographic.height);
|
|
198
|
+
};
|
|
199
|
+
|
|
181
200
|
// 是否是wkt类型的字符串
|
|
182
201
|
export var isWKT = function isWKT(str) {
|
|
183
202
|
return str.startsWith('POINT') || str.startsWith('LINESTRING') || str.startsWith('POLYGON') || str.startsWith('MULTIPOINT') || str.startsWith('MULTILINESTRING') || str.startsWith('GEOMETRYCOLLECTION');
|
|
@@ -320,6 +339,41 @@ export function error(message) {
|
|
|
320
339
|
console.error("[DeepTwinsEngine3d error]: ".concat(message));
|
|
321
340
|
}
|
|
322
341
|
|
|
342
|
+
/**
|
|
343
|
+
* 去除 Polygon ring 的闭合点(首尾重复)
|
|
344
|
+
*/
|
|
345
|
+
export function normalizeRing(ring) {
|
|
346
|
+
var _ring$slice;
|
|
347
|
+
if (!ring || ring.length < 3) return (_ring$slice = ring === null || ring === void 0 ? void 0 : ring.slice()) !== null && _ring$slice !== void 0 ? _ring$slice : [];
|
|
348
|
+
var first = ring[0];
|
|
349
|
+
var last = ring[ring.length - 1];
|
|
350
|
+
if (Cesium.Cartesian3.equals(first, last)) {
|
|
351
|
+
return ring.slice(0, -1);
|
|
352
|
+
}
|
|
353
|
+
return ring.slice();
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* 构建 Cesium 安全的 PolygonHierarchy
|
|
358
|
+
* 支持闭合 / 非闭合 / holes
|
|
359
|
+
*/
|
|
360
|
+
export function buildPolygonHierarchy(positions) {
|
|
361
|
+
var holes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
362
|
+
var outer = normalizeRing(positions);
|
|
363
|
+
if (outer.length < 3) {
|
|
364
|
+
throw new Error('Polygon 外环至少需要 3 个不同的点');
|
|
365
|
+
}
|
|
366
|
+
var holeHierarchies = holes.map(function (h, i) {
|
|
367
|
+
var ring = normalizeRing(h);
|
|
368
|
+
if (ring.length < 3) {
|
|
369
|
+
console.warn("Polygon hole ".concat(i, " \u9876\u70B9\u4E0D\u8DB3\uFF0C\u5DF2\u5FFD\u7565"));
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
return new Cesium.PolygonHierarchy(ring);
|
|
373
|
+
}).filter(Boolean);
|
|
374
|
+
return new Cesium.PolygonHierarchy(outer, holeHierarchies);
|
|
375
|
+
}
|
|
376
|
+
|
|
323
377
|
/**
|
|
324
378
|
* 沿多边形平面局部坐标系计算 ST
|
|
325
379
|
* @param positions Cartesian3[] 多边形顶点
|
|
@@ -328,36 +382,56 @@ export function error(message) {
|
|
|
328
382
|
*/
|
|
329
383
|
export function computeSTAlongPlane(positions) {
|
|
330
384
|
var rotation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
331
|
-
|
|
332
|
-
var
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
var
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
var
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
385
|
+
// 1️⃣ 去闭合
|
|
386
|
+
var ring = buildPolygonHierarchy(positions).positions;
|
|
387
|
+
var count = ring.length;
|
|
388
|
+
var center = Cesium.BoundingSphere.fromPoints(ring).center;
|
|
389
|
+
|
|
390
|
+
// 2️⃣ 官方切平面(稳定)
|
|
391
|
+
var tangentPlane = new Cesium.EllipsoidTangentPlane(center, Cesium.Ellipsoid.WGS84);
|
|
392
|
+
|
|
393
|
+
// 3️⃣ 投影到 2D
|
|
394
|
+
var pts2D = ring.map(function (p) {
|
|
395
|
+
return tangentPlane.projectPointOntoPlane(p);
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
// 4️⃣ 计算 2D 中心
|
|
399
|
+
var cx = 0,
|
|
400
|
+
cy = 0;
|
|
401
|
+
pts2D.forEach(function (p) {
|
|
402
|
+
cx += p.x;
|
|
403
|
+
cy += p.y;
|
|
404
|
+
});
|
|
405
|
+
cx /= count;
|
|
406
|
+
cy /= count;
|
|
407
|
+
|
|
408
|
+
// 5️⃣ PCA 求主方向(S 轴)
|
|
409
|
+
var xx = 0,
|
|
410
|
+
xy = 0,
|
|
411
|
+
yy = 0;
|
|
412
|
+
pts2D.forEach(function (p) {
|
|
413
|
+
var dx = p.x - cx;
|
|
414
|
+
var dy = p.y - cy;
|
|
415
|
+
xx += dx * dx;
|
|
416
|
+
xy += dx * dy;
|
|
417
|
+
yy += dy * dy;
|
|
418
|
+
});
|
|
419
|
+
var theta = 0.5 * Math.atan2(2 * xy, xx - yy);
|
|
420
|
+
var cosT = Math.cos(theta + rotation);
|
|
421
|
+
var sinT = Math.sin(theta + rotation);
|
|
422
|
+
|
|
423
|
+
// 6️⃣ 投影到主轴坐标系
|
|
351
424
|
var minS = Infinity,
|
|
352
425
|
maxS = -Infinity,
|
|
353
426
|
minT = Infinity,
|
|
354
427
|
maxT = -Infinity;
|
|
355
|
-
var
|
|
356
|
-
|
|
357
|
-
var
|
|
358
|
-
var
|
|
359
|
-
var
|
|
360
|
-
|
|
428
|
+
var local = [];
|
|
429
|
+
pts2D.forEach(function (p) {
|
|
430
|
+
var dx = p.x - cx;
|
|
431
|
+
var dy = p.y - cy;
|
|
432
|
+
var s = dx * cosT + dy * sinT;
|
|
433
|
+
var t = -dx * sinT + dy * cosT;
|
|
434
|
+
local.push({
|
|
361
435
|
s: s,
|
|
362
436
|
t: t
|
|
363
437
|
});
|
|
@@ -366,25 +440,16 @@ export function computeSTAlongPlane(positions) {
|
|
|
366
440
|
minT = Math.min(minT, t);
|
|
367
441
|
maxT = Math.max(maxT, t);
|
|
368
442
|
});
|
|
369
|
-
var rangeS = maxS - minS || 1
|
|
370
|
-
var rangeT = maxT - minT || 1
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
var t = (pt.t - minT) / rangeT;
|
|
378
|
-
|
|
379
|
-
// 旋转 around center (0.5,0.5)
|
|
380
|
-
var s0 = s - 0.5;
|
|
381
|
-
var t0 = t - 0.5;
|
|
382
|
-
s = s0 * cosA - t0 * sinA + 0.5;
|
|
383
|
-
t = s0 * sinA + t0 * cosA + 0.5;
|
|
384
|
-
stValues[i * 2] = s;
|
|
385
|
-
stValues[i * 2 + 1] = t;
|
|
443
|
+
var rangeS = maxS - minS || 1;
|
|
444
|
+
var rangeT = maxT - minT || 1;
|
|
445
|
+
|
|
446
|
+
// 7️⃣ 归一化
|
|
447
|
+
var st = new Float32Array(count * 2);
|
|
448
|
+
local.forEach(function (p, i) {
|
|
449
|
+
st[i * 2] = (p.s - minS) / rangeS;
|
|
450
|
+
st[i * 2 + 1] = (p.t - minT) / rangeT;
|
|
386
451
|
});
|
|
387
|
-
return
|
|
452
|
+
return st;
|
|
388
453
|
}
|
|
389
454
|
|
|
390
455
|
// 计算两点的中心点
|
|
@@ -402,4 +467,14 @@ export function getMidpoint(position1, position2) {
|
|
|
402
467
|
lat: lat,
|
|
403
468
|
alt: alt
|
|
404
469
|
};
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// 对两点间进行插值
|
|
473
|
+
export function densifyLine(p1, p2) {
|
|
474
|
+
var count = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
|
|
475
|
+
var result = [];
|
|
476
|
+
for (var i = 0; i <= count; i++) {
|
|
477
|
+
result.push(Cesium.Cartesian3.lerp(p1, p2, i / count, new Cesium.Cartesian3()));
|
|
478
|
+
}
|
|
479
|
+
return result;
|
|
405
480
|
}
|
|
@@ -71,7 +71,7 @@ var VideoProject = /*#__PURE__*/function (_BaseVideo) {
|
|
|
71
71
|
_this2.type = type;
|
|
72
72
|
_this2.frustum = frustum;
|
|
73
73
|
// 取后4个点
|
|
74
|
-
var points = _this2.frustum.
|
|
74
|
+
var points = _this2.frustum.getFarPlane();
|
|
75
75
|
if (_this2.type === 'projection') {
|
|
76
76
|
// 交点数组
|
|
77
77
|
var interPoints = [];
|
|
@@ -1,5 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default class Frustum
|
|
1
|
+
import { MapContext } from "../map/Map";
|
|
2
|
+
export default class Frustum {
|
|
3
|
+
_mapContext: MapContext | undefined;
|
|
4
|
+
options: any;
|
|
5
|
+
frustumPrimitive: any;
|
|
6
|
+
frustumLinePrimitive: any;
|
|
7
|
+
isDestroyed: boolean;
|
|
3
8
|
constructor(map: any, options: any);
|
|
9
|
+
getMap(): any;
|
|
10
|
+
private _canOperate;
|
|
4
11
|
private _addFrustum;
|
|
12
|
+
/**
|
|
13
|
+
* 获取视锥体投影面的顶点坐标
|
|
14
|
+
* @param type 投影面类型: 'near'(近裁剪面) 或 'far'(远裁剪面)
|
|
15
|
+
* @returns 投影面的4个顶点坐标数组 [[lng, lat, alt], ...]
|
|
16
|
+
*/
|
|
17
|
+
getProjectionPlane(type?: 'near' | 'far'): any;
|
|
18
|
+
/**
|
|
19
|
+
* 获取近裁剪面的顶点坐标
|
|
20
|
+
* @returns 近裁剪面的4个顶点坐标数组
|
|
21
|
+
*/
|
|
22
|
+
getNearPlane(): any;
|
|
23
|
+
/**
|
|
24
|
+
* 获取远裁剪面的顶点坐标
|
|
25
|
+
* @returns 远裁剪面的4个顶点坐标数组
|
|
26
|
+
*/
|
|
27
|
+
getFarPlane(): any;
|
|
28
|
+
show(isShow: boolean): void;
|
|
29
|
+
destroy(): void;
|
|
5
30
|
}
|