@antv/l7-layers 2.21.0 → 2.21.2
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/canvas/index.js +60 -113
- package/es/canvas/models/canvas.js +95 -135
- package/es/canvas/models/constants.js +1 -1
- package/es/citybuliding/building.js +20 -58
- package/es/citybuliding/models/build.js +142 -199
- package/es/core/BaseLayer.d.ts +2 -1
- package/es/core/BaseLayer.js +1113 -1405
- package/es/core/BaseModel.js +262 -318
- package/es/core/CommonStyleAttribute.js +25 -18
- package/es/core/LayerPickService.js +92 -142
- package/es/core/TextureService.js +58 -69
- package/es/core/constant.js +2 -2
- package/es/core/interface.js +5 -5
- package/es/core/line_trangluation.js +38 -43
- package/es/core/shape/Path.js +21 -13
- package/es/core/shape/arrow.js +50 -62
- package/es/core/shape/extrude.js +54 -63
- package/es/core/triangulation.js +192 -171
- package/es/core/utils.js +5 -5
- package/es/earth/index.js +35 -73
- package/es/earth/models/atmosphere.js +98 -148
- package/es/earth/models/base.js +148 -202
- package/es/earth/models/bloomsphere.js +97 -147
- package/es/earth/utils.js +37 -38
- package/es/geometry/index.js +36 -75
- package/es/geometry/models/billboard.js +147 -204
- package/es/geometry/models/index.js +1 -1
- package/es/geometry/models/plane.js +277 -357
- package/es/geometry/models/sprite.js +182 -240
- package/es/heatmap/index.js +72 -122
- package/es/heatmap/models/grid.js +66 -118
- package/es/heatmap/models/grid3d.js +101 -151
- package/es/heatmap/models/heatmap.js +398 -455
- package/es/heatmap/models/hexagon.js +67 -119
- package/es/heatmap/models/index.js +1 -1
- package/es/heatmap/triangulation.js +20 -20
- package/es/image/index.js +23 -62
- package/es/image/models/image.js +99 -163
- package/es/image/models/index.js +1 -1
- package/es/line/index.js +65 -106
- package/es/line/models/arc.js +200 -248
- package/es/line/models/arc_3d.js +190 -242
- package/es/line/models/flow.js +101 -153
- package/es/line/models/great_circle.js +183 -234
- package/es/line/models/index.js +1 -1
- package/es/line/models/line.js +232 -288
- package/es/line/models/simple_line.js +142 -192
- package/es/line/models/wall.js +221 -273
- package/es/line/shaders/line/line_vert.glsl +0 -2
- package/es/line/shaders/wall/wall_vert.glsl +15 -0
- package/es/mask/index.js +16 -53
- package/es/mask/models/fill.js +51 -108
- package/es/mask/models/index.js +1 -1
- package/es/plugins/DataMappingPlugin.js +205 -251
- package/es/plugins/DataSourcePlugin.js +64 -92
- package/es/plugins/FeatureScalePlugin.js +258 -302
- package/es/plugins/LayerAnimateStylePlugin.js +12 -22
- package/es/plugins/LayerMaskPlugin.js +15 -24
- package/es/plugins/LayerModelPlugin.js +52 -136
- package/es/plugins/LayerStylePlugin.js +14 -23
- package/es/plugins/LightingPlugin.js +26 -37
- package/es/plugins/MultiPassRendererPlugin.js +34 -39
- package/es/plugins/PixelPickingPlugin.js +129 -151
- package/es/plugins/RegisterStyleAttributePlugin.js +80 -96
- package/es/plugins/ShaderUniformPlugin.js +159 -131
- package/es/plugins/UpdateModelPlugin.js +16 -26
- package/es/plugins/UpdateStyleAttributePlugin.js +47 -65
- package/es/point/index.js +118 -182
- package/es/point/models/billboard_point.js +72 -127
- package/es/point/models/earthExtrude.js +170 -220
- package/es/point/models/earthFill.js +136 -192
- package/es/point/models/extrude.js +167 -217
- package/es/point/models/fill.js +153 -210
- package/es/point/models/fillImage.js +156 -211
- package/es/point/models/image.js +127 -180
- package/es/point/models/index.js +1 -1
- package/es/point/models/normal.js +67 -122
- package/es/point/models/radar.js +93 -148
- package/es/point/models/text.js +447 -578
- package/es/point/shape/extrude.js +19 -25
- package/es/polygon/index.js +61 -99
- package/es/polygon/models/extrude.js +208 -281
- package/es/polygon/models/extrusion.js +95 -142
- package/es/polygon/models/fill.js +103 -155
- package/es/polygon/models/index.js +1 -2
- package/es/polygon/models/ocean.js +139 -198
- package/es/polygon/models/water.js +120 -179
- package/es/raster/buffers/triangulation.js +13 -11
- package/es/raster/index.js +47 -88
- package/es/raster/models/index.js +1 -1
- package/es/raster/models/raster.js +134 -202
- package/es/raster/models/rasterRgb.js +134 -208
- package/es/raster/models/rasterTerrainRgb.js +98 -153
- package/es/tile/core/BaseLayer.d.ts +1 -0
- package/es/tile/core/BaseLayer.js +206 -282
- package/es/tile/core/TileDebugLayer.js +12 -46
- package/es/tile/interaction/getRasterData.js +24 -31
- package/es/tile/interaction/utils.js +15 -33
- package/es/tile/service/TileLayerService.js +104 -177
- package/es/tile/service/TilePickService.js +99 -156
- package/es/tile/service/TileSourceService.js +17 -26
- package/es/tile/tile/DebugTile.js +41 -78
- package/es/tile/tile/ImageTile.js +33 -66
- package/es/tile/tile/MaskTile.js +47 -81
- package/es/tile/tile/RasterRGBTile.js +40 -71
- package/es/tile/tile/RasterTerrainRGBTile.js +33 -66
- package/es/tile/tile/RasterTile.js +69 -104
- package/es/tile/tile/Tile.d.ts +1 -1
- package/es/tile/tile/Tile.js +151 -232
- package/es/tile/tile/VectorTile.js +77 -124
- package/es/tile/tile/index.js +4 -2
- package/es/tile/utils/constants.js +1 -1
- package/es/tile/utils/utils.js +2 -2
- package/es/utils/blend.js +52 -47
- package/es/utils/collision-index.js +62 -70
- package/es/utils/extrude_polyline.js +441 -471
- package/es/utils/grid-index.js +97 -123
- package/es/utils/identityScale.js +5 -5
- package/es/utils/load-image.js +15 -39
- package/es/utils/multiPassRender.js +7 -9
- package/es/utils/polylineNormal.js +40 -43
- package/es/utils/rampcolor_legend.js +5 -4
- package/es/utils/simpleLine.js +53 -66
- package/es/utils/symbol-layout.js +95 -117
- package/es/wind/index.js +28 -71
- package/es/wind/models/index.js +1 -1
- package/es/wind/models/utils.js +36 -34
- package/es/wind/models/wind.js +203 -260
- package/es/wind/models/windRender.js +258 -269
- package/es/wind/models/windShader.js +145 -6
- package/lib/canvas/index.d.ts +18 -0
- package/lib/canvas/index.js +64 -113
- package/lib/canvas/models/canvas.d.ts +23 -0
- package/lib/canvas/models/canvas.js +97 -136
- package/lib/canvas/models/constants.d.ts +2 -0
- package/lib/canvas/models/constants.js +1 -1
- package/lib/canvas/models/index.d.ts +2 -0
- package/lib/canvas/models/index.js +2 -2
- package/lib/citybuliding/building.d.ts +7 -0
- package/lib/citybuliding/building.js +22 -58
- package/lib/citybuliding/models/build.d.ts +17 -0
- package/lib/citybuliding/models/build.js +144 -199
- package/lib/core/BaseLayer.d.ts +247 -0
- package/lib/core/BaseLayer.js +1115 -1405
- package/lib/core/BaseModel.d.ts +82 -0
- package/lib/core/BaseModel.js +262 -316
- package/lib/core/CommonStyleAttribute.d.ts +20 -0
- package/lib/core/CommonStyleAttribute.js +25 -18
- package/lib/core/LayerPickService.d.ts +12 -0
- package/lib/core/LayerPickService.js +93 -141
- package/lib/core/TextureService.d.ts +15 -0
- package/lib/core/TextureService.js +59 -68
- package/lib/core/constant.d.ts +6 -0
- package/lib/core/constant.js +2 -2
- package/lib/core/interface.d.ts +282 -0
- package/lib/core/interface.js +5 -5
- package/lib/core/line_trangluation.d.ts +19 -0
- package/lib/core/line_trangluation.js +38 -43
- package/lib/core/schema.d.ts +27 -0
- package/lib/core/shape/Path.d.ts +39 -0
- package/lib/core/shape/Path.js +21 -14
- package/lib/core/shape/arrow.d.ts +25 -0
- package/lib/core/shape/arrow.js +50 -62
- package/lib/core/shape/extrude.d.ts +17 -0
- package/lib/core/shape/extrude.js +54 -63
- package/lib/core/triangulation.d.ts +136 -0
- package/lib/core/triangulation.js +194 -174
- package/lib/core/utils.d.ts +4 -0
- package/lib/core/utils.js +5 -5
- package/lib/earth/index.d.ts +22 -0
- package/lib/earth/index.js +37 -73
- package/lib/earth/models/atmosphere.d.ts +15 -0
- package/lib/earth/models/atmosphere.js +100 -148
- package/lib/earth/models/base.d.ts +22 -0
- package/lib/earth/models/base.js +150 -202
- package/lib/earth/models/bloomsphere.d.ts +15 -0
- package/lib/earth/models/bloomsphere.js +99 -147
- package/lib/earth/utils.d.ts +26 -0
- package/lib/earth/utils.js +37 -39
- package/lib/geometry/index.d.ts +22 -0
- package/lib/geometry/index.js +38 -75
- package/lib/geometry/models/billboard.d.ts +24 -0
- package/lib/geometry/models/billboard.js +149 -204
- package/lib/geometry/models/index.d.ts +5 -0
- package/lib/geometry/models/index.js +1 -1
- package/lib/geometry/models/plane.d.ts +43 -0
- package/lib/geometry/models/plane.js +280 -357
- package/lib/geometry/models/sprite.d.ts +48 -0
- package/lib/geometry/models/sprite.js +184 -240
- package/lib/heatmap/index.d.ts +13 -0
- package/lib/heatmap/index.js +74 -122
- package/lib/heatmap/models/grid.d.ts +15 -0
- package/lib/heatmap/models/grid.js +68 -118
- package/lib/heatmap/models/grid3d.d.ts +15 -0
- package/lib/heatmap/models/grid3d.js +103 -151
- package/lib/heatmap/models/heatmap.d.ts +27 -0
- package/lib/heatmap/models/heatmap.js +400 -455
- package/lib/heatmap/models/hexagon.d.ts +15 -0
- package/lib/heatmap/models/hexagon.js +69 -119
- package/lib/heatmap/models/index.d.ts +5 -0
- package/lib/heatmap/models/index.js +1 -1
- package/lib/heatmap/triangulation.d.ts +5 -0
- package/lib/heatmap/triangulation.js +20 -20
- package/lib/image/index.d.ts +9 -0
- package/lib/image/index.js +25 -62
- package/lib/image/models/image.d.ts +17 -0
- package/lib/image/models/image.js +101 -163
- package/lib/image/models/index.d.ts +5 -0
- package/lib/image/models/index.js +1 -1
- package/lib/index.d.ts +18 -0
- package/lib/index.js +17 -17
- package/lib/line/index.d.ts +36 -0
- package/lib/line/index.js +67 -106
- package/lib/line/models/arc.d.ts +22 -0
- package/lib/line/models/arc.js +202 -248
- package/lib/line/models/arc_3d.d.ts +22 -0
- package/lib/line/models/arc_3d.js +193 -242
- package/lib/line/models/flow.d.ts +14 -0
- package/lib/line/models/flow.js +103 -153
- package/lib/line/models/great_circle.d.ts +17 -0
- package/lib/line/models/great_circle.js +185 -234
- package/lib/line/models/index.d.ts +5 -0
- package/lib/line/models/index.js +1 -1
- package/lib/line/models/line.d.ts +27 -0
- package/lib/line/models/line.js +233 -285
- package/lib/line/models/simple_line.d.ts +19 -0
- package/lib/line/models/simple_line.js +144 -192
- package/lib/line/models/wall.d.ts +17 -0
- package/lib/line/models/wall.js +223 -273
- package/lib/line/shaders/line/line_vert.glsl +0 -2
- package/lib/line/shaders/wall/wall_vert.glsl +15 -0
- package/lib/mask/index.d.ts +16 -0
- package/lib/mask/index.js +18 -53
- package/lib/mask/models/fill.d.ts +18 -0
- package/lib/mask/models/fill.js +53 -108
- package/lib/mask/models/index.d.ts +5 -0
- package/lib/mask/models/index.js +1 -1
- package/lib/plugins/DataMappingPlugin.d.ts +13 -0
- package/lib/plugins/DataMappingPlugin.js +206 -250
- package/lib/plugins/DataSourcePlugin.d.ts +6 -0
- package/lib/plugins/DataSourcePlugin.js +65 -91
- package/lib/plugins/FeatureScalePlugin.d.ts +20 -0
- package/lib/plugins/FeatureScalePlugin.js +261 -304
- package/lib/plugins/LayerAnimateStylePlugin.d.ts +4 -0
- package/lib/plugins/LayerAnimateStylePlugin.js +13 -21
- package/lib/plugins/LayerMaskPlugin.d.ts +7 -0
- package/lib/plugins/LayerMaskPlugin.js +16 -24
- package/lib/plugins/LayerModelPlugin.d.ts +10 -0
- package/lib/plugins/LayerModelPlugin.js +53 -135
- package/lib/plugins/LayerStylePlugin.d.ts +7 -0
- package/lib/plugins/LayerStylePlugin.js +15 -23
- package/lib/plugins/LightingPlugin.d.ts +35 -0
- package/lib/plugins/LightingPlugin.js +27 -36
- package/lib/plugins/MultiPassRendererPlugin.d.ts +22 -0
- package/lib/plugins/MultiPassRendererPlugin.js +35 -38
- package/lib/plugins/PixelPickingPlugin.d.ts +11 -0
- package/lib/plugins/PixelPickingPlugin.js +130 -150
- package/lib/plugins/RegisterStyleAttributePlugin.d.ts +11 -0
- package/lib/plugins/RegisterStyleAttributePlugin.js +81 -96
- package/lib/plugins/ShaderUniformPlugin.d.ts +22 -0
- package/lib/plugins/ShaderUniformPlugin.js +160 -130
- package/lib/plugins/UpdateModelPlugin.d.ts +7 -0
- package/lib/plugins/UpdateModelPlugin.js +17 -26
- package/lib/plugins/UpdateStyleAttributePlugin.d.ts +9 -0
- package/lib/plugins/UpdateStyleAttributePlugin.js +48 -65
- package/lib/plugins/index.d.ts +15 -0
- package/lib/point/index.d.ts +33 -0
- package/lib/point/index.js +120 -182
- package/lib/point/models/billboard_point.d.ts +21 -0
- package/lib/point/models/billboard_point.js +74 -127
- package/lib/point/models/earthExtrude.d.ts +16 -0
- package/lib/point/models/earthExtrude.js +172 -220
- package/lib/point/models/earthFill.d.ts +15 -0
- package/lib/point/models/earthFill.js +138 -192
- package/lib/point/models/extrude.d.ts +16 -0
- package/lib/point/models/extrude.js +169 -217
- package/lib/point/models/fill.d.ts +31 -0
- package/lib/point/models/fill.js +155 -210
- package/lib/point/models/fillImage.d.ts +26 -0
- package/lib/point/models/fillImage.js +159 -211
- package/lib/point/models/image.d.ts +18 -0
- package/lib/point/models/image.js +129 -180
- package/lib/point/models/index.d.ts +5 -0
- package/lib/point/models/index.js +1 -1
- package/lib/point/models/normal.d.ts +22 -0
- package/lib/point/models/normal.js +69 -122
- package/lib/point/models/radar.d.ts +22 -0
- package/lib/point/models/radar.js +95 -148
- package/lib/point/models/text.d.ts +69 -0
- package/lib/point/models/text.js +449 -578
- package/lib/point/shape/extrude.d.ts +15 -0
- package/lib/point/shape/extrude.js +19 -25
- package/lib/polygon/index.d.ts +18 -0
- package/lib/polygon/index.js +63 -99
- package/lib/polygon/models/extrude.d.ts +25 -0
- package/lib/polygon/models/extrude.js +210 -281
- package/lib/polygon/models/extrusion.d.ts +24 -0
- package/lib/polygon/models/extrusion.js +97 -142
- package/lib/polygon/models/fill.d.ts +18 -0
- package/lib/polygon/models/fill.js +104 -154
- package/lib/polygon/models/index.d.ts +5 -0
- package/lib/polygon/models/index.js +1 -1
- package/lib/polygon/models/ocean.d.ts +23 -0
- package/lib/polygon/models/ocean.js +141 -198
- package/lib/polygon/models/water.d.ts +21 -0
- package/lib/polygon/models/water.js +122 -179
- package/lib/raster/buffers/triangulation.d.ts +6 -0
- package/lib/raster/buffers/triangulation.js +13 -11
- package/lib/raster/index.d.ts +11 -0
- package/lib/raster/index.js +49 -88
- package/lib/raster/models/index.d.ts +5 -0
- package/lib/raster/models/index.js +1 -1
- package/lib/raster/models/raster.d.ts +21 -0
- package/lib/raster/models/raster.js +136 -202
- package/lib/raster/models/rasterRgb.d.ts +21 -0
- package/lib/raster/models/rasterRgb.js +136 -208
- package/lib/raster/models/rasterTerrainRgb.d.ts +16 -0
- package/lib/raster/models/rasterTerrainRgb.js +100 -153
- package/lib/tile/core/BaseLayer.d.ts +48 -0
- package/lib/tile/core/BaseLayer.js +207 -281
- package/lib/tile/core/TileDebugLayer.d.ts +15 -0
- package/lib/tile/core/TileDebugLayer.js +14 -46
- package/lib/tile/interaction/getFeatureData.d.ts +0 -0
- package/lib/tile/interaction/getRasterData.d.ts +4 -0
- package/lib/tile/interaction/getRasterData.js +24 -32
- package/lib/tile/interaction/utils.d.ts +11 -0
- package/lib/tile/interaction/utils.js +15 -34
- package/lib/tile/interface.d.ts +29 -0
- package/lib/tile/service/TileLayerService.d.ts +33 -0
- package/lib/tile/service/TileLayerService.js +105 -177
- package/lib/tile/service/TilePickService.d.ts +26 -0
- package/lib/tile/service/TilePickService.js +100 -156
- package/lib/tile/service/TileSourceService.d.ts +7 -0
- package/lib/tile/service/TileSourceService.js +20 -29
- package/lib/tile/tile/DebugTile.d.ts +16 -0
- package/lib/tile/tile/DebugTile.js +43 -78
- package/lib/tile/tile/ImageTile.d.ts +14 -0
- package/lib/tile/tile/ImageTile.js +35 -66
- package/lib/tile/tile/MaskTile.d.ts +18 -0
- package/lib/tile/tile/MaskTile.js +49 -81
- package/lib/tile/tile/RasterRGBTile.d.ts +11 -0
- package/lib/tile/tile/RasterRGBTile.js +42 -71
- package/lib/tile/tile/RasterTerrainRGBTile.d.ts +14 -0
- package/lib/tile/tile/RasterTerrainRGBTile.js +35 -66
- package/lib/tile/tile/RasterTile.d.ts +18 -0
- package/lib/tile/tile/RasterTile.js +71 -104
- package/lib/tile/tile/Tile.d.ts +114 -0
- package/lib/tile/tile/Tile.js +152 -231
- package/lib/tile/tile/VectorTile.d.ts +26 -0
- package/lib/tile/tile/VectorTile.js +79 -124
- package/lib/tile/tile/index.d.ts +12 -0
- package/lib/tile/tile/index.js +6 -4
- package/lib/tile/tile/util.d.ts +5 -0
- package/lib/tile/utils/constants.d.ts +1 -0
- package/lib/tile/utils/constants.js +1 -1
- package/lib/tile/utils/utils.d.ts +8 -0
- package/lib/tile/utils/utils.js +2 -2
- package/lib/utils/blend.d.ts +2 -0
- package/lib/utils/blend.js +52 -48
- package/lib/utils/collision-index.d.ts +47 -0
- package/lib/utils/collision-index.js +64 -69
- package/lib/utils/extrude_polyline.d.ts +68 -0
- package/lib/utils/extrude_polyline.js +442 -470
- package/lib/utils/grid-index.d.ts +28 -0
- package/lib/utils/grid-index.js +97 -123
- package/lib/utils/identityScale.d.ts +8 -0
- package/lib/utils/identityScale.js +5 -5
- package/lib/utils/load-image.d.ts +1 -0
- package/lib/utils/load-image.js +15 -39
- package/lib/utils/multiPassRender.d.ts +16 -0
- package/lib/utils/multiPassRender.js +7 -10
- package/lib/utils/polylineNormal.d.ts +9 -0
- package/lib/utils/polylineNormal.js +40 -44
- package/lib/utils/rampcolor_legend.d.ts +6 -0
- package/lib/utils/rampcolor_legend.js +5 -5
- package/lib/utils/simpleLine.d.ts +23 -0
- package/lib/utils/simpleLine.js +54 -65
- package/lib/utils/stencil.d.ts +7 -0
- package/lib/utils/symbol-layout.d.ts +43 -0
- package/lib/utils/symbol-layout.js +95 -117
- package/lib/wind/index.d.ts +11 -0
- package/lib/wind/index.js +30 -71
- package/lib/wind/models/index.d.ts +5 -0
- package/lib/wind/models/index.js +1 -1
- package/lib/wind/models/utils.d.ts +19 -0
- package/lib/wind/models/utils.js +36 -34
- package/lib/wind/models/wind.d.ts +24 -0
- package/lib/wind/models/wind.js +205 -260
- package/lib/wind/models/windRender.d.ts +104 -0
- package/lib/wind/models/windRender.js +261 -272
- package/lib/wind/models/windShader.d.ts +12 -0
- package/lib/wind/models/windShader.js +145 -6
- package/package.json +16 -19
- package/CHANGELOG.md +0 -492
- package/LICENSE.md +0 -21
- package/es/glsl.d.ts +0 -5
- package/lib/glsl.d.ts +0 -5
|
@@ -5,394 +5,317 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
8
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
9
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
16
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
18
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
20
11
|
var _l7Core = require("@antv/l7-core");
|
|
21
|
-
var
|
|
12
|
+
var _BaseModel = _interopRequireDefault(require("../../core/BaseModel"));
|
|
22
13
|
var _CommonStyleAttribute = require("../../core/CommonStyleAttribute");
|
|
23
|
-
|
|
24
|
-
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; } } // import { mat4, vec3 } from 'gl-matrix';
|
|
14
|
+
// import { mat4, vec3 } from 'gl-matrix';
|
|
25
15
|
/* babel-plugin-inline-import '../shaders/plane_frag.glsl' */
|
|
26
|
-
|
|
16
|
+
const planeFrag = "\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n float u_mapFlag;\n float u_terrainClipHeight;\n};\n\nin vec3 v_Color;\nin vec2 v_uv;\nin float v_clip;\nout vec4 outputColor;\n\n#pragma include \"picking\"\nvoid main() {\n // gl_FragColor = vec4(v_Color, u_opacity);\n if(u_mapFlag > 0.0) {\n outputColor = texture(SAMPLER_2D(u_texture), vec2(v_uv.x, 1.0 - v_uv.y));\n outputColor.a *= u_opacity;\n } else {\n // gl_FragColor = vec4(v_uv, 0.0, u_opacity);\n outputColor = vec4(v_Color, u_opacity);\n }\n outputColor.a *= v_clip;\n outputColor = filterColor(outputColor);\n}\n";
|
|
27
17
|
/* babel-plugin-inline-import '../shaders/plane_vert.glsl' */
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
(0,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
_ref$heightSegments = _ref.heightSegments,
|
|
50
|
-
heightSegments = _ref$heightSegments === void 0 ? 1 : _ref$heightSegments,
|
|
51
|
-
_ref$center = _ref.center,
|
|
52
|
-
center = _ref$center === void 0 ? [120, 30] : _ref$center,
|
|
53
|
-
terrainTexture = _ref.terrainTexture;
|
|
54
|
-
var _this$initPlane = (_this2 = _this).initPlane.apply(_this2, [width, height, widthSegments, heightSegments].concat((0, _toConsumableArray2.default)(center))),
|
|
55
|
-
indices = _this$initPlane.indices,
|
|
56
|
-
positions = _this$initPlane.positions;
|
|
18
|
+
const planeVert = "\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec3 a_Color;\nlayout(location = 14) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniforms {\n float u_opacity;\n float u_mapFlag;\n float u_terrainClipHeight;\n};\n\nout vec3 v_Color;\nout vec2 v_uv;\nout 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_v2(vec4(project_pos.xy, a_Position.z, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
19
|
+
class PlaneModel extends _BaseModel.default {
|
|
20
|
+
constructor(...args) {
|
|
21
|
+
super(...args);
|
|
22
|
+
(0, _defineProperty2.default)(this, "texture", void 0);
|
|
23
|
+
(0, _defineProperty2.default)(this, "terrainImage", void 0);
|
|
24
|
+
(0, _defineProperty2.default)(this, "terrainImageLoaded", false);
|
|
25
|
+
(0, _defineProperty2.default)(this, "mapTexture", void 0);
|
|
26
|
+
(0, _defineProperty2.default)(this, "planeGeometryTriangulation", () => {
|
|
27
|
+
const {
|
|
28
|
+
width = 1,
|
|
29
|
+
height = 1,
|
|
30
|
+
widthSegments = 1,
|
|
31
|
+
heightSegments = 1,
|
|
32
|
+
center = [120, 30],
|
|
33
|
+
terrainTexture
|
|
34
|
+
} = this.layer.getLayerConfig();
|
|
35
|
+
const {
|
|
36
|
+
indices,
|
|
37
|
+
positions
|
|
38
|
+
} = this.initPlane(width, height, widthSegments, heightSegments, ...center);
|
|
57
39
|
if (terrainTexture) {
|
|
58
40
|
// 存在地形贴图的时候会根据地形贴图对顶点进行偏移
|
|
59
|
-
|
|
41
|
+
this.loadTerrainTexture(positions, indices);
|
|
60
42
|
}
|
|
61
43
|
return {
|
|
62
44
|
vertices: positions,
|
|
63
|
-
indices
|
|
45
|
+
indices,
|
|
64
46
|
size: 5
|
|
65
47
|
};
|
|
66
48
|
});
|
|
67
|
-
return _this;
|
|
68
49
|
}
|
|
69
|
-
(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
for (var ix = 0; ix < gridX1; ix++) {
|
|
92
|
-
var x = ix * segmentWidth - widthHalf;
|
|
93
|
-
if (this.mapService.version === 'GAODE2.x') {
|
|
94
|
-
// @ts-ignore
|
|
95
|
-
var _ref2 = this.mapService.lngLatToCoord([x + lng, -y + lat]),
|
|
96
|
-
_ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
97
|
-
a = _ref3[0],
|
|
98
|
-
_b = _ref3[1];
|
|
99
|
-
positions.push(a, _b, 0);
|
|
100
|
-
} else {
|
|
101
|
-
positions.push(x + lng, -y + lat, 0);
|
|
102
|
-
}
|
|
103
|
-
positions.push(ix / gridX);
|
|
104
|
-
positions.push(1 - iy / gridY);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
for (var _iy = 0; _iy < gridY; _iy++) {
|
|
108
|
-
for (var _ix = 0; _ix < gridX; _ix++) {
|
|
109
|
-
var _a = _ix + gridX1 * _iy;
|
|
110
|
-
var _b2 = _ix + gridX1 * (_iy + 1);
|
|
111
|
-
var c = _ix + 1 + gridX1 * (_iy + 1);
|
|
112
|
-
var d = _ix + 1 + gridX1 * _iy;
|
|
113
|
-
indices.push(_a, _b2, d);
|
|
114
|
-
indices.push(_b2, c, d);
|
|
50
|
+
initPlane(width = 1, height = 1, widthSegments = 1, heightSegments = 1, lng = 120, lat = 30) {
|
|
51
|
+
// https://github.com/mrdoob/three.js/blob/dev/src/geometries/PlaneGeometry.js
|
|
52
|
+
const widthHalf = width / 2;
|
|
53
|
+
const heightHalf = height / 2;
|
|
54
|
+
const gridX = Math.floor(widthSegments);
|
|
55
|
+
const gridY = Math.floor(heightSegments);
|
|
56
|
+
const gridX1 = gridX + 1;
|
|
57
|
+
const gridY1 = gridY + 1;
|
|
58
|
+
const segmentWidth = width / gridX;
|
|
59
|
+
const segmentHeight = height / gridY;
|
|
60
|
+
const indices = [];
|
|
61
|
+
const positions = [];
|
|
62
|
+
for (let iy = 0; iy < gridY1; iy++) {
|
|
63
|
+
const y = iy * segmentHeight - heightHalf;
|
|
64
|
+
for (let ix = 0; ix < gridX1; ix++) {
|
|
65
|
+
const x = ix * segmentWidth - widthHalf;
|
|
66
|
+
if (this.mapService.version === 'GAODE2.x') {
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
const [a, b] = this.mapService.lngLatToCoord([x + lng, -y + lat]);
|
|
69
|
+
positions.push(a, b, 0);
|
|
70
|
+
} else {
|
|
71
|
+
positions.push(x + lng, -y + lat, 0);
|
|
115
72
|
}
|
|
73
|
+
positions.push(ix / gridX);
|
|
74
|
+
positions.push(1 - iy / gridY);
|
|
116
75
|
}
|
|
117
|
-
return {
|
|
118
|
-
indices: indices,
|
|
119
|
-
positions: positions
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
}, {
|
|
123
|
-
key: "getUninforms",
|
|
124
|
-
value: function getUninforms() {
|
|
125
|
-
var commoninfo = this.getCommonUniformsInfo();
|
|
126
|
-
var attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
|
|
127
|
-
this.updateStyleUnifoms();
|
|
128
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, commoninfo.uniformsOption), attributeInfo.uniformsOption);
|
|
129
76
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
terrainTexture = _ref4.terrainTexture;
|
|
139
|
-
if (this.mapTexture !== mapTexture) {
|
|
140
|
-
var _this$texture;
|
|
141
|
-
this.mapTexture = mapTexture;
|
|
142
|
-
(_this$texture = this.texture) === null || _this$texture === void 0 || _this$texture.destroy();
|
|
143
|
-
this.updateTexture(mapTexture);
|
|
77
|
+
for (let iy = 0; iy < gridY; iy++) {
|
|
78
|
+
for (let ix = 0; ix < gridX; ix++) {
|
|
79
|
+
const a = ix + gridX1 * iy;
|
|
80
|
+
const b = ix + gridX1 * (iy + 1);
|
|
81
|
+
const c = ix + 1 + gridX1 * (iy + 1);
|
|
82
|
+
const d = ix + 1 + gridX1 * iy;
|
|
83
|
+
indices.push(a, b, d);
|
|
84
|
+
indices.push(b, c, d);
|
|
144
85
|
}
|
|
145
|
-
var commonOptions = {
|
|
146
|
-
u_opacity: opacity || 1,
|
|
147
|
-
u_mapFlag: mapTexture ? 1 : 0,
|
|
148
|
-
u_terrainClipHeight: terrainTexture ? terrainClipHeight : -1,
|
|
149
|
-
u_texture: this.texture
|
|
150
|
-
};
|
|
151
|
-
this.textures = [this.texture];
|
|
152
|
-
var commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
|
|
153
|
-
return commonBufferInfo;
|
|
154
86
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
87
|
+
return {
|
|
88
|
+
indices,
|
|
89
|
+
positions
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
getUninforms() {
|
|
93
|
+
const commoninfo = this.getCommonUniformsInfo();
|
|
94
|
+
const attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
|
|
95
|
+
this.updateStyleUnifoms();
|
|
96
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, commoninfo.uniformsOption), attributeInfo.uniformsOption);
|
|
97
|
+
}
|
|
98
|
+
getCommonUniformsInfo() {
|
|
99
|
+
const {
|
|
100
|
+
opacity,
|
|
101
|
+
mapTexture,
|
|
102
|
+
terrainClipHeight = 0,
|
|
103
|
+
terrainTexture
|
|
104
|
+
} = this.layer.getLayerConfig();
|
|
105
|
+
if (this.mapTexture !== mapTexture) {
|
|
106
|
+
var _this$texture;
|
|
107
|
+
this.mapTexture = mapTexture;
|
|
108
|
+
(_this$texture = this.texture) === null || _this$texture === void 0 || _this$texture.destroy();
|
|
109
|
+
this.updateTexture(mapTexture);
|
|
163
110
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
heightSegments = _ref7.heightSegments,
|
|
242
|
-
width = _ref7.width,
|
|
243
|
-
height = _ref7.height;
|
|
244
|
-
this.layer.style({
|
|
245
|
-
widthSegments: widthSegments !== undefined ? widthSegments : oldwidthSegments,
|
|
246
|
-
heightSegments: heightSegments !== undefined ? heightSegments : oldheightSegments,
|
|
247
|
-
width: width !== undefined ? width : oldwidth,
|
|
248
|
-
height: height !== undefined ? height : oldheight
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
var oldFeatures = this.layer.getEncodedData();
|
|
252
|
-
var res = this.styleAttributeService.createAttributesAndIndices(oldFeatures, this.planeGeometryTriangulation);
|
|
253
|
-
return res;
|
|
111
|
+
const commonOptions = {
|
|
112
|
+
u_opacity: opacity || 1,
|
|
113
|
+
u_mapFlag: mapTexture ? 1 : 0,
|
|
114
|
+
u_terrainClipHeight: terrainTexture ? terrainClipHeight : -1,
|
|
115
|
+
u_texture: this.texture
|
|
116
|
+
};
|
|
117
|
+
this.textures = [this.texture];
|
|
118
|
+
const commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
|
|
119
|
+
return commonBufferInfo;
|
|
120
|
+
}
|
|
121
|
+
clearModels() {
|
|
122
|
+
var _this$texture2;
|
|
123
|
+
// @ts-ignore
|
|
124
|
+
this.terrainImage = null;
|
|
125
|
+
(_this$texture2 = this.texture) === null || _this$texture2 === void 0 || _this$texture2.destroy();
|
|
126
|
+
this.textures = [];
|
|
127
|
+
}
|
|
128
|
+
initModels() {
|
|
129
|
+
var _this = this;
|
|
130
|
+
return (0, _asyncToGenerator2.default)(function* () {
|
|
131
|
+
const {
|
|
132
|
+
mapTexture
|
|
133
|
+
} = _this.layer.getLayerConfig();
|
|
134
|
+
_this.mapTexture = mapTexture;
|
|
135
|
+
const {
|
|
136
|
+
createTexture2D
|
|
137
|
+
} = _this.rendererService;
|
|
138
|
+
_this.texture = createTexture2D({
|
|
139
|
+
height: 0,
|
|
140
|
+
width: 0
|
|
141
|
+
});
|
|
142
|
+
_this.updateTexture(mapTexture);
|
|
143
|
+
_this.initUniformsBuffer();
|
|
144
|
+
const model = yield _this.layer.buildLayerModel({
|
|
145
|
+
moduleName: 'geometryPlane',
|
|
146
|
+
vertexShader: planeVert,
|
|
147
|
+
fragmentShader: planeFrag,
|
|
148
|
+
triangulation: _this.planeGeometryTriangulation,
|
|
149
|
+
inject: _this.getInject(),
|
|
150
|
+
primitive: _l7Core.gl.TRIANGLES,
|
|
151
|
+
depth: {
|
|
152
|
+
enable: true
|
|
153
|
+
},
|
|
154
|
+
cull: {
|
|
155
|
+
enable: true,
|
|
156
|
+
face: _l7Core.gl.BACK // gl.FRONT | gl.BACK;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
return [model];
|
|
160
|
+
})();
|
|
161
|
+
}
|
|
162
|
+
buildModels() {
|
|
163
|
+
var _this2 = this;
|
|
164
|
+
return (0, _asyncToGenerator2.default)(function* () {
|
|
165
|
+
return _this2.initModels();
|
|
166
|
+
})();
|
|
167
|
+
}
|
|
168
|
+
createModelData(options) {
|
|
169
|
+
if (options) {
|
|
170
|
+
const {
|
|
171
|
+
widthSegments: oldwidthSegments,
|
|
172
|
+
heightSegments: oldheightSegments,
|
|
173
|
+
width: oldwidth,
|
|
174
|
+
height: oldheight
|
|
175
|
+
} = this.layer.getLayerConfig();
|
|
176
|
+
const {
|
|
177
|
+
widthSegments,
|
|
178
|
+
heightSegments,
|
|
179
|
+
width,
|
|
180
|
+
height
|
|
181
|
+
} = options;
|
|
182
|
+
this.layer.style({
|
|
183
|
+
widthSegments: widthSegments !== undefined ? widthSegments : oldwidthSegments,
|
|
184
|
+
heightSegments: heightSegments !== undefined ? heightSegments : oldheightSegments,
|
|
185
|
+
width: width !== undefined ? width : oldwidth,
|
|
186
|
+
height: height !== undefined ? height : oldheight
|
|
187
|
+
});
|
|
254
188
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
height: img.height,
|
|
268
|
-
wrapS: _l7Core.gl.CLAMP_TO_EDGE,
|
|
269
|
-
wrapT: _l7Core.gl.CLAMP_TO_EDGE
|
|
270
|
-
});
|
|
271
|
-
_this3.layerService.reRender();
|
|
272
|
-
};
|
|
273
|
-
img.src = mapTexture;
|
|
274
|
-
} else {
|
|
189
|
+
const oldFeatures = this.layer.getEncodedData();
|
|
190
|
+
const res = this.styleAttributeService.createAttributesAndIndices(oldFeatures, this.planeGeometryTriangulation);
|
|
191
|
+
return res;
|
|
192
|
+
}
|
|
193
|
+
updateTexture(mapTexture) {
|
|
194
|
+
const {
|
|
195
|
+
createTexture2D
|
|
196
|
+
} = this.rendererService;
|
|
197
|
+
if (mapTexture) {
|
|
198
|
+
const img = new Image();
|
|
199
|
+
img.crossOrigin = 'anonymous';
|
|
200
|
+
img.onload = () => {
|
|
275
201
|
this.texture = createTexture2D({
|
|
276
|
-
|
|
277
|
-
|
|
202
|
+
data: img,
|
|
203
|
+
width: img.width,
|
|
204
|
+
height: img.height,
|
|
205
|
+
wrapS: _l7Core.gl.CLAMP_TO_EDGE,
|
|
206
|
+
wrapT: _l7Core.gl.CLAMP_TO_EDGE
|
|
278
207
|
});
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
height = img.height;
|
|
288
|
-
canvas.width = width;
|
|
289
|
-
canvas.height = height;
|
|
290
|
-
ctx.drawImage(img, 0, 0, width, height);
|
|
291
|
-
var imageData = ctx.getImageData(0, 0, width, height);
|
|
292
|
-
return imageData;
|
|
208
|
+
this.layerService.reRender();
|
|
209
|
+
};
|
|
210
|
+
img.src = mapTexture;
|
|
211
|
+
} else {
|
|
212
|
+
this.texture = createTexture2D({
|
|
213
|
+
width: 0,
|
|
214
|
+
height: 0
|
|
215
|
+
});
|
|
293
216
|
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
217
|
+
}
|
|
218
|
+
getImageData(img) {
|
|
219
|
+
const canvas = document.createElement('canvas');
|
|
220
|
+
const ctx = canvas.getContext('2d');
|
|
221
|
+
const {
|
|
222
|
+
width,
|
|
223
|
+
height
|
|
224
|
+
} = img;
|
|
225
|
+
canvas.width = width;
|
|
226
|
+
canvas.height = height;
|
|
227
|
+
ctx.drawImage(img, 0, 0, width, height);
|
|
228
|
+
const imageData = ctx.getImageData(0, 0, width, height);
|
|
229
|
+
return imageData;
|
|
230
|
+
}
|
|
231
|
+
translateVertex(positions, indices, image, widthSegments, heightSegments, rgb2height) {
|
|
232
|
+
const imgWidth = image.width;
|
|
233
|
+
const imgHeight = image.height;
|
|
234
|
+
const imageData = this.getImageData(image).data;
|
|
235
|
+
const gridX = Math.floor(widthSegments);
|
|
236
|
+
const gridY = Math.floor(heightSegments);
|
|
237
|
+
const gridX1 = gridX + 1;
|
|
238
|
+
const gridY1 = gridY + 1;
|
|
239
|
+
const widthStep = imgWidth / gridX;
|
|
240
|
+
const heightStep = imgHeight / gridY;
|
|
241
|
+
for (let iy = 0; iy < gridY1; iy++) {
|
|
242
|
+
const imgIndexY = Math.floor(iy * heightStep);
|
|
243
|
+
const imgLen = imgIndexY * imgWidth;
|
|
244
|
+
for (let ix = 0; ix < gridX1; ix++) {
|
|
245
|
+
const imgIndexX = Math.floor(ix * widthStep);
|
|
246
|
+
const imgDataIndex = (imgLen + imgIndexX) * 4;
|
|
247
|
+
const r = imageData[imgDataIndex];
|
|
248
|
+
const g = imageData[imgDataIndex + 1];
|
|
249
|
+
const b = imageData[imgDataIndex + 2];
|
|
250
|
+
const z = (iy * gridX1 + ix) * 5 + 2;
|
|
251
|
+
positions[z] = rgb2height(r, g, b);
|
|
318
252
|
}
|
|
319
|
-
var oldFeatures = this.layer.getEncodedData();
|
|
320
|
-
var modelData = this.styleAttributeService.createAttributesAndIndices(oldFeatures, function () {
|
|
321
|
-
return {
|
|
322
|
-
vertices: positions,
|
|
323
|
-
indices: indices,
|
|
324
|
-
size: 5
|
|
325
|
-
};
|
|
326
|
-
});
|
|
327
|
-
this.layer.updateModelData(modelData);
|
|
328
|
-
this.layerService.throttleRenderLayers();
|
|
329
253
|
}
|
|
254
|
+
const oldFeatures = this.layer.getEncodedData();
|
|
255
|
+
const modelData = this.styleAttributeService.createAttributesAndIndices(oldFeatures, () => {
|
|
256
|
+
return {
|
|
257
|
+
vertices: positions,
|
|
258
|
+
indices,
|
|
259
|
+
size: 5
|
|
260
|
+
};
|
|
261
|
+
});
|
|
262
|
+
this.layer.updateModelData(modelData);
|
|
263
|
+
this.layerService.throttleRenderLayers();
|
|
264
|
+
}
|
|
330
265
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
rgb2height = _ref8$rgb2height === void 0 ? function (r, g, b) {
|
|
346
|
-
return r + g + b;
|
|
347
|
-
} : _ref8$rgb2height;
|
|
348
|
-
if (this.terrainImage) {
|
|
349
|
-
// 若当前已经存在 image,直接进行偏移计算(LOD)
|
|
350
|
-
if (this.terrainImageLoaded) {
|
|
351
|
-
this.translateVertex(positions, indices, this.terrainImage, widthSegments, heightSegments, rgb2height);
|
|
352
|
-
} else {
|
|
353
|
-
this.terrainImage.onload = function () {
|
|
354
|
-
_this4.translateVertex(positions, indices, _this4.terrainImage, widthSegments, heightSegments, rgb2height);
|
|
355
|
-
};
|
|
356
|
-
}
|
|
266
|
+
/**
|
|
267
|
+
* load terrain texture & offset attribute z
|
|
268
|
+
*/
|
|
269
|
+
loadTerrainTexture(positions, indices) {
|
|
270
|
+
const {
|
|
271
|
+
widthSegments = 1,
|
|
272
|
+
heightSegments = 1,
|
|
273
|
+
terrainTexture,
|
|
274
|
+
rgb2height = (r, g, b) => r + g + b
|
|
275
|
+
} = this.layer.getLayerConfig();
|
|
276
|
+
if (this.terrainImage) {
|
|
277
|
+
// 若当前已经存在 image,直接进行偏移计算(LOD)
|
|
278
|
+
if (this.terrainImageLoaded) {
|
|
279
|
+
this.translateVertex(positions, indices, this.terrainImage, widthSegments, heightSegments, rgb2height);
|
|
357
280
|
} else {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
this.terrainImage = terrainImage;
|
|
361
|
-
terrainImage.crossOrigin = 'anonymous';
|
|
362
|
-
terrainImage.onload = function () {
|
|
363
|
-
_this4.terrainImageLoaded = true;
|
|
364
|
-
// 图片加载完,触发事件,可以进行地形图的顶点计算存储
|
|
365
|
-
setTimeout(function () {
|
|
366
|
-
return _this4.layer.emit('terrainImageLoaded', null);
|
|
367
|
-
});
|
|
368
|
-
_this4.translateVertex(positions, indices, terrainImage, widthSegments, heightSegments, rgb2height);
|
|
281
|
+
this.terrainImage.onload = () => {
|
|
282
|
+
this.translateVertex(positions, indices, this.terrainImage, widthSegments, heightSegments, rgb2height);
|
|
369
283
|
};
|
|
370
|
-
terrainImage.src = terrainTexture;
|
|
371
284
|
}
|
|
285
|
+
} else {
|
|
286
|
+
// 加载地形贴图、根据地形贴图对 planeGeometry 进行偏移
|
|
287
|
+
const terrainImage = new Image();
|
|
288
|
+
this.terrainImage = terrainImage;
|
|
289
|
+
terrainImage.crossOrigin = 'anonymous';
|
|
290
|
+
terrainImage.onload = () => {
|
|
291
|
+
this.terrainImageLoaded = true;
|
|
292
|
+
// 图片加载完,触发事件,可以进行地形图的顶点计算存储
|
|
293
|
+
setTimeout(() => this.layer.emit('terrainImageLoaded', null));
|
|
294
|
+
this.translateVertex(positions, indices, terrainImage, widthSegments, heightSegments, rgb2height);
|
|
295
|
+
};
|
|
296
|
+
terrainImage.src = terrainTexture;
|
|
372
297
|
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
buffer
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
return [vertex[3], vertex[4]];
|
|
392
|
-
}
|
|
298
|
+
}
|
|
299
|
+
registerBuiltinAttributes() {
|
|
300
|
+
// point layer size;
|
|
301
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
302
|
+
name: 'uv',
|
|
303
|
+
type: _l7Core.AttributeType.Attribute,
|
|
304
|
+
descriptor: {
|
|
305
|
+
name: 'a_Uv',
|
|
306
|
+
shaderLocation: _CommonStyleAttribute.ShaderLocation.UV,
|
|
307
|
+
buffer: {
|
|
308
|
+
// give the WebGL driver a hint that this buffer may change
|
|
309
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
310
|
+
data: [],
|
|
311
|
+
type: _l7Core.gl.FLOAT
|
|
312
|
+
},
|
|
313
|
+
size: 2,
|
|
314
|
+
update: (feature, featureIdx, vertex) => {
|
|
315
|
+
return [vertex[3], vertex[4]];
|
|
393
316
|
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
exports.default = PlaneModel;
|