@antv/l7-layers 2.21.1 → 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 +1 -1
- package/es/core/BaseLayer.js +1113 -1412
- package/es/core/BaseModel.js +263 -317
- package/es/core/CommonStyleAttribute.js +25 -18
- package/es/core/LayerPickService.js +92 -141
- 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 -12
- package/es/core/shape/arrow.js +50 -62
- package/es/core/shape/extrude.js +54 -62
- 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 -201
- 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 -121
- 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 -241
- 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 +230 -285
- package/es/line/models/simple_line.js +142 -192
- package/es/line/models/wall.js +221 -273
- 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 -249
- 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 -150
- 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 +152 -209
- 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 +102 -153
- package/es/polygon/models/index.js +1 -1
- 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 -30
- 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 -46
- 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 -42
- package/es/utils/rampcolor_legend.js +5 -3
- package/es/utils/simpleLine.js +53 -66
- package/es/utils/symbol-layout.js +95 -117
- package/es/wind/index.js +28 -70
- 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 -1412
- package/lib/core/BaseModel.d.ts +82 -0
- package/lib/core/BaseModel.js +263 -315
- 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 -140
- 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 -13
- 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 -62
- 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 -201
- 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 -121
- 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 -241
- 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 +232 -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/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 -248
- 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 -149
- 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 +154 -209
- 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 -153
- 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 -31
- 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 -47
- 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 -43
- package/lib/utils/rampcolor_legend.d.ts +6 -0
- package/lib/utils/rampcolor_legend.js +5 -4
- 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 -70
- 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
package/es/point/models/text.js
CHANGED
|
@@ -1,36 +1,25 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
6
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
7
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
8
|
-
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
9
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
10
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
11
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
12
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
15
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
16
|
-
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; } }
|
|
17
4
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
18
5
|
import { boundsContains, calculateCentroid, lodashUtil, padBounds, rgb2arr } from '@antv/l7-utils';
|
|
19
6
|
import BaseModel from "../../core/BaseModel";
|
|
20
7
|
import CollisionIndex from "../../utils/collision-index";
|
|
21
8
|
import { getGlyphQuads, shapeText } from "../../utils/symbol-layout";
|
|
22
9
|
/* babel-plugin-inline-import '../shaders/text/text_frag.glsl' */
|
|
23
|
-
|
|
10
|
+
const textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\n\nuniform sampler2D u_sdf_map;\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nin vec2 v_uv;\nin float v_gamma_scale;\nin vec4 v_color;\nin vec4 v_stroke_color;\nin float v_fontScale;\n\nout vec4 outputColor;\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n\n // get sdf from atlas\n float dist = texture(SAMPLER_2D(u_sdf_map), v_uv).a;\n\n lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;\n\n highp float gamma_scaled = gamma * v_gamma_scale;\n\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n outputColor = mix(v_color, v_stroke_color, smoothstep(0., 0.5, 1.- dist));\n\n outputColor.a *= alpha;\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if (outputColor.a < 0.01) {\n discard;\n }\n outputColor = filterColor(outputColor);\n}\n";
|
|
24
11
|
/* babel-plugin-inline-import '../shaders/text/text_vert.glsl' */
|
|
25
|
-
|
|
12
|
+
const textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\n\nlayout(location = 0) in vec3 a_Position;\nlayout(location = 1) in vec4 a_Color;\nlayout(location = 9) in float a_Size;\nlayout(location = 10) in vec2 a_textOffsets;\nlayout(location = 14) in vec2 a_tex;\n\nlayout(std140) uniform commonUniforms {\n vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n vec2 u_sdf_map_size;\n float u_raisingHeight: 0.0;\n float u_stroke_width : 2;\n float u_gamma_scale : 0.5;\n float u_halo_blur : 0.5;\n};\n\nout vec2 v_uv;\nout float v_gamma_scale;\nout vec4 v_color;\nout vec4 v_stroke_color;\nout float v_fontScale;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n \n v_uv = a_tex / u_sdf_map_size;\n\n\n\n v_color = vec4(a_Color.xyz, a_Color.w * opacity);\n v_stroke_color = vec4(u_stroke_color.xyz, u_stroke_color.w * opacity);\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n vec2 offset = rotate_matrix(a_textOffsets,rotation);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = 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 raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position = project_common_position_to_clipspace_v2(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + offset * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
|
|
26
13
|
import { ShaderLocation } from "../../core/CommonStyleAttribute";
|
|
27
|
-
|
|
14
|
+
const {
|
|
15
|
+
isEqual
|
|
16
|
+
} = lodashUtil;
|
|
28
17
|
export function TextTrianglation(feature) {
|
|
29
18
|
// @ts-ignore
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
19
|
+
const that = this;
|
|
20
|
+
const id = feature.id;
|
|
21
|
+
const vertices = [];
|
|
22
|
+
const indices = [];
|
|
34
23
|
if (!that.glyphInfoMap || !that.glyphInfoMap[id]) {
|
|
35
24
|
return {
|
|
36
25
|
vertices: [],
|
|
@@ -39,589 +28,469 @@ export function TextTrianglation(feature) {
|
|
|
39
28
|
size: 7
|
|
40
29
|
};
|
|
41
30
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
that.glyphInfoMap[id].glyphQuads.forEach(
|
|
45
|
-
vertices.push
|
|
31
|
+
const centroid = that.glyphInfoMap[id].centroid; // 计算中心点
|
|
32
|
+
const coord = centroid.length === 2 ? [centroid[0], centroid[1], 0] : centroid;
|
|
33
|
+
that.glyphInfoMap[id].glyphQuads.forEach((quad, index) => {
|
|
34
|
+
vertices.push(...coord, quad.tex.x, quad.tex.y + quad.tex.height, quad.tl.x, quad.tl.y, ...coord, quad.tex.x + quad.tex.width, quad.tex.y + quad.tex.height, quad.tr.x, quad.tr.y, ...coord, quad.tex.x + quad.tex.width, quad.tex.y, quad.br.x, quad.br.y, ...coord, quad.tex.x, quad.tex.y, quad.bl.x, quad.bl.y);
|
|
46
35
|
indices.push(0 + index * 4, 1 + index * 4, 2 + index * 4, 2 + index * 4, 3 + index * 4, 0 + index * 4);
|
|
47
36
|
});
|
|
48
37
|
return {
|
|
49
|
-
vertices
|
|
38
|
+
vertices,
|
|
50
39
|
// [ x, y, z, tex.x,tex.y, offset.x. offset.y]
|
|
51
|
-
indices
|
|
40
|
+
indices,
|
|
52
41
|
size: 7
|
|
53
42
|
};
|
|
54
43
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
var _super = _createSuper(TextModel);
|
|
58
|
-
function TextModel() {
|
|
44
|
+
export default class TextModel extends BaseModel {
|
|
45
|
+
constructor(...args) {
|
|
59
46
|
var _this;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
_defineProperty(
|
|
66
|
-
_defineProperty(
|
|
67
|
-
_defineProperty(
|
|
68
|
-
_defineProperty(
|
|
69
|
-
_defineProperty(
|
|
70
|
-
_defineProperty(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
_context.next = 4;
|
|
77
|
-
return _this.reBuildModel();
|
|
78
|
-
case 4:
|
|
79
|
-
case "end":
|
|
80
|
-
return _context.stop();
|
|
81
|
-
}
|
|
82
|
-
}, _callee);
|
|
83
|
-
})));
|
|
84
|
-
return _this;
|
|
47
|
+
super(...args);
|
|
48
|
+
_this = this;
|
|
49
|
+
_defineProperty(this, "glyphInfo", void 0);
|
|
50
|
+
_defineProperty(this, "glyphInfoMap", {});
|
|
51
|
+
_defineProperty(this, "rawEncodeData", void 0);
|
|
52
|
+
_defineProperty(this, "texture", void 0);
|
|
53
|
+
_defineProperty(this, "currentZoom", -1);
|
|
54
|
+
_defineProperty(this, "extent", void 0);
|
|
55
|
+
_defineProperty(this, "textureHeight", 0);
|
|
56
|
+
_defineProperty(this, "textCount", 0);
|
|
57
|
+
_defineProperty(this, "preTextStyle", {});
|
|
58
|
+
_defineProperty(this, "mapping", /*#__PURE__*/_asyncToGenerator(function* () {
|
|
59
|
+
_this.initGlyph(); //
|
|
60
|
+
_this.updateTexture();
|
|
61
|
+
yield _this.reBuildModel();
|
|
62
|
+
}));
|
|
85
63
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
this.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
64
|
+
getUninforms() {
|
|
65
|
+
const commoninfo = this.getCommonUniformsInfo();
|
|
66
|
+
const attributeInfo = this.getUniformsBufferInfo(this.getStyleAttribute());
|
|
67
|
+
this.updateStyleUnifoms();
|
|
68
|
+
return _objectSpread(_objectSpread(_objectSpread({}, commoninfo.uniformsOption), attributeInfo.uniformsOption), {
|
|
69
|
+
u_sdf_map: this.textures[0]
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
getCommonUniformsInfo() {
|
|
73
|
+
const {
|
|
74
|
+
stroke = '#fff',
|
|
75
|
+
strokeWidth = 0,
|
|
76
|
+
halo = 0.5,
|
|
77
|
+
gamma = 2.0,
|
|
78
|
+
raisingHeight = 0
|
|
79
|
+
} = this.layer.getLayerConfig();
|
|
80
|
+
const mapping = this.getFontServiceMapping();
|
|
81
|
+
const canvas = this.getFontServiceCanvas();
|
|
82
|
+
if (mapping && Object.keys(mapping).length !== this.textCount && canvas) {
|
|
83
|
+
this.updateTexture();
|
|
84
|
+
this.textCount = Object.keys(mapping).length;
|
|
95
85
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
86
|
+
this.preTextStyle = this.getTextStyle();
|
|
87
|
+
const commonOptions = {
|
|
88
|
+
u_stroke_color: rgb2arr(stroke),
|
|
89
|
+
u_sdf_map_size: [(canvas === null || canvas === void 0 ? void 0 : canvas.width) || 1, (canvas === null || canvas === void 0 ? void 0 : canvas.height) || 1],
|
|
90
|
+
u_raisingHeight: Number(raisingHeight),
|
|
91
|
+
u_stroke_width: strokeWidth,
|
|
92
|
+
u_gamma_scale: gamma,
|
|
93
|
+
u_halo_blur: halo
|
|
94
|
+
};
|
|
95
|
+
const commonBufferInfo = this.getUniformsBufferInfo(commonOptions);
|
|
96
|
+
return commonBufferInfo;
|
|
97
|
+
}
|
|
98
|
+
initModels() {
|
|
99
|
+
var _this2 = this;
|
|
100
|
+
return _asyncToGenerator(function* () {
|
|
101
|
+
// 绑定事件
|
|
102
|
+
_this2.bindEvent();
|
|
103
|
+
_this2.extent = _this2.textExtent();
|
|
104
|
+
_this2.rawEncodeData = _this2.layer.getEncodedData();
|
|
105
|
+
_this2.preTextStyle = _this2.getTextStyle();
|
|
106
|
+
_this2.initUniformsBuffer();
|
|
107
|
+
return _this2.buildModels();
|
|
108
|
+
})();
|
|
109
|
+
}
|
|
110
|
+
buildModels() {
|
|
111
|
+
var _this3 = this;
|
|
112
|
+
return _asyncToGenerator(function* () {
|
|
113
|
+
const {
|
|
114
|
+
textAllowOverlap = false
|
|
115
|
+
} = _this3.layer.getLayerConfig();
|
|
116
|
+
|
|
117
|
+
// this.mapping(); 重复调用
|
|
118
|
+
_this3.initGlyph(); //
|
|
119
|
+
_this3.updateTexture();
|
|
120
|
+
if (!textAllowOverlap) {
|
|
121
|
+
_this3.filterGlyphs();
|
|
115
122
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
return _initModels.apply(this, arguments);
|
|
123
|
+
const model = yield _this3.layer.buildLayerModel({
|
|
124
|
+
moduleName: 'pointText',
|
|
125
|
+
vertexShader: textVert,
|
|
126
|
+
fragmentShader: textFrag,
|
|
127
|
+
inject: _this3.getInject(),
|
|
128
|
+
triangulation: TextTrianglation.bind(_this3),
|
|
129
|
+
depth: {
|
|
130
|
+
enable: false
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
return [model];
|
|
134
|
+
})();
|
|
135
|
+
}
|
|
136
|
+
// 需要更新的场景
|
|
137
|
+
// 1. 文本偏移量发生改变
|
|
138
|
+
// 2. 文本锚点发生改变
|
|
139
|
+
// 3. 文本允许重叠发生改变
|
|
140
|
+
// 4. 文本字体发生改变
|
|
141
|
+
// 5. 文本字体粗细发生改变
|
|
142
|
+
needUpdate() {
|
|
143
|
+
var _this4 = this;
|
|
144
|
+
return _asyncToGenerator(function* () {
|
|
145
|
+
const {
|
|
146
|
+
textAllowOverlap = false,
|
|
147
|
+
textAnchor = 'center',
|
|
148
|
+
textOffset,
|
|
149
|
+
padding,
|
|
150
|
+
fontFamily,
|
|
151
|
+
fontWeight
|
|
152
|
+
} = _this4.getTextStyle();
|
|
153
|
+
if (!isEqual(padding, _this4.preTextStyle.padding) || !isEqual(textOffset, _this4.preTextStyle.textOffset) || !isEqual(textAnchor, _this4.preTextStyle.textAnchor) || !isEqual(fontFamily, _this4.preTextStyle.fontFamily) || !isEqual(fontWeight, _this4.preTextStyle.fontWeight)) {
|
|
154
|
+
yield _this4.mapping();
|
|
155
|
+
return true;
|
|
150
156
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
key: "buildModels",
|
|
155
|
-
value: function () {
|
|
156
|
-
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
157
|
-
var _ref3, _ref3$textAllowOverla, textAllowOverlap, model;
|
|
158
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
159
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
160
|
-
case 0:
|
|
161
|
-
_ref3 = this.layer.getLayerConfig(), _ref3$textAllowOverla = _ref3.textAllowOverlap, textAllowOverlap = _ref3$textAllowOverla === void 0 ? false : _ref3$textAllowOverla; // this.mapping(); 重复调用
|
|
162
|
-
this.initGlyph(); //
|
|
163
|
-
this.updateTexture();
|
|
164
|
-
if (!textAllowOverlap) {
|
|
165
|
-
this.filterGlyphs();
|
|
166
|
-
}
|
|
167
|
-
_context3.next = 6;
|
|
168
|
-
return this.layer.buildLayerModel({
|
|
169
|
-
moduleName: 'pointText',
|
|
170
|
-
vertexShader: textVert,
|
|
171
|
-
fragmentShader: textFrag,
|
|
172
|
-
inject: this.getInject(),
|
|
173
|
-
triangulation: TextTrianglation.bind(this),
|
|
174
|
-
depth: {
|
|
175
|
-
enable: false
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
case 6:
|
|
179
|
-
model = _context3.sent;
|
|
180
|
-
return _context3.abrupt("return", [model]);
|
|
181
|
-
case 8:
|
|
182
|
-
case "end":
|
|
183
|
-
return _context3.stop();
|
|
184
|
-
}
|
|
185
|
-
}, _callee3, this);
|
|
186
|
-
}));
|
|
187
|
-
function buildModels() {
|
|
188
|
-
return _buildModels.apply(this, arguments);
|
|
157
|
+
if (textAllowOverlap) {
|
|
158
|
+
// 小于不做避让
|
|
159
|
+
return false;
|
|
189
160
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
var _needUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
201
|
-
var _ref4, _ref4$textAllowOverla, textAllowOverlap, _ref4$textAnchor, textAnchor, textOffset, padding, fontFamily, fontWeight, zoom, extent, flag;
|
|
202
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
203
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
204
|
-
case 0:
|
|
205
|
-
_ref4 = this.getTextStyle(), _ref4$textAllowOverla = _ref4.textAllowOverlap, textAllowOverlap = _ref4$textAllowOverla === void 0 ? false : _ref4$textAllowOverla, _ref4$textAnchor = _ref4.textAnchor, textAnchor = _ref4$textAnchor === void 0 ? 'center' : _ref4$textAnchor, textOffset = _ref4.textOffset, padding = _ref4.padding, fontFamily = _ref4.fontFamily, fontWeight = _ref4.fontWeight;
|
|
206
|
-
if (!(!isEqual(padding, this.preTextStyle.padding) || !isEqual(textOffset, this.preTextStyle.textOffset) || !isEqual(textAnchor, this.preTextStyle.textAnchor) || !isEqual(fontFamily, this.preTextStyle.fontFamily) || !isEqual(fontWeight, this.preTextStyle.fontWeight))) {
|
|
207
|
-
_context4.next = 5;
|
|
208
|
-
break;
|
|
209
|
-
}
|
|
210
|
-
_context4.next = 4;
|
|
211
|
-
return this.mapping();
|
|
212
|
-
case 4:
|
|
213
|
-
return _context4.abrupt("return", true);
|
|
214
|
-
case 5:
|
|
215
|
-
if (!textAllowOverlap) {
|
|
216
|
-
_context4.next = 7;
|
|
217
|
-
break;
|
|
218
|
-
}
|
|
219
|
-
return _context4.abrupt("return", false);
|
|
220
|
-
case 7:
|
|
221
|
-
// textAllowOverlap 发生改变
|
|
222
|
-
zoom = this.mapService.getZoom();
|
|
223
|
-
extent = this.mapService.getBounds();
|
|
224
|
-
flag = boundsContains(this.extent, extent); // 文本不能压盖则进行过滤
|
|
225
|
-
if (!(Math.abs(this.currentZoom - zoom) > 0.5 || !flag || textAllowOverlap !== this.preTextStyle.textAllowOverlap)) {
|
|
226
|
-
_context4.next = 14;
|
|
227
|
-
break;
|
|
228
|
-
}
|
|
229
|
-
_context4.next = 13;
|
|
230
|
-
return this.reBuildModel();
|
|
231
|
-
case 13:
|
|
232
|
-
return _context4.abrupt("return", true);
|
|
233
|
-
case 14:
|
|
234
|
-
return _context4.abrupt("return", false);
|
|
235
|
-
case 15:
|
|
236
|
-
case "end":
|
|
237
|
-
return _context4.stop();
|
|
238
|
-
}
|
|
239
|
-
}, _callee4, this);
|
|
240
|
-
}));
|
|
241
|
-
function needUpdate() {
|
|
242
|
-
return _needUpdate.apply(this, arguments);
|
|
161
|
+
|
|
162
|
+
// textAllowOverlap 发生改变
|
|
163
|
+
const zoom = _this4.mapService.getZoom();
|
|
164
|
+
const extent = _this4.mapService.getBounds();
|
|
165
|
+
const flag = boundsContains(_this4.extent, extent);
|
|
166
|
+
// 文本不能压盖则进行过滤
|
|
167
|
+
if (Math.abs(_this4.currentZoom - zoom) > 0.5 || !flag || textAllowOverlap !== _this4.preTextStyle.textAllowOverlap) {
|
|
168
|
+
// TODO this.mapping 数据未变化,避让
|
|
169
|
+
yield _this4.reBuildModel();
|
|
170
|
+
return true;
|
|
243
171
|
}
|
|
244
|
-
return
|
|
245
|
-
}()
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
size: 2,
|
|
271
|
-
update: function update(feature, featureIdx, vertex) {
|
|
272
|
-
return [vertex[5], vertex[6]];
|
|
273
|
-
}
|
|
172
|
+
return false;
|
|
173
|
+
})();
|
|
174
|
+
}
|
|
175
|
+
clearModels() {
|
|
176
|
+
var _this$texture;
|
|
177
|
+
(_this$texture = this.texture) === null || _this$texture === void 0 || _this$texture.destroy();
|
|
178
|
+
// TODO this.mapping
|
|
179
|
+
this.layer.off('remapping', this.mapping);
|
|
180
|
+
}
|
|
181
|
+
registerBuiltinAttributes() {
|
|
182
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
183
|
+
name: 'textOffsets',
|
|
184
|
+
type: AttributeType.Attribute,
|
|
185
|
+
descriptor: {
|
|
186
|
+
shaderLocation: 10,
|
|
187
|
+
name: 'a_textOffsets',
|
|
188
|
+
// 文字偏移量
|
|
189
|
+
buffer: {
|
|
190
|
+
// give the WebGL driver a hint that this buffer may change
|
|
191
|
+
usage: gl.STATIC_DRAW,
|
|
192
|
+
data: [],
|
|
193
|
+
type: gl.FLOAT
|
|
194
|
+
},
|
|
195
|
+
size: 2,
|
|
196
|
+
update: (feature, featureIdx, vertex) => {
|
|
197
|
+
return [vertex[5], vertex[6]];
|
|
274
198
|
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
202
|
+
name: 'textUv',
|
|
203
|
+
type: AttributeType.Attribute,
|
|
204
|
+
descriptor: {
|
|
205
|
+
name: 'a_tex',
|
|
206
|
+
shaderLocation: ShaderLocation.UV,
|
|
207
|
+
buffer: {
|
|
208
|
+
usage: gl.DYNAMIC_DRAW,
|
|
209
|
+
data: [],
|
|
210
|
+
type: gl.FLOAT
|
|
211
|
+
},
|
|
212
|
+
size: 2,
|
|
213
|
+
update: (feature, featureIdx, vertex) => {
|
|
214
|
+
return [vertex[3], vertex[4]];
|
|
291
215
|
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
// point layer size;
|
|
219
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
220
|
+
name: 'size',
|
|
221
|
+
type: AttributeType.Attribute,
|
|
222
|
+
descriptor: {
|
|
223
|
+
name: 'a_Size',
|
|
224
|
+
shaderLocation: ShaderLocation.SIZE,
|
|
225
|
+
buffer: {
|
|
226
|
+
// give the WebGL driver a hint that this buffer may change
|
|
227
|
+
usage: gl.DYNAMIC_DRAW,
|
|
228
|
+
data: [],
|
|
229
|
+
type: gl.FLOAT
|
|
230
|
+
},
|
|
231
|
+
size: 1,
|
|
232
|
+
update: feature => {
|
|
233
|
+
const {
|
|
234
|
+
size = 12
|
|
235
|
+
} = feature;
|
|
236
|
+
return Array.isArray(size) ? [size[0]] : [size];
|
|
312
237
|
}
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
}, {
|
|
316
|
-
key: "bindEvent",
|
|
317
|
-
value: function bindEvent() {
|
|
318
|
-
if (!this.layer.isTileLayer) {
|
|
319
|
-
// 重新绑定
|
|
320
|
-
this.layer.on('remapping', this.mapping);
|
|
321
238
|
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
bindEvent() {
|
|
242
|
+
if (!this.layer.isTileLayer) {
|
|
243
|
+
// 重新绑定
|
|
244
|
+
this.layer.on('remapping', this.mapping);
|
|
322
245
|
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
348
|
-
var char = _step.value;
|
|
349
|
-
// 去重
|
|
350
|
-
if (characterSet.indexOf(char) === -1) {
|
|
351
|
-
characterSet.push(char);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
} catch (err) {
|
|
355
|
-
_iterator.e(err);
|
|
356
|
-
} finally {
|
|
357
|
-
_iterator.f();
|
|
246
|
+
}
|
|
247
|
+
textExtent() {
|
|
248
|
+
const bounds = this.mapService.getBounds();
|
|
249
|
+
return padBounds(bounds, 0.5);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* 生成文字纹理(生成文字纹理字典)
|
|
253
|
+
*/
|
|
254
|
+
initTextFont() {
|
|
255
|
+
const {
|
|
256
|
+
fontWeight,
|
|
257
|
+
fontFamily
|
|
258
|
+
} = this.getTextStyle();
|
|
259
|
+
const data = this.rawEncodeData;
|
|
260
|
+
const characterSet = [];
|
|
261
|
+
data.forEach(item => {
|
|
262
|
+
let {
|
|
263
|
+
shape = ''
|
|
264
|
+
} = item;
|
|
265
|
+
shape = shape.toString();
|
|
266
|
+
for (const char of shape) {
|
|
267
|
+
// 去重
|
|
268
|
+
if (characterSet.indexOf(char) === -1) {
|
|
269
|
+
characterSet.push(char);
|
|
358
270
|
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
}
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
this.fontService.setFontOptions({
|
|
274
|
+
characterSet,
|
|
275
|
+
fontWeight,
|
|
276
|
+
fontFamily,
|
|
277
|
+
iconfont: false
|
|
278
|
+
});
|
|
279
|
+
}
|
|
367
280
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
fontFamily: fontFamily,
|
|
421
|
-
textAllowOverlap: textAllowOverlap,
|
|
422
|
-
padding: padding,
|
|
423
|
-
textAnchor: textAnchor,
|
|
424
|
-
textOffset: textOffset,
|
|
425
|
-
opacity: opacity,
|
|
426
|
-
strokeOpacity: strokeOpacity,
|
|
427
|
-
strokeWidth: strokeWidth,
|
|
428
|
-
stroke: stroke
|
|
429
|
-
};
|
|
430
|
-
}
|
|
281
|
+
/**
|
|
282
|
+
* 生成 iconfont 纹理字典
|
|
283
|
+
*/
|
|
284
|
+
initIconFontTex() {
|
|
285
|
+
const {
|
|
286
|
+
fontWeight,
|
|
287
|
+
fontFamily
|
|
288
|
+
} = this.getTextStyle();
|
|
289
|
+
const data = this.rawEncodeData;
|
|
290
|
+
const characterSet = [];
|
|
291
|
+
data.forEach(item => {
|
|
292
|
+
let {
|
|
293
|
+
shape = ''
|
|
294
|
+
} = item;
|
|
295
|
+
shape = `${shape}`;
|
|
296
|
+
if (characterSet.indexOf(shape) === -1) {
|
|
297
|
+
characterSet.push(shape);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
this.fontService.setFontOptions({
|
|
301
|
+
characterSet,
|
|
302
|
+
fontWeight,
|
|
303
|
+
fontFamily,
|
|
304
|
+
iconfont: true
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
getTextStyle() {
|
|
308
|
+
const {
|
|
309
|
+
fontWeight = '400',
|
|
310
|
+
fontFamily = 'sans-serif',
|
|
311
|
+
textAllowOverlap = false,
|
|
312
|
+
padding = [0, 0],
|
|
313
|
+
textAnchor = 'center',
|
|
314
|
+
textOffset = [0, 0],
|
|
315
|
+
opacity = 1,
|
|
316
|
+
strokeOpacity = 1,
|
|
317
|
+
strokeWidth = 0,
|
|
318
|
+
stroke = '#000'
|
|
319
|
+
} = this.layer.getLayerConfig();
|
|
320
|
+
return {
|
|
321
|
+
fontWeight,
|
|
322
|
+
fontFamily,
|
|
323
|
+
textAllowOverlap,
|
|
324
|
+
padding,
|
|
325
|
+
textAnchor,
|
|
326
|
+
textOffset,
|
|
327
|
+
opacity,
|
|
328
|
+
strokeOpacity,
|
|
329
|
+
strokeWidth,
|
|
330
|
+
stroke
|
|
331
|
+
};
|
|
332
|
+
}
|
|
431
333
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
var glyphQuads = getGlyphQuads(shaping, offset, false);
|
|
461
|
-
feature.shaping = shaping;
|
|
462
|
-
feature.glyphQuads = glyphQuads;
|
|
463
|
-
// feature.centroid = calculteCentroid(coordinates);
|
|
334
|
+
/**
|
|
335
|
+
* 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)
|
|
336
|
+
*/
|
|
337
|
+
generateGlyphLayout(iconfont) {
|
|
338
|
+
const mapping = this.getFontServiceMapping();
|
|
339
|
+
const {
|
|
340
|
+
spacing = 2,
|
|
341
|
+
textAnchor = 'center',
|
|
342
|
+
textOffset
|
|
343
|
+
} = this.layer.getLayerConfig();
|
|
344
|
+
const data = this.rawEncodeData;
|
|
345
|
+
this.glyphInfo = data.map(feature => {
|
|
346
|
+
const {
|
|
347
|
+
shape = '',
|
|
348
|
+
id,
|
|
349
|
+
size = 1
|
|
350
|
+
} = feature;
|
|
351
|
+
const offset = feature.textOffset ? feature.textOffset : textOffset || [0, 0];
|
|
352
|
+
const anchor = feature.textAnchor ? feature.textAnchor : textAnchor || 'center';
|
|
353
|
+
const shaping = shapeText(shape.toString(), mapping,
|
|
354
|
+
// @ts-ignore
|
|
355
|
+
size, anchor, 'left', spacing, offset,
|
|
356
|
+
//
|
|
357
|
+
iconfont);
|
|
358
|
+
const glyphQuads = getGlyphQuads(shaping, offset, false);
|
|
359
|
+
feature.shaping = shaping;
|
|
360
|
+
feature.glyphQuads = glyphQuads;
|
|
361
|
+
// feature.centroid = calculteCentroid(coordinates);
|
|
464
362
|
|
|
465
|
-
|
|
363
|
+
feature.centroid = calculateCentroid(feature.coordinates);
|
|
466
364
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
fontWeight = _ref8$fontWeight === void 0 ? '400' : _ref8$fontWeight,
|
|
493
|
-
_ref8$fontFamily = _ref8.fontFamily,
|
|
494
|
-
fontFamily = _ref8$fontFamily === void 0 ? 'sans-serif' : _ref8$fontFamily;
|
|
495
|
-
// 更新文字布局
|
|
496
|
-
return this.fontService.getCanvasByKey("".concat(fontFamily, "_").concat(fontWeight));
|
|
497
|
-
}
|
|
365
|
+
// 此时地图高德2.0 originCentroid == centroid
|
|
366
|
+
feature.originCentroid = feature.version === 'GAODE2.x' ? calculateCentroid(feature.originCoordinates) : feature.originCentroid = feature.centroid;
|
|
367
|
+
this.glyphInfoMap[id] = {
|
|
368
|
+
shaping,
|
|
369
|
+
glyphQuads,
|
|
370
|
+
centroid: calculateCentroid(feature.coordinates)
|
|
371
|
+
};
|
|
372
|
+
return feature;
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
getFontServiceMapping() {
|
|
376
|
+
const {
|
|
377
|
+
fontWeight = '400',
|
|
378
|
+
fontFamily = 'sans-serif'
|
|
379
|
+
} = this.layer.getLayerConfig();
|
|
380
|
+
return this.fontService.getMappingByKey(`${fontFamily}_${fontWeight}`);
|
|
381
|
+
}
|
|
382
|
+
getFontServiceCanvas() {
|
|
383
|
+
const {
|
|
384
|
+
fontWeight = '400',
|
|
385
|
+
fontFamily = 'sans-serif'
|
|
386
|
+
} = this.layer.getLayerConfig();
|
|
387
|
+
// 更新文字布局
|
|
388
|
+
return this.fontService.getCanvasByKey(`${fontFamily}_${fontWeight}`);
|
|
389
|
+
}
|
|
498
390
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
textAllowOverlap = _ref9$textAllowOverla === void 0 ? false : _ref9$textAllowOverla;
|
|
511
|
-
if (textAllowOverlap) {
|
|
512
|
-
// 如果允许文本覆盖
|
|
513
|
-
return;
|
|
514
|
-
}
|
|
515
|
-
this.glyphInfoMap = {};
|
|
516
|
-
this.currentZoom = this.mapService.getZoom();
|
|
517
|
-
this.extent = this.textExtent();
|
|
518
|
-
var _this$rendererService = this.rendererService.getViewportSize(),
|
|
519
|
-
width = _this$rendererService.width,
|
|
520
|
-
height = _this$rendererService.height;
|
|
521
|
-
var collisionIndex = new CollisionIndex(width, height);
|
|
522
|
-
var filterData = this.glyphInfo.filter(function (feature) {
|
|
523
|
-
var shaping = feature.shaping,
|
|
524
|
-
_feature$id = feature.id,
|
|
525
|
-
id = _feature$id === void 0 ? 0 : _feature$id;
|
|
526
|
-
// const centroid = feature.centroid as [number, number];
|
|
527
|
-
// const centroid = feature.originCentroid as [number, number];
|
|
528
|
-
var centroid = feature.version === 'GAODE2.x' ? feature.originCentroid : feature.centroid;
|
|
529
|
-
var size = feature.size;
|
|
530
|
-
var fontScale = size / 16;
|
|
531
|
-
var pixels = _this3.mapService.lngLatToContainer(centroid);
|
|
532
|
-
var _collisionIndex$place = collisionIndex.placeCollisionBox({
|
|
533
|
-
x1: shaping.left * fontScale - padding[0],
|
|
534
|
-
x2: shaping.right * fontScale + padding[0],
|
|
535
|
-
y1: shaping.top * fontScale - padding[1],
|
|
536
|
-
y2: shaping.bottom * fontScale + padding[1],
|
|
537
|
-
anchorPointX: pixels.x,
|
|
538
|
-
anchorPointY: pixels.y
|
|
539
|
-
}),
|
|
540
|
-
box = _collisionIndex$place.box;
|
|
541
|
-
if (box && box.length) {
|
|
542
|
-
collisionIndex.insertCollisionBox(box, id);
|
|
543
|
-
return true;
|
|
544
|
-
} else {
|
|
545
|
-
return false;
|
|
546
|
-
}
|
|
547
|
-
});
|
|
548
|
-
filterData.forEach(function (item) {
|
|
549
|
-
// @ts-ignore
|
|
550
|
-
_this3.glyphInfoMap[item.id] = item;
|
|
551
|
-
});
|
|
552
|
-
// this.layer.setEncodedData(filterData);
|
|
391
|
+
/**
|
|
392
|
+
* 文字避让 depend on originCentorid
|
|
393
|
+
*/
|
|
394
|
+
filterGlyphs() {
|
|
395
|
+
const {
|
|
396
|
+
padding = [0, 0],
|
|
397
|
+
textAllowOverlap = false
|
|
398
|
+
} = this.layer.getLayerConfig();
|
|
399
|
+
if (textAllowOverlap) {
|
|
400
|
+
// 如果允许文本覆盖
|
|
401
|
+
return;
|
|
553
402
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
mag: gl.LINEAR,
|
|
583
|
-
min: gl.LINEAR,
|
|
584
|
-
width: canvas.width,
|
|
585
|
-
height: canvas.height
|
|
403
|
+
this.glyphInfoMap = {};
|
|
404
|
+
this.currentZoom = this.mapService.getZoom();
|
|
405
|
+
this.extent = this.textExtent();
|
|
406
|
+
const {
|
|
407
|
+
width,
|
|
408
|
+
height
|
|
409
|
+
} = this.rendererService.getViewportSize();
|
|
410
|
+
const collisionIndex = new CollisionIndex(width, height);
|
|
411
|
+
const filterData = this.glyphInfo.filter(feature => {
|
|
412
|
+
const {
|
|
413
|
+
shaping,
|
|
414
|
+
id = 0
|
|
415
|
+
} = feature;
|
|
416
|
+
// const centroid = feature.centroid as [number, number];
|
|
417
|
+
// const centroid = feature.originCentroid as [number, number];
|
|
418
|
+
const centroid = feature.version === 'GAODE2.x' ? feature.originCentroid : feature.centroid;
|
|
419
|
+
const size = feature.size;
|
|
420
|
+
const fontScale = size / 16;
|
|
421
|
+
const pixels = this.mapService.lngLatToContainer(centroid);
|
|
422
|
+
const {
|
|
423
|
+
box
|
|
424
|
+
} = collisionIndex.placeCollisionBox({
|
|
425
|
+
x1: shaping.left * fontScale - padding[0],
|
|
426
|
+
x2: shaping.right * fontScale + padding[0],
|
|
427
|
+
y1: shaping.top * fontScale - padding[1],
|
|
428
|
+
y2: shaping.bottom * fontScale + padding[1],
|
|
429
|
+
anchorPointX: pixels.x,
|
|
430
|
+
anchorPointY: pixels.y
|
|
586
431
|
});
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
var _reBuildModel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
593
|
-
var model;
|
|
594
|
-
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
595
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
596
|
-
case 0:
|
|
597
|
-
this.filterGlyphs();
|
|
598
|
-
_context5.next = 3;
|
|
599
|
-
return this.layer.buildLayerModel({
|
|
600
|
-
moduleName: 'pointText',
|
|
601
|
-
vertexShader: textVert,
|
|
602
|
-
fragmentShader: textFrag,
|
|
603
|
-
triangulation: TextTrianglation.bind(this),
|
|
604
|
-
inject: this.getInject(),
|
|
605
|
-
depth: {
|
|
606
|
-
enable: false
|
|
607
|
-
}
|
|
608
|
-
});
|
|
609
|
-
case 3:
|
|
610
|
-
model = _context5.sent;
|
|
611
|
-
// TODO 渲染流程待修改
|
|
612
|
-
this.layer.models = [model];
|
|
613
|
-
case 5:
|
|
614
|
-
case "end":
|
|
615
|
-
return _context5.stop();
|
|
616
|
-
}
|
|
617
|
-
}, _callee5, this);
|
|
618
|
-
}));
|
|
619
|
-
function reBuildModel() {
|
|
620
|
-
return _reBuildModel.apply(this, arguments);
|
|
432
|
+
if (box && box.length) {
|
|
433
|
+
collisionIndex.insertCollisionBox(box, id);
|
|
434
|
+
return true;
|
|
435
|
+
} else {
|
|
436
|
+
return false;
|
|
621
437
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
}
|
|
627
|
-
|
|
438
|
+
});
|
|
439
|
+
filterData.forEach(item => {
|
|
440
|
+
// @ts-ignore
|
|
441
|
+
this.glyphInfoMap[item.id] = item;
|
|
442
|
+
});
|
|
443
|
+
// this.layer.setEncodedData(filterData);
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* 初始化文字布局
|
|
447
|
+
*/
|
|
448
|
+
initGlyph() {
|
|
449
|
+
const {
|
|
450
|
+
iconfont = false
|
|
451
|
+
} = this.layer.getLayerConfig();
|
|
452
|
+
// 1.生成文字纹理(或是生成 iconfont)
|
|
453
|
+
iconfont ? this.initIconFontTex() : this.initTextFont();
|
|
454
|
+
// 2.生成文字布局
|
|
455
|
+
this.generateGlyphLayout(iconfont);
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* 更新文字纹理
|
|
459
|
+
*/
|
|
460
|
+
updateTexture() {
|
|
461
|
+
const {
|
|
462
|
+
createTexture2D
|
|
463
|
+
} = this.rendererService;
|
|
464
|
+
const canvas = this.getFontServiceCanvas();
|
|
465
|
+
this.textureHeight = canvas.height;
|
|
466
|
+
if (this.texture) {
|
|
467
|
+
this.texture.destroy();
|
|
468
|
+
}
|
|
469
|
+
this.texture = createTexture2D({
|
|
470
|
+
data: canvas,
|
|
471
|
+
mag: gl.LINEAR,
|
|
472
|
+
min: gl.LINEAR,
|
|
473
|
+
width: canvas.width,
|
|
474
|
+
height: canvas.height
|
|
475
|
+
});
|
|
476
|
+
this.textures = [this.texture];
|
|
477
|
+
}
|
|
478
|
+
reBuildModel() {
|
|
479
|
+
var _this5 = this;
|
|
480
|
+
return _asyncToGenerator(function* () {
|
|
481
|
+
_this5.filterGlyphs();
|
|
482
|
+
const model = yield _this5.layer.buildLayerModel({
|
|
483
|
+
moduleName: 'pointText',
|
|
484
|
+
vertexShader: textVert,
|
|
485
|
+
fragmentShader: textFrag,
|
|
486
|
+
triangulation: TextTrianglation.bind(_this5),
|
|
487
|
+
inject: _this5.getInject(),
|
|
488
|
+
depth: {
|
|
489
|
+
enable: false
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
// TODO 渲染流程待修改
|
|
493
|
+
_this5.layer.models = [model];
|
|
494
|
+
})();
|
|
495
|
+
}
|
|
496
|
+
}
|