@antv/l7-layers 2.17.4 → 2.17.6
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/index.js +9 -31
- package/es/Geometry/models/billboard.js +51 -89
- package/es/Geometry/models/plane.js +81 -143
- package/es/Geometry/models/sprite.js +60 -118
- package/es/canvas/index.js +10 -33
- package/es/canvas/models/canvas.js +41 -97
- package/es/citybuliding/building.js +8 -27
- package/es/citybuliding/models/build.js +57 -82
- package/es/core/BaseLayer.js +325 -483
- package/es/core/BaseModel.js +51 -80
- package/es/core/CommonStyleAttribute.js +2 -5
- package/es/core/LayerPickService.js +21 -32
- package/es/core/TextureService.js +0 -13
- package/es/core/interface.js +17 -24
- package/es/core/shape/Path.js +13 -20
- package/es/core/shape/extrude.js +27 -39
- package/es/core/triangulation.js +99 -136
- package/es/earth/index.js +9 -33
- package/es/earth/models/atmosphere.js +30 -54
- package/es/earth/models/base.js +47 -85
- package/es/earth/models/bloomsphere.js +30 -54
- package/es/earth/utils.js +9 -13
- package/es/heatmap/index.js +10 -40
- package/es/heatmap/models/grid.js +28 -52
- package/es/heatmap/models/grid3d.js +28 -52
- package/es/heatmap/models/heatmap.js +92 -149
- package/es/heatmap/models/hexagon.js +28 -52
- package/es/heatmap/triangulation.js +0 -4
- package/es/image/index.js +9 -28
- package/es/image/models/image.js +66 -100
- package/es/index.js +9 -17
- package/es/line/index.js +9 -35
- package/es/line/models/arc.js +63 -112
- package/es/line/models/arc_3d.js +58 -102
- package/es/line/models/earthArc_3d.js +60 -105
- package/es/line/models/flow.js +36 -60
- package/es/line/models/great_circle.js +53 -94
- package/es/line/models/line.js +92 -144
- package/es/line/models/linearline.js +42 -74
- package/es/line/models/simpleLine.js +38 -67
- package/es/line/models/wall.js +52 -92
- package/es/line/shaders/dash/line_dash_vert.glsl +1 -2
- package/es/line/shaders/line_frag.glsl +1 -3
- package/es/line/shaders/line_vert.glsl +2 -0
- package/es/line/shaders/linear/line_linear_frag.glsl +1 -1
- package/es/mask/index.js +9 -28
- package/es/mask/models/fill.js +29 -54
- package/es/plugins/DataMappingPlugin.js +78 -114
- package/es/plugins/DataSourcePlugin.js +45 -68
- package/es/plugins/FeatureScalePlugin.js +67 -122
- package/es/plugins/LayerAnimateStylePlugin.js +0 -5
- package/es/plugins/LayerMaskPlugin.js +3 -11
- package/es/plugins/LayerModelPlugin.js +69 -118
- package/es/plugins/LayerStylePlugin.js +4 -9
- package/es/plugins/LightingPlugin.js +12 -18
- package/es/plugins/MultiPassRendererPlugin.js +11 -16
- package/es/plugins/PixelPickingPlugin.js +12 -21
- package/es/plugins/RegisterStyleAttributePlugin.js +5 -12
- package/es/plugins/ShaderUniformPlugin.js +13 -27
- package/es/plugins/UpdateModelPlugin.js +0 -5
- package/es/plugins/UpdateStyleAttributePlugin.js +5 -11
- package/es/point/index.js +26 -78
- package/es/point/models/earthExtrude.js +58 -95
- package/es/point/models/earthFill.js +52 -80
- package/es/point/models/extrude.js +57 -94
- package/es/point/models/fill.js +56 -81
- package/es/point/models/fillmage.js +60 -100
- package/es/point/models/image.js +47 -83
- package/es/point/models/index.js +2 -2
- package/es/point/models/normal.js +30 -54
- package/es/point/models/radar.js +38 -63
- package/es/point/models/simplePoint.js +38 -62
- package/es/point/models/text.js +199 -296
- package/es/point/shape/extrude.js +4 -13
- package/es/polygon/index.js +11 -41
- package/es/polygon/models/extrude.js +87 -135
- package/es/polygon/models/fill.js +50 -79
- package/es/polygon/models/index.js +3 -2
- package/es/polygon/models/ocean.js +42 -76
- package/es/polygon/models/water.js +37 -71
- package/es/raster/buffers/triangulation.js +2 -4
- package/es/raster/index.js +9 -32
- package/es/raster/models/raster.js +80 -116
- package/es/raster/models/rasterRgb.js +84 -127
- package/es/raster/models/rasterTerrainRgb.js +56 -84
- package/es/tile/interaction/getRasterData.js +14 -20
- package/es/tile/interaction/utils.js +7 -9
- package/es/tile/manager/base.js +63 -96
- package/es/tile/service/TileLayerService.js +33 -55
- package/es/tile/service/TilePickService.js +26 -40
- package/es/tile/service/TileSourceService.js +3 -7
- package/es/tile/tileFactory/DebugTile.js +29 -46
- package/es/tile/tileFactory/ImageTile.js +20 -38
- package/es/tile/tileFactory/MaskTile.js +22 -43
- package/es/tile/tileFactory/RasterRGBTile.js +22 -42
- package/es/tile/tileFactory/RasterTerrainRGBTile.js +20 -38
- package/es/tile/tileFactory/RasterTile.js +30 -53
- package/es/tile/tileFactory/Tile.js +63 -97
- package/es/tile/tileFactory/VectorTile.js +41 -68
- package/es/tile/tileFactory/index.js +0 -11
- package/es/tile/tileFactory/layers/TileDebugLayer.js +6 -27
- package/es/tile/tileFactory/util.js +0 -3
- package/es/tile/tileLayer/BaseLayer.js +105 -146
- package/es/tile/utils.js +1 -1
- package/es/utils/blend.js +0 -2
- package/es/utils/collision-index.js +9 -16
- package/es/utils/extrude_polyline.js +101 -149
- package/es/utils/grid-index.js +2 -27
- package/es/utils/identityScale.js +0 -8
- package/es/utils/layerData.js +30 -44
- package/es/utils/multiPassRender.js +11 -13
- package/es/utils/polylineNormal.js +31 -37
- package/es/utils/simpleLine.js +2 -16
- package/es/utils/stencil.js +2 -3
- package/es/utils/symbol-layout.js +27 -53
- package/es/wind/index.js +9 -29
- package/es/wind/models/utils.js +26 -51
- package/es/wind/models/wind.js +101 -147
- package/es/wind/models/windRender.js +53 -66
- package/lib/Geometry/index.js +9 -38
- package/lib/Geometry/models/billboard.js +51 -97
- package/lib/Geometry/models/index.js +0 -5
- package/lib/Geometry/models/plane.js +79 -151
- package/lib/Geometry/models/sprite.js +60 -127
- package/lib/canvas/index.js +10 -40
- package/lib/canvas/models/canvas.js +41 -101
- package/lib/canvas/models/index.js +0 -3
- package/lib/citybuliding/building.js +8 -35
- package/lib/citybuliding/models/build.js +57 -92
- package/lib/core/BaseLayer.js +325 -474
- package/lib/core/BaseModel.js +51 -90
- package/lib/core/CommonStyleAttribute.js +2 -7
- package/lib/core/LayerPickService.js +21 -37
- package/lib/core/TextureService.js +0 -16
- package/lib/core/interface.js +21 -31
- package/lib/core/schema.js +0 -1
- package/lib/core/shape/Path.js +14 -31
- package/lib/core/shape/extrude.js +27 -62
- package/lib/core/triangulation.js +98 -177
- package/lib/earth/index.js +9 -43
- package/lib/earth/models/atmosphere.js +30 -63
- package/lib/earth/models/base.js +47 -90
- package/lib/earth/models/bloomsphere.js +30 -63
- package/lib/earth/utils.js +7 -31
- package/lib/heatmap/index.js +10 -48
- package/lib/heatmap/models/grid.js +28 -60
- package/lib/heatmap/models/grid3d.js +28 -60
- package/lib/heatmap/models/heatmap.js +92 -166
- package/lib/heatmap/models/hexagon.js +28 -60
- package/lib/heatmap/models/index.js +0 -6
- package/lib/heatmap/triangulation.js +0 -5
- package/lib/image/index.js +9 -36
- package/lib/image/models/image.js +66 -109
- package/lib/image/models/index.js +0 -3
- package/lib/index.js +7 -61
- package/lib/line/index.js +9 -40
- package/lib/line/models/arc.js +61 -122
- package/lib/line/models/arc_3d.js +56 -113
- package/lib/line/models/earthArc_3d.js +58 -115
- package/lib/line/models/flow.js +36 -70
- package/lib/line/models/great_circle.js +53 -104
- package/lib/line/models/index.js +0 -11
- package/lib/line/models/line.js +90 -152
- package/lib/line/models/linearline.js +42 -86
- package/lib/line/models/simpleLine.js +38 -77
- package/lib/line/models/wall.js +52 -103
- package/lib/line/shaders/dash/line_dash_vert.glsl +1 -2
- package/lib/line/shaders/line_frag.glsl +1 -3
- package/lib/line/shaders/line_vert.glsl +2 -0
- package/lib/line/shaders/linear/line_linear_frag.glsl +1 -1
- package/lib/mask/index.js +9 -36
- package/lib/mask/models/fill.js +29 -63
- package/lib/mask/models/index.js +0 -3
- package/lib/plugins/DataMappingPlugin.js +78 -125
- package/lib/plugins/DataSourcePlugin.js +45 -76
- package/lib/plugins/FeatureScalePlugin.js +67 -138
- package/lib/plugins/LayerAnimateStylePlugin.js +0 -10
- package/lib/plugins/LayerMaskPlugin.js +4 -17
- package/lib/plugins/LayerModelPlugin.js +70 -127
- package/lib/plugins/LayerStylePlugin.js +5 -14
- package/lib/plugins/LightingPlugin.js +12 -25
- package/lib/plugins/MultiPassRendererPlugin.js +11 -22
- package/lib/plugins/PixelPickingPlugin.js +12 -27
- package/lib/plugins/RegisterStyleAttributePlugin.js +5 -19
- package/lib/plugins/ShaderUniformPlugin.js +13 -34
- package/lib/plugins/UpdateModelPlugin.js +1 -10
- package/lib/plugins/UpdateStyleAttributePlugin.js +5 -16
- package/lib/point/index.js +26 -83
- package/lib/point/models/earthExtrude.js +58 -106
- package/lib/point/models/earthFill.js +52 -110
- package/lib/point/models/extrude.js +57 -103
- package/lib/point/models/fill.js +54 -90
- package/lib/point/models/fillmage.js +58 -107
- package/lib/point/models/image.js +47 -92
- package/lib/point/models/index.js +1 -12
- package/lib/point/models/normal.js +30 -64
- package/lib/point/models/radar.js +38 -72
- package/lib/point/models/simplePoint.js +38 -72
- package/lib/point/models/text.js +199 -305
- package/lib/point/shape/extrude.js +4 -20
- package/lib/polygon/index.js +11 -48
- package/lib/polygon/models/extrude.js +87 -146
- package/lib/polygon/models/fill.js +50 -89
- package/lib/polygon/models/index.js +2 -14
- package/lib/polygon/models/ocean.js +42 -88
- package/lib/polygon/models/water.js +37 -82
- package/lib/raster/buffers/triangulation.js +3 -7
- package/lib/raster/index.js +9 -40
- package/lib/raster/models/index.js +0 -5
- package/lib/raster/models/raster.js +80 -125
- package/lib/raster/models/rasterRgb.js +84 -139
- package/lib/raster/models/rasterTerrainRgb.js +56 -93
- package/lib/tile/interaction/getRasterData.js +14 -25
- package/lib/tile/interaction/utils.js +7 -19
- package/lib/tile/manager/base.js +63 -104
- package/lib/tile/service/TileLayerService.js +33 -60
- package/lib/tile/service/TilePickService.js +26 -48
- package/lib/tile/service/TileSourceService.js +2 -16
- package/lib/tile/style/utils.js +0 -3
- package/lib/tile/tileFactory/DebugTile.js +29 -54
- package/lib/tile/tileFactory/ImageTile.js +20 -46
- package/lib/tile/tileFactory/MaskTile.js +22 -51
- package/lib/tile/tileFactory/RasterRGBTile.js +22 -50
- package/lib/tile/tileFactory/RasterTerrainRGBTile.js +20 -46
- package/lib/tile/tileFactory/RasterTile.js +30 -63
- package/lib/tile/tileFactory/Tile.js +63 -102
- package/lib/tile/tileFactory/VectorTile.js +41 -76
- package/lib/tile/tileFactory/index.js +0 -25
- package/lib/tile/tileFactory/layers/TileDebugLayer.js +6 -32
- package/lib/tile/tileFactory/util.js +0 -9
- package/lib/tile/tileLayer/BaseLayer.js +105 -153
- package/lib/tile/utils.js +1 -5
- package/lib/utils/blend.js +0 -5
- package/lib/utils/collision-index.js +9 -25
- package/lib/utils/extrude_polyline.js +101 -181
- package/lib/utils/grid-index.js +2 -28
- package/lib/utils/identityScale.js +0 -9
- package/lib/utils/layerData.js +30 -49
- package/lib/utils/multiPassRender.js +11 -16
- package/lib/utils/polylineNormal.js +31 -66
- package/lib/utils/simpleLine.js +2 -21
- package/lib/utils/stencil.js +0 -4
- package/lib/utils/symbol-layout.js +27 -55
- package/lib/wind/index.js +9 -37
- package/lib/wind/models/index.js +0 -3
- package/lib/wind/models/utils.js +26 -62
- package/lib/wind/models/wind.js +101 -157
- package/lib/wind/models/windRender.js +53 -71
- package/lib/wind/models/windShader.js +0 -1
- package/package.json +7 -7
|
@@ -7,62 +7,44 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
|
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
9
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
|
-
|
|
11
10
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
-
|
|
13
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; } }
|
|
14
|
-
|
|
15
12
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
16
13
|
import { getCullFace } from '@antv/l7-utils';
|
|
17
14
|
import BaseModel from "../../core/BaseModel";
|
|
18
15
|
import { SizeUnitType } from "../../core/interface";
|
|
19
|
-
import { PointFillTriangulation } from "../../core/triangulation";
|
|
20
|
-
|
|
16
|
+
import { PointFillTriangulation } from "../../core/triangulation";
|
|
17
|
+
// static pointLayer shader - not support animate
|
|
21
18
|
/* babel-plugin-inline-import '../shaders/image/fillImage_frag.glsl' */
|
|
22
19
|
var pointFillFrag = "uniform sampler2D u_texture;\nuniform vec2 u_textSize;\nuniform float u_opacity : 1;\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv;\n\nvoid main() {\n\n vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;\n gl_FragColor = texture2D(u_texture, pos);\n gl_FragColor.a *= u_opacity;\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
23
|
-
|
|
24
20
|
/* babel-plugin-inline-import '../shaders/image/fillImage_vert.glsl' */
|
|
25
21
|
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute vec2 a_Uv;\nattribute float a_Rotate;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform mat2 u_RotateMatrix;\nuniform int u_size_unit;\n\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv; // icon \u8D34\u56FE\u7684 uv \u5750\u6807\n\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\nuniform float u_opacity : 1;\nuniform vec2 u_offsets;\n\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n v_uv = (a_Extrude.xy + 1.0)/2.0;\n v_uv.y = 1.0 - v_uv.y;\n v_Iconuv = a_Uv;\n\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n float newSize = a_Size;\n if(u_size_unit == 1) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\n // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec2 offset = (rotation_matrix * u_RotateMatrix * extrude.xy * (newSize) + u_offsets);\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\n\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // height fixed\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp *vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
26
|
-
|
|
27
22
|
var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
28
23
|
_inherits(FillImageModel, _BaseModel);
|
|
29
|
-
|
|
30
24
|
var _super = _createSuper(FillImageModel);
|
|
31
|
-
|
|
32
25
|
function FillImageModel() {
|
|
33
26
|
var _this;
|
|
34
|
-
|
|
35
27
|
_classCallCheck(this, FillImageModel);
|
|
36
|
-
|
|
37
28
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
38
29
|
args[_key] = arguments[_key];
|
|
39
30
|
}
|
|
40
|
-
|
|
41
31
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
42
|
-
|
|
43
32
|
_defineProperty(_assertThisInitialized(_this), "meter2coord", 1);
|
|
44
|
-
|
|
45
33
|
_defineProperty(_assertThisInitialized(_this), "isMeter", false);
|
|
46
|
-
|
|
47
34
|
_defineProperty(_assertThisInitialized(_this), "radian", 0);
|
|
48
|
-
|
|
49
35
|
_defineProperty(_assertThisInitialized(_this), "updateTexture", function () {
|
|
50
36
|
var createTexture2D = _this.rendererService.createTexture2D;
|
|
51
|
-
|
|
52
37
|
if (_this.texture) {
|
|
53
38
|
_this.texture.update({
|
|
54
39
|
data: _this.iconService.getCanvas(),
|
|
55
40
|
mag: 'linear',
|
|
56
41
|
min: 'linear mipmap nearest',
|
|
57
42
|
mipmap: true
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
|
|
43
|
+
});
|
|
44
|
+
// 更新完纹理后在更新的图层的时候需要更新所有的图层
|
|
61
45
|
_this.layerService.throttleRenderLayers();
|
|
62
|
-
|
|
63
46
|
return;
|
|
64
47
|
}
|
|
65
|
-
|
|
66
48
|
_this.texture = createTexture2D({
|
|
67
49
|
data: _this.iconService.getCanvas(),
|
|
68
50
|
mag: gl.LINEAR,
|
|
@@ -73,27 +55,25 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
73
55
|
mipmap: true
|
|
74
56
|
});
|
|
75
57
|
});
|
|
76
|
-
|
|
77
58
|
return _this;
|
|
78
59
|
}
|
|
79
|
-
|
|
80
60
|
_createClass(FillImageModel, [{
|
|
81
61
|
key: "getUninforms",
|
|
82
|
-
value:
|
|
62
|
+
value:
|
|
63
|
+
// 旋转的弧度
|
|
83
64
|
function getUninforms() {
|
|
84
65
|
var _ref = this.layer.getLayerConfig(),
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
66
|
+
_ref$opacity = _ref.opacity,
|
|
67
|
+
opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
|
|
68
|
+
_ref$offsets = _ref.offsets,
|
|
69
|
+
offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets,
|
|
70
|
+
rotation = _ref.rotation,
|
|
71
|
+
_ref$raisingHeight = _ref.raisingHeight,
|
|
72
|
+
raisingHeight = _ref$raisingHeight === void 0 ? 0.0 : _ref$raisingHeight,
|
|
73
|
+
_ref$heightfixed = _ref.heightfixed,
|
|
74
|
+
heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed,
|
|
75
|
+
_ref$unit = _ref.unit,
|
|
76
|
+
unit = _ref$unit === void 0 ? 'pixel' : _ref$unit;
|
|
97
77
|
if (this.rendererService.getDirty()) {
|
|
98
78
|
this.texture.bind();
|
|
99
79
|
}
|
|
@@ -104,15 +84,11 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
104
84
|
* GAODE2.x -1
|
|
105
85
|
* GAODE1.x -1
|
|
106
86
|
*/
|
|
107
|
-
|
|
108
|
-
|
|
109
87
|
var rotateFlag = 1;
|
|
110
|
-
|
|
111
88
|
if (this.mapService.version === 'GAODE2.x' || this.mapService.version === 'GAODE1.x') {
|
|
112
89
|
rotateFlag = -1;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
90
|
+
}
|
|
91
|
+
// 控制图标的旋转角度(绕 Z 轴旋转)
|
|
116
92
|
this.radian = rotation !== undefined ? rotateFlag * Math.PI * rotation / 180 : rotateFlag * Math.PI * (this.mapService.getRotation() % 360) / 180;
|
|
117
93
|
return {
|
|
118
94
|
u_raisingHeight: Number(raisingHeight),
|
|
@@ -135,25 +111,20 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
135
111
|
value: function () {
|
|
136
112
|
var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
137
113
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
138
|
-
while (1) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
case "end":
|
|
147
|
-
return _context.stop();
|
|
148
|
-
}
|
|
114
|
+
while (1) switch (_context.prev = _context.next) {
|
|
115
|
+
case 0:
|
|
116
|
+
this.iconService.on('imageUpdate', this.updateTexture);
|
|
117
|
+
this.updateTexture();
|
|
118
|
+
return _context.abrupt("return", this.buildModels());
|
|
119
|
+
case 3:
|
|
120
|
+
case "end":
|
|
121
|
+
return _context.stop();
|
|
149
122
|
}
|
|
150
123
|
}, _callee, this);
|
|
151
124
|
}));
|
|
152
|
-
|
|
153
125
|
function initModels() {
|
|
154
126
|
return _initModels.apply(this, arguments);
|
|
155
127
|
}
|
|
156
|
-
|
|
157
128
|
return initModels;
|
|
158
129
|
}()
|
|
159
130
|
}, {
|
|
@@ -162,56 +133,49 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
162
133
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
163
134
|
var model;
|
|
164
135
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
165
|
-
while (1) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
case 4:
|
|
188
|
-
case "end":
|
|
189
|
-
return _context2.stop();
|
|
190
|
-
}
|
|
136
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
137
|
+
case 0:
|
|
138
|
+
_context2.next = 2;
|
|
139
|
+
return this.layer.buildLayerModel({
|
|
140
|
+
moduleName: 'pointFillImage',
|
|
141
|
+
vertexShader: pointFillVert,
|
|
142
|
+
fragmentShader: pointFillFrag,
|
|
143
|
+
triangulation: PointFillTriangulation,
|
|
144
|
+
depth: {
|
|
145
|
+
enable: false
|
|
146
|
+
},
|
|
147
|
+
cull: {
|
|
148
|
+
enable: true,
|
|
149
|
+
face: getCullFace(this.mapService.version)
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
case 2:
|
|
153
|
+
model = _context2.sent;
|
|
154
|
+
return _context2.abrupt("return", [model]);
|
|
155
|
+
case 4:
|
|
156
|
+
case "end":
|
|
157
|
+
return _context2.stop();
|
|
191
158
|
}
|
|
192
159
|
}, _callee2, this);
|
|
193
160
|
}));
|
|
194
|
-
|
|
195
161
|
function buildModels() {
|
|
196
162
|
return _buildModels.apply(this, arguments);
|
|
197
163
|
}
|
|
198
|
-
|
|
199
164
|
return buildModels;
|
|
200
165
|
}()
|
|
201
166
|
}, {
|
|
202
167
|
key: "clearModels",
|
|
203
168
|
value: function clearModels() {
|
|
204
169
|
var _this$texture;
|
|
205
|
-
|
|
206
170
|
this.iconService.off('imageUpdate', this.updateTexture);
|
|
207
171
|
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
208
|
-
}
|
|
172
|
+
}
|
|
209
173
|
|
|
174
|
+
// overwrite baseModel func
|
|
210
175
|
}, {
|
|
211
176
|
key: "registerBuiltinAttributes",
|
|
212
177
|
value: function registerBuiltinAttributes() {
|
|
213
178
|
var _this2 = this;
|
|
214
|
-
|
|
215
179
|
this.styleAttributeService.registerStyleAttribute({
|
|
216
180
|
name: 'rotate',
|
|
217
181
|
type: AttributeType.Attribute,
|
|
@@ -225,7 +189,7 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
225
189
|
size: 1,
|
|
226
190
|
update: function update(feature) {
|
|
227
191
|
var _feature$rotate = feature.rotate,
|
|
228
|
-
|
|
192
|
+
rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
|
|
229
193
|
return Array.isArray(rotate) ? [rotate[0]] : [rotate];
|
|
230
194
|
}
|
|
231
195
|
}
|
|
@@ -244,16 +208,13 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
244
208
|
size: 2,
|
|
245
209
|
update: function update(feature) {
|
|
246
210
|
var iconMap = _this2.iconService.getIconMap();
|
|
247
|
-
|
|
248
211
|
var shape = feature.shape;
|
|
249
|
-
|
|
250
212
|
var _ref2 = iconMap[shape] || {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
213
|
+
x: -64,
|
|
214
|
+
y: -64
|
|
215
|
+
},
|
|
216
|
+
x = _ref2.x,
|
|
217
|
+
y = _ref2.y;
|
|
257
218
|
return [x, y];
|
|
258
219
|
}
|
|
259
220
|
}
|
|
@@ -276,8 +237,9 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
276
237
|
return [extrude[extrudeIndex], extrude[extrudeIndex + 1], extrude[extrudeIndex + 2]];
|
|
277
238
|
}
|
|
278
239
|
}
|
|
279
|
-
});
|
|
240
|
+
});
|
|
280
241
|
|
|
242
|
+
// point layer size;
|
|
281
243
|
this.styleAttributeService.registerStyleAttribute({
|
|
282
244
|
name: 'size',
|
|
283
245
|
type: AttributeType.Attribute,
|
|
@@ -292,15 +254,13 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
292
254
|
size: 1,
|
|
293
255
|
update: function update(feature) {
|
|
294
256
|
var _feature$size = feature.size,
|
|
295
|
-
|
|
257
|
+
size = _feature$size === void 0 ? 5 : _feature$size;
|
|
296
258
|
return Array.isArray(size) ? [size[0]] : [size];
|
|
297
259
|
}
|
|
298
260
|
}
|
|
299
261
|
});
|
|
300
262
|
}
|
|
301
263
|
}]);
|
|
302
|
-
|
|
303
264
|
return FillImageModel;
|
|
304
265
|
}(BaseModel);
|
|
305
|
-
|
|
306
266
|
export { FillImageModel as default };
|
package/es/point/models/image.js
CHANGED
|
@@ -7,57 +7,42 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
|
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
9
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
|
-
|
|
11
10
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
-
|
|
13
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; } }
|
|
14
|
-
|
|
15
12
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
16
13
|
import BaseModel from "../../core/BaseModel";
|
|
17
14
|
import { PointImageTriangulation } from "../../core/triangulation";
|
|
18
|
-
|
|
19
15
|
/* babel-plugin-inline-import '../shaders/image_frag.glsl' */
|
|
20
16
|
var pointImageFrag = "\nuniform sampler2D u_texture;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nuniform vec2 u_textSize;\nuniform float u_opacity : 1;\n\n#pragma include \"picking\"\n\nvoid main(){\n vec2 pos = v_uv / u_textSize + gl_PointCoord / u_textSize * 64.;\n vec4 textureColor;\n\n // Y = 0.299R + 0.587G + 0.114B // \u4EAE\u5EA6\u63D0\u53D6\n \n textureColor = texture2D(u_texture, pos);\n\n // Tip: \u53BB\u9664\u8FB9\u7F18\u90E8\u5206 mipmap \u5BFC\u81F4\u7684\u6DF7\u5408\u53D8\u6697\n float fragmengTocenter = distance(vec2(0.5), gl_PointCoord);\n if(fragmengTocenter >= 0.5) {\n float luma = 0.299 * textureColor.r + 0.587 * textureColor.g + 0.114 * textureColor.b;\n textureColor.a *= luma;\n }\n \n \n\n if(all(lessThan(v_color, vec4(1.0+0.00001))) && all(greaterThan(v_color, vec4(1.0-0.00001))) || v_color==vec4(1.0)){\n gl_FragColor= textureColor;\n }else {\n gl_FragColor= step(0.01, textureColor.z) * v_color;\n }\n\n gl_FragColor.a = gl_FragColor.a * u_opacity;\n \n if (gl_FragColor.a < 0.01) {\n discard;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
21
|
-
|
|
22
17
|
/* babel-plugin-inline-import '../shaders/image_vert.glsl' */
|
|
23
18
|
var pointImageVert = "precision highp float;\nattribute vec3 a_Position;\nattribute vec4 a_Color;\nattribute vec2 a_Uv;\nattribute float a_Size;\nvarying vec4 v_color;\nvarying vec2 v_uv;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform vec2 u_offsets;\n\nuniform float u_opacity : 1;\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n v_color = a_Color;\n v_uv = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n \n vec2 offset = project_pixel(u_offsets);\n\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // false\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n\n gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;\n setPickingColor(a_PickingColor);\n}\n";
|
|
24
|
-
|
|
25
19
|
var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
26
20
|
_inherits(ImageModel, _BaseModel);
|
|
27
|
-
|
|
28
21
|
var _super = _createSuper(ImageModel);
|
|
29
|
-
|
|
30
22
|
function ImageModel() {
|
|
31
23
|
var _this;
|
|
32
|
-
|
|
33
24
|
_classCallCheck(this, ImageModel);
|
|
34
|
-
|
|
35
25
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
36
26
|
args[_key] = arguments[_key];
|
|
37
27
|
}
|
|
38
|
-
|
|
39
28
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
40
|
-
|
|
41
29
|
_defineProperty(_assertThisInitialized(_this), "updateTexture", function () {
|
|
42
30
|
var createTexture2D = _this.rendererService.createTexture2D;
|
|
43
|
-
|
|
44
31
|
if (_this.texture) {
|
|
45
32
|
_this.texture.update({
|
|
46
33
|
data: _this.iconService.getCanvas(),
|
|
47
34
|
mag: 'linear',
|
|
48
35
|
min: 'linear mipmap nearest',
|
|
49
36
|
mipmap: true
|
|
50
|
-
});
|
|
37
|
+
});
|
|
38
|
+
// 更新完纹理后在更新的图层的时候需要更新所有的图层
|
|
51
39
|
// this.layer.layerModelNeedUpdate = true;
|
|
52
|
-
|
|
53
|
-
|
|
54
40
|
setTimeout(function () {
|
|
55
41
|
// 延迟渲染
|
|
56
42
|
_this.layerService.throttleRenderLayers();
|
|
57
43
|
});
|
|
58
44
|
return;
|
|
59
45
|
}
|
|
60
|
-
|
|
61
46
|
_this.texture = createTexture2D({
|
|
62
47
|
data: _this.iconService.getCanvas(),
|
|
63
48
|
mag: gl.LINEAR,
|
|
@@ -68,28 +53,25 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
68
53
|
mipmap: true
|
|
69
54
|
});
|
|
70
55
|
});
|
|
71
|
-
|
|
72
56
|
return _this;
|
|
73
57
|
}
|
|
74
|
-
|
|
75
58
|
_createClass(ImageModel, [{
|
|
76
59
|
key: "getUninforms",
|
|
77
60
|
value: function getUninforms() {
|
|
78
61
|
var _ref = this.layer.getLayerConfig(),
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
62
|
+
_ref$opacity = _ref.opacity,
|
|
63
|
+
opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
|
|
64
|
+
_ref$offsets = _ref.offsets,
|
|
65
|
+
offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets,
|
|
66
|
+
_ref$raisingHeight = _ref.raisingHeight,
|
|
67
|
+
raisingHeight = _ref$raisingHeight === void 0 ? 0 : _ref$raisingHeight,
|
|
68
|
+
_ref$heightfixed = _ref.heightfixed,
|
|
69
|
+
heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed;
|
|
70
|
+
|
|
71
|
+
// ThreeJS 图层兼容
|
|
89
72
|
if (this.rendererService.getDirty()) {
|
|
90
73
|
this.texture.bind();
|
|
91
74
|
}
|
|
92
|
-
|
|
93
75
|
return {
|
|
94
76
|
u_raisingHeight: Number(raisingHeight),
|
|
95
77
|
u_heightfixed: Number(heightfixed),
|
|
@@ -104,32 +86,26 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
104
86
|
value: function () {
|
|
105
87
|
var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
106
88
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
107
|
-
while (1) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
case "end":
|
|
116
|
-
return _context.stop();
|
|
117
|
-
}
|
|
89
|
+
while (1) switch (_context.prev = _context.next) {
|
|
90
|
+
case 0:
|
|
91
|
+
this.iconService.on('imageUpdate', this.updateTexture);
|
|
92
|
+
this.updateTexture();
|
|
93
|
+
return _context.abrupt("return", this.buildModels());
|
|
94
|
+
case 3:
|
|
95
|
+
case "end":
|
|
96
|
+
return _context.stop();
|
|
118
97
|
}
|
|
119
98
|
}, _callee, this);
|
|
120
99
|
}));
|
|
121
|
-
|
|
122
100
|
function initModels() {
|
|
123
101
|
return _initModels.apply(this, arguments);
|
|
124
102
|
}
|
|
125
|
-
|
|
126
103
|
return initModels;
|
|
127
104
|
}()
|
|
128
105
|
}, {
|
|
129
106
|
key: "clearModels",
|
|
130
107
|
value: function clearModels() {
|
|
131
108
|
var _this$texture;
|
|
132
|
-
|
|
133
109
|
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
134
110
|
this.iconService.off('imageUpdate', this.updateTexture);
|
|
135
111
|
}
|
|
@@ -139,44 +115,37 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
139
115
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
140
116
|
var model;
|
|
141
117
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
142
|
-
while (1) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
case 4:
|
|
162
|
-
case "end":
|
|
163
|
-
return _context2.stop();
|
|
164
|
-
}
|
|
118
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
119
|
+
case 0:
|
|
120
|
+
_context2.next = 2;
|
|
121
|
+
return this.layer.buildLayerModel({
|
|
122
|
+
moduleName: 'pointImage',
|
|
123
|
+
vertexShader: pointImageVert,
|
|
124
|
+
fragmentShader: pointImageFrag,
|
|
125
|
+
triangulation: PointImageTriangulation,
|
|
126
|
+
depth: {
|
|
127
|
+
enable: false
|
|
128
|
+
},
|
|
129
|
+
primitive: gl.POINTS
|
|
130
|
+
});
|
|
131
|
+
case 2:
|
|
132
|
+
model = _context2.sent;
|
|
133
|
+
return _context2.abrupt("return", [model]);
|
|
134
|
+
case 4:
|
|
135
|
+
case "end":
|
|
136
|
+
return _context2.stop();
|
|
165
137
|
}
|
|
166
138
|
}, _callee2, this);
|
|
167
139
|
}));
|
|
168
|
-
|
|
169
140
|
function buildModels() {
|
|
170
141
|
return _buildModels.apply(this, arguments);
|
|
171
142
|
}
|
|
172
|
-
|
|
173
143
|
return buildModels;
|
|
174
144
|
}()
|
|
175
145
|
}, {
|
|
176
146
|
key: "registerBuiltinAttributes",
|
|
177
147
|
value: function registerBuiltinAttributes() {
|
|
178
148
|
var _this2 = this;
|
|
179
|
-
|
|
180
149
|
// point layer size;
|
|
181
150
|
this.styleAttributeService.registerStyleAttribute({
|
|
182
151
|
name: 'size',
|
|
@@ -192,12 +161,13 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
192
161
|
size: 1,
|
|
193
162
|
update: function update(feature) {
|
|
194
163
|
var _feature$size = feature.size,
|
|
195
|
-
|
|
164
|
+
size = _feature$size === void 0 ? 5 : _feature$size;
|
|
196
165
|
return Array.isArray(size) ? [size[0]] : [size];
|
|
197
166
|
}
|
|
198
167
|
}
|
|
199
|
-
});
|
|
168
|
+
});
|
|
200
169
|
|
|
170
|
+
// point layer size;
|
|
201
171
|
this.styleAttributeService.registerStyleAttribute({
|
|
202
172
|
name: 'uv',
|
|
203
173
|
type: AttributeType.Attribute,
|
|
@@ -212,25 +182,19 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
212
182
|
size: 2,
|
|
213
183
|
update: function update(feature) {
|
|
214
184
|
var iconMap = _this2.iconService.getIconMap();
|
|
215
|
-
|
|
216
185
|
var shape = feature.shape;
|
|
217
|
-
|
|
218
186
|
var _ref2 = iconMap[shape] || {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
187
|
+
x: -64,
|
|
188
|
+
y: -64
|
|
189
|
+
},
|
|
190
|
+
x = _ref2.x,
|
|
191
|
+
y = _ref2.y; // 非画布区域,默认的图标改为透明
|
|
226
192
|
return [x, y];
|
|
227
193
|
}
|
|
228
194
|
}
|
|
229
195
|
});
|
|
230
196
|
}
|
|
231
197
|
}]);
|
|
232
|
-
|
|
233
198
|
return ImageModel;
|
|
234
199
|
}(BaseModel);
|
|
235
|
-
|
|
236
200
|
export { ImageModel as default };
|
package/es/point/models/index.js
CHANGED