deeptwins-engine-3d 0.1.65 → 0.1.66
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/constant.d.ts +1 -0
- package/dist/esm/drawCommand/viewShed/RectangularSensorPrimitive.d.ts +1 -0
- package/dist/esm/drawCommand/viewShed/ViewShedAnalyserLayer.d.ts +1 -0
- package/dist/esm/drawer/common.d.ts +1 -0
- package/dist/esm/drawer/coordinate.d.ts +1 -0
- package/dist/esm/drawer/index.d.ts +1 -1
- package/dist/esm/drawer/shape/BaseShape.d.ts +1 -0
- package/dist/esm/graphicLayer/BaseSource.d.ts +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +6 -2
- package/dist/esm/map/Map.d.ts +9 -0
- package/dist/esm/map/Map.js +115 -2
- package/dist/esm/material/AtmosphericDispersion.d.ts +71 -0
- package/dist/esm/material/AtmosphericDispersion.js +485 -33
- package/dist/esm/material/GlobalVolumetricCloud.d.ts +117 -0
- package/dist/esm/material/GlobalVolumetricCloud.js +219 -223
- package/dist/esm/material/entity/ImageMaterialProperty.d.ts +1 -0
- package/dist/esm/material/shader/AtmosphericShader.glsl +244 -0
- package/dist/esm/measure/BaseDraw.d.ts +1 -0
- package/dist/esm/measure/types.d.ts +1 -0
- package/dist/esm/measure/utils.d.ts +1 -0
- package/dist/esm/sceneFusion/Airway.d.ts +0 -0
- package/dist/esm/sceneFusion/Airway.js +692 -0
- package/dist/esm/tileLayer/ArcGisLayer.d.ts +1 -0
- package/dist/esm/tileLayer/ImageryLayer.d.ts +1 -0
- package/dist/esm/tileLayer/MvtVectorLoad.d.ts +1 -0
- package/dist/esm/tool/common.d.ts +1 -0
- package/dist/esm/tool/utils.d.ts +1 -0
- package/dist/esm/typings.d.ts +8 -0
- package/dist/esm/visualization/BaseHeatmap.d.ts +5 -0
- package/dist/esm/visualization/BaseHeatmap.js +54 -12
- package/dist/esm/visualization/Heatmap2d.d.ts +1 -0
- package/dist/esm/visualization/Heatmap2d.js +17 -26
- package/dist/esm/visualization/Heatmap3d.d.ts +8 -2
- package/dist/esm/visualization/Heatmap3d.js +195 -59
- package/dist/umd/deeptwins-engine-3d.min.js +1 -1
- package/package.json +1 -1
package/dist/esm/tool/utils.d.ts
CHANGED
package/dist/esm/typings.d.ts
CHANGED
|
@@ -13,3 +13,11 @@ declare const VERSION: string;
|
|
|
13
13
|
// 在esm中会赋值给window.CESIUM_BASE_URL 使用本地代理
|
|
14
14
|
// 在umd中会使用https://unpkg.com上相应版本的地址
|
|
15
15
|
declare const DEEP_TWINS_BASE_URL: string;
|
|
16
|
+
declare module 'deeptwins-cesium' {
|
|
17
|
+
export const BufferUsage: any;
|
|
18
|
+
export const DrawCommand: any;
|
|
19
|
+
export const Pass: any;
|
|
20
|
+
export const RenderState: any;
|
|
21
|
+
export const ShaderProgram: any;
|
|
22
|
+
export const VertexArray: any;
|
|
23
|
+
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
var _excluded = ["heading", "pitch", "scale"];
|
|
2
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
|
|
4
|
-
function
|
|
3
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
9
|
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
10
|
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; }
|
|
11
|
+
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; }
|
|
12
|
+
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; }
|
|
7
13
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
14
|
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
15
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -39,7 +45,7 @@ var BaseHeatmap = /*#__PURE__*/function () {
|
|
|
39
45
|
_options$style = options.style,
|
|
40
46
|
style = _options$style === void 0 ? {} : _options$style;
|
|
41
47
|
this.id = uuidv4();
|
|
42
|
-
this.positions = positions;
|
|
48
|
+
this.positions = positions || [];
|
|
43
49
|
this.style = merge(constant.DEFAULT_HEATMAP_STYLE(), cloneDeep(style));
|
|
44
50
|
}
|
|
45
51
|
_createClass(BaseHeatmap, [{
|
|
@@ -54,9 +60,7 @@ var BaseHeatmap = /*#__PURE__*/function () {
|
|
|
54
60
|
return;
|
|
55
61
|
}
|
|
56
62
|
heatmapContainer.appendChild(el);
|
|
57
|
-
this.heatmapInstance = h337.create(
|
|
58
|
-
container: el
|
|
59
|
-
}, this.style));
|
|
63
|
+
this.heatmapInstance = h337.create(this._getHeatmapConfig(el));
|
|
60
64
|
this.canvasW = this.heatmapInstance._renderer.canvas.width;
|
|
61
65
|
this.canvasH = this.heatmapInstance._renderer.canvas.height;
|
|
62
66
|
this._translatePositions();
|
|
@@ -106,6 +110,12 @@ var BaseHeatmap = /*#__PURE__*/function () {
|
|
|
106
110
|
}, {
|
|
107
111
|
key: "_translatePositions",
|
|
108
112
|
value: function _translatePositions() {
|
|
113
|
+
var _this$positions;
|
|
114
|
+
this.boundRect = undefined;
|
|
115
|
+
this.boundBox = undefined;
|
|
116
|
+
if (!((_this$positions = this.positions) !== null && _this$positions !== void 0 && _this$positions.length)) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
109
119
|
for (var i = 0; i < this.positions.length; i++) {
|
|
110
120
|
var position = utils.lngLatAltToCartesian3(this.positions[i].lng, this.positions[i].lat);
|
|
111
121
|
this.hierarchy.push(position);
|
|
@@ -118,14 +128,16 @@ var BaseHeatmap = /*#__PURE__*/function () {
|
|
|
118
128
|
y_axios = Cesium.Cartesian3.normalize(y_axios, new Cesium.Cartesian3());
|
|
119
129
|
var girthX = Cesium.Cartesian3.distance(this.boundBox.rightTop, this.boundBox.leftTop);
|
|
120
130
|
var girthY = Cesium.Cartesian3.distance(this.boundBox.leftBottom, this.boundBox.leftTop);
|
|
131
|
+
var safeGirthX = girthX || 1;
|
|
132
|
+
var safeGirthY = girthY || 1;
|
|
121
133
|
for (var _i = 0; _i < this.hierarchy.length; _i++) {
|
|
122
134
|
var p1 = this.hierarchy[_i];
|
|
123
135
|
var p_origin = Cesium.Cartesian3.subtract(p1, this.boundBox.leftTop, new Cesium.Cartesian3());
|
|
124
136
|
var diffX = Cesium.Cartesian3.dot(p_origin, x_axios);
|
|
125
137
|
var diffY = Cesium.Cartesian3.dot(p_origin, y_axios);
|
|
126
138
|
this.sources.push({
|
|
127
|
-
x: Number(diffX /
|
|
128
|
-
y: Number(diffY /
|
|
139
|
+
x: Number(diffX / safeGirthX * this.canvasW).toFixed(0),
|
|
140
|
+
y: Number(diffY / safeGirthY * this.canvasH).toFixed(0),
|
|
129
141
|
value: this.positions[_i].value
|
|
130
142
|
});
|
|
131
143
|
}
|
|
@@ -162,11 +174,13 @@ var BaseHeatmap = /*#__PURE__*/function () {
|
|
|
162
174
|
}
|
|
163
175
|
var diff_lat = maxLat - minLat;
|
|
164
176
|
var diff_lng = maxLng - minLng;
|
|
177
|
+
var latPadding = diff_lat / length || 0.0001;
|
|
178
|
+
var lngPadding = diff_lng / length || 0.0001;
|
|
165
179
|
this.boundRect = {
|
|
166
|
-
minLat: minLat -
|
|
167
|
-
maxLat: maxLat +
|
|
168
|
-
minLng: minLng -
|
|
169
|
-
maxLng: maxLng +
|
|
180
|
+
minLat: minLat - latPadding,
|
|
181
|
+
maxLat: maxLat + latPadding,
|
|
182
|
+
minLng: minLng - lngPadding,
|
|
183
|
+
maxLng: maxLng + lngPadding
|
|
170
184
|
};
|
|
171
185
|
this.boundBox = {
|
|
172
186
|
leftTop: Cesium.Cartesian3.fromDegrees(this.boundRect.minLng, this.boundRect.maxLat),
|
|
@@ -198,6 +212,34 @@ var BaseHeatmap = /*#__PURE__*/function () {
|
|
|
198
212
|
return arr;
|
|
199
213
|
}
|
|
200
214
|
|
|
215
|
+
// heatmap.js配置与Cesium业务样式分离,避免height误用为canvas高度
|
|
216
|
+
}, {
|
|
217
|
+
key: "_getHeatmapConfig",
|
|
218
|
+
value: function _getHeatmapConfig(container) {
|
|
219
|
+
var heatmapStyle = _objectSpread({}, this.style);
|
|
220
|
+
delete heatmapStyle.height;
|
|
221
|
+
delete heatmapStyle.heightReference;
|
|
222
|
+
delete heatmapStyle.perPositionHeight;
|
|
223
|
+
delete heatmapStyle.stretchingHeight;
|
|
224
|
+
return _objectSpread({
|
|
225
|
+
container: container
|
|
226
|
+
}, heatmapStyle);
|
|
227
|
+
}
|
|
228
|
+
}, {
|
|
229
|
+
key: "_getHeatValueRange",
|
|
230
|
+
value: function _getHeatValueRange() {
|
|
231
|
+
var _this$style$min, _this$style$max;
|
|
232
|
+
var minValue = (_this$style$min = this.style.min) !== null && _this$style$min !== void 0 ? _this$style$min : 0;
|
|
233
|
+
var sourceMaxValue = this.sources.length ? Math.max.apply(Math, _toConsumableArray(this.sources.map(function (t) {
|
|
234
|
+
return t.value;
|
|
235
|
+
}))) : minValue;
|
|
236
|
+
var maxValue = Math.max(minValue, (_this$style$max = this.style.max) !== null && _this$style$max !== void 0 ? _this$style$max : sourceMaxValue);
|
|
237
|
+
return {
|
|
238
|
+
minValue: minValue,
|
|
239
|
+
maxValue: maxValue
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
201
243
|
// 销毁
|
|
202
244
|
}, {
|
|
203
245
|
key: "destroy",
|
|
@@ -1,10 +1,4 @@
|
|
|
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
2
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
3
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
10
4
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -37,17 +31,8 @@ var Heatmap2d = /*#__PURE__*/function (_BaseHeatmap) {
|
|
|
37
31
|
}
|
|
38
32
|
this._mapContext = map._mapContext;
|
|
39
33
|
this._init();
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
min = _this$style.min,
|
|
43
|
-
max = _this$style.max;
|
|
44
|
-
this.heatmapInstance.setData({
|
|
45
|
-
min: min || 0,
|
|
46
|
-
max: max || Math.max.apply(Math, _toConsumableArray(this.sources.map(function (t) {
|
|
47
|
-
return t.value;
|
|
48
|
-
}))),
|
|
49
|
-
data: this.sources
|
|
50
|
-
});
|
|
34
|
+
this._syncHeatmapData();
|
|
35
|
+
if (!this.boundBox || !this.heatmapInstance) return;
|
|
51
36
|
this._createPolygonEntity();
|
|
52
37
|
}
|
|
53
38
|
|
|
@@ -67,7 +52,7 @@ var Heatmap2d = /*#__PURE__*/function (_BaseHeatmap) {
|
|
|
67
52
|
transparent: true
|
|
68
53
|
}),
|
|
69
54
|
heightReference: this.style.heightReference,
|
|
70
|
-
perPositionHeight:
|
|
55
|
+
perPositionHeight: false
|
|
71
56
|
};
|
|
72
57
|
if (this.style.heightReference === Cesium.HeightReference.NONE) {
|
|
73
58
|
polygonInfo.height = this.style.height;
|
|
@@ -85,18 +70,24 @@ var Heatmap2d = /*#__PURE__*/function (_BaseHeatmap) {
|
|
|
85
70
|
if (!this._canOperate()) {
|
|
86
71
|
return;
|
|
87
72
|
}
|
|
73
|
+
this.positions = positions || [];
|
|
88
74
|
this.hierarchy = [];
|
|
89
75
|
this.sources = [];
|
|
90
|
-
this.positions = positions;
|
|
91
76
|
this._translatePositions();
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
77
|
+
this._syncHeatmapData();
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
key: "_syncHeatmapData",
|
|
81
|
+
value: function _syncHeatmapData() {
|
|
82
|
+
if (!this.boundBox || !this.heatmapInstance) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
var _this$_getHeatValueRa = this._getHeatValueRange(),
|
|
86
|
+
minValue = _this$_getHeatValueRa.minValue,
|
|
87
|
+
maxValue = _this$_getHeatValueRa.maxValue;
|
|
95
88
|
this.heatmapInstance.setData({
|
|
96
|
-
min:
|
|
97
|
-
max:
|
|
98
|
-
return t.value;
|
|
99
|
-
}))),
|
|
89
|
+
min: minValue,
|
|
90
|
+
max: maxValue,
|
|
100
91
|
data: this.sources
|
|
101
92
|
});
|
|
102
93
|
}
|
|
@@ -2,7 +2,13 @@ import BaseHeatmap from './BaseHeatmap';
|
|
|
2
2
|
export default class Heatmap3d extends BaseHeatmap {
|
|
3
3
|
constructor(options?: any);
|
|
4
4
|
addToMap(map: any): void;
|
|
5
|
-
|
|
5
|
+
setData(positions: any[]): void;
|
|
6
|
+
private _syncHeatmapData;
|
|
7
|
+
private _rebuildPrimitive;
|
|
8
|
+
private _createPolygonPrimitive;
|
|
6
9
|
private _generateMeshData;
|
|
7
|
-
private
|
|
10
|
+
private _appendSideSkirt;
|
|
11
|
+
private _sampleHeatPixel;
|
|
12
|
+
private _getRendererImageData;
|
|
13
|
+
private _getSideAlpha;
|
|
8
14
|
}
|
|
@@ -1,10 +1,4 @@
|
|
|
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
2
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
3
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
10
4
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -18,7 +12,13 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
|
|
|
18
12
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
19
13
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
20
14
|
import * as Cesium from 'deeptwins-cesium';
|
|
15
|
+
import GeometryPrimitive from "../drawCommand/volumeCloud/GeometryPrimitive";
|
|
21
16
|
import BaseHeatmap from "./BaseHeatmap";
|
|
17
|
+
var MAX_GRID_SIZE = 300;
|
|
18
|
+
var MIN_SURFACE_ALPHA = 0.18;
|
|
19
|
+
var MIN_SIDE_ALPHA = 0.08;
|
|
20
|
+
var VERTEX_SHADER_SOURCE = /* glsl */"\nin vec3 position3DHigh;\nin vec3 position3DLow;\nin vec4 color;\n\nout vec4 v_color;\n\nvec4 czm_computePosition() {\n return czm_translateRelativeToEye(position3DHigh, position3DLow);\n}\n\nvoid main() {\n vec4 p = czm_computePosition();\n v_color = color;\n gl_Position = czm_modelViewProjectionRelativeToEye * p;\n}\n";
|
|
21
|
+
var FRAGMENT_SHADER_SOURCE = /* glsl */"\nin vec4 v_color;\n\nvoid main() {\n vec4 color = czm_gammaCorrect(v_color);\n if (color.a <= 0.001) {\n discard;\n }\n out_FragColor = color;\n}\n";
|
|
22
22
|
var Heatmap3d = /*#__PURE__*/function (_BaseHeatmap) {
|
|
23
23
|
_inherits(Heatmap3d, _BaseHeatmap);
|
|
24
24
|
var _super = _createSuper(Heatmap3d);
|
|
@@ -37,107 +37,243 @@ var Heatmap3d = /*#__PURE__*/function (_BaseHeatmap) {
|
|
|
37
37
|
}
|
|
38
38
|
this._mapContext = map._mapContext;
|
|
39
39
|
this._init();
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
this._syncHeatmapData();
|
|
41
|
+
this._rebuildPrimitive();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// 更新数据
|
|
45
|
+
}, {
|
|
46
|
+
key: "setData",
|
|
47
|
+
value: function setData(positions) {
|
|
48
|
+
if (!this._canOperate()) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
this.positions = positions;
|
|
52
|
+
this.hierarchy = [];
|
|
53
|
+
this.sources = [];
|
|
54
|
+
this._translatePositions();
|
|
55
|
+
this._syncHeatmapData();
|
|
56
|
+
this._rebuildPrimitive();
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "_syncHeatmapData",
|
|
60
|
+
value: function _syncHeatmapData() {
|
|
61
|
+
if (!this.boundBox || !this.heatmapInstance) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
var _this$_getHeatValueRa = this._getHeatValueRange(),
|
|
65
|
+
minValue = _this$_getHeatValueRa.minValue,
|
|
66
|
+
maxValue = _this$_getHeatValueRa.maxValue;
|
|
44
67
|
this.heatmapInstance.setData({
|
|
45
|
-
min:
|
|
46
|
-
max:
|
|
47
|
-
return t.value;
|
|
48
|
-
}))),
|
|
68
|
+
min: minValue,
|
|
69
|
+
max: maxValue,
|
|
49
70
|
data: this.sources
|
|
50
71
|
});
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
key: "_rebuildPrimitive",
|
|
75
|
+
value: function _rebuildPrimitive() {
|
|
76
|
+
if (!this.boundBox || !this.getMap()) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (this.heatmapPrimitive) {
|
|
80
|
+
this.getMap().scene.primitives.remove(this.heatmapPrimitive);
|
|
81
|
+
this.heatmapPrimitive = null;
|
|
82
|
+
}
|
|
51
83
|
this._createPolygonPrimitive();
|
|
52
84
|
}
|
|
53
85
|
}, {
|
|
54
86
|
key: "_createPolygonPrimitive",
|
|
55
87
|
value: function _createPolygonPrimitive() {
|
|
56
88
|
var meshData = this._generateMeshData();
|
|
89
|
+
if (!meshData) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
57
92
|
var attributes = new Cesium.GeometryAttributes();
|
|
58
93
|
attributes.position = new Cesium.GeometryAttribute({
|
|
59
94
|
componentDatatype: Cesium.ComponentDatatype.DOUBLE,
|
|
60
95
|
componentsPerAttribute: 3,
|
|
61
|
-
values: meshData.positions
|
|
96
|
+
values: new Float64Array(meshData.positions)
|
|
62
97
|
});
|
|
63
|
-
attributes.
|
|
64
|
-
componentDatatype: Cesium.ComponentDatatype.
|
|
65
|
-
componentsPerAttribute:
|
|
66
|
-
|
|
98
|
+
attributes.color = new Cesium.GeometryAttribute({
|
|
99
|
+
componentDatatype: Cesium.ComponentDatatype.UNSIGNED_BYTE,
|
|
100
|
+
componentsPerAttribute: 4,
|
|
101
|
+
normalize: true,
|
|
102
|
+
values: new Uint8Array(meshData.colors)
|
|
67
103
|
});
|
|
68
104
|
var geometry = new Cesium.Geometry({
|
|
69
105
|
attributes: attributes,
|
|
70
|
-
indices: new Uint16Array(meshData.indices),
|
|
106
|
+
indices: meshData.vertexCount > 65535 ? new Uint32Array(meshData.indices) : new Uint16Array(meshData.indices),
|
|
71
107
|
primitiveType: Cesium.PrimitiveType.TRIANGLES,
|
|
72
108
|
boundingSphere: Cesium.BoundingSphere.fromVertices(meshData.positions)
|
|
73
109
|
});
|
|
74
|
-
var
|
|
75
|
-
|
|
110
|
+
var renderState = Cesium.RenderState.fromCache({
|
|
111
|
+
depthMask: false,
|
|
112
|
+
depthTest: {
|
|
113
|
+
enabled: true,
|
|
114
|
+
func: Cesium.DepthFunction.LESS_OR_EQUAL
|
|
115
|
+
},
|
|
116
|
+
blending: Cesium.BlendingState.ALPHA_BLEND,
|
|
117
|
+
cull: {
|
|
118
|
+
enabled: false
|
|
119
|
+
}
|
|
76
120
|
});
|
|
77
|
-
this.heatmapPrimitive = this.getMap().scene.primitives.add(new
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
uniforms: {
|
|
84
|
-
image: this.heatmapInstance.getDataURL()
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}),
|
|
88
|
-
vertexShaderSource: this._getShader(),
|
|
89
|
-
translucent: true,
|
|
90
|
-
flat: true
|
|
91
|
-
}),
|
|
92
|
-
asynchronous: false
|
|
121
|
+
this.heatmapPrimitive = this.getMap().scene.primitives.add(new GeometryPrimitive(geometry, {
|
|
122
|
+
modelMatrix: Cesium.Matrix4.IDENTITY,
|
|
123
|
+
vertexShaderSource: VERTEX_SHADER_SOURCE,
|
|
124
|
+
fragmentShaderSource: FRAGMENT_SHADER_SOURCE,
|
|
125
|
+
renderState: renderState,
|
|
126
|
+
pass: Cesium.Pass.TRANSLUCENT
|
|
93
127
|
}));
|
|
94
128
|
this.heatmapPrimitive.id = this.id;
|
|
95
129
|
}
|
|
96
130
|
|
|
97
|
-
//
|
|
131
|
+
// 根据热力图范围生成曲面与侧壁
|
|
98
132
|
}, {
|
|
99
133
|
key: "_generateMeshData",
|
|
100
134
|
value: function _generateMeshData() {
|
|
101
|
-
var
|
|
102
|
-
|
|
135
|
+
var _this$heatmapInstance;
|
|
136
|
+
if (!this.boundRect || !((_this$heatmapInstance = this.heatmapInstance) !== null && _this$heatmapInstance !== void 0 && _this$heatmapInstance._renderer)) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
var gridWidth = Math.max(2, Math.min(this.canvasW, MAX_GRID_SIZE));
|
|
140
|
+
var gridHeight = Math.max(2, Math.min(this.canvasH, MAX_GRID_SIZE));
|
|
103
141
|
var _this$boundRect = this.boundRect,
|
|
104
142
|
minLat = _this$boundRect.minLat,
|
|
105
143
|
maxLat = _this$boundRect.maxLat,
|
|
106
144
|
minLng = _this$boundRect.minLng,
|
|
107
145
|
maxLng = _this$boundRect.maxLng;
|
|
108
|
-
var
|
|
109
|
-
var
|
|
146
|
+
var maxGridWidthIndex = gridWidth - 1;
|
|
147
|
+
var maxGridHeightIndex = gridHeight - 1;
|
|
148
|
+
var longitudeStep = (maxLng - minLng) / maxGridWidthIndex;
|
|
149
|
+
var latitudeStep = (maxLat - minLat) / maxGridHeightIndex;
|
|
150
|
+
var sampleMaxX = Math.max(0, this.canvasW - 1);
|
|
151
|
+
var sampleMaxY = Math.max(0, this.canvasH - 1);
|
|
152
|
+
var baseHeight = this.style.height;
|
|
153
|
+
var stretchingHeight = this.style.stretchingHeight;
|
|
154
|
+
var colorImageData = this._getRendererImageData(this.heatmapInstance._renderer.canvas);
|
|
155
|
+
var shadowImageData = this._getRendererImageData(this.heatmapInstance._renderer.shadowCanvas);
|
|
156
|
+
if (!colorImageData || !shadowImageData) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
110
159
|
var positions = [];
|
|
111
|
-
var
|
|
160
|
+
var colors = [];
|
|
112
161
|
var indices = [];
|
|
162
|
+
var topVertexInfo = [];
|
|
163
|
+
var getTopVertexIndex = function getTopVertexIndex(x, y) {
|
|
164
|
+
return x * gridHeight + y;
|
|
165
|
+
};
|
|
113
166
|
for (var i = 0; i < gridWidth; i++) {
|
|
114
167
|
var currentLongitude = minLng + longitudeStep * i;
|
|
168
|
+
var sampleX = Math.round(i / maxGridWidthIndex * sampleMaxX);
|
|
115
169
|
for (var j = 0; j < gridHeight; j++) {
|
|
116
170
|
var currentLatitude = minLat + latitudeStep * j;
|
|
117
|
-
var
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
var cartesian3 = Cesium.Cartesian3.fromDegrees(currentLongitude, currentLatitude, this.style.height + heatValue);
|
|
171
|
+
var sampleY = Math.round(j / maxGridHeightIndex * sampleMaxY);
|
|
172
|
+
var sample = this._sampleHeatPixel(sampleX, sampleY, colorImageData, shadowImageData);
|
|
173
|
+
var currentHeight = baseHeight + sample.intensity * stretchingHeight;
|
|
174
|
+
var cartesian3 = Cesium.Cartesian3.fromDegrees(currentLongitude, currentLatitude, currentHeight);
|
|
122
175
|
positions.push(cartesian3.x, cartesian3.y, cartesian3.z);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
176
|
+
colors.push(sample.color[0], sample.color[1], sample.color[2], sample.color[3]);
|
|
177
|
+
topVertexInfo.push({
|
|
178
|
+
lng: currentLongitude,
|
|
179
|
+
lat: currentLatitude,
|
|
180
|
+
color: sample.color
|
|
181
|
+
});
|
|
182
|
+
if (i !== maxGridWidthIndex && j !== maxGridHeightIndex) {
|
|
183
|
+
indices.push(getTopVertexIndex(i, j), getTopVertexIndex(i + 1, j), getTopVertexIndex(i, j + 1));
|
|
184
|
+
indices.push(getTopVertexIndex(i + 1, j), getTopVertexIndex(i + 1, j + 1), getTopVertexIndex(i, j + 1));
|
|
127
185
|
}
|
|
128
186
|
}
|
|
129
187
|
}
|
|
188
|
+
this._appendSideSkirt(positions, colors, indices, topVertexInfo, baseHeight, 0, gridHeight, function (step) {
|
|
189
|
+
return {
|
|
190
|
+
topAIndex: getTopVertexIndex(0, step),
|
|
191
|
+
topBIndex: getTopVertexIndex(0, step + 1)
|
|
192
|
+
};
|
|
193
|
+
});
|
|
194
|
+
this._appendSideSkirt(positions, colors, indices, topVertexInfo, baseHeight, 0, gridHeight, function (step) {
|
|
195
|
+
return {
|
|
196
|
+
topAIndex: getTopVertexIndex(maxGridWidthIndex, step + 1),
|
|
197
|
+
topBIndex: getTopVertexIndex(maxGridWidthIndex, step)
|
|
198
|
+
};
|
|
199
|
+
});
|
|
200
|
+
this._appendSideSkirt(positions, colors, indices, topVertexInfo, baseHeight, 0, gridWidth, function (step) {
|
|
201
|
+
return {
|
|
202
|
+
topAIndex: getTopVertexIndex(step + 1, 0),
|
|
203
|
+
topBIndex: getTopVertexIndex(step, 0)
|
|
204
|
+
};
|
|
205
|
+
});
|
|
206
|
+
this._appendSideSkirt(positions, colors, indices, topVertexInfo, baseHeight, 0, gridWidth, function (step) {
|
|
207
|
+
return {
|
|
208
|
+
topAIndex: getTopVertexIndex(step, maxGridHeightIndex),
|
|
209
|
+
topBIndex: getTopVertexIndex(step + 1, maxGridHeightIndex)
|
|
210
|
+
};
|
|
211
|
+
});
|
|
130
212
|
return {
|
|
131
213
|
positions: positions,
|
|
132
|
-
|
|
133
|
-
indices: indices
|
|
214
|
+
colors: colors,
|
|
215
|
+
indices: indices,
|
|
216
|
+
vertexCount: positions.length / 3
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
}, {
|
|
220
|
+
key: "_appendSideSkirt",
|
|
221
|
+
value: function _appendSideSkirt(positions, colors, indices, topVertexInfo, baseHeight, start, size, getSegment) {
|
|
222
|
+
if (size < 2) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
for (var _step = start; _step < size - 1; _step++) {
|
|
226
|
+
var _getSegment = getSegment(_step),
|
|
227
|
+
topAIndex = _getSegment.topAIndex,
|
|
228
|
+
topBIndex = _getSegment.topBIndex;
|
|
229
|
+
var topA = topVertexInfo[topAIndex];
|
|
230
|
+
var topB = topVertexInfo[topBIndex];
|
|
231
|
+
var bottomA = Cesium.Cartesian3.fromDegrees(topA.lng, topA.lat, baseHeight);
|
|
232
|
+
var bottomB = Cesium.Cartesian3.fromDegrees(topB.lng, topB.lat, baseHeight);
|
|
233
|
+
var bottomAIndex = positions.length / 3;
|
|
234
|
+
positions.push(bottomA.x, bottomA.y, bottomA.z);
|
|
235
|
+
colors.push(topA.color[0], topA.color[1], topA.color[2], this._getSideAlpha(topA.color[3]));
|
|
236
|
+
var bottomBIndex = positions.length / 3;
|
|
237
|
+
positions.push(bottomB.x, bottomB.y, bottomB.z);
|
|
238
|
+
colors.push(topB.color[0], topB.color[1], topB.color[2], this._getSideAlpha(topB.color[3]));
|
|
239
|
+
indices.push(topAIndex, bottomAIndex, topBIndex);
|
|
240
|
+
indices.push(topBIndex, bottomAIndex, bottomBIndex);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}, {
|
|
244
|
+
key: "_sampleHeatPixel",
|
|
245
|
+
value: function _sampleHeatPixel(x, y, colorImageData, shadowImageData) {
|
|
246
|
+
var index = (y * this.canvasW + x) * 4;
|
|
247
|
+
var red = colorImageData[index] || 0;
|
|
248
|
+
var green = colorImageData[index + 1] || 0;
|
|
249
|
+
var blue = colorImageData[index + 2] || 0;
|
|
250
|
+
var shadowAlpha = (shadowImageData[index + 3] || 0) / 255;
|
|
251
|
+
var alpha = shadowAlpha > 0 ? Math.round(Cesium.Math.lerp(MIN_SURFACE_ALPHA, 1, shadowAlpha) * 255) : 0;
|
|
252
|
+
return {
|
|
253
|
+
intensity: shadowAlpha,
|
|
254
|
+
color: [red, green, blue, alpha]
|
|
134
255
|
};
|
|
135
256
|
}
|
|
136
257
|
}, {
|
|
137
|
-
key: "
|
|
138
|
-
value: function
|
|
139
|
-
|
|
140
|
-
|
|
258
|
+
key: "_getRendererImageData",
|
|
259
|
+
value: function _getRendererImageData(canvas) {
|
|
260
|
+
if (!canvas) {
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
var context = canvas.getContext('2d');
|
|
264
|
+
if (!context) {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
return context.getImageData(0, 0, this.canvasW, this.canvasH).data;
|
|
268
|
+
}
|
|
269
|
+
}, {
|
|
270
|
+
key: "_getSideAlpha",
|
|
271
|
+
value: function _getSideAlpha(topAlpha) {
|
|
272
|
+
if (topAlpha <= 0) {
|
|
273
|
+
return 0;
|
|
274
|
+
}
|
|
275
|
+
var alphaRatio = topAlpha / 255;
|
|
276
|
+
return Math.round(Cesium.Math.clamp(alphaRatio * 0.5, MIN_SIDE_ALPHA, 0.5) * 255);
|
|
141
277
|
}
|
|
142
278
|
}]);
|
|
143
279
|
return Heatmap3d;
|