@antv/l7-layers 2.9.23 → 2.9.25

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.
Files changed (166) hide show
  1. package/es/Geometry/models/plane.d.ts +1 -0
  2. package/es/citybuliding/building.js +1 -1
  3. package/es/core/BaseLayer.js +10 -3
  4. package/es/core/interface.d.ts +26 -48
  5. package/es/core/interface.js +3 -0
  6. package/es/core/schema.d.ts +3 -3
  7. package/es/core/triangulation.d.ts +4 -3
  8. package/es/core/triangulation.js +54 -39
  9. package/es/heatmap/models/heatmap.js +1 -1
  10. package/es/image/models/image.js +7 -1
  11. package/es/line/index.js +4 -1
  12. package/es/line/models/arc.js +1 -1
  13. package/es/line/models/simpleLine.js +1 -1
  14. package/es/line/shaders/line_arc_vert.glsl +5 -3
  15. package/es/line/shaders/simple/simpleline_vert.glsl +1 -0
  16. package/es/plugins/FeatureScalePlugin.js +0 -1
  17. package/es/point/index.js +3 -1
  18. package/es/point/models/fill.js +5 -2
  19. package/es/point/models/fillmage.js +9 -3
  20. package/es/point/models/image.js +8 -2
  21. package/es/point/models/radar.js +2 -3
  22. package/es/point/models/tile.js +1 -1
  23. package/es/point/shaders/fill_vert.glsl +13 -6
  24. package/es/point/shaders/image/fillImage_vert.glsl +13 -5
  25. package/es/point/shaders/image_vert.glsl +17 -8
  26. package/es/polygon/index.js +4 -1
  27. package/es/raster/index.js +3 -1
  28. package/es/tile/manager/tileLayerManager.d.ts +3 -2
  29. package/es/tile/manager/tileLayerManager.js +5 -2
  30. package/es/tile/models/tileModel.js +4 -3
  31. package/es/tile/tileFactory/base.d.ts +1 -1
  32. package/es/tile/tileFactory/base.js +32 -5
  33. package/es/tile/tileFactory/vectorLayer.d.ts +3 -1
  34. package/es/tile/tileFactory/vectorLayer.js +22 -1
  35. package/es/tile/tileLayer/baseTileLayer.d.ts +1 -1
  36. package/es/tile/tileLayer/baseTileLayer.js +3 -2
  37. package/es/tile/utils.d.ts +2 -0
  38. package/es/tile/utils.js +5 -1
  39. package/lib/Geometry/index.js +114 -77
  40. package/lib/Geometry/models/billboard.js +232 -181
  41. package/lib/Geometry/models/index.js +18 -34
  42. package/lib/Geometry/models/plane.js +407 -278
  43. package/lib/Geometry/models/sprite.js +291 -189
  44. package/lib/canvas/index.js +101 -66
  45. package/lib/canvas/models/canvas.js +207 -140
  46. package/lib/canvas/models/index.js +12 -30
  47. package/lib/citybuliding/building.js +98 -63
  48. package/lib/citybuliding/models/build.js +192 -146
  49. package/lib/core/BaseLayer.js +1331 -809
  50. package/lib/core/BaseModel.js +457 -279
  51. package/lib/core/interface.js +40 -53
  52. package/lib/core/schema.js +21 -39
  53. package/lib/core/shape/Path.js +67 -79
  54. package/lib/core/shape/extrude.js +132 -91
  55. package/lib/core/triangulation.js +412 -213
  56. package/lib/earth/index.js +100 -62
  57. package/lib/earth/models/atmosphere.js +146 -112
  58. package/lib/earth/models/base.js +210 -150
  59. package/lib/earth/models/bloomsphere.js +146 -112
  60. package/lib/earth/utils.js +111 -91
  61. package/lib/heatmap/index.js +149 -92
  62. package/lib/heatmap/models/grid.js +118 -91
  63. package/lib/heatmap/models/grid3d.js +155 -123
  64. package/lib/heatmap/models/heatmap.js +475 -338
  65. package/lib/heatmap/models/hexagon.js +121 -92
  66. package/lib/heatmap/models/index.js +22 -37
  67. package/lib/heatmap/triangulation.js +31 -47
  68. package/lib/image/index.js +111 -74
  69. package/lib/image/models/dataImage.js +232 -174
  70. package/lib/image/models/image.js +175 -123
  71. package/lib/image/models/index.js +15 -32
  72. package/lib/index.js +263 -97
  73. package/lib/line/index.js +131 -83
  74. package/lib/line/models/arc.js +352 -237
  75. package/lib/line/models/arc_3d.js +334 -228
  76. package/lib/line/models/earthArc_3d.js +336 -228
  77. package/lib/line/models/great_circle.js +291 -200
  78. package/lib/line/models/half.js +286 -201
  79. package/lib/line/models/index.js +42 -50
  80. package/lib/line/models/line.js +428 -299
  81. package/lib/line/models/linearline.js +277 -203
  82. package/lib/line/models/simpleLine.js +239 -175
  83. package/lib/line/models/tile.js +348 -237
  84. package/lib/line/models/wall.js +327 -235
  85. package/lib/line/shaders/line_arc_vert.glsl +5 -3
  86. package/lib/line/shaders/simple/simpleline_vert.glsl +1 -0
  87. package/lib/mask/index.js +92 -59
  88. package/lib/mask/models/fill.js +134 -82
  89. package/lib/mask/models/index.js +12 -30
  90. package/lib/plugins/DataMappingPlugin.js +342 -224
  91. package/lib/plugins/DataSourcePlugin.js +102 -87
  92. package/lib/plugins/FeatureScalePlugin.js +330 -241
  93. package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
  94. package/lib/plugins/LayerModelPlugin.js +80 -73
  95. package/lib/plugins/LayerStylePlugin.js +48 -51
  96. package/lib/plugins/LightingPlugin.js +80 -68
  97. package/lib/plugins/MultiPassRendererPlugin.js +91 -65
  98. package/lib/plugins/PixelPickingPlugin.js +150 -109
  99. package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
  100. package/lib/plugins/ShaderUniformPlugin.js +118 -99
  101. package/lib/plugins/UpdateModelPlugin.js +40 -47
  102. package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
  103. package/lib/point/index.js +226 -148
  104. package/lib/point/models/earthExtrude.js +279 -201
  105. package/lib/point/models/earthFill.js +287 -202
  106. package/lib/point/models/extrude.js +299 -203
  107. package/lib/point/models/fill.js +406 -273
  108. package/lib/point/models/fillmage.js +365 -252
  109. package/lib/point/models/image.js +241 -164
  110. package/lib/point/models/index.js +46 -52
  111. package/lib/point/models/normal.js +183 -134
  112. package/lib/point/models/radar.js +304 -212
  113. package/lib/point/models/simplePoint.js +194 -142
  114. package/lib/point/models/text.js +608 -385
  115. package/lib/point/models/tile.js +314 -223
  116. package/lib/point/shaders/fill_vert.glsl +13 -6
  117. package/lib/point/shaders/image/fillImage_vert.glsl +13 -5
  118. package/lib/point/shaders/image_vert.glsl +17 -8
  119. package/lib/point/shape/extrude.js +56 -52
  120. package/lib/polygon/index.js +154 -100
  121. package/lib/polygon/models/extrude.js +311 -223
  122. package/lib/polygon/models/fill.js +215 -153
  123. package/lib/polygon/models/index.js +46 -52
  124. package/lib/polygon/models/ocean.js +244 -173
  125. package/lib/polygon/models/tile.js +144 -100
  126. package/lib/polygon/models/water.js +222 -153
  127. package/lib/raster/buffers/triangulation.js +27 -40
  128. package/lib/raster/index.js +115 -74
  129. package/lib/raster/models/index.js +16 -33
  130. package/lib/raster/models/raster.js +178 -135
  131. package/lib/raster/raster.js +187 -132
  132. package/lib/tile/interface.js +4 -16
  133. package/lib/tile/manager/tileConfigManager.js +125 -86
  134. package/lib/tile/manager/tileLayerManager.js +314 -227
  135. package/lib/tile/manager/tilePickerManager.js +192 -123
  136. package/lib/tile/models/tileModel.js +71 -51
  137. package/lib/tile/tileFactory/base.js +433 -292
  138. package/lib/tile/tileFactory/index.js +51 -49
  139. package/lib/tile/tileFactory/line.js +65 -50
  140. package/lib/tile/tileFactory/point.js +65 -50
  141. package/lib/tile/tileFactory/polygon.js +65 -50
  142. package/lib/tile/tileFactory/raster.js +66 -54
  143. package/lib/tile/tileFactory/rasterData.js +88 -76
  144. package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
  145. package/lib/tile/tileFactory/vectorLayer.js +169 -95
  146. package/lib/tile/tileLayer/baseTileLayer.js +420 -220
  147. package/lib/tile/tmsTileLayer.js +110 -67
  148. package/lib/tile/utils.js +113 -87
  149. package/lib/utils/blend.js +59 -79
  150. package/lib/utils/collision-index.js +107 -64
  151. package/lib/utils/dataMappingStyle.js +105 -60
  152. package/lib/utils/extrude_polyline.js +600 -398
  153. package/lib/utils/grid-index.js +163 -111
  154. package/lib/utils/layerData.js +130 -99
  155. package/lib/utils/multiPassRender.js +49 -41
  156. package/lib/utils/polylineNormal.js +148 -96
  157. package/lib/utils/simpleLine.js +100 -85
  158. package/lib/utils/symbol-layout.js +219 -116
  159. package/lib/utils/updateShape.js +15 -41
  160. package/lib/wind/index.js +109 -71
  161. package/lib/wind/models/index.js +12 -30
  162. package/lib/wind/models/utils.js +144 -105
  163. package/lib/wind/models/wind.js +333 -224
  164. package/lib/wind/models/windRender.js +329 -218
  165. package/lib/wind/models/windShader.js +23 -181
  166. package/package.json +7 -6
@@ -1,287 +1,420 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
-
22
- // src/point/models/fill.ts
23
- var fill_exports = {};
24
- __export(fill_exports, {
25
- default: () => FillModel
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
26
7
  });
27
- module.exports = __toCommonJS(fill_exports);
28
- var import_l7_core = require("@antv/l7-core");
29
- var import_l7_utils = require("@antv/l7-utils");
30
- var import_lodash = require("lodash");
31
- var import_BaseModel = __toESM(require("../../core/BaseModel"));
32
- var import_wave_frag = __toESM(require("../shaders/animate/wave_frag.glsl"));
33
- var import_fill_frag = __toESM(require("../shaders/fill_frag.glsl"));
34
- var import_fill_vert = __toESM(require("../shaders/fill_vert.glsl"));
35
- var import_l7_maps = require("@antv/l7-maps");
36
- var FillModel = class extends import_BaseModel.default {
37
- constructor() {
38
- super(...arguments);
39
- this.meter2coord = 1;
40
- this.meteryScale = 1;
41
- this.isMeter = false;
42
- this.unit = "l7size";
43
- }
44
- getUninforms() {
45
- const {
46
- opacity = 1,
47
- strokeOpacity = 1,
48
- strokeWidth = 0,
49
- stroke = "rgba(0,0,0,0)",
50
- offsets = [0, 0],
51
- blend,
52
- blur = 0,
53
- raisingHeight = 0,
54
- unit = "l7size"
55
- } = this.layer.getLayerConfig();
56
- this.updateUnit(unit);
57
- if (this.dataTextureTest && this.dataTextureNeedUpdate({
58
- opacity,
59
- strokeOpacity,
60
- strokeWidth,
61
- stroke,
62
- offsets
63
- })) {
64
- this.judgeStyleAttributes({
65
- opacity,
66
- strokeOpacity,
67
- strokeWidth,
68
- stroke,
69
- offsets
70
- });
71
- const encodeData = this.layer.getEncodedData();
72
- const { data, width, height } = this.calDataFrame(this.cellLength, encodeData, this.cellProperties);
73
- this.rowCount = height;
74
- this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
75
- flipY: true,
76
- data,
77
- format: import_l7_core.gl.LUMINANCE,
78
- type: import_l7_core.gl.FLOAT,
79
- width,
80
- height
81
- }) : this.createTexture2D({
82
- flipY: true,
83
- data: [1],
84
- format: import_l7_core.gl.LUMINANCE,
85
- type: import_l7_core.gl.FLOAT,
86
- width: 1,
87
- height: 1
88
- });
8
+ exports.default = void 0;
9
+
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
+
14
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
+
16
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
17
+
18
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
19
+
20
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
21
+
22
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
23
+
24
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
25
+
26
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
27
+
28
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
29
+
30
+ var _l7Core = require("@antv/l7-core");
31
+
32
+ var _l7Utils = require("@antv/l7-utils");
33
+
34
+ var _lodash = require("lodash");
35
+
36
+ var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
37
+
38
+ var _l7Maps = require("@antv/l7-maps");
39
+
40
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
41
+
42
+ 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; } }
43
+
44
+ /* babel-plugin-inline-import '../shaders/animate/wave_frag.glsl' */
45
+ // import { PointFillTriangulation } from '../../core/triangulation';
46
+ // animate pointLayer shader - support animate
47
+ var waveFillFrag = "\nuniform float u_additive;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n\n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n float opacity = styleMappingMat[0][0];\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n \n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n float color_t = smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n float PI = 3.14159;\n float N_RINGS = 3.0;\n float FREQ = 1.0;\n\n gl_FragColor = vec4(v_color.rgb, v_color.a * opacity);\n\n float d = length(v_data.xy);\n if(d > 0.5) {\n discard;\n }\n float intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_aimate.z - u_aimate.y * u_time)), 0.0, 1.0);\n \n // TODO: \u6839\u636E\u53E0\u52A0\u6A21\u5F0F\u9009\u62E9\u6548\u679C\n if(u_additive > 0.0) {\n gl_FragColor *= intensity;\n // TODO: \u4F18\u5316\u6C34\u6CE2\u70B9 blend additive \u6A21\u5F0F\u4E0B\u6709\u7684\u62FE\u53D6\u6548\u679C \n gl_FragColor = filterColorAlpha(gl_FragColor, gl_FragColor.a);\n } else {\n gl_FragColor = vec4(gl_FragColor.xyz, gl_FragColor.a * intensity);\n gl_FragColor = filterColor(gl_FragColor);\n }\n}\n"; // static pointLayer shader - not support animate
48
+
49
+ /* babel-plugin-inline-import '../shaders/fill_frag.glsl' */
50
+ var pointFillFrag = "uniform float u_additive;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n\n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n float opacity = styleMappingMat[0][0];\n float stroke_opacity = styleMappingMat[0][1];\n float strokeWidth = styleMappingMat[0][2];\n vec4 strokeColor = textrueStroke == vec4(0) ? v_color : textrueStroke;\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius + strokeWidth);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n if (shape == 0) {\n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n } else if (shape == 1) {\n outer_df = sdEquilateralTriangle(1.1 * v_data.xy);\n inner_df = sdEquilateralTriangle(1.1 / r * v_data.xy);\n } else if (shape == 2) {\n outer_df = sdBox(v_data.xy, vec2(1.));\n inner_df = sdBox(v_data.xy, vec2(r));\n } else if (shape == 3) {\n outer_df = sdPentagon(v_data.xy, 0.8);\n inner_df = sdPentagon(v_data.xy, r * 0.8);\n } else if (shape == 4) {\n outer_df = sdHexagon(v_data.xy, 0.8);\n inner_df = sdHexagon(v_data.xy, r * 0.8);\n } else if (shape == 5) {\n outer_df = sdOctogon(v_data.xy, 1.0);\n inner_df = sdOctogon(v_data.xy, r);\n } else if (shape == 6) {\n outer_df = sdHexagram(v_data.xy, 0.52);\n inner_df = sdHexagram(v_data.xy, r * 0.52);\n } else if (shape == 7) {\n outer_df = sdRhombus(v_data.xy, vec2(1.0));\n inner_df = sdRhombus(v_data.xy, vec2(r));\n } else if (shape == 8) {\n outer_df = sdVesica(v_data.xy, 1.1, 0.8);\n inner_df = sdVesica(v_data.xy, r * 1.1, r * 0.8);\n }\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n float color_t = strokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n\n if(strokeWidth < 0.01) {\n gl_FragColor = vec4(v_color.rgb, v_color.a * opacity);\n } else {\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), strokeColor * stroke_opacity, color_t);\n }\n\n if(u_additive > 0.0) {\n gl_FragColor *= opacity_t;\n gl_FragColor = filterColorAlpha(gl_FragColor, gl_FragColor.a);\n } else {\n gl_FragColor.a *= opacity_t;\n gl_FragColor = filterColor(gl_FragColor);\n }\n}\n";
51
+
52
+ /* babel-plugin-inline-import '../shaders/fill_vert.glsl' */
53
+ var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute float a_Shape;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_meter2coord;\nuniform float u_meteryScale;\nuniform float u_isMeter;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\n\nuniform float u_opacity : 1;\nuniform float u_stroke_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\nuniform vec2 u_offsets;\n\nuniform float u_blur : 0.0;\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\n\nvoid main() {\n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n /*\n * setPickingSize \u8BBE\u7F6E\u62FE\u53D6\u5927\u5C0F\n * u_meter2coord \u5728\u7B49\u9762\u79EF\u5927\u5C0F\u7684\u65F6\u5019\u8BBE\u7F6E\u5355\u4F4D\n */\n float newSize = setPickingSize(a_Size) * u_meter2coord;\n // float newSize = setPickingSize(a_Size) * 0.00001038445708445579;\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 strokeOpacityAndOffset = calStrokeOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][1] = strokeOpacityAndOffset.r;\n textureOffset = strokeOpacityAndOffset.g;\n\n vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][2] = strokeWidthAndOffset.r;\n textureOffset = strokeWidthAndOffset.g;\n\n vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);\n if(hasStroke()) {\n vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R\n textureOffset += 1.0;\n\n vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G\n textureOffset += 1.0;\n\n vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B\n textureOffset += 1.0;\n\n vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A\n textureOffset += 1.0;\n } else {\n if(u_stroke_color == vec4(0.0)) {\n styleMappingMat[1][0] = v_color.r;\n styleMappingMat[1][1] = v_color.g;\n styleMappingMat[1][2] = v_color.b;\n styleMappingMat[1][3] = v_color.a;\n } else {\n styleMappingMat[1][0] = u_stroke_color.r;\n styleMappingMat[1][1] = u_stroke_color.g;\n styleMappingMat[1][2] = u_stroke_color.b;\n styleMappingMat[1][3] = u_stroke_color.a;\n }\n }\n\n vec2 textrueOffsets = vec2(0.0, 0.0);\n if(hasOffsets()) {\n vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n\n vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n } else {\n textrueOffsets = u_offsets;\n }\n\n // cal style mapping\n\n // unpack color(vec2)\n v_color = a_Color;\n\n // radius(16-bit)\n v_radius = newSize;\n\n // TODO: billboard\n // anti-alias\n // float antialiased_blur = -max(u_blur, antialiasblur);\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur);\n\n vec2 offset = (extrude.xy * (newSize + u_stroke_width) + textrueOffsets);\n vec3 aPosition = a_Position;\n if(u_isMeter < 1.0) {\n // \u4E0D\u4EE5\u7C73\u4E3A\u5B9E\u9645\u5355\u4F4D\n offset = project_pixel(offset);\n } else {\n // \u4EE5\u7C73\u4E3A\u5B9E\u9645\u5355\u4F4D\n if(newSize * pow(2.0, u_Zoom) < 48.0) {\n antialiasblur = max(antialiasblur, -0.05);\n } else if(newSize * pow(2.0, u_Zoom) < 128.0) {\n antialiasblur = max(antialiasblur, -0.6/pow(u_Zoom, 2.0));\n } else {\n antialiasblur = max(antialiasblur, -0.8/pow(u_Zoom, 2.0));\n }\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n aPosition.x += offset.x / u_meteryScale;\n aPosition.y += offset.y;\n offset = vec2(0.0);\n }\n }\n\n // TODP: /abs(extrude.x) \u662F\u4E3A\u4E86\u517C\u5BB9\u5730\u7403\u6A21\u5F0F\n v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);\n\n\n // vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n float raisingHeight = u_raisingHeight;\n\n if(u_heightfixed < 1.0) { // false\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n \n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
54
+
55
+ var FillModel = /*#__PURE__*/function (_BaseModel) {
56
+ (0, _inherits2.default)(FillModel, _BaseModel);
57
+
58
+ var _super = _createSuper(FillModel);
59
+
60
+ function FillModel() {
61
+ var _this;
62
+
63
+ (0, _classCallCheck2.default)(this, FillModel);
64
+
65
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
66
+ args[_key] = arguments[_key];
89
67
  }
90
- return {
91
- u_raisingHeight: Number(raisingHeight),
92
- u_meter2coord: this.meter2coord,
93
- u_meteryScale: this.meteryScale,
94
- u_isMeter: Number(this.isMeter),
95
- u_blur: blur,
96
- u_additive: blend === "additive" ? 1 : 0,
97
- u_dataTexture: this.dataTexture,
98
- u_cellTypeLayout: this.getCellTypeLayout(),
99
- u_opacity: (0, import_lodash.isNumber)(opacity) ? opacity : 1,
100
- u_stroke_opacity: (0, import_lodash.isNumber)(strokeOpacity) ? strokeOpacity : 1,
101
- u_stroke_width: (0, import_lodash.isNumber)(strokeWidth) ? strokeWidth : 1,
102
- u_stroke_color: this.getStrokeColor(stroke),
103
- u_offsets: this.isOffsetStatic(offsets) ? offsets : [0, 0]
104
- };
105
- }
106
- getAnimateUniforms() {
107
- const {
108
- animateOption = { enable: false }
109
- } = this.layer.getLayerConfig();
110
- return {
111
- u_aimate: this.animateOption2Array(animateOption),
112
- u_time: this.layer.getLayerAnimateTime()
113
- };
114
- }
115
- getAttribute() {
116
- return this.styleAttributeService.createAttributesAndIndices(this.layer.getEncodedData(), import_l7_utils.PointFillTriangulation);
117
- }
118
- initModels(callbackModel) {
119
- this.updateUnit("l7size");
120
- this.buildModels(callbackModel);
68
+
69
+ _this = _super.call.apply(_super, [this].concat(args));
70
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "meter2coord", 1);
71
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "meteryScale", 1);
72
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isMeter", false);
73
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "unit", 'l7size');
74
+ return _this;
121
75
  }
122
- calMeter2Coord() {
123
- var _a;
124
- const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;
125
- const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];
126
- const { version } = this.mapService;
127
- const mapboxContext = (_a = import_l7_utils.$window) == null ? void 0 : _a.mapboxgl;
128
- if (version === import_l7_maps.Version.MAPBOX && (mapboxContext == null ? void 0 : mapboxContext.MercatorCoordinate)) {
129
- const coord = mapboxContext.MercatorCoordinate.fromLngLat({ lng: center[0], lat: center[1] }, 0);
130
- const offsetInMercatorCoordinateUnits = coord.meterInMercatorCoordinateUnits();
131
- const westCoord = new mapboxContext.MercatorCoordinate(coord.x - offsetInMercatorCoordinateUnits, coord.y, coord.z);
132
- const westLnglat = westCoord.toLngLat();
133
- const southCoord = new mapboxContext.MercatorCoordinate(coord.x, coord.y - offsetInMercatorCoordinateUnits, coord.z);
134
- const southLnglat = southCoord.toLngLat();
135
- this.meter2coord = center[0] - westLnglat.lng;
136
- this.meteryScale = (southLnglat.lat - center[1]) / this.meter2coord;
137
- return;
76
+
77
+ (0, _createClass2.default)(FillModel, [{
78
+ key: "getUninforms",
79
+ value: function getUninforms() {
80
+ var _ref = this.layer.getLayerConfig(),
81
+ _ref$opacity = _ref.opacity,
82
+ opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
83
+ _ref$strokeOpacity = _ref.strokeOpacity,
84
+ strokeOpacity = _ref$strokeOpacity === void 0 ? 1 : _ref$strokeOpacity,
85
+ _ref$strokeWidth = _ref.strokeWidth,
86
+ strokeWidth = _ref$strokeWidth === void 0 ? 0 : _ref$strokeWidth,
87
+ _ref$stroke = _ref.stroke,
88
+ stroke = _ref$stroke === void 0 ? 'rgba(0,0,0,0)' : _ref$stroke,
89
+ _ref$offsets = _ref.offsets,
90
+ offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets,
91
+ blend = _ref.blend,
92
+ _ref$blur = _ref.blur,
93
+ blur = _ref$blur === void 0 ? 0 : _ref$blur,
94
+ _ref$raisingHeight = _ref.raisingHeight,
95
+ raisingHeight = _ref$raisingHeight === void 0 ? 0 : _ref$raisingHeight,
96
+ _ref$heightfixed = _ref.heightfixed,
97
+ heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed,
98
+ _ref$unit = _ref.unit,
99
+ unit = _ref$unit === void 0 ? 'l7size' : _ref$unit;
100
+
101
+ this.updateUnit(unit);
102
+
103
+ if (this.dataTextureTest && this.dataTextureNeedUpdate({
104
+ opacity: opacity,
105
+ strokeOpacity: strokeOpacity,
106
+ strokeWidth: strokeWidth,
107
+ stroke: stroke,
108
+ offsets: offsets
109
+ })) {
110
+ // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量
111
+ this.judgeStyleAttributes({
112
+ opacity: opacity,
113
+ strokeOpacity: strokeOpacity,
114
+ strokeWidth: strokeWidth,
115
+ stroke: stroke,
116
+ offsets: offsets
117
+ });
118
+ var encodeData = this.layer.getEncodedData();
119
+
120
+ var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
121
+ data = _this$calDataFrame.data,
122
+ width = _this$calDataFrame.width,
123
+ height = _this$calDataFrame.height;
124
+
125
+ this.rowCount = height; // 当前数据纹理有多少行
126
+
127
+ this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
128
+ flipY: true,
129
+ data: data,
130
+ format: _l7Core.gl.LUMINANCE,
131
+ type: _l7Core.gl.FLOAT,
132
+ width: width,
133
+ height: height
134
+ }) : this.createTexture2D({
135
+ flipY: true,
136
+ data: [1],
137
+ format: _l7Core.gl.LUMINANCE,
138
+ type: _l7Core.gl.FLOAT,
139
+ width: 1,
140
+ height: 1
141
+ });
142
+ }
143
+
144
+ return {
145
+ u_raisingHeight: Number(raisingHeight),
146
+ u_heightfixed: Number(heightfixed),
147
+ u_meter2coord: this.meter2coord,
148
+ u_meteryScale: this.meteryScale,
149
+ u_isMeter: Number(this.isMeter),
150
+ u_blur: blur,
151
+ u_additive: blend === 'additive' ? 1.0 : 0.0,
152
+ u_dataTexture: this.dataTexture,
153
+ // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
154
+ u_cellTypeLayout: this.getCellTypeLayout(),
155
+ u_opacity: (0, _lodash.isNumber)(opacity) ? opacity : 1.0,
156
+ u_stroke_opacity: (0, _lodash.isNumber)(strokeOpacity) ? strokeOpacity : 1.0,
157
+ u_stroke_width: (0, _lodash.isNumber)(strokeWidth) ? strokeWidth : 1.0,
158
+ u_stroke_color: this.getStrokeColor(stroke),
159
+ u_offsets: this.isOffsetStatic(offsets) ? offsets : [0, 0]
160
+ };
161
+ }
162
+ }, {
163
+ key: "getAnimateUniforms",
164
+ value: function getAnimateUniforms() {
165
+ var _ref2 = this.layer.getLayerConfig(),
166
+ _ref2$animateOption = _ref2.animateOption,
167
+ animateOption = _ref2$animateOption === void 0 ? {
168
+ enable: false
169
+ } : _ref2$animateOption;
170
+
171
+ return {
172
+ u_aimate: this.animateOption2Array(animateOption),
173
+ u_time: this.layer.getLayerAnimateTime()
174
+ };
138
175
  }
139
- const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);
140
- const m2 = this.mapService.meterToCoord(center, [
141
- maxLng === minLng ? maxLng + 0.1 : maxLng,
142
- maxLat === minLat ? minLat + 0.1 : maxLat
143
- ]);
144
- this.meter2coord = (m1 + m2) / 2;
145
- if (!Boolean(this.meter2coord)) {
146
- this.meter2coord = 7.70681090738883;
176
+ }, {
177
+ key: "getAttribute",
178
+ value: function getAttribute() {
179
+ return this.styleAttributeService.createAttributesAndIndices(this.layer.getEncodedData(), _l7Utils.PointFillTriangulation);
147
180
  }
148
- }
149
- async buildModels(callbackModel) {
150
- const {
151
- mask = false,
152
- maskInside = true,
153
- animateOption = { enable: false },
154
- workerEnabled = false,
155
- enablePicking,
156
- shape2d
157
- } = this.layer.getLayerConfig();
158
- const { frag, vert, type } = this.getShaders(animateOption);
159
- this.layer.triangulation = import_l7_utils.PointFillTriangulation;
160
- this.layer.buildLayerModel({
161
- moduleName: type,
162
- vertexShader: vert,
163
- fragmentShader: frag,
164
- triangulation: import_l7_utils.PointFillTriangulation,
165
- depth: { enable: false },
166
- blend: this.getBlend(),
167
- stencil: (0, import_l7_utils.getMask)(mask, maskInside),
168
- workerEnabled,
169
- workerOptions: {
170
- modelType: type,
171
- enablePicking,
172
- shape2d
181
+ }, {
182
+ key: "initModels",
183
+ value: function initModels(callbackModel) {
184
+ this.updateUnit('l7size');
185
+ this.buildModels(callbackModel);
186
+ }
187
+ /**
188
+ * 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例
189
+ * @returns
190
+ */
191
+
192
+ }, {
193
+ key: "calMeter2Coord",
194
+ value: function calMeter2Coord() {
195
+ var _this$layer$getSource = (0, _slicedToArray2.default)(this.layer.getSource().extent, 4),
196
+ minLng = _this$layer$getSource[0],
197
+ minLat = _this$layer$getSource[1],
198
+ maxLng = _this$layer$getSource[2],
199
+ maxLat = _this$layer$getSource[3];
200
+
201
+ var center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];
202
+ var version = this.mapService.version;
203
+ var mapboxContext = _l7Utils.$window === null || _l7Utils.$window === void 0 ? void 0 : _l7Utils.$window.mapboxgl;
204
+
205
+ if (version === _l7Maps.Version.MAPBOX && mapboxContext !== null && mapboxContext !== void 0 && mapboxContext.MercatorCoordinate) {
206
+ // 参考:
207
+ // https://docs.mapbox.com/mapbox-gl-js/api/geography/#mercatorcoordinate#meterinmercatorcoordinateunits
208
+ var coord = mapboxContext.MercatorCoordinate.fromLngLat({
209
+ lng: center[0],
210
+ lat: center[1]
211
+ }, 0);
212
+ var offsetInMercatorCoordinateUnits = coord.meterInMercatorCoordinateUnits();
213
+ var westCoord = new mapboxContext.MercatorCoordinate(coord.x - offsetInMercatorCoordinateUnits, coord.y, coord.z);
214
+ var westLnglat = westCoord.toLngLat();
215
+ var southCoord = new mapboxContext.MercatorCoordinate(coord.x, coord.y - offsetInMercatorCoordinateUnits, coord.z);
216
+ var southLnglat = southCoord.toLngLat();
217
+ this.meter2coord = center[0] - westLnglat.lng;
218
+ this.meteryScale = (southLnglat.lat - center[1]) / this.meter2coord;
219
+ return;
173
220
  }
174
- }).then((model) => {
175
- callbackModel([model]);
176
- }).catch((err) => {
177
- console.warn(err);
178
- callbackModel([]);
179
- });
180
- }
181
- getShaders(animateOption) {
182
- if (animateOption.enable) {
183
- switch (animateOption.type) {
184
- case "wave":
185
- return {
186
- frag: import_wave_frag.default,
187
- vert: import_fill_vert.default,
188
- type: "pointWave"
189
- };
190
- default:
191
- return {
192
- frag: import_wave_frag.default,
193
- vert: import_fill_vert.default,
194
- type: "pointWave"
195
- };
221
+
222
+ var m1 = this.mapService.meterToCoord(center, [minLng, minLat]);
223
+ var m2 = this.mapService.meterToCoord(center, [maxLng === minLng ? maxLng + 0.1 : maxLng, maxLat === minLat ? minLat + 0.1 : maxLat]);
224
+ this.meter2coord = (m1 + m2) / 2;
225
+
226
+ if (!this.meter2coord) {
227
+ // Tip: 兼容单个数据导致的 m1、m2 为 NaN
228
+ this.meter2coord = 7.70681090738883;
196
229
  }
197
- } else {
198
- return {
199
- frag: import_fill_frag.default,
200
- vert: import_fill_vert.default,
201
- type: "pointFill"
202
- };
203
230
  }
204
- }
205
- clearModels() {
206
- var _a;
207
- (_a = this.dataTexture) == null ? void 0 : _a.destroy();
208
- }
209
- animateOption2Array(option) {
210
- return [option.enable ? 0 : 1, option.speed || 1, option.rings || 3, 0];
211
- }
212
- registerBuiltinAttributes() {
213
- const shape2d = this.layer.getLayerConfig().shape2d;
214
- this.styleAttributeService.registerStyleAttribute({
215
- name: "extrude",
216
- type: import_l7_core.AttributeType.Attribute,
217
- descriptor: {
218
- name: "a_Extrude",
219
- buffer: {
220
- usage: import_l7_core.gl.DYNAMIC_DRAW,
221
- data: [],
222
- type: import_l7_core.gl.FLOAT
223
- },
224
- size: 3,
225
- update: (feature, featureIdx, vertex, attributeIdx) => {
226
- const extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];
227
- const extrudeIndex = attributeIdx % 4 * 3;
228
- return [
229
- extrude[extrudeIndex],
230
- extrude[extrudeIndex + 1],
231
- extrude[extrudeIndex + 2]
232
- ];
233
- }
231
+ }, {
232
+ key: "buildModels",
233
+ value: function () {
234
+ var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(callbackModel) {
235
+ var _ref3, _ref3$mask, mask, _ref3$maskInside, maskInside, _ref3$animateOption, animateOption, _ref3$workerEnabled, workerEnabled, enablePicking, shape2d, _this$getShaders, frag, vert, type;
236
+
237
+ return _regenerator.default.wrap(function _callee$(_context) {
238
+ while (1) {
239
+ switch (_context.prev = _context.next) {
240
+ case 0:
241
+ _ref3 = this.layer.getLayerConfig(), _ref3$mask = _ref3.mask, mask = _ref3$mask === void 0 ? false : _ref3$mask, _ref3$maskInside = _ref3.maskInside, maskInside = _ref3$maskInside === void 0 ? true : _ref3$maskInside, _ref3$animateOption = _ref3.animateOption, animateOption = _ref3$animateOption === void 0 ? {
242
+ enable: false
243
+ } : _ref3$animateOption, _ref3$workerEnabled = _ref3.workerEnabled, workerEnabled = _ref3$workerEnabled === void 0 ? false : _ref3$workerEnabled, enablePicking = _ref3.enablePicking, shape2d = _ref3.shape2d;
244
+ _this$getShaders = this.getShaders(animateOption), frag = _this$getShaders.frag, vert = _this$getShaders.vert, type = _this$getShaders.type;
245
+ this.layer.triangulation = _l7Utils.PointFillTriangulation;
246
+ this.layer.buildLayerModel({
247
+ moduleName: type,
248
+ vertexShader: vert,
249
+ fragmentShader: frag,
250
+ triangulation: _l7Utils.PointFillTriangulation,
251
+ depth: {
252
+ enable: false
253
+ },
254
+ blend: this.getBlend(),
255
+ stencil: (0, _l7Utils.getMask)(mask, maskInside),
256
+ workerEnabled: workerEnabled,
257
+ workerOptions: {
258
+ modelType: type,
259
+ enablePicking: enablePicking,
260
+ shape2d: shape2d
261
+ }
262
+ }).then(function (model) {
263
+ callbackModel([model]);
264
+ }).catch(function (err) {
265
+ console.warn(err);
266
+ callbackModel([]);
267
+ });
268
+
269
+ case 4:
270
+ case "end":
271
+ return _context.stop();
272
+ }
273
+ }
274
+ }, _callee, this);
275
+ }));
276
+
277
+ function buildModels(_x) {
278
+ return _buildModels.apply(this, arguments);
234
279
  }
235
- });
236
- this.styleAttributeService.registerStyleAttribute({
237
- name: "size",
238
- type: import_l7_core.AttributeType.Attribute,
239
- descriptor: {
240
- name: "a_Size",
241
- buffer: {
242
- usage: import_l7_core.gl.DYNAMIC_DRAW,
243
- data: [],
244
- type: import_l7_core.gl.FLOAT
245
- },
246
- size: 1,
247
- update: (feature, featureIdx, vertex, attributeIdx) => {
248
- const { size = 5 } = feature;
249
- return Array.isArray(size) ? [size[0]] : [size];
280
+
281
+ return buildModels;
282
+ }()
283
+ /**
284
+ * 根据 animateOption 的值返回对应的 shader 代码
285
+ * @returns
286
+ */
287
+
288
+ }, {
289
+ key: "getShaders",
290
+ value: function getShaders(animateOption) {
291
+ if (animateOption.enable) {
292
+ switch (animateOption.type) {
293
+ case 'wave':
294
+ return {
295
+ frag: waveFillFrag,
296
+ vert: pointFillVert,
297
+ type: 'pointWave'
298
+ };
299
+
300
+ default:
301
+ return {
302
+ frag: waveFillFrag,
303
+ vert: pointFillVert,
304
+ type: 'pointWave'
305
+ };
250
306
  }
307
+ } else {
308
+ return {
309
+ frag: pointFillFrag,
310
+ vert: pointFillVert,
311
+ type: 'pointFill'
312
+ };
251
313
  }
252
- });
253
- this.styleAttributeService.registerStyleAttribute({
254
- name: "shape",
255
- type: import_l7_core.AttributeType.Attribute,
256
- descriptor: {
257
- name: "a_Shape",
258
- buffer: {
259
- usage: import_l7_core.gl.DYNAMIC_DRAW,
260
- data: [],
261
- type: import_l7_core.gl.FLOAT
262
- },
263
- size: 1,
264
- update: (feature, featureIdx, vertex, attributeIdx) => {
265
- const { shape = 2 } = feature;
266
- const shapeIndex = shape2d.indexOf(shape);
267
- return [shapeIndex];
314
+ }
315
+ }, {
316
+ key: "clearModels",
317
+ value: function clearModels() {
318
+ var _this$dataTexture;
319
+
320
+ (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
321
+ } // overwrite baseModel func
322
+
323
+ }, {
324
+ key: "animateOption2Array",
325
+ value: function animateOption2Array(option) {
326
+ return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];
327
+ }
328
+ }, {
329
+ key: "registerBuiltinAttributes",
330
+ value: function registerBuiltinAttributes() {
331
+ var shape2d = this.layer.getLayerConfig().shape2d;
332
+ this.styleAttributeService.registerStyleAttribute({
333
+ name: 'extrude',
334
+ type: _l7Core.AttributeType.Attribute,
335
+ descriptor: {
336
+ name: 'a_Extrude',
337
+ buffer: {
338
+ // give the WebGL driver a hint that this buffer may change
339
+ usage: _l7Core.gl.DYNAMIC_DRAW,
340
+ data: [],
341
+ type: _l7Core.gl.FLOAT
342
+ },
343
+ size: 3,
344
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
345
+ var extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];
346
+ var extrudeIndex = attributeIdx % 4 * 3;
347
+ return [extrude[extrudeIndex], extrude[extrudeIndex + 1], extrude[extrudeIndex + 2]];
348
+ }
268
349
  }
350
+ }); // point layer size;
351
+
352
+ this.styleAttributeService.registerStyleAttribute({
353
+ name: 'size',
354
+ type: _l7Core.AttributeType.Attribute,
355
+ descriptor: {
356
+ name: 'a_Size',
357
+ buffer: {
358
+ // give the WebGL driver a hint that this buffer may change
359
+ usage: _l7Core.gl.DYNAMIC_DRAW,
360
+ data: [],
361
+ type: _l7Core.gl.FLOAT
362
+ },
363
+ size: 1,
364
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
365
+ var _feature$size = feature.size,
366
+ size = _feature$size === void 0 ? 5 : _feature$size;
367
+ return Array.isArray(size) ? [size[0]] : [size];
368
+ }
369
+ }
370
+ }); // point layer size;
371
+
372
+ this.styleAttributeService.registerStyleAttribute({
373
+ name: 'shape',
374
+ type: _l7Core.AttributeType.Attribute,
375
+ descriptor: {
376
+ name: 'a_Shape',
377
+ buffer: {
378
+ // give the WebGL driver a hint that this buffer may change
379
+ usage: _l7Core.gl.DYNAMIC_DRAW,
380
+ data: [],
381
+ type: _l7Core.gl.FLOAT
382
+ },
383
+ size: 1,
384
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
385
+ var _feature$shape = feature.shape,
386
+ shape = _feature$shape === void 0 ? 2 : _feature$shape;
387
+ var shapeIndex = shape2d.indexOf(shape);
388
+ return [shapeIndex];
389
+ }
390
+ }
391
+ });
392
+ }
393
+ /**
394
+ * 判断是否更新点图层的计量单位
395
+ * @param unit
396
+ */
397
+
398
+ }, {
399
+ key: "updateUnit",
400
+ value: function updateUnit(unit) {
401
+ var version = this.mapService.version;
402
+
403
+ if (this.unit !== unit) {
404
+ // l7size => meter
405
+ if (this.unit !== 'meter' && unit === 'meter' && version !== _l7Maps.Version.L7MAP && version !== _l7Maps.Version.GLOBEL) {
406
+ this.isMeter = true;
407
+ this.calMeter2Coord(); // meter => l7size
408
+ } else if (this.unit === 'meter' && unit !== 'meter') {
409
+ this.isMeter = false;
410
+ this.meter2coord = 1;
411
+ }
412
+
413
+ this.unit = unit;
269
414
  }
270
- });
271
- }
272
- updateUnit(unit) {
273
- const { version } = this.mapService;
274
- if (this.unit !== unit) {
275
- if (this.unit !== "meter" && unit === "meter" && version !== import_l7_maps.Version.L7MAP && version !== import_l7_maps.Version.GLOBEL) {
276
- this.isMeter = true;
277
- this.calMeter2Coord();
278
- } else if (this.unit === "meter" && unit !== "meter") {
279
- this.isMeter = false;
280
- this.meter2coord = 1;
281
- }
282
- this.unit = unit;
283
415
  }
284
- }
285
- };
286
- // Annotate the CommonJS export names for ESM import in node:
287
- 0 && (module.exports = {});
416
+ }]);
417
+ return FillModel;
418
+ }(_BaseModel2.default);
419
+
420
+ exports.default = FillModel;