@antv/l7-layers 2.14.1 → 2.14.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.
- package/es/Geometry/models/billboard.js +3 -6
- package/es/Geometry/models/plane.js +3 -6
- package/es/core/BaseLayer.d.ts +7 -3
- package/es/core/BaseLayer.js +64 -20
- package/es/core/BaseModel.d.ts +3 -2
- package/es/core/BaseModel.js +39 -3
- package/es/core/LayerPickService.js +6 -30
- package/es/heatmap/index.d.ts +2 -2
- package/es/heatmap/index.js +5 -2
- package/es/heatmap/models/grid.js +5 -9
- package/es/heatmap/models/grid3d.js +5 -10
- package/es/heatmap/models/heatmap.d.ts +2 -2
- package/es/heatmap/models/heatmap.js +54 -46
- package/es/heatmap/models/hexagon.js +5 -10
- package/es/image/models/image.js +13 -16
- package/es/image/shaders/image_frag.glsl +2 -0
- package/es/index.js +6 -0
- package/es/line/models/arc.js +4 -6
- package/es/line/models/arc_3d.js +4 -6
- package/es/line/models/earthArc_3d.js +4 -6
- package/es/line/models/great_circle.js +9 -13
- package/es/line/models/half.js +4 -6
- package/es/line/models/line.js +3 -5
- package/es/line/models/linearline.js +4 -6
- package/es/line/models/simpleLine.js +5 -8
- package/es/mask/models/fill.js +1 -17
- package/es/plugins/LayerMaskPlugin.d.ts +8 -0
- package/es/plugins/LayerMaskPlugin.js +42 -0
- package/es/plugins/LayerStylePlugin.js +2 -1
- package/es/point/models/extrude.js +0 -1
- package/es/point/models/fill.js +4 -6
- package/es/point/models/fillmage.js +8 -12
- package/es/point/models/image.js +9 -14
- package/es/point/models/normal.js +4 -9
- package/es/point/models/radar.js +5 -10
- package/es/point/models/simplePoint.js +5 -10
- package/es/point/models/text.js +10 -16
- package/es/point/shaders/fill_frag.glsl +4 -0
- package/es/point/shaders/image_frag.glsl +4 -0
- package/es/point/shaders/text_frag.glsl +4 -0
- package/es/polygon/index.js +1 -1
- package/es/polygon/models/extrude.js +11 -13
- package/es/polygon/models/fill.js +3 -5
- package/es/polygon/models/ocean.js +6 -9
- package/es/polygon/models/water.js +7 -11
- package/es/raster/models/raster.js +9 -11
- package/es/raster/models/rasterRgb.js +8 -11
- package/es/raster/models/rasterTerrainRgb.js +9 -13
- package/es/raster/shaders/raster_2d_frag.glsl +6 -3
- package/es/raster/shaders/raster_frag.glsl +2 -0
- package/es/raster/shaders/raster_rgb_frag.glsl +2 -0
- package/es/raster/shaders/raster_terrain_rgb_frag.glsl +2 -0
- package/es/tile/service/TileLayerService.js +5 -4
- package/es/tile/style/constants.js +1 -1
- package/es/tile/tileFactory/Tile.d.ts +8 -0
- package/es/tile/tileFactory/Tile.js +102 -14
- package/es/tile/tileFactory/VectorTile.d.ts +0 -1
- package/es/tile/tileFactory/VectorTile.js +6 -46
- package/es/tile/tileLayer/BaseLayer.d.ts +2 -1
- package/es/tile/tileLayer/BaseLayer.js +68 -62
- package/es/utils/stencil.d.ts +7 -0
- package/es/utils/stencil.js +50 -0
- package/es/wind/index.d.ts +2 -1
- package/es/wind/index.js +3 -1
- package/es/wind/models/wind.d.ts +2 -2
- package/es/wind/models/wind.js +12 -10
- package/lib/Geometry/models/billboard.js +3 -7
- package/lib/Geometry/models/plane.js +2 -6
- package/lib/core/BaseLayer.js +64 -20
- package/lib/core/BaseModel.js +40 -2
- package/lib/core/LayerPickService.js +6 -32
- package/lib/heatmap/index.js +5 -2
- package/lib/heatmap/models/grid.js +5 -10
- package/lib/heatmap/models/grid3d.js +5 -11
- package/lib/heatmap/models/heatmap.js +53 -45
- package/lib/heatmap/models/hexagon.js +5 -11
- package/lib/image/models/image.js +12 -15
- package/lib/image/shaders/image_frag.glsl +2 -0
- package/lib/index.js +8 -0
- package/lib/line/models/arc.js +3 -5
- package/lib/line/models/arc_3d.js +3 -5
- package/lib/line/models/earthArc_3d.js +3 -5
- package/lib/line/models/great_circle.js +8 -12
- package/lib/line/models/half.js +3 -5
- package/lib/line/models/line.js +2 -4
- package/lib/line/models/linearline.js +3 -5
- package/lib/line/models/simpleLine.js +4 -7
- package/lib/mask/models/fill.js +1 -18
- package/lib/plugins/LayerMaskPlugin.js +54 -0
- package/lib/plugins/LayerStylePlugin.js +2 -1
- package/lib/point/models/extrude.js +0 -1
- package/lib/point/models/fill.js +3 -5
- package/lib/point/models/fillmage.js +7 -11
- package/lib/point/models/image.js +9 -15
- package/lib/point/models/normal.js +4 -10
- package/lib/point/models/radar.js +5 -11
- package/lib/point/models/simplePoint.js +5 -11
- package/lib/point/models/text.js +9 -15
- package/lib/point/shaders/fill_frag.glsl +4 -0
- package/lib/point/shaders/image_frag.glsl +4 -0
- package/lib/point/shaders/text_frag.glsl +4 -0
- package/lib/polygon/index.js +1 -1
- package/lib/polygon/models/extrude.js +10 -12
- package/lib/polygon/models/fill.js +2 -4
- package/lib/polygon/models/ocean.js +5 -8
- package/lib/polygon/models/water.js +7 -12
- package/lib/raster/models/raster.js +8 -10
- package/lib/raster/models/rasterRgb.js +8 -12
- package/lib/raster/models/rasterTerrainRgb.js +8 -12
- package/lib/raster/shaders/raster_2d_frag.glsl +6 -3
- package/lib/raster/shaders/raster_frag.glsl +2 -0
- package/lib/raster/shaders/raster_rgb_frag.glsl +2 -0
- package/lib/raster/shaders/raster_terrain_rgb_frag.glsl +2 -0
- package/lib/tile/service/TileLayerService.js +5 -4
- package/lib/tile/style/constants.js +1 -1
- package/lib/tile/tileFactory/Tile.js +102 -14
- package/lib/tile/tileFactory/VectorTile.js +6 -47
- package/lib/tile/tileLayer/BaseLayer.js +67 -62
- package/lib/utils/stencil.js +60 -0
- package/lib/wind/index.js +3 -1
- package/lib/wind/models/wind.js +11 -9
- package/package.json +7 -7
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _inversify = require("inversify");
|
|
17
|
+
|
|
18
|
+
require("reflect-metadata");
|
|
19
|
+
|
|
20
|
+
var _dec, _class;
|
|
21
|
+
|
|
22
|
+
var LayerStylePlugin = (
|
|
23
|
+
/**
|
|
24
|
+
* 更新图层样式,初始图层相关配置
|
|
25
|
+
*/
|
|
26
|
+
_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
|
|
27
|
+
function LayerStylePlugin() {
|
|
28
|
+
(0, _classCallCheck2.default)(this, LayerStylePlugin);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
(0, _createClass2.default)(LayerStylePlugin, [{
|
|
32
|
+
key: "apply",
|
|
33
|
+
value: function apply(layer) {
|
|
34
|
+
layer.hooks.afterInit.tap('LayerMaskPlugin', function () {
|
|
35
|
+
var _layer$getLayerConfig = layer.getLayerConfig(),
|
|
36
|
+
maskLayers = _layer$getLayerConfig.maskLayers,
|
|
37
|
+
enableMask = _layer$getLayerConfig.enableMask; // mask 初始化
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
if (!layer.tileLayer && maskLayers && maskLayers.length > 0) {
|
|
41
|
+
var _layer$masks;
|
|
42
|
+
|
|
43
|
+
(_layer$masks = layer.masks).push.apply(_layer$masks, (0, _toConsumableArray2.default)(maskLayers));
|
|
44
|
+
|
|
45
|
+
layer.updateLayerConfig({
|
|
46
|
+
mask: true && enableMask
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}]);
|
|
52
|
+
return LayerStylePlugin;
|
|
53
|
+
}()) || _class);
|
|
54
|
+
exports.default = LayerStylePlugin;
|
|
@@ -32,7 +32,8 @@ _dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
|
|
|
32
32
|
layer.hooks.afterInit.tap('LayerStylePlugin', function () {
|
|
33
33
|
var _layer$getLayerConfig = layer.getLayerConfig(),
|
|
34
34
|
autoFit = _layer$getLayerConfig.autoFit,
|
|
35
|
-
fitBoundsOptions = _layer$getLayerConfig.fitBoundsOptions;
|
|
35
|
+
fitBoundsOptions = _layer$getLayerConfig.fitBoundsOptions; // mask 初始化
|
|
36
|
+
|
|
36
37
|
|
|
37
38
|
if (autoFit) {
|
|
38
39
|
layer.fitBounds(fitBoundsOptions);
|
|
@@ -216,7 +216,6 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
216
216
|
vertexShader: pointExtrudeVert,
|
|
217
217
|
fragmentShader: pointExtrudeFrag,
|
|
218
218
|
triangulation: _triangulation.PointExtrudeTriangulation,
|
|
219
|
-
blend: this.getBlend(),
|
|
220
219
|
cull: {
|
|
221
220
|
enable: true,
|
|
222
221
|
face: (0, _l7Utils.getCullFace)(this.mapService.version)
|
package/lib/point/models/fill.js
CHANGED
|
@@ -40,7 +40,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
40
40
|
var waveFillFrag = "\nuniform float u_additive;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n\n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n float opacity = styleMappingMat[0][0];\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n \n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n float color_t = smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n float PI = 3.14159;\n float N_RINGS = 3.0;\n float FREQ = 1.0;\n\n gl_FragColor = vec4(v_color.rgb, v_color.a * opacity);\n\n float d = length(v_data.xy);\n if(d > 0.5) {\n discard;\n }\n float intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_animate.z - u_animate.y * u_time)), 0.0, 1.0);\n \n // \u6839\u636E\u53E0\u52A0\u6A21\u5F0F\u9009\u62E9\u6548\u679C\n if(u_additive > 0.0) {\n gl_FragColor *= intensity;\n // \u4F18\u5316\u6C34\u6CE2\u70B9 blend additive \u6A21\u5F0F\u4E0B\u6709\u7684\u62FE\u53D6\u6548\u679C \n gl_FragColor = filterColorAlpha(gl_FragColor, gl_FragColor.a);\n } else {\n gl_FragColor = vec4(gl_FragColor.xyz, gl_FragColor.a * intensity);\n gl_FragColor = filterColor(gl_FragColor);\n }\n}\n"; // static pointLayer shader - not support animate
|
|
41
41
|
|
|
42
42
|
/* babel-plugin-inline-import '../shaders/fill_frag.glsl' */
|
|
43
|
-
var pointFillFrag = "uniform float u_additive;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\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\n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n float opacity = styleMappingMat[0][0];\n float stroke_opacity = styleMappingMat[0][1];\n float strokeWidth = styleMappingMat[0][2];\n vec4 strokeColor = textrueStroke == vec4(0) ? v_color : textrueStroke;\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius + strokeWidth);\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 = strokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n\n if(strokeWidth < 0.01) {\n gl_FragColor = vec4(v_color.rgb, v_color.a * opacity);\n } else {\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), strokeColor * 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";
|
|
43
|
+
var pointFillFrag = "uniform float u_additive;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\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\n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n float opacity = styleMappingMat[0][0];\n float stroke_opacity = styleMappingMat[0][1];\n float strokeWidth = styleMappingMat[0][2];\n vec4 strokeColor = textrueStroke == vec4(0) ? v_color : textrueStroke;\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius + strokeWidth);\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 = strokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n\n if(strokeWidth < 0.01) {\n gl_FragColor = vec4(v_color.rgb, v_color.a * opacity);\n } else {\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), strokeColor * 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";
|
|
44
44
|
|
|
45
45
|
/* babel-plugin-inline-import '../shaders/fill_vert.glsl' */
|
|
46
46
|
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute float a_Shape;\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 int u_Size_Unit;\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];\nuniform vec2 u_offsets;\n\nuniform float u_blur : 0.0;\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\n\nvoid main() {\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 // 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 strokeOpacityAndOffset = calStrokeOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][1] = strokeOpacityAndOffset.r;\n textureOffset = strokeOpacityAndOffset.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 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 // unpack color(vec2)\n v_color = a_Color;\nif(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);\n\n vec2 offset = (extrude.xy * (newSize + u_stroke_width) + textrueOffsets);\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_raisingHeight;\n\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\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";
|
|
@@ -183,13 +183,13 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
183
183
|
key: "buildModels",
|
|
184
184
|
value: function () {
|
|
185
185
|
var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
186
|
-
var _ref3, _ref3$
|
|
186
|
+
var _ref3, _ref3$animateOption, animateOption, _ref3$workerEnabled, workerEnabled, enablePicking, shape2d, _this$getShaders, frag, vert, type, model;
|
|
187
187
|
|
|
188
188
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
189
189
|
while (1) {
|
|
190
190
|
switch (_context2.prev = _context2.next) {
|
|
191
191
|
case 0:
|
|
192
|
-
_ref3 = this.layer.getLayerConfig(), _ref3$
|
|
192
|
+
_ref3 = this.layer.getLayerConfig(), _ref3$animateOption = _ref3.animateOption, animateOption = _ref3$animateOption === void 0 ? {
|
|
193
193
|
enable: false
|
|
194
194
|
} : _ref3$animateOption, _ref3$workerEnabled = _ref3.workerEnabled, workerEnabled = _ref3$workerEnabled === void 0 ? false : _ref3$workerEnabled, enablePicking = _ref3.enablePicking, shape2d = _ref3.shape2d;
|
|
195
195
|
_this$getShaders = this.getShaders(animateOption), frag = _this$getShaders.frag, vert = _this$getShaders.vert, type = _this$getShaders.type;
|
|
@@ -203,8 +203,6 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
203
203
|
depth: {
|
|
204
204
|
enable: false
|
|
205
205
|
},
|
|
206
|
-
blend: this.getBlend(),
|
|
207
|
-
stencil: (0, _l7Utils.getMask)(mask, maskInside),
|
|
208
206
|
workerEnabled: workerEnabled,
|
|
209
207
|
workerOptions: {
|
|
210
208
|
modelType: type,
|
|
@@ -218,14 +218,12 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
218
218
|
key: "buildModels",
|
|
219
219
|
value: function () {
|
|
220
220
|
var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
221
|
-
var
|
|
222
|
-
|
|
221
|
+
var model;
|
|
223
222
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
224
223
|
while (1) {
|
|
225
224
|
switch (_context2.prev = _context2.next) {
|
|
226
225
|
case 0:
|
|
227
|
-
|
|
228
|
-
_context2.next = 3;
|
|
226
|
+
_context2.next = 2;
|
|
229
227
|
return this.layer.buildLayerModel({
|
|
230
228
|
moduleName: 'pointFillImage',
|
|
231
229
|
vertexShader: pointFillVert,
|
|
@@ -234,19 +232,17 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
234
232
|
depth: {
|
|
235
233
|
enable: false
|
|
236
234
|
},
|
|
237
|
-
blend: this.getBlend(),
|
|
238
|
-
stencil: (0, _l7Utils.getMask)(mask, maskInside),
|
|
239
235
|
cull: {
|
|
240
236
|
enable: true,
|
|
241
237
|
face: (0, _l7Utils.getCullFace)(this.mapService.version)
|
|
242
238
|
}
|
|
243
239
|
});
|
|
244
240
|
|
|
245
|
-
case
|
|
241
|
+
case 2:
|
|
246
242
|
model = _context2.sent;
|
|
247
243
|
return _context2.abrupt("return", [model]);
|
|
248
244
|
|
|
249
|
-
case
|
|
245
|
+
case 4:
|
|
250
246
|
case "end":
|
|
251
247
|
return _context2.stop();
|
|
252
248
|
}
|
|
@@ -310,12 +306,12 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
310
306
|
|
|
311
307
|
var shape = feature.shape;
|
|
312
308
|
|
|
313
|
-
var
|
|
309
|
+
var _ref2 = iconMap[shape] || {
|
|
314
310
|
x: -64,
|
|
315
311
|
y: -64
|
|
316
312
|
},
|
|
317
|
-
x =
|
|
318
|
-
y =
|
|
313
|
+
x = _ref2.x,
|
|
314
|
+
y = _ref2.y;
|
|
319
315
|
|
|
320
316
|
return [x, y];
|
|
321
317
|
}
|
|
@@ -27,8 +27,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
27
27
|
|
|
28
28
|
var _l7Core = require("@antv/l7-core");
|
|
29
29
|
|
|
30
|
-
var _l7Utils = require("@antv/l7-utils");
|
|
31
|
-
|
|
32
30
|
var _lodash = require("lodash");
|
|
33
31
|
|
|
34
32
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
@@ -40,7 +38,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
40
38
|
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; } }
|
|
41
39
|
|
|
42
40
|
/* babel-plugin-inline-import '../shaders/image_frag.glsl' */
|
|
43
|
-
var pointImageFrag = "\nuniform sampler2D u_texture;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nuniform vec2 u_textSize;\nuniform float u_opacity : 1;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\n\nvoid main(){\n float opacity = styleMappingMat[0][0];\n float size = styleMappingMat[1][0];\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 * opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
41
|
+
var pointImageFrag = "\nuniform sampler2D u_texture;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nuniform vec2 u_textSize;\nuniform float u_opacity : 1;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\n\nvoid main(){\n float opacity = styleMappingMat[0][0];\n float size = styleMappingMat[1][0];\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 * opacity;\n \n if (gl_FragColor.a < 0.01) {\n discard;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
44
42
|
|
|
45
43
|
/* babel-plugin-inline-import '../shaders/image_vert.glsl' */
|
|
46
44
|
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\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\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\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 styleMappingMat[1][0] = a_Size;\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 - \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(textrueOffsets);\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";
|
|
@@ -195,14 +193,12 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
195
193
|
key: "buildModels",
|
|
196
194
|
value: function () {
|
|
197
195
|
var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
198
|
-
var
|
|
199
|
-
|
|
196
|
+
var model;
|
|
200
197
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
201
198
|
while (1) {
|
|
202
199
|
switch (_context2.prev = _context2.next) {
|
|
203
200
|
case 0:
|
|
204
|
-
|
|
205
|
-
_context2.next = 3;
|
|
201
|
+
_context2.next = 2;
|
|
206
202
|
return this.layer.buildLayerModel({
|
|
207
203
|
moduleName: 'pointImage',
|
|
208
204
|
vertexShader: pointImageVert,
|
|
@@ -211,16 +207,14 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
211
207
|
depth: {
|
|
212
208
|
enable: false
|
|
213
209
|
},
|
|
214
|
-
primitive: _l7Core.gl.POINTS
|
|
215
|
-
blend: this.getBlend(),
|
|
216
|
-
stencil: (0, _l7Utils.getMask)(mask, maskInside)
|
|
210
|
+
primitive: _l7Core.gl.POINTS
|
|
217
211
|
});
|
|
218
212
|
|
|
219
|
-
case
|
|
213
|
+
case 2:
|
|
220
214
|
model = _context2.sent;
|
|
221
215
|
return _context2.abrupt("return", [model]);
|
|
222
216
|
|
|
223
|
-
case
|
|
217
|
+
case 4:
|
|
224
218
|
case "end":
|
|
225
219
|
return _context2.stop();
|
|
226
220
|
}
|
|
@@ -277,12 +271,12 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
277
271
|
|
|
278
272
|
var shape = feature.shape;
|
|
279
273
|
|
|
280
|
-
var
|
|
274
|
+
var _ref2 = iconMap[shape] || {
|
|
281
275
|
x: -64,
|
|
282
276
|
y: -64
|
|
283
277
|
},
|
|
284
|
-
x =
|
|
285
|
-
y =
|
|
278
|
+
x = _ref2.x,
|
|
279
|
+
y = _ref2.y; // 非画布区域,默认的图标改为透明
|
|
286
280
|
|
|
287
281
|
|
|
288
282
|
return [x, y];
|
|
@@ -26,8 +26,6 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
26
26
|
|
|
27
27
|
var _l7Core = require("@antv/l7-core");
|
|
28
28
|
|
|
29
|
-
var _l7Utils = require("@antv/l7-utils");
|
|
30
|
-
|
|
31
29
|
var _lodash = require("lodash");
|
|
32
30
|
|
|
33
31
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
@@ -107,15 +105,13 @@ var NormalModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
107
105
|
key: "buildModels",
|
|
108
106
|
value: function () {
|
|
109
107
|
var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
110
|
-
var
|
|
111
|
-
|
|
108
|
+
var model;
|
|
112
109
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
113
110
|
while (1) {
|
|
114
111
|
switch (_context2.prev = _context2.next) {
|
|
115
112
|
case 0:
|
|
116
|
-
_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;
|
|
117
113
|
this.layer.triangulation = PointTriangulation;
|
|
118
|
-
_context2.next =
|
|
114
|
+
_context2.next = 3;
|
|
119
115
|
return this.layer.buildLayerModel({
|
|
120
116
|
moduleName: 'pointNormal',
|
|
121
117
|
vertexShader: normalVert,
|
|
@@ -125,16 +121,14 @@ var NormalModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
125
121
|
enable: false
|
|
126
122
|
},
|
|
127
123
|
primitive: _l7Core.gl.POINTS,
|
|
128
|
-
blend: this.getBlend(),
|
|
129
|
-
stencil: (0, _l7Utils.getMask)(mask, maskInside),
|
|
130
124
|
pick: false
|
|
131
125
|
});
|
|
132
126
|
|
|
133
|
-
case
|
|
127
|
+
case 3:
|
|
134
128
|
model = _context2.sent;
|
|
135
129
|
return _context2.abrupt("return", [model]);
|
|
136
130
|
|
|
137
|
-
case
|
|
131
|
+
case 5:
|
|
138
132
|
case "end":
|
|
139
133
|
return _context2.stop();
|
|
140
134
|
}
|
|
@@ -23,8 +23,6 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
23
23
|
|
|
24
24
|
var _l7Core = require("@antv/l7-core");
|
|
25
25
|
|
|
26
|
-
var _l7Utils = require("@antv/l7-utils");
|
|
27
|
-
|
|
28
26
|
var _lodash = require("lodash");
|
|
29
27
|
|
|
30
28
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
@@ -119,14 +117,12 @@ var RadarModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
119
117
|
key: "buildModels",
|
|
120
118
|
value: function () {
|
|
121
119
|
var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
122
|
-
var
|
|
123
|
-
|
|
120
|
+
var model;
|
|
124
121
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
125
122
|
while (1) {
|
|
126
123
|
switch (_context2.prev = _context2.next) {
|
|
127
124
|
case 0:
|
|
128
|
-
|
|
129
|
-
_context2.next = 3;
|
|
125
|
+
_context2.next = 2;
|
|
130
126
|
return this.layer.buildLayerModel({
|
|
131
127
|
moduleName: 'pointRadar',
|
|
132
128
|
vertexShader: pointFillVert,
|
|
@@ -134,16 +130,14 @@ var RadarModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
134
130
|
triangulation: _triangulation.PointFillTriangulation,
|
|
135
131
|
depth: {
|
|
136
132
|
enable: false
|
|
137
|
-
}
|
|
138
|
-
blend: this.getBlend(),
|
|
139
|
-
stencil: (0, _l7Utils.getMask)(mask, maskInside)
|
|
133
|
+
}
|
|
140
134
|
});
|
|
141
135
|
|
|
142
|
-
case
|
|
136
|
+
case 2:
|
|
143
137
|
model = _context2.sent;
|
|
144
138
|
return _context2.abrupt("return", [model]);
|
|
145
139
|
|
|
146
|
-
case
|
|
140
|
+
case 4:
|
|
147
141
|
case "end":
|
|
148
142
|
return _context2.stop();
|
|
149
143
|
}
|
|
@@ -26,8 +26,6 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
26
26
|
|
|
27
27
|
var _l7Core = require("@antv/l7-core");
|
|
28
28
|
|
|
29
|
-
var _l7Utils = require("@antv/l7-utils");
|
|
30
|
-
|
|
31
29
|
var _lodash = require("lodash");
|
|
32
30
|
|
|
33
31
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
@@ -159,15 +157,13 @@ var SimplePointModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
159
157
|
key: "buildModels",
|
|
160
158
|
value: function () {
|
|
161
159
|
var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
162
|
-
var
|
|
163
|
-
|
|
160
|
+
var model;
|
|
164
161
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
165
162
|
while (1) {
|
|
166
163
|
switch (_context2.prev = _context2.next) {
|
|
167
164
|
case 0:
|
|
168
|
-
_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;
|
|
169
165
|
this.layer.triangulation = PointTriangulation;
|
|
170
|
-
_context2.next =
|
|
166
|
+
_context2.next = 3;
|
|
171
167
|
return this.layer.buildLayerModel({
|
|
172
168
|
moduleName: 'pointSimple',
|
|
173
169
|
vertexShader: simplePointVert,
|
|
@@ -176,16 +172,14 @@ var SimplePointModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
176
172
|
depth: {
|
|
177
173
|
enable: false
|
|
178
174
|
},
|
|
179
|
-
primitive: _l7Core.gl.POINTS
|
|
180
|
-
blend: this.getBlend(),
|
|
181
|
-
stencil: (0, _l7Utils.getMask)(mask, maskInside)
|
|
175
|
+
primitive: _l7Core.gl.POINTS
|
|
182
176
|
});
|
|
183
177
|
|
|
184
|
-
case
|
|
178
|
+
case 3:
|
|
185
179
|
model = _context2.sent;
|
|
186
180
|
return _context2.abrupt("return", [model]);
|
|
187
181
|
|
|
188
|
-
case
|
|
182
|
+
case 5:
|
|
189
183
|
case "end":
|
|
190
184
|
return _context2.stop();
|
|
191
185
|
}
|
package/lib/point/models/text.js
CHANGED
|
@@ -51,7 +51,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
51
51
|
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; } }
|
|
52
52
|
|
|
53
53
|
/* babel-plugin-inline-import '../shaders/text_frag.glsl' */
|
|
54
|
-
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";
|
|
54
|
+
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 // \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";
|
|
55
55
|
|
|
56
56
|
/* babel-plugin-inline-import '../shaders/text_vert.glsl' */
|
|
57
57
|
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";
|
|
@@ -240,13 +240,13 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
240
240
|
key: "buildModels",
|
|
241
241
|
value: function () {
|
|
242
242
|
var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
243
|
-
var _ref3, _ref3$
|
|
243
|
+
var _ref3, _ref3$textAllowOverla, textAllowOverlap, model;
|
|
244
244
|
|
|
245
245
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
246
246
|
while (1) {
|
|
247
247
|
switch (_context3.prev = _context3.next) {
|
|
248
248
|
case 0:
|
|
249
|
-
_ref3 = this.layer.getLayerConfig(), _ref3$
|
|
249
|
+
_ref3 = this.layer.getLayerConfig(), _ref3$textAllowOverla = _ref3.textAllowOverlap, textAllowOverlap = _ref3$textAllowOverla === void 0 ? false : _ref3$textAllowOverla; // this.mapping(); 重复调用
|
|
250
250
|
|
|
251
251
|
this.initGlyph(); //
|
|
252
252
|
|
|
@@ -264,9 +264,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
264
264
|
triangulation: TextTriangulation.bind(this),
|
|
265
265
|
depth: {
|
|
266
266
|
enable: false
|
|
267
|
-
}
|
|
268
|
-
blend: this.getBlend(),
|
|
269
|
-
stencil: (0, _l7Utils.getMask)(mask, maskInside)
|
|
267
|
+
}
|
|
270
268
|
});
|
|
271
269
|
|
|
272
270
|
case 6:
|
|
@@ -716,15 +714,13 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
716
714
|
key: "reBuildModel",
|
|
717
715
|
value: function () {
|
|
718
716
|
var _reBuildModel = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
719
|
-
var
|
|
720
|
-
|
|
717
|
+
var model;
|
|
721
718
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
722
719
|
while (1) {
|
|
723
720
|
switch (_context5.prev = _context5.next) {
|
|
724
721
|
case 0:
|
|
725
|
-
_ref8 = this.layer.getLayerConfig(), _ref8$mask = _ref8.mask, mask = _ref8$mask === void 0 ? false : _ref8$mask, _ref8$maskInside = _ref8.maskInside, maskInside = _ref8$maskInside === void 0 ? true : _ref8$maskInside;
|
|
726
722
|
this.filterGlyphs();
|
|
727
|
-
_context5.next =
|
|
723
|
+
_context5.next = 3;
|
|
728
724
|
return this.layer.buildLayerModel({
|
|
729
725
|
moduleName: 'pointText',
|
|
730
726
|
vertexShader: textVert,
|
|
@@ -732,17 +728,15 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
732
728
|
triangulation: TextTriangulation.bind(this),
|
|
733
729
|
depth: {
|
|
734
730
|
enable: false
|
|
735
|
-
}
|
|
736
|
-
blend: this.getBlend(),
|
|
737
|
-
stencil: (0, _l7Utils.getMask)(mask, maskInside)
|
|
731
|
+
}
|
|
738
732
|
});
|
|
739
733
|
|
|
740
|
-
case
|
|
734
|
+
case 3:
|
|
741
735
|
model = _context5.sent;
|
|
742
736
|
// TODO 渲染流程待修改
|
|
743
737
|
this.layer.models = [model];
|
|
744
738
|
|
|
745
|
-
case
|
|
739
|
+
case 5:
|
|
746
740
|
case "end":
|
|
747
741
|
return _context5.stop();
|
|
748
742
|
}
|
|
@@ -44,5 +44,9 @@ void main() {
|
|
|
44
44
|
// 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));
|
|
45
45
|
gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), vec4(textrueStroke.rgb, textrueStroke.a * opacity), smoothstep(0., 0.5, 1. - dist));
|
|
46
46
|
gl_FragColor.a= gl_FragColor.a * alpha;
|
|
47
|
+
// 作为 mask 模板时需要丢弃透明的像素
|
|
48
|
+
if (gl_FragColor.a < 0.01) {
|
|
49
|
+
discard;
|
|
50
|
+
}
|
|
47
51
|
gl_FragColor = filterColor(gl_FragColor);
|
|
48
52
|
}
|
package/lib/polygon/index.js
CHANGED
|
@@ -88,7 +88,7 @@ var PolygonLayer = /*#__PURE__*/function (_BaseLayer) {
|
|
|
88
88
|
var shapeAttribute = this.styleAttributeService.getLayerStyleAttribute('shape');
|
|
89
89
|
var shape = shapeAttribute === null || shapeAttribute === void 0 ? void 0 : (_shapeAttribute$scale = shapeAttribute.scale) === null || _shapeAttribute$scale === void 0 ? void 0 : _shapeAttribute$scale.field;
|
|
90
90
|
|
|
91
|
-
if (shape === 'fill') {
|
|
91
|
+
if (shape === 'fill' || !shape) {
|
|
92
92
|
return 'fill';
|
|
93
93
|
} else if (shape === 'extrude') {
|
|
94
94
|
return 'extrude';
|
|
@@ -172,28 +172,26 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
172
172
|
key: "buildModels",
|
|
173
173
|
value: function () {
|
|
174
174
|
var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
175
|
-
var
|
|
175
|
+
var _this$getShaders, frag, vert, type, model;
|
|
176
176
|
|
|
177
177
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
178
178
|
while (1) {
|
|
179
179
|
switch (_context2.prev = _context2.next) {
|
|
180
180
|
case 0:
|
|
181
|
-
_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;
|
|
182
181
|
_this$getShaders = this.getShaders(), frag = _this$getShaders.frag, vert = _this$getShaders.vert, type = _this$getShaders.type;
|
|
183
|
-
_context2.next =
|
|
182
|
+
_context2.next = 3;
|
|
184
183
|
return this.layer.buildLayerModel({
|
|
185
184
|
moduleName: type,
|
|
186
185
|
vertexShader: vert,
|
|
187
186
|
fragmentShader: frag,
|
|
188
|
-
triangulation: _triangulation.PolygonExtrudeTriangulation
|
|
189
|
-
stencil: (0, _l7Utils.getMask)(mask, maskInside)
|
|
187
|
+
triangulation: _triangulation.PolygonExtrudeTriangulation
|
|
190
188
|
});
|
|
191
189
|
|
|
192
|
-
case
|
|
190
|
+
case 3:
|
|
193
191
|
model = _context2.sent;
|
|
194
192
|
return _context2.abrupt("return", [model]);
|
|
195
193
|
|
|
196
|
-
case
|
|
194
|
+
case 5:
|
|
197
195
|
case "end":
|
|
198
196
|
return _context2.stop();
|
|
199
197
|
}
|
|
@@ -210,9 +208,9 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
210
208
|
}, {
|
|
211
209
|
key: "getShaders",
|
|
212
210
|
value: function getShaders() {
|
|
213
|
-
var
|
|
214
|
-
pickLight =
|
|
215
|
-
mapTexture =
|
|
211
|
+
var _ref2 = this.layer.getLayerConfig(),
|
|
212
|
+
pickLight = _ref2.pickLight,
|
|
213
|
+
mapTexture = _ref2.mapTexture;
|
|
216
214
|
|
|
217
215
|
if (mapTexture) {
|
|
218
216
|
return {
|
|
@@ -317,8 +315,8 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
317
315
|
value: function loadTexture() {
|
|
318
316
|
var _this = this;
|
|
319
317
|
|
|
320
|
-
var
|
|
321
|
-
mapTexture =
|
|
318
|
+
var _ref3 = this.layer.getLayerConfig(),
|
|
319
|
+
mapTexture = _ref3.mapTexture;
|
|
322
320
|
|
|
323
321
|
var createTexture2D = this.rendererService.createTexture2D;
|
|
324
322
|
this.texture = createTexture2D({
|
|
@@ -141,14 +141,14 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
141
141
|
key: "buildModels",
|
|
142
142
|
value: function () {
|
|
143
143
|
var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
144
|
-
var _this$getModelParams, frag, vert, triangulation, type, _ref2, _ref2$
|
|
144
|
+
var _this$getModelParams, frag, vert, triangulation, type, _ref2, _ref2$workerEnabled, workerEnabled, enablePicking, model;
|
|
145
145
|
|
|
146
146
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
147
147
|
while (1) {
|
|
148
148
|
switch (_context2.prev = _context2.next) {
|
|
149
149
|
case 0:
|
|
150
150
|
_this$getModelParams = this.getModelParams(), frag = _this$getModelParams.frag, vert = _this$getModelParams.vert, triangulation = _this$getModelParams.triangulation, type = _this$getModelParams.type;
|
|
151
|
-
_ref2 = this.layer.getLayerConfig(), _ref2$
|
|
151
|
+
_ref2 = this.layer.getLayerConfig(), _ref2$workerEnabled = _ref2.workerEnabled, workerEnabled = _ref2$workerEnabled === void 0 ? false : _ref2$workerEnabled, enablePicking = _ref2.enablePicking;
|
|
152
152
|
this.layer.triangulation = triangulation;
|
|
153
153
|
_context2.next = 5;
|
|
154
154
|
return this.layer.buildLayerModel({
|
|
@@ -160,8 +160,6 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
160
160
|
depth: {
|
|
161
161
|
enable: false
|
|
162
162
|
},
|
|
163
|
-
blend: this.getBlend(),
|
|
164
|
-
stencil: (0, _l7Utils.getMask)(mask, maskInside),
|
|
165
163
|
workerEnabled: workerEnabled,
|
|
166
164
|
workerOptions: {
|
|
167
165
|
modelType: type,
|