@antv/l7-layers 2.19.11 → 2.20.1

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 (173) hide show
  1. package/es/canvas/models/canvas.js +2 -2
  2. package/es/core/BaseLayer.d.ts +1 -1
  3. package/es/core/BaseLayer.js +18 -11
  4. package/es/core/BaseModel.d.ts +3 -1
  5. package/es/core/BaseModel.js +28 -4
  6. package/es/core/CommonStyleAttribute.d.ts +15 -0
  7. package/es/core/CommonStyleAttribute.js +21 -0
  8. package/es/core/TextureService.js +2 -2
  9. package/es/earth/index.js +1 -1
  10. package/es/geometry/index.js +1 -1
  11. package/es/geometry/models/billboard.js +1 -1
  12. package/es/geometry/models/plane.js +2 -2
  13. package/es/geometry/models/sprite.js +2 -2
  14. package/es/heatmap/index.js +1 -1
  15. package/es/heatmap/models/heatmap.js +4 -4
  16. package/es/image/models/image.js +1 -1
  17. package/es/line/index.js +1 -1
  18. package/es/line/models/arc.js +1 -1
  19. package/es/line/models/arc_3d.js +1 -1
  20. package/es/line/models/earthArc_3d.js +1 -1
  21. package/es/line/models/great_circle.js +1 -1
  22. package/es/line/models/line.js +1 -1
  23. package/es/line/models/linearline.js +1 -1
  24. package/es/line/models/wall.js +1 -1
  25. package/es/plugins/DataMappingPlugin.js +1 -1
  26. package/es/plugins/PixelPickingPlugin.d.ts +4 -1
  27. package/es/plugins/PixelPickingPlugin.js +91 -22
  28. package/es/plugins/RegisterStyleAttributePlugin.d.ts +0 -1
  29. package/es/plugins/RegisterStyleAttributePlugin.js +4 -22
  30. package/es/plugins/ShaderUniformPlugin.d.ts +2 -0
  31. package/es/plugins/ShaderUniformPlugin.js +74 -6
  32. package/es/point/index.js +1 -1
  33. package/es/point/models/fill.js +31 -7
  34. package/es/point/models/fillmage.js +1 -1
  35. package/es/point/models/image.js +1 -1
  36. package/es/point/models/normal.js +30 -12
  37. package/es/point/models/text.js +1 -1
  38. package/es/point/shaders/fill_frag.glsl +20 -14
  39. package/es/point/shaders/fill_vert.glsl +19 -18
  40. package/es/point/shaders/normal_frag.glsl +4 -3
  41. package/es/point/shaders/normal_vert.glsl +12 -11
  42. package/es/polygon/index.js +1 -1
  43. package/es/polygon/models/extrude.js +1 -1
  44. package/es/polygon/models/extrusion.js +1 -1
  45. package/es/polygon/models/ocean.js +3 -3
  46. package/es/polygon/models/water.js +1 -1
  47. package/es/raster/models/raster.js +2 -2
  48. package/es/raster/models/rasterRgb.js +1 -1
  49. package/es/raster/models/rasterTerrainRgb.js +1 -1
  50. package/es/tile/core/BaseLayer.js +4 -4
  51. package/es/tile/interaction/getRasterData.js +4 -4
  52. package/es/tile/service/TileLayerService.js +4 -4
  53. package/es/tile/service/TilePickService.js +3 -3
  54. package/es/tile/tile/Tile.d.ts +3 -0
  55. package/es/tile/tile/Tile.js +2 -2
  56. package/es/wind/models/wind.js +5 -6
  57. package/lib/canvas/index.js +2 -3
  58. package/lib/canvas/models/canvas.js +4 -5
  59. package/lib/canvas/models/index.js +1 -2
  60. package/lib/citybuliding/building.js +2 -3
  61. package/lib/citybuliding/models/build.js +2 -3
  62. package/lib/core/BaseLayer.js +19 -13
  63. package/lib/core/BaseModel.js +30 -7
  64. package/lib/core/CommonStyleAttribute.js +22 -0
  65. package/lib/core/LayerPickService.js +2 -3
  66. package/lib/core/TextureService.js +4 -5
  67. package/lib/core/constant.js +3 -5
  68. package/lib/core/interface.js +6 -11
  69. package/lib/core/schema.js +2 -3
  70. package/lib/core/shape/Path.js +3 -6
  71. package/lib/core/triangulation.js +2 -2
  72. package/lib/earth/index.js +3 -4
  73. package/lib/earth/models/atmosphere.js +2 -3
  74. package/lib/earth/models/base.js +2 -3
  75. package/lib/earth/models/bloomsphere.js +2 -3
  76. package/lib/earth/utils.js +3 -6
  77. package/lib/geometry/index.js +3 -4
  78. package/lib/geometry/models/billboard.js +3 -4
  79. package/lib/geometry/models/index.js +1 -2
  80. package/lib/geometry/models/plane.js +4 -5
  81. package/lib/geometry/models/sprite.js +4 -5
  82. package/lib/heatmap/index.js +3 -4
  83. package/lib/heatmap/models/grid.js +2 -3
  84. package/lib/heatmap/models/grid3d.js +2 -3
  85. package/lib/heatmap/models/heatmap.js +6 -7
  86. package/lib/heatmap/models/hexagon.js +2 -3
  87. package/lib/heatmap/models/index.js +1 -2
  88. package/lib/image/index.js +2 -3
  89. package/lib/image/models/image.js +3 -4
  90. package/lib/image/models/index.js +1 -2
  91. package/lib/line/index.js +3 -4
  92. package/lib/line/models/arc.js +3 -4
  93. package/lib/line/models/arc_3d.js +3 -4
  94. package/lib/line/models/earthArc_3d.js +3 -4
  95. package/lib/line/models/flow.js +2 -3
  96. package/lib/line/models/great_circle.js +3 -4
  97. package/lib/line/models/index.js +1 -2
  98. package/lib/line/models/line.js +3 -4
  99. package/lib/line/models/linearline.js +3 -4
  100. package/lib/line/models/simpleLine.js +2 -3
  101. package/lib/line/models/wall.js +3 -4
  102. package/lib/mask/index.js +2 -3
  103. package/lib/mask/models/fill.js +2 -3
  104. package/lib/mask/models/index.js +1 -2
  105. package/lib/plugins/DataMappingPlugin.js +3 -4
  106. package/lib/plugins/DataSourcePlugin.js +2 -3
  107. package/lib/plugins/FeatureScalePlugin.js +4 -5
  108. package/lib/plugins/LayerAnimateStylePlugin.js +2 -3
  109. package/lib/plugins/LayerMaskPlugin.js +2 -3
  110. package/lib/plugins/LayerModelPlugin.js +2 -3
  111. package/lib/plugins/LayerStylePlugin.js +2 -3
  112. package/lib/plugins/LightingPlugin.js +2 -3
  113. package/lib/plugins/MultiPassRendererPlugin.js +2 -3
  114. package/lib/plugins/PixelPickingPlugin.js +93 -25
  115. package/lib/plugins/RegisterStyleAttributePlugin.js +6 -25
  116. package/lib/plugins/ShaderUniformPlugin.js +75 -8
  117. package/lib/plugins/UpdateModelPlugin.js +2 -3
  118. package/lib/plugins/UpdateStyleAttributePlugin.js +2 -3
  119. package/lib/point/index.js +3 -4
  120. package/lib/point/models/billboard_point.js +2 -3
  121. package/lib/point/models/earthExtrude.js +2 -3
  122. package/lib/point/models/earthFill.js +2 -3
  123. package/lib/point/models/extrude.js +2 -3
  124. package/lib/point/models/fill.js +33 -10
  125. package/lib/point/models/fillmage.js +3 -4
  126. package/lib/point/models/image.js +3 -4
  127. package/lib/point/models/index.js +1 -2
  128. package/lib/point/models/normal.js +32 -15
  129. package/lib/point/models/radar.js +2 -3
  130. package/lib/point/models/text.js +3 -4
  131. package/lib/point/shaders/fill_frag.glsl +20 -14
  132. package/lib/point/shaders/fill_vert.glsl +19 -18
  133. package/lib/point/shaders/normal_frag.glsl +4 -3
  134. package/lib/point/shaders/normal_vert.glsl +12 -11
  135. package/lib/polygon/index.js +3 -4
  136. package/lib/polygon/models/extrude.js +3 -4
  137. package/lib/polygon/models/extrusion.js +3 -4
  138. package/lib/polygon/models/fill.js +2 -3
  139. package/lib/polygon/models/index.js +1 -2
  140. package/lib/polygon/models/ocean.js +5 -6
  141. package/lib/polygon/models/water.js +3 -4
  142. package/lib/raster/index.js +2 -3
  143. package/lib/raster/models/index.js +1 -2
  144. package/lib/raster/models/raster.js +4 -5
  145. package/lib/raster/models/rasterRgb.js +3 -4
  146. package/lib/raster/models/rasterTerrainRgb.js +3 -4
  147. package/lib/tile/core/BaseLayer.js +6 -7
  148. package/lib/tile/core/TileDebugLayer.js +2 -3
  149. package/lib/tile/interaction/getRasterData.js +4 -4
  150. package/lib/tile/service/TileLayerService.js +6 -7
  151. package/lib/tile/service/TilePickService.js +5 -6
  152. package/lib/tile/service/TileSourceService.js +4 -5
  153. package/lib/tile/tile/DebugTile.js +2 -3
  154. package/lib/tile/tile/ImageTile.js +2 -3
  155. package/lib/tile/tile/MaskTile.js +2 -3
  156. package/lib/tile/tile/RasterRGBTile.js +2 -3
  157. package/lib/tile/tile/RasterTerrainRGBTile.js +2 -3
  158. package/lib/tile/tile/RasterTile.js +2 -3
  159. package/lib/tile/tile/Tile.js +4 -5
  160. package/lib/tile/tile/VectorTile.js +2 -3
  161. package/lib/tile/utils/constants.js +2 -3
  162. package/lib/tile/utils/utils.js +1 -2
  163. package/lib/utils/blend.js +2 -3
  164. package/lib/utils/collision-index.js +2 -3
  165. package/lib/utils/extrude_polyline.js +2 -3
  166. package/lib/utils/grid-index.js +1 -2
  167. package/lib/utils/simpleLine.js +2 -3
  168. package/lib/wind/index.js +2 -3
  169. package/lib/wind/models/index.js +1 -2
  170. package/lib/wind/models/wind.js +7 -9
  171. package/lib/wind/models/windRender.js +4 -5
  172. package/lib/wind/models/windShader.js +6 -12
  173. package/package.json +7 -7
@@ -11,7 +11,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
11
11
  var _inversify = require("inversify");
12
12
  require("reflect-metadata");
13
13
  var _dec, _class;
14
- var LayerAnimateStylePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
14
+ var LayerAnimateStylePlugin = exports.default = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
15
15
  function LayerAnimateStylePlugin() {
16
16
  (0, _classCallCheck2.default)(this, LayerAnimateStylePlugin);
17
17
  }
@@ -30,5 +30,4 @@ var LayerAnimateStylePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class
30
30
  }
31
31
  }]);
32
32
  return LayerAnimateStylePlugin;
33
- }()) || _class);
34
- exports.default = LayerAnimateStylePlugin;
33
+ }()) || _class);
@@ -14,7 +14,7 @@ var _dec, _class;
14
14
  /**
15
15
  * 更新图层样式,初始图层相关配置
16
16
  */
17
- var LayerStylePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
17
+ var LayerStylePlugin = exports.default = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
18
18
  function LayerStylePlugin() {
19
19
  (0, _classCallCheck2.default)(this, LayerStylePlugin);
20
20
  }
@@ -37,5 +37,4 @@ var LayerStylePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__
37
37
  }
38
38
  }]);
39
39
  return LayerStylePlugin;
40
- }()) || _class);
41
- exports.default = LayerStylePlugin;
40
+ }()) || _class);
@@ -17,7 +17,7 @@ var _dec, _class;
17
17
  /**
18
18
  * Layer Model 初始化,更新,销毁
19
19
  */
20
- var LayerModelPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
20
+ var LayerModelPlugin = exports.default = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
21
21
  function LayerModelPlugin() {
22
22
  (0, _classCallCheck2.default)(this, LayerModelPlugin);
23
23
  }
@@ -152,5 +152,4 @@ var LayerModelPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__
152
152
  }
153
153
  }]);
154
154
  return LayerModelPlugin;
155
- }()) || _class);
156
- exports.default = LayerModelPlugin;
155
+ }()) || _class);
@@ -13,7 +13,7 @@ var _dec, _class;
13
13
  /**
14
14
  * 更新图层样式,初始图层相关配置
15
15
  */
16
- var LayerStylePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
16
+ var LayerStylePlugin = exports.default = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
17
17
  function LayerStylePlugin() {
18
18
  (0, _classCallCheck2.default)(this, LayerStylePlugin);
19
19
  }
@@ -33,5 +33,4 @@ var LayerStylePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__
33
33
  }
34
34
  }]);
35
35
  return LayerStylePlugin;
36
- }()) || _class);
37
- exports.default = LayerStylePlugin;
36
+ }()) || _class);
@@ -80,7 +80,7 @@ function generateLightingUniforms(lights) {
80
80
  /**
81
81
  * 光照 & Shadow
82
82
  */
83
- var LightingPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
83
+ var LightingPlugin = exports.default = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
84
84
  function LightingPlugin() {
85
85
  (0, _classCallCheck2.default)(this, LightingPlugin);
86
86
  }
@@ -102,5 +102,4 @@ var LightingPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PU
102
102
  }
103
103
  }]);
104
104
  return LightingPlugin;
105
- }()) || _class);
106
- exports.default = LightingPlugin;
105
+ }()) || _class);
@@ -24,7 +24,7 @@ var _dec, _class;
24
24
  * ],
25
25
  * })
26
26
  */
27
- var MultiPassRendererPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
27
+ var MultiPassRendererPlugin = exports.default = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
28
28
  function MultiPassRendererPlugin() {
29
29
  (0, _classCallCheck2.default)(this, MultiPassRendererPlugin);
30
30
  }
@@ -62,5 +62,4 @@ var MultiPassRendererPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class
62
62
  }
63
63
  }]);
64
64
  return MultiPassRendererPlugin;
65
- }()) || _class);
66
- exports.default = MultiPassRendererPlugin;
65
+ }()) || _class);
@@ -7,24 +7,81 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
11
  var _l7Core = require("@antv/l7-core");
11
12
  var _l7Utils = require("@antv/l7-utils");
12
13
  var _inversify = require("inversify");
13
14
  require("reflect-metadata");
15
+ var _CommonStyleAttribute = require("../core/CommonStyleAttribute");
14
16
  var _dec, _class;
15
17
  var PickingStage = {
16
18
  NONE: 0.0,
17
19
  ENCODE: 1.0,
18
20
  HIGHLIGHT: 2.0
19
21
  };
20
- var PixelPickingPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
22
+ var PixelPickingPlugin = exports.default = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
21
23
  function PixelPickingPlugin() {
22
24
  (0, _classCallCheck2.default)(this, PixelPickingPlugin);
25
+ (0, _defineProperty2.default)(this, "PickOption", {
26
+ u_HighlightColor: [1, 0, 0, 1],
27
+ u_SelectColor: [1, 0, 0, 1],
28
+ u_PickingColor: [0, 0, 0],
29
+ u_PickingStage: 0,
30
+ u_CurrentSelectedId: [0, 0, 0],
31
+ u_PickingThreshold: 10,
32
+ u_PickingBuffer: 0,
33
+ // TODO: 更新机制
34
+ u_shaderPick: 0,
35
+ u_EnableSelect: 0,
36
+ u_activeMix: 0
37
+ });
23
38
  }
24
39
  (0, _createClass2.default)(PixelPickingPlugin, [{
40
+ key: "pickOption2Array",
41
+ value: function pickOption2Array() {
42
+ return Object.values(this.PickOption).flat();
43
+ }
44
+ }, {
45
+ key: "updatePickOption",
46
+ value: function updatePickOption(option, rendererService) {
47
+ var _this = this;
48
+ Object.keys(option).forEach(function (key) {
49
+ _this.PickOption[key] = option[key];
50
+ });
51
+ rendererService.uniformBuffers[1].subData({
52
+ offset: 0,
53
+ data: new Uint8Array(new Float32Array(this.pickOption2Array()))
54
+ });
55
+ }
56
+ }, {
25
57
  key: "apply",
26
58
  value: function apply(layer, _ref) {
27
- var styleAttributeService = _ref.styleAttributeService;
59
+ var _this2 = this;
60
+ var rendererService = _ref.rendererService,
61
+ styleAttributeService = _ref.styleAttributeService;
62
+ if (!rendererService.uniformBuffers[1]) {
63
+ // Create a Uniform Buffer Object(UBO).
64
+ var uniformBuffer = rendererService.createBuffer({
65
+ // vec4 u_HighlightColor;
66
+ // vec4 u_SelectColor;
67
+ // vec3 u_PickingColor;
68
+ // float u_PickingStage;
69
+ // vec3 u_CurrentSelectedId;
70
+ // float u_PickingThreshold;
71
+ // float u_PickingBuffer;
72
+ // float u_shaderPick;
73
+ // float u_EnableSelect;
74
+ // float u_activeMix;
75
+ data: new Float32Array(this.pickOption2Array().length),
76
+ isUBO: true
77
+ });
78
+ rendererService.uniformBuffers[1] = uniformBuffer;
79
+ this.updatePickOption({}, rendererService);
80
+ }
81
+ // u_PickingBuffer: layer.getLayerConfig().pickingBuffer || 0,
82
+ // // Tip: 当前地图是否在拖动
83
+ // u_shaderPick: Number(layer.getShaderPickStat()),
84
+
28
85
  // TODO: 由于 Shader 目前无法根据是否开启拾取进行内容修改,因此即使不开启也需要生成 a_PickingColor
29
86
  layer.hooks.init.tapPromise('PixelPickingPlugin', function () {
30
87
  var _layer$getLayerConfig = layer.getLayerConfig(),
@@ -34,6 +91,7 @@ var PixelPickingPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#
34
91
  type: _l7Core.AttributeType.Attribute,
35
92
  descriptor: {
36
93
  name: 'a_PickingColor',
94
+ shaderLocation: _CommonStyleAttribute.ShaderLocation.PICKING_COLOR,
37
95
  buffer: {
38
96
  data: [],
39
97
  type: _l7Core.gl.FLOAT
@@ -53,6 +111,9 @@ var PixelPickingPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#
53
111
  var _layer$getLayerConfig2 = layer.getLayerConfig(),
54
112
  enablePicking = _layer$getLayerConfig2.enablePicking;
55
113
  if (enablePicking && layer.isVisible()) {
114
+ _this2.updatePickOption({
115
+ u_PickingStage: PickingStage.ENCODE
116
+ }, rendererService);
56
117
  layer.models.forEach(function (model) {
57
118
  return model.addUniforms({
58
119
  u_PickingStage: PickingStage.ENCODE
@@ -65,6 +126,9 @@ var PixelPickingPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#
65
126
  enablePicking = _layer$getLayerConfig3.enablePicking;
66
127
  // 区分选中高亮 和滑过高亮
67
128
  if (enablePicking && layer.isVisible()) {
129
+ _this2.updatePickOption({
130
+ u_PickingStage: PickingStage.HIGHLIGHT
131
+ }, rendererService);
68
132
  layer.models.forEach(function (model) {
69
133
  return model.addUniforms({
70
134
  u_PickingStage: PickingStage.HIGHLIGHT
@@ -81,15 +145,17 @@ var PixelPickingPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#
81
145
  layer.updateLayerConfig({
82
146
  pickedFeatureID: (0, _l7Utils.decodePickingColor)(new Uint8Array(pickedColor))
83
147
  });
148
+ var option = {
149
+ u_PickingStage: PickingStage.HIGHLIGHT,
150
+ u_PickingColor: pickedColor,
151
+ u_HighlightColor: highlightColorInArray.map(function (c) {
152
+ return c * 255;
153
+ }),
154
+ u_activeMix: activeMix
155
+ };
156
+ _this2.updatePickOption(option, rendererService);
84
157
  layer.models.forEach(function (model) {
85
- return model.addUniforms({
86
- u_PickingStage: PickingStage.HIGHLIGHT,
87
- u_PickingColor: pickedColor,
88
- u_HighlightColor: highlightColorInArray.map(function (c) {
89
- return c * 255;
90
- }),
91
- u_activeMix: activeMix
92
- });
158
+ return model.addUniforms(option);
93
159
  });
94
160
  });
95
161
  layer.hooks.beforeSelect.tap('PixelPickingPlugin', function (pickedColor) {
@@ -101,24 +167,26 @@ var PixelPickingPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#
101
167
  layer.updateLayerConfig({
102
168
  pickedFeatureID: (0, _l7Utils.decodePickingColor)(new Uint8Array(pickedColor))
103
169
  });
170
+ var option = {
171
+ u_PickingStage: PickingStage.HIGHLIGHT,
172
+ u_PickingColor: pickedColor,
173
+ u_HighlightColor: highlightColorInArray.map(function (c) {
174
+ return c * 255;
175
+ }),
176
+ u_activeMix: selectMix,
177
+ u_CurrentSelectedId: pickedColor,
178
+ u_SelectColor: highlightColorInArray.map(function (c) {
179
+ return c * 255;
180
+ }),
181
+ u_EnableSelect: 1
182
+ };
183
+ console.log(option);
184
+ _this2.updatePickOption(option, rendererService);
104
185
  layer.models.forEach(function (model) {
105
- return model.addUniforms({
106
- u_PickingStage: PickingStage.HIGHLIGHT,
107
- u_PickingColor: pickedColor,
108
- u_HighlightColor: highlightColorInArray.map(function (c) {
109
- return c * 255;
110
- }),
111
- u_activeMix: selectMix,
112
- u_CurrentSelectedId: pickedColor,
113
- u_SelectColor: highlightColorInArray.map(function (c) {
114
- return c * 255;
115
- }),
116
- u_EnableSelect: 1
117
- });
186
+ return model.addUniforms(option);
118
187
  });
119
188
  });
120
189
  }
121
190
  }]);
122
191
  return PixelPickingPlugin;
123
- }()) || _class);
124
- exports.default = PixelPickingPlugin;
192
+ }()) || _class);
@@ -10,12 +10,13 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
10
10
  var _l7Core = require("@antv/l7-core");
11
11
  var _inversify = require("inversify");
12
12
  require("reflect-metadata");
13
+ var _CommonStyleAttribute = require("../core/CommonStyleAttribute");
13
14
  var _utils = require("../tile/utils/utils");
14
15
  var _dec, _class;
15
16
  /**
16
17
  * 在初始化阶段完成属性的注册,以及首次根据 Layer 指定的三角化方法完成 indices 和 attribute 的创建
17
18
  */
18
- var RegisterStyleAttributePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
19
+ var RegisterStyleAttributePlugin = exports.default = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
19
20
  function RegisterStyleAttributePlugin() {
20
21
  (0, _classCallCheck2.default)(this, RegisterStyleAttributePlugin);
21
22
  }
@@ -54,6 +55,7 @@ var RegisterStyleAttributePlugin = (_dec = (0, _inversify.injectable)(), _dec(_c
54
55
  type: _l7Core.AttributeType.Attribute,
55
56
  descriptor: {
56
57
  name: 'a_Position',
58
+ shaderLocation: _CommonStyleAttribute.ShaderLocation.POSITION,
57
59
  buffer: {
58
60
  data: [],
59
61
  type: _l7Core.gl.FLOAT
@@ -65,28 +67,6 @@ var RegisterStyleAttributePlugin = (_dec = (0, _inversify.injectable)(), _dec(_c
65
67
  }
66
68
  });
67
69
  }
68
- }, {
69
- key: "registerFilterAttribute",
70
- value: function registerFilterAttribute(styleAttributeService) {
71
- styleAttributeService.registerStyleAttribute({
72
- name: 'filter',
73
- type: _l7Core.AttributeType.Attribute,
74
- descriptor: {
75
- name: 'filter',
76
- buffer: {
77
- // give the WebGL driver a hint that this buffer may change
78
- usage: _l7Core.gl.DYNAMIC_DRAW,
79
- data: [],
80
- type: _l7Core.gl.FLOAT
81
- },
82
- size: 1,
83
- update: function update(feature) {
84
- var filter = feature.filter;
85
- return filter ? [1] : [0];
86
- }
87
- }
88
- });
89
- }
90
70
  }, {
91
71
  key: "registerColorAttribute",
92
72
  value: function registerColorAttribute(styleAttributeService) {
@@ -95,6 +75,7 @@ var RegisterStyleAttributePlugin = (_dec = (0, _inversify.injectable)(), _dec(_c
95
75
  type: _l7Core.AttributeType.Attribute,
96
76
  descriptor: {
97
77
  name: 'a_Color',
78
+ shaderLocation: _CommonStyleAttribute.ShaderLocation.COLOR,
98
79
  buffer: {
99
80
  // give the WebGL driver a hint that this buffer may change
100
81
  usage: _l7Core.gl.DYNAMIC_DRAW,
@@ -118,6 +99,7 @@ var RegisterStyleAttributePlugin = (_dec = (0, _inversify.injectable)(), _dec(_c
118
99
  type: _l7Core.AttributeType.Attribute,
119
100
  descriptor: {
120
101
  name: 'a_vertexId',
102
+ shaderLocation: _CommonStyleAttribute.ShaderLocation.VERTEX_ID,
121
103
  buffer: {
122
104
  // give the WebGL driver a hint that this buffer may change
123
105
  usage: _l7Core.gl.DYNAMIC_DRAW,
@@ -133,5 +115,4 @@ var RegisterStyleAttributePlugin = (_dec = (0, _inversify.injectable)(), _dec(_c
133
115
  }
134
116
  }]);
135
117
  return RegisterStyleAttributePlugin;
136
- }()) || _class);
137
- exports.default = RegisterStyleAttributePlugin;
118
+ }()) || _class);
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
8
10
  var _initializerDefineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/initializerDefineProperty"));
9
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
@@ -14,7 +16,7 @@ var _initializerWarningHelper2 = _interopRequireDefault(require("@babel/runtime/
14
16
  var _l7Core = require("@antv/l7-core");
15
17
  var _inversify = require("inversify");
16
18
  require("reflect-metadata");
17
- var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;
19
+ var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5;
18
20
  /**
19
21
  * 在渲染之前需要获取当前 Shader 所需 Uniform,例如:
20
22
  * 1. 从相机服务中获取 View & ProjectionMatrix,当前缩放等级等等
@@ -22,13 +24,14 @@ var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2
22
24
  * @see https://yuque.antfin-inc.com/yuqi.pyq/fgetpa/doml91
23
25
  * 3. 当前 Layer 本身的样式属性
24
26
  */
25
- var ShaderUniformPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inversify.inject)(_l7Core.TYPES.ICameraService), _dec3 = (0, _inversify.inject)(_l7Core.TYPES.ICoordinateSystemService), _dec4 = (0, _inversify.inject)(_l7Core.TYPES.IRendererService), _dec5 = (0, _inversify.inject)(_l7Core.TYPES.IMapService), _dec(_class = (_class2 = /*#__PURE__*/function () {
27
+ var ShaderUniformPlugin = exports.default = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inversify.inject)(_l7Core.TYPES.ICameraService), _dec3 = (0, _inversify.inject)(_l7Core.TYPES.ICoordinateSystemService), _dec4 = (0, _inversify.inject)(_l7Core.TYPES.IRendererService), _dec5 = (0, _inversify.inject)(_l7Core.TYPES.IMapService), _dec6 = (0, _inversify.inject)(_l7Core.TYPES.ILayerService), _dec(_class = (_class2 = /*#__PURE__*/function () {
26
28
  function ShaderUniformPlugin() {
27
29
  (0, _classCallCheck2.default)(this, ShaderUniformPlugin);
28
30
  (0, _initializerDefineProperty2.default)(this, "cameraService", _descriptor, this);
29
31
  (0, _initializerDefineProperty2.default)(this, "coordinateSystemService", _descriptor2, this);
30
32
  (0, _initializerDefineProperty2.default)(this, "rendererService", _descriptor3, this);
31
33
  (0, _initializerDefineProperty2.default)(this, "mapService", _descriptor4, this);
34
+ (0, _initializerDefineProperty2.default)(this, "layerService", _descriptor5, this);
32
35
  }
33
36
  (0, _createClass2.default)(ShaderUniformPlugin, [{
34
37
  key: "apply",
@@ -37,6 +40,15 @@ var ShaderUniformPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inv
37
40
  var version = this.mapService.version;
38
41
  var mvp = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; // default matrix (for gaode2.x)
39
42
  var sceneCenterMercator = [0, 0];
43
+ var uniformBuffer;
44
+ if (!this.rendererService.uniformBuffers[0]) {
45
+ // Create a Uniform Buffer Object(UBO).
46
+ uniformBuffer = this.rendererService.createBuffer({
47
+ data: new Float32Array(16 * 5 + 4 * 6 + 4),
48
+ isUBO: true
49
+ });
50
+ this.rendererService.uniformBuffers[0] = uniformBuffer;
51
+ }
40
52
  layer.hooks.beforeRender.tap('ShaderUniformPlugin', function () {
41
53
  // @ts-ignore
42
54
  var offset = layer.getLayerConfig().tileOrigin;
@@ -53,12 +65,25 @@ var ShaderUniformPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inv
53
65
  var _this$rendererService = _this.rendererService.getViewportSize(),
54
66
  width = _this$rendererService.width,
55
67
  height = _this$rendererService.height;
68
+ var _this$generateUBO = _this.generateUBO(mvp, sceneCenterMercator, width, height),
69
+ data = _this$generateUBO.data,
70
+ uniforms = _this$generateUBO.uniforms;
71
+ if (_this.layerService.alreadyInRendering && uniformBuffer) {
72
+ // Update only once since all models can share one UBO.
73
+ uniformBuffer.subData({
74
+ offset: 0,
75
+ data: data
76
+ });
77
+ }
78
+ // For WebGL1. regl
56
79
  layer.models.forEach(function (model) {
57
- var _model$addUniforms;
58
- model.addUniforms((_model$addUniforms = {}, (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ProjectionMatrix, _this.cameraService.getProjectionMatrix()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ViewMatrix, _this.cameraService.getViewMatrix()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ViewProjectionMatrix, _this.cameraService.getViewProjectionMatrix()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.Zoom, _this.cameraService.getZoom()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.ZoomScale, _this.cameraService.getZoomScale()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.FocalDistance, _this.cameraService.getFocalDistance()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CameraUniform.CameraPosition, _this.cameraService.getCameraPosition()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.CoordinateSystem, _this.coordinateSystemService.getCoordinateSystem()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.ViewportCenter, _this.coordinateSystemService.getViewportCenter()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.ViewportCenterProjection, _this.coordinateSystemService.getViewportCenterProjection()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.PixelsPerDegree, _this.coordinateSystemService.getPixelsPerDegree()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.PixelsPerDegree2, _this.coordinateSystemService.getPixelsPerDegree2()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.PixelsPerMeter, _this.coordinateSystemService.getPixelsPerMeter()), (0, _defineProperty2.default)(_model$addUniforms, _l7Core.CoordinateUniform.Mvp, mvp), (0, _defineProperty2.default)(_model$addUniforms, "u_sceneCenterMercator", sceneCenterMercator), (0, _defineProperty2.default)(_model$addUniforms, "u_ViewportSize", [width, height]), (0, _defineProperty2.default)(_model$addUniforms, "u_ModelMatrix", _this.cameraService.getModelMatrix()), (0, _defineProperty2.default)(_model$addUniforms, "u_DevicePixelRatio", window.devicePixelRatio), (0, _defineProperty2.default)(_model$addUniforms, "u_PickingBuffer", layer.getLayerConfig().pickingBuffer || 0), (0, _defineProperty2.default)(_model$addUniforms, "u_shaderPick", Number(layer.getShaderPickStat())), _model$addUniforms));
80
+ model.addUniforms((0, _objectSpread2.default)((0, _objectSpread2.default)({}, uniforms), {}, {
81
+ // TODO: move these 2 uniforms to PixelPickingPlugin
82
+ u_PickingBuffer: layer.getLayerConfig().pickingBuffer || 0,
83
+ // Tip: 当前地图是否在拖动
84
+ u_shaderPick: Number(layer.getShaderPickStat())
85
+ }));
59
86
  });
60
-
61
- // TODO:脏检查,决定是否需要渲染
62
87
  });
63
88
  }
64
89
 
@@ -76,6 +101,44 @@ var ShaderUniformPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inv
76
101
  this.mapService.setCoordCenter(layer.coordCenter);
77
102
  }
78
103
  }
104
+ }, {
105
+ key: "generateUBO",
106
+ value: function generateUBO(u_Mvp, sceneCenterMercator, width, height) {
107
+ var _uniforms;
108
+ var u_ProjectionMatrix = this.cameraService.getProjectionMatrix();
109
+ var u_ViewMatrix = this.cameraService.getViewMatrix();
110
+ var u_ViewProjectionMatrix = this.cameraService.getViewProjectionMatrix();
111
+ var u_ModelMatrix = this.cameraService.getModelMatrix();
112
+ var u_ViewportCenterProjection = this.coordinateSystemService.getViewportCenterProjection();
113
+ var u_PixelsPerDegree = this.coordinateSystemService.getPixelsPerDegree();
114
+ var u_Zoom = this.cameraService.getZoom();
115
+ var u_PixelsPerDegree2 = this.coordinateSystemService.getPixelsPerDegree2();
116
+ var u_ZoomScale = this.cameraService.getZoomScale();
117
+ var u_PixelsPerMeter = this.coordinateSystemService.getPixelsPerMeter();
118
+ var u_CoordinateSystem = this.coordinateSystemService.getCoordinateSystem();
119
+ var u_CameraPosition = this.cameraService.getCameraPosition();
120
+ var u_DevicePixelRatio = window.devicePixelRatio;
121
+ var u_ViewportCenter = this.coordinateSystemService.getViewportCenter();
122
+ var u_ViewportSize = [width, height];
123
+ var u_FocalDistance = this.cameraService.getFocalDistance();
124
+ var data = [].concat((0, _toConsumableArray2.default)(u_ViewMatrix), (0, _toConsumableArray2.default)(u_ProjectionMatrix), (0, _toConsumableArray2.default)(u_ViewProjectionMatrix), (0, _toConsumableArray2.default)(u_ModelMatrix), (0, _toConsumableArray2.default)(u_Mvp), (0, _toConsumableArray2.default)(u_ViewportCenterProjection), (0, _toConsumableArray2.default)(u_PixelsPerDegree), [
125
+ // 4
126
+ u_Zoom], (0, _toConsumableArray2.default)(u_PixelsPerDegree2), [
127
+ // 4
128
+ u_ZoomScale], (0, _toConsumableArray2.default)(u_PixelsPerMeter), [
129
+ // 4
130
+ u_CoordinateSystem], (0, _toConsumableArray2.default)(u_CameraPosition), [
131
+ // 4
132
+ u_DevicePixelRatio], (0, _toConsumableArray2.default)(u_ViewportCenter), u_ViewportSize, (0, _toConsumableArray2.default)(sceneCenterMercator), [
133
+ // 2
134
+ u_FocalDistance,
135
+ // 1
136
+ 0]);
137
+ return {
138
+ data: data,
139
+ uniforms: (_uniforms = {}, (0, _defineProperty2.default)(_uniforms, _l7Core.CameraUniform.ProjectionMatrix, u_ProjectionMatrix), (0, _defineProperty2.default)(_uniforms, _l7Core.CameraUniform.ViewMatrix, u_ViewMatrix), (0, _defineProperty2.default)(_uniforms, _l7Core.CameraUniform.ViewProjectionMatrix, u_ViewProjectionMatrix), (0, _defineProperty2.default)(_uniforms, _l7Core.CameraUniform.Zoom, u_Zoom), (0, _defineProperty2.default)(_uniforms, _l7Core.CameraUniform.ZoomScale, u_ZoomScale), (0, _defineProperty2.default)(_uniforms, _l7Core.CameraUniform.FocalDistance, u_FocalDistance), (0, _defineProperty2.default)(_uniforms, _l7Core.CameraUniform.CameraPosition, u_CameraPosition), (0, _defineProperty2.default)(_uniforms, _l7Core.CoordinateUniform.CoordinateSystem, u_CoordinateSystem), (0, _defineProperty2.default)(_uniforms, _l7Core.CoordinateUniform.ViewportCenter, u_ViewportCenter), (0, _defineProperty2.default)(_uniforms, _l7Core.CoordinateUniform.ViewportCenterProjection, u_ViewportCenterProjection), (0, _defineProperty2.default)(_uniforms, _l7Core.CoordinateUniform.PixelsPerDegree, u_PixelsPerDegree), (0, _defineProperty2.default)(_uniforms, _l7Core.CoordinateUniform.PixelsPerDegree2, u_PixelsPerDegree2), (0, _defineProperty2.default)(_uniforms, _l7Core.CoordinateUniform.PixelsPerMeter, u_PixelsPerMeter), (0, _defineProperty2.default)(_uniforms, _l7Core.CoordinateUniform.Mvp, u_Mvp), (0, _defineProperty2.default)(_uniforms, "u_sceneCenterMercator", sceneCenterMercator), (0, _defineProperty2.default)(_uniforms, "u_ViewportSize", u_ViewportSize), (0, _defineProperty2.default)(_uniforms, "u_ModelMatrix", u_ModelMatrix), (0, _defineProperty2.default)(_uniforms, "u_DevicePixelRatio", u_DevicePixelRatio), _uniforms)
140
+ };
141
+ }
79
142
  }]);
80
143
  return ShaderUniformPlugin;
81
144
  }(), (_descriptor = (0, _applyDecoratedDescriptor2.default)(_class2.prototype, "cameraService", [_dec2], {
@@ -98,5 +161,9 @@ var ShaderUniformPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inv
98
161
  enumerable: true,
99
162
  writable: true,
100
163
  initializer: null
101
- })), _class2)) || _class);
102
- exports.default = ShaderUniformPlugin;
164
+ }), _descriptor5 = (0, _applyDecoratedDescriptor2.default)(_class2.prototype, "layerService", [_dec6], {
165
+ configurable: true,
166
+ enumerable: true,
167
+ writable: true,
168
+ initializer: null
169
+ })), _class2)) || _class);
@@ -13,7 +13,7 @@ var _dec, _class;
13
13
  /**
14
14
  * Model 更新
15
15
  */
16
- var UpdateModelPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
16
+ var UpdateModelPlugin = exports.default = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
17
17
  function UpdateModelPlugin() {
18
18
  (0, _classCallCheck2.default)(this, UpdateModelPlugin);
19
19
  }
@@ -36,5 +36,4 @@ var UpdateModelPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#_
36
36
  }
37
37
  }]);
38
38
  return UpdateModelPlugin;
39
- }()) || _class);
40
- exports.default = UpdateModelPlugin;
39
+ }()) || _class);
@@ -13,7 +13,7 @@ var _dec, _class;
13
13
  /**
14
14
  * 在初始化阶段完成属性的注册,以及首次根据 Layer 指定的三角化方法完成 indices 和 attribute 的创建
15
15
  */
16
- var UpdateStyleAttributePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
16
+ var UpdateStyleAttributePlugin = exports.default = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
17
17
  function UpdateStyleAttributePlugin() {
18
18
  (0, _classCallCheck2.default)(this, UpdateStyleAttributePlugin);
19
19
  }
@@ -78,5 +78,4 @@ var UpdateStyleAttributePlugin = (_dec = (0, _inversify.injectable)(), _dec(_cla
78
78
  }
79
79
  }]);
80
80
  return UpdateStyleAttributePlugin;
81
- }()) || _class);
82
- exports.default = UpdateStyleAttributePlugin;
81
+ }()) || _class);
@@ -21,7 +21,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
21
21
  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; }
22
22
  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); }; }
23
23
  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; } }
24
- var PointLayer = /*#__PURE__*/function (_BaseLayer) {
24
+ var PointLayer = exports.default = /*#__PURE__*/function (_BaseLayer) {
25
25
  (0, _inherits2.default)(PointLayer, _BaseLayer);
26
26
  var _super = _createSuper(PointLayer);
27
27
  function PointLayer() {
@@ -32,7 +32,7 @@ var PointLayer = /*#__PURE__*/function (_BaseLayer) {
32
32
  }
33
33
  _this = _super.call.apply(_super, [this].concat(args));
34
34
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "type", 'PointLayer');
35
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "enableShaderEncodeStyles", ['opacity', 'offsets', 'stroke', 'rotation']);
35
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "enableShaderEncodeStyles", ['stroke', 'offsets', 'opacity', 'rotation']);
36
36
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "enableDataEncodeStyles", ['textOffset', 'textAnchor']);
37
37
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "defaultSourceConfig", {
38
38
  data: [],
@@ -209,5 +209,4 @@ var PointLayer = /*#__PURE__*/function (_BaseLayer) {
209
209
  }
210
210
  }]);
211
211
  return PointLayer;
212
- }(_BaseLayer2.default);
213
- exports.default = PointLayer;
212
+ }(_BaseLayer2.default);
@@ -31,7 +31,7 @@ function PointTriangulation(feature) {
31
31
  size: coordinates.length
32
32
  };
33
33
  }
34
- var SimplePointModel = /*#__PURE__*/function (_BaseModel) {
34
+ var SimplePointModel = exports.default = /*#__PURE__*/function (_BaseModel) {
35
35
  (0, _inherits2.default)(SimplePointModel, _BaseModel);
36
36
  var _super = _createSuper(SimplePointModel);
37
37
  function SimplePointModel() {
@@ -146,5 +146,4 @@ var SimplePointModel = /*#__PURE__*/function (_BaseModel) {
146
146
  }
147
147
  }]);
148
148
  return SimplePointModel;
149
- }(_BaseModel2.default);
150
- exports.default = SimplePointModel;
149
+ }(_BaseModel2.default);
@@ -26,7 +26,7 @@ var pointExtrudeFrag = "varying vec4 v_color;\nuniform float u_opacity: 1.0;\n\n
26
26
  /* babel-plugin-inline-import '../shaders/earth/extrude_vert.glsl' */
27
27
  var pointExtrudeVert = "precision highp float;\n\n#define pi 3.1415926535\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec3 a_Position;\nattribute vec3 a_Pos;\nattribute vec4 a_Color;\nattribute vec3 a_Size;\nattribute vec3 a_Normal;\n\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_globel;\nuniform float u_r;\nuniform mat4 u_ModelMatrix;\n\nvarying vec4 v_color;\n\nuniform float u_opacity : 1;\nuniform float u_lightEnable: 1;\nvarying float v_lightWeight;\nvarying float v_barLinearZ;\n// \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nfloat getYRadian(float x, float z) {\n if(x > 0.0 && z > 0.0) {\n return atan(x/z);\n } else if(x > 0.0 && z <= 0.0){\n return atan(-z/x) + pi/2.0;\n } else if(x <= 0.0 && z <= 0.0) {\n return pi + atan(x/z); //atan(x/z) + \n } else {\n return atan(z/-x) + pi*3.0/2.0;\n }\n}\n\nfloat getXRadian(float y, float r) {\n return atan(y/r);\n}\n\nvoid main() {\n\n \n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n vec3 size = a_Size * a_Position;\n\n // a_Position.z \u662F\u5728\u6784\u5EFA\u7F51\u683C\u7684\u65F6\u5019\u4F20\u5165\u7684\u6807\u51C6\u503C 0 - 1\uFF0C\u5728\u63D2\u503C\u5668\u63D2\u503C\u53EF\u4EE5\u83B7\u53D6 0\uFF5E1 \u7EBF\u6027\u6E10\u53D8\u7684\u503C\n v_barLinearZ = a_Position.z;\n\n vec3 offset = size; // \u63A7\u5236\u5706\u67F1\u4F53\u7684\u5927\u5C0F - \u4ECE\u6807\u51C6\u5355\u4F4D\u5706\u67F1\u4F53\u8FDB\u884C\u504F\u79FB\n if(u_heightfixed < 1.0) { // \u5706\u67F1\u4F53\u4E0D\u56FA\u5B9A\u9AD8\u5EA6\n \n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n offset = offset * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n offset = offset * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n } else {// \u5706\u67F1\u4F53\u56FA\u5B9A\u9AD8\u5EA6 \uFF08 \u5904\u7406 mapbox \uFF09\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n offset *= 4.0/pow(2.0, 21.0 - u_Zoom);\n }\n }\n\n\n vec4 project_pos = project_position(vec4(a_Pos.xy, 0., 1.0));\n\n // u_r \u63A7\u5236\u5706\u67F1\u7684\u751F\u957F\n vec4 pos = vec4(project_pos.xy + offset.xy, offset.z * u_r, 1.0);\n\n // \u5706\u67F1\u5149\u7167\u6548\u679C\n float lightWeight = 1.0;\n if(u_lightEnable > 0.0) { // \u53D6\u6D88\u4E09\u5143\u8868\u8FBE\u5F0F\uFF0C\u589E\u5F3A\u5065\u58EE\u6027\n lightWeight = calc_lighting(pos);\n }\n v_lightWeight = lightWeight;\n // \u8BBE\u7F6E\u5706\u67F1\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n v_color = mix(u_sourceColor, u_targetColor, barLinearZ);\n v_color.rgb *= lightWeight;\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n v_color = a_Color;\n }\n v_color.a *= u_opacity;\n\n \n // \u5728\u5730\u7403\u6A21\u5F0F\u4E0B\uFF0C\u5C06\u539F\u672C\u5782\u76F4\u4E8E xy \u5E73\u9762\u7684\u5706\u67F1\u8C03\u6574\u59FF\u6001\u5230\u9002\u5E94\u5706\u7684\u89D2\u5EA6\n //\u65CB\u8F6C\u77E9\u9635mx\uFF0C\u521B\u5EFA\u7ED5x\u8F74\u65CB\u8F6C\u77E9\u9635\n float r = sqrt(a_Pos.z*a_Pos.z + a_Pos.x*a_Pos.x);\n float xRadian = getXRadian(a_Pos.y, r);\n float xcos = cos(xRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u4F59\u5F26\u503C\n float xsin = sin(xRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u6B63\u5F26\u503C\n mat4 mx = mat4(\n 1,0,0,0, \n 0,xcos,-xsin,0, \n 0,xsin,xcos,0, \n 0,0,0,1);\n\n //\u65CB\u8F6C\u77E9\u9635my\uFF0C\u521B\u5EFA\u7ED5y\u8F74\u65CB\u8F6C\u77E9\u9635\n float yRadian = getYRadian(a_Pos.x, a_Pos.z);\n float ycos = cos(yRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u4F59\u5F26\u503C\n float ysin = sin(yRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u6B63\u5F26\u503C\n mat4 my = mat4(\n ycos,0,-ysin,0, \n 0,1,0,0, \n ysin,0,ycos,0, \n 0,0,0,1);\n\n gl_Position = u_ViewProjectionMatrix * vec4(( my * mx * vec4(a_Position * a_Size, 1.0)).xyz + a_Pos, 1.0);\n \n\n setPickingColor(a_PickingColor);\n}\n";
28
28
  var isNumber = _l7Utils.lodashUtil.isNumber;
29
- var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
29
+ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
30
30
  (0, _inherits2.default)(ExtrudeModel, _BaseModel);
31
31
  var _super = _createSuper(ExtrudeModel);
32
32
  function ExtrudeModel() {
@@ -237,5 +237,4 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
237
237
  }
238
238
  }]);
239
239
  return ExtrudeModel;
240
- }(_BaseModel2.default);
241
- exports.default = ExtrudeModel;
240
+ }(_BaseModel2.default);
@@ -25,7 +25,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
25
25
  var pointFillFrag = "uniform float u_additive;\nuniform float u_opacity : 1;\nuniform float u_stroke_opacity : 1;\nuniform float u_stroke_width : 2;\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 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 if(outer_df > antialiasblur + 0.018) discard;\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 * u_opacity);\n } else {\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), u_stroke_color * u_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";
26
26
  /* babel-plugin-inline-import '../shaders/earth/fill_vert.glsl' */
27
27
  var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute float a_Shape;\nuniform mat4 u_ModelMatrix;\n\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;\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 */\n float newSize = setPickingSize(a_Size);\n // float newSize = setPickingSize(a_Size) * 0.00001038445708445579;\n\n // unpack color(vec2)\n v_color = a_Color;\n\n // radius(16-bit)\n v_radius = newSize;\n\n // anti-alias\n // float antialiased_blur = -max(u_blur, antialiasblur);\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur);\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 gl_Position = u_ViewProjectionMatrix * vec4(a_Position + extrude * newSize * 0.1 + u_offsets, 1.0);\n\n setPickingColor(a_PickingColor);\n}\n";
28
- var FillModel = /*#__PURE__*/function (_BaseModel) {
28
+ var FillModel = exports.default = /*#__PURE__*/function (_BaseModel) {
29
29
  (0, _inherits2.default)(FillModel, _BaseModel);
30
30
  var _super = _createSuper(FillModel);
31
31
  function FillModel() {
@@ -221,5 +221,4 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
221
221
  }
222
222
  }]);
223
223
  return FillModel;
224
- }(_BaseModel2.default);
225
- exports.default = FillModel;
224
+ }(_BaseModel2.default);
@@ -24,7 +24,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
24
24
  var pointExtrudeFrag = "varying vec4 v_color;\nvarying float v_lightWeight;\nuniform float u_pickLight: 0.0;\n\n#pragma include \"picking\"\n\n\nvoid main() {\n\n gl_FragColor = v_color;\n // \u5F00\u542F\u900F\u660E\u5EA6\u6E10\u53D8\n // picking\n if(u_pickLight > 0.0) {\n gl_FragColor = filterColorAlpha(gl_FragColor, v_lightWeight);\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n}\n";
25
25
  /* babel-plugin-inline-import '../shaders/extrude/extrude_vert.glsl' */
26
26
  var pointExtrudeVert = "precision highp float;\n\n#define pi 3.1415926535\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec3 a_Position;\nattribute vec3 a_Pos;\nattribute vec4 a_Color;\nattribute vec3 a_Size;\nattribute vec3 a_Normal;\n\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_r;\nuniform mat4 u_ModelMatrix;\n\nvarying vec4 v_color;\nvarying float v_lightWeight;\nvarying float v_barLinearZ;\n\nuniform float u_opacity : 1;\nuniform float u_lightEnable: 1;\nuniform float u_opacitylinear: 0.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_opacitylinear_dir: 1.0;\nuniform float u_linearColor: 0.0;\n\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nfloat getYRadian(float x, float z) {\n if(x > 0.0 && z > 0.0) {\n return atan(x/z);\n } else if(x > 0.0 && z <= 0.0){\n return atan(-z/x) + pi/2.0;\n } else if(x <= 0.0 && z <= 0.0) {\n return pi + atan(x/z); //atan(x/z) + \n } else {\n return atan(z/-x) + pi*3.0/2.0;\n }\n}\n\nfloat getXRadian(float y, float r) {\n return atan(y/r);\n}\n\nvoid main() {\n\n\n vec3 size = a_Size * a_Position;\n\n vec3 offset = size; // \u63A7\u5236\u5706\u67F1\u4F53\u7684\u5927\u5C0F - \u4ECE\u6807\u51C6\u5355\u4F4D\u5706\u67F1\u4F53\u8FDB\u884C\u504F\u79FB\n\n if(u_heightfixed < 1.0) { // \u5706\u67F1\u4F53\u4E0D\u56FA\u5B9A\u9AD8\u5EA6\n \n if (u_CoordinateSystem == COORDINATE_SYSTEM_P20 || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) {\n // P20 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF1\n offset = offset * pow(2.0, (19.0 - u_Zoom));\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n offset = offset * pow(2.0, (19.0 - 3.0 - u_Zoom));\n }\n } else {// \u5706\u67F1\u4F53\u56FA\u5B9A\u9AD8\u5EA6 \uFF08 \u5904\u7406 mapbox \uFF09\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n offset *= 4.0/pow(2.0, 21.0 - u_Zoom);\n }\n }\n\n\n vec4 project_pos = project_position(vec4(a_Pos.xy, 0., 1.0));\n\n // u_r \u63A7\u5236\u5706\u67F1\u7684\u751F\u957F\n vec4 pos = vec4(project_pos.xy + offset.xy, offset.z * u_r, 1.0);\n\n // // \u5706\u67F1\u5149\u7167\u6548\u679C\n float lightWeight = 1.0;\n\n if(u_lightEnable > 0.0) { // \u53D6\u6D88\u4E09\u5143\u8868\u8FBE\u5F0F\uFF0C\u589E\u5F3A\u5065\u58EE\u6027\n lightWeight = calc_lighting(pos);\n }\n\n v_lightWeight = lightWeight;\n\n v_color = a_Color;\n\n // \u8BBE\u7F6E\u5706\u67F1\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n v_color = mix(u_sourceColor, u_targetColor, a_Position.z);\n v_color.a = v_color.a * u_opacity;\n } else {\n v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * u_opacity);\n }\n\n if(u_opacitylinear > 0.0) {\n v_color.a *= u_opacitylinear_dir > 0.0 ? (1.0 - a_Position.z): a_Position.z;\n }\n\n\n // gl_Position = project_common_position_to_clipspace(pos);\n\n gl_Position = project_common_position_to_clipspace_v2(pos);\n\n setPickingColor(a_PickingColor);\n}\n";
27
- var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
27
+ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
28
28
  (0, _inherits2.default)(ExtrudeModel, _BaseModel);
29
29
  var _super = _createSuper(ExtrudeModel);
30
30
  function ExtrudeModel() {
@@ -236,5 +236,4 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
236
236
  }
237
237
  }]);
238
238
  return ExtrudeModel;
239
- }(_BaseModel2.default);
240
- exports.default = ExtrudeModel;
239
+ }(_BaseModel2.default);