@antv/l7-layers 2.17.2 → 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 +114 -64
- 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 +138 -86
- package/es/line/models/linearline.js +76 -43
- package/es/line/models/simpleLine.js +69 -39
- 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 +124 -62
- 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 +146 -84
- package/lib/line/models/linearline.js +88 -43
- package/lib/line/models/simpleLine.js +79 -39
- 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
|
@@ -9,56 +9,75 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
|
|
|
9
9
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
10
10
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
11
11
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
12
|
+
|
|
12
13
|
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); }; }
|
|
14
|
+
|
|
13
15
|
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; } }
|
|
16
|
+
|
|
14
17
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
15
|
-
import { Version } from '@antv/l7-maps';
|
|
16
|
-
|
|
18
|
+
import { Version } from '@antv/l7-maps'; // import { mat4, vec3 } from 'gl-matrix';
|
|
19
|
+
|
|
17
20
|
import BaseModel from "../../core/BaseModel";
|
|
21
|
+
|
|
18
22
|
/* babel-plugin-inline-import '../shaders/plane_frag.glsl' */
|
|
19
23
|
var planeFrag = "\nuniform sampler2D u_texture;\nuniform float u_mapFlag;\nuniform float u_opacity;\n\nvarying vec3 v_Color;\nvarying vec2 v_uv;\nvarying float v_clip;\n\n#pragma include \"picking\"\nvoid main() {\n // gl_FragColor = vec4(v_Color, u_opacity);\n if(u_mapFlag > 0.0) {\n gl_FragColor = texture2D(u_texture, vec2(v_uv.x, 1.0 - v_uv.y));\n gl_FragColor.a *= u_opacity;\n } else {\n // gl_FragColor = vec4(v_uv, 0.0, u_opacity);\n gl_FragColor = vec4(v_Color, u_opacity);\n }\n gl_FragColor.a *= v_clip;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
24
|
+
|
|
20
25
|
/* babel-plugin-inline-import '../shaders/plane_vert.glsl' */
|
|
21
26
|
var planeVert = "precision highp float;\nuniform mat4 u_ModelMatrix;\n\nuniform mat4 u_Mvp;\nuniform float u_opacity;\nuniform float u_terrainClipHeight;\n\nattribute vec3 a_Position;\nattribute vec2 a_Uv;\nattribute vec3 a_Color;\n\nvarying vec3 v_Color;\nvarying vec2 v_uv;\nvarying float v_clip;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\nvoid main() {\n v_Color = a_Color;\n v_uv = a_Uv;\n \n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n v_clip = 1.0;\n if(a_Position.z < u_terrainClipHeight) {\n v_clip = 0.0;\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy,0., 1.0));\n\n // float x = 1.0;\n // float y = 0.0;\n // float z = 0.0;\n // mat3 translateMatrix = mat3(\n // 1.0, 0.0, 0.0 \n // 0.0, 1.0, 0.0\n // -project_pos.x, -project_pos.y, 1.0\n // );\n // mat4 translateMatrix = mat4(\n // 1.0, 0.0, 0.0, 0.0 ,\n // 0.0, 1.0, 0.0, 0.0,\n // 0.0, 0.0, 1.0, 0.0,\n // 1.0, 0.0, 0.0, 1.0\n // );\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy, a_Position.z, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, a_Position.z, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
27
|
+
|
|
22
28
|
var PlaneModel = /*#__PURE__*/function (_BaseModel) {
|
|
23
29
|
_inherits(PlaneModel, _BaseModel);
|
|
30
|
+
|
|
24
31
|
var _super = _createSuper(PlaneModel);
|
|
32
|
+
|
|
25
33
|
function PlaneModel() {
|
|
26
34
|
var _this;
|
|
35
|
+
|
|
27
36
|
_classCallCheck(this, PlaneModel);
|
|
37
|
+
|
|
28
38
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
29
39
|
args[_key] = arguments[_key];
|
|
30
40
|
}
|
|
41
|
+
|
|
31
42
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
43
|
+
|
|
32
44
|
_defineProperty(_assertThisInitialized(_this), "terrainImageLoaded", false);
|
|
45
|
+
|
|
33
46
|
_defineProperty(_assertThisInitialized(_this), "planeGeometryTriangulation", function () {
|
|
34
47
|
var _this2;
|
|
48
|
+
|
|
35
49
|
var _ref = _this.layer.getLayerConfig(),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
_ref$width = _ref.width,
|
|
51
|
+
width = _ref$width === void 0 ? 1 : _ref$width,
|
|
52
|
+
_ref$height = _ref.height,
|
|
53
|
+
height = _ref$height === void 0 ? 1 : _ref$height,
|
|
54
|
+
_ref$widthSegments = _ref.widthSegments,
|
|
55
|
+
widthSegments = _ref$widthSegments === void 0 ? 1 : _ref$widthSegments,
|
|
56
|
+
_ref$heightSegments = _ref.heightSegments,
|
|
57
|
+
heightSegments = _ref$heightSegments === void 0 ? 1 : _ref$heightSegments,
|
|
58
|
+
_ref$center = _ref.center,
|
|
59
|
+
center = _ref$center === void 0 ? [120, 30] : _ref$center,
|
|
60
|
+
terrainTexture = _ref.terrainTexture;
|
|
61
|
+
|
|
47
62
|
var _this$initPlane = (_this2 = _this).initPlane.apply(_this2, [width, height, widthSegments, heightSegments].concat(_toConsumableArray(center))),
|
|
48
|
-
|
|
49
|
-
|
|
63
|
+
indices = _this$initPlane.indices,
|
|
64
|
+
positions = _this$initPlane.positions;
|
|
65
|
+
|
|
50
66
|
if (terrainTexture) {
|
|
51
67
|
// 存在地形贴图的时候会根据地形贴图对顶点进行偏移
|
|
52
68
|
_this.loadTerrainTexture(positions, indices);
|
|
53
69
|
}
|
|
70
|
+
|
|
54
71
|
return {
|
|
55
72
|
vertices: positions,
|
|
56
73
|
indices: indices,
|
|
57
74
|
size: 5
|
|
58
75
|
};
|
|
59
76
|
});
|
|
77
|
+
|
|
60
78
|
return _this;
|
|
61
79
|
}
|
|
80
|
+
|
|
62
81
|
_createClass(PlaneModel, [{
|
|
63
82
|
key: "initPlane",
|
|
64
83
|
value: function initPlane() {
|
|
@@ -79,34 +98,43 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
79
98
|
var segmentHeight = height / gridY;
|
|
80
99
|
var indices = [];
|
|
81
100
|
var positions = [];
|
|
101
|
+
|
|
82
102
|
for (var iy = 0; iy < gridY1; iy++) {
|
|
83
103
|
var y = iy * segmentHeight - heightHalf;
|
|
104
|
+
|
|
84
105
|
for (var ix = 0; ix < gridX1; ix++) {
|
|
85
106
|
var x = ix * segmentWidth - widthHalf;
|
|
107
|
+
|
|
86
108
|
if (this.mapService.version === Version['GAODE2.x']) {
|
|
87
109
|
// @ts-ignore
|
|
88
110
|
var _ref2 = this.mapService.lngLatToCoord([x + lng, -y + lat]),
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
111
|
+
_ref3 = _slicedToArray(_ref2, 2),
|
|
112
|
+
a = _ref3[0],
|
|
113
|
+
_b = _ref3[1];
|
|
114
|
+
|
|
92
115
|
positions.push(a, _b, 0);
|
|
93
116
|
} else {
|
|
94
117
|
positions.push(x + lng, -y + lat, 0);
|
|
95
118
|
}
|
|
119
|
+
|
|
96
120
|
positions.push(ix / gridX);
|
|
97
121
|
positions.push(1 - iy / gridY);
|
|
98
122
|
}
|
|
99
123
|
}
|
|
124
|
+
|
|
100
125
|
for (var _iy = 0; _iy < gridY; _iy++) {
|
|
101
126
|
for (var _ix = 0; _ix < gridX; _ix++) {
|
|
102
127
|
var _a = _ix + gridX1 * _iy;
|
|
128
|
+
|
|
103
129
|
var _b2 = _ix + gridX1 * (_iy + 1);
|
|
130
|
+
|
|
104
131
|
var c = _ix + 1 + gridX1 * (_iy + 1);
|
|
105
132
|
var d = _ix + 1 + gridX1 * _iy;
|
|
106
133
|
indices.push(_a, _b2, d);
|
|
107
134
|
indices.push(_b2, c, d);
|
|
108
135
|
}
|
|
109
136
|
}
|
|
137
|
+
|
|
110
138
|
return {
|
|
111
139
|
indices: indices,
|
|
112
140
|
positions: positions
|
|
@@ -116,17 +144,20 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
116
144
|
key: "getUninforms",
|
|
117
145
|
value: function getUninforms() {
|
|
118
146
|
var _ref4 = this.layer.getLayerConfig(),
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
147
|
+
opacity = _ref4.opacity,
|
|
148
|
+
mapTexture = _ref4.mapTexture,
|
|
149
|
+
_ref4$terrainClipHeig = _ref4.terrainClipHeight,
|
|
150
|
+
terrainClipHeight = _ref4$terrainClipHeig === void 0 ? 0 : _ref4$terrainClipHeig,
|
|
151
|
+
terrainTexture = _ref4.terrainTexture;
|
|
152
|
+
|
|
124
153
|
if (this.mapTexture !== mapTexture) {
|
|
125
154
|
var _this$texture;
|
|
155
|
+
|
|
126
156
|
this.mapTexture = mapTexture;
|
|
127
157
|
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
128
158
|
this.updateTexture(mapTexture);
|
|
129
159
|
}
|
|
160
|
+
|
|
130
161
|
return {
|
|
131
162
|
u_opacity: opacity || 1,
|
|
132
163
|
u_mapFlag: mapTexture ? 1 : 0,
|
|
@@ -138,6 +169,7 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
138
169
|
key: "clearModels",
|
|
139
170
|
value: function clearModels() {
|
|
140
171
|
var _this$texture2;
|
|
172
|
+
|
|
141
173
|
// @ts-ignore
|
|
142
174
|
this.terrainImage = null;
|
|
143
175
|
(_this$texture2 = this.texture) === null || _this$texture2 === void 0 ? void 0 : _this$texture2.destroy();
|
|
@@ -147,44 +179,52 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
147
179
|
value: function () {
|
|
148
180
|
var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
149
181
|
var _ref5, mapTexture, createTexture2D, model;
|
|
182
|
+
|
|
150
183
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
151
|
-
while (1)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
184
|
+
while (1) {
|
|
185
|
+
switch (_context.prev = _context.next) {
|
|
186
|
+
case 0:
|
|
187
|
+
_ref5 = this.layer.getLayerConfig(), mapTexture = _ref5.mapTexture;
|
|
188
|
+
this.mapTexture = mapTexture;
|
|
189
|
+
createTexture2D = this.rendererService.createTexture2D;
|
|
190
|
+
this.texture = createTexture2D({
|
|
191
|
+
height: 0,
|
|
192
|
+
width: 0
|
|
193
|
+
});
|
|
194
|
+
this.updateTexture(mapTexture);
|
|
195
|
+
_context.next = 7;
|
|
196
|
+
return this.layer.buildLayerModel({
|
|
197
|
+
moduleName: 'geometryPlane',
|
|
198
|
+
vertexShader: planeVert,
|
|
199
|
+
fragmentShader: planeFrag,
|
|
200
|
+
triangulation: this.planeGeometryTriangulation,
|
|
201
|
+
primitive: gl.TRIANGLES,
|
|
202
|
+
depth: {
|
|
203
|
+
enable: true
|
|
204
|
+
},
|
|
205
|
+
cull: {
|
|
206
|
+
enable: true,
|
|
207
|
+
face: gl.BACK // gl.FRONT | gl.BACK;
|
|
208
|
+
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
case 7:
|
|
213
|
+
model = _context.sent;
|
|
214
|
+
return _context.abrupt("return", [model]);
|
|
215
|
+
|
|
216
|
+
case 9:
|
|
217
|
+
case "end":
|
|
218
|
+
return _context.stop();
|
|
219
|
+
}
|
|
182
220
|
}
|
|
183
221
|
}, _callee, this);
|
|
184
222
|
}));
|
|
223
|
+
|
|
185
224
|
function initModels() {
|
|
186
225
|
return _initModels.apply(this, arguments);
|
|
187
226
|
}
|
|
227
|
+
|
|
188
228
|
return initModels;
|
|
189
229
|
}()
|
|
190
230
|
}, {
|
|
@@ -192,18 +232,23 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
192
232
|
value: function () {
|
|
193
233
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
194
234
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
195
|
-
while (1)
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
235
|
+
while (1) {
|
|
236
|
+
switch (_context2.prev = _context2.next) {
|
|
237
|
+
case 0:
|
|
238
|
+
return _context2.abrupt("return", this.initModels());
|
|
239
|
+
|
|
240
|
+
case 1:
|
|
241
|
+
case "end":
|
|
242
|
+
return _context2.stop();
|
|
243
|
+
}
|
|
201
244
|
}
|
|
202
245
|
}, _callee2, this);
|
|
203
246
|
}));
|
|
247
|
+
|
|
204
248
|
function buildModels() {
|
|
205
249
|
return _buildModels.apply(this, arguments);
|
|
206
250
|
}
|
|
251
|
+
|
|
207
252
|
return buildModels;
|
|
208
253
|
}()
|
|
209
254
|
}, {
|
|
@@ -211,15 +256,16 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
211
256
|
value: function createModelData(options) {
|
|
212
257
|
if (options) {
|
|
213
258
|
var _ref6 = this.layer.getLayerConfig(),
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
259
|
+
oldwidthSegments = _ref6.widthSegments,
|
|
260
|
+
oldheightSegments = _ref6.heightSegments,
|
|
261
|
+
oldwidth = _ref6.width,
|
|
262
|
+
oldheight = _ref6.height;
|
|
263
|
+
|
|
218
264
|
var _ref7 = options,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
265
|
+
widthSegments = _ref7.widthSegments,
|
|
266
|
+
heightSegments = _ref7.heightSegments,
|
|
267
|
+
width = _ref7.width,
|
|
268
|
+
height = _ref7.height;
|
|
223
269
|
this.layer.style({
|
|
224
270
|
widthSegments: widthSegments !== undefined ? widthSegments : oldwidthSegments,
|
|
225
271
|
heightSegments: heightSegments !== undefined ? heightSegments : oldheightSegments,
|
|
@@ -227,6 +273,7 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
227
273
|
height: height !== undefined ? height : oldheight
|
|
228
274
|
});
|
|
229
275
|
}
|
|
276
|
+
|
|
230
277
|
var oldFeatures = this.layer.getEncodedData();
|
|
231
278
|
var res = this.styleAttributeService.createAttributesAndIndices(oldFeatures, this.planeGeometryTriangulation);
|
|
232
279
|
return res;
|
|
@@ -235,10 +282,13 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
235
282
|
key: "updateTexture",
|
|
236
283
|
value: function updateTexture(mapTexture) {
|
|
237
284
|
var _this3 = this;
|
|
285
|
+
|
|
238
286
|
var createTexture2D = this.rendererService.createTexture2D;
|
|
287
|
+
|
|
239
288
|
if (mapTexture) {
|
|
240
289
|
var img = new Image();
|
|
241
290
|
img.crossOrigin = 'anonymous';
|
|
291
|
+
|
|
242
292
|
img.onload = function () {
|
|
243
293
|
_this3.texture = createTexture2D({
|
|
244
294
|
data: img,
|
|
@@ -247,8 +297,10 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
247
297
|
wrapS: gl.CLAMP_TO_EDGE,
|
|
248
298
|
wrapT: gl.CLAMP_TO_EDGE
|
|
249
299
|
});
|
|
300
|
+
|
|
250
301
|
_this3.layerService.reRender();
|
|
251
302
|
};
|
|
303
|
+
|
|
252
304
|
img.src = mapTexture;
|
|
253
305
|
} else {
|
|
254
306
|
this.texture = createTexture2D({
|
|
@@ -263,7 +315,7 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
263
315
|
var canvas = document.createElement('canvas');
|
|
264
316
|
var ctx = canvas.getContext('2d');
|
|
265
317
|
var width = img.width,
|
|
266
|
-
|
|
318
|
+
height = img.height;
|
|
267
319
|
canvas.width = width;
|
|
268
320
|
canvas.height = height;
|
|
269
321
|
ctx.drawImage(img, 0, 0, width, height);
|
|
@@ -282,9 +334,11 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
282
334
|
var gridY1 = gridY + 1;
|
|
283
335
|
var widthStep = imgWidth / gridX;
|
|
284
336
|
var heightStep = imgHeight / gridY;
|
|
337
|
+
|
|
285
338
|
for (var iy = 0; iy < gridY1; iy++) {
|
|
286
339
|
var imgIndexY = Math.floor(iy * heightStep);
|
|
287
340
|
var imgLen = imgIndexY * imgWidth;
|
|
341
|
+
|
|
288
342
|
for (var ix = 0; ix < gridX1; ix++) {
|
|
289
343
|
var imgIndexX = Math.floor(ix * widthStep);
|
|
290
344
|
var imgDataIndex = (imgLen + imgIndexX) * 4;
|
|
@@ -295,6 +349,7 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
295
349
|
positions[z] = rgb2height(_r, _g, _b3);
|
|
296
350
|
}
|
|
297
351
|
}
|
|
352
|
+
|
|
298
353
|
var oldFeatures = this.layer.getEncodedData();
|
|
299
354
|
var modelData = this.styleAttributeService.createAttributesAndIndices(oldFeatures, function () {
|
|
300
355
|
return {
|
|
@@ -306,24 +361,26 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
306
361
|
this.layer.updateModelData(modelData);
|
|
307
362
|
this.layerService.throttleRenderLayers();
|
|
308
363
|
}
|
|
309
|
-
|
|
310
364
|
/**
|
|
311
365
|
* load terrain texture & offset attribute z
|
|
312
366
|
*/
|
|
367
|
+
|
|
313
368
|
}, {
|
|
314
369
|
key: "loadTerrainTexture",
|
|
315
370
|
value: function loadTerrainTexture(positions, indices) {
|
|
316
371
|
var _this4 = this;
|
|
372
|
+
|
|
317
373
|
var _ref8 = this.layer.getLayerConfig(),
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
374
|
+
_ref8$widthSegments = _ref8.widthSegments,
|
|
375
|
+
widthSegments = _ref8$widthSegments === void 0 ? 1 : _ref8$widthSegments,
|
|
376
|
+
_ref8$heightSegments = _ref8.heightSegments,
|
|
377
|
+
heightSegments = _ref8$heightSegments === void 0 ? 1 : _ref8$heightSegments,
|
|
378
|
+
terrainTexture = _ref8.terrainTexture,
|
|
379
|
+
_ref8$rgb2height = _ref8.rgb2height,
|
|
380
|
+
rgb2height = _ref8$rgb2height === void 0 ? function (r, g, b) {
|
|
381
|
+
return r + g + b;
|
|
382
|
+
} : _ref8$rgb2height;
|
|
383
|
+
|
|
327
384
|
if (this.terrainImage) {
|
|
328
385
|
// 若当前已经存在 image,直接进行偏移计算(LOD)
|
|
329
386
|
if (this.terrainImageLoaded) {
|
|
@@ -338,14 +395,17 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
338
395
|
var terrainImage = new Image();
|
|
339
396
|
this.terrainImage = terrainImage;
|
|
340
397
|
terrainImage.crossOrigin = 'anonymous';
|
|
398
|
+
|
|
341
399
|
terrainImage.onload = function () {
|
|
342
|
-
_this4.terrainImageLoaded = true;
|
|
343
|
-
|
|
400
|
+
_this4.terrainImageLoaded = true; // 图片加载完,触发事件,可以进行地形图的顶点计算存储
|
|
401
|
+
|
|
344
402
|
setTimeout(function () {
|
|
345
403
|
return _this4.layer.emit('terrainImageLoaded', null);
|
|
346
404
|
});
|
|
405
|
+
|
|
347
406
|
_this4.translateVertex(positions, indices, terrainImage, widthSegments, heightSegments, rgb2height);
|
|
348
407
|
};
|
|
408
|
+
|
|
349
409
|
terrainImage.src = terrainTexture;
|
|
350
410
|
}
|
|
351
411
|
}
|
|
@@ -372,6 +432,8 @@ var PlaneModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
372
432
|
});
|
|
373
433
|
}
|
|
374
434
|
}]);
|
|
435
|
+
|
|
375
436
|
return PlaneModel;
|
|
376
437
|
}(BaseModel);
|
|
438
|
+
|
|
377
439
|
export { PlaneModel as default };
|