@antv/l7-layers 2.12.2 → 2.13.0

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 (96) hide show
  1. package/es/core/BaseLayer.d.ts +1 -1
  2. package/es/core/BaseLayer.js +18 -7
  3. package/es/core/TextureService.d.ts +4 -3
  4. package/es/core/TextureService.js +32 -10
  5. package/es/core/interface.d.ts +5 -6
  6. package/es/core/interface.js +7 -0
  7. package/es/line/index.d.ts +1 -1
  8. package/es/line/models/index.d.ts +1 -1
  9. package/es/line/models/index.js +0 -2
  10. package/es/plugins/DataMappingPlugin.js +10 -7
  11. package/es/point/index.d.ts +1 -1
  12. package/es/point/models/fill.d.ts +0 -14
  13. package/es/point/models/fill.js +9 -100
  14. package/es/point/models/fillmage.d.ts +0 -5
  15. package/es/point/models/fillmage.js +15 -65
  16. package/es/point/models/index.d.ts +1 -1
  17. package/es/point/models/index.js +0 -4
  18. package/es/point/models/radar.d.ts +0 -7
  19. package/es/point/models/radar.js +13 -79
  20. package/es/point/models/text.js +1 -1
  21. package/es/point/shaders/fill_vert.glsl +9 -26
  22. package/es/point/shaders/image/fillImage_vert.glsl +8 -14
  23. package/es/point/shaders/radar/radar_vert.glsl +12 -19
  24. package/es/point/shaders/text_vert.glsl +1 -1
  25. package/es/polygon/index.js +0 -2
  26. package/es/polygon/models/index.d.ts +1 -1
  27. package/es/polygon/models/index.js +2 -4
  28. package/es/raster/models/raster.d.ts +0 -2
  29. package/es/raster/models/raster.js +6 -22
  30. package/es/raster/models/rasterTerrainRgb.js +6 -6
  31. package/es/raster/shaders/raster_2d_frag.glsl +1 -0
  32. package/es/tile/tileFactory/RasterRGBTile.js +0 -1
  33. package/es/tile/tileFactory/RasterTile.js +13 -8
  34. package/lib/core/BaseLayer.js +17 -6
  35. package/lib/core/TextureService.js +31 -9
  36. package/lib/core/interface.js +9 -1
  37. package/lib/line/models/index.js +0 -3
  38. package/lib/plugins/DataMappingPlugin.js +10 -7
  39. package/lib/point/models/fill.js +8 -98
  40. package/lib/point/models/fillmage.js +16 -67
  41. package/lib/point/models/index.js +0 -6
  42. package/lib/point/models/radar.js +13 -80
  43. package/lib/point/models/text.js +1 -1
  44. package/lib/point/shaders/fill_vert.glsl +9 -26
  45. package/lib/point/shaders/image/fillImage_vert.glsl +8 -14
  46. package/lib/point/shaders/radar/radar_vert.glsl +12 -19
  47. package/lib/point/shaders/text_vert.glsl +1 -1
  48. package/lib/polygon/index.js +0 -2
  49. package/lib/polygon/models/index.js +2 -5
  50. package/lib/raster/models/raster.js +5 -21
  51. package/lib/raster/models/rasterTerrainRgb.js +5 -5
  52. package/lib/raster/shaders/raster_2d_frag.glsl +1 -0
  53. package/lib/tile/tileFactory/RasterTile.js +14 -8
  54. package/package.json +6 -6
  55. package/es/line/models/tile.d.ts +0 -8
  56. package/es/line/models/tile.js +0 -201
  57. package/es/line/shaders/tile/line_tile_map_vert.glsl +0 -25
  58. package/es/line/shaders/tile/line_tile_vert.glsl +0 -52
  59. package/es/line/shaders/tile/simpleline_map_vert.glsl +0 -15
  60. package/es/line/shaders/tile/simpleline_vert.glsl +0 -21
  61. package/es/point/models/tile.d.ts +0 -15
  62. package/es/point/models/tile.js +0 -217
  63. package/es/point/models/tileText.d.ts +0 -52
  64. package/es/point/models/tileText.js +0 -544
  65. package/es/point/shaders/tile/fill_tile_frag.glsl +0 -76
  66. package/es/point/shaders/tile/fill_tile_vert.glsl +0 -78
  67. package/es/point/shaders/tile/text_frag.glsl +0 -33
  68. package/es/point/shaders/tile/text_map_frag.glsl +0 -31
  69. package/es/point/shaders/tile/text_map_vert.glsl +0 -38
  70. package/es/point/shaders/tile/text_vert.glsl +0 -48
  71. package/es/polygon/models/tile.d.ts +0 -12
  72. package/es/polygon/models/tile.js +0 -141
  73. package/es/polygon/shaders/tile/polygon_tile_map_vert.glsl +0 -16
  74. package/es/polygon/shaders/tile/polygon_tile_vert.glsl +0 -42
  75. package/es/raster/models/rasterTile.d.ts +0 -18
  76. package/es/raster/models/rasterTile.js +0 -180
  77. package/es/tile/tileFactory/layers/RasterDataLayer.d.ts +0 -11
  78. package/es/tile/tileFactory/layers/RasterDataLayer.js +0 -89
  79. package/lib/line/models/tile.js +0 -217
  80. package/lib/line/shaders/tile/line_tile_map_vert.glsl +0 -25
  81. package/lib/line/shaders/tile/line_tile_vert.glsl +0 -52
  82. package/lib/line/shaders/tile/simpleline_map_vert.glsl +0 -15
  83. package/lib/line/shaders/tile/simpleline_vert.glsl +0 -21
  84. package/lib/point/models/tile.js +0 -233
  85. package/lib/point/models/tileText.js +0 -560
  86. package/lib/point/shaders/tile/fill_tile_frag.glsl +0 -76
  87. package/lib/point/shaders/tile/fill_tile_vert.glsl +0 -78
  88. package/lib/point/shaders/tile/text_frag.glsl +0 -33
  89. package/lib/point/shaders/tile/text_map_frag.glsl +0 -31
  90. package/lib/point/shaders/tile/text_map_vert.glsl +0 -38
  91. package/lib/point/shaders/tile/text_vert.glsl +0 -48
  92. package/lib/polygon/models/tile.js +0 -156
  93. package/lib/polygon/shaders/tile/polygon_tile_map_vert.glsl +0 -16
  94. package/lib/polygon/shaders/tile/polygon_tile_vert.glsl +0 -42
  95. package/lib/raster/models/rasterTile.js +0 -196
  96. package/lib/tile/tileFactory/layers/RasterDataLayer.js +0 -105
@@ -1,217 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import _inherits from "@babel/runtime/helpers/esm/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
7
- import _regeneratorRuntime from "@babel/runtime/regenerator";
8
-
9
- 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); }; }
10
-
11
- 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; } }
12
-
13
- import { AttributeType, gl } from '@antv/l7-core';
14
- import { getCullFace } from '@antv/l7-utils';
15
- import BaseModel from "../../core/BaseModel";
16
- import { PointFillTriangulation } from "../../core/triangulation";
17
-
18
- /* babel-plugin-inline-import '../shaders/tile/fill_tile_frag.glsl' */
19
- var point_tile_frag = "uniform float u_additive;\n\nuniform float u_opacity : 1;\nuniform float u_stroke_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n\n\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\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 = vec4(v_color.rgb, v_color.a * u_opacity);\n } else {\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), u_stroke_color * u_stroke_opacity, color_t);\n }\n\n if(u_additive > 0.0) {\n gl_FragColor *= opacity_t;\n gl_FragColor = filterColorAlpha(gl_FragColor, gl_FragColor.a);\n } else {\n gl_FragColor.a *= opacity_t;\n gl_FragColor = filterColor(gl_FragColor);\n }\n}\n";
20
-
21
- /* babel-plugin-inline-import '../shaders/tile/fill_tile_vert.glsl' */
22
- var point_tile_vert = "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;\n\n// uniform vec2 u_tileOrigin;\n// uniform float u_coord;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\n\nuniform float u_opacity : 1;\nuniform float u_stroke_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n float newSize = setPickingSize(a_Size);\n\n // cal style mapping\n\n v_color = a_Color;\n v_radius = newSize;\n\n // anti-alias\n // float antialiased_blur = -max(u_blur, antialiasblur);\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, 0.0);\n\n vec2 offset = (extrude.xy * (newSize + u_stroke_width));\n offset = project_pixel(offset);\n\n v_data = vec4(extrude.x, extrude.y, antialiasblur,shape_type);\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n\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 }\n\n// if(u_coord > 0.0) {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, 0.0, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n }\n// } else {\n\n // vec2 pointPos = a_Position.xy;\n // vec4 world = vec4(project_mvt_offset_position(vec4(u_tileOrigin, 0.0, 1.0)).xyz, 1.0); // \u74E6\u7247\u8D77\u59CB\u70B9\u7684\u4E16\u754C\u5750\u6807\n\n // vec2 pointOffset = pointPos * pow(2.0, u_Zoom); // \u74E6\u7247\u5185\u7684\u70B9\u7684\u504F\u79FB\u5750\u6807\n \n // world.xy += offset;\n // world.xy += pointOffset;\n\n // if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // // Needs to be divided with project_uCommonUnitsPerMeter\n // world.w *= u_PixelsPerMeter.z;\n // }\n\n // gl_Position = u_ViewProjectionMatrix * world + u_ViewportCenterProjection;\n// }\n\n \n setPickingColor(a_PickingColor);\n\n\n}\n";
23
-
24
- var FillModel = /*#__PURE__*/function (_BaseModel) {
25
- _inherits(FillModel, _BaseModel);
26
-
27
- var _super = _createSuper(FillModel);
28
-
29
- function FillModel() {
30
- _classCallCheck(this, FillModel);
31
-
32
- return _super.apply(this, arguments);
33
- }
34
-
35
- _createClass(FillModel, [{
36
- key: "getUninforms",
37
- value: function getUninforms() {
38
- var _ref = this.layer.getLayerConfig(),
39
- _ref$opacity = _ref.opacity,
40
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
41
- _ref$strokeOpacity = _ref.strokeOpacity,
42
- strokeOpacity = _ref$strokeOpacity === void 0 ? 1 : _ref$strokeOpacity,
43
- _ref$strokeWidth = _ref.strokeWidth,
44
- strokeWidth = _ref$strokeWidth === void 0 ? 0 : _ref$strokeWidth,
45
- _ref$stroke = _ref.stroke,
46
- stroke = _ref$stroke === void 0 ? 'rgba(0,0,0,0)' : _ref$stroke,
47
- blend = _ref.blend;
48
-
49
- return {
50
- // u_tileOrigin: tileOrigin || [0, 0],
51
- // u_coord: coord === 'lnglat' ? 1.0 : 0.0,
52
- u_additive: blend === 'additive' ? 1.0 : 0.0,
53
- u_opacity: Number(opacity),
54
- u_stroke_opacity: Number(strokeOpacity),
55
- u_stroke_width: Number(strokeWidth),
56
- u_stroke_color: this.getStrokeColor(stroke)
57
- };
58
- }
59
- }, {
60
- key: "getAttribute",
61
- value: function getAttribute() {
62
- return this.styleAttributeService.createAttributesAndIndices(this.layer.getEncodedData(), PointFillTriangulation);
63
- }
64
- }, {
65
- key: "initModels",
66
- value: function () {
67
- var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
68
- return _regeneratorRuntime.wrap(function _callee$(_context) {
69
- while (1) {
70
- switch (_context.prev = _context.next) {
71
- case 0:
72
- _context.next = 2;
73
- return this.buildModels();
74
-
75
- case 2:
76
- return _context.abrupt("return", _context.sent);
77
-
78
- case 3:
79
- case "end":
80
- return _context.stop();
81
- }
82
- }
83
- }, _callee, this);
84
- }));
85
-
86
- function initModels() {
87
- return _initModels.apply(this, arguments);
88
- }
89
-
90
- return initModels;
91
- }()
92
- }, {
93
- key: "buildModels",
94
- value: function () {
95
- var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
96
- var _ref2, _ref2$workerEnabled, workerEnabled, usage, model;
97
-
98
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
99
- while (1) {
100
- switch (_context2.prev = _context2.next) {
101
- case 0:
102
- _ref2 = this.layer.getLayerConfig(), _ref2$workerEnabled = _ref2.workerEnabled, workerEnabled = _ref2$workerEnabled === void 0 ? false : _ref2$workerEnabled, usage = _ref2.usage;
103
- this.layer.triangulation = PointFillTriangulation;
104
- _context2.next = 4;
105
- return this.layer.buildLayerModel({
106
- moduleName: 'pointTile_' + usage,
107
- vertexShader: point_tile_vert,
108
- fragmentShader: point_tile_frag,
109
- triangulation: PointFillTriangulation,
110
- depth: {
111
- enable: false
112
- },
113
- cull: {
114
- enable: true,
115
- face: getCullFace(this.mapService.version)
116
- },
117
- blend: this.getBlend(),
118
- workerEnabled: workerEnabled,
119
- workerOptions: {
120
- modelType: 'pointTile'
121
- },
122
- pick: usage !== 'basemap'
123
- });
124
-
125
- case 4:
126
- model = _context2.sent;
127
- return _context2.abrupt("return", [model]);
128
-
129
- case 6:
130
- case "end":
131
- return _context2.stop();
132
- }
133
- }
134
- }, _callee2, this);
135
- }));
136
-
137
- function buildModels() {
138
- return _buildModels.apply(this, arguments);
139
- }
140
-
141
- return buildModels;
142
- }()
143
- }, {
144
- key: "clearModels",
145
- value: function clearModels() {}
146
- }, {
147
- key: "registerBuiltinAttributes",
148
- value: function registerBuiltinAttributes() {
149
- var _this = this;
150
-
151
- this.styleAttributeService.registerStyleAttribute({
152
- name: 'extrude',
153
- type: AttributeType.Attribute,
154
- descriptor: {
155
- name: 'a_Extrude',
156
- buffer: {
157
- // give the WebGL driver a hint that this buffer may change
158
- usage: gl.DYNAMIC_DRAW,
159
- data: [],
160
- type: gl.FLOAT
161
- },
162
- size: 3,
163
- update: function update(feature, featureIdx, vertex, attributeIdx) {
164
- var extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];
165
- var extrudeIndex = attributeIdx % 4 * 3;
166
- return [extrude[extrudeIndex], extrude[extrudeIndex + 1], extrude[extrudeIndex + 2]];
167
- }
168
- }
169
- });
170
- this.styleAttributeService.registerStyleAttribute({
171
- name: 'size',
172
- type: AttributeType.Attribute,
173
- descriptor: {
174
- name: 'a_Size',
175
- buffer: {
176
- usage: gl.DYNAMIC_DRAW,
177
- data: [],
178
- type: gl.FLOAT
179
- },
180
- size: 1,
181
- update: function update(feature) {
182
- var _feature$size = feature.size,
183
- size = _feature$size === void 0 ? 5 : _feature$size;
184
- return Array.isArray(size) ? [size[0]] : [size];
185
- }
186
- }
187
- });
188
- this.styleAttributeService.registerStyleAttribute({
189
- name: 'shape',
190
- type: AttributeType.Attribute,
191
- descriptor: {
192
- name: 'a_Shape',
193
- buffer: {
194
- // give the WebGL driver a hint that this buffer may change
195
- usage: gl.DYNAMIC_DRAW,
196
- data: [],
197
- type: gl.FLOAT
198
- },
199
- size: 1,
200
- update: function update(feature) {
201
- var _feature$shape = feature.shape,
202
- shape = _feature$shape === void 0 ? 2 : _feature$shape;
203
-
204
- var shape2d = _this.layer.getLayerConfig().shape2d;
205
-
206
- var shapeIndex = shape2d.indexOf(shape);
207
- return [shapeIndex];
208
- }
209
- }
210
- });
211
- }
212
- }]);
213
-
214
- return FillModel;
215
- }(BaseModel);
216
-
217
- export { FillModel as default };
@@ -1,52 +0,0 @@
1
- import { IEncodeFeature, IModel, IModelUniform } from '@antv/l7-core';
2
- import BaseModel from '../../core/BaseModel';
3
- import { IGlyphQuad } from '../../utils/symbol-layout';
4
- export declare function TextTriangulation(feature: IEncodeFeature): {
5
- vertices: number[];
6
- indices: number[];
7
- size: number;
8
- };
9
- export default class TextModel extends BaseModel {
10
- glyphInfo: IEncodeFeature[];
11
- glyphInfoMap: {
12
- [key: string]: {
13
- shaping: any;
14
- glyphQuads: IGlyphQuad[];
15
- centroid: number[];
16
- };
17
- };
18
- private texture;
19
- private currentZoom;
20
- private extent;
21
- private textureHeight;
22
- private textCount;
23
- private preTextStyle;
24
- getUninforms(): IModelUniform;
25
- initModels(): Promise<IModel[]>;
26
- buildModels(): Promise<IModel[]>;
27
- clearModels(): void;
28
- protected registerBuiltinAttributes(): void;
29
- private mapping;
30
- private textExtent;
31
- /**
32
- * 生成文字纹理(生成文字纹理字典)
33
- */
34
- private initTextFont;
35
- /**
36
- * 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)
37
- */
38
- private generateGlyphLayout;
39
- /**
40
- * 文字避让 depend on originCentorid
41
- */
42
- private filterGlyphs;
43
- /**
44
- * 初始化文字布局
45
- */
46
- private initGlyph;
47
- /**
48
- * 更新文字纹理
49
- */
50
- private updateTexture;
51
- private reBuildModel;
52
- }