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