@antv/l7-layers 2.20.2 → 2.20.5

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.
@@ -1,32 +1,28 @@
1
- precision highp float;
2
-
3
1
  #define pi 3.1415926535
4
2
  #define ambientRatio 0.5
5
3
  #define diffuseRatio 0.3
6
4
  #define specularRatio 0.2
7
5
 
8
- attribute vec3 a_Position;
9
- attribute vec3 a_Pos;
10
- attribute vec4 a_Color;
11
- attribute vec3 a_Size;
12
- attribute vec3 a_Normal;
13
-
14
- uniform float u_heightfixed: 0.0; // 默认不固定
15
- uniform float u_r;
16
- uniform mat4 u_ModelMatrix;
17
-
18
- varying vec4 v_color;
19
- varying float v_lightWeight;
20
- varying float v_barLinearZ;
21
-
22
- uniform float u_opacity : 1;
23
- uniform float u_lightEnable: 1;
24
- uniform float u_opacitylinear: 0.0;
25
- uniform vec4 u_sourceColor;
26
- uniform vec4 u_targetColor;
27
- uniform float u_opacitylinear_dir: 1.0;
28
- uniform float u_linearColor: 0.0;
29
-
6
+ layout(location = 0) in vec3 a_Position;
7
+ layout(location = 1) in vec4 a_Color;
8
+ layout(location = 9) in vec3 a_Size;
9
+ layout(location = 11) in vec3 a_Extrude;
10
+ layout(location = 13) in vec3 a_Normal;
11
+
12
+ layout(std140) uniform commonUniforms {
13
+ float u_pickLight;
14
+ float u_heightfixed;
15
+ float u_r;
16
+ float u_linearColor;
17
+ vec4 u_sourceColor;
18
+ vec4 u_targetColor;
19
+ float u_opacitylinear;
20
+ float u_opacitylinear_dir;
21
+ float u_lightEnable;
22
+ };
23
+ out vec4 v_color;
24
+ out float v_lightWeight;
25
+ out float v_barLinearZ;
30
26
 
31
27
  #pragma include "projection"
32
28
  #pragma include "light"
@@ -72,7 +68,7 @@ void main() {
72
68
  }
73
69
 
74
70
 
75
- vec4 project_pos = project_position(vec4(a_Pos.xy, 0., 1.0));
71
+ vec4 project_pos = project_position(vec4(a_Extrude.xy, 0., 1.0));
76
72
 
77
73
  // u_r 控制圆柱的生长
78
74
  vec4 pos = vec4(project_pos.xy + offset.xy, offset.z * u_r, 1.0);
@@ -91,9 +87,9 @@ void main() {
91
87
  // 设置圆柱的底色
92
88
  if(u_linearColor == 1.0) { // 使用渐变颜色
93
89
  v_color = mix(u_sourceColor, u_targetColor, a_Position.z);
94
- v_color.a = v_color.a * u_opacity;
90
+ v_color.a = v_color.a * opacity;
95
91
  } else {
96
- v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * u_opacity);
92
+ v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);
97
93
  }
98
94
 
99
95
  if(u_opacitylinear > 0.0) {
@@ -101,8 +97,6 @@ void main() {
101
97
  }
102
98
 
103
99
 
104
- // gl_Position = project_common_position_to_clipspace(pos);
105
-
106
100
  gl_Position = project_common_position_to_clipspace_v2(pos);
107
101
 
108
102
  setPickingColor(a_PickingColor);
@@ -132,7 +132,9 @@ var BaseLayer = exports.default = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.
132
132
  }
133
133
  var autoRender = _this.layerSource.getSourceCfg().autoRender;
134
134
  if (autoRender) {
135
- _this.reRender();
135
+ setTimeout(function () {
136
+ _this.reRender();
137
+ }, 10);
136
138
  }
137
139
  });
138
140
  _this.name = config.name || _this.id;
@@ -952,14 +954,14 @@ var BaseLayer = exports.default = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.
952
954
  }, {
953
955
  key: "destroy",
954
956
  value: function destroy() {
955
- var _this$multiPassRender, _this$layerModel, _this$tileLayer, _this$debugService2;
957
+ var _this$layerModel, _this$multiPassRender, _this$layerModel2, _this$tileLayer, _this$debugService2;
956
958
  var refresh = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
957
959
  if (this.isDestroyed) {
958
960
  return;
959
961
  }
960
962
 
961
963
  // destroy all UBOs
962
- this.layerModel.uniformBuffers.forEach(function (buffer) {
964
+ (_this$layerModel = this.layerModel) === null || _this$layerModel === void 0 || _this$layerModel.uniformBuffers.forEach(function (buffer) {
963
965
  buffer.destroy();
964
966
  });
965
967
 
@@ -991,7 +993,7 @@ var BaseLayer = exports.default = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.
991
993
 
992
994
  this.hooks.afterDestroy.call();
993
995
  // Tip: 清除各个图层自定义的 models 资源
994
- (_this$layerModel = this.layerModel) === null || _this$layerModel === void 0 || _this$layerModel.clearModels(refresh);
996
+ (_this$layerModel2 = this.layerModel) === null || _this$layerModel2 === void 0 || _this$layerModel2.clearModels(refresh);
995
997
  (_this$tileLayer = this.tileLayer) === null || _this$tileLayer === void 0 || _this$tileLayer.destroy();
996
998
  this.models = [];
997
999
  // 清除图层日志(如果有的话:非瓦片相关)
@@ -1018,11 +1020,11 @@ var BaseLayer = exports.default = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.
1018
1020
  }, {
1019
1021
  key: "clearModels",
1020
1022
  value: function clearModels() {
1021
- var _this$layerModel2;
1023
+ var _this$layerModel3;
1022
1024
  this.models.forEach(function (model) {
1023
1025
  return model.destroy();
1024
1026
  });
1025
- (_this$layerModel2 = this.layerModel) === null || _this$layerModel2 === void 0 || _this$layerModel2.clearModels();
1027
+ (_this$layerModel3 = this.layerModel) === null || _this$layerModel3 === void 0 || _this$layerModel3.clearModels();
1026
1028
  this.models = [];
1027
1029
  }
1028
1030
  }, {
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
11
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
12
  var _initializerDefineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/initializerDefineProperty"));
@@ -19,6 +20,7 @@ var _l7Utils = require("@antv/l7-utils");
19
20
  var _blend = require("../utils/blend");
20
21
  var _stencil = require("../utils/stencil");
21
22
  var _constant = require("./constant");
23
+ var _utils = require("./utils");
22
24
  var _CommonStyleAttribute = require("./CommonStyleAttribute");
23
25
  var _dec, _class, _descriptor;
24
26
  var shaderLocationMap = {
@@ -39,6 +41,9 @@ var BaseModel = exports.default = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.
39
41
 
40
42
  // @lazyInject(TYPES.IShaderModuleService)
41
43
 
44
+ // 支持数据映射的buffer
45
+ // 不支持数据映射的buffer
46
+
42
47
  // style texture data mapping
43
48
 
44
49
  function BaseModel(layer) {
@@ -219,6 +224,8 @@ var BaseModel = exports.default = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.
219
224
  this.layer.setAnimateStartTime();
220
225
  }
221
226
  }
227
+
228
+ // 动态注入参与数据映射的uniform
222
229
  }, {
223
230
  key: "getInject",
224
231
  value: function getInject() {
@@ -293,6 +300,70 @@ var BaseModel = exports.default = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.
293
300
  value: function updateEncodeAttribute(type, flag) {
294
301
  this.encodeStyleAttribute[type] = flag;
295
302
  }
303
+ }, {
304
+ key: "initUniformsBuffer",
305
+ value: function initUniformsBuffer() {
306
+ var attrUniforms = this.getUniformsBufferInfo(this.getStyleAttribute());
307
+ var commonUniforms = this.getCommonUniformsInfo();
308
+ this.attributeUnifoms = this.rendererService.createBuffer({
309
+ data: new Float32Array((0, _utils.MultipleOfFourNumber)(attrUniforms.uniformsLength)),
310
+ // 长度需要大于等于 4
311
+ isUBO: true
312
+ });
313
+ this.commonUnifoms = this.rendererService.createBuffer({
314
+ data: new Float32Array((0, _utils.MultipleOfFourNumber)(commonUniforms.uniformsLength)),
315
+ isUBO: true
316
+ });
317
+ this.uniformBuffers = [this.attributeUnifoms, this.commonUnifoms];
318
+ }
319
+ // 获取数据映射 uniform 信息
320
+ }, {
321
+ key: "getUniformsBufferInfo",
322
+ value: function getUniformsBufferInfo(uniformsOption) {
323
+ var uniformsLength = 0;
324
+ var uniformsArray = [];
325
+ Object.values(uniformsOption).forEach(function (value) {
326
+ if (Array.isArray(value)) {
327
+ uniformsArray.push.apply(uniformsArray, (0, _toConsumableArray2.default)(value));
328
+ uniformsLength += value.length;
329
+ } else {
330
+ uniformsArray.push(value);
331
+ uniformsLength += 1;
332
+ }
333
+ });
334
+ return {
335
+ uniformsOption: uniformsOption,
336
+ uniformsLength: uniformsLength,
337
+ uniformsArray: uniformsArray
338
+ };
339
+ }
340
+ }, {
341
+ key: "getCommonUniformsInfo",
342
+ value: function getCommonUniformsInfo() {
343
+ return {
344
+ uniformsLength: 0,
345
+ uniformsArray: [],
346
+ uniformsOption: {}
347
+ };
348
+ }
349
+
350
+ // 更新支持数据映射的uniform
351
+ }, {
352
+ key: "updateStyleUnifoms",
353
+ value: function updateStyleUnifoms() {
354
+ var _this$getUniformsBuff = this.getUniformsBufferInfo(this.getStyleAttribute()),
355
+ uniformsArray = _this$getUniformsBuff.uniformsArray;
356
+ var _this$getCommonUnifor = this.getCommonUniformsInfo(),
357
+ commonUniformsArray = _this$getCommonUnifor.uniformsArray;
358
+ this.attributeUnifoms.subData({
359
+ offset: 0,
360
+ data: new Uint8Array(new Float32Array(uniformsArray).buffer)
361
+ });
362
+ this.commonUnifoms.subData({
363
+ offset: 0,
364
+ data: new Uint8Array(new Float32Array(commonUniformsArray).buffer)
365
+ });
366
+ }
296
367
  }]);
297
368
  return BaseModel;
298
369
  }(), (_descriptor = (0, _applyDecoratedDescriptor2.default)(_class.prototype, "configService", [_dec], {
@@ -20,6 +20,7 @@ var ShaderLocation = exports.ShaderLocation = /*#__PURE__*/function (ShaderLocat
20
20
  ShaderLocation[ShaderLocation["SHAPE"] = 10] = "SHAPE";
21
21
  ShaderLocation[ShaderLocation["EXTRUDE"] = 11] = "EXTRUDE";
22
22
  ShaderLocation[ShaderLocation["MAX"] = 12] = "MAX";
23
+ ShaderLocation[ShaderLocation["NORMAL"] = 13] = "NORMAL";
23
24
  return ShaderLocation;
24
25
  }({});
25
26
  function getCommonStyleAttributeOptions(name) {
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MultipleOfFourNumber = MultipleOfFourNumber;
7
+ exports.formatUniformsOption2Std140 = formatUniformsOption2Std140;
8
+ function formatUniformsOption2Std140(uniformsOption) {
9
+ var std140_str = '';
10
+ Object.keys(uniformsOption).forEach(function (key) {
11
+ var value = uniformsOption[key];
12
+ if (Array.isArray(value)) {
13
+ std140_str += "vec".concat(value.length, " ").concat(key, ";\n");
14
+ } else {
15
+ std140_str += "flot ".concat(key, ";\n");
16
+ }
17
+ });
18
+ return std140_str;
19
+ }
20
+ function MultipleOfFourNumber(num) {
21
+ return Math.ceil(num / 4) * 4;
22
+ }
@@ -153,25 +153,29 @@ var GreatCircleModel = exports.default = /*#__PURE__*/function (_BaseModel) {
153
153
  key: "buildModels",
154
154
  value: function () {
155
155
  var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
156
- var model;
156
+ var _ref3, _ref3$segmentNumber, segmentNumber, model;
157
157
  return _regenerator.default.wrap(function _callee2$(_context2) {
158
158
  while (1) switch (_context2.prev = _context2.next) {
159
159
  case 0:
160
- _context2.next = 2;
160
+ _ref3 = this.layer.getLayerConfig(), _ref3$segmentNumber = _ref3.segmentNumber, segmentNumber = _ref3$segmentNumber === void 0 ? 30 : _ref3$segmentNumber;
161
+ _context2.next = 3;
161
162
  return this.layer.buildLayerModel({
162
163
  moduleName: 'lineGreatCircle',
163
164
  vertexShader: line_arc2d_vert,
164
165
  fragmentShader: line_arc_frag,
165
166
  triangulation: _triangulation.LineArcTriangulation,
167
+ styleOption: {
168
+ segmentNumber: segmentNumber
169
+ },
166
170
  inject: this.getInject(),
167
171
  depth: {
168
172
  enable: false
169
173
  }
170
174
  });
171
- case 2:
175
+ case 3:
172
176
  model = _context2.sent;
173
177
  return _context2.abrupt("return", [model]);
174
- case 4:
178
+ case 5:
175
179
  case "end":
176
180
  return _context2.stop();
177
181
  }
@@ -238,12 +242,12 @@ var GreatCircleModel = exports.default = /*#__PURE__*/function (_BaseModel) {
238
242
  var iconMap = _this2.iconService.getIconMap();
239
243
  var texture = feature.texture;
240
244
  // console.log('icon feature', feature)
241
- var _ref3 = iconMap[texture] || {
245
+ var _ref4 = iconMap[texture] || {
242
246
  x: 0,
243
247
  y: 0
244
248
  },
245
- x = _ref3.x,
246
- y = _ref3.y;
249
+ x = _ref4.x,
250
+ y = _ref4.y;
247
251
  return [x, y];
248
252
  }
249
253
  }
@@ -22,10 +22,9 @@ var _triangulation = require("../../core/triangulation");
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
24
  /* babel-plugin-inline-import '../shaders/wall/wall_frag.glsl' */
25
- var line_frag = "#define Animate 0.0\n#define LineTexture 1.0\n\n// line texture\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_opacity : 1.0;\nuniform float u_textureBlend;\nuniform float u_iconStepCount;\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n\nvarying vec2 v_iconMapUV;\nvarying float v_blur;\nvarying float v_radio;\nvarying vec4 v_color;\nvarying vec4 v_dataset;\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = u_opacity;\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = v_dataset.r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n float v = v_dataset.a;\n\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, v);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n if(u_animate.x == Animate) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_animate.z)* (1.0/ u_animate.z) + animateSpeed);\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n\n if(u_line_texture == LineTexture) { // while load texture\n float aDistance = v_dataset.g; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n float d_texPixelLen = v_dataset.b; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen - animateSpeed);\n float v = v_dataset.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // \u8BA1\u7B97\u7EB9\u7406\u95F4\u9694 start\n float flag = 0.0;\n if(u > 1.0/u_iconStepCount) {\n flag = 1.0;\n }\n u = fract(u*u_iconStepCount);\n // \u8BA1\u7B97\u7EB9\u7406\u95F4\u9694 end\n\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture2D(u_texture, uv);\n\n // Tip: \u5224\u65AD\u7EB9\u7406\u95F4\u9694\n if(flag > 0.0) {\n pattern = vec4(0.0);\n }\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor = filterColor(gl_FragColor + pattern);\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = filterColor(pattern);\n }\n }\n \n\n // blur - AA\n if(v < v_blur) {\n gl_FragColor.a = mix(0.0, gl_FragColor.a, v/v_blur);\n } else if(v > 1.0 - v_blur) {\n gl_FragColor.a = mix(gl_FragColor.a, 0.0, (v - (1.0 - v_blur))/v_blur);\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
25
+ var line_frag = "#define Animate 0.0\n#define LineTexture 1.0\n\n// line texture\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_textureBlend;\nuniform float u_iconStepCount;\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n\nvarying vec2 v_iconMapUV;\nvarying float v_blur;\nvarying float v_radio;\nvarying vec4 v_color;\nvarying vec4 v_dataset;\n\n#pragma include \"picking\"\n\nvoid main() {\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = v_dataset.r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n float v = v_dataset.a;\n\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, v);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n gl_FragColor.a *= v_color.a; // \u5168\u5C40\u900F\u660E\u5EA6\n if(u_animate.x == Animate) {\n animateSpeed = u_time / u_animate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_animate.z)* (1.0/ u_animate.z) + animateSpeed);\n alpha = (alpha + u_animate.w -1.0) / u_animate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n\n if(u_line_texture == LineTexture) { // while load texture\n float aDistance = v_dataset.g; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n float d_texPixelLen = v_dataset.b; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen - animateSpeed);\n float v = v_dataset.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // \u8BA1\u7B97\u7EB9\u7406\u95F4\u9694 start\n float flag = 0.0;\n if(u > 1.0/u_iconStepCount) {\n flag = 1.0;\n }\n u = fract(u*u_iconStepCount);\n // \u8BA1\u7B97\u7EB9\u7406\u95F4\u9694 end\n\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture2D(u_texture, uv);\n\n // Tip: \u5224\u65AD\u7EB9\u7406\u95F4\u9694\n if(flag > 0.0) {\n pattern = vec4(0.0);\n }\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor = filterColor(gl_FragColor + pattern);\n } else { // replace\n pattern.a *= v_color.a;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = filterColor(pattern);\n }\n }\n \n\n // blur - AA\n if(v < v_blur) {\n gl_FragColor.a = mix(0.0, gl_FragColor.a, v/v_blur);\n } else if(v > 1.0 - v_blur) {\n gl_FragColor.a = mix(gl_FragColor.a, 0.0, (v - (1.0 - v_blur))/v_blur);\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
26
26
  /* babel-plugin-inline-import '../shaders/wall/wall_vert.glsl' */
27
- var line_vert = "#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\nattribute vec2 a_iconMapUV;\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\n\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\nuniform float u_icon_step: 100;\nuniform float u_heightfixed;\nuniform float u_linearColor: 0;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nvarying vec2 v_iconMapUV;\nvarying vec4 v_color;\nvarying float v_blur;\nvarying float v_radio;\nvarying vec4 v_dataset;\n\nvoid main() {\n\n\n float d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n\n v_iconMapUV = a_iconMapUV;\n if(u_heightfixed < 1.0) { // \u9AD8\u5EA6\u968F zoom \u8C03\u6574\n d_texPixelLen = project_pixel(u_icon_step);\n } else {\n d_texPixelLen = u_icon_step;\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n if(u_animate.x == Animate || u_linearColor == 1.0) {\n d_distance_ratio = a_Distance / a_Total_Distance;\n }\n\n float miter = (a_Miter + 1.0)/2.0;\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n v_dataset[0] = d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n v_dataset[1] = a_Distance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n v_dataset[2] = d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n v_dataset[3] = miter; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C 0 - 1\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n float originSize = a_Size.x; // \u56FA\u5B9A\u9AD8\u5EA6\n if(u_heightfixed < 1.0) { // \u9AD8\u5EA6\u968F zoom \u8C03\u6574\n originSize = project_float_pixel(a_Size.x);\n }\n\n float wallHeight = originSize * miter;\n float lightWeight = calc_lighting(vec4(project_pos.xy, wallHeight, 1.0));\n\n v_blur = min(project_float_pixel(2.0) / originSize, 0.05);\n v_color = vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy, wallHeight, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, wallHeight, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
28
- var isNumber = _l7Utils.lodashUtil.isNumber;
27
+ var line_vert = "#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\nattribute vec2 a_iconMapUV;\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\n\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\nuniform float u_icon_step: 100;\nuniform float u_heightfixed;\nuniform float u_linearColor: 0;\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nvarying vec2 v_iconMapUV;\nvarying vec4 v_color;\nvarying float v_blur;\nvarying float v_radio;\nvarying vec4 v_dataset;\n\nvoid main() {\n\n\n float d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n\n v_iconMapUV = a_iconMapUV;\n if(u_heightfixed < 1.0) { // \u9AD8\u5EA6\u968F zoom \u8C03\u6574\n d_texPixelLen = project_pixel(u_icon_step);\n } else {\n d_texPixelLen = u_icon_step;\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n if(u_animate.x == Animate || u_linearColor == 1.0) {\n d_distance_ratio = a_Distance / a_Total_Distance;\n }\n\n float miter = (a_Miter + 1.0)/2.0;\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n v_dataset[0] = d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n v_dataset[1] = a_Distance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n v_dataset[2] = d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n v_dataset[3] = miter; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C 0 - 1\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n float originSize = a_Size.x; // \u56FA\u5B9A\u9AD8\u5EA6\n if(u_heightfixed < 1.0) { \n originSize = project_float_meter(a_Size.x); // \u9AD8\u5EA6\u968F zoom \u8C03\u6574\n }\n\n\n float wallHeight = originSize * miter;\n float lightWeight = calc_lighting(vec4(project_pos.xy, wallHeight, 1.0));\n\n v_blur = min(project_float_pixel(2.0) / originSize, 0.05);\n v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy, wallHeight, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, wallHeight, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
29
28
  var LineWallModel = exports.default = /*#__PURE__*/function (_BaseModel) {
30
29
  (0, _inherits2.default)(LineWallModel, _BaseModel);
31
30
  var _super = _createSuper(LineWallModel);
@@ -8,7 +8,6 @@ uniform vec2 u_textSize;
8
8
  uniform float u_linearColor: 0;
9
9
  uniform vec4 u_sourceColor;
10
10
  uniform vec4 u_targetColor;
11
- uniform float u_opacity : 1.0;
12
11
  uniform float u_textureBlend;
13
12
  uniform float u_iconStepCount;
14
13
  uniform float u_time;
@@ -23,7 +22,6 @@ varying vec4 v_dataset;
23
22
  #pragma include "picking"
24
23
 
25
24
  void main() {
26
- float opacity = u_opacity;
27
25
  float animateSpeed = 0.0; // 运动速度
28
26
  float d_distance_ratio = v_dataset.r; // 当前点位距离占线总长的比例
29
27
  float v = v_dataset.a;
@@ -34,7 +32,7 @@ void main() {
34
32
  gl_FragColor = v_color;
35
33
  }
36
34
 
37
- gl_FragColor.a *= opacity; // 全局透明度
35
+ gl_FragColor.a *= v_color.a; // 全局透明度
38
36
  if(u_animate.x == Animate) {
39
37
  animateSpeed = u_time / u_animate.y;
40
38
  float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_animate.z)* (1.0/ u_animate.z) + animateSpeed);
@@ -69,7 +67,7 @@ void main() {
69
67
  pattern.a = 0.0;
70
68
  gl_FragColor = filterColor(gl_FragColor + pattern);
71
69
  } else { // replace
72
- pattern.a *= opacity;
70
+ pattern.a *= v_color.a;
73
71
  if(gl_FragColor.a <= 0.0) {
74
72
  pattern.a = 0.0;
75
73
  }
@@ -57,15 +57,16 @@ void main() {
57
57
  vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));
58
58
 
59
59
  float originSize = a_Size.x; // 固定高度
60
- if(u_heightfixed < 1.0) { // 高度随 zoom 调整
61
- originSize = project_float_pixel(a_Size.x);
60
+ if(u_heightfixed < 1.0) {
61
+ originSize = project_float_meter(a_Size.x); // 高度随 zoom 调整
62
62
  }
63
63
 
64
+
64
65
  float wallHeight = originSize * miter;
65
66
  float lightWeight = calc_lighting(vec4(project_pos.xy, wallHeight, 1.0));
66
67
 
67
68
  v_blur = min(project_float_pixel(2.0) / originSize, 0.05);
68
- v_color = vec4(a_Color.rgb * lightWeight, a_Color.w);
69
+ v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * opacity);
69
70
 
70
71
  if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
71
72
  gl_Position = u_Mvp * (vec4(project_pos.xy, wallHeight, 1.0));
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
13
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
@@ -18,12 +19,13 @@ var _l7Core = require("@antv/l7-core");
18
19
  var _l7Utils = require("@antv/l7-utils");
19
20
  var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
20
21
  var _triangulation = require("../../core/triangulation");
22
+ var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
21
23
  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); }; }
22
24
  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; } }
23
25
  /* babel-plugin-inline-import '../shaders/extrude/extrude_frag.glsl' */
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";
26
+ var pointExtrudeFrag = "in vec4 v_color;\nin float v_lightWeight;\nout vec4 outputColor;\n\n\nlayout(std140) uniform commonUniforms {\n float u_pickLight;\n float u_heightfixed;\n float u_r;\n float u_linearColor;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_opacitylinear;\n float u_opacitylinear_dir;\n float u_lightEnable;\n};\n\n#pragma include \"picking\"\n\nvoid main() {\n\n outputColor = v_color;\n // \u5F00\u542F\u900F\u660E\u5EA6\u6E10\u53D8\n // picking\n if(u_pickLight > 0.0) {\n outputColor = filterColorAlpha(outputColor, v_lightWeight);\n } else {\n outputColor = filterColor(outputColor);\n }\n}\n";
25
27
  /* babel-plugin-inline-import '../shaders/extrude/extrude_vert.glsl' */
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";
28
+ var pointExtrudeVert = "#define pi 3.1415926535\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in vec3 a_Size;\nlayout(location = 11) in vec3 a_Extrude;\nlayout(location = 13) in vec3 a_Normal;\n\nlayout(std140) uniform commonUniforms {\n float u_pickLight;\n float u_heightfixed;\n float u_r;\n float u_linearColor;\n vec4 u_sourceColor;\n vec4 u_targetColor;\n float u_opacitylinear;\n float u_opacitylinear_dir;\n float u_lightEnable;\n};\nout vec4 v_color;\nout float v_lightWeight;\nout float v_barLinearZ;\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_Extrude.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 * opacity;\n } else {\n v_color = vec4(a_Color.rgb * lightWeight, a_Color.w * 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_v2(pos);\n\n setPickingColor(a_PickingColor);\n}\n";
27
29
  var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
28
30
  (0, _inherits2.default)(ExtrudeModel, _BaseModel);
29
31
  var _super = _createSuper(ExtrudeModel);
@@ -41,6 +43,14 @@ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
41
43
  (0, _createClass2.default)(ExtrudeModel, [{
42
44
  key: "getUninforms",
43
45
  value: function getUninforms() {
46
+ var commoninfo = this.getCommonUniformsInfo();
47
+ var attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
48
+ this.updateStyleUnifoms();
49
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, commoninfo.uniformsOption), attributeInfo.uniformsOption);
50
+ }
51
+ }, {
52
+ key: "getCommonUniformsInfo",
53
+ value: function getCommonUniformsInfo() {
44
54
  var _ref = this.layer.getLayerConfig(),
45
55
  _ref$animateOption = _ref.animateOption,
46
56
  animateOption = _ref$animateOption === void 0 ? {
@@ -48,8 +58,6 @@ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
48
58
  speed: 0.01,
49
59
  repeat: false
50
60
  } : _ref$animateOption,
51
- _ref$opacity = _ref.opacity,
52
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
53
61
  sourceColor = _ref.sourceColor,
54
62
  targetColor = _ref.targetColor,
55
63
  _ref$pickLight = _ref.pickLight,
@@ -88,13 +96,12 @@ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
88
96
  }
89
97
  }
90
98
  }
91
- return {
99
+ var commonOptions = {
92
100
  // 圆柱体的拾取高亮是否要计算光照
93
101
  u_pickLight: Number(pickLight),
94
102
  // 圆柱体是否固定高度
95
103
  u_heightfixed: Number(heightfixed),
96
104
  u_r: animateOption.enable && this.raiseRepeat > 0 ? this.raiseCount : 1.0,
97
- u_opacity: opacity,
98
105
  // 渐变色支持参数
99
106
  u_linearColor: useLinearColor,
100
107
  u_sourceColor: sourceColorArr,
@@ -105,6 +112,8 @@ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
105
112
  // 光照计算开关
106
113
  u_lightEnable: Number(lightEnable)
107
114
  };
115
+ var commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
116
+ return commonBufferInfo;
108
117
  }
109
118
  }, {
110
119
  key: "initModels",
@@ -136,12 +145,14 @@ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
136
145
  // GAODE1.x GAODE2.x MAPBOX
137
146
  _ref2 = this.layer.getLayerConfig(), _ref2$depth = _ref2.depth, depth = _ref2$depth === void 0 ? true : _ref2$depth, _ref2$animateOption$r = _ref2.animateOption.repeat, repeat = _ref2$animateOption$r === void 0 ? 1 : _ref2$animateOption$r;
138
147
  this.raiseRepeat = repeat;
139
- _context2.next = 4;
148
+ this.initUniformsBuffer();
149
+ _context2.next = 5;
140
150
  return this.layer.buildLayerModel({
141
151
  moduleName: 'pointExtrude',
142
152
  vertexShader: pointExtrudeVert,
143
153
  fragmentShader: pointExtrudeFrag,
144
154
  triangulation: _triangulation.PointExtrudeTriangulation,
155
+ inject: this.getInject(),
145
156
  cull: {
146
157
  enable: true,
147
158
  face: (0, _l7Utils.getCullFace)(this.mapService.version)
@@ -150,10 +161,10 @@ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
150
161
  enable: depth
151
162
  }
152
163
  });
153
- case 4:
164
+ case 5:
154
165
  model = _context2.sent;
155
166
  return _context2.abrupt("return", [model]);
156
- case 6:
167
+ case 7:
157
168
  case "end":
158
169
  return _context2.stop();
159
170
  }
@@ -173,6 +184,7 @@ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
173
184
  type: _l7Core.AttributeType.Attribute,
174
185
  descriptor: {
175
186
  name: 'a_Size',
187
+ shaderLocation: _CommonStyleAttribute.ShaderLocation.SIZE,
176
188
  buffer: {
177
189
  usage: _l7Core.gl.DYNAMIC_DRAW,
178
190
  data: [],
@@ -203,6 +215,7 @@ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
203
215
  type: _l7Core.AttributeType.Attribute,
204
216
  descriptor: {
205
217
  name: 'a_Normal',
218
+ shaderLocation: _CommonStyleAttribute.ShaderLocation.NORMAL,
206
219
  buffer: {
207
220
  // give the WebGL driver a hint that this buffer may change
208
221
  usage: _l7Core.gl.STATIC_DRAW,
@@ -216,10 +229,11 @@ var ExtrudeModel = exports.default = /*#__PURE__*/function (_BaseModel) {
216
229
  }
217
230
  });
218
231
  this.styleAttributeService.registerStyleAttribute({
219
- name: 'pos',
232
+ name: 'extrude',
220
233
  type: _l7Core.AttributeType.Attribute,
221
234
  descriptor: {
222
- name: 'a_Pos',
235
+ name: 'a_Extrude',
236
+ shaderLocation: _CommonStyleAttribute.ShaderLocation.EXTRUDE,
223
237
  buffer: {
224
238
  // give the WebGL driver a hint that this buffer may change
225
239
  usage: _l7Core.gl.DYNAMIC_DRAW,
@@ -67,10 +67,6 @@ var ImageModel = exports.default = /*#__PURE__*/function (_BaseModel) {
67
67
  key: "getUninforms",
68
68
  value: function getUninforms() {
69
69
  var _ref = this.layer.getLayerConfig(),
70
- _ref$opacity = _ref.opacity,
71
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
72
- _ref$offsets = _ref.offsets,
73
- offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets,
74
70
  _ref$raisingHeight = _ref.raisingHeight,
75
71
  raisingHeight = _ref$raisingHeight === void 0 ? 0 : _ref$raisingHeight,
76
72
  _ref$heightfixed = _ref.heightfixed,
@@ -1,18 +1,30 @@
1
- varying vec4 v_color;
2
- varying float v_lightWeight;
3
- uniform float u_pickLight: 0.0;
1
+ in vec4 v_color;
2
+ in float v_lightWeight;
3
+ out vec4 outputColor;
4
4
 
5
- #pragma include "picking"
6
5
 
6
+ layout(std140) uniform commonUniforms {
7
+ float u_pickLight;
8
+ float u_heightfixed;
9
+ float u_r;
10
+ float u_linearColor;
11
+ vec4 u_sourceColor;
12
+ vec4 u_targetColor;
13
+ float u_opacitylinear;
14
+ float u_opacitylinear_dir;
15
+ float u_lightEnable;
16
+ };
17
+
18
+ #pragma include "picking"
7
19
 
8
20
  void main() {
9
21
 
10
- gl_FragColor = v_color;
22
+ outputColor = v_color;
11
23
  // 开启透明度渐变
12
24
  // picking
13
25
  if(u_pickLight > 0.0) {
14
- gl_FragColor = filterColorAlpha(gl_FragColor, v_lightWeight);
26
+ outputColor = filterColorAlpha(outputColor, v_lightWeight);
15
27
  } else {
16
- gl_FragColor = filterColor(gl_FragColor);
28
+ outputColor = filterColor(outputColor);
17
29
  }
18
30
  }