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