@antv/l7-layers 2.21.1 → 2.21.3
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/plugins/index.d.ts +1 -1
- 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.d.ts +1 -1
- package/es/tile/tile/index.js +4 -2
- package/es/tile/tile/util.d.ts +1 -1
- 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/es/glsl.d.ts +0 -5
- package/lib/glsl.d.ts +0 -5
package/es/core/triangulation.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
1
|
import { calculateCentroid, calculatePointsCenterAndRadius, lngLatToMeters, aProjectFlat } from '@antv/l7-utils';
|
|
4
2
|
import earcut from 'earcut';
|
|
5
3
|
// @ts-ignore
|
|
@@ -8,7 +6,7 @@ import { EARTH_RADIUS, EARTH_RADIUS_OUTER, EARTH_SEGMENTS, lglt2xyz, primitiveSp
|
|
|
8
6
|
import ExtrudePolyline from "../utils/extrude_polyline";
|
|
9
7
|
import extrudePolygon, { extrude_PolygonNormal, fillPolygon } from "./shape/extrude";
|
|
10
8
|
import { geometryShape } from "./shape/Path";
|
|
11
|
-
|
|
9
|
+
const GeometryCache = {};
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* 计算2D 填充点图顶点
|
|
@@ -16,9 +14,9 @@ var GeometryCache = {};
|
|
|
16
14
|
*/
|
|
17
15
|
|
|
18
16
|
export function PointFillTriangulation(feature) {
|
|
19
|
-
|
|
17
|
+
const coordinates = calculateCentroid(feature.coordinates);
|
|
20
18
|
return {
|
|
21
|
-
vertices: [
|
|
19
|
+
vertices: [...coordinates, ...coordinates, ...coordinates, ...coordinates],
|
|
22
20
|
indices: [0, 1, 2, 2, 3, 0],
|
|
23
21
|
size: coordinates.length
|
|
24
22
|
};
|
|
@@ -28,10 +26,10 @@ export function PointFillTriangulation(feature) {
|
|
|
28
26
|
* @param feature 映射feature
|
|
29
27
|
*/
|
|
30
28
|
export function GlobelPointFillTriangulation(feature) {
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const coordinates = calculateCentroid(feature.coordinates);
|
|
30
|
+
const xyz = lglt2xyz(coordinates);
|
|
33
31
|
return {
|
|
34
|
-
vertices: [
|
|
32
|
+
vertices: [...xyz, ...xyz, ...xyz, ...xyz],
|
|
35
33
|
indices: [0, 1, 2, 2, 3, 0],
|
|
36
34
|
size: xyz.length
|
|
37
35
|
};
|
|
@@ -42,15 +40,18 @@ export function GlobelPointFillTriangulation(feature) {
|
|
|
42
40
|
* @param feature 映射feature
|
|
43
41
|
*/
|
|
44
42
|
export function PointExtrudeTriangulation(feature) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
const {
|
|
44
|
+
shape
|
|
45
|
+
} = feature;
|
|
46
|
+
const {
|
|
47
|
+
positions,
|
|
48
|
+
index,
|
|
49
|
+
normals
|
|
50
|
+
} = getGeometry(shape, false);
|
|
50
51
|
return {
|
|
51
52
|
vertices: positions,
|
|
52
53
|
indices: index,
|
|
53
|
-
normals
|
|
54
|
+
normals,
|
|
54
55
|
size: 5
|
|
55
56
|
};
|
|
56
57
|
}
|
|
@@ -60,9 +61,9 @@ export function PointExtrudeTriangulation(feature) {
|
|
|
60
61
|
* @param feature 映射feature
|
|
61
62
|
*/
|
|
62
63
|
export function PointImageTriangulation(feature) {
|
|
63
|
-
|
|
64
|
+
const coordinates = calculateCentroid(feature.coordinates);
|
|
64
65
|
return {
|
|
65
|
-
vertices:
|
|
66
|
+
vertices: [...coordinates],
|
|
66
67
|
indices: [0],
|
|
67
68
|
size: coordinates.length
|
|
68
69
|
};
|
|
@@ -73,45 +74,47 @@ export function PointImageTriangulation(feature) {
|
|
|
73
74
|
* @param feature 映射feature
|
|
74
75
|
*/
|
|
75
76
|
export function LineTriangulation(feature) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
const {
|
|
78
|
+
coordinates,
|
|
79
|
+
originCoordinates,
|
|
80
|
+
version
|
|
81
|
+
} = feature;
|
|
79
82
|
// let path = coordinates as number[][][] | number[][];
|
|
80
83
|
// if (!Array.isArray(path[0][0])) {
|
|
81
84
|
// path = [coordinates] as number[][][];
|
|
82
85
|
// }
|
|
83
86
|
|
|
84
|
-
|
|
87
|
+
const line = new ExtrudePolyline({
|
|
85
88
|
dash: true,
|
|
86
89
|
join: 'bevel'
|
|
87
90
|
});
|
|
88
91
|
if (version === 'GAODE2.x') {
|
|
89
92
|
// 处理高德2.0几何体构建
|
|
90
|
-
|
|
93
|
+
let path1 = coordinates; // 计算位置
|
|
91
94
|
if (!Array.isArray(path1[0][0])) {
|
|
92
95
|
path1 = [coordinates];
|
|
93
96
|
}
|
|
94
|
-
|
|
97
|
+
let path2 = originCoordinates; // 计算法线
|
|
95
98
|
if (!Array.isArray(path2[0][0])) {
|
|
96
99
|
path2 = [originCoordinates];
|
|
97
100
|
}
|
|
98
|
-
for (
|
|
101
|
+
for (let i = 0; i < path1.length; i++) {
|
|
99
102
|
// 高德2.0在计算线时,需要使用经纬度计算发现,使用 customCoords.lnglatToCoords 计算的数据来计算顶点的位置
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
const item1 = path1[i];
|
|
104
|
+
const item2 = path2[i];
|
|
102
105
|
line.extrude_gaode2(item1, item2);
|
|
103
106
|
}
|
|
104
107
|
} else {
|
|
105
108
|
// 处理非高德2.0的几何体构建
|
|
106
|
-
|
|
109
|
+
let path = coordinates;
|
|
107
110
|
if (path[0] && !Array.isArray(path[0][0])) {
|
|
108
111
|
path = [coordinates];
|
|
109
112
|
}
|
|
110
|
-
path.forEach(
|
|
113
|
+
path.forEach(item => {
|
|
111
114
|
line.extrude(item);
|
|
112
115
|
});
|
|
113
116
|
}
|
|
114
|
-
|
|
117
|
+
const linebuffer = line.complex;
|
|
115
118
|
return {
|
|
116
119
|
vertices: linebuffer.positions,
|
|
117
120
|
// [ x,y,z, distance, miter,total ]
|
|
@@ -123,29 +126,38 @@ export function LineTriangulation(feature) {
|
|
|
123
126
|
}
|
|
124
127
|
export function FlowLineFillTriangulation(feature) {
|
|
125
128
|
// @ts-ignore
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
const coord = feature.coordinates.flat();
|
|
130
|
+
const tin = 1;
|
|
131
|
+
const tout = 1.0;
|
|
129
132
|
return {
|
|
130
|
-
vertices: [1, 0, 0
|
|
133
|
+
vertices: [1, 0, 0, ...coord,
|
|
131
134
|
// 0
|
|
132
|
-
1, 2, -3
|
|
135
|
+
1, 2, -3,
|
|
136
|
+
// mapbox 为正
|
|
137
|
+
...coord,
|
|
133
138
|
// 1
|
|
134
|
-
1, 1, -3
|
|
139
|
+
1, 1, -3,
|
|
140
|
+
// mapbox 为正
|
|
141
|
+
...coord,
|
|
135
142
|
// 2
|
|
136
|
-
0, 1, 0
|
|
143
|
+
0, 1, 0, ...coord,
|
|
137
144
|
// 3
|
|
138
|
-
0, 0, 0
|
|
145
|
+
0, 0, 0, ...coord,
|
|
139
146
|
// 4
|
|
140
|
-
1, 0, 0
|
|
147
|
+
1, 0, 0, ...coord,
|
|
141
148
|
// 0
|
|
142
|
-
1, 2, -3
|
|
149
|
+
1, 2, -3,
|
|
150
|
+
// mapbox 为正
|
|
151
|
+
...coord,
|
|
143
152
|
// 1
|
|
144
|
-
1, 1, -3
|
|
153
|
+
1, 1, -3,
|
|
154
|
+
// // mapbox 为正
|
|
155
|
+
...coord,
|
|
145
156
|
// 2
|
|
146
|
-
0, 1, 0
|
|
157
|
+
0, 1, 0, ...coord,
|
|
147
158
|
// 3
|
|
148
|
-
0, 0, 0
|
|
159
|
+
0, 0, 0, ...coord // 4
|
|
160
|
+
],
|
|
149
161
|
normals: [-tin, 2 * tout, 1,
|
|
150
162
|
// 0
|
|
151
163
|
2 * tout, -tout, 1,
|
|
@@ -162,9 +174,11 @@ export function FlowLineFillTriangulation(feature) {
|
|
|
162
174
|
};
|
|
163
175
|
}
|
|
164
176
|
export function SimpleLineTriangulation(feature) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
177
|
+
const {
|
|
178
|
+
coordinates,
|
|
179
|
+
originCoordinates
|
|
180
|
+
} = feature;
|
|
181
|
+
const pos = [];
|
|
168
182
|
if (!Array.isArray(coordinates[0])) {
|
|
169
183
|
return {
|
|
170
184
|
vertices: [],
|
|
@@ -174,10 +188,11 @@ export function SimpleLineTriangulation(feature) {
|
|
|
174
188
|
count: 0
|
|
175
189
|
};
|
|
176
190
|
}
|
|
177
|
-
|
|
178
|
-
results
|
|
179
|
-
totalDistance
|
|
180
|
-
|
|
191
|
+
const {
|
|
192
|
+
results,
|
|
193
|
+
totalDistance
|
|
194
|
+
} = getSimpleLineVertices(coordinates, originCoordinates);
|
|
195
|
+
results.map(point => {
|
|
181
196
|
pos.push(point[0], point[1], point[2], point[3], 0, totalDistance);
|
|
182
197
|
});
|
|
183
198
|
return {
|
|
@@ -189,8 +204,10 @@ export function SimpleLineTriangulation(feature) {
|
|
|
189
204
|
};
|
|
190
205
|
}
|
|
191
206
|
export function TileSimpleLineTriangulation(feature) {
|
|
192
|
-
|
|
193
|
-
|
|
207
|
+
const {
|
|
208
|
+
coordinates
|
|
209
|
+
} = feature;
|
|
210
|
+
const pos = [];
|
|
194
211
|
if (!Array.isArray(coordinates[0])) {
|
|
195
212
|
return {
|
|
196
213
|
vertices: [],
|
|
@@ -199,9 +216,10 @@ export function TileSimpleLineTriangulation(feature) {
|
|
|
199
216
|
count: 0
|
|
200
217
|
};
|
|
201
218
|
}
|
|
202
|
-
|
|
203
|
-
results
|
|
204
|
-
|
|
219
|
+
const {
|
|
220
|
+
results
|
|
221
|
+
} = getTileSimpleLineVertices(coordinates);
|
|
222
|
+
results.map(point => {
|
|
205
223
|
pos.push(point[0], point[1], point[2], point[3]);
|
|
206
224
|
});
|
|
207
225
|
return {
|
|
@@ -212,8 +230,8 @@ export function TileSimpleLineTriangulation(feature) {
|
|
|
212
230
|
};
|
|
213
231
|
}
|
|
214
232
|
function lineSegmentDistance(b1, a1) {
|
|
215
|
-
|
|
216
|
-
|
|
233
|
+
const dx = a1[0] - b1[0];
|
|
234
|
+
const dy = a1[1] - b1[1];
|
|
217
235
|
return Math.sqrt(dx * dx + dy * dy);
|
|
218
236
|
}
|
|
219
237
|
function pushDis(point, n) {
|
|
@@ -226,9 +244,9 @@ function pushDis(point, n) {
|
|
|
226
244
|
return point;
|
|
227
245
|
}
|
|
228
246
|
function getSimpleLineVertices(coordinates, originCoordinates) {
|
|
229
|
-
|
|
247
|
+
let points = coordinates;
|
|
230
248
|
//除了amap2.0以外 coordinates就是经纬度数据
|
|
231
|
-
|
|
249
|
+
let originPoints = originCoordinates || coordinates;
|
|
232
250
|
if (Array.isArray(points) && Array.isArray(points[0]) && Array.isArray(points[0][0])) {
|
|
233
251
|
// @ts-ignore
|
|
234
252
|
points = originCoordinates.flat();
|
|
@@ -236,28 +254,28 @@ function getSimpleLineVertices(coordinates, originCoordinates) {
|
|
|
236
254
|
originPoints = originCoordinates.flat();
|
|
237
255
|
}
|
|
238
256
|
//修改计算距离的方式,与普通线的计算方式保持一致 edit by huyang 20231214
|
|
239
|
-
|
|
257
|
+
let distance = 0;
|
|
240
258
|
if (points.length < 2) {
|
|
241
259
|
return {
|
|
242
260
|
results: points,
|
|
243
261
|
totalDistance: 0
|
|
244
262
|
};
|
|
245
263
|
} else {
|
|
246
|
-
|
|
247
|
-
|
|
264
|
+
const results = [];
|
|
265
|
+
const point = pushDis(points[0], distance);
|
|
248
266
|
results.push(point);
|
|
249
|
-
for (
|
|
250
|
-
|
|
267
|
+
for (let i = 1; i < points.length - 1; i++) {
|
|
268
|
+
const subDistance = lineSegmentDistance(aProjectFlat(originPoints[i - 1]), aProjectFlat(originPoints[i]));
|
|
251
269
|
distance += subDistance;
|
|
252
|
-
|
|
270
|
+
const mulPoint = pushDis(points[i], distance);
|
|
253
271
|
results.push(mulPoint);
|
|
254
272
|
results.push(mulPoint);
|
|
255
273
|
}
|
|
256
|
-
|
|
274
|
+
const pointDistance = lineSegmentDistance(aProjectFlat(originPoints[originPoints.length - 2]), aProjectFlat(originPoints[originPoints.length - 1]));
|
|
257
275
|
distance += pointDistance;
|
|
258
276
|
results.push(pushDis(points[points.length - 1], distance));
|
|
259
277
|
return {
|
|
260
|
-
results
|
|
278
|
+
results,
|
|
261
279
|
totalDistance: distance
|
|
262
280
|
};
|
|
263
281
|
}
|
|
@@ -268,40 +286,48 @@ function getTileSimpleLineVertices(points) {
|
|
|
268
286
|
results: points
|
|
269
287
|
};
|
|
270
288
|
} else {
|
|
271
|
-
|
|
272
|
-
|
|
289
|
+
const results = [];
|
|
290
|
+
const point = pushDis(points[0]);
|
|
273
291
|
results.push(point);
|
|
274
|
-
for (
|
|
275
|
-
|
|
292
|
+
for (let i = 1; i < points.length - 1; i++) {
|
|
293
|
+
const mulPoint = pushDis(points[i]);
|
|
276
294
|
results.push(mulPoint);
|
|
277
295
|
results.push(mulPoint);
|
|
278
296
|
}
|
|
279
297
|
results.push(pushDis(points[points.length - 1]));
|
|
280
298
|
return {
|
|
281
|
-
results
|
|
299
|
+
results
|
|
282
300
|
};
|
|
283
301
|
}
|
|
284
302
|
}
|
|
285
303
|
export function polygonTriangulation(feature) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
304
|
+
const {
|
|
305
|
+
coordinates
|
|
306
|
+
} = feature;
|
|
307
|
+
const flattengeo = earcut.flatten(coordinates);
|
|
308
|
+
const {
|
|
309
|
+
vertices,
|
|
310
|
+
dimensions,
|
|
311
|
+
holes
|
|
312
|
+
} = flattengeo;
|
|
291
313
|
return {
|
|
292
314
|
indices: earcut(vertices, holes, dimensions),
|
|
293
|
-
vertices
|
|
315
|
+
vertices,
|
|
294
316
|
size: dimensions
|
|
295
317
|
};
|
|
296
318
|
}
|
|
297
319
|
|
|
298
320
|
// 构建几何图形(带有中心点和大小)
|
|
299
321
|
export function polygonTriangulationWithCenter(feature) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
322
|
+
const {
|
|
323
|
+
coordinates
|
|
324
|
+
} = feature;
|
|
325
|
+
const flattengeo = earcut.flatten(coordinates);
|
|
326
|
+
const {
|
|
327
|
+
vertices,
|
|
328
|
+
dimensions,
|
|
329
|
+
holes
|
|
330
|
+
} = flattengeo;
|
|
305
331
|
return {
|
|
306
332
|
indices: earcut(vertices, holes, dimensions),
|
|
307
333
|
vertices: getVerticesWithCenter(vertices),
|
|
@@ -309,36 +335,41 @@ export function polygonTriangulationWithCenter(feature) {
|
|
|
309
335
|
};
|
|
310
336
|
}
|
|
311
337
|
function getVerticesWithCenter(vertices) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
center
|
|
315
|
-
radius
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
338
|
+
const verticesWithCenter = [];
|
|
339
|
+
const {
|
|
340
|
+
center,
|
|
341
|
+
radius
|
|
342
|
+
} = calculatePointsCenterAndRadius(vertices);
|
|
343
|
+
for (let i = 0; i < vertices.length; i += 2) {
|
|
344
|
+
const lng = vertices[i];
|
|
345
|
+
const lat = vertices[i + 1];
|
|
346
|
+
verticesWithCenter.push(lng, lat, 0, ...center, radius);
|
|
320
347
|
}
|
|
321
348
|
return verticesWithCenter;
|
|
322
349
|
}
|
|
323
350
|
export function PolygonExtrudeTriangulation(feature) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
positions
|
|
327
|
-
index
|
|
328
|
-
normals
|
|
351
|
+
const coordinates = feature.coordinates;
|
|
352
|
+
const {
|
|
353
|
+
positions,
|
|
354
|
+
index,
|
|
355
|
+
normals
|
|
356
|
+
} = extrude_PolygonNormal(coordinates, true);
|
|
329
357
|
return {
|
|
330
358
|
vertices: positions,
|
|
331
359
|
// [ x, y, z, uv.x,uv.y ]
|
|
332
360
|
indices: index,
|
|
333
|
-
normals
|
|
361
|
+
normals,
|
|
334
362
|
size: 5
|
|
335
363
|
};
|
|
336
364
|
}
|
|
337
365
|
export function HeatmapGridTriangulation(feature) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
366
|
+
const {
|
|
367
|
+
shape
|
|
368
|
+
} = feature;
|
|
369
|
+
const {
|
|
370
|
+
positions,
|
|
371
|
+
index
|
|
372
|
+
} = getHeatmapGeometry(shape);
|
|
342
373
|
return {
|
|
343
374
|
vertices: positions,
|
|
344
375
|
// [ x, y, z ] 多边形顶点
|
|
@@ -352,10 +383,10 @@ export function HeatmapGridTriangulation(feature) {
|
|
|
352
383
|
* @param feature 数据
|
|
353
384
|
*/
|
|
354
385
|
export function RasterImageTriangulation(feature) {
|
|
355
|
-
|
|
386
|
+
const coordinates = feature.coordinates;
|
|
356
387
|
// [ x, y, z. uv.x, uv.y]
|
|
357
|
-
|
|
358
|
-
|
|
388
|
+
const positions = [...coordinates[0], 0, 0, 0, ...coordinates[1], 0, 1, 0, ...coordinates[2], 0, 1, 1, ...coordinates[3], 0, 0, 1];
|
|
389
|
+
const indexs = [0, 1, 2, 0, 2, 3];
|
|
359
390
|
return {
|
|
360
391
|
vertices: positions,
|
|
361
392
|
indices: indexs,
|
|
@@ -370,23 +401,21 @@ export function RasterImageTriangulation(feature) {
|
|
|
370
401
|
*/
|
|
371
402
|
export function LineArcTriangulation(feature, styleOption) {
|
|
372
403
|
// @ts-ignore
|
|
373
|
-
|
|
374
|
-
segmentNumber =
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
404
|
+
const {
|
|
405
|
+
segmentNumber = 30
|
|
406
|
+
} = styleOption;
|
|
407
|
+
const coordinates = feature.coordinates;
|
|
408
|
+
const positions = [];
|
|
409
|
+
const indexArray = [];
|
|
410
|
+
for (let i = 0; i < segmentNumber; i++) {
|
|
379
411
|
// 上线两个顶点
|
|
380
412
|
// [ x, y, z, sx,sy, tx,ty]
|
|
381
413
|
positions.push(i, 1, i, coordinates[0][0], coordinates[0][1], coordinates[1][0], coordinates[1][1], i, -1, i, coordinates[0][0], coordinates[0][1], coordinates[1][0], coordinates[1][1]);
|
|
382
414
|
if (i !== segmentNumber - 1) {
|
|
383
|
-
indexArray.push
|
|
415
|
+
indexArray.push(...[0, 1, 2, 1, 3, 2].map(v => {
|
|
384
416
|
return i * 2 + v;
|
|
385
|
-
}))
|
|
417
|
+
}));
|
|
386
418
|
}
|
|
387
|
-
};
|
|
388
|
-
for (var i = 0; i < segmentNumber; i++) {
|
|
389
|
-
_loop(i);
|
|
390
419
|
}
|
|
391
420
|
return {
|
|
392
421
|
vertices: positions,
|
|
@@ -401,17 +430,17 @@ export function LineArcTriangulation(feature, styleOption) {
|
|
|
401
430
|
* @returns
|
|
402
431
|
*/
|
|
403
432
|
export function HeatmapTriangulation(feature) {
|
|
404
|
-
|
|
433
|
+
const coordinates = feature.coordinates;
|
|
405
434
|
if (coordinates.length === 2) {
|
|
406
435
|
coordinates.push(0);
|
|
407
436
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
437
|
+
const dir = addDir(-1, 1);
|
|
438
|
+
const dir1 = addDir(1, 1);
|
|
439
|
+
const dir2 = addDir(-1, -1);
|
|
440
|
+
const dir3 = addDir(1, -1);
|
|
412
441
|
// [x,y,z, dirx ,diry, weight]
|
|
413
|
-
|
|
414
|
-
|
|
442
|
+
const positions = [...coordinates, ...dir, ...coordinates, ...dir2, ...coordinates, ...dir3, ...coordinates, ...dir1];
|
|
443
|
+
const indexArray = [0, 1, 2, 3, 0, 2];
|
|
415
444
|
return {
|
|
416
445
|
vertices: positions,
|
|
417
446
|
indices: indexArray,
|
|
@@ -423,53 +452,41 @@ export function HeatmapTriangulation(feature) {
|
|
|
423
452
|
* 点图层3d geomerty
|
|
424
453
|
* @param shape 3D形状
|
|
425
454
|
*/
|
|
426
|
-
function getGeometry(shape) {
|
|
427
|
-
var needFlat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
455
|
+
function getGeometry(shape, needFlat = false) {
|
|
428
456
|
if (GeometryCache && GeometryCache[shape]) {
|
|
429
457
|
return GeometryCache[shape];
|
|
430
458
|
}
|
|
431
|
-
|
|
432
|
-
|
|
459
|
+
const path = geometryShape[shape] ? geometryShape[shape]() : geometryShape.cylinder();
|
|
460
|
+
const geometry = extrude_PolygonNormal([path], needFlat);
|
|
433
461
|
GeometryCache[shape] = geometry;
|
|
434
462
|
return geometry;
|
|
435
463
|
}
|
|
436
|
-
export function computeVertexNormals(positions, indexArray) {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
var normal = vec3.create();
|
|
446
|
-
for (var i = 0, li = indexArray.length; i < li; i += 3) {
|
|
464
|
+
export function computeVertexNormals(positions, indexArray, dim = 3, needFlat = false) {
|
|
465
|
+
const normals = new Float32Array(positions.length / dim * 3);
|
|
466
|
+
let vA;
|
|
467
|
+
let vB;
|
|
468
|
+
let vC;
|
|
469
|
+
const cb = vec3.create();
|
|
470
|
+
const ab = vec3.create();
|
|
471
|
+
const normal = vec3.create();
|
|
472
|
+
for (let i = 0, li = indexArray.length; i < li; i += 3) {
|
|
447
473
|
vA = indexArray[i + 0] * 3;
|
|
448
474
|
vB = indexArray[i + 1] * 3;
|
|
449
475
|
vC = indexArray[i + 2] * 3;
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
476
|
+
let p1 = [positions[vA], positions[vA + 1]];
|
|
477
|
+
let p2 = [positions[vB], positions[vB + 1]];
|
|
478
|
+
let p3 = [positions[vC], positions[vC + 1]];
|
|
453
479
|
if (needFlat) {
|
|
454
480
|
p1 = lngLatToMeters(p1);
|
|
455
481
|
p2 = lngLatToMeters(p2);
|
|
456
482
|
p3 = lngLatToMeters(p3);
|
|
457
483
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
_p4 = _slicedToArray(_p3, 2),
|
|
465
|
-
bx = _p4[0],
|
|
466
|
-
by = _p4[1];
|
|
467
|
-
var pB = vec3.fromValues(bx, by, positions[vB + 2]);
|
|
468
|
-
var _p5 = p3,
|
|
469
|
-
_p6 = _slicedToArray(_p5, 2),
|
|
470
|
-
cx = _p6[0],
|
|
471
|
-
cy = _p6[1];
|
|
472
|
-
var pC = vec3.fromValues(cx, cy, positions[vC + 2]);
|
|
484
|
+
const [ax, ay] = p1;
|
|
485
|
+
const pA = vec3.fromValues(ax, ay, positions[vA + 2]);
|
|
486
|
+
const [bx, by] = p2;
|
|
487
|
+
const pB = vec3.fromValues(bx, by, positions[vB + 2]);
|
|
488
|
+
const [cx, cy] = p3;
|
|
489
|
+
const pC = vec3.fromValues(cx, cy, positions[vC + 2]);
|
|
473
490
|
vec3.sub(cb, pC, pB);
|
|
474
491
|
vec3.sub(ab, pA, pB);
|
|
475
492
|
vec3.cross(normal, cb, ab);
|
|
@@ -487,29 +504,29 @@ export function computeVertexNormals(positions, indexArray) {
|
|
|
487
504
|
return normals;
|
|
488
505
|
}
|
|
489
506
|
function normalizeNormals(normals) {
|
|
490
|
-
for (
|
|
491
|
-
|
|
492
|
-
|
|
507
|
+
for (let i = 0, li = normals.length; i < li; i += 3) {
|
|
508
|
+
const normal = vec3.fromValues(normals[i], normals[i + 1], normals[i + 2]);
|
|
509
|
+
const newNormal = vec3.create();
|
|
493
510
|
vec3.normalize(newNormal, normal);
|
|
494
511
|
normals.set(newNormal, i);
|
|
495
512
|
}
|
|
496
513
|
}
|
|
497
514
|
export function checkIsClosed(points) {
|
|
498
|
-
|
|
499
|
-
|
|
515
|
+
const p1 = points[0][0];
|
|
516
|
+
const p2 = points[0][points[0].length - 1];
|
|
500
517
|
return p1[0] === p2[0] && p1[1] === p2[1];
|
|
501
518
|
}
|
|
502
519
|
function getHeatmapGeometry(shape) {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
520
|
+
const shape3d = ['cylinder', 'triangleColumn', 'hexagonColumn', 'squareColumn'];
|
|
521
|
+
const path = geometryShape[shape] ? geometryShape[shape]() : geometryShape.circle();
|
|
522
|
+
const geometry = shape3d.indexOf(shape) === -1 ? fillPolygon([path]) : extrudePolygon([path]);
|
|
506
523
|
// const geometry = fillPolygon([path]);
|
|
507
524
|
return geometry;
|
|
508
525
|
}
|
|
509
526
|
// 热力图计算范围
|
|
510
527
|
function addDir(dirX, dirY) {
|
|
511
|
-
|
|
512
|
-
|
|
528
|
+
const x = (dirX + 1) / 2;
|
|
529
|
+
const y = (dirY + 1) / 2;
|
|
513
530
|
return [x, y];
|
|
514
531
|
}
|
|
515
532
|
|
|
@@ -518,12 +535,14 @@ function addDir(dirX, dirY) {
|
|
|
518
535
|
* @returns
|
|
519
536
|
*/
|
|
520
537
|
export function earthTriangulation() {
|
|
521
|
-
|
|
538
|
+
const earthmesh = primitiveSphere(EARTH_RADIUS, {
|
|
522
539
|
segments: EARTH_SEGMENTS
|
|
523
540
|
});
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
541
|
+
const {
|
|
542
|
+
positionsArr,
|
|
543
|
+
indicesArr,
|
|
544
|
+
normalArr
|
|
545
|
+
} = earthmesh;
|
|
527
546
|
return {
|
|
528
547
|
vertices: positionsArr,
|
|
529
548
|
indices: indicesArr,
|
|
@@ -532,12 +551,14 @@ export function earthTriangulation() {
|
|
|
532
551
|
};
|
|
533
552
|
}
|
|
534
553
|
export function earthOuterTriangulation() {
|
|
535
|
-
|
|
554
|
+
const earthmesh = primitiveSphere(EARTH_RADIUS + EARTH_RADIUS_OUTER, {
|
|
536
555
|
segments: EARTH_SEGMENTS
|
|
537
556
|
});
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
557
|
+
const {
|
|
558
|
+
positionsArr,
|
|
559
|
+
indicesArr,
|
|
560
|
+
normalArr
|
|
561
|
+
} = earthmesh;
|
|
541
562
|
return {
|
|
542
563
|
vertices: positionsArr,
|
|
543
564
|
indices: indicesArr,
|
package/es/core/utils.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export function formatUniformsOption2Std140(uniformsOption) {
|
|
2
|
-
|
|
3
|
-
Object.keys(uniformsOption).forEach(
|
|
4
|
-
|
|
2
|
+
let std140_str = '';
|
|
3
|
+
Object.keys(uniformsOption).forEach(key => {
|
|
4
|
+
const value = uniformsOption[key];
|
|
5
5
|
if (Array.isArray(value)) {
|
|
6
|
-
std140_str +=
|
|
6
|
+
std140_str += `vec${value.length} ${key};\n`;
|
|
7
7
|
} else {
|
|
8
|
-
std140_str +=
|
|
8
|
+
std140_str += `flot ${key};\n`;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
return std140_str;
|