@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
@@ -87,6 +87,8 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
87
87
  private currentPickId;
88
88
  protected rawConfig: Partial<ILayerConfig & ChildLayerStyleOptions>;
89
89
  private needUpdateConfig;
90
+ encodeStyleAttribute: Record<string, any>;
91
+ enableEncodeStyles: string[];
90
92
  /**
91
93
  * 待更新样式属性,在初始化阶段完成注册
92
94
  */
@@ -141,6 +143,7 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
141
143
  source(data: any, options?: ISourceCFG): ILayer;
142
144
  setData(data: any, options?: ISourceCFG): this;
143
145
  style(options: Partial<ChildLayerStyleOptions> & Partial<ILayerConfig>): ILayer;
146
+ private encodeStyle;
144
147
  scale(field: string | number | IScaleOptions, cfg?: IScale): this;
145
148
  /**
146
149
  * 渲染所有的图层
@@ -12,7 +12,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
12
12
  import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
13
13
  import _initializerWarningHelper from "@babel/runtime/helpers/esm/initializerWarningHelper";
14
14
  var _excluded = ["passes"],
15
- _excluded2 = ["moduleName", "vertexShader", "fragmentShader", "triangulation", "segmentNumber", "workerEnabled", "workerOptions"];
15
+ _excluded2 = ["moduleName", "vertexShader", "fragmentShader", "inject", "triangulation", "segmentNumber"];
16
16
  var _dec, _class, _descriptor;
17
17
  import _regeneratorRuntime from "@babel/runtime/regenerator";
18
18
  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; } } }; }
@@ -24,11 +24,10 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
24
24
  import { AsyncSeriesBailHook, AsyncWaterfallHook, SyncBailHook, SyncHook } from '@antv/async-hook';
25
25
  import { BlendType, IDebugLog, ILayerStage, lazyInject, TYPES } from '@antv/l7-core';
26
26
  import Source from '@antv/l7-source';
27
- import { encodePickingColor, WorkerSourceMap } from '@antv/l7-utils';
27
+ import { encodePickingColor } from '@antv/l7-utils';
28
28
  import { EventEmitter } from 'eventemitter3';
29
- import { isEqual, isFunction, isObject, isUndefined } from 'lodash';
29
+ import { isEqual, isFunction, isObject, isPlainObject, isUndefined } from 'lodash';
30
30
  import { BlendTypes } from "../utils/blend";
31
- import { styleDataMapping } from "../utils/dataMappingStyle";
32
31
  import { calculateData } from "../utils/layerData";
33
32
  import { createMultiPassRenderer, normalizePasses } from "../utils/multiPassRender";
34
33
  import LayerPickService from "./LayerPickService";
@@ -107,6 +106,8 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
107
106
  enable: false
108
107
  });
109
108
  _defineProperty(_assertThisInitialized(_this), "currentPickId", null);
109
+ _defineProperty(_assertThisInitialized(_this), "encodeStyleAttribute", {});
110
+ _defineProperty(_assertThisInitialized(_this), "enableEncodeStyles", []);
110
111
  _defineProperty(_assertThisInitialized(_this), "pendingStyleAttributes", []);
111
112
  _defineProperty(_assertThisInitialized(_this), "scaleOptions", {});
112
113
  _defineProperty(_assertThisInitialized(_this), "animateStatus", false);
@@ -126,7 +127,6 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
126
127
  _this.name = config.name || _this.id;
127
128
  _this.zIndex = config.zIndex || 0;
128
129
  _this.rawConfig = config;
129
- // this.parent = this;
130
130
  return _this;
131
131
  }
132
132
  _createClass(BaseLayer, [{
@@ -199,7 +199,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
199
199
  } else {
200
200
  var sceneId = this.container.get(TYPES.SceneID);
201
201
  // @ts-ignore
202
- styleDataMapping(configToUpdate, this); // 处理 style 中进行数据映射的属性字段
202
+ // styleDataMapping(configToUpdate, this); // 处理 style 中进行数据映射的属性字段
203
203
  this.configService.setLayerConfig(sceneId, this.id, _objectSpread(_objectSpread(_objectSpread({}, this.configService.getLayerConfig(this.id)), this.needUpdateConfig), configToUpdate));
204
204
  this.needUpdateConfig = {};
205
205
  }
@@ -422,7 +422,9 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
422
422
  }, {
423
423
  key: "prepareBuildModel",
424
424
  value: function prepareBuildModel() {
425
- this.updateLayerConfig(_objectSpread(_objectSpread(_objectSpread({}, this.getDefaultConfig()), this.rawConfig), this.needUpdateConfig));
425
+ if (Object.keys(this.needUpdateConfig || {}).length !== 0) {
426
+ this.updateLayerConfig({});
427
+ }
426
428
 
427
429
  // 启动动画
428
430
  var _this$getLayerConfig2 = this.getLayerConfig(),
@@ -559,21 +561,32 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
559
561
  }
560
562
  });
561
563
  }
562
- this.rawConfig = _objectSpread(_objectSpread({}, this.rawConfig), rest);
563
- if (this.container) {
564
- this.updateLayerConfig(this.rawConfig);
565
- this.styleNeedUpdate = true;
566
- }
567
- // TODO style model 更新
568
- // @ts-ignore
569
- // if (lastConfig && lastConfig.mask === true && options.mask === false) {
570
- // this.clearModels();
571
- // this.layerModel.buildModels((models) => {
572
- // this.models = models;
573
- // });
574
- // }
564
+ this.encodeStyle(rest);
565
+ this.updateLayerConfig(rest);
575
566
  return this;
576
567
  }
568
+
569
+ // 参与数据映射的字段 encodeing
570
+ }, {
571
+ key: "encodeStyle",
572
+ value: function encodeStyle(options) {
573
+ var _this6 = this;
574
+ Object.keys(options).forEach(function (key) {
575
+ if (
576
+ // 需要数据映射
577
+ _this6.enableEncodeStyles.includes(key) && isPlainObject(options[key]) && (options[key].field || options[key].values) && !isEqual(_this6.encodeStyleAttribute[key], options[key]) // 防止计算属性重复计算
578
+ ) {
579
+ _this6.encodeStyleAttribute[key] = options[key];
580
+ _this6.updateStyleAttribute(key, options[key].field, options[key].values);
581
+ _this6.styleNeedUpdate = true;
582
+ } else {
583
+ // 不需要数据映射
584
+ if (_this6.encodeStyleAttribute[key]) {
585
+ delete _this6.encodeStyleAttribute[key]; // 删除已经存在的属性
586
+ }
587
+ }
588
+ });
589
+ }
577
590
  }, {
578
591
  key: "scale",
579
592
  value: function scale(field, cfg) {
@@ -683,7 +696,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
683
696
  }, {
684
697
  key: "setActive",
685
698
  value: function setActive(id, options) {
686
- var _this6 = this;
699
+ var _this7 = this;
687
700
  if (isObject(id)) {
688
701
  var _id$x = id.x,
689
702
  x = _id$x === void 0 ? 0 : _id$x,
@@ -707,7 +720,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
707
720
  // @ts-ignore
708
721
  .then(function () {
709
722
  setTimeout(function () {
710
- _this6.reRender();
723
+ _this7.reRender();
711
724
  }, 1);
712
725
  });
713
726
  }
@@ -734,7 +747,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
734
747
  }, {
735
748
  key: "setSelect",
736
749
  value: function setSelect(id, options) {
737
- var _this7 = this;
750
+ var _this8 = this;
738
751
  if (isObject(id)) {
739
752
  var _id$x2 = id.x,
740
753
  x = _id$x2 === void 0 ? 0 : _id$x2,
@@ -758,7 +771,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
758
771
  // @ts-ignore
759
772
  .then(function () {
760
773
  setTimeout(function () {
761
- _this7.reRender();
774
+ _this8.reRender();
762
775
  }, 1);
763
776
  });
764
777
  }
@@ -1009,7 +1022,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1009
1022
  }, {
1010
1023
  key: "setSource",
1011
1024
  value: function setSource(source) {
1012
- var _this8 = this;
1025
+ var _this9 = this;
1013
1026
  // 解除原 sources 事件
1014
1027
  if (this.layerSource) {
1015
1028
  this.layerSource.off('update', this.sourceEvent);
@@ -1028,22 +1041,22 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1028
1041
  // this.layerSource.inited 为 true update 事件不会再触发
1029
1042
  this.layerSource.on('update', function (_ref4) {
1030
1043
  var type = _ref4.type;
1031
- if (_this8.coordCenter === undefined) {
1032
- var _this8$mapService;
1033
- var layerCenter = _this8.layerSource.center;
1034
- _this8.coordCenter = layerCenter;
1035
- if ((_this8$mapService = _this8.mapService) !== null && _this8$mapService !== void 0 && _this8$mapService.setCoordCenter) {
1036
- _this8.mapService.setCoordCenter(layerCenter);
1044
+ if (_this9.coordCenter === undefined) {
1045
+ var _this9$mapService;
1046
+ var layerCenter = _this9.layerSource.center;
1047
+ _this9.coordCenter = layerCenter;
1048
+ if ((_this9$mapService = _this9.mapService) !== null && _this9$mapService !== void 0 && _this9$mapService.setCoordCenter) {
1049
+ _this9.mapService.setCoordCenter(layerCenter);
1037
1050
  }
1038
1051
  }
1039
1052
  if (type === 'update') {
1040
- if (_this8.tileLayer) {
1053
+ if (_this9.tileLayer) {
1041
1054
  // 瓦片图层独立更新
1042
- _this8.tileLayer.reload();
1055
+ _this9.tileLayer.reload();
1043
1056
  return;
1044
1057
  }
1045
1058
  // source 初始化不需要处理
1046
- _this8.sourceEvent();
1059
+ _this9.sourceEvent();
1047
1060
  }
1048
1061
  });
1049
1062
  }
@@ -1141,56 +1154,38 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1141
1154
  key: "buildLayerModel",
1142
1155
  value: function () {
1143
1156
  var _buildLayerModel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(options) {
1144
- var _this9 = this;
1145
- var moduleName, vertexShader, fragmentShader, triangulation, segmentNumber, _options$workerEnable, workerEnabled, workerOptions, rest, _this$shaderModuleSer, vs, fs, uniforms, createModel;
1157
+ var _this10 = this;
1158
+ var moduleName, vertexShader, fragmentShader, inject, triangulation, segmentNumber, rest, _this$shaderModuleSer, vs, fs, uniforms, createModel;
1146
1159
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
1147
1160
  while (1) switch (_context3.prev = _context3.next) {
1148
1161
  case 0:
1149
- moduleName = options.moduleName, vertexShader = options.vertexShader, fragmentShader = options.fragmentShader, triangulation = options.triangulation, segmentNumber = options.segmentNumber, _options$workerEnable = options.workerEnabled, workerEnabled = _options$workerEnable === void 0 ? false : _options$workerEnable, workerOptions = options.workerOptions, rest = _objectWithoutProperties(options, _excluded2);
1162
+ moduleName = options.moduleName, vertexShader = options.vertexShader, fragmentShader = options.fragmentShader, inject = options.inject, triangulation = options.triangulation, segmentNumber = options.segmentNumber, rest = _objectWithoutProperties(options, _excluded2);
1150
1163
  this.shaderModuleService.registerModule(moduleName, {
1151
1164
  vs: vertexShader,
1152
- fs: fragmentShader
1165
+ fs: fragmentShader,
1166
+ inject: inject
1153
1167
  });
1154
1168
  _this$shaderModuleSer = this.shaderModuleService.getModule(moduleName), vs = _this$shaderModuleSer.vs, fs = _this$shaderModuleSer.fs, uniforms = _this$shaderModuleSer.uniforms;
1155
1169
  createModel = this.rendererService.createModel;
1156
- return _context3.abrupt("return", new Promise(function (resolve, reject) {
1157
- // filter supported worker & worker enabled layer
1158
- if (workerOptions && workerOptions.modelType in WorkerSourceMap && workerEnabled) {
1159
- _this9.styleAttributeService.createAttributesAndIndicesAscy(_this9.encodedData, segmentNumber, workerOptions).then(function (_ref9) {
1160
- var attributes = _ref9.attributes,
1161
- elements = _ref9.elements;
1162
- var m = createModel(_objectSpread({
1163
- attributes: attributes,
1164
- uniforms: uniforms,
1165
- fs: fs,
1166
- vs: vs,
1167
- elements: elements,
1168
- blend: BlendTypes[BlendType.normal]
1169
- }, rest));
1170
- resolve(m);
1171
- }).catch(function (err) {
1172
- return reject(err);
1173
- });
1174
- } else {
1175
- // console.log(this.encodedData)
1176
- var _this9$styleAttribute = _this9.styleAttributeService.createAttributesAndIndices(_this9.encodedData, triangulation, segmentNumber),
1177
- attributes = _this9$styleAttribute.attributes,
1178
- elements = _this9$styleAttribute.elements,
1179
- count = _this9$styleAttribute.count;
1180
- var modelOptions = _objectSpread({
1181
- attributes: attributes,
1182
- uniforms: uniforms,
1183
- fs: fs,
1184
- vs: vs,
1185
- elements: elements,
1186
- blend: BlendTypes[BlendType.normal]
1187
- }, rest);
1188
- if (count) {
1189
- modelOptions.count = count;
1190
- }
1191
- var m = createModel(modelOptions);
1192
- resolve(m);
1170
+ return _context3.abrupt("return", new Promise(function (resolve) {
1171
+ // console.log(this.encodedData)
1172
+ var _this10$styleAttribut = _this10.styleAttributeService.createAttributesAndIndices(_this10.encodedData, triangulation, segmentNumber),
1173
+ attributes = _this10$styleAttribut.attributes,
1174
+ elements = _this10$styleAttribut.elements,
1175
+ count = _this10$styleAttribut.count;
1176
+ var modelOptions = _objectSpread({
1177
+ attributes: attributes,
1178
+ uniforms: uniforms,
1179
+ fs: fs,
1180
+ vs: vs,
1181
+ elements: elements,
1182
+ blend: BlendTypes[BlendType.normal]
1183
+ }, rest);
1184
+ if (count) {
1185
+ modelOptions.count = count;
1193
1186
  }
1187
+ var m = createModel(modelOptions);
1188
+ resolve(m);
1194
1189
  }));
1195
1190
  case 5:
1196
1191
  case "end":
@@ -1320,7 +1315,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1320
1315
  }, {
1321
1316
  key: "renderModels",
1322
1317
  value: function renderModels() {
1323
- var _this10 = this;
1318
+ var _this11 = this;
1324
1319
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1325
1320
  // TODO: this.getEncodedData().length > 0 这个判断是为了解决在 2.5.x 引入数据纹理后产生的 空数据渲染导致 texture 超出上限问题
1326
1321
  if (this.encodeDataLength <= 0 && !this.forceRender) {
@@ -1331,9 +1326,9 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1331
1326
  this.hooks.beforeRender.call();
1332
1327
  this.models.forEach(function (model) {
1333
1328
  model.draw({
1334
- uniforms: _this10.layerModel.getUninforms(),
1335
- blend: _this10.layerModel.getBlend(),
1336
- stencil: _this10.layerModel.getStencil(options)
1329
+ uniforms: _this11.layerModel.getUninforms(),
1330
+ blend: _this11.layerModel.getBlend(),
1331
+ stencil: _this11.layerModel.getStencil(options)
1337
1332
  }, (options === null || options === void 0 ? void 0 : options.ispick) || false);
1338
1333
  });
1339
1334
  this.hooks.afterRender.call();
@@ -1349,10 +1344,11 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1349
1344
  field: field,
1350
1345
  values: values
1351
1346
  })) {
1347
+ // 检测是否发生更新
1352
1348
  return false;
1353
1349
  }
1354
1350
 
1355
- // 存储 Attribute
1351
+ // 存储 Attribute 瓦片图层使用
1356
1352
  if (['color', 'size', 'texture', 'rotate', 'filter', 'label', 'shape'].indexOf(type) !== -1) {
1357
1353
  this.configService.setAttributeConfig(this.id, _defineProperty({}, type, {
1358
1354
  field: field,
@@ -1,4 +1,4 @@
1
- import { IAnimateOption, IAttribute, IBlendOptions, ICameraService, IElements, IEncodeFeature, IFontService, IGlobalConfigService, IIconService, ILayer, ILayerModel, ILayerService, IMapService, IModel, IModelUniform, IPickingService, IRendererService, IRenderOptions, IShaderModuleService, IStencilOptions, IStyleAttributeService, ITexture2D, ITexture2DInitializationOptions, Triangulation } from '@antv/l7-core';
1
+ import { IAnimateOption, IAttribute, IBlendOptions, ICameraService, IElements, IFontService, IGlobalConfigService, IIconService, IInject, ILayer, ILayerModel, ILayerService, IMapService, IModel, IModelUniform, IPickingService, IRendererService, IRenderOptions, IShaderModuleService, IStencilOptions, IStyleAttributeService, ITexture2D, ITexture2DInitializationOptions, Triangulation } from '@antv/l7-core';
2
2
  export type styleSingle = number | string | [string, (single: any) => number] | [string, [number, number]];
3
3
  export type styleOffset = string | [number, number] | [string, (single: any) => number];
4
4
  export type styleColor = string | [string, (single: any) => string] | [string, [string, string]];
@@ -14,6 +14,8 @@ export interface ICellProperty {
14
14
  export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerModel {
15
15
  triangulation: Triangulation;
16
16
  createTexture2D: (options: ITexture2DInitializationOptions) => ITexture2D;
17
+ preStyleAttribute: Record<string, any>;
18
+ protected encodeStyleAttribute: Record<string, boolean>;
17
19
  protected layer: ILayer;
18
20
  protected dataTexture: ITexture2D;
19
21
  protected DATA_TEXTURE_WIDTH: number;
@@ -49,76 +51,6 @@ export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerMod
49
51
  protected layerService: ILayerService;
50
52
  protected pickingService: IPickingService;
51
53
  constructor(layer: ILayer);
52
- /**
53
- * 清除上一次的计算结果 - 全量清除
54
- */
55
- clearLastCalRes(): void;
56
- getCellTypeLayout(): number[];
57
- /**
58
- * 判断数据纹理是否需要重新计算 - 根据传入的值进行判断
59
- * @param options
60
- * @returns
61
- */
62
- dataTextureNeedUpdate(options: {
63
- thetaOffset?: styleSingle;
64
- opacity?: styleSingle;
65
- strokeOpacity?: styleSingle;
66
- strokeWidth?: styleSingle;
67
- stroke?: styleColor;
68
- offsets?: styleOffset;
69
- textOffset?: styleOffset;
70
- }): boolean;
71
- /**
72
- * 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量
73
- * @param options
74
- */
75
- judgeStyleAttributes(options: {
76
- thetaOffset?: styleSingle;
77
- opacity?: styleSingle;
78
- strokeOpacity?: styleSingle;
79
- strokeWidth?: styleSingle;
80
- stroke?: styleColor;
81
- offsets?: styleOffset;
82
- }): void;
83
- /**
84
- * 判断变量 stroke 是否是常量值
85
- * @param stroke
86
- * @returns
87
- */
88
- isStaticColor(stroke: styleColor): boolean;
89
- /**
90
- * 获取 stroke 颜色并做兼容处理
91
- * @param stroke
92
- * @returns
93
- */
94
- getStrokeColor(stroke: styleColor): number[];
95
- /**
96
- * 判断 offsets 是否是常量
97
- * @param offsets
98
- * @returns
99
- */
100
- isOffsetStatic(offsets: styleOffset): boolean;
101
- /**
102
- * 补空位
103
- * @param d
104
- * @param count
105
- */
106
- patchMod(d: number[], count: number): void;
107
- /**
108
- * 根据映射的数据字段往推入数据
109
- * @param d
110
- * @param cellData
111
- * @param cellPropertiesLayouts
112
- */
113
- patchData(d: number[], cellData: IEncodeFeature, cellPropertiesLayouts: ICellProperty[]): void;
114
- /**
115
- * 计算推入数据纹理的数据
116
- * @param cellLength
117
- * @param encodeData
118
- * @param cellPropertiesLayouts
119
- * @returns
120
- */
121
- calDataFrame(cellLength: number, encodeData: IEncodeFeature[], cellPropertiesLayouts: ICellProperty[]): IDataTextureFrame;
122
54
  getBlend(): IBlendOptions;
123
55
  getStencil(option: Partial<IRenderOptions>): Partial<IStencilOptions>;
124
56
  getDefaultStyle(): unknown;
@@ -138,4 +70,10 @@ export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerMod
138
70
  protected registerBuiltinAttributes(): void;
139
71
  protected animateOption2Array(option: IAnimateOption): number[];
140
72
  protected startModelAnimate(): void;
73
+ protected getInject(): IInject;
74
+ protected getStyleAttribute(): {
75
+ [key: string]: any;
76
+ };
77
+ protected registerStyleAttribute(): void;
78
+ updateEncodeAttribute(type: string, flag: boolean): void;
141
79
  }