@antv/l7-layers 2.14.1 → 2.14.2
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 +62 -18
- package/es/core/BaseModel.d.ts +3 -2
- package/es/core/BaseModel.js +39 -3
- package/es/core/LayerPickService.js +6 -2
- 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 +1 -0
- package/es/tile/tileLayer/BaseLayer.js +5 -0
- 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 +62 -18
- package/lib/core/BaseModel.js +40 -2
- package/lib/core/LayerPickService.js +6 -2
- 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 +5 -0
- 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
|
@@ -11,7 +11,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
11
11
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
12
|
|
|
13
13
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
14
|
-
import {
|
|
14
|
+
import { rgb2arr } from '@antv/l7-utils';
|
|
15
15
|
import { isNumber } from 'lodash';
|
|
16
16
|
import BaseModel from "../../core/BaseModel";
|
|
17
17
|
import { SimpleLineTriangulation } from "../../core/triangulation";
|
|
@@ -161,15 +161,14 @@ var SimpleLineModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
161
161
|
key: "buildModels",
|
|
162
162
|
value: function () {
|
|
163
163
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
164
|
-
var
|
|
164
|
+
var _this$getShaders, frag, vert, type, model;
|
|
165
165
|
|
|
166
166
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
167
167
|
while (1) {
|
|
168
168
|
switch (_context2.prev = _context2.next) {
|
|
169
169
|
case 0:
|
|
170
|
-
_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;
|
|
171
170
|
_this$getShaders = this.getShaders(), frag = _this$getShaders.frag, vert = _this$getShaders.vert, type = _this$getShaders.type;
|
|
172
|
-
_context2.next =
|
|
171
|
+
_context2.next = 3;
|
|
173
172
|
return this.layer.buildLayerModel({
|
|
174
173
|
moduleName: type,
|
|
175
174
|
vertexShader: vert,
|
|
@@ -179,16 +178,14 @@ var SimpleLineModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
179
178
|
depth: {
|
|
180
179
|
enable: false
|
|
181
180
|
},
|
|
182
|
-
blend: this.getBlend(),
|
|
183
|
-
stencil: getMask(mask, maskInside),
|
|
184
181
|
pick: false
|
|
185
182
|
});
|
|
186
183
|
|
|
187
|
-
case
|
|
184
|
+
case 3:
|
|
188
185
|
model = _context2.sent;
|
|
189
186
|
return _context2.abrupt("return", [model]);
|
|
190
187
|
|
|
191
|
-
case
|
|
188
|
+
case 5:
|
|
192
189
|
case "end":
|
|
193
190
|
return _context2.stop();
|
|
194
191
|
}
|
package/es/mask/models/fill.js
CHANGED
|
@@ -10,7 +10,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
10
10
|
|
|
11
11
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
12
|
|
|
13
|
-
import { gl } from '@antv/l7-core';
|
|
14
13
|
import { rgb2arr } from '@antv/l7-utils';
|
|
15
14
|
import { isNumber } from 'lodash';
|
|
16
15
|
import BaseModel from "../../core/BaseModel";
|
|
@@ -38,7 +37,7 @@ var MaskModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
38
37
|
value: function getUninforms() {
|
|
39
38
|
var _ref = this.layer.getLayerConfig(),
|
|
40
39
|
_ref$opacity = _ref.opacity,
|
|
41
|
-
opacity = _ref$opacity === void 0 ?
|
|
40
|
+
opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
|
|
42
41
|
_ref$color = _ref.color,
|
|
43
42
|
color = _ref$color === void 0 ? '#000' : _ref$color;
|
|
44
43
|
|
|
@@ -89,21 +88,6 @@ var MaskModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
89
88
|
depth: {
|
|
90
89
|
enable: false
|
|
91
90
|
},
|
|
92
|
-
blend: this.getBlend(),
|
|
93
|
-
stencil: {
|
|
94
|
-
enable: true,
|
|
95
|
-
mask: 0xff,
|
|
96
|
-
func: {
|
|
97
|
-
cmp: gl.ALWAYS,
|
|
98
|
-
ref: 1,
|
|
99
|
-
mask: 0xff
|
|
100
|
-
},
|
|
101
|
-
opFront: {
|
|
102
|
-
fail: gl.REPLACE,
|
|
103
|
-
zfail: gl.REPLACE,
|
|
104
|
-
zpass: gl.REPLACE
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
91
|
pick: false
|
|
108
92
|
});
|
|
109
93
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
|
|
5
|
+
var _dec, _class;
|
|
6
|
+
|
|
7
|
+
import { injectable } from 'inversify';
|
|
8
|
+
import 'reflect-metadata';
|
|
9
|
+
/**
|
|
10
|
+
* 更新图层样式,初始图层相关配置
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
var LayerStylePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function () {
|
|
14
|
+
function LayerStylePlugin() {
|
|
15
|
+
_classCallCheck(this, LayerStylePlugin);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
_createClass(LayerStylePlugin, [{
|
|
19
|
+
key: "apply",
|
|
20
|
+
value: function apply(layer) {
|
|
21
|
+
layer.hooks.afterInit.tap('LayerMaskPlugin', function () {
|
|
22
|
+
var _layer$getLayerConfig = layer.getLayerConfig(),
|
|
23
|
+
maskLayers = _layer$getLayerConfig.maskLayers,
|
|
24
|
+
enableMask = _layer$getLayerConfig.enableMask; // mask 初始化
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
if (!layer.tileLayer && maskLayers && maskLayers.length > 0) {
|
|
28
|
+
var _layer$masks;
|
|
29
|
+
|
|
30
|
+
(_layer$masks = layer.masks).push.apply(_layer$masks, _toConsumableArray(maskLayers));
|
|
31
|
+
|
|
32
|
+
layer.updateLayerConfig({
|
|
33
|
+
mask: true && enableMask
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}]);
|
|
39
|
+
|
|
40
|
+
return LayerStylePlugin;
|
|
41
|
+
}()) || _class);
|
|
42
|
+
export { LayerStylePlugin as default };
|
|
@@ -20,7 +20,8 @@ var LayerStylePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function
|
|
|
20
20
|
layer.hooks.afterInit.tap('LayerStylePlugin', function () {
|
|
21
21
|
var _layer$getLayerConfig = layer.getLayerConfig(),
|
|
22
22
|
autoFit = _layer$getLayerConfig.autoFit,
|
|
23
|
-
fitBoundsOptions = _layer$getLayerConfig.fitBoundsOptions;
|
|
23
|
+
fitBoundsOptions = _layer$getLayerConfig.fitBoundsOptions; // mask 初始化
|
|
24
|
+
|
|
24
25
|
|
|
25
26
|
if (autoFit) {
|
|
26
27
|
layer.fitBounds(fitBoundsOptions);
|
|
@@ -198,7 +198,6 @@ var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
198
198
|
vertexShader: pointExtrudeVert,
|
|
199
199
|
fragmentShader: pointExtrudeFrag,
|
|
200
200
|
triangulation: PointExtrudeTriangulation,
|
|
201
|
-
blend: this.getBlend(),
|
|
202
201
|
cull: {
|
|
203
202
|
enable: true,
|
|
204
203
|
face: getCullFace(this.mapService.version)
|
package/es/point/models/fill.js
CHANGED
|
@@ -11,7 +11,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
11
11
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
12
|
|
|
13
13
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
14
|
-
import {
|
|
14
|
+
import { PointFillTriangulation } from '@antv/l7-utils';
|
|
15
15
|
import { isNumber } from 'lodash';
|
|
16
16
|
import BaseModel from "../../core/BaseModel";
|
|
17
17
|
import { SizeUnitType } from "../../core/interface"; // animate pointLayer shader - support animate
|
|
@@ -20,7 +20,7 @@ import { SizeUnitType } from "../../core/interface"; // animate pointLayer shade
|
|
|
20
20
|
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
|
|
21
21
|
|
|
22
22
|
/* babel-plugin-inline-import '../shaders/fill_frag.glsl' */
|
|
23
|
-
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";
|
|
23
|
+
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";
|
|
24
24
|
|
|
25
25
|
/* babel-plugin-inline-import '../shaders/fill_vert.glsl' */
|
|
26
26
|
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";
|
|
@@ -164,13 +164,13 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
164
164
|
key: "buildModels",
|
|
165
165
|
value: function () {
|
|
166
166
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
167
|
-
var _ref3, _ref3$
|
|
167
|
+
var _ref3, _ref3$animateOption, animateOption, _ref3$workerEnabled, workerEnabled, enablePicking, shape2d, _this$getShaders, frag, vert, type, model;
|
|
168
168
|
|
|
169
169
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
170
170
|
while (1) {
|
|
171
171
|
switch (_context2.prev = _context2.next) {
|
|
172
172
|
case 0:
|
|
173
|
-
_ref3 = this.layer.getLayerConfig(), _ref3$
|
|
173
|
+
_ref3 = this.layer.getLayerConfig(), _ref3$animateOption = _ref3.animateOption, animateOption = _ref3$animateOption === void 0 ? {
|
|
174
174
|
enable: false
|
|
175
175
|
} : _ref3$animateOption, _ref3$workerEnabled = _ref3.workerEnabled, workerEnabled = _ref3$workerEnabled === void 0 ? false : _ref3$workerEnabled, enablePicking = _ref3.enablePicking, shape2d = _ref3.shape2d;
|
|
176
176
|
_this$getShaders = this.getShaders(animateOption), frag = _this$getShaders.frag, vert = _this$getShaders.vert, type = _this$getShaders.type;
|
|
@@ -184,8 +184,6 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
184
184
|
depth: {
|
|
185
185
|
enable: false
|
|
186
186
|
},
|
|
187
|
-
blend: this.getBlend(),
|
|
188
|
-
stencil: getMask(mask, maskInside),
|
|
189
187
|
workerEnabled: workerEnabled,
|
|
190
188
|
workerOptions: {
|
|
191
189
|
modelType: type,
|
|
@@ -13,7 +13,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
13
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; } }
|
|
14
14
|
|
|
15
15
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
16
|
-
import { getCullFace
|
|
16
|
+
import { getCullFace } from '@antv/l7-utils';
|
|
17
17
|
import { isNumber } from 'lodash';
|
|
18
18
|
import BaseModel from "../../core/BaseModel";
|
|
19
19
|
import { SizeUnitType } from "../../core/interface";
|
|
@@ -200,14 +200,12 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
200
200
|
key: "buildModels",
|
|
201
201
|
value: function () {
|
|
202
202
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
203
|
-
var
|
|
204
|
-
|
|
203
|
+
var model;
|
|
205
204
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
206
205
|
while (1) {
|
|
207
206
|
switch (_context2.prev = _context2.next) {
|
|
208
207
|
case 0:
|
|
209
|
-
|
|
210
|
-
_context2.next = 3;
|
|
208
|
+
_context2.next = 2;
|
|
211
209
|
return this.layer.buildLayerModel({
|
|
212
210
|
moduleName: 'pointFillImage',
|
|
213
211
|
vertexShader: pointFillVert,
|
|
@@ -216,19 +214,17 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
216
214
|
depth: {
|
|
217
215
|
enable: false
|
|
218
216
|
},
|
|
219
|
-
blend: this.getBlend(),
|
|
220
|
-
stencil: getMask(mask, maskInside),
|
|
221
217
|
cull: {
|
|
222
218
|
enable: true,
|
|
223
219
|
face: getCullFace(this.mapService.version)
|
|
224
220
|
}
|
|
225
221
|
});
|
|
226
222
|
|
|
227
|
-
case
|
|
223
|
+
case 2:
|
|
228
224
|
model = _context2.sent;
|
|
229
225
|
return _context2.abrupt("return", [model]);
|
|
230
226
|
|
|
231
|
-
case
|
|
227
|
+
case 4:
|
|
232
228
|
case "end":
|
|
233
229
|
return _context2.stop();
|
|
234
230
|
}
|
|
@@ -292,12 +288,12 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
292
288
|
|
|
293
289
|
var shape = feature.shape;
|
|
294
290
|
|
|
295
|
-
var
|
|
291
|
+
var _ref2 = iconMap[shape] || {
|
|
296
292
|
x: -64,
|
|
297
293
|
y: -64
|
|
298
294
|
},
|
|
299
|
-
x =
|
|
300
|
-
y =
|
|
295
|
+
x = _ref2.x,
|
|
296
|
+
y = _ref2.y;
|
|
301
297
|
|
|
302
298
|
return [x, y];
|
|
303
299
|
}
|
package/es/point/models/image.js
CHANGED
|
@@ -13,13 +13,12 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
13
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; } }
|
|
14
14
|
|
|
15
15
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
16
|
-
import { getMask } from '@antv/l7-utils';
|
|
17
16
|
import { isNumber } from 'lodash';
|
|
18
17
|
import BaseModel from "../../core/BaseModel";
|
|
19
18
|
import { PointImageTriangulation } from "../../core/triangulation";
|
|
20
19
|
|
|
21
20
|
/* babel-plugin-inline-import '../shaders/image_frag.glsl' */
|
|
22
|
-
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";
|
|
21
|
+
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";
|
|
23
22
|
|
|
24
23
|
/* babel-plugin-inline-import '../shaders/image_vert.glsl' */
|
|
25
24
|
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";
|
|
@@ -176,14 +175,12 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
176
175
|
key: "buildModels",
|
|
177
176
|
value: function () {
|
|
178
177
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
179
|
-
var
|
|
180
|
-
|
|
178
|
+
var model;
|
|
181
179
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
182
180
|
while (1) {
|
|
183
181
|
switch (_context2.prev = _context2.next) {
|
|
184
182
|
case 0:
|
|
185
|
-
|
|
186
|
-
_context2.next = 3;
|
|
183
|
+
_context2.next = 2;
|
|
187
184
|
return this.layer.buildLayerModel({
|
|
188
185
|
moduleName: 'pointImage',
|
|
189
186
|
vertexShader: pointImageVert,
|
|
@@ -192,16 +189,14 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
192
189
|
depth: {
|
|
193
190
|
enable: false
|
|
194
191
|
},
|
|
195
|
-
primitive: gl.POINTS
|
|
196
|
-
blend: this.getBlend(),
|
|
197
|
-
stencil: getMask(mask, maskInside)
|
|
192
|
+
primitive: gl.POINTS
|
|
198
193
|
});
|
|
199
194
|
|
|
200
|
-
case
|
|
195
|
+
case 2:
|
|
201
196
|
model = _context2.sent;
|
|
202
197
|
return _context2.abrupt("return", [model]);
|
|
203
198
|
|
|
204
|
-
case
|
|
199
|
+
case 4:
|
|
205
200
|
case "end":
|
|
206
201
|
return _context2.stop();
|
|
207
202
|
}
|
|
@@ -258,12 +253,12 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
258
253
|
|
|
259
254
|
var shape = feature.shape;
|
|
260
255
|
|
|
261
|
-
var
|
|
256
|
+
var _ref2 = iconMap[shape] || {
|
|
262
257
|
x: -64,
|
|
263
258
|
y: -64
|
|
264
259
|
},
|
|
265
|
-
x =
|
|
266
|
-
y =
|
|
260
|
+
x = _ref2.x,
|
|
261
|
+
y = _ref2.y; // 非画布区域,默认的图标改为透明
|
|
267
262
|
|
|
268
263
|
|
|
269
264
|
return [x, y];
|
|
@@ -12,7 +12,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
12
12
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
13
|
|
|
14
14
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
15
|
-
import { getMask } from '@antv/l7-utils';
|
|
16
15
|
import { isNumber } from 'lodash';
|
|
17
16
|
import BaseModel from "../../core/BaseModel";
|
|
18
17
|
|
|
@@ -87,15 +86,13 @@ var NormalModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
87
86
|
key: "buildModels",
|
|
88
87
|
value: function () {
|
|
89
88
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
90
|
-
var
|
|
91
|
-
|
|
89
|
+
var model;
|
|
92
90
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
93
91
|
while (1) {
|
|
94
92
|
switch (_context2.prev = _context2.next) {
|
|
95
93
|
case 0:
|
|
96
|
-
_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;
|
|
97
94
|
this.layer.triangulation = PointTriangulation;
|
|
98
|
-
_context2.next =
|
|
95
|
+
_context2.next = 3;
|
|
99
96
|
return this.layer.buildLayerModel({
|
|
100
97
|
moduleName: 'pointNormal',
|
|
101
98
|
vertexShader: normalVert,
|
|
@@ -105,16 +102,14 @@ var NormalModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
105
102
|
enable: false
|
|
106
103
|
},
|
|
107
104
|
primitive: gl.POINTS,
|
|
108
|
-
blend: this.getBlend(),
|
|
109
|
-
stencil: getMask(mask, maskInside),
|
|
110
105
|
pick: false
|
|
111
106
|
});
|
|
112
107
|
|
|
113
|
-
case
|
|
108
|
+
case 3:
|
|
114
109
|
model = _context2.sent;
|
|
115
110
|
return _context2.abrupt("return", [model]);
|
|
116
111
|
|
|
117
|
-
case
|
|
112
|
+
case 5:
|
|
118
113
|
case "end":
|
|
119
114
|
return _context2.stop();
|
|
120
115
|
}
|
package/es/point/models/radar.js
CHANGED
|
@@ -11,7 +11,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
11
11
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
12
|
|
|
13
13
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
14
|
-
import { getMask } from '@antv/l7-utils';
|
|
15
14
|
import { isNumber } from 'lodash';
|
|
16
15
|
import BaseModel from "../../core/BaseModel";
|
|
17
16
|
import { SizeUnitType } from "../../core/interface";
|
|
@@ -100,14 +99,12 @@ var RadarModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
100
99
|
key: "buildModels",
|
|
101
100
|
value: function () {
|
|
102
101
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
103
|
-
var
|
|
104
|
-
|
|
102
|
+
var model;
|
|
105
103
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
106
104
|
while (1) {
|
|
107
105
|
switch (_context2.prev = _context2.next) {
|
|
108
106
|
case 0:
|
|
109
|
-
|
|
110
|
-
_context2.next = 3;
|
|
107
|
+
_context2.next = 2;
|
|
111
108
|
return this.layer.buildLayerModel({
|
|
112
109
|
moduleName: 'pointRadar',
|
|
113
110
|
vertexShader: pointFillVert,
|
|
@@ -115,16 +112,14 @@ var RadarModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
115
112
|
triangulation: PointFillTriangulation,
|
|
116
113
|
depth: {
|
|
117
114
|
enable: false
|
|
118
|
-
}
|
|
119
|
-
blend: this.getBlend(),
|
|
120
|
-
stencil: getMask(mask, maskInside)
|
|
115
|
+
}
|
|
121
116
|
});
|
|
122
117
|
|
|
123
|
-
case
|
|
118
|
+
case 2:
|
|
124
119
|
model = _context2.sent;
|
|
125
120
|
return _context2.abrupt("return", [model]);
|
|
126
121
|
|
|
127
|
-
case
|
|
122
|
+
case 4:
|
|
128
123
|
case "end":
|
|
129
124
|
return _context2.stop();
|
|
130
125
|
}
|
|
@@ -12,7 +12,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
12
12
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
13
|
|
|
14
14
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
15
|
-
import { getMask } from '@antv/l7-utils';
|
|
16
15
|
import { isNumber } from 'lodash';
|
|
17
16
|
import BaseModel from "../../core/BaseModel";
|
|
18
17
|
|
|
@@ -139,15 +138,13 @@ var SimplePointModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
139
138
|
key: "buildModels",
|
|
140
139
|
value: function () {
|
|
141
140
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
142
|
-
var
|
|
143
|
-
|
|
141
|
+
var model;
|
|
144
142
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
145
143
|
while (1) {
|
|
146
144
|
switch (_context2.prev = _context2.next) {
|
|
147
145
|
case 0:
|
|
148
|
-
_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;
|
|
149
146
|
this.layer.triangulation = PointTriangulation;
|
|
150
|
-
_context2.next =
|
|
147
|
+
_context2.next = 3;
|
|
151
148
|
return this.layer.buildLayerModel({
|
|
152
149
|
moduleName: 'pointSimple',
|
|
153
150
|
vertexShader: simplePointVert,
|
|
@@ -156,16 +153,14 @@ var SimplePointModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
156
153
|
depth: {
|
|
157
154
|
enable: false
|
|
158
155
|
},
|
|
159
|
-
primitive: gl.POINTS
|
|
160
|
-
blend: this.getBlend(),
|
|
161
|
-
stencil: getMask(mask, maskInside)
|
|
156
|
+
primitive: gl.POINTS
|
|
162
157
|
});
|
|
163
158
|
|
|
164
|
-
case
|
|
159
|
+
case 3:
|
|
165
160
|
model = _context2.sent;
|
|
166
161
|
return _context2.abrupt("return", [model]);
|
|
167
162
|
|
|
168
|
-
case
|
|
163
|
+
case 5:
|
|
169
164
|
case "end":
|
|
170
165
|
return _context2.stop();
|
|
171
166
|
}
|
package/es/point/models/text.js
CHANGED
|
@@ -21,14 +21,14 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
21
21
|
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; } }
|
|
22
22
|
|
|
23
23
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
24
|
-
import { boundsContains, calculateCentroid,
|
|
24
|
+
import { boundsContains, calculateCentroid, padBounds } from '@antv/l7-utils';
|
|
25
25
|
import { isEqual, isNumber } from 'lodash';
|
|
26
26
|
import BaseModel from "../../core/BaseModel";
|
|
27
27
|
import CollisionIndex from "../../utils/collision-index";
|
|
28
28
|
import { getGlyphQuads, shapeText } from "../../utils/symbol-layout";
|
|
29
29
|
|
|
30
30
|
/* babel-plugin-inline-import '../shaders/text_frag.glsl' */
|
|
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";
|
|
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 // \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";
|
|
32
32
|
|
|
33
33
|
/* babel-plugin-inline-import '../shaders/text_vert.glsl' */
|
|
34
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";
|
|
@@ -223,13 +223,13 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
223
223
|
key: "buildModels",
|
|
224
224
|
value: function () {
|
|
225
225
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
226
|
-
var _ref3, _ref3$
|
|
226
|
+
var _ref3, _ref3$textAllowOverla, textAllowOverlap, model;
|
|
227
227
|
|
|
228
228
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
229
229
|
while (1) {
|
|
230
230
|
switch (_context3.prev = _context3.next) {
|
|
231
231
|
case 0:
|
|
232
|
-
_ref3 = this.layer.getLayerConfig(), _ref3$
|
|
232
|
+
_ref3 = this.layer.getLayerConfig(), _ref3$textAllowOverla = _ref3.textAllowOverlap, textAllowOverlap = _ref3$textAllowOverla === void 0 ? false : _ref3$textAllowOverla; // this.mapping(); 重复调用
|
|
233
233
|
|
|
234
234
|
this.initGlyph(); //
|
|
235
235
|
|
|
@@ -247,9 +247,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
247
247
|
triangulation: TextTriangulation.bind(this),
|
|
248
248
|
depth: {
|
|
249
249
|
enable: false
|
|
250
|
-
}
|
|
251
|
-
blend: this.getBlend(),
|
|
252
|
-
stencil: getMask(mask, maskInside)
|
|
250
|
+
}
|
|
253
251
|
});
|
|
254
252
|
|
|
255
253
|
case 6:
|
|
@@ -699,15 +697,13 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
699
697
|
key: "reBuildModel",
|
|
700
698
|
value: function () {
|
|
701
699
|
var _reBuildModel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
702
|
-
var
|
|
703
|
-
|
|
700
|
+
var model;
|
|
704
701
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
705
702
|
while (1) {
|
|
706
703
|
switch (_context5.prev = _context5.next) {
|
|
707
704
|
case 0:
|
|
708
|
-
_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;
|
|
709
705
|
this.filterGlyphs();
|
|
710
|
-
_context5.next =
|
|
706
|
+
_context5.next = 3;
|
|
711
707
|
return this.layer.buildLayerModel({
|
|
712
708
|
moduleName: 'pointText',
|
|
713
709
|
vertexShader: textVert,
|
|
@@ -715,17 +711,15 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
715
711
|
triangulation: TextTriangulation.bind(this),
|
|
716
712
|
depth: {
|
|
717
713
|
enable: false
|
|
718
|
-
}
|
|
719
|
-
blend: this.getBlend(),
|
|
720
|
-
stencil: getMask(mask, maskInside)
|
|
714
|
+
}
|
|
721
715
|
});
|
|
722
716
|
|
|
723
|
-
case
|
|
717
|
+
case 3:
|
|
724
718
|
model = _context5.sent;
|
|
725
719
|
// TODO 渲染流程待修改
|
|
726
720
|
this.layer.models = [model];
|
|
727
721
|
|
|
728
|
-
case
|
|
722
|
+
case 5:
|
|
729
723
|
case "end":
|
|
730
724
|
return _context5.stop();
|
|
731
725
|
}
|