@antv/l7-layers 2.16.0 → 2.16.2

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 (218) hide show
  1. package/es/core/BaseLayer.d.ts +3 -0
  2. package/es/core/BaseLayer.js +76 -80
  3. package/es/core/BaseModel.d.ts +9 -71
  4. package/es/core/BaseModel.js +75 -357
  5. package/es/core/CommonStyleAttribute.d.ts +2 -0
  6. package/es/core/CommonStyleAttribute.js +66 -0
  7. package/es/core/interface.d.ts +13 -3
  8. package/es/core/shape/extrude.js +18 -6
  9. package/es/core/triangulation.d.ts +12 -0
  10. package/es/core/triangulation.js +70 -0
  11. package/es/heatmap/models/grid.js +1 -1
  12. package/es/heatmap/models/grid3d.js +1 -1
  13. package/es/heatmap/models/heatmap.d.ts +1 -0
  14. package/es/heatmap/models/heatmap.js +17 -13
  15. package/es/heatmap/models/hexagon.js +1 -1
  16. package/es/heatmap/shaders/grid_vert.glsl +2 -2
  17. package/es/heatmap/shaders/hexagon_3d_vert.glsl +2 -2
  18. package/es/heatmap/shaders/hexagon_vert.glsl +2 -2
  19. package/es/line/index.d.ts +1 -0
  20. package/es/line/index.js +3 -2
  21. package/es/line/models/arc.js +9 -45
  22. package/es/line/models/arc_3d.js +12 -45
  23. package/es/line/models/earthArc_3d.js +6 -40
  24. package/es/line/models/{half.d.ts → flow.d.ts} +1 -11
  25. package/es/line/models/flow.js +167 -0
  26. package/es/line/models/great_circle.js +4 -38
  27. package/es/line/models/index.d.ts +1 -1
  28. package/es/line/models/index.js +3 -3
  29. package/es/line/models/line.js +7 -41
  30. package/es/line/models/linearline.js +4 -38
  31. package/es/line/models/simpleLine.d.ts +0 -1
  32. package/es/line/models/simpleLine.js +4 -43
  33. package/es/line/shaders/dash/arc_dash_frag.glsl +3 -6
  34. package/es/line/shaders/dash/arc_dash_vert.glsl +6 -46
  35. package/es/line/shaders/dash/line_dash_frag.glsl +4 -7
  36. package/es/line/shaders/dash/line_dash_vert.glsl +3 -33
  37. package/es/line/shaders/flow/flow_line_frag.glsl +13 -0
  38. package/es/line/shaders/flow/flow_line_vert.glsl +83 -0
  39. package/es/line/shaders/line_arc_3d_frag.glsl +6 -6
  40. package/es/line/shaders/line_arc_3d_vert.glsl +4 -34
  41. package/es/line/shaders/line_arc_frag.glsl +7 -11
  42. package/es/line/shaders/line_arc_great_circle_frag.glsl +5 -6
  43. package/es/line/shaders/line_arc_great_circle_vert.glsl +4 -32
  44. package/es/line/shaders/line_arc_vert.glsl +9 -45
  45. package/es/line/shaders/line_frag.glsl +15 -17
  46. package/es/line/shaders/line_vert.glsl +3 -34
  47. package/es/line/shaders/linear/arc3d_linear_frag.glsl +5 -19
  48. package/es/line/shaders/linear/arc3d_linear_vert.glsl +9 -48
  49. package/es/line/shaders/linear/arc_linear_frag.glsl +2 -30
  50. package/es/line/shaders/linear/arc_linear_vert.glsl +9 -45
  51. package/es/line/shaders/linear/line_linear_frag.glsl +5 -6
  52. package/es/line/shaders/linearLine/line_linear_frag.glsl +2 -14
  53. package/es/line/shaders/linearLine/line_linear_vert.glsl +14 -32
  54. package/es/line/shaders/simple/simpleline_frag.glsl +1 -5
  55. package/es/line/shaders/simple/simpleline_linear_frag.glsl +2 -6
  56. package/es/line/shaders/simple/simpleline_vert.glsl +7 -33
  57. package/es/plugins/DataMappingPlugin.js +20 -34
  58. package/es/plugins/LayerModelPlugin.js +13 -1
  59. package/es/plugins/ShaderUniformPlugin.js +3 -3
  60. package/es/point/index.d.ts +1 -0
  61. package/es/point/index.js +1 -0
  62. package/es/point/models/earthExtrude.d.ts +0 -3
  63. package/es/point/models/earthExtrude.js +2 -40
  64. package/es/point/models/earthFill.d.ts +0 -1
  65. package/es/point/models/earthFill.js +9 -60
  66. package/es/point/models/extrude.d.ts +0 -3
  67. package/es/point/models/extrude.js +3 -42
  68. package/es/point/models/fill.d.ts +0 -1
  69. package/es/point/models/fill.js +15 -76
  70. package/es/point/models/fillmage.js +6 -43
  71. package/es/point/models/image.js +7 -41
  72. package/es/point/models/normal.js +2 -2
  73. package/es/point/models/radar.d.ts +0 -1
  74. package/es/point/models/radar.js +4 -13
  75. package/es/point/models/simplePoint.d.ts +0 -1
  76. package/es/point/models/simplePoint.js +8 -49
  77. package/es/point/models/text.js +17 -47
  78. package/es/point/shaders/animate/wave_frag.glsl +1 -11
  79. package/es/point/shaders/earth/extrude_frag.glsl +5 -17
  80. package/es/point/shaders/earth/extrude_vert.glsl +14 -29
  81. package/es/point/shaders/earth/fill_frag.glsl +5 -14
  82. package/es/point/shaders/earth/fill_vert.glsl +1 -75
  83. package/es/point/shaders/extrude/extrude_frag.glsl +3 -29
  84. package/es/point/shaders/extrude/extrude_vert.glsl +27 -35
  85. package/es/point/shaders/fill_frag.glsl +9 -20
  86. package/es/point/shaders/fill_vert.glsl +16 -101
  87. package/es/point/shaders/image/fillImage_frag.glsl +2 -5
  88. package/es/point/shaders/image/fillImage_vert.glsl +4 -47
  89. package/es/point/shaders/image_frag.glsl +1 -5
  90. package/es/point/shaders/image_vert.glsl +1 -44
  91. package/es/point/shaders/normal_frag.glsl +0 -2
  92. package/es/point/shaders/normal_vert.glsl +2 -1
  93. package/es/point/shaders/radar/radar_vert.glsl +2 -2
  94. package/es/point/shaders/simplePoint_frag.glsl +0 -7
  95. package/es/point/shaders/simplePoint_vert.glsl +3 -45
  96. package/es/point/shaders/text_frag.glsl +6 -19
  97. package/es/point/shaders/text_vert.glsl +5 -66
  98. package/es/polygon/index.d.ts +1 -0
  99. package/es/polygon/index.js +1 -0
  100. package/es/polygon/models/extrude.d.ts +0 -3
  101. package/es/polygon/models/extrude.js +86 -82
  102. package/es/polygon/models/fill.d.ts +0 -4
  103. package/es/polygon/models/fill.js +8 -47
  104. package/es/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -23
  105. package/es/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -5
  106. package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +7 -32
  107. package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +33 -38
  108. package/es/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +12 -9
  109. package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +16 -44
  110. package/es/polygon/shaders/polygon_frag.glsl +0 -5
  111. package/es/polygon/shaders/polygon_linear_frag.glsl +0 -8
  112. package/es/polygon/shaders/polygon_linear_vert.glsl +0 -32
  113. package/es/polygon/shaders/polygon_vert.glsl +1 -27
  114. package/es/utils/layerData.js +2 -2
  115. package/lib/core/BaseLayer.js +74 -78
  116. package/lib/core/BaseModel.js +74 -356
  117. package/lib/core/CommonStyleAttribute.js +72 -0
  118. package/lib/core/shape/extrude.js +18 -6
  119. package/lib/core/triangulation.js +72 -0
  120. package/lib/heatmap/models/grid.js +1 -1
  121. package/lib/heatmap/models/grid3d.js +1 -1
  122. package/lib/heatmap/models/heatmap.js +17 -13
  123. package/lib/heatmap/models/hexagon.js +1 -1
  124. package/lib/heatmap/shaders/grid_vert.glsl +2 -2
  125. package/lib/heatmap/shaders/hexagon_3d_vert.glsl +2 -2
  126. package/lib/heatmap/shaders/hexagon_vert.glsl +2 -2
  127. package/lib/line/index.js +3 -2
  128. package/lib/line/models/arc.js +9 -45
  129. package/lib/line/models/arc_3d.js +12 -45
  130. package/lib/line/models/earthArc_3d.js +6 -40
  131. package/lib/line/models/flow.js +174 -0
  132. package/lib/line/models/great_circle.js +4 -38
  133. package/lib/line/models/index.js +3 -3
  134. package/lib/line/models/line.js +7 -41
  135. package/lib/line/models/linearline.js +4 -38
  136. package/lib/line/models/simpleLine.js +4 -43
  137. package/lib/line/shaders/dash/arc_dash_frag.glsl +3 -6
  138. package/lib/line/shaders/dash/arc_dash_vert.glsl +6 -46
  139. package/lib/line/shaders/dash/line_dash_frag.glsl +4 -7
  140. package/lib/line/shaders/dash/line_dash_vert.glsl +3 -33
  141. package/lib/line/shaders/flow/flow_line_frag.glsl +13 -0
  142. package/lib/line/shaders/flow/flow_line_vert.glsl +83 -0
  143. package/lib/line/shaders/line_arc_3d_frag.glsl +6 -6
  144. package/lib/line/shaders/line_arc_3d_vert.glsl +4 -34
  145. package/lib/line/shaders/line_arc_frag.glsl +7 -11
  146. package/lib/line/shaders/line_arc_great_circle_frag.glsl +5 -6
  147. package/lib/line/shaders/line_arc_great_circle_vert.glsl +4 -32
  148. package/lib/line/shaders/line_arc_vert.glsl +9 -45
  149. package/lib/line/shaders/line_frag.glsl +15 -17
  150. package/lib/line/shaders/line_vert.glsl +3 -34
  151. package/lib/line/shaders/linear/arc3d_linear_frag.glsl +5 -19
  152. package/lib/line/shaders/linear/arc3d_linear_vert.glsl +9 -48
  153. package/lib/line/shaders/linear/arc_linear_frag.glsl +2 -30
  154. package/lib/line/shaders/linear/arc_linear_vert.glsl +9 -45
  155. package/lib/line/shaders/linear/line_linear_frag.glsl +5 -6
  156. package/lib/line/shaders/linearLine/line_linear_frag.glsl +2 -14
  157. package/lib/line/shaders/linearLine/line_linear_vert.glsl +14 -32
  158. package/lib/line/shaders/simple/simpleline_frag.glsl +1 -5
  159. package/lib/line/shaders/simple/simpleline_linear_frag.glsl +2 -6
  160. package/lib/line/shaders/simple/simpleline_vert.glsl +7 -33
  161. package/lib/plugins/DataMappingPlugin.js +20 -34
  162. package/lib/plugins/LayerModelPlugin.js +13 -1
  163. package/lib/plugins/ShaderUniformPlugin.js +3 -3
  164. package/lib/point/index.js +1 -0
  165. package/lib/point/models/earthExtrude.js +2 -40
  166. package/lib/point/models/earthFill.js +9 -60
  167. package/lib/point/models/extrude.js +3 -42
  168. package/lib/point/models/fill.js +15 -76
  169. package/lib/point/models/fillmage.js +6 -43
  170. package/lib/point/models/image.js +7 -41
  171. package/lib/point/models/normal.js +2 -2
  172. package/lib/point/models/radar.js +4 -13
  173. package/lib/point/models/simplePoint.js +8 -49
  174. package/lib/point/models/text.js +15 -45
  175. package/lib/point/shaders/animate/wave_frag.glsl +1 -11
  176. package/lib/point/shaders/earth/extrude_frag.glsl +5 -17
  177. package/lib/point/shaders/earth/extrude_vert.glsl +14 -29
  178. package/lib/point/shaders/earth/fill_frag.glsl +5 -14
  179. package/lib/point/shaders/earth/fill_vert.glsl +1 -75
  180. package/lib/point/shaders/extrude/extrude_frag.glsl +3 -29
  181. package/lib/point/shaders/extrude/extrude_vert.glsl +27 -35
  182. package/lib/point/shaders/fill_frag.glsl +9 -20
  183. package/lib/point/shaders/fill_vert.glsl +16 -101
  184. package/lib/point/shaders/image/fillImage_frag.glsl +2 -5
  185. package/lib/point/shaders/image/fillImage_vert.glsl +4 -47
  186. package/lib/point/shaders/image_frag.glsl +1 -5
  187. package/lib/point/shaders/image_vert.glsl +1 -44
  188. package/lib/point/shaders/normal_frag.glsl +0 -2
  189. package/lib/point/shaders/normal_vert.glsl +2 -1
  190. package/lib/point/shaders/radar/radar_vert.glsl +2 -2
  191. package/lib/point/shaders/simplePoint_frag.glsl +0 -7
  192. package/lib/point/shaders/simplePoint_vert.glsl +3 -45
  193. package/lib/point/shaders/text_frag.glsl +6 -19
  194. package/lib/point/shaders/text_vert.glsl +5 -66
  195. package/lib/polygon/index.js +1 -0
  196. package/lib/polygon/models/extrude.js +86 -82
  197. package/lib/polygon/models/fill.js +8 -47
  198. package/lib/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -23
  199. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +7 -5
  200. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +7 -32
  201. package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +33 -38
  202. package/lib/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +12 -9
  203. package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +16 -44
  204. package/lib/polygon/shaders/polygon_frag.glsl +0 -5
  205. package/lib/polygon/shaders/polygon_linear_frag.glsl +0 -8
  206. package/lib/polygon/shaders/polygon_linear_vert.glsl +0 -32
  207. package/lib/polygon/shaders/polygon_vert.glsl +1 -27
  208. package/lib/utils/layerData.js +2 -2
  209. package/package.json +7 -7
  210. package/es/line/models/half.js +0 -267
  211. package/es/line/shaders/half/line_half_frag.glsl +0 -53
  212. package/es/line/shaders/half/line_half_vert.glsl +0 -169
  213. package/es/utils/dataMappingStyle.d.ts +0 -31
  214. package/es/utils/dataMappingStyle.js +0 -137
  215. package/lib/line/models/half.js +0 -274
  216. package/lib/line/shaders/half/line_half_frag.glsl +0 -53
  217. package/lib/line/shaders/half/line_half_vert.glsl +0 -169
  218. package/lib/utils/dataMappingStyle.js +0 -140
@@ -1,6 +1,5 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4
3
  import _initializerDefineProperty from "@babel/runtime/helpers/esm/initializerDefineProperty";
5
4
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
6
5
  import _createClass from "@babel/runtime/helpers/esm/createClass";
@@ -9,30 +8,21 @@ import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecorated
9
8
  import _initializerWarningHelper from "@babel/runtime/helpers/esm/initializerWarningHelper";
10
9
  var _dec, _class, _descriptor;
11
10
  import _regeneratorRuntime from "@babel/runtime/regenerator";
12
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
13
- 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); }
14
- 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; }
15
- import { BlendType, gl, lazyInject, MaskOperation, StencilType, TYPES } from '@antv/l7-core';
11
+ import { BlendType, lazyInject, MaskOperation, StencilType, TYPES } from '@antv/l7-core';
16
12
  import { rgb2arr } from '@antv/l7-utils';
17
- import { color } from 'd3-color';
18
- import { isEqual, isNumber, isString } from 'lodash';
19
13
  import { BlendTypes } from "../utils/blend";
20
14
  import { getStencil as _getStencil, getStencilMask } from "../utils/stencil";
15
+ import { getCommonStyleAttributeOptions } from "./CommonStyleAttribute";
21
16
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
22
17
  var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__PURE__*/function () {
23
18
  // style texture data mapping
24
19
 
25
- // 用于数据传递的数据纹理
26
- // 默认有多少列(宽度)
27
- // 计算得到的当前数据纹理有多少行(高度)
28
-
29
- // 单个 cell 的长度
30
- // 需要进行数据映射的属性集合
31
-
32
20
  // style texture data mapping
33
21
 
34
22
  function BaseModel(layer) {
35
23
  _classCallCheck(this, BaseModel);
24
+ _defineProperty(this, "preStyleAttribute", {});
25
+ _defineProperty(this, "encodeStyleAttribute", {});
36
26
  _initializerDefineProperty(this, "configService", _descriptor, this);
37
27
  this.layer = layer;
38
28
  this.rendererService = layer.getContainer().get(TYPES.IRendererService);
@@ -44,360 +34,19 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
44
34
  this.fontService = layer.getContainer().get(TYPES.IFontService);
45
35
  this.cameraService = layer.getContainer().get(TYPES.ICameraService);
46
36
  this.layerService = layer.getContainer().get(TYPES.ILayerService);
37
+ // 初始化支持数据映射的 Style 属性
47
38
 
39
+ this.registerStyleAttribute();
48
40
  // 注册 Attribute
49
41
  this.registerBuiltinAttributes();
50
42
  // 开启动画
51
43
  this.startModelAnimate();
52
44
  var createTexture2D = this.rendererService.createTexture2D;
53
45
  this.createTexture2D = createTexture2D;
54
- this.DATA_TEXTURE_WIDTH = 1024; // 数据纹理固定宽度
55
- this.rowCount = 1;
56
- this.cellLength = 0;
57
- this.cellProperties = [];
58
- this.cacheStyleProperties = {
59
- thetaOffset: undefined,
60
- opacity: undefined,
61
- strokeOpacity: undefined,
62
- strokeWidth: undefined,
63
- stroke: undefined,
64
- offsets: undefined
65
- };
66
- this.stylePropertiesExist = {
67
- hasThetaOffset: 0,
68
- hasOpacity: 0,
69
- hasStrokeOpacity: 0,
70
- hasStrokeWidth: 0,
71
- hasStroke: 0,
72
- hasOffsets: 0
73
- };
74
- this.dataTextureTest = this.layerService.getOESTextureFloat();
75
- // 只有在不支持数据纹理的情况下进行赋值
76
- if (!this.dataTextureTest) {
77
- this.dataTexture = this.createTexture2D({
78
- // data: new Uint8ClampedArray(4),
79
- // 使用 Uint8ClampedArray 在 支付宝 环境中可能存在问题 UC 内核对格式有要求 L7 v2.7.18 版本发现
80
- // Uint8ClampedArray 和 Uint8Array 没有实质性的区别
81
- data: new Uint8Array(4),
82
- mag: gl.NEAREST,
83
- min: gl.NEAREST,
84
- width: 1,
85
- height: 1
86
- });
87
- }
88
46
  }
89
47
 
90
48
  // style datatexture mapping
91
-
92
- /**
93
- * 清除上一次的计算结果 - 全量清除
94
- */
95
49
  _createClass(BaseModel, [{
96
- key: "clearLastCalRes",
97
- value: function clearLastCalRes() {
98
- this.cellProperties = []; // 清空上一次计算的需要进行数据映射的属性集合
99
- this.cellLength = 0; // 清空上一次计算的 cell 的长度
100
- this.stylePropertiesExist = {
101
- // 全量清空上一次是否需要对 style 属性进行数据映射的判断
102
- hasThetaOffset: 0,
103
- hasOpacity: 0,
104
- hasStrokeOpacity: 0,
105
- hasStrokeWidth: 0,
106
- hasStroke: 0,
107
- hasOffsets: 0
108
- };
109
- }
110
- }, {
111
- key: "getCellTypeLayout",
112
- value: function getCellTypeLayout() {
113
- if (this.dataTextureTest) {
114
- return [
115
- // 0
116
- this.rowCount,
117
- // 数据纹理有几行
118
- this.DATA_TEXTURE_WIDTH,
119
- // 数据纹理有几列
120
- 0.0, 0.0,
121
- // 1
122
- this.stylePropertiesExist.hasOpacity,
123
- // cell 中是否存在 opacity
124
- this.stylePropertiesExist.hasStrokeOpacity,
125
- // cell 中是否存在 strokeOpacity
126
- this.stylePropertiesExist.hasStrokeWidth,
127
- // cell 中是否存在 strokeWidth
128
- this.stylePropertiesExist.hasStroke,
129
- // cell 中是否存在 stroke
130
- // 2
131
- this.stylePropertiesExist.hasOffsets,
132
- // cell 中是否存在 offsets
133
- this.stylePropertiesExist.hasThetaOffset,
134
- // cell 中是否存在 thetaOffset
135
- 0.0, 0.0,
136
- // 3
137
- 0.0, 0.0, 0.0, 1.0];
138
- } else {
139
- return [1.0,
140
- // 数据纹理有几行
141
- 1.0,
142
- // 数据纹理有几列
143
- 0.0, 0.0, 0.0,
144
- // cell 中是否存在 opacity
145
- 0.0,
146
- // cell 中是否存在 strokeOpacity
147
- 0.0,
148
- // cell 中是否存在 strokeWidth
149
- 0.0,
150
- // cell 中是否存在 stroke
151
- 0.0,
152
- // cell 中是否存在 offsets
153
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0];
154
- }
155
- }
156
-
157
- /**
158
- * 判断数据纹理是否需要重新计算 - 根据传入的值进行判断
159
- * @param options
160
- * @returns
161
- */
162
- }, {
163
- key: "dataTextureNeedUpdate",
164
- value: function dataTextureNeedUpdate(options) {
165
- var isUpdate = false;
166
- if (!isEqual(options.thetaOffset, this.cacheStyleProperties.thetaOffset)) {
167
- isUpdate = true;
168
- this.cacheStyleProperties.thetaOffset = options.thetaOffset;
169
- }
170
- if (!isEqual(options.opacity, this.cacheStyleProperties.opacity)) {
171
- isUpdate = true;
172
- this.cacheStyleProperties.opacity = options.opacity;
173
- }
174
- if (!isEqual(options.strokeOpacity, this.cacheStyleProperties.strokeOpacity)) {
175
- isUpdate = true;
176
- this.cacheStyleProperties.strokeOpacity = options.strokeOpacity;
177
- }
178
- if (!isEqual(options.strokeWidth, this.cacheStyleProperties.strokeWidth)) {
179
- isUpdate = true;
180
- this.cacheStyleProperties.strokeWidth = options.strokeWidth;
181
- }
182
- if (!isEqual(options.stroke, this.cacheStyleProperties.stroke)) {
183
- isUpdate = true;
184
- this.cacheStyleProperties.stroke = options.stroke;
185
- }
186
- if (!isEqual(options.offsets, this.cacheStyleProperties.offsets)) {
187
- isUpdate = true;
188
- this.cacheStyleProperties.offsets = options.offsets;
189
- }
190
- if (this.dataTexture === undefined) {
191
- isUpdate = true;
192
- }
193
- return isUpdate;
194
- }
195
- /**
196
- * 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量
197
- * @param options
198
- */
199
- }, {
200
- key: "judgeStyleAttributes",
201
- value: function judgeStyleAttributes(options) {
202
- this.clearLastCalRes(); // 清除上一次的计算结果 - 全量清除
203
-
204
- if (options.opacity !== undefined && !isNumber(options.opacity)) {
205
- // 数据映射
206
- this.cellProperties.push({
207
- attr: 'opacity',
208
- count: 1
209
- });
210
- this.stylePropertiesExist.hasOpacity = 1;
211
- this.cellLength += 1;
212
- }
213
- if (options.strokeOpacity !== undefined && !isNumber(options.strokeOpacity)) {
214
- // 数据映射
215
- this.cellProperties.push({
216
- attr: 'strokeOpacity',
217
- count: 1
218
- });
219
- this.stylePropertiesExist.hasStrokeOpacity = 1;
220
- this.cellLength += 1;
221
- }
222
- if (options.strokeWidth !== undefined && !isNumber(options.strokeWidth)) {
223
- // 数据映射
224
- this.cellProperties.push({
225
- attr: 'strokeWidth',
226
- count: 1
227
- });
228
- this.stylePropertiesExist.hasStrokeWidth = 1;
229
- this.cellLength += 1;
230
- }
231
- if (options.stroke !== undefined && !this.isStaticColor(options.stroke)) {
232
- // 数据映射
233
- this.cellProperties.push({
234
- attr: 'stroke',
235
- count: 4
236
- });
237
- this.stylePropertiesExist.hasStroke = 1;
238
- this.cellLength += 4;
239
- }
240
- if (options.offsets !== undefined && !this.isOffsetStatic(options.offsets)) {
241
- // 数据映射
242
- this.cellProperties.push({
243
- attr: 'offsets',
244
- count: 2
245
- });
246
- this.stylePropertiesExist.hasOffsets = 1;
247
- this.cellLength += 2;
248
- }
249
- if (options.thetaOffset !== undefined && !isNumber(options.thetaOffset)) {
250
- // 数据映射
251
- this.cellProperties.push({
252
- attr: 'thetaOffset',
253
- count: 1
254
- });
255
- this.stylePropertiesExist.hasThetaOffset = 1;
256
- this.cellLength += 1;
257
- }
258
- }
259
-
260
- /**
261
- * 判断变量 stroke 是否是常量值
262
- * @param stroke
263
- * @returns
264
- */
265
- }, {
266
- key: "isStaticColor",
267
- value: function isStaticColor(stroke) {
268
- if (isString(stroke)) {
269
- if (color(stroke)) {
270
- return true;
271
- } else {
272
- return false;
273
- }
274
- }
275
- return false;
276
- }
277
- /**
278
- * 获取 stroke 颜色并做兼容处理
279
- * @param stroke
280
- * @returns
281
- */
282
- }, {
283
- key: "getStrokeColor",
284
- value: function getStrokeColor(stroke) {
285
- if (this.isStaticColor(stroke)) {
286
- var strokeColor = rgb2arr(stroke);
287
- strokeColor[0] = strokeColor[0] ? strokeColor[0] : 0;
288
- strokeColor[1] = strokeColor[1] ? strokeColor[1] : 0;
289
- strokeColor[2] = strokeColor[2] ? strokeColor[2] : 0;
290
- strokeColor[3] = strokeColor[3] ? strokeColor[3] : 0;
291
- return strokeColor;
292
- } else {
293
- return [0, 0, 0, 0];
294
- }
295
- }
296
-
297
- /**
298
- * 判断 offsets 是否是常量
299
- * @param offsets
300
- * @returns
301
- */
302
- }, {
303
- key: "isOffsetStatic",
304
- value: function isOffsetStatic(offsets) {
305
- if (Array.isArray(offsets) && offsets.length === 2 && isNumber(offsets[0]) && isNumber(offsets[1])) {
306
- return true;
307
- } else {
308
- return false;
309
- }
310
- }
311
-
312
- /**
313
- * 补空位
314
- * @param d
315
- * @param count
316
- */
317
- }, {
318
- key: "patchMod",
319
- value: function patchMod(d, count) {
320
- for (var i = 0; i < count; i++) {
321
- d.push(-1);
322
- }
323
- }
324
-
325
- /**
326
- * 根据映射的数据字段往推入数据
327
- * @param d
328
- * @param cellData
329
- * @param cellPropertiesLayouts
330
- */
331
- }, {
332
- key: "patchData",
333
- value: function patchData(d, cellData, cellPropertiesLayouts) {
334
- var _iterator = _createForOfIteratorHelper(cellPropertiesLayouts),
335
- _step;
336
- try {
337
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
338
- var layout = _step.value;
339
- var attr = layout.attr,
340
- count = layout.count;
341
- var value = cellData[attr];
342
- if (value !== undefined) {
343
- // 数据中存在该属性
344
- if (attr === 'stroke') {
345
- d.push.apply(d, _toConsumableArray(rgb2arr(value)));
346
- } else if (attr === 'offsets') {
347
- if (this.isOffsetStatic(value)) {
348
- d.push(-value[0], value[1]);
349
- } else {
350
- d.push(0, 0);
351
- }
352
- } else {
353
- d.push(isNumber(value) ? value : 1.0);
354
- }
355
- } else {
356
- // 若不存在时则补位
357
- this.patchMod(d, count);
358
- }
359
- }
360
- } catch (err) {
361
- _iterator.e(err);
362
- } finally {
363
- _iterator.f();
364
- }
365
- }
366
-
367
- /**
368
- * 计算推入数据纹理的数据
369
- * @param cellLength
370
- * @param encodeData
371
- * @param cellPropertiesLayouts
372
- * @returns
373
- */
374
- }, {
375
- key: "calDataFrame",
376
- value: function calDataFrame(cellLength, encodeData, cellPropertiesLayouts) {
377
- var encodeDatalength = encodeData.length;
378
- var rowCount = Math.ceil(encodeDatalength * cellLength / this.DATA_TEXTURE_WIDTH); // 有多少行
379
-
380
- var totalLength = rowCount * this.DATA_TEXTURE_WIDTH;
381
- var d = [];
382
- for (var i = 0; i < encodeDatalength; i++) {
383
- // 根据 encodeData 数据推入数据
384
- var cellData = encodeData[i];
385
- this.patchData(d, cellData, cellPropertiesLayouts);
386
- }
387
- for (var _i = d.length; _i < totalLength; _i++) {
388
- // 每行不足的部分用 -1 补足(数据纹理时 width * height 的矩形数据集合)
389
- d.push(-1);
390
- }
391
- // console.log('data', d)
392
- return {
393
- data: d,
394
- width: this.DATA_TEXTURE_WIDTH,
395
- height: rowCount
396
- };
397
- }
398
-
399
- // style datatexture mapping
400
- }, {
401
50
  key: "getBlend",
402
51
  value: function getBlend() {
403
52
  var _this$layer$getLayerC = this.layer.getLayerConfig(),
@@ -546,6 +195,75 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
546
195
  this.layer.setAnimateStartTime();
547
196
  }
548
197
  }
198
+ }, {
199
+ key: "getInject",
200
+ value: function getInject() {
201
+ var encodeStyleAttribute = this.layer.encodeStyleAttribute;
202
+ var str = '';
203
+ var attrType = {
204
+ opacity: 'float',
205
+ stroke: 'vec4',
206
+ offsets: 'vec2',
207
+ textOffset: 'vec2'
208
+ };
209
+ this.layer.enableEncodeStyles.forEach(function (key) {
210
+ if (encodeStyleAttribute[key]) {
211
+ str += "#define USE_ATTRIBUTE_".concat(key.toUpperCase(), " 0.0; \n\n");
212
+ }
213
+ str += "\n #ifdef USE_ATTRIBUTE_".concat(key.toUpperCase(), "\n attribute ").concat(attrType[key], " a_").concat(key.charAt(0).toUpperCase() + key.slice(1), ";\n#else\n uniform ").concat(attrType[key], " u_").concat(key, ";\n#endif\n\n");
214
+ });
215
+ var innerStr = '';
216
+ this.layer.enableEncodeStyles.forEach(function (key) {
217
+ innerStr += "\n\n#ifdef USE_ATTRIBUTE_".concat(key.toUpperCase(), "\n ").concat(attrType[key], " ").concat(key, " = a_").concat(key.charAt(0).toUpperCase() + key.slice(1), ";\n#else\n ").concat(attrType[key], " ").concat(key, " = u_").concat(key, ";\n#endif\n\n");
218
+ });
219
+ return {
220
+ 'vs:#decl': str,
221
+ 'vs:#main-start': innerStr
222
+ };
223
+ }
224
+
225
+ // 获取数据映射样式
226
+ }, {
227
+ key: "getStyleAttribute",
228
+ value: function getStyleAttribute() {
229
+ var _this = this;
230
+ var options = {};
231
+ // TODO: 优化
232
+
233
+ var defualtValue = {
234
+ opacity: 1,
235
+ stroke: [1, 0, 0, 1],
236
+ offsets: [0, 0]
237
+ };
238
+ this.layer.enableEncodeStyles.forEach(function (key) {
239
+ if (!_this.layer.encodeStyleAttribute[key]) {
240
+ // @ts-ignore
241
+ var value = _this.layer.getLayerConfig()[key] || defualtValue[key];
242
+ if (key === 'stroke') {
243
+ value = rgb2arr(value);
244
+ }
245
+ options['u_' + key] = value;
246
+ }
247
+ });
248
+ return options;
249
+ }
250
+ // 注册数据映射样式
251
+ }, {
252
+ key: "registerStyleAttribute",
253
+ value: function registerStyleAttribute() {
254
+ var _this2 = this;
255
+ Object.keys(this.layer.encodeStyleAttribute).forEach(function (key) {
256
+ var options = getCommonStyleAttributeOptions(key);
257
+ if (options) {
258
+ _this2.styleAttributeService.registerStyleAttribute(options);
259
+ }
260
+ });
261
+ }
262
+ }, {
263
+ key: "updateEncodeAttribute",
264
+ value: function updateEncodeAttribute(type, flag) {
265
+ this.encodeStyleAttribute[type] = flag;
266
+ }
549
267
  }]);
550
268
  return BaseModel;
551
269
  }(), (_descriptor = _applyDecoratedDescriptor(_class.prototype, "configService", [_dec], {
@@ -0,0 +1,2 @@
1
+ import { IStyleAttribute } from '@antv/l7-core';
2
+ export declare function getCommonStyleAttributeOptions(name: string): Partial<IStyleAttribute> | undefined;
@@ -0,0 +1,66 @@
1
+ import { AttributeType, gl } from '@antv/l7-core';
2
+ export function getCommonStyleAttributeOptions(name) {
3
+ switch (name) {
4
+ case 'stroke':
5
+ return {
6
+ name: 'stroke',
7
+ type: AttributeType.Attribute,
8
+ descriptor: {
9
+ name: 'a_Stroke',
10
+ buffer: {
11
+ // give the WebGL driver a hint that this buffer may change
12
+ usage: gl.DYNAMIC_DRAW,
13
+ data: [],
14
+ type: gl.FLOAT
15
+ },
16
+ size: 4,
17
+ update: function update(feature) {
18
+ var _feature$stroke = feature.stroke,
19
+ stroke = _feature$stroke === void 0 ? [1, 1, 1, 1] : _feature$stroke;
20
+ return stroke;
21
+ }
22
+ }
23
+ };
24
+ case 'opacity':
25
+ return {
26
+ name: 'opacity',
27
+ type: AttributeType.Attribute,
28
+ descriptor: {
29
+ name: 'a_Opacity',
30
+ buffer: {
31
+ // give the WebGL driver a hint that this buffer may change
32
+ usage: gl.STATIC_DRAW,
33
+ data: [],
34
+ type: gl.FLOAT
35
+ },
36
+ size: 1,
37
+ update: function update(feature) {
38
+ var _feature$opacity = feature.opacity,
39
+ op = _feature$opacity === void 0 ? 1 : _feature$opacity;
40
+ return [op];
41
+ }
42
+ }
43
+ };
44
+ case 'offsets':
45
+ return {
46
+ name: 'offsets',
47
+ type: AttributeType.Attribute,
48
+ descriptor: {
49
+ name: 'a_Offsets',
50
+ buffer: {
51
+ // give the WebGL driver a hint that this buffer may change
52
+ usage: gl.STATIC_DRAW,
53
+ data: [],
54
+ type: gl.FLOAT
55
+ },
56
+ size: 2,
57
+ update: function update(feature) {
58
+ var epo = feature.offsets;
59
+ return epo;
60
+ }
61
+ }
62
+ };
63
+ default:
64
+ return undefined;
65
+ }
66
+ }
@@ -1,6 +1,5 @@
1
- import { IAnimateOption, IMapService, ITexture2D } from '@antv/l7-core';
1
+ import { IAnimateOption, IMapService, ITexture2D, StyleAttributeField, StyleAttributeOption } from '@antv/l7-core';
2
2
  import { IColorRamp } from '@antv/l7-utils';
3
- import { styleOffset } from '../core/BaseModel';
4
3
  import { anchorType } from '../utils/symbol-layout';
5
4
  export declare enum lineStyleType {
6
5
  'solid' = 0,
@@ -91,7 +90,7 @@ export interface IPointLayerStyleOptions extends IBaseLayerStyleOptions {
91
90
  dir: string;
92
91
  };
93
92
  lightEnable: boolean;
94
- offsets?: styleOffset;
93
+ offsets?: [number, number];
95
94
  unit?: SizeUnitType;
96
95
  rotation?: number;
97
96
  speed?: number;
@@ -227,4 +226,15 @@ export interface IRasterTerrainLayerStyleOptions extends IBaseRasterLayerStyleOp
227
226
  bScaler?: number;
228
227
  offset?: number;
229
228
  }
229
+ export interface IFlowLineStyleOptions extends IBaseLayerStyleOptions {
230
+ gapWidth?: number;
231
+ offsets?: [number, number];
232
+ stroke?: string;
233
+ strokeOpacity?: number;
234
+ strokeWidth?: number;
235
+ }
236
+ export interface IStyleEncodeAttributeOptions {
237
+ field: StyleAttributeField;
238
+ values?: StyleAttributeOption;
239
+ }
230
240
  export {};
@@ -73,15 +73,22 @@ export function extrude_PolygonNormal(path) {
73
73
  var normals = [];
74
74
  // 设置顶部z值 position uv
75
75
  for (var j = 0; j < vertices.length / dimensions; j++) {
76
- if (dimensions === 2) {
77
- positions.push(vertices[j * 2], vertices[j * 2 + 1], 1, -1, -1);
78
- } else {
79
- positions.push(vertices[j * 3], vertices[j * 3 + 1], 1, -1, -1);
80
- }
76
+ positions.push(vertices[j * dimensions],
77
+ // x
78
+ vertices[j * dimensions + 1],
79
+ // y
80
+ 1,
81
+ // z
82
+ -1,
83
+ // 顶部uv
84
+ -1 // 顶部uv
85
+ );
86
+
81
87
  normals.push(0, 0, 1);
82
88
  }
83
89
  var triangles = earcut(flattengeo.vertices, flattengeo.holes, flattengeo.dimensions);
84
90
  indexArray.push.apply(indexArray, _toConsumableArray(triangles));
91
+ // 设置侧面
85
92
  var _loop2 = function _loop2() {
86
93
  var prePoint = flattengeo.vertices.slice(i * dimensions, (i + 1) * dimensions);
87
94
  var nextPoint = flattengeo.vertices.slice((i + 1) * dimensions, (i + 2) * dimensions);
@@ -89,7 +96,12 @@ export function extrude_PolygonNormal(path) {
89
96
  nextPoint = flattengeo.vertices.slice(0, dimensions);
90
97
  }
91
98
  var indexOffset = positions.length / 5;
92
- positions.push(prePoint[0], prePoint[1], 1, 0, 0, nextPoint[0], nextPoint[1], 1, 0.1, 0, prePoint[0], prePoint[1], 0, 0, 0.8, nextPoint[0], nextPoint[1], 0, 0.1, 0.8);
99
+ // 侧面四顶点
100
+ positions.push(prePoint[0], prePoint[1], 1, 0, 0, nextPoint[0], nextPoint[1], 1, 0.1,
101
+ // 侧面 低uv
102
+ 0,
103
+ // 侧面低 uv
104
+ prePoint[0], prePoint[1], 0, 0, 0.8, nextPoint[0], nextPoint[1], 0, 0.1, 0.8);
93
105
  var normal = computeVertexNormals([nextPoint[0], nextPoint[1], 1], [prePoint[0], prePoint[1], 0], [prePoint[0], prePoint[1], 1], needFlat);
94
106
  normals.push.apply(normals, _toConsumableArray(normal).concat(_toConsumableArray(normal), _toConsumableArray(normal), _toConsumableArray(normal)));
95
107
  indexArray.push.apply(indexArray, _toConsumableArray([1, 2, 0, 3, 2, 1].map(function (v) {
@@ -47,6 +47,18 @@ export declare function LineTriangulation(feature: IEncodeFeature): {
47
47
  indexes: number[];
48
48
  size: number;
49
49
  };
50
+ export declare function FlowLineFillTriangulation(feature: IEncodeFeature): {
51
+ vertices: any[];
52
+ normals: number[];
53
+ indices: number[];
54
+ size: number;
55
+ };
56
+ export declare function FlowLineStrokeTriangulation(feature: IEncodeFeature): {
57
+ vertices: any[];
58
+ normals: number[];
59
+ indices: number[];
60
+ size: number;
61
+ };
50
62
  export declare function SimpleLineTriangulation(feature: IEncodeFeature): {
51
63
  vertices: any[];
52
64
  indices: never[];