@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.
@@ -126,7 +126,9 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
126
126
  }
127
127
  var autoRender = _this.layerSource.getSourceCfg().autoRender;
128
128
  if (autoRender) {
129
- _this.reRender();
129
+ setTimeout(function () {
130
+ _this.reRender();
131
+ }, 10);
130
132
  }
131
133
  });
132
134
  _this.name = config.name || _this.id;
@@ -946,14 +948,14 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
946
948
  }, {
947
949
  key: "destroy",
948
950
  value: function destroy() {
949
- var _this$multiPassRender, _this$layerModel, _this$tileLayer, _this$debugService2;
951
+ var _this$layerModel, _this$multiPassRender, _this$layerModel2, _this$tileLayer, _this$debugService2;
950
952
  var refresh = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
951
953
  if (this.isDestroyed) {
952
954
  return;
953
955
  }
954
956
 
955
957
  // destroy all UBOs
956
- this.layerModel.uniformBuffers.forEach(function (buffer) {
958
+ (_this$layerModel = this.layerModel) === null || _this$layerModel === void 0 || _this$layerModel.uniformBuffers.forEach(function (buffer) {
957
959
  buffer.destroy();
958
960
  });
959
961
 
@@ -985,7 +987,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
985
987
 
986
988
  this.hooks.afterDestroy.call();
987
989
  // Tip: 清除各个图层自定义的 models 资源
988
- (_this$layerModel = this.layerModel) === null || _this$layerModel === void 0 || _this$layerModel.clearModels(refresh);
990
+ (_this$layerModel2 = this.layerModel) === null || _this$layerModel2 === void 0 || _this$layerModel2.clearModels(refresh);
989
991
  (_this$tileLayer = this.tileLayer) === null || _this$tileLayer === void 0 || _this$tileLayer.destroy();
990
992
  this.models = [];
991
993
  // 清除图层日志(如果有的话:非瓦片相关)
@@ -1012,11 +1014,11 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1012
1014
  }, {
1013
1015
  key: "clearModels",
1014
1016
  value: function clearModels() {
1015
- var _this$layerModel2;
1017
+ var _this$layerModel3;
1016
1018
  this.models.forEach(function (model) {
1017
1019
  return model.destroy();
1018
1020
  });
1019
- (_this$layerModel2 = this.layerModel) === null || _this$layerModel2 === void 0 || _this$layerModel2.clearModels();
1021
+ (_this$layerModel3 = this.layerModel) === null || _this$layerModel3 === void 0 || _this$layerModel3.clearModels();
1020
1022
  this.models = [];
1021
1023
  }
1022
1024
  }, {
@@ -32,6 +32,8 @@ export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerMod
32
32
  protected cameraService: ICameraService;
33
33
  protected layerService: ILayerService;
34
34
  protected pickingService: IPickingService;
35
+ protected attributeUnifoms: IBuffer;
36
+ protected commonUnifoms: IBuffer;
35
37
  constructor(layer: ILayer);
36
38
  getBlend(): IBlendOptions;
37
39
  getStencil(option: Partial<IRenderOptions>): Partial<IStencilOptions>;
@@ -58,4 +60,22 @@ export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerMod
58
60
  };
59
61
  protected registerStyleAttribute(): void;
60
62
  updateEncodeAttribute(type: string, flag: boolean): void;
63
+ initUniformsBuffer(): void;
64
+ protected getUniformsBufferInfo(uniformsOption: {
65
+ [key: string]: any;
66
+ }): {
67
+ uniformsOption: {
68
+ [key: string]: any;
69
+ };
70
+ uniformsLength: number;
71
+ uniformsArray: number[];
72
+ };
73
+ protected getCommonUniformsInfo(): {
74
+ uniformsArray: number[];
75
+ uniformsLength: number;
76
+ uniformsOption: {
77
+ [key: string]: any;
78
+ };
79
+ };
80
+ updateStyleUnifoms(): void;
61
81
  }
@@ -1,3 +1,4 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
1
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
3
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
4
  import _initializerDefineProperty from "@babel/runtime/helpers/esm/initializerDefineProperty";
@@ -13,6 +14,7 @@ import { rgb2arr } from '@antv/l7-utils';
13
14
  import { BlendTypes } from "../utils/blend";
14
15
  import { getStencil as _getStencil, getStencilMask } from "../utils/stencil";
15
16
  import { DefaultUniformStyleType, DefaultUniformStyleValue } from "./constant";
17
+ import { MultipleOfFourNumber } from "./utils";
16
18
  import { getCommonStyleAttributeOptions, ShaderLocation } from "./CommonStyleAttribute";
17
19
  var shaderLocationMap = {
18
20
  opacity: ShaderLocation.OPACITY,
@@ -32,6 +34,9 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
32
34
 
33
35
  // @lazyInject(TYPES.IShaderModuleService)
34
36
 
37
+ // 支持数据映射的buffer
38
+ // 不支持数据映射的buffer
39
+
35
40
  // style texture data mapping
36
41
 
37
42
  function BaseModel(layer) {
@@ -212,6 +217,8 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
212
217
  this.layer.setAnimateStartTime();
213
218
  }
214
219
  }
220
+
221
+ // 动态注入参与数据映射的uniform
215
222
  }, {
216
223
  key: "getInject",
217
224
  value: function getInject() {
@@ -286,6 +293,70 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
286
293
  value: function updateEncodeAttribute(type, flag) {
287
294
  this.encodeStyleAttribute[type] = flag;
288
295
  }
296
+ }, {
297
+ key: "initUniformsBuffer",
298
+ value: function initUniformsBuffer() {
299
+ var attrUniforms = this.getUniformsBufferInfo(this.getStyleAttribute());
300
+ var commonUniforms = this.getCommonUniformsInfo();
301
+ this.attributeUnifoms = this.rendererService.createBuffer({
302
+ data: new Float32Array(MultipleOfFourNumber(attrUniforms.uniformsLength)),
303
+ // 长度需要大于等于 4
304
+ isUBO: true
305
+ });
306
+ this.commonUnifoms = this.rendererService.createBuffer({
307
+ data: new Float32Array(MultipleOfFourNumber(commonUniforms.uniformsLength)),
308
+ isUBO: true
309
+ });
310
+ this.uniformBuffers = [this.attributeUnifoms, this.commonUnifoms];
311
+ }
312
+ // 获取数据映射 uniform 信息
313
+ }, {
314
+ key: "getUniformsBufferInfo",
315
+ value: function getUniformsBufferInfo(uniformsOption) {
316
+ var uniformsLength = 0;
317
+ var uniformsArray = [];
318
+ Object.values(uniformsOption).forEach(function (value) {
319
+ if (Array.isArray(value)) {
320
+ uniformsArray.push.apply(uniformsArray, _toConsumableArray(value));
321
+ uniformsLength += value.length;
322
+ } else {
323
+ uniformsArray.push(value);
324
+ uniformsLength += 1;
325
+ }
326
+ });
327
+ return {
328
+ uniformsOption: uniformsOption,
329
+ uniformsLength: uniformsLength,
330
+ uniformsArray: uniformsArray
331
+ };
332
+ }
333
+ }, {
334
+ key: "getCommonUniformsInfo",
335
+ value: function getCommonUniformsInfo() {
336
+ return {
337
+ uniformsLength: 0,
338
+ uniformsArray: [],
339
+ uniformsOption: {}
340
+ };
341
+ }
342
+
343
+ // 更新支持数据映射的uniform
344
+ }, {
345
+ key: "updateStyleUnifoms",
346
+ value: function updateStyleUnifoms() {
347
+ var _this$getUniformsBuff = this.getUniformsBufferInfo(this.getStyleAttribute()),
348
+ uniformsArray = _this$getUniformsBuff.uniformsArray;
349
+ var _this$getCommonUnifor = this.getCommonUniformsInfo(),
350
+ commonUniformsArray = _this$getCommonUnifor.uniformsArray;
351
+ this.attributeUnifoms.subData({
352
+ offset: 0,
353
+ data: new Uint8Array(new Float32Array(uniformsArray).buffer)
354
+ });
355
+ this.commonUnifoms.subData({
356
+ offset: 0,
357
+ data: new Uint8Array(new Float32Array(commonUniformsArray).buffer)
358
+ });
359
+ }
289
360
  }]);
290
361
  return BaseModel;
291
362
  }(), (_descriptor = _applyDecoratedDescriptor(_class.prototype, "configService", [_dec], {
@@ -12,6 +12,7 @@ export declare enum ShaderLocation {
12
12
  SIZE = 9,
13
13
  SHAPE = 10,
14
14
  EXTRUDE = 11,
15
- MAX = 12
15
+ MAX = 12,
16
+ NORMAL = 13
16
17
  }
17
18
  export declare function getCommonStyleAttributeOptions(name: string): Partial<IStyleAttribute> | undefined;
@@ -13,6 +13,7 @@ export var ShaderLocation = /*#__PURE__*/function (ShaderLocation) {
13
13
  ShaderLocation[ShaderLocation["SHAPE"] = 10] = "SHAPE";
14
14
  ShaderLocation[ShaderLocation["EXTRUDE"] = 11] = "EXTRUDE";
15
15
  ShaderLocation[ShaderLocation["MAX"] = 12] = "MAX";
16
+ ShaderLocation[ShaderLocation["NORMAL"] = 13] = "NORMAL";
16
17
  return ShaderLocation;
17
18
  }({});
18
19
  export function getCommonStyleAttributeOptions(name) {
@@ -0,0 +1,4 @@
1
+ export declare function formatUniformsOption2Std140(uniformsOption: {
2
+ [key: string]: any;
3
+ }): string;
4
+ export declare function MultipleOfFourNumber(num: number): number;
@@ -0,0 +1,15 @@
1
+ export function formatUniformsOption2Std140(uniformsOption) {
2
+ var std140_str = '';
3
+ Object.keys(uniformsOption).forEach(function (key) {
4
+ var value = uniformsOption[key];
5
+ if (Array.isArray(value)) {
6
+ std140_str += "vec".concat(value.length, " ").concat(key, ";\n");
7
+ } else {
8
+ std140_str += "flot ".concat(key, ";\n");
9
+ }
10
+ });
11
+ return std140_str;
12
+ }
13
+ export function MultipleOfFourNumber(num) {
14
+ return Math.ceil(num / 4) * 4;
15
+ }
@@ -146,25 +146,29 @@ var GreatCircleModel = /*#__PURE__*/function (_BaseModel) {
146
146
  key: "buildModels",
147
147
  value: function () {
148
148
  var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
149
- var model;
149
+ var _ref3, _ref3$segmentNumber, segmentNumber, model;
150
150
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
151
151
  while (1) switch (_context2.prev = _context2.next) {
152
152
  case 0:
153
- _context2.next = 2;
153
+ _ref3 = this.layer.getLayerConfig(), _ref3$segmentNumber = _ref3.segmentNumber, segmentNumber = _ref3$segmentNumber === void 0 ? 30 : _ref3$segmentNumber;
154
+ _context2.next = 3;
154
155
  return this.layer.buildLayerModel({
155
156
  moduleName: 'lineGreatCircle',
156
157
  vertexShader: line_arc2d_vert,
157
158
  fragmentShader: line_arc_frag,
158
159
  triangulation: LineArcTriangulation,
160
+ styleOption: {
161
+ segmentNumber: segmentNumber
162
+ },
159
163
  inject: this.getInject(),
160
164
  depth: {
161
165
  enable: false
162
166
  }
163
167
  });
164
- case 2:
168
+ case 3:
165
169
  model = _context2.sent;
166
170
  return _context2.abrupt("return", [model]);
167
- case 4:
171
+ case 5:
168
172
  case "end":
169
173
  return _context2.stop();
170
174
  }
@@ -231,12 +235,12 @@ var GreatCircleModel = /*#__PURE__*/function (_BaseModel) {
231
235
  var iconMap = _this2.iconService.getIconMap();
232
236
  var texture = feature.texture;
233
237
  // console.log('icon feature', feature)
234
- var _ref3 = iconMap[texture] || {
238
+ var _ref4 = iconMap[texture] || {
235
239
  x: 0,
236
240
  y: 0
237
241
  },
238
- x = _ref3.x,
239
- y = _ref3.y;
242
+ x = _ref4.x,
243
+ y = _ref4.y;
240
244
  return [x, y];
241
245
  }
242
246
  }
@@ -11,14 +11,13 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
11
11
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12
12
  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; } }
13
13
  import { AttributeType, gl } from '@antv/l7-core';
14
- import { lodashUtil, rgb2arr } from '@antv/l7-utils';
14
+ import { rgb2arr } from '@antv/l7-utils';
15
15
  import BaseModel from "../../core/BaseModel";
16
16
  import { LineTriangulation } from "../../core/triangulation";
17
17
  /* babel-plugin-inline-import '../shaders/wall/wall_frag.glsl' */
18
- 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";
18
+ 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";
19
19
  /* babel-plugin-inline-import '../shaders/wall/wall_vert.glsl' */
20
- 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";
21
- var isNumber = lodashUtil.isNumber;
20
+ 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";
22
21
  var LineWallModel = /*#__PURE__*/function (_BaseModel) {
23
22
  _inherits(LineWallModel, _BaseModel);
24
23
  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));
@@ -4,16 +4,14 @@ export default class ExtrudeModel extends BaseModel {
4
4
  private raiseCount;
5
5
  private raiseRepeat;
6
6
  getUninforms(): {
7
- u_pickLight: number;
8
- u_heightfixed: number;
9
- u_r: number;
10
- u_opacity: number;
11
- u_linearColor: number;
12
- u_sourceColor: number[];
13
- u_targetColor: number[];
14
- u_opacitylinear: number;
15
- u_opacitylinear_dir: number;
16
- u_lightEnable: number;
7
+ [x: string]: any;
8
+ };
9
+ protected getCommonUniformsInfo(): {
10
+ uniformsArray: number[];
11
+ uniformsLength: number;
12
+ uniformsOption: {
13
+ [key: string]: any;
14
+ };
17
15
  };
18
16
  initModels(): Promise<IModel[]>;
19
17
  buildModels(): Promise<IModel[]>;
@@ -1,4 +1,5 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
5
  import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
@@ -14,9 +15,10 @@ import { calculateCentroid, getCullFace, rgb2arr } from '@antv/l7-utils';
14
15
  import BaseModel from "../../core/BaseModel";
15
16
  import { PointExtrudeTriangulation } from "../../core/triangulation";
16
17
  /* babel-plugin-inline-import '../shaders/extrude/extrude_frag.glsl' */
17
- 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";
18
+ 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";
18
19
  /* babel-plugin-inline-import '../shaders/extrude/extrude_vert.glsl' */
19
- 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";
20
+ 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";
21
+ import { ShaderLocation } from "../../core/CommonStyleAttribute";
20
22
  var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
21
23
  _inherits(ExtrudeModel, _BaseModel);
22
24
  var _super = _createSuper(ExtrudeModel);
@@ -34,6 +36,14 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
34
36
  _createClass(ExtrudeModel, [{
35
37
  key: "getUninforms",
36
38
  value: function getUninforms() {
39
+ var commoninfo = this.getCommonUniformsInfo();
40
+ var attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
41
+ this.updateStyleUnifoms();
42
+ return _objectSpread(_objectSpread({}, commoninfo.uniformsOption), attributeInfo.uniformsOption);
43
+ }
44
+ }, {
45
+ key: "getCommonUniformsInfo",
46
+ value: function getCommonUniformsInfo() {
37
47
  var _ref = this.layer.getLayerConfig(),
38
48
  _ref$animateOption = _ref.animateOption,
39
49
  animateOption = _ref$animateOption === void 0 ? {
@@ -41,8 +51,6 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
41
51
  speed: 0.01,
42
52
  repeat: false
43
53
  } : _ref$animateOption,
44
- _ref$opacity = _ref.opacity,
45
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
46
54
  sourceColor = _ref.sourceColor,
47
55
  targetColor = _ref.targetColor,
48
56
  _ref$pickLight = _ref.pickLight,
@@ -81,13 +89,12 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
81
89
  }
82
90
  }
83
91
  }
84
- return {
92
+ var commonOptions = {
85
93
  // 圆柱体的拾取高亮是否要计算光照
86
94
  u_pickLight: Number(pickLight),
87
95
  // 圆柱体是否固定高度
88
96
  u_heightfixed: Number(heightfixed),
89
97
  u_r: animateOption.enable && this.raiseRepeat > 0 ? this.raiseCount : 1.0,
90
- u_opacity: opacity,
91
98
  // 渐变色支持参数
92
99
  u_linearColor: useLinearColor,
93
100
  u_sourceColor: sourceColorArr,
@@ -98,6 +105,8 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
98
105
  // 光照计算开关
99
106
  u_lightEnable: Number(lightEnable)
100
107
  };
108
+ var commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
109
+ return commonBufferInfo;
101
110
  }
102
111
  }, {
103
112
  key: "initModels",
@@ -129,12 +138,14 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
129
138
  // GAODE1.x GAODE2.x MAPBOX
130
139
  _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;
131
140
  this.raiseRepeat = repeat;
132
- _context2.next = 4;
141
+ this.initUniformsBuffer();
142
+ _context2.next = 5;
133
143
  return this.layer.buildLayerModel({
134
144
  moduleName: 'pointExtrude',
135
145
  vertexShader: pointExtrudeVert,
136
146
  fragmentShader: pointExtrudeFrag,
137
147
  triangulation: PointExtrudeTriangulation,
148
+ inject: this.getInject(),
138
149
  cull: {
139
150
  enable: true,
140
151
  face: getCullFace(this.mapService.version)
@@ -143,10 +154,10 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
143
154
  enable: depth
144
155
  }
145
156
  });
146
- case 4:
157
+ case 5:
147
158
  model = _context2.sent;
148
159
  return _context2.abrupt("return", [model]);
149
- case 6:
160
+ case 7:
150
161
  case "end":
151
162
  return _context2.stop();
152
163
  }
@@ -166,6 +177,7 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
166
177
  type: AttributeType.Attribute,
167
178
  descriptor: {
168
179
  name: 'a_Size',
180
+ shaderLocation: ShaderLocation.SIZE,
169
181
  buffer: {
170
182
  usage: gl.DYNAMIC_DRAW,
171
183
  data: [],
@@ -196,6 +208,7 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
196
208
  type: AttributeType.Attribute,
197
209
  descriptor: {
198
210
  name: 'a_Normal',
211
+ shaderLocation: ShaderLocation.NORMAL,
199
212
  buffer: {
200
213
  // give the WebGL driver a hint that this buffer may change
201
214
  usage: gl.STATIC_DRAW,
@@ -209,10 +222,11 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
209
222
  }
210
223
  });
211
224
  this.styleAttributeService.registerStyleAttribute({
212
- name: 'pos',
225
+ name: 'extrude',
213
226
  type: AttributeType.Attribute,
214
227
  descriptor: {
215
- name: 'a_Pos',
228
+ name: 'a_Extrude',
229
+ shaderLocation: ShaderLocation.EXTRUDE,
216
230
  buffer: {
217
231
  // give the WebGL driver a hint that this buffer may change
218
232
  usage: gl.DYNAMIC_DRAW,
@@ -60,10 +60,6 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
60
60
  key: "getUninforms",
61
61
  value: function getUninforms() {
62
62
  var _ref = this.layer.getLayerConfig(),
63
- _ref$opacity = _ref.opacity,
64
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
65
- _ref$offsets = _ref.offsets,
66
- offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets,
67
63
  _ref$raisingHeight = _ref.raisingHeight,
68
64
  raisingHeight = _ref$raisingHeight === void 0 ? 0 : _ref$raisingHeight,
69
65
  _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
  }