@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,234 +1,322 @@
|
|
|
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/polygon/models/extrude.ts
|
|
23
|
-
var extrude_exports = {};
|
|
24
|
-
__export(extrude_exports, {
|
|
25
|
-
default: () => ExtrudeModel
|
|
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
|
-
var
|
|
36
|
-
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
u_sidesurface: Number(sidesurface),
|
|
82
|
-
u_heightfixed: Number(heightfixed),
|
|
83
|
-
u_dataTexture: this.dataTexture,
|
|
84
|
-
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
85
|
-
u_raisingHeight: Number(raisingHeight),
|
|
86
|
-
u_opacity: (0, import_lodash.isNumber)(opacity) ? opacity : 1,
|
|
87
|
-
u_linearColor: useLinearColor,
|
|
88
|
-
u_sourceColor: sourceColorArr,
|
|
89
|
-
u_targetColor: targetColorArr,
|
|
90
|
-
u_texture: this.texture
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
initModels(callbackModel) {
|
|
94
|
-
this.loadTexture();
|
|
95
|
-
this.buildModels(callbackModel);
|
|
96
|
-
}
|
|
97
|
-
buildModels(callbackModel) {
|
|
98
|
-
const {
|
|
99
|
-
mask = false,
|
|
100
|
-
maskInside = true
|
|
101
|
-
} = this.layer.getLayerConfig();
|
|
102
|
-
const { frag, vert, type } = this.getShaders();
|
|
103
|
-
this.layer.buildLayerModel({
|
|
104
|
-
moduleName: type,
|
|
105
|
-
vertexShader: vert,
|
|
106
|
-
fragmentShader: frag,
|
|
107
|
-
triangulation: import_triangulation.PolygonExtrudeTriangulation,
|
|
108
|
-
stencil: (0, import_l7_utils.getMask)(mask, maskInside)
|
|
109
|
-
}).then((model) => {
|
|
110
|
-
callbackModel([model]);
|
|
111
|
-
}).catch((err) => {
|
|
112
|
-
console.warn(err);
|
|
113
|
-
callbackModel([]);
|
|
114
|
-
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
22
|
+
var _l7Core = require("@antv/l7-core");
|
|
23
|
+
|
|
24
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
25
|
+
|
|
26
|
+
var _lodash = require("lodash");
|
|
27
|
+
|
|
28
|
+
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
29
|
+
|
|
30
|
+
var _triangulation = require("../../core/triangulation");
|
|
31
|
+
|
|
32
|
+
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); }; }
|
|
33
|
+
|
|
34
|
+
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; } }
|
|
35
|
+
|
|
36
|
+
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_frag.glsl' */
|
|
37
|
+
var polygonExtrudeFrag = "uniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\n\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\n\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0]; \n float isSide = styleMappingMat[0][3];\n float sidey = styleMappingMat[3][0];\n float lightWeight = styleMappingMat[3][1];\n\n if(isSide < 1.0) {\n // side face\n if(u_sidesurface < 1.0) {\n discard;\n }\n\n if(u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n gl_FragColor = linearColor;\n } else {\n gl_FragColor = v_Color;\n }\n\n } else {\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n\n gl_FragColor = v_Color;\n }\n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; // extrude
|
|
38
|
+
|
|
39
|
+
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_vert.glsl' */
|
|
40
|
+
var polygonExtrudeVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nattribute vec3 a_uvs;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - isSide\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // sidey\n );\n styleMappingMat[0][3] = a_Position.z;\n styleMappingMat[3][0] = a_uvs[2];\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n // project_pos.z += 500000.0; // amap1\n\n // project_pos.z += (500000.0 * 4.0)/pow(2.0, 21.0 - u_Zoom); // mapbox\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(project_pos.xyz * vec3(1.0, 1.0, -1.0), 1.0));\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n float lightWeight = calc_lighting(pos);\n // v_Color = a_Color;\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n styleMappingMat[3][1] = lightWeight;\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
41
|
+
|
|
42
|
+
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrudetex_frag.glsl' */
|
|
43
|
+
var polygonExtrudeTexFrag = "uniform sampler2D u_texture;\nuniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\n\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\n\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float isSide = styleMappingMat[0][3];\n float lightWeight = styleMappingMat[3][1];\n float topU = styleMappingMat[2][2];\n float topV = styleMappingMat[2][3];\n\n float sidey = styleMappingMat[3][0];\n if(isSide < 1.0) {\n // side face\n if(u_sidesurface < 1.0) {\n discard;\n }\n\n if(u_linearColor == 1.0) {\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n gl_FragColor = linearColor;\n } else {\n gl_FragColor = v_Color;\n }\n } else {\n\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n\n gl_FragColor = texture2D(u_texture, vec2(topU, topV));\n }\n \n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n"; // texture
|
|
44
|
+
|
|
45
|
+
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrudetex_vert.glsl' */
|
|
46
|
+
var polygonExtrudeTexVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nattribute vec3 a_uvs;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n v_Color = a_Color;\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - a_Position.z(judge side by a_Position.z)\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1] - u - v\n 0.0, 0.0, 0.0, 0.0 // sidey\n );\n \n styleMappingMat[0][3] = a_Position.z;\n styleMappingMat[2][2] = a_uvs[0];\n styleMappingMat[2][3] = 1.0 - a_uvs[1];\n styleMappingMat[3][0] = a_uvs[2];\n\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n // project_pos.z += 500000.0; // amap1\n\n // project_pos.z += (500000.0 * 4.0)/pow(2.0, 21.0 - u_Zoom); // mapbox\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(project_pos.xyz * vec3(1.0, 1.0, -1.0), 1.0));\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n float lightWeight = calc_lighting(pos);\n styleMappingMat[3][1] = lightWeight;\n\n setPickingColor(a_PickingColor);\n}\n"; // extrude picking
|
|
47
|
+
|
|
48
|
+
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_picklight_frag.glsl' */
|
|
49
|
+
var polygonExtrudePickLightFrag = "uniform float u_opacity: 1.0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\nuniform float u_linearColor: 0;\n\nuniform float u_topsurface: 1.0;\nuniform float u_sidesurface: 1.0;\n\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float isSide = styleMappingMat[0][3];\n float sidey = styleMappingMat[3][0];\n float lightWeight = styleMappingMat[3][1];\n\n if(isSide < 1.0) {\n // side face\n if(u_sidesurface < 1.0) {\n discard;\n }\n \n if( u_linearColor == 1.0) {\n // side use linear\n vec4 linearColor = mix(u_targetColor, u_sourceColor, sidey);\n linearColor.rgb *= lightWeight;\n gl_FragColor = linearColor;\n } else {\n // side notuse linear\n gl_FragColor = v_Color;\n }\n } else {\n // top face\n if(u_topsurface < 1.0) {\n discard;\n }\n gl_FragColor = v_Color;\n }\n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColorAlpha(gl_FragColor, lightWeight);\n}\n";
|
|
50
|
+
|
|
51
|
+
/* babel-plugin-inline-import '../shaders/extrude/polygon_extrude_picklight_vert.glsl' */
|
|
52
|
+
var polygonExtrudePickLightVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nattribute vec3 a_uvs;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\nuniform float u_heightfixed: 0.0; // \u9ED8\u8BA4\u4E0D\u56FA\u5B9A\nuniform float u_raisingHeight: 0.0;\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - isSide\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // sidey\n );\n styleMappingMat[0][3] = a_Position.z;\n styleMappingMat[3][0] = a_uvs[2];\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos);\n\n if(u_heightfixed > 0.0) { // \u5224\u65AD\u51E0\u4F55\u4F53\u662F\u5426\u56FA\u5B9A\u9AD8\u5EA6\n project_pos.z = a_Position.z * a_Size;\n project_pos.z += u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n project_pos.z *= mapboxZoomScale;\n project_pos.z += u_raisingHeight * mapboxZoomScale;\n }\n }\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(project_pos.xyz * vec3(1.0, 1.0, -1.0), 1.0));\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n float lightWeight = calc_lighting(pos);\n // v_Color = a_Color;\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n styleMappingMat[3][1] = lightWeight;\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
53
|
+
|
|
54
|
+
var ExtrudeModel = /*#__PURE__*/function (_BaseModel) {
|
|
55
|
+
(0, _inherits2.default)(ExtrudeModel, _BaseModel);
|
|
56
|
+
|
|
57
|
+
var _super = _createSuper(ExtrudeModel);
|
|
58
|
+
|
|
59
|
+
function ExtrudeModel() {
|
|
60
|
+
(0, _classCallCheck2.default)(this, ExtrudeModel);
|
|
61
|
+
return _super.apply(this, arguments);
|
|
115
62
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
63
|
+
|
|
64
|
+
(0, _createClass2.default)(ExtrudeModel, [{
|
|
65
|
+
key: "getUninforms",
|
|
66
|
+
value: function getUninforms() {
|
|
67
|
+
var _ref = this.layer.getLayerConfig(),
|
|
68
|
+
_ref$opacity = _ref.opacity,
|
|
69
|
+
opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
|
|
70
|
+
_ref$heightfixed = _ref.heightfixed,
|
|
71
|
+
heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed,
|
|
72
|
+
_ref$raisingHeight = _ref.raisingHeight,
|
|
73
|
+
raisingHeight = _ref$raisingHeight === void 0 ? 0 : _ref$raisingHeight,
|
|
74
|
+
_ref$topsurface = _ref.topsurface,
|
|
75
|
+
topsurface = _ref$topsurface === void 0 ? true : _ref$topsurface,
|
|
76
|
+
_ref$sidesurface = _ref.sidesurface,
|
|
77
|
+
sidesurface = _ref$sidesurface === void 0 ? true : _ref$sidesurface,
|
|
78
|
+
sourceColor = _ref.sourceColor,
|
|
79
|
+
targetColor = _ref.targetColor;
|
|
80
|
+
|
|
81
|
+
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
82
|
+
opacity: opacity
|
|
83
|
+
})) {
|
|
84
|
+
this.judgeStyleAttributes({
|
|
85
|
+
opacity: opacity
|
|
86
|
+
});
|
|
87
|
+
var encodeData = this.layer.getEncodedData();
|
|
88
|
+
|
|
89
|
+
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
90
|
+
data = _this$calDataFrame.data,
|
|
91
|
+
width = _this$calDataFrame.width,
|
|
92
|
+
height = _this$calDataFrame.height;
|
|
93
|
+
|
|
94
|
+
this.rowCount = height; // 当前数据纹理有多少行
|
|
95
|
+
|
|
96
|
+
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
97
|
+
flipY: true,
|
|
98
|
+
data: data,
|
|
99
|
+
format: _l7Core.gl.LUMINANCE,
|
|
100
|
+
type: _l7Core.gl.FLOAT,
|
|
101
|
+
width: width,
|
|
102
|
+
height: height
|
|
103
|
+
}) : this.createTexture2D({
|
|
104
|
+
flipY: true,
|
|
105
|
+
data: [1],
|
|
106
|
+
format: _l7Core.gl.LUMINANCE,
|
|
107
|
+
type: _l7Core.gl.FLOAT,
|
|
108
|
+
width: 1,
|
|
109
|
+
height: 1
|
|
110
|
+
});
|
|
111
|
+
} // 转化渐变色
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
var useLinearColor = 0; // 默认不生效
|
|
115
|
+
|
|
116
|
+
var sourceColorArr = [1, 1, 1, 1];
|
|
117
|
+
var targetColorArr = [1, 1, 1, 1];
|
|
118
|
+
|
|
119
|
+
if (sourceColor && targetColor) {
|
|
120
|
+
sourceColorArr = (0, _l7Utils.rgb2arr)(sourceColor);
|
|
121
|
+
targetColorArr = (0, _l7Utils.rgb2arr)(targetColor);
|
|
122
|
+
useLinearColor = 1;
|
|
123
|
+
}
|
|
124
|
+
|
|
122
125
|
return {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
// 控制侧面和顶面的显示隐藏
|
|
127
|
+
u_topsurface: Number(topsurface),
|
|
128
|
+
u_sidesurface: Number(sidesurface),
|
|
129
|
+
u_heightfixed: Number(heightfixed),
|
|
130
|
+
u_dataTexture: this.dataTexture,
|
|
131
|
+
// 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
|
|
132
|
+
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
133
|
+
u_raisingHeight: Number(raisingHeight),
|
|
134
|
+
u_opacity: (0, _lodash.isNumber)(opacity) ? opacity : 1.0,
|
|
135
|
+
// 渐变色支持参数
|
|
136
|
+
u_linearColor: useLinearColor,
|
|
137
|
+
u_sourceColor: sourceColorArr,
|
|
138
|
+
u_targetColor: targetColorArr,
|
|
139
|
+
u_texture: this.texture
|
|
126
140
|
};
|
|
127
141
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
};
|
|
134
|
-
} else {
|
|
135
|
-
return {
|
|
136
|
-
frag: import_polygon_extrude_frag.default,
|
|
137
|
-
vert: import_polygon_extrude_vert.default,
|
|
138
|
-
type: "polygonExtrude"
|
|
139
|
-
};
|
|
142
|
+
}, {
|
|
143
|
+
key: "initModels",
|
|
144
|
+
value: function initModels(callbackModel) {
|
|
145
|
+
this.loadTexture();
|
|
146
|
+
this.buildModels(callbackModel);
|
|
140
147
|
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
148
|
+
}, {
|
|
149
|
+
key: "buildModels",
|
|
150
|
+
value: function buildModels(callbackModel) {
|
|
151
|
+
var _ref2 = this.layer.getLayerConfig(),
|
|
152
|
+
_ref2$mask = _ref2.mask,
|
|
153
|
+
mask = _ref2$mask === void 0 ? false : _ref2$mask,
|
|
154
|
+
_ref2$maskInside = _ref2.maskInside,
|
|
155
|
+
maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
|
|
156
|
+
|
|
157
|
+
var _this$getShaders = this.getShaders(),
|
|
158
|
+
frag = _this$getShaders.frag,
|
|
159
|
+
vert = _this$getShaders.vert,
|
|
160
|
+
type = _this$getShaders.type;
|
|
161
|
+
|
|
162
|
+
this.layer.buildLayerModel({
|
|
163
|
+
moduleName: type,
|
|
164
|
+
vertexShader: vert,
|
|
165
|
+
fragmentShader: frag,
|
|
166
|
+
triangulation: _triangulation.PolygonExtrudeTriangulation,
|
|
167
|
+
stencil: (0, _l7Utils.getMask)(mask, maskInside)
|
|
168
|
+
}).then(function (model) {
|
|
169
|
+
callbackModel([model]);
|
|
170
|
+
}).catch(function (err) {
|
|
171
|
+
console.warn(err);
|
|
172
|
+
callbackModel([]);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}, {
|
|
176
|
+
key: "getShaders",
|
|
177
|
+
value: function getShaders() {
|
|
178
|
+
var _ref3 = this.layer.getLayerConfig(),
|
|
179
|
+
pickLight = _ref3.pickLight,
|
|
180
|
+
mapTexture = _ref3.mapTexture;
|
|
181
|
+
|
|
182
|
+
if (mapTexture) {
|
|
183
|
+
return {
|
|
184
|
+
frag: polygonExtrudeTexFrag,
|
|
185
|
+
vert: polygonExtrudeTexVert,
|
|
186
|
+
type: 'polygonExtrudeTexture'
|
|
187
|
+
};
|
|
168
188
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
return normal;
|
|
183
|
-
}
|
|
189
|
+
|
|
190
|
+
if (pickLight) {
|
|
191
|
+
return {
|
|
192
|
+
frag: polygonExtrudePickLightFrag,
|
|
193
|
+
vert: polygonExtrudePickLightVert,
|
|
194
|
+
type: 'polygonExtrudePickLight'
|
|
195
|
+
};
|
|
196
|
+
} else {
|
|
197
|
+
return {
|
|
198
|
+
frag: polygonExtrudeFrag,
|
|
199
|
+
vert: polygonExtrudeVert,
|
|
200
|
+
type: 'polygonExtrude'
|
|
201
|
+
};
|
|
184
202
|
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
203
|
+
}
|
|
204
|
+
}, {
|
|
205
|
+
key: "clearModels",
|
|
206
|
+
value: function clearModels() {
|
|
207
|
+
var _this$dataTexture, _this$texture;
|
|
208
|
+
|
|
209
|
+
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
210
|
+
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
211
|
+
}
|
|
212
|
+
}, {
|
|
213
|
+
key: "registerBuiltinAttributes",
|
|
214
|
+
value: function registerBuiltinAttributes() {
|
|
215
|
+
var bbox = this.layer.getSource().extent;
|
|
216
|
+
|
|
217
|
+
var _bbox = (0, _slicedToArray2.default)(bbox, 4),
|
|
218
|
+
minLng = _bbox[0],
|
|
219
|
+
minLat = _bbox[1],
|
|
220
|
+
maxLng = _bbox[2],
|
|
221
|
+
maxLat = _bbox[3];
|
|
222
|
+
|
|
223
|
+
var lngLen = maxLng - minLng;
|
|
224
|
+
var latLen = maxLat - minLat;
|
|
225
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
226
|
+
name: 'uvs',
|
|
227
|
+
type: _l7Core.AttributeType.Attribute,
|
|
228
|
+
descriptor: {
|
|
229
|
+
name: 'a_uvs',
|
|
230
|
+
buffer: {
|
|
231
|
+
// give the WebGL driver a hint that this buffer may change
|
|
232
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
233
|
+
data: [],
|
|
234
|
+
type: _l7Core.gl.FLOAT
|
|
235
|
+
},
|
|
236
|
+
size: 3,
|
|
237
|
+
update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
|
|
238
|
+
var lng = vertex[0];
|
|
239
|
+
var lat = vertex[1];
|
|
240
|
+
return [(lng - minLng) / lngLen, (lat - minLat) / latLen, vertex[4]];
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}); // point layer size;
|
|
244
|
+
|
|
245
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
246
|
+
name: 'normal',
|
|
247
|
+
type: _l7Core.AttributeType.Attribute,
|
|
248
|
+
descriptor: {
|
|
249
|
+
name: 'a_Normal',
|
|
250
|
+
buffer: {
|
|
251
|
+
// give the WebGL driver a hint that this buffer may change
|
|
252
|
+
usage: _l7Core.gl.STATIC_DRAW,
|
|
253
|
+
data: [],
|
|
254
|
+
type: _l7Core.gl.FLOAT
|
|
255
|
+
},
|
|
256
|
+
size: 3,
|
|
257
|
+
update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
|
|
258
|
+
return normal;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
263
|
+
name: 'size',
|
|
264
|
+
type: _l7Core.AttributeType.Attribute,
|
|
265
|
+
descriptor: {
|
|
266
|
+
name: 'a_Size',
|
|
267
|
+
buffer: {
|
|
268
|
+
// give the WebGL driver a hint that this buffer may change
|
|
269
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
270
|
+
data: [],
|
|
271
|
+
type: _l7Core.gl.FLOAT
|
|
272
|
+
},
|
|
273
|
+
size: 1,
|
|
274
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
275
|
+
var _feature$size = feature.size,
|
|
276
|
+
size = _feature$size === void 0 ? 10 : _feature$size;
|
|
277
|
+
return Array.isArray(size) ? [size[0]] : [size];
|
|
278
|
+
}
|
|
200
279
|
}
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
}, {
|
|
283
|
+
key: "loadTexture",
|
|
284
|
+
value: function loadTexture() {
|
|
285
|
+
var _this = this;
|
|
286
|
+
|
|
287
|
+
var _ref4 = this.layer.getLayerConfig(),
|
|
288
|
+
mapTexture = _ref4.mapTexture;
|
|
289
|
+
|
|
290
|
+
var createTexture2D = this.rendererService.createTexture2D;
|
|
291
|
+
this.texture = createTexture2D({
|
|
292
|
+
height: 0,
|
|
293
|
+
width: 0
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
if (mapTexture) {
|
|
297
|
+
var image = new Image();
|
|
298
|
+
image.crossOrigin = '';
|
|
299
|
+
image.src = mapTexture;
|
|
300
|
+
|
|
301
|
+
image.onload = function () {
|
|
302
|
+
_this.texture = createTexture2D({
|
|
303
|
+
data: image,
|
|
304
|
+
width: image.width,
|
|
305
|
+
height: image.height,
|
|
306
|
+
wrapS: _l7Core.gl.CLAMP_TO_EDGE,
|
|
307
|
+
wrapT: _l7Core.gl.CLAMP_TO_EDGE,
|
|
308
|
+
min: _l7Core.gl.LINEAR,
|
|
309
|
+
mag: _l7Core.gl.LINEAR
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
_this.layerService.updateLayerRenderList();
|
|
313
|
+
|
|
314
|
+
_this.layerService.renderLayers();
|
|
315
|
+
};
|
|
201
316
|
}
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
loadTexture() {
|
|
205
|
-
const {
|
|
206
|
-
mapTexture
|
|
207
|
-
} = this.layer.getLayerConfig();
|
|
208
|
-
const { createTexture2D } = this.rendererService;
|
|
209
|
-
this.texture = createTexture2D({
|
|
210
|
-
height: 0,
|
|
211
|
-
width: 0
|
|
212
|
-
});
|
|
213
|
-
if (mapTexture) {
|
|
214
|
-
const image = new Image();
|
|
215
|
-
image.crossOrigin = "";
|
|
216
|
-
image.src = mapTexture;
|
|
217
|
-
image.onload = () => {
|
|
218
|
-
this.texture = createTexture2D({
|
|
219
|
-
data: image,
|
|
220
|
-
width: image.width,
|
|
221
|
-
height: image.height,
|
|
222
|
-
wrapS: import_l7_core.gl.CLAMP_TO_EDGE,
|
|
223
|
-
wrapT: import_l7_core.gl.CLAMP_TO_EDGE,
|
|
224
|
-
min: import_l7_core.gl.LINEAR,
|
|
225
|
-
mag: import_l7_core.gl.LINEAR
|
|
226
|
-
});
|
|
227
|
-
this.layerService.updateLayerRenderList();
|
|
228
|
-
this.layerService.renderLayers();
|
|
229
|
-
};
|
|
230
317
|
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
318
|
+
}]);
|
|
319
|
+
return ExtrudeModel;
|
|
320
|
+
}(_BaseModel2.default);
|
|
321
|
+
|
|
322
|
+
exports.default = ExtrudeModel;
|