@anov/3d-ability 0.0.90 → 0.0.92

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.
@@ -0,0 +1,103 @@
1
+ import { Object3D } from '@anov/3d-core';
2
+ import type { HeatMapData, HeatMapnterface } from './index';
3
+ type RangeType = {
4
+ min: number;
5
+ max: number;
6
+ };
7
+ type HeatMapOptions = {
8
+ colorMap?: {
9
+ [key: number]: string;
10
+ };
11
+ max?: number;
12
+ radius?: number;
13
+ height?: number;
14
+ isPixel?: boolean;
15
+ range?: RangeType;
16
+ };
17
+ /**
18
+ * 区域热力图
19
+ */
20
+ declare class HeatMap extends Object3D implements HeatMapnterface {
21
+ data: HeatMapData[];
22
+ private _height;
23
+ private _radius;
24
+ private _heatmap;
25
+ private _url;
26
+ private _colorMap;
27
+ private _isPixel;
28
+ private _canvasBox;
29
+ private _attachmentMesh;
30
+ private _supercluster;
31
+ private _range;
32
+ private get defaultMax();
33
+ get url(): string;
34
+ constructor(options: HeatMapOptions);
35
+ private initSupercluster;
36
+ /**
37
+ * set supercluster data
38
+ */
39
+ private setSuperclusterData;
40
+ /**
41
+ * get zoom level
42
+ * @param camera
43
+ * @returns
44
+ */
45
+ private getZoomLevel;
46
+ /**
47
+ * get supercluster data
48
+ * @returns
49
+ */
50
+ private getSuperclusterData;
51
+ /**
52
+ * calculate data max and min
53
+ * @returns
54
+ */
55
+ private calDataMaxMin;
56
+ /**
57
+ * handle range data filter
58
+ * @param data
59
+ * @returns
60
+ */
61
+ private handleRandeDataFilter;
62
+ /**
63
+ * coordinate transformation
64
+ * @param data
65
+ * @returns
66
+ */
67
+ private coordinateTransformation;
68
+ /**
69
+ * generate heatmap texture
70
+ * @param canvasBox
71
+ * @returns
72
+ */
73
+ private createHeatmapTool;
74
+ /**
75
+ * create heatmap container canvas
76
+ * @returns
77
+ */
78
+ private createCanvas;
79
+ /**
80
+ * calculate resolution scale
81
+ * @param width
82
+ * @returns
83
+ */
84
+ private calResolutionScale;
85
+ /**
86
+ * handle resolution canvas
87
+ * @param canvas
88
+ * @param scale
89
+ * @returns
90
+ */
91
+ private handleResolutionCanvas;
92
+ /**
93
+ * create attachment mesh
94
+ */
95
+ private createAttachmentMesh;
96
+ /**
97
+ * set heatmap data
98
+ * @param data
99
+ */
100
+ setData(data: HeatMapData[]): void;
101
+ removeFromParent(): this;
102
+ }
103
+ export default HeatMap;
@@ -0,0 +1,374 @@
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
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
+ 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
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
12
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
13
+ 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); }
14
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
15
+ 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); }; }
16
+ 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); }
17
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18
+ 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
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
20
+ 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; }
21
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
22
+ 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); }
23
+ import { CanvasTexture, DoubleSide, Mesh, NearestFilter, Object3D, PlaneGeometry, ShaderMaterial, use } from '@anov/3d-core';
24
+ import h from 'anov-heat-map';
25
+ import Supercluster from 'supercluster';
26
+ import { heightFragmentShader, heightVertexShader } from "./shader";
27
+ var defaultGradient = {
28
+ 0.25: 'rgb(0,0,255)',
29
+ 0.55: 'rgb(0,255,0)',
30
+ 0.85: 'yellow',
31
+ 1.0: 'rgb(255,0,0)'
32
+ };
33
+
34
+ /**
35
+ * 区域热力图
36
+ */
37
+ var HeatMap = /*#__PURE__*/function (_Object3D) {
38
+ _inherits(HeatMap, _Object3D);
39
+ var _super = _createSuper(HeatMap);
40
+ function HeatMap(options) {
41
+ var _options$radius, _options$height, _options$isPixel;
42
+ var _this;
43
+ _classCallCheck(this, HeatMap);
44
+ _this = _super.call(this);
45
+ _defineProperty(_assertThisInitialized(_this), "data", []);
46
+ _defineProperty(_assertThisInitialized(_this), "_height", void 0);
47
+ _defineProperty(_assertThisInitialized(_this), "_radius", void 0);
48
+ _defineProperty(_assertThisInitialized(_this), "_heatmap", void 0);
49
+ _defineProperty(_assertThisInitialized(_this), "_url", void 0);
50
+ _defineProperty(_assertThisInitialized(_this), "_colorMap", void 0);
51
+ _defineProperty(_assertThisInitialized(_this), "_isPixel", void 0);
52
+ _defineProperty(_assertThisInitialized(_this), "_canvasBox", void 0);
53
+ _defineProperty(_assertThisInitialized(_this), "_attachmentMesh", void 0);
54
+ _defineProperty(_assertThisInitialized(_this), "_supercluster", void 0);
55
+ _defineProperty(_assertThisInitialized(_this), "_range", void 0);
56
+ _this._colorMap = options.colorMap || defaultGradient;
57
+ _this._radius = (_options$radius = options.radius) !== null && _options$radius !== void 0 ? _options$radius : 40;
58
+ _this._height = (_options$height = options.height) !== null && _options$height !== void 0 ? _options$height : 70;
59
+ _this._isPixel = (_options$isPixel = options.isPixel) !== null && _options$isPixel !== void 0 ? _options$isPixel : false;
60
+ _this._range = options.range;
61
+
62
+ // this.initSupercluster()
63
+ return _this;
64
+ }
65
+ _createClass(HeatMap, [{
66
+ key: "defaultMax",
67
+ get: function get() {
68
+ return Math.max.apply(Math, _toConsumableArray(this.data.map(function (item) {
69
+ return item.value;
70
+ })));
71
+ }
72
+ }, {
73
+ key: "url",
74
+ get: function get() {
75
+ return this._url;
76
+ }
77
+ }, {
78
+ key: "initSupercluster",
79
+ value: function initSupercluster() {
80
+ this._supercluster = new Supercluster({
81
+ radius: 40,
82
+ minZoom: 1,
83
+ maxZoom: 16
84
+ });
85
+ }
86
+
87
+ /**
88
+ * set supercluster data
89
+ */
90
+ }, {
91
+ key: "setSuperclusterData",
92
+ value: function setSuperclusterData() {
93
+ var featuresPoints = this.data.map(function (item) {
94
+ return {
95
+ type: 'Feature',
96
+ properties: {},
97
+ geometry: {
98
+ type: 'Point',
99
+ coordinates: [item.x, item.z]
100
+ }
101
+ };
102
+ });
103
+ console.log('正在加载点数据到supercluster:', featuresPoints.length);
104
+ this._supercluster.load(featuresPoints);
105
+ }
106
+
107
+ /**
108
+ * get zoom level
109
+ * @param camera
110
+ * @returns
111
+ */
112
+ }, {
113
+ key: "getZoomLevel",
114
+ value: function getZoomLevel(camera) {
115
+ var minZoom = 10;
116
+ var maxZoom = 16;
117
+ var minHeight = 10;
118
+ var maxHeight = 1000;
119
+ return Math.max(minZoom, Math.min(maxZoom, (maxHeight - camera.position.y) / (maxHeight - minHeight) * (maxZoom - minZoom) + minZoom));
120
+ }
121
+
122
+ /**
123
+ * get supercluster data
124
+ * @returns
125
+ */
126
+ }, {
127
+ key: "getSuperclusterData",
128
+ value: function getSuperclusterData() {
129
+ var _this$calDataMaxMin = this.calDataMaxMin(),
130
+ max = _this$calDataMaxMin.max;
131
+ var zoom = this.getZoomLevel(use.useScene().camera);
132
+ var clusters = this._supercluster.getClusters([-max, -max, max, max], zoom);
133
+ console.log('当前缩放级别:', zoom, '输入点数量:', this.data.length, '聚类后点数量:', clusters.length);
134
+ return clusters;
135
+ }
136
+
137
+ /**
138
+ * calculate data max and min
139
+ * @returns
140
+ */
141
+ }, {
142
+ key: "calDataMaxMin",
143
+ value: function calDataMaxMin() {
144
+ var maxX = Math.max.apply(Math, _toConsumableArray(this.data.map(function (item) {
145
+ return item.x;
146
+ })));
147
+ var minX = Math.min.apply(Math, _toConsumableArray(this.data.map(function (item) {
148
+ return item.x;
149
+ })));
150
+ var maxZ = Math.max.apply(Math, _toConsumableArray(this.data.map(function (item) {
151
+ return item.z;
152
+ })));
153
+ var minZ = Math.min.apply(Math, _toConsumableArray(this.data.map(function (item) {
154
+ return item.z;
155
+ })));
156
+ var max = Math.max(Math.abs(Math.ceil(maxX)), Math.abs(Math.ceil(minX)), Math.abs(Math.ceil(maxZ)), Math.abs(Math.ceil(minZ)), 60);
157
+ var width = max * 2;
158
+ var height = max * 2;
159
+ var realShowWidth = maxX - minX;
160
+ var realShowHeight = maxZ - minZ;
161
+ var realShowMax = Math.max(Math.ceil(realShowWidth), Math.ceil(realShowHeight), 60);
162
+ return {
163
+ width: width,
164
+ height: height,
165
+ max: max,
166
+ minX: minX,
167
+ minZ: minZ,
168
+ maxX: maxX,
169
+ maxZ: maxZ,
170
+ realShowMax: realShowMax
171
+ };
172
+ }
173
+
174
+ /**
175
+ * handle range data filter
176
+ * @param data
177
+ * @returns
178
+ */
179
+ }, {
180
+ key: "handleRandeDataFilter",
181
+ value: function handleRandeDataFilter(data) {
182
+ var _this2 = this;
183
+ if (this._range) {
184
+ return data.filter(function (item) {
185
+ return item.x >= _this2._range.min && item.x <= _this2._range.max && item.z >= _this2._range.min && item.z <= _this2._range.max;
186
+ });
187
+ }
188
+ return data;
189
+ }
190
+
191
+ /**
192
+ * coordinate transformation
193
+ * @param data
194
+ * @returns
195
+ */
196
+ }, {
197
+ key: "coordinateTransformation",
198
+ value: function coordinateTransformation(data) {
199
+ var _this3 = this;
200
+ var hanldeData = this.handleRandeDataFilter(data);
201
+ var _this$calDataMaxMin2 = this.calDataMaxMin(),
202
+ width = _this$calDataMaxMin2.width,
203
+ height = _this$calDataMaxMin2.height,
204
+ max = _this$calDataMaxMin2.max;
205
+ var result = hanldeData.map(function (item) {
206
+ var _item$radius;
207
+ return {
208
+ x: Math.floor((item.x - -max) / (max - -max) * width),
209
+ y: Math.floor((item.z - -max) / (max - -max) * height),
210
+ value: item.value,
211
+ radius: (_item$radius = item.radius) !== null && _item$radius !== void 0 ? _item$radius : _this3._radius
212
+ };
213
+ });
214
+ return result;
215
+ }
216
+
217
+ /**
218
+ * generate heatmap texture
219
+ * @param canvasBox
220
+ * @returns
221
+ */
222
+ }, {
223
+ key: "createHeatmapTool",
224
+ value: function createHeatmapTool() {
225
+ var heatmap = h.create({
226
+ container: this._canvasBox,
227
+ radius: this._radius,
228
+ gradient: this._colorMap,
229
+ maxOpacity: 1,
230
+ minOpacity: 0
231
+ });
232
+ return heatmap;
233
+ }
234
+
235
+ /**
236
+ * create heatmap container canvas
237
+ * @returns
238
+ */
239
+ }, {
240
+ key: "createCanvas",
241
+ value: function createCanvas() {
242
+ var _this$calDataMaxMin3 = this.calDataMaxMin(),
243
+ width = _this$calDataMaxMin3.width,
244
+ height = _this$calDataMaxMin3.height;
245
+ var canvasBox = document.createElement('div');
246
+ canvasBox.style.width = "".concat(width, "px");
247
+ canvasBox.style.height = "".concat(height, "px");
248
+ canvasBox.style.top = '0';
249
+ canvasBox.style.right = '0';
250
+ use.useScene().domElement.parentElement.appendChild(canvasBox);
251
+ return canvasBox;
252
+ }
253
+
254
+ /**
255
+ * calculate resolution scale
256
+ * @param width
257
+ * @returns
258
+ */
259
+ }, {
260
+ key: "calResolutionScale",
261
+ value: function calResolutionScale(width) {
262
+ return Math.max(1, Math.min(10, 10 - width * 9 / 2000));
263
+ }
264
+
265
+ /**
266
+ * handle resolution canvas
267
+ * @param canvas
268
+ * @param scale
269
+ * @returns
270
+ */
271
+ }, {
272
+ key: "handleResolutionCanvas",
273
+ value: function handleResolutionCanvas(canvas, scale) {
274
+ var finalCanvas = document.createElement('canvas');
275
+ finalCanvas.width = canvas.width * scale;
276
+ finalCanvas.height = canvas.height * scale;
277
+ var ctx = finalCanvas.getContext('2d');
278
+ ctx.scale(scale, scale);
279
+ ctx.drawImage(canvas, 0, 0);
280
+ return finalCanvas;
281
+ }
282
+
283
+ /**
284
+ * create attachment mesh
285
+ */
286
+ }, {
287
+ key: "createAttachmentMesh",
288
+ value: function createAttachmentMesh() {
289
+ if (this._attachmentMesh) this.remove(this._attachmentMesh);
290
+ var _this$calDataMaxMin4 = this.calDataMaxMin(),
291
+ width = _this$calDataMaxMin4.width,
292
+ height = _this$calDataMaxMin4.height,
293
+ realShowMax = _this$calDataMaxMin4.realShowMax;
294
+ var canvas = this._heatmap._renderer.canvas;
295
+ var scale = this.calResolutionScale(canvas.width);
296
+ var canvas2 = this.handleResolutionCanvas(canvas, scale);
297
+ var texture = new CanvasTexture(canvas2);
298
+ texture.minFilter = NearestFilter;
299
+ texture.magFilter = NearestFilter;
300
+ this._url = canvas.toDataURL('image/png');
301
+ var threshold = 0.3 / 1000 * realShowMax;
302
+ var shaderMaterial = new ShaderMaterial({
303
+ uniforms: {
304
+ map: {
305
+ value: texture
306
+ },
307
+ granularity: {
308
+ value: realShowMax / 3 < 300 ? 300 : realShowMax / 3
309
+ },
310
+ threshold: {
311
+ value: threshold > 0.6 ? 0.6 : threshold < 0.25 ? 0.25 : threshold
312
+ },
313
+ uOpacity: {
314
+ value: 2.0
315
+ },
316
+ uHeight: {
317
+ value: this._height
318
+ },
319
+ isPixel: {
320
+ value: this._isPixel
321
+ }
322
+ },
323
+ vertexShader: heightVertexShader,
324
+ fragmentShader: heightFragmentShader,
325
+ transparent: true,
326
+ side: DoubleSide
327
+ });
328
+ var mesh = new Mesh(new PlaneGeometry(width, height, 500, 500), shaderMaterial);
329
+ mesh.rotation.x = -Math.PI / 2;
330
+ mesh.position.set(0, 0, 0);
331
+ this._attachmentMesh = mesh;
332
+ this.add(mesh);
333
+ }
334
+
335
+ /**
336
+ * set heatmap data
337
+ * @param data
338
+ */
339
+ }, {
340
+ key: "setData",
341
+ value: function setData(data) {
342
+ this.data = data;
343
+ this._canvasBox && use.useScene().domElement.parentElement.removeChild(this._canvasBox);
344
+ this._canvasBox = this.createCanvas();
345
+ this._heatmap = this.createHeatmapTool();
346
+ this._heatmap.setData({
347
+ data: this.coordinateTransformation(data),
348
+ max: this.defaultMax
349
+ });
350
+ this.createAttachmentMesh();
351
+
352
+ // 聚类暂时不实现
353
+ // this.setSuperclusterData()
354
+ // use.useScene().orbitControls.addEventListener('change', () => {
355
+ // const clusters = this.getSuperclusterData()
356
+ // console.log(clusters)
357
+ // })
358
+ }
359
+ }, {
360
+ key: "removeFromParent",
361
+ value: function removeFromParent() {
362
+ var _this$_attachmentMesh;
363
+ _get(_getPrototypeOf(HeatMap.prototype), "removeFromParent", this).call(this);
364
+ use.useScene().domElement.parentElement.removeChild(this._canvasBox);
365
+
366
+ // @ts-ignore
367
+ (_this$_attachmentMesh = this._attachmentMesh) === null || _this$_attachmentMesh === void 0 || _this$_attachmentMesh.material.map.dispose();
368
+ return this;
369
+ }
370
+ }]);
371
+ return HeatMap;
372
+ }(Object3D);
373
+ export default HeatMap;
374
+ //# sourceMappingURL=HeatMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CanvasTexture","DoubleSide","Mesh","NearestFilter","Object3D","PlaneGeometry","ShaderMaterial","use","h","Supercluster","heightFragmentShader","heightVertexShader","defaultGradient","HeatMap","_Object3D","_inherits","_super","_createSuper","options","_options$radius","_options$height","_options$isPixel","_this","_classCallCheck","call","_defineProperty","_assertThisInitialized","_colorMap","colorMap","_radius","radius","_height","height","_isPixel","isPixel","_range","range","_createClass","key","get","Math","max","apply","_toConsumableArray","data","map","item","value","_url","initSupercluster","_supercluster","minZoom","maxZoom","setSuperclusterData","featuresPoints","type","properties","geometry","coordinates","x","z","console","log","length","load","getZoomLevel","camera","minHeight","maxHeight","min","position","y","getSuperclusterData","_this$calDataMaxMin","calDataMaxMin","zoom","useScene","clusters","getClusters","maxX","minX","maxZ","minZ","abs","ceil","width","realShowWidth","realShowHeight","realShowMax","handleRandeDataFilter","_this2","filter","coordinateTransformation","_this3","hanldeData","_this$calDataMaxMin2","result","_item$radius","floor","createHeatmapTool","heatmap","create","container","_canvasBox","gradient","maxOpacity","minOpacity","createCanvas","_this$calDataMaxMin3","canvasBox","document","createElement","style","concat","top","right","domElement","parentElement","appendChild","calResolutionScale","handleResolutionCanvas","canvas","scale","finalCanvas","ctx","getContext","drawImage","createAttachmentMesh","_attachmentMesh","remove","_this$calDataMaxMin4","_heatmap","_renderer","canvas2","texture","minFilter","magFilter","toDataURL","threshold","shaderMaterial","uniforms","granularity","uOpacity","uHeight","vertexShader","fragmentShader","transparent","side","mesh","rotation","PI","set","add","setData","removeChild","defaultMax","removeFromParent","_this$_attachmentMesh","_get","_getPrototypeOf","prototype","material","dispose"],"sources":["../../../src/business/HeatMap/HeatMap.ts"],"sourcesContent":["import type { PerspectiveCamera } from '@anov/3d-core'\nimport { CanvasTexture, DoubleSide, Mesh, NearestFilter, Object3D, PlaneGeometry, ShaderMaterial, use } from '@anov/3d-core'\nimport h from 'anov-heat-map'\nimport type { AnyProps } from 'supercluster'\nimport Supercluster from 'supercluster'\nimport { heightFragmentShader, heightVertexShader } from './shader'\nimport type { HeatMapData, HeatMapnterface } from './index'\n\ntype RangeType = {\n min: number\n max: number\n}\n\ntype HeatMapOptions = {\n colorMap?: {\n [key: number]: string\n }\n max?: number\n radius?: number\n height?: number\n isPixel?: boolean\n range?: RangeType\n}\n\nconst defaultGradient = { 0.25: 'rgb(0,0,255)', 0.55: 'rgb(0,255,0)', 0.85: 'yellow', 1.0: 'rgb(255,0,0)' }\n\n/**\n * 区域热力图\n */\n\nclass HeatMap extends Object3D implements HeatMapnterface {\n public data: HeatMapData[] = []\n\n private _height: number\n private _radius: number\n private _heatmap: any\n private _url: string\n private _colorMap: {\n [key: number]: string\n }\n\n private _isPixel: boolean\n private _canvasBox: HTMLDivElement | undefined\n private _attachmentMesh: Mesh | undefined\n private _supercluster: Supercluster\n private _range: RangeType | undefined\n\n private get defaultMax() {\n return Math.max(...this.data.map(item => item.value))\n }\n\n public get url() {\n return this._url\n }\n\n constructor(options: HeatMapOptions) {\n super()\n\n this._colorMap = options.colorMap || defaultGradient\n this._radius = options.radius ?? 40\n this._height = options.height ?? 70\n this._isPixel = options.isPixel ?? false\n this._range = options.range\n\n // this.initSupercluster()\n }\n\n private initSupercluster() {\n this._supercluster = new Supercluster({\n radius: 40,\n minZoom: 1,\n maxZoom: 16,\n })\n }\n\n /**\n * set supercluster data\n */\n private setSuperclusterData() {\n const featuresPoints = this.data.map((item) => {\n return {\n type: 'Feature',\n properties: {},\n geometry: {\n type: 'Point',\n coordinates: [item.x, item.z],\n },\n }\n })\n\n console.log('正在加载点数据到supercluster:', featuresPoints.length)\n this._supercluster.load(featuresPoints as Supercluster.PointFeature<AnyProps>[])\n }\n\n /**\n * get zoom level\n * @param camera\n * @returns\n */\n private getZoomLevel(camera: PerspectiveCamera) {\n const minZoom = 10\n const maxZoom = 16\n const minHeight = 10\n const maxHeight = 1000\n\n return Math.max(minZoom, Math.min(maxZoom,\n ((maxHeight - camera.position.y) / (maxHeight - minHeight)) * (maxZoom - minZoom) + minZoom,\n ))\n }\n\n /**\n * get supercluster data\n * @returns\n */\n private getSuperclusterData() {\n const { max } = this.calDataMaxMin()\n const zoom = this.getZoomLevel(use.useScene().camera)\n const clusters = this._supercluster.getClusters([-max, -max, max, max], zoom)\n\n console.log('当前缩放级别:', zoom, '输入点数量:', this.data.length, '聚类后点数量:', clusters.length)\n\n return clusters\n }\n\n /**\n * calculate data max and min\n * @returns\n */\n private calDataMaxMin() {\n const maxX = Math.max(...this.data.map(item => item.x))\n const minX = Math.min(...this.data.map(item => item.x))\n const maxZ = Math.max(...this.data.map(item => item.z))\n const minZ = Math.min(...this.data.map(item => item.z))\n\n const max = Math.max(Math.abs(Math.ceil(maxX)), Math.abs(Math.ceil(minX)), Math.abs(Math.ceil(maxZ)), Math.abs(Math.ceil(minZ)), 60)\n\n const width = max * 2\n const height = max * 2\n\n const realShowWidth = maxX - minX\n const realShowHeight = maxZ - minZ\n const realShowMax = Math.max(Math.ceil(realShowWidth), Math.ceil(realShowHeight), 60)\n\n return { width, height, max, minX, minZ, maxX, maxZ, realShowMax }\n }\n\n /**\n * handle range data filter\n * @param data\n * @returns\n */\n private handleRandeDataFilter(data: HeatMapData[]) {\n if (this._range) {\n return data.filter((item) => {\n return item.x >= this._range.min && item.x <= this._range.max && item.z >= this._range.min && item.z <= this._range.max\n })\n }\n\n return data\n }\n\n /**\n * coordinate transformation\n * @param data\n * @returns\n */\n private coordinateTransformation(data: HeatMapData[]) {\n const hanldeData = this.handleRandeDataFilter(data)\n const { width, height, max } = this.calDataMaxMin()\n\n const result = hanldeData.map(item => ({\n x: Math.floor((item.x - (-max)) / (max - (-max)) * width),\n y: Math.floor((item.z - (-max)) / (max - (-max)) * height),\n value: item.value,\n radius: item.radius ?? this._radius,\n }))\n\n return result\n }\n\n /**\n * generate heatmap texture\n * @param canvasBox\n * @returns\n */\n private createHeatmapTool() {\n const heatmap = h.create({\n container: this._canvasBox,\n radius: this._radius,\n gradient: this._colorMap,\n maxOpacity: 1,\n minOpacity: 0,\n })\n\n return heatmap\n }\n\n /**\n * create heatmap container canvas\n * @returns\n */\n private createCanvas() {\n const { width, height } = this.calDataMaxMin()\n const canvasBox = document.createElement('div')\n\n canvasBox.style.width = `${width}px`\n canvasBox.style.height = `${height}px`\n canvasBox.style.top = '0'\n canvasBox.style.right = '0'\n\n use.useScene().domElement.parentElement.appendChild(canvasBox)\n\n return canvasBox\n }\n\n /**\n * calculate resolution scale\n * @param width\n * @returns\n */\n private calResolutionScale(width: number) {\n return Math.max(1, Math.min(10, 10 - (width * 9) / 2000))\n }\n\n /**\n * handle resolution canvas\n * @param canvas\n * @param scale\n * @returns\n */\n private handleResolutionCanvas(canvas: HTMLCanvasElement, scale: number) {\n const finalCanvas = document.createElement('canvas')\n finalCanvas.width = canvas.width * scale\n finalCanvas.height = canvas.height * scale\n const ctx = finalCanvas.getContext('2d')\n ctx.scale(scale, scale)\n ctx.drawImage(canvas, 0, 0)\n\n return finalCanvas\n }\n\n /**\n * create attachment mesh\n */\n private createAttachmentMesh() {\n if (this._attachmentMesh)\n this.remove(this._attachmentMesh)\n\n const { width, height, realShowMax } = this.calDataMaxMin()\n const canvas = this._heatmap._renderer.canvas\n const scale = this.calResolutionScale(canvas.width)\n const canvas2 = this.handleResolutionCanvas(canvas, scale)\n const texture = new CanvasTexture(canvas2)\n\n texture.minFilter = NearestFilter\n texture.magFilter = NearestFilter\n\n this._url = canvas.toDataURL('image/png')\n\n const threshold = (0.3 / 1000 * realShowMax)\n const shaderMaterial = new ShaderMaterial({\n uniforms: {\n map: { value: texture },\n granularity: { value: realShowMax / 3 < 300 ? 300 : realShowMax / 3 },\n threshold: { value: threshold > 0.6 ? 0.6 : threshold < 0.25 ? 0.25 : threshold },\n uOpacity: { value: 2.0 },\n uHeight: { value: this._height },\n isPixel: { value: this._isPixel },\n },\n vertexShader: heightVertexShader,\n fragmentShader: heightFragmentShader,\n transparent: true,\n side: DoubleSide,\n })\n\n const mesh = new Mesh(new PlaneGeometry(width, height, 500, 500), shaderMaterial)\n\n mesh.rotation.x = -Math.PI / 2\n mesh.position.set(0, 0, 0)\n\n this._attachmentMesh = mesh\n this.add(mesh)\n }\n\n /**\n * set heatmap data\n * @param data\n */\n public setData(data: HeatMapData[]) {\n this.data = data\n this._canvasBox && use.useScene().domElement.parentElement.removeChild(this._canvasBox)\n this._canvasBox = this.createCanvas()\n this._heatmap = this.createHeatmapTool()\n\n this._heatmap.setData({\n data: this.coordinateTransformation(data),\n max: this.defaultMax,\n })\n\n this.createAttachmentMesh()\n\n // 聚类暂时不实现\n // this.setSuperclusterData()\n // use.useScene().orbitControls.addEventListener('change', () => {\n // const clusters = this.getSuperclusterData()\n // console.log(clusters)\n // })\n }\n\n override removeFromParent(): this {\n super.removeFromParent()\n use.useScene().domElement.parentElement.removeChild(this._canvasBox)\n\n // @ts-ignore\n this._attachmentMesh?.material.map.dispose()\n\n return this\n }\n}\n\nexport default HeatMap"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,SAASA,aAAa,EAAEC,UAAU,EAAEC,IAAI,EAAEC,aAAa,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,cAAc,EAAEC,GAAG,QAAQ,eAAe;AAC5H,OAAOC,CAAC,MAAM,eAAe;AAE7B,OAAOC,YAAY,MAAM,cAAc;AACvC,SAASC,oBAAoB,EAAEC,kBAAkB;AAmBjD,IAAMC,eAAe,GAAG;EAAE,IAAI,EAAE,cAAc;EAAE,IAAI,EAAE,cAAc;EAAE,IAAI,EAAE,QAAQ;EAAE,GAAG,EAAE;AAAe,CAAC;;AAE3G;AACA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ACA;IACF;EAAC;IAAAzF,GAAA;IAAAS,KAAA,EAED,SAAA6G,iBAAA,EAAkC;MAAA,IAAAC,qBAAA;MAChCC,IAAA,CAAAC,eAAA,CAAAlJ,OAAA,CAAAmJ,SAAA,6BAAAxI,IAAA;MACAjB,GAAG,CAACqE,QAAQ,CAAC,CAAC,CAACwC,UAAU,CAACC,aAAa,CAACqC,WAAW,CAAC,IAAI,CAACnD,UAAU,CAAC;;MAEpE;MACA,CAAAsD,qBAAA,OAAI,CAAC7B,eAAe,cAAA6B,qBAAA,eAApBA,qBAAA,CAAsBI,QAAQ,CAACpH,GAAG,CAACqH,OAAO,CAAC,CAAC;MAE5C,OAAO,IAAI;IACb;EAAC;EAAA,OAAArJ,OAAA;AAAA,EA/RmBT,QAAQ;AAkS9B,eAAeS,OAAO"}
@@ -0,0 +1,30 @@
1
+ declare class Heatmap {
2
+ private _config;
3
+ private _coordinator;
4
+ _renderer: any;
5
+ private _store;
6
+ constructor(config: any);
7
+ private _connect;
8
+ addData(...args: any[]): this;
9
+ removeData(...args: any[]): this;
10
+ setData(...args: any[]): this;
11
+ setDataMax(...args: any[]): this;
12
+ setDataMin(...args: any[]): this;
13
+ configure(config: any): this;
14
+ repaint(): this;
15
+ getData(): {
16
+ min: number;
17
+ max: number;
18
+ data: any[];
19
+ };
20
+ getDataURL(): any;
21
+ getValueAt(point: {
22
+ x: number;
23
+ y: number;
24
+ }): any;
25
+ }
26
+ export declare const heatmapFactory: {
27
+ create(config: any): Heatmap;
28
+ register(pluginKey: string, plugin: any): void;
29
+ };
30
+ export {};