@antv/l7-layers 2.18.0 → 2.18.3

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 (44) hide show
  1. package/es/core/BaseModel.d.ts +0 -20
  2. package/es/core/BaseModel.js +4 -2
  3. package/es/core/CommonStyleAttribute.js +20 -0
  4. package/es/core/interface.d.ts +1 -0
  5. package/es/plugins/FeatureScalePlugin.js +2 -1
  6. package/es/point/index.js +5 -3
  7. package/es/point/models/{simplePoint.js → billboard_point.js} +2 -2
  8. package/es/point/models/fill.js +1 -1
  9. package/es/point/models/fillmage.js +8 -37
  10. package/es/point/models/image.js +7 -7
  11. package/es/point/models/index.js +1 -1
  12. package/es/point/models/normal.js +4 -4
  13. package/es/point/models/text.js +1 -19
  14. package/es/point/shaders/fill_vert.glsl +3 -4
  15. package/es/point/shaders/image/fillImage_frag.glsl +2 -1
  16. package/es/point/shaders/image/fillImage_vert.glsl +9 -11
  17. package/es/point/shaders/image_frag.glsl +2 -4
  18. package/es/point/shaders/image_vert.glsl +3 -4
  19. package/es/point/shaders/normal_vert.glsl +1 -2
  20. package/es/point/shaders/text_vert.glsl +4 -6
  21. package/lib/core/BaseModel.js +4 -2
  22. package/lib/core/CommonStyleAttribute.js +20 -0
  23. package/lib/plugins/FeatureScalePlugin.js +2 -1
  24. package/lib/point/index.js +5 -3
  25. package/lib/point/models/{simplePoint.js → billboard_point.js} +2 -2
  26. package/lib/point/models/fill.js +1 -1
  27. package/lib/point/models/fillmage.js +8 -37
  28. package/lib/point/models/image.js +7 -7
  29. package/lib/point/models/index.js +2 -2
  30. package/lib/point/models/normal.js +4 -4
  31. package/lib/point/models/text.js +1 -19
  32. package/lib/point/shaders/fill_vert.glsl +3 -4
  33. package/lib/point/shaders/image/fillImage_frag.glsl +2 -1
  34. package/lib/point/shaders/image/fillImage_vert.glsl +9 -11
  35. package/lib/point/shaders/image_frag.glsl +2 -4
  36. package/lib/point/shaders/image_vert.glsl +3 -4
  37. package/lib/point/shaders/normal_vert.glsl +1 -2
  38. package/lib/point/shaders/text_vert.glsl +4 -6
  39. package/package.json +7 -7
  40. /package/es/point/models/{simplePoint.d.ts → billboard_point.d.ts} +0 -0
  41. /package/es/point/shaders/{simplePoint_frag.glsl → billboard_point_frag.glsl} +0 -0
  42. /package/es/point/shaders/{simplePoint_vert.glsl → billboard_point_vert.glsl} +0 -0
  43. /package/lib/point/shaders/{simplePoint_frag.glsl → billboard_point_frag.glsl} +0 -0
  44. /package/lib/point/shaders/{simplePoint_vert.glsl → billboard_point_vert.glsl} +0 -0
@@ -19,26 +19,6 @@ export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerMod
19
19
  protected layer: ILayer;
20
20
  protected dataTexture: ITexture2D;
21
21
  protected DATA_TEXTURE_WIDTH: number;
22
- protected rowCount: number;
23
- protected cacheStyleProperties: {
24
- thetaOffset: styleSingle | undefined;
25
- opacity: styleSingle | undefined;
26
- strokeOpacity: styleSingle | undefined;
27
- strokeWidth: styleSingle | undefined;
28
- stroke: styleColor | undefined;
29
- offsets: styleOffset | undefined;
30
- };
31
- protected cellLength: number;
32
- protected cellProperties: ICellProperty[];
33
- protected cellTypeLayout: number[];
34
- protected stylePropertiesExist: {
35
- hasThetaOffset: number;
36
- hasOpacity: number;
37
- hasStrokeOpacity: number;
38
- hasStrokeWidth: number;
39
- hasStroke: number;
40
- hasOffsets: number;
41
- };
42
22
  protected dataTextureTest: boolean;
43
23
  protected readonly configService: IGlobalConfigService;
44
24
  protected shaderModuleService: IShaderModuleService;
@@ -211,7 +211,8 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
211
211
  opacity: 'float',
212
212
  stroke: 'vec4',
213
213
  offsets: 'vec2',
214
- textOffset: 'vec2'
214
+ textOffset: 'vec2',
215
+ rotation: 'float'
215
216
  };
216
217
  this.layer.enableShaderEncodeStyles.forEach(function (key) {
217
218
  if (encodeStyleAttribute[key]) {
@@ -240,7 +241,8 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
240
241
  var defualtValue = {
241
242
  opacity: 1,
242
243
  stroke: [1, 0, 0, 1],
243
- offsets: [0, 0]
244
+ offsets: [0, 0],
245
+ rotation: 0
244
246
  };
245
247
  this.layer.enableShaderEncodeStyles.forEach(function (key) {
246
248
  if (!_this.layer.encodeStyleAttribute[key]) {
@@ -1,6 +1,26 @@
1
1
  import { AttributeType, gl } from '@antv/l7-core';
2
2
  export function getCommonStyleAttributeOptions(name) {
3
3
  switch (name) {
4
+ // // roate
5
+ case 'rotation':
6
+ return {
7
+ name: 'Rotation',
8
+ type: AttributeType.Attribute,
9
+ descriptor: {
10
+ name: 'a_Rotation',
11
+ buffer: {
12
+ usage: gl.DYNAMIC_DRAW,
13
+ data: [],
14
+ type: gl.FLOAT
15
+ },
16
+ size: 1,
17
+ update: function update(feature) {
18
+ var _feature$rotation = feature.rotation,
19
+ rotation = _feature$rotation === void 0 ? 0 : _feature$rotation;
20
+ return Array.isArray(rotation) ? [rotation[0]] : [rotation];
21
+ }
22
+ }
23
+ };
4
24
  case 'stroke':
5
25
  return {
6
26
  name: 'stroke',
@@ -73,6 +73,7 @@ export interface IPointLayerStyleOptions extends IBaseLayerStyleOptions {
73
73
  strokeWidth: number;
74
74
  stroke: string;
75
75
  blur?: number;
76
+ billboard?: boolean;
76
77
  textOffset?: [number, number];
77
78
  textAnchor?: anchorType;
78
79
  spacing?: number;
@@ -128,7 +128,8 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
128
128
  // 创建Scale
129
129
  var attributeScale = attribute.scale;
130
130
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
131
- attributeScale.names = _this2.parseFields(attribute.scale.field || []);
131
+ var fieldValue = attribute.scale.field;
132
+ attributeScale.names = _this2.parseFields(isNil(fieldValue) ? [] : fieldValue);
132
133
  var scales = [];
133
134
  // 为每个字段创建 Scale
134
135
  attributeScale.names.forEach(function (field) {
package/es/point/index.js CHANGED
@@ -25,7 +25,7 @@ var PointLayer = /*#__PURE__*/function (_BaseLayer) {
25
25
  }
26
26
  _this = _super.call.apply(_super, [this].concat(args));
27
27
  _defineProperty(_assertThisInitialized(_this), "type", 'PointLayer');
28
- _defineProperty(_assertThisInitialized(_this), "enableShaderEncodeStyles", ['opacity', 'offsets', 'stroke']);
28
+ _defineProperty(_assertThisInitialized(_this), "enableShaderEncodeStyles", ['opacity', 'offsets', 'stroke', 'rotation']);
29
29
  _defineProperty(_assertThisInitialized(_this), "enableDataEncodeStyles", ['textOffset', 'textAnchor']);
30
30
  _defineProperty(_assertThisInitialized(_this), "defaultSourceConfig", {
31
31
  data: [],
@@ -157,7 +157,9 @@ var PointLayer = /*#__PURE__*/function (_BaseLayer) {
157
157
  var layerData = this.getEncodedData();
158
158
  var _this$getLayerConfig2 = this.getLayerConfig(),
159
159
  shape2d = _this$getLayerConfig2.shape2d,
160
- shape3d = _this$getLayerConfig2.shape3d;
160
+ shape3d = _this$getLayerConfig2.shape3d,
161
+ _this$getLayerConfig3 = _this$getLayerConfig2.billboard,
162
+ billboard = _this$getLayerConfig3 === void 0 ? true : _this$getLayerConfig3;
161
163
  var iconMap = this.iconService.getIconMap();
162
164
  var item = layerData.find(function (fe) {
163
165
  return fe.hasOwnProperty('shape');
@@ -175,7 +177,7 @@ var PointLayer = /*#__PURE__*/function (_BaseLayer) {
175
177
  if (shape === 'radar') {
176
178
  return 'radar';
177
179
  }
178
- if (this.layerType === 'fillImage') {
180
+ if (this.layerType === 'fillImage' || billboard === false) {
179
181
  return 'fillImage';
180
182
  }
181
183
  if ((shape2d === null || shape2d === void 0 ? void 0 : shape2d.indexOf(shape)) !== -1) {
@@ -11,9 +11,9 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
11
11
  import { AttributeType, gl } from '@antv/l7-core';
12
12
  import BaseModel from "../../core/BaseModel";
13
13
  import { rgb2arr } from '@antv/l7-utils';
14
- /* babel-plugin-inline-import '../shaders/simplePoint_frag.glsl' */
14
+ /* babel-plugin-inline-import '../shaders/billboard_point_frag.glsl' */
15
15
  var simplePointFrag = "\nuniform float u_additive;\nuniform float u_stroke_opacity : 1;\n\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\nvarying vec4 v_color;\nvarying float v_blur;\nvarying float v_innerRadius;\n\n#pragma include \"picking\"\nvoid main() {\n vec2 center = vec2(0.5);\n\n // Tip: \u7247\u5143\u5230\u4E2D\u5FC3\u70B9\u7684\u8DDD\u79BB 0 - 1\n float fragmengTocenter = distance(center, gl_PointCoord) * 2.0;\n // Tip: \u7247\u5143\u7684\u526A\u5207\u6210\u5706\u5F62\n float circleClipOpacity = 1.0 - smoothstep(v_blur, 1.0, fragmengTocenter);\n\n\n if(v_innerRadius < 0.99) {\n // \u5F53\u5B58\u5728 stroke \u4E14 stroke > 0.01\n float blurWidth = (1.0 - v_blur)/2.0;\n vec4 stroke = vec4(u_stroke_color.rgb, u_stroke_opacity);\n if(fragmengTocenter > v_innerRadius + blurWidth) {\n gl_FragColor = stroke;\n } else if(fragmengTocenter > v_innerRadius - blurWidth){\n float mixR = (fragmengTocenter - (v_innerRadius - blurWidth)) / (blurWidth * 2.0);\n gl_FragColor = mix(v_color, stroke, mixR);\n } else {\n gl_FragColor = v_color;\n }\n } else {\n // \u5F53\u4E0D\u5B58\u5728 stroke \u6216 stroke <= 0.01\n gl_FragColor = v_color;\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n \n if(u_additive > 0.0) {\n gl_FragColor *= circleClipOpacity;\n } else {\n gl_FragColor.a *= circleClipOpacity;\n }\n\n}\n";
16
- /* babel-plugin-inline-import '../shaders/simplePoint_vert.glsl' */
16
+ /* babel-plugin-inline-import '../shaders/billboard_point_vert.glsl' */
17
17
  var simplePointVert = "\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nattribute float a_Size;\nattribute vec4 a_Color;\nvarying vec4 v_color;\n\nuniform float u_opacity : 1;\nuniform vec2 u_offsets;\nuniform float u_stroke_width;\n\nvarying float v_blur;\nvarying float v_innerRadius;\n\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"project\"\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * u_opacity);\n v_blur = 1.0 - max(2.0/a_Size, 0.05);\n v_innerRadius = max((a_Size - u_stroke_width) / a_Size, 0.0);\n \n vec2 offset = project_pixel(u_offsets);\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(a_Position.xy + offset, a_Position.z, 1.0);\n } else { // else\n vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);\n gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
18
18
  export function PointTriangulation(feature) {
19
19
  var coordinates = feature.coordinates;
@@ -18,7 +18,7 @@ var waveFillFrag = "\nuniform float u_additive;\n\n\nvarying vec4 v_data;\nvaryi
18
18
  /* babel-plugin-inline-import '../shaders/fill_frag.glsl' */
19
19
  var pointFillFrag = "uniform float u_additive;\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;\nvarying vec4 v_stroke;\n\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 lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius + u_stroke_width);\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 float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n\n if(u_stroke_width < 0.01) {\n gl_FragColor = v_color;\n } else {\n gl_FragColor = mix(v_color, v_stroke * 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 // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if(gl_FragColor.a < 0.01) {\n discard;\n } \n}\n";
20
20
  /* babel-plugin-inline-import '../shaders/fill_vert.glsl' */
21
- var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute float a_Shape;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform int u_size_unit;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nvarying vec4 v_stroke;\n\n// uniform float u_opacity : 1;\nuniform float u_stroke_width: 2;\nuniform vec3 u_blur_height_fixed: [0, 0, 0];\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\n\nvoid main() {\n // \u900F\u660E\u5EA6\u8BA1\u7B97\n v_stroke = stroke; \n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n /*\n * setPickingSize \u8BBE\u7F6E\u62FE\u53D6\u5927\u5C0F\n * u_meter2coord \u5728\u7B49\u9762\u79EF\u5927\u5C0F\u7684\u65F6\u5019\u8BBE\u7F6E\u5355\u4F4D\n */\n float newSize = setPickingSize(a_Size);\n // float newSize = setPickingSize(a_Size) * 0.00001038445708445579;\n\n\n\n // unpack color(vec2)\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n if(u_size_unit == 1) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\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_height_fixed.x);\n\n vec2 offset = (extrude.xy * (newSize + u_stroke_width) + u_offsets);\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\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 // vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n float raisingHeight = u_blur_height_fixed.y;\n\n if(u_blur_height_fixed.z < 1.0) { // false\n raisingHeight = project_pixel(u_blur_height_fixed.y);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_blur_height_fixed.y * mapboxZoomScale;\n }\n }\n \n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
21
+ 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;\nuniform mat4 u_Mvp;\nuniform int u_size_unit;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nvarying vec4 v_stroke;\nuniform float u_stroke_width: 2;\nuniform vec3 u_blur_height_fixed: [0, 0, 0];\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\n\nvoid main() {\n // \u900F\u660E\u5EA6\u8BA1\u7B97\n v_stroke = stroke; \n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n /*\n * setPickingSize \u8BBE\u7F6E\u62FE\u53D6\u5927\u5C0F\n * u_meter2coord \u5728\u7B49\u9762\u79EF\u5927\u5C0F\u7684\u65F6\u5019\u8BBE\u7F6E\u5355\u4F4D\n */\n float newSize = setPickingSize(a_Size);\n // float newSize = setPickingSize(a_Size) * 0.00001038445708445579;\n\n\n\n // unpack color(vec2)\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n if(u_size_unit == 1) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\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_height_fixed.x);\n\n vec2 offset = (extrude.xy * (newSize + u_stroke_width) + u_offsets);\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\n offset = rotate_matrix(offset,rotation);\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 // vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n float raisingHeight = u_blur_height_fixed.y;\n\n if(u_blur_height_fixed.z < 1.0) { // false\n raisingHeight = project_pixel(u_blur_height_fixed.y);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_blur_height_fixed.y * mapboxZoomScale;\n }\n }\n \n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
22
22
  var FillModel = /*#__PURE__*/function (_BaseModel) {
23
23
  _inherits(FillModel, _BaseModel);
24
24
  var _super = _createSuper(FillModel);
@@ -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";
@@ -16,9 +17,9 @@ import { SizeUnitType } from "../../core/interface";
16
17
  import { PointFillTriangulation } from "../../core/triangulation";
17
18
  // static pointLayer shader - not support animate
18
19
  /* babel-plugin-inline-import '../shaders/image/fillImage_frag.glsl' */
19
- var pointFillFrag = "uniform sampler2D u_texture;\nuniform vec2 u_textSize;\nuniform float u_opacity : 1;\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv;\n\nvoid main() {\n\n vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;\n gl_FragColor = texture2D(u_texture, pos);\n gl_FragColor.a *= u_opacity;\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
20
+ var pointFillFrag = "uniform sampler2D u_texture;\nuniform vec2 u_textSize;\nuniform float u_opacity : 1;\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv;\nvarying float v_opacity;\n\nvoid main() {\n\n vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;\n gl_FragColor = texture2D(u_texture, pos);\n gl_FragColor.a *= v_opacity;\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
20
21
  /* babel-plugin-inline-import '../shaders/image/fillImage_vert.glsl' */
21
- var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute vec2 a_Uv;\nattribute float a_Rotate;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform mat2 u_RotateMatrix;\nuniform int u_size_unit;\n\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv; // icon \u8D34\u56FE\u7684 uv \u5750\u6807\n\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\nuniform float u_opacity : 1;\nuniform vec2 u_offsets;\n\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n v_uv = (a_Extrude.xy + 1.0)/2.0;\n v_uv.y = 1.0 - v_uv.y;\n v_Iconuv = a_Uv;\n\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n float newSize = a_Size;\n if(u_size_unit == 1) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\n // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec2 offset = (rotation_matrix * u_RotateMatrix * extrude.xy * (newSize) + u_offsets);\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\n\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // height fixed\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp *vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
22
+ var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute vec2 a_Uv;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform mat2 u_RotateMatrix;\nuniform int u_size_unit;\n\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv; // icon \u8D34\u56FE\u7684 uv \u5750\u6807\n\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\nvarying float v_opacity;\n// uniform vec2 u_offsets; // shader \u6CE8\u5165\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n v_uv = (a_Extrude.xy + 1.0)/2.0;\n v_uv.y = 1.0 - v_uv.y;\n v_Iconuv = a_Uv;\n v_opacity = opacity;\n float newSize = a_Size;\n if(u_size_unit == 1) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n \n // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec2 offset = (extrude.xy * (newSize) + offsets);\n\n offset = rotate_matrix(offset,rotation);\n\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\n\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // height fixed\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp *vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
22
23
  var FillImageModel = /*#__PURE__*/function (_BaseModel) {
23
24
  _inherits(FillImageModel, _BaseModel);
24
25
  var _super = _createSuper(FillImageModel);
@@ -63,11 +64,6 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
63
64
  // 旋转的弧度
64
65
  function getUninforms() {
65
66
  var _ref = this.layer.getLayerConfig(),
66
- _ref$opacity = _ref.opacity,
67
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
68
- _ref$offsets = _ref.offsets,
69
- offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets,
70
- rotation = _ref.rotation,
71
67
  _ref$raisingHeight = _ref.raisingHeight,
72
68
  raisingHeight = _ref$raisingHeight === void 0 ? 0.0 : _ref$raisingHeight,
73
69
  _ref$heightfixed = _ref.heightfixed,
@@ -84,22 +80,14 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
84
80
  * GAODE2.x -1
85
81
  * GAODE1.x -1
86
82
  */
87
- var rotateFlag = 1;
88
- if (this.mapService.version === 'GAODE2.x' || this.mapService.version === 'GAODE1.x') {
89
- rotateFlag = -1;
90
- }
91
- // 控制图标的旋转角度(绕 Z 轴旋转)
92
- this.radian = rotation !== undefined ? rotateFlag * Math.PI * rotation / 180 : rotateFlag * Math.PI * (this.mapService.getRotation() % 360) / 180;
93
- return {
83
+
84
+ return _objectSpread({
94
85
  u_raisingHeight: Number(raisingHeight),
95
86
  u_heightfixed: Number(heightfixed),
96
87
  u_size_unit: SizeUnitType[unit],
97
- u_RotateMatrix: new Float32Array([Math.cos(this.radian), Math.sin(this.radian), -Math.sin(this.radian), Math.cos(this.radian)]),
98
88
  u_texture: this.texture,
99
- u_textSize: [1024, this.iconService.canvasHeight || 128],
100
- u_opacity: opacity,
101
- u_offsets: offsets
102
- };
89
+ u_textSize: [1024, this.iconService.canvasHeight || 128]
90
+ }, this.getStyleAttribute());
103
91
  }
104
92
  }, {
105
93
  key: "getAttribute",
@@ -144,6 +132,7 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
144
132
  depth: {
145
133
  enable: false
146
134
  },
135
+ inject: this.getInject(),
147
136
  cull: {
148
137
  enable: true,
149
138
  face: getCullFace(this.mapService.version)
@@ -176,24 +165,6 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
176
165
  key: "registerBuiltinAttributes",
177
166
  value: function registerBuiltinAttributes() {
178
167
  var _this2 = this;
179
- this.styleAttributeService.registerStyleAttribute({
180
- name: 'rotate',
181
- type: AttributeType.Attribute,
182
- descriptor: {
183
- name: 'a_Rotate',
184
- buffer: {
185
- usage: gl.DYNAMIC_DRAW,
186
- data: [],
187
- type: gl.FLOAT
188
- },
189
- size: 1,
190
- update: function update(feature) {
191
- var _feature$rotate = feature.rotate,
192
- rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
193
- return Array.isArray(rotate) ? [rotate[0]] : [rotate];
194
- }
195
- }
196
- });
197
168
  this.styleAttributeService.registerStyleAttribute({
198
169
  name: 'uv',
199
170
  type: AttributeType.Attribute,
@@ -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";
@@ -13,9 +14,9 @@ import { AttributeType, gl } from '@antv/l7-core';
13
14
  import BaseModel from "../../core/BaseModel";
14
15
  import { PointImageTriangulation } from "../../core/triangulation";
15
16
  /* babel-plugin-inline-import '../shaders/image_frag.glsl' */
16
- var pointImageFrag = "\nuniform sampler2D u_texture;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nuniform vec2 u_textSize;\nuniform float u_opacity : 1;\n\n#pragma include \"picking\"\n\nvoid main(){\n vec2 pos = v_uv / u_textSize + gl_PointCoord / u_textSize * 64.;\n vec4 textureColor;\n\n // Y = 0.299R + 0.587G + 0.114B // \u4EAE\u5EA6\u63D0\u53D6\n \n textureColor = texture2D(u_texture, pos);\n\n // Tip: \u53BB\u9664\u8FB9\u7F18\u90E8\u5206 mipmap \u5BFC\u81F4\u7684\u6DF7\u5408\u53D8\u6697\n float fragmengTocenter = distance(vec2(0.5), gl_PointCoord);\n if(fragmengTocenter >= 0.5) {\n float luma = 0.299 * textureColor.r + 0.587 * textureColor.g + 0.114 * textureColor.b;\n textureColor.a *= luma;\n }\n \n \n\n if(all(lessThan(v_color, vec4(1.0+0.00001))) && all(greaterThan(v_color, vec4(1.0-0.00001))) || v_color==vec4(1.0)){\n gl_FragColor= textureColor;\n }else {\n gl_FragColor= step(0.01, textureColor.z) * v_color;\n }\n\n gl_FragColor.a = gl_FragColor.a * u_opacity;\n \n if (gl_FragColor.a < 0.01) {\n discard;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
17
+ var pointImageFrag = "\nuniform sampler2D u_texture;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nvarying float v_opacity;\nuniform vec2 u_textSize;\n\n#pragma include \"picking\"\n\nvoid main(){\n vec2 pos = v_uv / u_textSize + gl_PointCoord / u_textSize * 64.;\n vec4 textureColor;\n\n // Y = 0.299R + 0.587G + 0.114B // \u4EAE\u5EA6\u63D0\u53D6\n \n textureColor = texture2D(u_texture, pos);\n\n // Tip: \u53BB\u9664\u8FB9\u7F18\u90E8\u5206 mipmap \u5BFC\u81F4\u7684\u6DF7\u5408\u53D8\u6697\n float fragmengTocenter = distance(vec2(0.5), gl_PointCoord);\n if(fragmengTocenter >= 0.5) {\n float luma = 0.299 * textureColor.r + 0.587 * textureColor.g + 0.114 * textureColor.b;\n textureColor.a *= luma;\n }\n \n \n\n if(all(lessThan(v_color, vec4(1.0+0.00001))) && all(greaterThan(v_color, vec4(1.0-0.00001))) || v_color==vec4(1.0)){\n gl_FragColor= textureColor;\n }else {\n gl_FragColor= step(0.01, textureColor.z) * v_color;\n }\n gl_FragColor.a *= v_opacity;\n if (gl_FragColor.a < 0.01) {\n discard;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
17
18
  /* babel-plugin-inline-import '../shaders/image_vert.glsl' */
18
- var pointImageVert = "precision highp float;\nattribute vec3 a_Position;\nattribute vec4 a_Color;\nattribute vec2 a_Uv;\nattribute float a_Size;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform vec2 u_offsets;\n\nuniform float u_opacity : 1;\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n v_color = a_Color;\n v_uv = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n \n vec2 offset = project_pixel(u_offsets);\n\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // false\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
19
+ var pointImageVert = "precision highp float;\nattribute vec3 a_Position;\nattribute vec4 a_Color;\nattribute vec2 a_Uv;\nattribute float a_Size;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nvarying float v_opacity;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n v_color = a_Color;\n v_opacity = opacity;\n v_uv = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n \n vec2 offset = project_pixel(offsets);\n\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // false\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
19
20
  var ImageModel = /*#__PURE__*/function (_BaseModel) {
20
21
  _inherits(ImageModel, _BaseModel);
21
22
  var _super = _createSuper(ImageModel);
@@ -72,14 +73,12 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
72
73
  if (this.rendererService.getDirty()) {
73
74
  this.texture.bind();
74
75
  }
75
- return {
76
+ return _objectSpread({
76
77
  u_raisingHeight: Number(raisingHeight),
77
78
  u_heightfixed: Number(heightfixed),
78
79
  u_texture: this.texture,
79
- u_textSize: [1024, this.iconService.canvasHeight || 128],
80
- u_opacity: opacity,
81
- u_offsets: offsets
82
- };
80
+ u_textSize: [1024, this.iconService.canvasHeight || 128]
81
+ }, this.getStyleAttribute());
83
82
  }
84
83
  }, {
85
84
  key: "initModels",
@@ -123,6 +122,7 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
123
122
  vertexShader: pointImageVert,
124
123
  fragmentShader: pointImageFrag,
125
124
  triangulation: PointImageTriangulation,
125
+ inject: this.getInject(),
126
126
  depth: {
127
127
  enable: false
128
128
  },
@@ -1,3 +1,4 @@
1
+ import SimplePoint from "./billboard_point";
1
2
  import EarthExtrudeModel from "./earthExtrude";
2
3
  // earth
3
4
  import EarthFillModel from "./earthFill";
@@ -7,7 +8,6 @@ import FillImageModel from "./fillmage";
7
8
  import IMageModel from "./image";
8
9
  import NormalModel from "./normal";
9
10
  import Radar from "./radar";
10
- import SimplePoint from "./simplePoint";
11
11
  import TextModel from "./text";
12
12
  var PointModels = {
13
13
  fillImage: FillImageModel,
@@ -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 _inherits from "@babel/runtime/helpers/esm/inherits";
@@ -14,7 +15,7 @@ import BaseModel from "../../core/BaseModel";
14
15
  /* babel-plugin-inline-import '../shaders/normal_frag.glsl' */
15
16
  var normalFrag = "varying vec4 v_color;\nvoid main() {\n gl_FragColor = v_color;\n}\n";
16
17
  /* babel-plugin-inline-import '../shaders/normal_vert.glsl' */
17
- var normalVert = "\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform float u_opacity : 1;\nuniform mat4 u_Mvp;\nattribute float a_Size;\nattribute vec4 a_Color;\n\nvarying vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * u_opacity);\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(a_Position.xy, a_Position.z, 1.0);\n } else {\n vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);\n gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy),project_pos.z,project_pos.w));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n}\n";
18
+ var normalVert = "\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nattribute float a_Size;\nattribute vec4 a_Color;\n\nvarying vec4 v_color;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n\nvoid main() {\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(a_Position.xy, a_Position.z, 1.0);\n } else {\n vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);\n gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy),project_pos.z,project_pos.w));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n}\n";
18
19
  var isNumber = lodashUtil.isNumber;
19
20
  export function PointTriangulation(feature) {
20
21
  var coordinates = feature.coordinates;
@@ -44,9 +45,7 @@ var NormalModel = /*#__PURE__*/function (_BaseModel) {
44
45
  var _ref = this.layer.getLayerConfig(),
45
46
  _ref$opacity = _ref.opacity,
46
47
  opacity = _ref$opacity === void 0 ? 1 : _ref$opacity;
47
- return {
48
- u_opacity: isNumber(opacity) ? opacity : 1.0
49
- };
48
+ return _objectSpread({}, this.getStyleAttribute());
50
49
  }
51
50
  }, {
52
51
  key: "initModels",
@@ -82,6 +81,7 @@ var NormalModel = /*#__PURE__*/function (_BaseModel) {
82
81
  vertexShader: normalVert,
83
82
  fragmentShader: normalFrag,
84
83
  triangulation: PointTriangulation,
84
+ inject: this.getInject(),
85
85
  depth: {
86
86
  enable: false
87
87
  },
@@ -22,7 +22,7 @@ import { getGlyphQuads, shapeText } from "../../utils/symbol-layout";
22
22
  /* babel-plugin-inline-import '../shaders/text_frag.glsl' */
23
23
  var textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\nuniform sampler2D u_sdf_map;\nuniform float u_gamma_scale : 0.5;\nuniform float u_stroke_width : 2.0;\nuniform float u_halo_blur : 0.5;\nuniform float u_DevicePixelRatio;\n\nvarying vec4 v_color;\nvarying vec4 v_stroke_color;\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying float v_fontScale;\n\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n\n // get sdf from atlas\n float dist = texture2D(u_sdf_map, v_uv).a;\n\n lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;\n\n highp float gamma_scaled = gamma * v_gamma_scale;\n\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n gl_FragColor = mix(v_color, v_stroke_color, smoothstep(0., 0.5, 1.- dist));\n\n gl_FragColor.a *= alpha;\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if (gl_FragColor.a < 0.01) {\n discard;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
24
24
  /* babel-plugin-inline-import '../shaders/text_vert.glsl' */
25
- var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute float a_Rotate;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying vec4 v_stroke_color;\nvarying float v_fontScale;\n// uniform float u_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n \n v_uv = a_tex / u_sdf_map_size;\n\n\n\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n v_stroke_color = vec4(u_stroke_color.xyz, u_stroke_color.w * opacity);\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp *(vec4(a_Position.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n }\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
25
+ var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying vec4 v_stroke_color;\nvarying float v_fontScale;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n \n v_uv = a_tex / u_sdf_map_size;\n\n\n\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n v_stroke_color = vec4(u_stroke_color.xyz, u_stroke_color.w * opacity);\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n vec2 offset = rotate_matrix(a_textOffsets,rotation);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp *(vec4(a_Position.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n }\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + offset * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
26
26
  var isEqual = lodashUtil.isEqual;
27
27
  export function TextTrianglation(feature) {
28
28
  // @ts-ignore
@@ -241,24 +241,6 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
241
241
  }, {
242
242
  key: "registerBuiltinAttributes",
243
243
  value: function registerBuiltinAttributes() {
244
- this.styleAttributeService.registerStyleAttribute({
245
- name: 'rotate',
246
- type: AttributeType.Attribute,
247
- descriptor: {
248
- name: 'a_Rotate',
249
- buffer: {
250
- usage: gl.DYNAMIC_DRAW,
251
- data: [],
252
- type: gl.FLOAT
253
- },
254
- size: 1,
255
- update: function update(feature) {
256
- var _feature$rotate = feature.rotate,
257
- rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
258
- return Array.isArray(rotate) ? [rotate[0]] : [rotate];
259
- }
260
- }
261
- });
262
244
  this.styleAttributeService.registerStyleAttribute({
263
245
  name: 'textOffsets',
264
246
  type: AttributeType.Attribute,
@@ -3,7 +3,6 @@ attribute vec3 a_Position;
3
3
  attribute vec3 a_Extrude;
4
4
  attribute float a_Size;
5
5
  attribute float a_Shape;
6
-
7
6
  uniform mat4 u_ModelMatrix;
8
7
  uniform mat4 u_Mvp;
9
8
  uniform int u_size_unit;
@@ -12,19 +11,18 @@ varying vec4 v_data;
12
11
  varying vec4 v_color;
13
12
  varying float v_radius;
14
13
  varying vec4 v_stroke;
15
-
16
- // uniform float u_opacity : 1;
17
14
  uniform float u_stroke_width: 2;
18
15
  uniform vec3 u_blur_height_fixed: [0, 0, 0];
19
16
 
20
17
 
21
18
  #pragma include "projection"
22
19
  #pragma include "picking"
20
+ #pragma include "rotation_2d"
23
21
 
24
22
 
25
23
  void main() {
26
24
  // 透明度计算
27
- v_stroke = stroke;
25
+ v_stroke = stroke;
28
26
  vec3 extrude = a_Extrude;
29
27
  float shape_type = a_Shape;
30
28
  /*
@@ -53,6 +51,7 @@ void main() {
53
51
  vec3 aPosition = a_Position;
54
52
 
55
53
  offset = project_pixel(offset);
54
+ offset = rotate_matrix(offset,rotation);
56
55
 
57
56
  // TODP: /abs(extrude.x) 是为了兼容地球模式
58
57
  v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);
@@ -6,12 +6,13 @@ uniform float u_opacity : 1;
6
6
  #pragma include "picking"
7
7
  varying vec2 v_uv; // 本身的 uv 坐标
8
8
  varying vec2 v_Iconuv;
9
+ varying float v_opacity;
9
10
 
10
11
  void main() {
11
12
 
12
13
  vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;
13
14
  gl_FragColor = texture2D(u_texture, pos);
14
- gl_FragColor.a *= u_opacity;
15
+ gl_FragColor.a *= v_opacity;
15
16
 
16
17
  gl_FragColor = filterColor(gl_FragColor);
17
18
  }
@@ -3,7 +3,6 @@ attribute vec3 a_Position;
3
3
  attribute vec3 a_Extrude;
4
4
  attribute float a_Size;
5
5
  attribute vec2 a_Uv;
6
- attribute float a_Rotate;
7
6
 
8
7
  uniform mat4 u_ModelMatrix;
9
8
  uniform mat4 u_Mvp;
@@ -15,31 +14,30 @@ varying vec2 v_Iconuv; // icon 贴图的 uv 坐标
15
14
 
16
15
  uniform float u_raisingHeight: 0.0;
17
16
  uniform float u_heightfixed: 0.0;
18
- uniform float u_opacity : 1;
19
- uniform vec2 u_offsets;
20
-
17
+ varying float v_opacity;
18
+ // uniform vec2 u_offsets; // shader 注入
21
19
 
22
20
 
23
21
  #pragma include "projection"
24
22
  #pragma include "picking"
23
+ #pragma include "rotation_2d"
25
24
 
26
25
  void main() {
27
26
  vec3 extrude = a_Extrude;
28
27
  v_uv = (a_Extrude.xy + 1.0)/2.0;
29
28
  v_uv.y = 1.0 - v_uv.y;
30
29
  v_Iconuv = a_Uv;
31
-
32
-
33
- highp float angle_sin = sin(a_Rotate);
34
- highp float angle_cos = cos(a_Rotate);
35
- mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);
30
+ v_opacity = opacity;
36
31
  float newSize = a_Size;
37
32
  if(u_size_unit == 1) {
38
33
  newSize = newSize * u_PixelsPerMeter.z;
39
34
  }
40
-
35
+
41
36
  // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);
42
- vec2 offset = (rotation_matrix * u_RotateMatrix * extrude.xy * (newSize) + u_offsets);
37
+ vec2 offset = (extrude.xy * (newSize) + offsets);
38
+
39
+ offset = rotate_matrix(offset,rotation);
40
+
43
41
  vec3 aPosition = a_Position;
44
42
 
45
43
  offset = project_pixel(offset);
@@ -2,8 +2,8 @@
2
2
  uniform sampler2D u_texture;
3
3
  varying vec4 v_color;
4
4
  varying vec2 v_uv;
5
+ varying float v_opacity;
5
6
  uniform vec2 u_textSize;
6
- uniform float u_opacity : 1;
7
7
 
8
8
  #pragma include "picking"
9
9
 
@@ -29,9 +29,7 @@ void main(){
29
29
  }else {
30
30
  gl_FragColor= step(0.01, textureColor.z) * v_color;
31
31
  }
32
-
33
- gl_FragColor.a = gl_FragColor.a * u_opacity;
34
-
32
+ gl_FragColor.a *= v_opacity;
35
33
  if (gl_FragColor.a < 0.01) {
36
34
  discard;
37
35
  }
@@ -5,15 +5,13 @@ attribute vec2 a_Uv;
5
5
  attribute float a_Size;
6
6
  varying vec4 v_color;
7
7
  varying vec2 v_uv;
8
+ varying float v_opacity;
8
9
  uniform mat4 u_ModelMatrix;
9
10
  uniform mat4 u_Mvp;
10
- uniform vec2 u_offsets;
11
11
 
12
- uniform float u_opacity : 1;
13
12
  uniform float u_raisingHeight: 0.0;
14
13
  uniform float u_heightfixed: 0.0;
15
14
 
16
-
17
15
  #pragma include "projection"
18
16
  #pragma include "picking"
19
17
 
@@ -21,10 +19,11 @@ void main() {
21
19
 
22
20
  // cal style mapping - 数据纹理映射部分的计算
23
21
  v_color = a_Color;
22
+ v_opacity = opacity;
24
23
  v_uv = a_Uv;
25
24
  vec4 project_pos = project_position(vec4(a_Position, 1.0));
26
25
 
27
- vec2 offset = project_pixel(u_offsets);
26
+ vec2 offset = project_pixel(offsets);
28
27
 
29
28
  float raisingHeight = u_raisingHeight;
30
29
  if(u_heightfixed < 1.0) { // false
@@ -1,7 +1,6 @@
1
1
 
2
2
  attribute vec3 a_Position;
3
3
  uniform mat4 u_ModelMatrix;
4
- uniform float u_opacity : 1;
5
4
  uniform mat4 u_Mvp;
6
5
  attribute float a_Size;
7
6
  attribute vec4 a_Color;
@@ -12,7 +11,7 @@ varying vec4 v_color;
12
11
  #pragma include "project"
13
12
 
14
13
  void main() {
15
- v_color = vec4(a_Color.xyz, a_Color.w * u_opacity);
14
+ v_color = vec4(a_Color.xyz, a_Color.w * opacity);
16
15
 
17
16
  if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
18
17
  gl_Position = u_Mvp * vec4(a_Position.xy, a_Position.z, 1.0);
@@ -6,7 +6,6 @@ attribute vec2 a_tex;
6
6
  attribute vec2 a_textOffsets;
7
7
  attribute vec4 a_Color;
8
8
  attribute float a_Size;
9
- attribute float a_Rotate;
10
9
 
11
10
  uniform vec2 u_sdf_map_size;
12
11
  uniform mat4 u_ModelMatrix;
@@ -18,13 +17,14 @@ varying float v_gamma_scale;
18
17
  varying vec4 v_color;
19
18
  varying vec4 v_stroke_color;
20
19
  varying float v_fontScale;
21
- // uniform float u_opacity : 1;
22
20
  uniform float u_stroke_width : 2;
23
21
  uniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];
24
22
 
25
23
 
24
+
26
25
  #pragma include "projection"
27
26
  #pragma include "picking"
27
+ #pragma include "rotation_2d"
28
28
 
29
29
  void main() {
30
30
  // cal style mapping - 数据纹理映射部分的计算
@@ -43,9 +43,7 @@ void main() {
43
43
  vec4 project_pos = project_position(vec4(a_Position, 1.0));
44
44
  // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
45
45
 
46
- highp float angle_sin = sin(a_Rotate);
47
- highp float angle_cos = cos(a_Rotate);
48
- mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);
46
+ vec2 offset = rotate_matrix(a_textOffsets,rotation);
49
47
 
50
48
  // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);
51
49
 
@@ -63,7 +61,7 @@ void main() {
63
61
  }
64
62
 
65
63
  gl_Position = vec4(
66
- projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);
64
+ projected_position.xy / projected_position.w + offset * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);
67
65
  v_gamma_scale = gl_Position.w;
68
66
  setPickingColor(a_PickingColor);
69
67