@antv/l7-layers 2.12.1 → 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.
- package/es/core/BaseLayer.d.ts +1 -1
- package/es/core/BaseLayer.js +18 -7
- package/es/core/TextureService.d.ts +4 -3
- package/es/core/TextureService.js +32 -10
- package/es/core/interface.d.ts +5 -6
- package/es/core/interface.js +7 -0
- package/es/line/index.d.ts +1 -1
- package/es/line/models/index.d.ts +1 -1
- package/es/line/models/index.js +0 -2
- package/es/plugins/DataMappingPlugin.js +10 -7
- package/es/point/index.d.ts +1 -1
- package/es/point/models/fill.d.ts +0 -14
- package/es/point/models/fill.js +9 -100
- package/es/point/models/fillmage.d.ts +0 -5
- package/es/point/models/fillmage.js +15 -65
- package/es/point/models/index.d.ts +1 -1
- package/es/point/models/index.js +0 -4
- package/es/point/models/radar.d.ts +0 -7
- package/es/point/models/radar.js +13 -79
- package/es/point/models/text.js +1 -1
- package/es/point/shaders/fill_vert.glsl +9 -26
- package/es/point/shaders/image/fillImage_vert.glsl +8 -14
- package/es/point/shaders/radar/radar_vert.glsl +12 -19
- package/es/point/shaders/text_vert.glsl +1 -1
- package/es/polygon/index.js +0 -2
- package/es/polygon/models/index.d.ts +1 -1
- package/es/polygon/models/index.js +2 -4
- package/es/raster/models/raster.d.ts +0 -2
- package/es/raster/models/raster.js +6 -22
- package/es/raster/models/rasterTerrainRgb.js +6 -6
- package/es/raster/shaders/raster_2d_frag.glsl +1 -0
- package/es/tile/tileFactory/RasterRGBTile.js +0 -1
- package/es/tile/tileFactory/RasterTile.js +13 -8
- package/lib/core/BaseLayer.js +17 -6
- package/lib/core/TextureService.js +31 -9
- package/lib/core/interface.js +9 -1
- package/lib/line/models/index.js +0 -3
- package/lib/plugins/DataMappingPlugin.js +10 -7
- package/lib/point/models/fill.js +8 -98
- package/lib/point/models/fillmage.js +16 -67
- package/lib/point/models/index.js +0 -6
- package/lib/point/models/radar.js +13 -80
- package/lib/point/models/text.js +1 -1
- package/lib/point/shaders/fill_vert.glsl +9 -26
- package/lib/point/shaders/image/fillImage_vert.glsl +8 -14
- package/lib/point/shaders/radar/radar_vert.glsl +12 -19
- package/lib/point/shaders/text_vert.glsl +1 -1
- package/lib/polygon/index.js +0 -2
- package/lib/polygon/models/index.js +2 -5
- package/lib/raster/models/raster.js +5 -21
- package/lib/raster/models/rasterTerrainRgb.js +5 -5
- package/lib/raster/shaders/raster_2d_frag.glsl +1 -0
- package/lib/tile/tileFactory/RasterTile.js +14 -8
- package/package.json +6 -6
- package/es/line/models/tile.d.ts +0 -8
- package/es/line/models/tile.js +0 -201
- package/es/line/shaders/tile/line_tile_map_vert.glsl +0 -25
- package/es/line/shaders/tile/line_tile_vert.glsl +0 -52
- package/es/line/shaders/tile/simpleline_map_vert.glsl +0 -15
- package/es/line/shaders/tile/simpleline_vert.glsl +0 -21
- package/es/point/models/tile.d.ts +0 -15
- package/es/point/models/tile.js +0 -217
- package/es/point/models/tileText.d.ts +0 -52
- package/es/point/models/tileText.js +0 -544
- package/es/point/shaders/tile/fill_tile_frag.glsl +0 -76
- package/es/point/shaders/tile/fill_tile_vert.glsl +0 -78
- package/es/point/shaders/tile/text_frag.glsl +0 -33
- package/es/point/shaders/tile/text_map_frag.glsl +0 -31
- package/es/point/shaders/tile/text_map_vert.glsl +0 -38
- package/es/point/shaders/tile/text_vert.glsl +0 -48
- package/es/polygon/models/tile.d.ts +0 -12
- package/es/polygon/models/tile.js +0 -141
- package/es/polygon/shaders/tile/polygon_tile_map_vert.glsl +0 -16
- package/es/polygon/shaders/tile/polygon_tile_vert.glsl +0 -42
- package/es/raster/models/rasterTile.d.ts +0 -18
- package/es/raster/models/rasterTile.js +0 -180
- package/es/tile/tileFactory/layers/RasterDataLayer.d.ts +0 -11
- package/es/tile/tileFactory/layers/RasterDataLayer.js +0 -89
- package/lib/line/models/tile.js +0 -217
- package/lib/line/shaders/tile/line_tile_map_vert.glsl +0 -25
- package/lib/line/shaders/tile/line_tile_vert.glsl +0 -52
- package/lib/line/shaders/tile/simpleline_map_vert.glsl +0 -15
- package/lib/line/shaders/tile/simpleline_vert.glsl +0 -21
- package/lib/point/models/tile.js +0 -233
- package/lib/point/models/tileText.js +0 -560
- package/lib/point/shaders/tile/fill_tile_frag.glsl +0 -76
- package/lib/point/shaders/tile/fill_tile_vert.glsl +0 -78
- package/lib/point/shaders/tile/text_frag.glsl +0 -33
- package/lib/point/shaders/tile/text_map_frag.glsl +0 -31
- package/lib/point/shaders/tile/text_map_vert.glsl +0 -38
- package/lib/point/shaders/tile/text_vert.glsl +0 -48
- package/lib/polygon/models/tile.js +0 -156
- package/lib/polygon/shaders/tile/polygon_tile_map_vert.glsl +0 -16
- package/lib/polygon/shaders/tile/polygon_tile_vert.glsl +0 -42
- package/lib/raster/models/rasterTile.js +0 -196
- package/lib/tile/tileFactory/layers/RasterDataLayer.js +0 -105
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
3
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
@@ -14,7 +13,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
14
13
|
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; } }
|
|
15
14
|
|
|
16
15
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
17
|
-
import { Version } from '@antv/l7-maps';
|
|
18
16
|
import { getCullFace, getMask } from '@antv/l7-utils';
|
|
19
17
|
import { isNumber } from 'lodash';
|
|
20
18
|
import BaseModel from "../../core/BaseModel";
|
|
@@ -24,7 +22,8 @@ import { PointFillTriangulation } from "../../core/triangulation"; // static poi
|
|
|
24
22
|
var pointFillFrag = "uniform sampler2D u_texture;\nuniform vec2 u_textSize;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\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 float opacity = styleMappingMat[0][0];\n\n vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;\n gl_FragColor = texture2D(u_texture, pos);\n gl_FragColor.a *= opacity;\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
25
23
|
|
|
26
24
|
/* babel-plugin-inline-import '../shaders/image/fillImage_vert.glsl' */
|
|
27
|
-
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\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform mat2 u_RotateMatrix;\nuniform
|
|
25
|
+
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\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\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#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n\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 // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - empty - empty - empty\n 0.0, 0.0, 0.0, 0.0, // empty - empty - empty - empty\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 textrueOffsets = vec2(0.0, 0.0);\n if(hasOffsets()) {\n vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n\n vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n } else {\n textrueOffsets = u_offsets;\n }\n\n // cal style mapping\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) + textrueOffsets);\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";
|
|
26
|
+
import { SizeUnitType } from "../../core/interface";
|
|
28
27
|
|
|
29
28
|
var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
30
29
|
_inherits(FillImageModel, _BaseModel);
|
|
@@ -92,7 +91,9 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
92
91
|
_ref$raisingHeight = _ref.raisingHeight,
|
|
93
92
|
raisingHeight = _ref$raisingHeight === void 0 ? 0.0 : _ref$raisingHeight,
|
|
94
93
|
_ref$heightfixed = _ref.heightfixed,
|
|
95
|
-
heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed
|
|
94
|
+
heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed,
|
|
95
|
+
_ref$unit = _ref.unit,
|
|
96
|
+
unit = _ref$unit === void 0 ? 'pixel' : _ref$unit;
|
|
96
97
|
|
|
97
98
|
if (this.rendererService.getDirty()) {
|
|
98
99
|
this.texture.bind();
|
|
@@ -153,7 +154,7 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
153
154
|
return {
|
|
154
155
|
u_raisingHeight: Number(raisingHeight),
|
|
155
156
|
u_heightfixed: Number(heightfixed),
|
|
156
|
-
|
|
157
|
+
u_Size_Unit: SizeUnitType[unit],
|
|
157
158
|
u_RotateMatrix: new Float32Array([Math.cos(this.radian), Math.sin(this.radian), -Math.sin(this.radian), Math.cos(this.radian)]),
|
|
158
159
|
u_dataTexture: this.dataTexture,
|
|
159
160
|
// 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
|
|
@@ -173,29 +174,19 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
173
174
|
key: "initModels",
|
|
174
175
|
value: function () {
|
|
175
176
|
var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
176
|
-
var _ref2, _ref2$unit, unit, version;
|
|
177
|
-
|
|
178
177
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
179
178
|
while (1) {
|
|
180
179
|
switch (_context.prev = _context.next) {
|
|
181
180
|
case 0:
|
|
182
181
|
this.iconService.on('imageUpdate', this.updateTexture);
|
|
183
182
|
this.updateTexture();
|
|
184
|
-
|
|
185
|
-
version = this.mapService.version;
|
|
186
|
-
|
|
187
|
-
if (unit === 'meter' && version !== Version.DEFUALT && version !== Version.GLOBEL) {
|
|
188
|
-
this.isMeter = true;
|
|
189
|
-
this.calMeter2Coord();
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
_context.next = 7;
|
|
183
|
+
_context.next = 4;
|
|
193
184
|
return this.buildModels();
|
|
194
185
|
|
|
195
|
-
case
|
|
186
|
+
case 4:
|
|
196
187
|
return _context.abrupt("return", _context.sent);
|
|
197
188
|
|
|
198
|
-
case
|
|
189
|
+
case 5:
|
|
199
190
|
case "end":
|
|
200
191
|
return _context.stop();
|
|
201
192
|
}
|
|
@@ -209,58 +200,17 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
209
200
|
|
|
210
201
|
return initModels;
|
|
211
202
|
}()
|
|
212
|
-
/**
|
|
213
|
-
* 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例
|
|
214
|
-
* @returns
|
|
215
|
-
*/
|
|
216
|
-
|
|
217
|
-
}, {
|
|
218
|
-
key: "calMeter2Coord",
|
|
219
|
-
value: function calMeter2Coord() {
|
|
220
|
-
var _this$layer$getSource = _slicedToArray(this.layer.getSource().extent, 4),
|
|
221
|
-
minLng = _this$layer$getSource[0],
|
|
222
|
-
minLat = _this$layer$getSource[1],
|
|
223
|
-
maxLng = _this$layer$getSource[2],
|
|
224
|
-
maxLat = _this$layer$getSource[3];
|
|
225
|
-
|
|
226
|
-
var center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];
|
|
227
|
-
var version = this.mapService.version;
|
|
228
|
-
|
|
229
|
-
if (version === Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {
|
|
230
|
-
var coord = window.mapboxgl.MercatorCoordinate.fromLngLat({
|
|
231
|
-
lng: center[0],
|
|
232
|
-
lat: center[1]
|
|
233
|
-
}, 0);
|
|
234
|
-
var offsetInMeters = 1;
|
|
235
|
-
var offsetInMercatorCoordinateUnits = offsetInMeters * coord.meterInMercatorCoordinateUnits();
|
|
236
|
-
var westCoord = new window.mapboxgl.MercatorCoordinate(coord.x - offsetInMercatorCoordinateUnits, coord.y, coord.z);
|
|
237
|
-
var westLnglat = westCoord.toLngLat();
|
|
238
|
-
this.meter2coord = center[0] - westLnglat.lng;
|
|
239
|
-
return;
|
|
240
|
-
} // @ts-ignore
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
var m1 = this.mapService.meterToCoord(center, [minLng, minLat]); // @ts-ignore
|
|
244
|
-
|
|
245
|
-
var m2 = this.mapService.meterToCoord(center, [maxLng === minLng ? maxLng + 0.1 : maxLng, maxLat === minLat ? minLat + 0.1 : maxLat]);
|
|
246
|
-
this.meter2coord = (m1 + m2) / 2;
|
|
247
|
-
|
|
248
|
-
if (!this.meter2coord) {
|
|
249
|
-
// Tip: 兼容单个数据导致的 m1、m2 为 NaN
|
|
250
|
-
this.meter2coord = 7.70681090738883;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
203
|
}, {
|
|
254
204
|
key: "buildModels",
|
|
255
205
|
value: function () {
|
|
256
206
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
257
|
-
var
|
|
207
|
+
var _ref2, _ref2$mask, mask, _ref2$maskInside, maskInside, model;
|
|
258
208
|
|
|
259
209
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
260
210
|
while (1) {
|
|
261
211
|
switch (_context2.prev = _context2.next) {
|
|
262
212
|
case 0:
|
|
263
|
-
|
|
213
|
+
_ref2 = this.layer.getLayerConfig(), _ref2$mask = _ref2.mask, mask = _ref2$mask === void 0 ? false : _ref2$mask, _ref2$maskInside = _ref2.maskInside, maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
|
|
264
214
|
_context2.next = 3;
|
|
265
215
|
return this.layer.buildLayerModel({
|
|
266
216
|
moduleName: 'pointFillImage',
|
|
@@ -346,12 +296,12 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
346
296
|
|
|
347
297
|
var shape = feature.shape;
|
|
348
298
|
|
|
349
|
-
var
|
|
299
|
+
var _ref3 = iconMap[shape] || {
|
|
350
300
|
x: 0,
|
|
351
301
|
y: 0
|
|
352
302
|
},
|
|
353
|
-
x =
|
|
354
|
-
y =
|
|
303
|
+
x = _ref3.x,
|
|
304
|
+
y = _ref3.y;
|
|
355
305
|
|
|
356
306
|
return [x, y];
|
|
357
307
|
}
|
|
@@ -392,7 +342,7 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
392
342
|
update: function update(feature) {
|
|
393
343
|
var _feature$size = feature.size,
|
|
394
344
|
size = _feature$size === void 0 ? 5 : _feature$size;
|
|
395
|
-
return Array.isArray(size) ? [size[0]
|
|
345
|
+
return Array.isArray(size) ? [size[0]] : [size];
|
|
396
346
|
}
|
|
397
347
|
}
|
|
398
348
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type PointType = 'fillImage' | 'fill' | 'radar' | 'image' | 'normal' | 'simplePoint' | 'extrude' | 'text' | '
|
|
1
|
+
export type PointType = 'fillImage' | 'fill' | 'radar' | 'image' | 'normal' | 'simplePoint' | 'extrude' | 'text' | 'earthFill' | 'earthExtrude';
|
|
2
2
|
declare const PointModels: {
|
|
3
3
|
[key in PointType]: any;
|
|
4
4
|
};
|
package/es/point/models/index.js
CHANGED
|
@@ -9,8 +9,6 @@ import NormalModel from "./normal";
|
|
|
9
9
|
import Radar from "./radar";
|
|
10
10
|
import SimplePoint from "./simplePoint";
|
|
11
11
|
import TextModel from "./text";
|
|
12
|
-
import TileTextModel from "./tileText";
|
|
13
|
-
import TileFillModel from "./tile";
|
|
14
12
|
var PointModels = {
|
|
15
13
|
fillImage: FillImageModel,
|
|
16
14
|
fill: FillModel,
|
|
@@ -20,8 +18,6 @@ var PointModels = {
|
|
|
20
18
|
simplePoint: SimplePoint,
|
|
21
19
|
extrude: ExtrudeModel,
|
|
22
20
|
text: TextModel,
|
|
23
|
-
tile: TileFillModel,
|
|
24
|
-
tileText: TileTextModel,
|
|
25
21
|
earthFill: EarthFillModel,
|
|
26
22
|
earthExtrude: EarthExtrudeModel
|
|
27
23
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { IAnimateOption, IAttribute, IElements, IModel, IModelUniform } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class RadarModel extends BaseModel {
|
|
4
|
-
meter2coord: number;
|
|
5
|
-
private isMeter;
|
|
6
4
|
getUninforms(): IModelUniform;
|
|
7
5
|
getAnimateUniforms(): IModelUniform;
|
|
8
6
|
getAttribute(): {
|
|
@@ -12,11 +10,6 @@ export default class RadarModel extends BaseModel {
|
|
|
12
10
|
elements: IElements;
|
|
13
11
|
};
|
|
14
12
|
initModels(): Promise<IModel[]>;
|
|
15
|
-
/**
|
|
16
|
-
* 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例
|
|
17
|
-
* @returns
|
|
18
|
-
*/
|
|
19
|
-
calMeter2Coord(): void;
|
|
20
13
|
buildModels(): Promise<IModel[]>;
|
|
21
14
|
clearModels(): void;
|
|
22
15
|
protected animateOption2Array(option: Partial<IAnimateOption>): number[];
|
package/es/point/models/radar.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
3
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
6
4
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
7
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
8
6
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
9
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
10
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
11
8
|
|
|
12
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); }; }
|
|
@@ -23,8 +20,8 @@ import { PointFillTriangulation } from "../../core/triangulation";
|
|
|
23
20
|
var pointFillFrag = "\nuniform float u_additive;\nuniform float u_opacity: 1.0;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nvarying vec2 v_exteude;\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius);\n\n float outer_df = sdCircle(v_data.xy, 1.0);\n float inner_df = sdCircle(v_data.xy, r);\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n gl_FragColor = vec4(v_color.rgb, v_color.a * u_opacity);\n\n if(u_additive > 0.0) {\n gl_FragColor *= opacity_t;\n } else {\n gl_FragColor.a *= opacity_t;\n }\n\n if(gl_FragColor.a > 0.0) {\n gl_FragColor = filterColor(gl_FragColor);\n }\n\n vec2 extrude = v_exteude;\n vec2 dir = normalize(extrude);\n vec2 baseDir = vec2(1.0, 0.0);\n float pi = 3.14159265359;\n // full circle\n // float rades = dot(dir, baseDir);\n // float flag = sign(dir.y);\n // float radar_v = (flag - 1.0) * -0.5 + flag * acos(rades)/pi/2.0;\n \n // half circle\n float flag = sign(dir.y);\n float rades = dot(dir, baseDir);\n float radar_v = (flag - 1.0) * -0.5 * acos(rades)/pi;\n // simple AA\n if(radar_v > 0.99) {\n radar_v = 1.0 - (radar_v - 0.99)/0.01;\n }\n\n gl_FragColor.a *= radar_v;\n}\n";
|
|
24
21
|
|
|
25
22
|
/* babel-plugin-inline-import '../shaders/radar/radar_vert.glsl' */
|
|
26
|
-
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nuniform float u_speed: 1.0;\nuniform float u_time;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform
|
|
27
|
-
import {
|
|
23
|
+
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nuniform float u_speed: 1.0;\nuniform float u_time;\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 vec2 v_exteude;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n float newSize = setPickingSize(a_Size);\n\n float time = u_time * u_speed;\n mat2 rotateMatrix = mat2( \n cos(time), sin(time), \n -sin(time), cos(time)\n );\n v_exteude = rotateMatrix * a_Extrude.xy;\n\n // unpack color(vec2)\n v_color = a_Color;\n\n\n\n // anti-alias\n float blur = 0.0;\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, blur);\n\n if(u_Size_Unit == 1) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n // radius(16-bit)\n v_radius = newSize;\n\n vec2 offset = (extrude.xy * (newSize));\n vec3 aPosition = a_Position;\n \n // \u4E0D\u4EE5\u7C73\u4E3A\u5B9E\u9645\u5355\u4F4D\n offset = project_pixel(offset);\n \n v_data = vec4(extrude.x, extrude.y, antialiasblur, -1.0);\n\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n\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, project_pixel(setPickingOrder(0.0)), 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
24
|
+
import { SizeUnitType } from "../../core/interface";
|
|
28
25
|
|
|
29
26
|
var RadarModel = /*#__PURE__*/function (_BaseModel) {
|
|
30
27
|
_inherits(RadarModel, _BaseModel);
|
|
@@ -32,21 +29,9 @@ var RadarModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
32
29
|
var _super = _createSuper(RadarModel);
|
|
33
30
|
|
|
34
31
|
function RadarModel() {
|
|
35
|
-
var _this;
|
|
36
|
-
|
|
37
32
|
_classCallCheck(this, RadarModel);
|
|
38
33
|
|
|
39
|
-
|
|
40
|
-
args[_key] = arguments[_key];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
44
|
-
|
|
45
|
-
_defineProperty(_assertThisInitialized(_this), "meter2coord", 1);
|
|
46
|
-
|
|
47
|
-
_defineProperty(_assertThisInitialized(_this), "isMeter", false);
|
|
48
|
-
|
|
49
|
-
return _this;
|
|
34
|
+
return _super.apply(this, arguments);
|
|
50
35
|
}
|
|
51
36
|
|
|
52
37
|
_createClass(RadarModel, [{
|
|
@@ -57,10 +42,12 @@ var RadarModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
57
42
|
opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
|
|
58
43
|
blend = _ref.blend,
|
|
59
44
|
_ref$speed = _ref.speed,
|
|
60
|
-
speed = _ref$speed === void 0 ? 1 : _ref$speed
|
|
45
|
+
speed = _ref$speed === void 0 ? 1 : _ref$speed,
|
|
46
|
+
_ref$unit = _ref.unit,
|
|
47
|
+
unit = _ref$unit === void 0 ? 'pixel' : _ref$unit;
|
|
61
48
|
|
|
62
49
|
return {
|
|
63
|
-
|
|
50
|
+
u_Size_Unit: SizeUnitType[unit],
|
|
64
51
|
u_speed: speed,
|
|
65
52
|
u_additive: blend === 'additive' ? 1.0 : 0.0,
|
|
66
53
|
u_opacity: isNumber(opacity) ? opacity : 1.0
|
|
@@ -89,27 +76,17 @@ var RadarModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
89
76
|
key: "initModels",
|
|
90
77
|
value: function () {
|
|
91
78
|
var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
92
|
-
var _ref3, _ref3$unit, unit, version;
|
|
93
|
-
|
|
94
79
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
95
80
|
while (1) {
|
|
96
81
|
switch (_context.prev = _context.next) {
|
|
97
82
|
case 0:
|
|
98
|
-
|
|
99
|
-
version = this.mapService.version;
|
|
100
|
-
|
|
101
|
-
if (unit === 'meter' && version !== Version.DEFUALT && version !== Version.GLOBEL) {
|
|
102
|
-
this.isMeter = true;
|
|
103
|
-
this.calMeter2Coord();
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
_context.next = 5;
|
|
83
|
+
_context.next = 2;
|
|
107
84
|
return this.buildModels();
|
|
108
85
|
|
|
109
|
-
case
|
|
86
|
+
case 2:
|
|
110
87
|
return _context.abrupt("return", _context.sent);
|
|
111
88
|
|
|
112
|
-
case
|
|
89
|
+
case 3:
|
|
113
90
|
case "end":
|
|
114
91
|
return _context.stop();
|
|
115
92
|
}
|
|
@@ -123,58 +100,17 @@ var RadarModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
123
100
|
|
|
124
101
|
return initModels;
|
|
125
102
|
}()
|
|
126
|
-
/**
|
|
127
|
-
* 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例
|
|
128
|
-
* @returns
|
|
129
|
-
*/
|
|
130
|
-
|
|
131
|
-
}, {
|
|
132
|
-
key: "calMeter2Coord",
|
|
133
|
-
value: function calMeter2Coord() {
|
|
134
|
-
var _this$layer$getSource = _slicedToArray(this.layer.getSource().extent, 4),
|
|
135
|
-
minLng = _this$layer$getSource[0],
|
|
136
|
-
minLat = _this$layer$getSource[1],
|
|
137
|
-
maxLng = _this$layer$getSource[2],
|
|
138
|
-
maxLat = _this$layer$getSource[3];
|
|
139
|
-
|
|
140
|
-
var center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];
|
|
141
|
-
var version = this.mapService.version;
|
|
142
|
-
|
|
143
|
-
if (version === Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {
|
|
144
|
-
var coord = window.mapboxgl.MercatorCoordinate.fromLngLat({
|
|
145
|
-
lng: center[0],
|
|
146
|
-
lat: center[1]
|
|
147
|
-
}, 0);
|
|
148
|
-
var offsetInMeters = 1;
|
|
149
|
-
var offsetInMercatorCoordinateUnits = offsetInMeters * coord.meterInMercatorCoordinateUnits();
|
|
150
|
-
var westCoord = new window.mapboxgl.MercatorCoordinate(coord.x - offsetInMercatorCoordinateUnits, coord.y, coord.z);
|
|
151
|
-
var westLnglat = westCoord.toLngLat();
|
|
152
|
-
this.meter2coord = center[0] - westLnglat.lng;
|
|
153
|
-
return;
|
|
154
|
-
} // @ts-ignore
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
var m1 = this.mapService.meterToCoord(center, [minLng, minLat]); // @ts-ignore
|
|
158
|
-
|
|
159
|
-
var m2 = this.mapService.meterToCoord(center, [maxLng === minLng ? maxLng + 0.1 : maxLng, maxLat === minLat ? minLat + 0.1 : maxLat]);
|
|
160
|
-
this.meter2coord = (m1 + m2) / 2;
|
|
161
|
-
|
|
162
|
-
if (!this.meter2coord) {
|
|
163
|
-
// Tip: 兼容单个数据导致的 m1、m2 为 NaN
|
|
164
|
-
this.meter2coord = 7.70681090738883;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
103
|
}, {
|
|
168
104
|
key: "buildModels",
|
|
169
105
|
value: function () {
|
|
170
106
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
171
|
-
var
|
|
107
|
+
var _ref3, _ref3$mask, mask, _ref3$maskInside, maskInside, model;
|
|
172
108
|
|
|
173
109
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
174
110
|
while (1) {
|
|
175
111
|
switch (_context2.prev = _context2.next) {
|
|
176
112
|
case 0:
|
|
177
|
-
|
|
113
|
+
_ref3 = this.layer.getLayerConfig(), _ref3$mask = _ref3.mask, mask = _ref3$mask === void 0 ? false : _ref3$mask, _ref3$maskInside = _ref3.maskInside, maskInside = _ref3$maskInside === void 0 ? true : _ref3$maskInside;
|
|
178
114
|
_context2.next = 3;
|
|
179
115
|
return this.layer.buildLayerModel({
|
|
180
116
|
moduleName: 'pointRadar',
|
|
@@ -222,8 +158,6 @@ var RadarModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
222
158
|
}, {
|
|
223
159
|
key: "registerBuiltinAttributes",
|
|
224
160
|
value: function registerBuiltinAttributes() {
|
|
225
|
-
var _this2 = this;
|
|
226
|
-
|
|
227
161
|
this.styleAttributeService.registerStyleAttribute({
|
|
228
162
|
name: 'extrude',
|
|
229
163
|
type: AttributeType.Attribute,
|
|
@@ -259,7 +193,7 @@ var RadarModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
259
193
|
update: function update(feature) {
|
|
260
194
|
var _feature$size = feature.size,
|
|
261
195
|
size = _feature$size === void 0 ? 5 : _feature$size;
|
|
262
|
-
return Array.isArray(size) ? [size[0]
|
|
196
|
+
return Array.isArray(size) ? [size[0]] : [size];
|
|
263
197
|
}
|
|
264
198
|
}
|
|
265
199
|
});
|
package/es/point/models/text.js
CHANGED
|
@@ -31,7 +31,7 @@ import { getGlyphQuads, shapeText } from "../../utils/symbol-layout";
|
|
|
31
31
|
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;\n// uniform float u_font_size : 24.0;\nuniform float u_opacity : 1.0;\nuniform vec4 u_stroke_color : [0, 0, 0, 1];\nuniform float u_stroke_width : 2.0;\nuniform float u_halo_blur : 0.5;\nuniform float u_DevicePixelRatio;\n\nvarying vec4 v_color;\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying float v_fontScale;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n float opacity = styleMappingMat[0][0];\n float strokeWidth = styleMappingMat[0][2];\n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n // get sdf from atlas\n float dist = texture2D(u_sdf_map, v_uv).a;\n\n // float fontScale = u_font_size / FONT_SIZE;\n\n // lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n lowp float buff = (6.0 - strokeWidth / 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 // gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), vec4(u_stroke_color.rgb, u_stroke_color.a * u_opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), vec4(textrueStroke.rgb, textrueStroke.a * opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor.a= gl_FragColor.a * alpha;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
32
32
|
|
|
33
33
|
/* babel-plugin-inline-import '../shaders/text_vert.glsl' */
|
|
34
|
-
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 float v_fontScale;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\nuniform 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#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\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 styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][2] = strokeWidthAndOffset.r;\n textureOffset = strokeWidthAndOffset.g;\n\n vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);\n if(hasStroke()) {\n vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R\n textureOffset += 1.0;\n\n vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G\n textureOffset += 1.0;\n\n vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B\n textureOffset += 1.0;\n\n vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A\n textureOffset += 1.0;\n } else {\n if(u_stroke_color == vec4(0.0)) {\n styleMappingMat[1][0] = v_color.r;\n styleMappingMat[1][1] = v_color.g;\n styleMappingMat[1][2] = v_color.b;\n styleMappingMat[1][3] = v_color.a;\n } else {\n styleMappingMat[1][0] = u_stroke_color.r;\n styleMappingMat[1][1] = u_stroke_color.g;\n styleMappingMat[1][2] = u_stroke_color.b;\n styleMappingMat[1][3] = u_stroke_color.a;\n }\n }\n \n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n v_uv = a_tex / u_sdf_map_size;\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 *
|
|
34
|
+
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 float v_fontScale;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\nuniform 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#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\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 styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][2] = strokeWidthAndOffset.r;\n textureOffset = strokeWidthAndOffset.g;\n\n vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);\n if(hasStroke()) {\n vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R\n textureOffset += 1.0;\n\n vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G\n textureOffset += 1.0;\n\n vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B\n textureOffset += 1.0;\n\n vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A\n textureOffset += 1.0;\n } else {\n if(u_stroke_color == vec4(0.0)) {\n styleMappingMat[1][0] = v_color.r;\n styleMappingMat[1][1] = v_color.g;\n styleMappingMat[1][2] = v_color.b;\n styleMappingMat[1][3] = v_color.a;\n } else {\n styleMappingMat[1][0] = u_stroke_color.r;\n styleMappingMat[1][1] = u_stroke_color.g;\n styleMappingMat[1][2] = u_stroke_color.b;\n styleMappingMat[1][3] = u_stroke_color.a;\n }\n }\n \n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n v_uv = a_tex / u_sdf_map_size;\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";
|
|
35
35
|
export function TextTriangulation(feature) {
|
|
36
36
|
// @ts-ignore
|
|
37
37
|
var that = this;
|
|
@@ -8,9 +8,7 @@ varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样
|
|
|
8
8
|
|
|
9
9
|
uniform mat4 u_ModelMatrix;
|
|
10
10
|
uniform mat4 u_Mvp;
|
|
11
|
-
uniform
|
|
12
|
-
uniform float u_meteryScale;
|
|
13
|
-
uniform float u_isMeter;
|
|
11
|
+
uniform int u_Size_Unit;
|
|
14
12
|
|
|
15
13
|
varying vec4 v_data;
|
|
16
14
|
varying vec4 v_color;
|
|
@@ -42,7 +40,7 @@ void main() {
|
|
|
42
40
|
* setPickingSize 设置拾取大小
|
|
43
41
|
* u_meter2coord 在等面积大小的时候设置单位
|
|
44
42
|
*/
|
|
45
|
-
float newSize = setPickingSize(a_Size)
|
|
43
|
+
float newSize = setPickingSize(a_Size);
|
|
46
44
|
// float newSize = setPickingSize(a_Size) * 0.00001038445708445579;
|
|
47
45
|
|
|
48
46
|
// cal style mapping - 数据纹理映射部分的计算
|
|
@@ -126,9 +124,11 @@ void main() {
|
|
|
126
124
|
|
|
127
125
|
// unpack color(vec2)
|
|
128
126
|
v_color = a_Color;
|
|
127
|
+
if(u_Size_Unit == 1) {
|
|
128
|
+
newSize = newSize * u_PixelsPerMeter.z;
|
|
129
|
+
}
|
|
129
130
|
|
|
130
|
-
|
|
131
|
-
v_radius = newSize;
|
|
131
|
+
v_radius = newSize;
|
|
132
132
|
|
|
133
133
|
// anti-alias
|
|
134
134
|
// float antialiased_blur = -max(u_blur, antialiasblur);
|
|
@@ -136,26 +136,9 @@ void main() {
|
|
|
136
136
|
|
|
137
137
|
vec2 offset = (extrude.xy * (newSize + u_stroke_width) + textrueOffsets);
|
|
138
138
|
vec3 aPosition = a_Position;
|
|
139
|
-
if(u_isMeter < 1.0) {
|
|
140
|
-
// 不以米为实际单位
|
|
141
|
-
offset = project_pixel(offset);
|
|
142
|
-
} else {
|
|
143
|
-
// 以米为实际单位
|
|
144
|
-
if(newSize * pow(2.0, u_Zoom) < 48.0) {
|
|
145
|
-
antialiasblur = max(antialiasblur, -0.05);
|
|
146
|
-
} else if(newSize * pow(2.0, u_Zoom) < 128.0) {
|
|
147
|
-
antialiasblur = max(antialiasblur, -0.6/pow(u_Zoom, 2.0));
|
|
148
|
-
} else {
|
|
149
|
-
antialiasblur = max(antialiasblur, -0.8/pow(u_Zoom, 2.0));
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
|
|
153
|
-
aPosition.x += offset.x / u_meteryScale;
|
|
154
|
-
aPosition.y += offset.y;
|
|
155
|
-
offset = vec2(0.0);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
139
|
|
|
140
|
+
offset = project_pixel(offset);
|
|
141
|
+
|
|
159
142
|
// TODP: /abs(extrude.x) 是为了兼容地球模式
|
|
160
143
|
v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);
|
|
161
144
|
|
|
@@ -177,7 +160,7 @@ void main() {
|
|
|
177
160
|
|
|
178
161
|
|
|
179
162
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
180
|
-
gl_Position =
|
|
163
|
+
gl_Position = u_Mvp * vec4(project_pos.xy + offset, raisingHeight, 1.0);
|
|
181
164
|
} else {
|
|
182
165
|
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));
|
|
183
166
|
}
|
|
@@ -10,7 +10,7 @@ varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样
|
|
|
10
10
|
uniform mat4 u_ModelMatrix;
|
|
11
11
|
uniform mat4 u_Mvp;
|
|
12
12
|
uniform mat2 u_RotateMatrix;
|
|
13
|
-
uniform
|
|
13
|
+
uniform int u_Size_Unit;
|
|
14
14
|
|
|
15
15
|
varying vec2 v_uv; // 本身的 uv 坐标
|
|
16
16
|
varying vec2 v_Iconuv; // icon 贴图的 uv 坐标
|
|
@@ -76,22 +76,16 @@ void main() {
|
|
|
76
76
|
highp float angle_sin = sin(a_Rotate);
|
|
77
77
|
highp float angle_cos = cos(a_Rotate);
|
|
78
78
|
mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);
|
|
79
|
+
float newSize = a_Size;
|
|
80
|
+
if(u_Size_Unit == 1) {
|
|
81
|
+
newSize = newSize * u_PixelsPerMeter.z;
|
|
82
|
+
}
|
|
79
83
|
|
|
80
84
|
// vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);
|
|
81
|
-
vec2 offset = (rotation_matrix * u_RotateMatrix * extrude.xy * (
|
|
85
|
+
vec2 offset = (rotation_matrix * u_RotateMatrix * extrude.xy * (newSize) + textrueOffsets);
|
|
82
86
|
vec3 aPosition = a_Position;
|
|
83
|
-
if(u_isMeter < 1.0) {
|
|
84
|
-
// 不以米为实际单位
|
|
85
|
-
offset = project_pixel(offset);
|
|
86
|
-
} else {
|
|
87
|
-
// 以米为实际单位
|
|
88
87
|
|
|
89
|
-
|
|
90
|
-
aPosition.xy += offset;
|
|
91
|
-
offset.x = 0.0;
|
|
92
|
-
offset.y = 0.0;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
88
|
+
offset = project_pixel(offset);
|
|
95
89
|
|
|
96
90
|
vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));
|
|
97
91
|
float raisingHeight = u_raisingHeight;
|
|
@@ -105,7 +99,7 @@ void main() {
|
|
|
105
99
|
}
|
|
106
100
|
|
|
107
101
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
108
|
-
gl_Position = u_Mvp *
|
|
102
|
+
gl_Position = u_Mvp *vec4(project_pos.xy + offset, raisingHeight, 1.0);
|
|
109
103
|
} else {
|
|
110
104
|
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));
|
|
111
105
|
}
|
|
@@ -7,7 +7,7 @@ uniform float u_time;
|
|
|
7
7
|
|
|
8
8
|
uniform mat4 u_ModelMatrix;
|
|
9
9
|
uniform mat4 u_Mvp;
|
|
10
|
-
uniform
|
|
10
|
+
uniform int u_Size_Unit;
|
|
11
11
|
|
|
12
12
|
varying vec4 v_data;
|
|
13
13
|
varying vec4 v_color;
|
|
@@ -31,37 +31,30 @@ void main() {
|
|
|
31
31
|
// unpack color(vec2)
|
|
32
32
|
v_color = a_Color;
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
v_radius = newSize;
|
|
34
|
+
|
|
36
35
|
|
|
37
36
|
// anti-alias
|
|
38
37
|
float blur = 0.0;
|
|
39
38
|
float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, blur);
|
|
40
39
|
|
|
40
|
+
if(u_Size_Unit == 1) {
|
|
41
|
+
newSize = newSize * u_PixelsPerMeter.z;
|
|
42
|
+
}
|
|
43
|
+
// radius(16-bit)
|
|
44
|
+
v_radius = newSize;
|
|
45
|
+
|
|
41
46
|
vec2 offset = (extrude.xy * (newSize));
|
|
42
47
|
vec3 aPosition = a_Position;
|
|
43
|
-
|
|
48
|
+
|
|
44
49
|
// 不以米为实际单位
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// 以米为实际单位
|
|
48
|
-
antialiasblur *= pow(19.0 - u_Zoom, 2.0);
|
|
49
|
-
antialiasblur = max(antialiasblur, -0.01);
|
|
50
|
-
// offset *= 0.5;
|
|
51
|
-
|
|
52
|
-
if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
|
|
53
|
-
aPosition.xy += offset;
|
|
54
|
-
offset.x = 0.0;
|
|
55
|
-
offset.y = 0.0;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
50
|
+
offset = project_pixel(offset);
|
|
51
|
+
|
|
59
52
|
v_data = vec4(extrude.x, extrude.y, antialiasblur, -1.0);
|
|
60
53
|
|
|
61
54
|
vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));
|
|
62
55
|
|
|
63
56
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
64
|
-
gl_Position = u_Mvp *
|
|
57
|
+
gl_Position = u_Mvp *vec4(project_pos.xy + offset, 0.0, 1.0);
|
|
65
58
|
} else {
|
|
66
59
|
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));
|
|
67
60
|
}
|
|
@@ -118,7 +118,7 @@ void main() {
|
|
|
118
118
|
|
|
119
119
|
vec4 projected_position;
|
|
120
120
|
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
|
|
121
|
-
projected_position = u_Mvp *
|
|
121
|
+
projected_position = u_Mvp *(vec4(a_Position.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));
|
|
122
122
|
} else { // else
|
|
123
123
|
projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));
|
|
124
124
|
}
|
package/es/polygon/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type PolygonModelType = 'fill' | 'extrude' | 'line' | 'point_fill' | 'point_image' | 'point_normal' | 'point_extrude' | 'text' | 'water' | 'ocean'
|
|
1
|
+
export type PolygonModelType = 'fill' | 'extrude' | 'line' | 'point_fill' | 'point_image' | 'point_normal' | 'point_extrude' | 'text' | 'water' | 'ocean';
|
|
2
2
|
declare const PolygonModels: {
|
|
3
3
|
[key in PolygonModelType]: any;
|
|
4
4
|
};
|