deeptwins-engine-3d 0.1.28 → 0.1.30
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
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
2
|
var _excluded = ["style"],
|
|
3
|
-
_excluded2 = ["color", "materialAppearance", "vertexFormat"],
|
|
4
|
-
_excluded3 = ["color", "height"];
|
|
3
|
+
_excluded2 = ["color", "stRotation", "materialAppearance", "vertexFormat"],
|
|
4
|
+
_excluded3 = ["color", "height", "stRotation"];
|
|
5
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
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
7
|
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; }
|
|
@@ -51,6 +51,7 @@ var PolygonPrimitiveInstance = /*#__PURE__*/function (_BasePrimitiveInstanc) {
|
|
|
51
51
|
function _init(options) {
|
|
52
52
|
var _options$style = options.style,
|
|
53
53
|
color = _options$style.color,
|
|
54
|
+
stRotation = _options$style.stRotation,
|
|
54
55
|
materialAppearance = _options$style.materialAppearance,
|
|
55
56
|
vertexFormat = _options$style.vertexFormat,
|
|
56
57
|
style = _objectWithoutProperties(_options$style, _excluded2),
|
|
@@ -58,14 +59,27 @@ var PolygonPrimitiveInstance = /*#__PURE__*/function (_BasePrimitiveInstanc) {
|
|
|
58
59
|
holes = options.holes,
|
|
59
60
|
primitiveInstance = options.primitiveInstance;
|
|
60
61
|
var currVertexFormat = vertexFormat || materialAppearance ? Cesium.VertexFormat.POSITION_AND_ST : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT;
|
|
62
|
+
var geometry = null;
|
|
63
|
+
var polygonGeometry = new Cesium.PolygonGeometry(_objectSpread({
|
|
64
|
+
polygonHierarchy: new Cesium.PolygonHierarchy(positions, holes.map(function (t) {
|
|
65
|
+
return new Cesium.PolygonHierarchy(t);
|
|
66
|
+
})),
|
|
67
|
+
vertexFormat: currVertexFormat,
|
|
68
|
+
stRotation: stRotation
|
|
69
|
+
}, style));
|
|
70
|
+
if (materialAppearance) {
|
|
71
|
+
geometry = Cesium.PolygonGeometry.createGeometry(polygonGeometry);
|
|
72
|
+
geometry.attributes.st = new Cesium.GeometryAttribute({
|
|
73
|
+
componentDatatype: Cesium.ComponentDatatype.FLOAT,
|
|
74
|
+
componentsPerAttribute: 2,
|
|
75
|
+
values: utils.computeSTAlongPlane(positions, stRotation)
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
geometry = polygonGeometry;
|
|
79
|
+
}
|
|
61
80
|
var instance = new Cesium.GeometryInstance({
|
|
62
81
|
id: this.id,
|
|
63
|
-
geometry:
|
|
64
|
-
polygonHierarchy: new Cesium.PolygonHierarchy(positions, holes.map(function (t) {
|
|
65
|
-
return new Cesium.PolygonHierarchy(t);
|
|
66
|
-
})),
|
|
67
|
-
vertexFormat: currVertexFormat
|
|
68
|
-
}, style)),
|
|
82
|
+
geometry: geometry,
|
|
69
83
|
attributes: {
|
|
70
84
|
color: color
|
|
71
85
|
}
|
|
@@ -84,6 +98,7 @@ var PolygonPrimitiveInstance = /*#__PURE__*/function (_BasePrimitiveInstanc) {
|
|
|
84
98
|
value: function handleOptions(style) {
|
|
85
99
|
var color = style.color,
|
|
86
100
|
height = style.height,
|
|
101
|
+
stRotation = style.stRotation,
|
|
87
102
|
options = _objectWithoutProperties(style, _excluded3);
|
|
88
103
|
var backStyle = _objectSpread({
|
|
89
104
|
height: height
|
|
@@ -94,6 +109,9 @@ var PolygonPrimitiveInstance = /*#__PURE__*/function (_BasePrimitiveInstanc) {
|
|
|
94
109
|
if (height) {
|
|
95
110
|
backStyle.perPositionHeight = false;
|
|
96
111
|
}
|
|
112
|
+
if (stRotation) {
|
|
113
|
+
backStyle.stRotation = Cesium.Math.toRadians(stRotation);
|
|
114
|
+
}
|
|
97
115
|
return backStyle;
|
|
98
116
|
}
|
|
99
117
|
}]);
|
package/dist/esm/index.js
CHANGED
|
@@ -51,7 +51,7 @@ loadCss(Cesium.buildModuleUrl('Widgets/widgets.css'));
|
|
|
51
51
|
export var DeepTwinsEngine3D = /*#__PURE__*/_createClass(function DeepTwinsEngine3D() {
|
|
52
52
|
_classCallCheck(this, DeepTwinsEngine3D);
|
|
53
53
|
});
|
|
54
|
-
_defineProperty(DeepTwinsEngine3D, "Version", "0.1.
|
|
54
|
+
_defineProperty(DeepTwinsEngine3D, "Version", "0.1.30");
|
|
55
55
|
_defineProperty(DeepTwinsEngine3D, "Map", Map);
|
|
56
56
|
_defineProperty(DeepTwinsEngine3D, "GroundSkyBox", GroundSkyBox);
|
|
57
57
|
_defineProperty(DeepTwinsEngine3D, "RasterLayer", RasterLayer);
|
package/dist/esm/tool/utils.d.ts
CHANGED
|
@@ -46,3 +46,10 @@ export declare const getHeightCompensatedScale: (map: Cesium.Viewer, entityHeigh
|
|
|
46
46
|
export declare function calculateLength(positions: any[]): number;
|
|
47
47
|
export declare function warn(message: string): void;
|
|
48
48
|
export declare function error(message: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* 沿多边形平面局部坐标系计算 ST
|
|
51
|
+
* @param positions Cartesian3[] 多边形顶点
|
|
52
|
+
* @param rotation number 旋转
|
|
53
|
+
* @returns Float32Array ST 坐标
|
|
54
|
+
*/
|
|
55
|
+
export declare function computeSTAlongPlane(positions: any, rotation?: number): Float32Array;
|
package/dist/esm/tool/utils.js
CHANGED
|
@@ -331,4 +331,71 @@ export function warn(message) {
|
|
|
331
331
|
// 异常
|
|
332
332
|
export function error(message) {
|
|
333
333
|
console.error("[DeepTwinsEngine3d error]: ".concat(message));
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* 沿多边形平面局部坐标系计算 ST
|
|
338
|
+
* @param positions Cartesian3[] 多边形顶点
|
|
339
|
+
* @param rotation number 旋转
|
|
340
|
+
* @returns Float32Array ST 坐标
|
|
341
|
+
*/
|
|
342
|
+
export function computeSTAlongPlane(positions) {
|
|
343
|
+
var rotation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
344
|
+
var n = positions.length;
|
|
345
|
+
var stValues = new Float32Array(n * 2);
|
|
346
|
+
|
|
347
|
+
// 1️⃣ 计算中心
|
|
348
|
+
var center = Cesium.BoundingSphere.fromPoints(positions).center;
|
|
349
|
+
|
|
350
|
+
// 2️⃣ 计算法线
|
|
351
|
+
var v1 = Cesium.Cartesian3.subtract(positions[1], positions[0], new Cesium.Cartesian3());
|
|
352
|
+
var v2 = Cesium.Cartesian3.subtract(positions[2], positions[0], new Cesium.Cartesian3());
|
|
353
|
+
var normal = Cesium.Cartesian3.cross(v1, v2, new Cesium.Cartesian3());
|
|
354
|
+
Cesium.Cartesian3.normalize(normal, normal);
|
|
355
|
+
|
|
356
|
+
// 3️⃣ 选择 tangent/bitangent
|
|
357
|
+
var ref = Math.abs(normal.z) > 0.9 ? Cesium.Cartesian3.UNIT_X : Cesium.Cartesian3.UNIT_Z;
|
|
358
|
+
var tangent = Cesium.Cartesian3.cross(ref, normal, new Cesium.Cartesian3());
|
|
359
|
+
Cesium.Cartesian3.normalize(tangent, tangent);
|
|
360
|
+
var bitangent = Cesium.Cartesian3.cross(normal, tangent, new Cesium.Cartesian3());
|
|
361
|
+
Cesium.Cartesian3.normalize(bitangent, bitangent);
|
|
362
|
+
|
|
363
|
+
// 4️⃣ 投影到局部平面,收集 min/max
|
|
364
|
+
var minS = Infinity,
|
|
365
|
+
maxS = -Infinity,
|
|
366
|
+
minT = Infinity,
|
|
367
|
+
maxT = -Infinity;
|
|
368
|
+
var localST = [];
|
|
369
|
+
positions.forEach(function (p) {
|
|
370
|
+
var local = Cesium.Cartesian3.subtract(p, center, new Cesium.Cartesian3());
|
|
371
|
+
var s = Cesium.Cartesian3.dot(local, tangent);
|
|
372
|
+
var t = Cesium.Cartesian3.dot(local, bitangent);
|
|
373
|
+
localST.push({
|
|
374
|
+
s: s,
|
|
375
|
+
t: t
|
|
376
|
+
});
|
|
377
|
+
minS = Math.min(minS, s);
|
|
378
|
+
maxS = Math.max(maxS, s);
|
|
379
|
+
minT = Math.min(minT, t);
|
|
380
|
+
maxT = Math.max(maxT, t);
|
|
381
|
+
});
|
|
382
|
+
var rangeS = maxS - minS || 1.0;
|
|
383
|
+
var rangeT = maxT - minT || 1.0;
|
|
384
|
+
var cosA = Math.cos(rotation);
|
|
385
|
+
var sinA = Math.sin(rotation);
|
|
386
|
+
|
|
387
|
+
// 5️⃣ 归一化并旋转
|
|
388
|
+
localST.forEach(function (pt, i) {
|
|
389
|
+
var s = (pt.s - minS) / rangeS;
|
|
390
|
+
var t = (pt.t - minT) / rangeT;
|
|
391
|
+
|
|
392
|
+
// 旋转 around center (0.5,0.5)
|
|
393
|
+
var s0 = s - 0.5;
|
|
394
|
+
var t0 = t - 0.5;
|
|
395
|
+
s = s0 * cosA - t0 * sinA + 0.5;
|
|
396
|
+
t = s0 * sinA + t0 * cosA + 0.5;
|
|
397
|
+
stValues[i * 2] = s;
|
|
398
|
+
stValues[i * 2 + 1] = t;
|
|
399
|
+
});
|
|
400
|
+
return stValues;
|
|
334
401
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
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; }
|
|
2
4
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
5
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
6
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -80,7 +82,6 @@ var Airspace = /*#__PURE__*/function () {
|
|
|
80
82
|
new BoxPrimitiveInstance({
|
|
81
83
|
positions: source[i].positions,
|
|
82
84
|
style: {
|
|
83
|
-
show: this._isShow,
|
|
84
85
|
color: source[i].properties.color,
|
|
85
86
|
dimensions: this.options.dimensions,
|
|
86
87
|
scale: this.options.scale
|
|
@@ -89,7 +90,9 @@ var Airspace = /*#__PURE__*/function () {
|
|
|
89
90
|
});
|
|
90
91
|
}
|
|
91
92
|
boxPrimitive.createPrimitive({
|
|
92
|
-
style: this.options
|
|
93
|
+
style: _objectSpread(_objectSpread({}, this.options), {}, {
|
|
94
|
+
show: this._isShow
|
|
95
|
+
})
|
|
93
96
|
}, primitiveInstance);
|
|
94
97
|
this.getMap().scene.primitives.add(boxPrimitive.primitive);
|
|
95
98
|
}
|