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