@antv/l7-layers 2.9.23 → 2.9.25
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/models/plane.d.ts +1 -0
- package/es/citybuliding/building.js +1 -1
- package/es/core/BaseLayer.js +10 -3
- package/es/core/interface.d.ts +26 -48
- package/es/core/interface.js +3 -0
- package/es/core/schema.d.ts +3 -3
- package/es/core/triangulation.d.ts +4 -3
- package/es/core/triangulation.js +54 -39
- package/es/heatmap/models/heatmap.js +1 -1
- package/es/image/models/image.js +7 -1
- package/es/line/index.js +4 -1
- package/es/line/models/arc.js +1 -1
- package/es/line/models/simpleLine.js +1 -1
- package/es/line/shaders/line_arc_vert.glsl +5 -3
- package/es/line/shaders/simple/simpleline_vert.glsl +1 -0
- package/es/plugins/FeatureScalePlugin.js +0 -1
- package/es/point/index.js +3 -1
- package/es/point/models/fill.js +5 -2
- package/es/point/models/fillmage.js +9 -3
- package/es/point/models/image.js +8 -2
- package/es/point/models/radar.js +2 -3
- package/es/point/models/tile.js +1 -1
- package/es/point/shaders/fill_vert.glsl +13 -6
- package/es/point/shaders/image/fillImage_vert.glsl +13 -5
- package/es/point/shaders/image_vert.glsl +17 -8
- package/es/polygon/index.js +4 -1
- package/es/raster/index.js +3 -1
- package/es/tile/manager/tileLayerManager.d.ts +3 -2
- package/es/tile/manager/tileLayerManager.js +5 -2
- package/es/tile/models/tileModel.js +4 -3
- package/es/tile/tileFactory/base.d.ts +1 -1
- package/es/tile/tileFactory/base.js +32 -5
- package/es/tile/tileFactory/vectorLayer.d.ts +3 -1
- package/es/tile/tileFactory/vectorLayer.js +22 -1
- package/es/tile/tileLayer/baseTileLayer.d.ts +1 -1
- package/es/tile/tileLayer/baseTileLayer.js +3 -2
- package/es/tile/utils.d.ts +2 -0
- package/es/tile/utils.js +5 -1
- package/lib/Geometry/index.js +114 -77
- package/lib/Geometry/models/billboard.js +232 -181
- package/lib/Geometry/models/index.js +18 -34
- package/lib/Geometry/models/plane.js +407 -278
- package/lib/Geometry/models/sprite.js +291 -189
- package/lib/canvas/index.js +101 -66
- package/lib/canvas/models/canvas.js +207 -140
- package/lib/canvas/models/index.js +12 -30
- package/lib/citybuliding/building.js +98 -63
- package/lib/citybuliding/models/build.js +192 -146
- package/lib/core/BaseLayer.js +1331 -809
- package/lib/core/BaseModel.js +457 -279
- package/lib/core/interface.js +40 -53
- package/lib/core/schema.js +21 -39
- package/lib/core/shape/Path.js +67 -79
- package/lib/core/shape/extrude.js +132 -91
- package/lib/core/triangulation.js +412 -213
- package/lib/earth/index.js +100 -62
- package/lib/earth/models/atmosphere.js +146 -112
- package/lib/earth/models/base.js +210 -150
- package/lib/earth/models/bloomsphere.js +146 -112
- package/lib/earth/utils.js +111 -91
- package/lib/heatmap/index.js +149 -92
- package/lib/heatmap/models/grid.js +118 -91
- package/lib/heatmap/models/grid3d.js +155 -123
- package/lib/heatmap/models/heatmap.js +475 -338
- package/lib/heatmap/models/hexagon.js +121 -92
- package/lib/heatmap/models/index.js +22 -37
- package/lib/heatmap/triangulation.js +31 -47
- package/lib/image/index.js +111 -74
- package/lib/image/models/dataImage.js +232 -174
- package/lib/image/models/image.js +175 -123
- package/lib/image/models/index.js +15 -32
- package/lib/index.js +263 -97
- package/lib/line/index.js +131 -83
- package/lib/line/models/arc.js +352 -237
- package/lib/line/models/arc_3d.js +334 -228
- package/lib/line/models/earthArc_3d.js +336 -228
- package/lib/line/models/great_circle.js +291 -200
- package/lib/line/models/half.js +286 -201
- package/lib/line/models/index.js +42 -50
- package/lib/line/models/line.js +428 -299
- package/lib/line/models/linearline.js +277 -203
- package/lib/line/models/simpleLine.js +239 -175
- package/lib/line/models/tile.js +348 -237
- package/lib/line/models/wall.js +327 -235
- package/lib/line/shaders/line_arc_vert.glsl +5 -3
- package/lib/line/shaders/simple/simpleline_vert.glsl +1 -0
- package/lib/mask/index.js +92 -59
- package/lib/mask/models/fill.js +134 -82
- package/lib/mask/models/index.js +12 -30
- package/lib/plugins/DataMappingPlugin.js +342 -224
- package/lib/plugins/DataSourcePlugin.js +102 -87
- package/lib/plugins/FeatureScalePlugin.js +330 -241
- package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
- package/lib/plugins/LayerModelPlugin.js +80 -73
- package/lib/plugins/LayerStylePlugin.js +48 -51
- package/lib/plugins/LightingPlugin.js +80 -68
- package/lib/plugins/MultiPassRendererPlugin.js +91 -65
- package/lib/plugins/PixelPickingPlugin.js +150 -109
- package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
- package/lib/plugins/ShaderUniformPlugin.js +118 -99
- package/lib/plugins/UpdateModelPlugin.js +40 -47
- package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
- package/lib/point/index.js +226 -148
- package/lib/point/models/earthExtrude.js +279 -201
- package/lib/point/models/earthFill.js +287 -202
- package/lib/point/models/extrude.js +299 -203
- package/lib/point/models/fill.js +406 -273
- package/lib/point/models/fillmage.js +365 -252
- package/lib/point/models/image.js +241 -164
- package/lib/point/models/index.js +46 -52
- package/lib/point/models/normal.js +183 -134
- package/lib/point/models/radar.js +304 -212
- package/lib/point/models/simplePoint.js +194 -142
- package/lib/point/models/text.js +608 -385
- package/lib/point/models/tile.js +314 -223
- package/lib/point/shaders/fill_vert.glsl +13 -6
- package/lib/point/shaders/image/fillImage_vert.glsl +13 -5
- package/lib/point/shaders/image_vert.glsl +17 -8
- package/lib/point/shape/extrude.js +56 -52
- package/lib/polygon/index.js +154 -100
- package/lib/polygon/models/extrude.js +311 -223
- package/lib/polygon/models/fill.js +215 -153
- package/lib/polygon/models/index.js +46 -52
- package/lib/polygon/models/ocean.js +244 -173
- package/lib/polygon/models/tile.js +144 -100
- package/lib/polygon/models/water.js +222 -153
- package/lib/raster/buffers/triangulation.js +27 -40
- package/lib/raster/index.js +115 -74
- package/lib/raster/models/index.js +16 -33
- package/lib/raster/models/raster.js +178 -135
- package/lib/raster/raster.js +187 -132
- package/lib/tile/interface.js +4 -16
- package/lib/tile/manager/tileConfigManager.js +125 -86
- package/lib/tile/manager/tileLayerManager.js +314 -227
- package/lib/tile/manager/tilePickerManager.js +192 -123
- package/lib/tile/models/tileModel.js +71 -51
- package/lib/tile/tileFactory/base.js +433 -292
- package/lib/tile/tileFactory/index.js +51 -49
- package/lib/tile/tileFactory/line.js +65 -50
- package/lib/tile/tileFactory/point.js +65 -50
- package/lib/tile/tileFactory/polygon.js +65 -50
- package/lib/tile/tileFactory/raster.js +66 -54
- package/lib/tile/tileFactory/rasterData.js +88 -76
- package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
- package/lib/tile/tileFactory/vectorLayer.js +169 -95
- package/lib/tile/tileLayer/baseTileLayer.js +420 -220
- package/lib/tile/tmsTileLayer.js +110 -67
- package/lib/tile/utils.js +113 -87
- package/lib/utils/blend.js +59 -79
- package/lib/utils/collision-index.js +107 -64
- package/lib/utils/dataMappingStyle.js +105 -60
- package/lib/utils/extrude_polyline.js +600 -398
- package/lib/utils/grid-index.js +163 -111
- package/lib/utils/layerData.js +130 -99
- package/lib/utils/multiPassRender.js +49 -41
- package/lib/utils/polylineNormal.js +148 -96
- package/lib/utils/simpleLine.js +100 -85
- package/lib/utils/symbol-layout.js +219 -116
- package/lib/utils/updateShape.js +15 -41
- package/lib/wind/index.js +109 -71
- package/lib/wind/models/index.js +12 -30
- package/lib/wind/models/utils.js +144 -105
- package/lib/wind/models/wind.js +333 -224
- package/lib/wind/models/windRender.js +329 -218
- package/lib/wind/models/windShader.js +23 -181
- package/package.json +7 -6
|
@@ -1,307 +1,436 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
-
|
|
22
|
-
// src/Geometry/models/plane.ts
|
|
23
|
-
var plane_exports = {};
|
|
24
|
-
__export(plane_exports, {
|
|
25
|
-
default: () => PlaneModel
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
26
7
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
|
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
+
|
|
14
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
+
|
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
|
|
18
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
19
|
+
|
|
20
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
+
|
|
22
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
23
|
+
|
|
24
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
25
|
+
|
|
26
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
|
+
|
|
28
|
+
var _l7Core = require("@antv/l7-core");
|
|
29
|
+
|
|
30
|
+
var _l7Maps = require("@antv/l7-maps");
|
|
31
|
+
|
|
32
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
33
|
+
|
|
34
|
+
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
35
|
+
|
|
36
|
+
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); }; }
|
|
37
|
+
|
|
38
|
+
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; } }
|
|
39
|
+
|
|
40
|
+
/* babel-plugin-inline-import '../shaders/plane_frag.glsl' */
|
|
41
|
+
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";
|
|
42
|
+
|
|
43
|
+
/* babel-plugin-inline-import '../shaders/plane_vert.glsl' */
|
|
44
|
+
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";
|
|
45
|
+
|
|
46
|
+
var PlaneModel = /*#__PURE__*/function (_BaseModel) {
|
|
47
|
+
(0, _inherits2.default)(PlaneModel, _BaseModel);
|
|
48
|
+
|
|
49
|
+
var _super = _createSuper(PlaneModel);
|
|
50
|
+
|
|
51
|
+
function PlaneModel() {
|
|
52
|
+
var _this;
|
|
53
|
+
|
|
54
|
+
(0, _classCallCheck2.default)(this, PlaneModel);
|
|
55
|
+
|
|
56
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
57
|
+
args[_key] = arguments[_key];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
61
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "terrainImageLoaded", false);
|
|
62
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "planeGeometryTriangulation", function () {
|
|
63
|
+
var _this2;
|
|
64
|
+
|
|
65
|
+
var _ref = _this.layer.getLayerConfig(),
|
|
66
|
+
_ref$width = _ref.width,
|
|
67
|
+
width = _ref$width === void 0 ? 1 : _ref$width,
|
|
68
|
+
_ref$height = _ref.height,
|
|
69
|
+
height = _ref$height === void 0 ? 1 : _ref$height,
|
|
70
|
+
_ref$widthSegments = _ref.widthSegments,
|
|
71
|
+
widthSegments = _ref$widthSegments === void 0 ? 1 : _ref$widthSegments,
|
|
72
|
+
_ref$heightSegments = _ref.heightSegments,
|
|
73
|
+
heightSegments = _ref$heightSegments === void 0 ? 1 : _ref$heightSegments,
|
|
74
|
+
_ref$center = _ref.center,
|
|
75
|
+
center = _ref$center === void 0 ? [120, 30] : _ref$center,
|
|
76
|
+
terrainTexture = _ref.terrainTexture;
|
|
77
|
+
|
|
78
|
+
var _this$initPlane = (_this2 = _this).initPlane.apply(_this2, [width, height, widthSegments, heightSegments].concat((0, _toConsumableArray2.default)(center))),
|
|
79
|
+
indices = _this$initPlane.indices,
|
|
80
|
+
positions = _this$initPlane.positions;
|
|
81
|
+
|
|
48
82
|
if (terrainTexture) {
|
|
49
|
-
|
|
83
|
+
// 存在地形贴图的时候会根据地形贴图对顶点进行偏移
|
|
84
|
+
_this.loadTerrainTexture(positions, indices);
|
|
50
85
|
}
|
|
86
|
+
|
|
51
87
|
return {
|
|
52
88
|
vertices: positions,
|
|
53
|
-
indices,
|
|
89
|
+
indices: indices,
|
|
54
90
|
size: 5
|
|
55
91
|
};
|
|
56
|
-
};
|
|
92
|
+
});
|
|
93
|
+
return _this;
|
|
57
94
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
95
|
+
|
|
96
|
+
(0, _createClass2.default)(PlaneModel, [{
|
|
97
|
+
key: "initPlane",
|
|
98
|
+
value: function initPlane() {
|
|
99
|
+
var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
100
|
+
var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
101
|
+
var widthSegments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
102
|
+
var heightSegments = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
103
|
+
var lng = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 120;
|
|
104
|
+
var lat = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 30;
|
|
105
|
+
// https://github.com/mrdoob/three.js/blob/dev/src/geometries/PlaneGeometry.js
|
|
106
|
+
var widthHalf = width / 2;
|
|
107
|
+
var heightHalf = height / 2;
|
|
108
|
+
var gridX = Math.floor(widthSegments);
|
|
109
|
+
var gridY = Math.floor(heightSegments);
|
|
110
|
+
var gridX1 = gridX + 1;
|
|
111
|
+
var gridY1 = gridY + 1;
|
|
112
|
+
var segmentWidth = width / gridX;
|
|
113
|
+
var segmentHeight = height / gridY;
|
|
114
|
+
var indices = [];
|
|
115
|
+
var positions = [];
|
|
116
|
+
|
|
117
|
+
for (var iy = 0; iy < gridY1; iy++) {
|
|
118
|
+
var y = iy * segmentHeight - heightHalf;
|
|
119
|
+
|
|
120
|
+
for (var ix = 0; ix < gridX1; ix++) {
|
|
121
|
+
var x = ix * segmentWidth - widthHalf;
|
|
122
|
+
|
|
123
|
+
if (this.mapService.version === _l7Maps.Version['GAODE2.x']) {
|
|
124
|
+
// @ts-ignore
|
|
125
|
+
var _ref2 = this.mapService.lngLatToCoord([x + lng, -y + lat]),
|
|
126
|
+
_ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
127
|
+
a = _ref3[0],
|
|
128
|
+
_b = _ref3[1];
|
|
129
|
+
|
|
130
|
+
positions.push(a, _b, 0);
|
|
131
|
+
} else {
|
|
132
|
+
positions.push(x + lng, -y + lat, 0);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
positions.push(ix / gridX);
|
|
136
|
+
positions.push(1 - iy / gridY);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
for (var _iy = 0; _iy < gridY; _iy++) {
|
|
141
|
+
for (var _ix = 0; _ix < gridX; _ix++) {
|
|
142
|
+
var _a = _ix + gridX1 * _iy;
|
|
143
|
+
|
|
144
|
+
var _b2 = _ix + gridX1 * (_iy + 1);
|
|
145
|
+
|
|
146
|
+
var c = _ix + 1 + gridX1 * (_iy + 1);
|
|
147
|
+
var d = _ix + 1 + gridX1 * _iy;
|
|
148
|
+
indices.push(_a, _b2, d);
|
|
149
|
+
indices.push(_b2, c, d);
|
|
78
150
|
}
|
|
79
|
-
positions.push(ix / gridX);
|
|
80
|
-
positions.push(1 - iy / gridY);
|
|
81
151
|
}
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
indices: indices,
|
|
155
|
+
positions: positions
|
|
156
|
+
};
|
|
82
157
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
158
|
+
}, {
|
|
159
|
+
key: "getUninforms",
|
|
160
|
+
value: function getUninforms() {
|
|
161
|
+
var _ref4 = this.layer.getLayerConfig(),
|
|
162
|
+
opacity = _ref4.opacity,
|
|
163
|
+
mapTexture = _ref4.mapTexture,
|
|
164
|
+
_ref4$terrainClipHeig = _ref4.terrainClipHeight,
|
|
165
|
+
terrainClipHeight = _ref4$terrainClipHeig === void 0 ? 0 : _ref4$terrainClipHeig,
|
|
166
|
+
terrainTexture = _ref4.terrainTexture;
|
|
167
|
+
|
|
168
|
+
if (this.mapTexture !== mapTexture) {
|
|
169
|
+
var _this$texture;
|
|
170
|
+
|
|
171
|
+
this.mapTexture = mapTexture;
|
|
172
|
+
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
173
|
+
this.updateTexture(mapTexture);
|
|
91
174
|
}
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
u_opacity: opacity || 1,
|
|
178
|
+
u_mapFlag: mapTexture ? 1 : 0,
|
|
179
|
+
u_terrainClipHeight: terrainTexture ? terrainClipHeight : -1,
|
|
180
|
+
u_texture: this.texture
|
|
181
|
+
};
|
|
92
182
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
183
|
+
}, {
|
|
184
|
+
key: "clearModels",
|
|
185
|
+
value: function clearModels() {
|
|
186
|
+
var _this$texture2;
|
|
187
|
+
|
|
188
|
+
// @ts-ignore
|
|
189
|
+
this.terrainImage = null;
|
|
190
|
+
(_this$texture2 = this.texture) === null || _this$texture2 === void 0 ? void 0 : _this$texture2.destroy();
|
|
191
|
+
}
|
|
192
|
+
}, {
|
|
193
|
+
key: "initModels",
|
|
194
|
+
value: function initModels(callbackModel) {
|
|
195
|
+
var _ref5 = this.layer.getLayerConfig(),
|
|
196
|
+
_ref5$mask = _ref5.mask,
|
|
197
|
+
mask = _ref5$mask === void 0 ? false : _ref5$mask,
|
|
198
|
+
_ref5$maskInside = _ref5.maskInside,
|
|
199
|
+
maskInside = _ref5$maskInside === void 0 ? true : _ref5$maskInside,
|
|
200
|
+
mapTexture = _ref5.mapTexture;
|
|
201
|
+
|
|
104
202
|
this.mapTexture = mapTexture;
|
|
105
|
-
|
|
203
|
+
var createTexture2D = this.rendererService.createTexture2D;
|
|
204
|
+
this.texture = createTexture2D({
|
|
205
|
+
height: 0,
|
|
206
|
+
width: 0
|
|
207
|
+
});
|
|
106
208
|
this.updateTexture(mapTexture);
|
|
209
|
+
this.layer.buildLayerModel({
|
|
210
|
+
moduleName: 'geometryPlane',
|
|
211
|
+
vertexShader: planeVert,
|
|
212
|
+
fragmentShader: planeFrag,
|
|
213
|
+
triangulation: this.planeGeometryTriangulation,
|
|
214
|
+
primitive: _l7Core.gl.TRIANGLES,
|
|
215
|
+
depth: {
|
|
216
|
+
enable: true
|
|
217
|
+
},
|
|
218
|
+
stencil: (0, _l7Utils.getMask)(mask, maskInside),
|
|
219
|
+
blend: this.getBlend(),
|
|
220
|
+
cull: {
|
|
221
|
+
enable: true,
|
|
222
|
+
face: _l7Core.gl.BACK // gl.FRONT | gl.BACK;
|
|
223
|
+
|
|
224
|
+
}
|
|
225
|
+
}).then(function (model) {
|
|
226
|
+
callbackModel([model]);
|
|
227
|
+
}).catch(function (err) {
|
|
228
|
+
console.warn(err);
|
|
229
|
+
callbackModel([]);
|
|
230
|
+
});
|
|
107
231
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
moduleName: "geometryPlane",
|
|
135
|
-
vertexShader: import_plane_vert.default,
|
|
136
|
-
fragmentShader: import_plane_frag.default,
|
|
137
|
-
triangulation: this.planeGeometryTriangulation,
|
|
138
|
-
primitive: import_l7_core.gl.TRIANGLES,
|
|
139
|
-
depth: { enable: true },
|
|
140
|
-
stencil: (0, import_l7_utils.getMask)(mask, maskInside),
|
|
141
|
-
blend: this.getBlend(),
|
|
142
|
-
cull: {
|
|
143
|
-
enable: true,
|
|
144
|
-
face: import_l7_core.gl.BACK
|
|
232
|
+
}, {
|
|
233
|
+
key: "buildModels",
|
|
234
|
+
value: function buildModels(callbackModel) {
|
|
235
|
+
this.initModels(callbackModel);
|
|
236
|
+
}
|
|
237
|
+
}, {
|
|
238
|
+
key: "createModelData",
|
|
239
|
+
value: function createModelData(options) {
|
|
240
|
+
if (options) {
|
|
241
|
+
var _ref6 = this.layer.getLayerConfig(),
|
|
242
|
+
oldwidthSegments = _ref6.widthSegments,
|
|
243
|
+
oldheightSegments = _ref6.heightSegments,
|
|
244
|
+
oldwidth = _ref6.width,
|
|
245
|
+
oldheight = _ref6.height;
|
|
246
|
+
|
|
247
|
+
var _ref7 = options,
|
|
248
|
+
widthSegments = _ref7.widthSegments,
|
|
249
|
+
heightSegments = _ref7.heightSegments,
|
|
250
|
+
width = _ref7.width,
|
|
251
|
+
height = _ref7.height;
|
|
252
|
+
this.layer.style({
|
|
253
|
+
widthSegments: widthSegments !== undefined ? widthSegments : oldwidthSegments,
|
|
254
|
+
heightSegments: heightSegments !== undefined ? heightSegments : oldheightSegments,
|
|
255
|
+
width: width !== undefined ? width : oldwidth,
|
|
256
|
+
height: height !== undefined ? height : oldheight
|
|
257
|
+
});
|
|
145
258
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
callbackModel([]);
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
buildModels(callbackModel) {
|
|
154
|
-
this.initModels(callbackModel);
|
|
155
|
-
}
|
|
156
|
-
createModelData(options) {
|
|
157
|
-
if (options) {
|
|
158
|
-
const {
|
|
159
|
-
widthSegments: oldwidthSegments,
|
|
160
|
-
heightSegments: oldheightSegments,
|
|
161
|
-
width: oldwidth,
|
|
162
|
-
height: oldheight
|
|
163
|
-
} = this.layer.getLayerConfig();
|
|
164
|
-
const {
|
|
165
|
-
widthSegments,
|
|
166
|
-
heightSegments,
|
|
167
|
-
width,
|
|
168
|
-
height
|
|
169
|
-
} = options;
|
|
170
|
-
this.layer.style({
|
|
171
|
-
widthSegments: widthSegments !== void 0 ? widthSegments : oldwidthSegments,
|
|
172
|
-
heightSegments: heightSegments !== void 0 ? heightSegments : oldheightSegments,
|
|
173
|
-
width: width !== void 0 ? width : oldwidth,
|
|
174
|
-
height: height !== void 0 ? height : oldheight
|
|
175
|
-
});
|
|
259
|
+
|
|
260
|
+
var oldFeatures = this.layer.getEncodedData();
|
|
261
|
+
var res = this.styleAttributeService.createAttributesAndIndices(oldFeatures, this.planeGeometryTriangulation);
|
|
262
|
+
return res;
|
|
176
263
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
264
|
+
}, {
|
|
265
|
+
key: "updateTexture",
|
|
266
|
+
value: function updateTexture(mapTexture) {
|
|
267
|
+
var _this3 = this;
|
|
268
|
+
|
|
269
|
+
var createTexture2D = this.rendererService.createTexture2D;
|
|
270
|
+
|
|
271
|
+
if (mapTexture) {
|
|
272
|
+
var img = new Image();
|
|
273
|
+
img.crossOrigin = 'anonymous';
|
|
274
|
+
|
|
275
|
+
img.onload = function () {
|
|
276
|
+
_this3.texture = createTexture2D({
|
|
277
|
+
data: img,
|
|
278
|
+
width: img.width,
|
|
279
|
+
height: img.height,
|
|
280
|
+
wrapS: _l7Core.gl.CLAMP_TO_EDGE,
|
|
281
|
+
wrapT: _l7Core.gl.CLAMP_TO_EDGE
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
_this3.layerService.updateLayerRenderList();
|
|
285
|
+
|
|
286
|
+
_this3.layerService.renderLayers();
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
img.src = mapTexture;
|
|
290
|
+
} else {
|
|
187
291
|
this.texture = createTexture2D({
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
height: img.height,
|
|
191
|
-
wrapS: import_l7_core.gl.CLAMP_TO_EDGE,
|
|
192
|
-
wrapT: import_l7_core.gl.CLAMP_TO_EDGE
|
|
292
|
+
width: 0,
|
|
293
|
+
height: 0
|
|
193
294
|
});
|
|
194
|
-
|
|
195
|
-
this.layerService.renderLayers();
|
|
196
|
-
};
|
|
197
|
-
img.src = mapTexture;
|
|
198
|
-
} else {
|
|
199
|
-
this.texture = createTexture2D({
|
|
200
|
-
width: 0,
|
|
201
|
-
height: 0
|
|
202
|
-
});
|
|
295
|
+
}
|
|
203
296
|
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
297
|
+
}, {
|
|
298
|
+
key: "getImageData",
|
|
299
|
+
value: function getImageData(img) {
|
|
300
|
+
var canvas = document.createElement('canvas');
|
|
301
|
+
var ctx = canvas.getContext('2d');
|
|
302
|
+
var width = img.width,
|
|
303
|
+
height = img.height;
|
|
304
|
+
canvas.width = width;
|
|
305
|
+
canvas.height = height;
|
|
306
|
+
ctx.drawImage(img, 0, 0, width, height);
|
|
307
|
+
var imageData = ctx.getImageData(0, 0, width, height);
|
|
308
|
+
return imageData;
|
|
309
|
+
}
|
|
310
|
+
}, {
|
|
311
|
+
key: "translateVertex",
|
|
312
|
+
value: function translateVertex(positions, indices, image, widthSegments, heightSegments, rgb2height) {
|
|
313
|
+
var imgWidth = image.width;
|
|
314
|
+
var imgHeight = image.height;
|
|
315
|
+
var imageData = this.getImageData(image).data;
|
|
316
|
+
var gridX = Math.floor(widthSegments);
|
|
317
|
+
var gridY = Math.floor(heightSegments);
|
|
318
|
+
var gridX1 = gridX + 1;
|
|
319
|
+
var gridY1 = gridY + 1;
|
|
320
|
+
var widthStep = imgWidth / gridX;
|
|
321
|
+
var heihgtStep = imgHeight / gridY;
|
|
322
|
+
|
|
323
|
+
for (var iy = 0; iy < gridY1; iy++) {
|
|
324
|
+
var imgIndexY = Math.floor(iy * heihgtStep);
|
|
325
|
+
var imgLen = imgIndexY * imgWidth;
|
|
326
|
+
|
|
327
|
+
for (var ix = 0; ix < gridX1; ix++) {
|
|
328
|
+
var imgIndexX = Math.floor(ix * widthStep);
|
|
329
|
+
var imgDataIndex = (imgLen + imgIndexX) * 4;
|
|
330
|
+
var _r = imageData[imgDataIndex];
|
|
331
|
+
var _g = imageData[imgDataIndex + 1];
|
|
332
|
+
var _b3 = imageData[imgDataIndex + 2];
|
|
333
|
+
var z = (iy * gridX1 + ix) * 5 + 2;
|
|
334
|
+
positions[z] = rgb2height(_r, _g, _b3);
|
|
335
|
+
}
|
|
236
336
|
}
|
|
337
|
+
|
|
338
|
+
var oldFeatures = this.layer.getEncodedData();
|
|
339
|
+
var modelData = this.styleAttributeService.createAttributesAndIndices(oldFeatures, function () {
|
|
340
|
+
return {
|
|
341
|
+
vertices: positions,
|
|
342
|
+
indices: indices,
|
|
343
|
+
size: 5
|
|
344
|
+
};
|
|
345
|
+
});
|
|
346
|
+
this.layer.updateModelData(modelData);
|
|
347
|
+
this.layerService.renderLayers();
|
|
237
348
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
this.
|
|
349
|
+
/**
|
|
350
|
+
* load terrain texture & offset attribute z
|
|
351
|
+
*/
|
|
352
|
+
|
|
353
|
+
}, {
|
|
354
|
+
key: "loadTerrainTexture",
|
|
355
|
+
value: function loadTerrainTexture(positions, indices) {
|
|
356
|
+
var _this4 = this;
|
|
357
|
+
|
|
358
|
+
var _ref8 = this.layer.getLayerConfig(),
|
|
359
|
+
_ref8$widthSegments = _ref8.widthSegments,
|
|
360
|
+
widthSegments = _ref8$widthSegments === void 0 ? 1 : _ref8$widthSegments,
|
|
361
|
+
_ref8$heightSegments = _ref8.heightSegments,
|
|
362
|
+
heightSegments = _ref8$heightSegments === void 0 ? 1 : _ref8$heightSegments,
|
|
363
|
+
terrainTexture = _ref8.terrainTexture,
|
|
364
|
+
_ref8$rgb2height = _ref8.rgb2height,
|
|
365
|
+
rgb2height = _ref8$rgb2height === void 0 ? function (r, g, b) {
|
|
366
|
+
return r + g + b;
|
|
367
|
+
} : _ref8$rgb2height;
|
|
368
|
+
|
|
369
|
+
if (this.terrainImage) {
|
|
370
|
+
// 若当前已经存在 image,直接进行偏移计算(LOD)
|
|
371
|
+
if (this.terrainImageLoaded) {
|
|
261
372
|
this.translateVertex(positions, indices, this.terrainImage, widthSegments, heightSegments, rgb2height);
|
|
373
|
+
} else {
|
|
374
|
+
this.terrainImage.onload = function () {
|
|
375
|
+
_this4.translateVertex(positions, indices, _this4.terrainImage, widthSegments, heightSegments, rgb2height);
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
} else {
|
|
379
|
+
// 加载地形贴图、根据地形贴图对 planeGeometry 进行偏移
|
|
380
|
+
var terrainImage = new Image();
|
|
381
|
+
this.terrainImage = terrainImage;
|
|
382
|
+
terrainImage.crossOrigin = 'anonymous';
|
|
383
|
+
|
|
384
|
+
terrainImage.onload = function () {
|
|
385
|
+
_this4.terrainImageLoaded = true; // 图片加载完,触发事件,可以进行地形图的顶点计算存储
|
|
386
|
+
|
|
387
|
+
setTimeout(function () {
|
|
388
|
+
return _this4.layer.emit('terrainImageLoaded', null);
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
_this4.translateVertex(positions, indices, terrainImage, widthSegments, heightSegments, rgb2height);
|
|
262
392
|
};
|
|
393
|
+
|
|
394
|
+
terrainImage.src = terrainTexture;
|
|
263
395
|
}
|
|
264
|
-
} else {
|
|
265
|
-
const terrainImage = new Image();
|
|
266
|
-
this.terrainImage = terrainImage;
|
|
267
|
-
terrainImage.crossOrigin = "anonymous";
|
|
268
|
-
terrainImage.onload = () => {
|
|
269
|
-
this.terrainImageLoaded = true;
|
|
270
|
-
setTimeout(() => this.layer.emit("terrainImageLoaded", null));
|
|
271
|
-
this.translateVertex(positions, indices, terrainImage, widthSegments, heightSegments, rgb2height);
|
|
272
|
-
};
|
|
273
|
-
terrainImage.src = terrainTexture;
|
|
274
396
|
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
397
|
+
}, {
|
|
398
|
+
key: "getConfigSchema",
|
|
399
|
+
value: function getConfigSchema() {
|
|
400
|
+
return {
|
|
401
|
+
properties: {
|
|
402
|
+
opacity: {
|
|
403
|
+
type: 'number',
|
|
404
|
+
minimum: 0,
|
|
405
|
+
maximum: 1
|
|
406
|
+
}
|
|
283
407
|
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
}, {
|
|
411
|
+
key: "registerBuiltinAttributes",
|
|
412
|
+
value: function registerBuiltinAttributes() {
|
|
413
|
+
// point layer size;
|
|
414
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
415
|
+
name: 'uv',
|
|
416
|
+
type: _l7Core.AttributeType.Attribute,
|
|
417
|
+
descriptor: {
|
|
418
|
+
name: 'a_Uv',
|
|
419
|
+
buffer: {
|
|
420
|
+
// give the WebGL driver a hint that this buffer may change
|
|
421
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
422
|
+
data: [],
|
|
423
|
+
type: _l7Core.gl.FLOAT
|
|
424
|
+
},
|
|
425
|
+
size: 2,
|
|
426
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
427
|
+
return [vertex[3], vertex[4]];
|
|
428
|
+
}
|
|
301
429
|
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
}]);
|
|
433
|
+
return PlaneModel;
|
|
434
|
+
}(_BaseModel2.default);
|
|
435
|
+
|
|
436
|
+
exports.default = PlaneModel;
|