@antv/l7-layers 2.25.7 → 2.25.9
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.d.ts +18 -0
- package/es/canvas/index.js +70 -0
- package/es/canvas/models/canvas.d.ts +23 -0
- package/es/canvas/models/canvas.js +141 -0
- package/es/canvas/models/constants.d.ts +2 -0
- package/es/canvas/models/constants.js +6 -0
- package/es/canvas/models/index.d.ts +2 -0
- package/es/canvas/models/index.js +2 -0
- package/es/citybuilding/building.d.ts +7 -0
- package/es/citybuilding/building.js +25 -0
- package/es/citybuilding/models/build.d.ts +33 -0
- package/es/citybuilding/models/build.js +160 -0
- package/es/citybuilding/shaders/build_frag.glsl +123 -0
- package/es/citybuilding/shaders/build_vert.glsl +58 -0
- package/es/core/BaseLayer.d.ts +265 -0
- package/es/core/BaseLayer.js +1310 -0
- package/es/core/BaseModel.d.ts +95 -0
- package/es/core/BaseModel.js +367 -0
- package/es/core/CommonStyleAttribute.d.ts +16 -0
- package/es/core/CommonStyleAttribute.js +114 -0
- package/es/core/LayerPickService.d.ts +12 -0
- package/es/core/LayerPickService.js +102 -0
- package/es/core/TextureService.d.ts +15 -0
- package/es/core/TextureService.js +65 -0
- package/es/core/constant.d.ts +6 -0
- package/es/core/constant.js +19 -0
- package/es/core/interface.d.ts +284 -0
- package/es/core/interface.js +32 -0
- package/es/core/line_trangluation.d.ts +19 -0
- package/es/core/line_trangluation.js +86 -0
- package/es/core/schema.d.ts +27 -0
- package/es/core/schema.js +25 -0
- package/es/core/shape/Path.d.ts +40 -0
- package/es/core/shape/Path.js +69 -0
- package/es/core/shape/arrow.d.ts +25 -0
- package/es/core/shape/arrow.js +144 -0
- package/es/core/shape/extrude.d.ts +17 -0
- package/es/core/shape/extrude.js +133 -0
- package/es/core/triangulation.d.ts +136 -0
- package/es/core/triangulation.js +601 -0
- package/es/core/utils.d.ts +5 -0
- package/es/core/utils.js +36 -0
- package/es/earth/index.d.ts +22 -0
- package/es/earth/index.js +54 -0
- package/es/earth/models/atmosphere.d.ts +30 -0
- package/es/earth/models/atmosphere.js +116 -0
- package/es/earth/models/base.d.ts +37 -0
- package/es/earth/models/base.js +172 -0
- package/es/earth/models/bloomsphere.d.ts +30 -0
- package/es/earth/models/bloomsphere.js +115 -0
- package/es/earth/shaders/atmosphere/atmosphere_frag.glsl +17 -0
- package/es/earth/shaders/atmosphere/atmosphere_vert.glsl +24 -0
- package/es/earth/shaders/base/base_frag.glsl +11 -0
- package/es/earth/shaders/base/base_vert.glsl +52 -0
- package/es/earth/shaders/bloomshpere/bloomsphere_frag.glsl +15 -0
- package/es/earth/shaders/bloomshpere/bloomsphere_vert.glsl +20 -0
- package/es/earth/utils.d.ts +26 -0
- package/es/earth/utils.js +99 -0
- package/es/geometry/index.d.ts +22 -0
- package/es/geometry/index.js +53 -0
- package/es/geometry/models/billboard.d.ts +39 -0
- package/es/geometry/models/billboard.js +175 -0
- package/es/geometry/models/index.d.ts +5 -0
- package/es/geometry/models/index.js +9 -0
- package/es/geometry/models/plane.d.ts +58 -0
- package/es/geometry/models/plane.js +308 -0
- package/es/geometry/models/sprite.d.ts +48 -0
- package/es/geometry/models/sprite.js +225 -0
- package/es/geometry/shaders/billboard_frag.glsl +18 -0
- package/es/geometry/shaders/billboard_vert.glsl +43 -0
- package/es/geometry/shaders/plane_frag.glsl +23 -0
- package/es/geometry/shaders/plane_vert.glsl +31 -0
- package/es/geometry/shaders/sprite_frag.glsl +23 -0
- package/es/geometry/shaders/sprite_vert.glsl +21 -0
- package/es/heatmap/index.d.ts +13 -0
- package/es/heatmap/index.js +87 -0
- package/es/heatmap/models/grid.d.ts +29 -0
- package/es/heatmap/models/grid.js +83 -0
- package/es/heatmap/models/grid3d.d.ts +31 -0
- package/es/heatmap/models/grid3d.js +122 -0
- package/es/heatmap/models/heatmap.d.ts +46 -0
- package/es/heatmap/models/heatmap.js +447 -0
- package/es/heatmap/models/hexagon.d.ts +29 -0
- package/es/heatmap/models/hexagon.js +83 -0
- package/es/heatmap/models/index.d.ts +5 -0
- package/es/heatmap/models/index.js +12 -0
- package/es/heatmap/shaders/grid/grid_frag.glsl +9 -0
- package/es/heatmap/shaders/grid/grid_vert.glsl +30 -0
- package/es/heatmap/shaders/grid3d/grid_3d_frag.glsl +17 -0
- package/es/heatmap/shaders/grid3d/grid_3d_vert.glsl +34 -0
- package/es/heatmap/shaders/heatmap/heatmap_3d_frag.glsl +23 -0
- package/es/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +59 -0
- package/es/heatmap/shaders/heatmap/heatmap_frag.glsl +40 -0
- package/es/heatmap/shaders/heatmap/heatmap_framebuffer_frag.glsl +17 -0
- package/es/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +36 -0
- package/es/heatmap/shaders/heatmap/heatmap_vert.glsl +21 -0
- package/es/heatmap/shaders/hexagon/hexagon_frag.glsl +8 -0
- package/es/heatmap/shaders/hexagon/hexagon_vert.glsl +30 -0
- package/es/heatmap/triangulation.d.ts +5 -0
- package/es/heatmap/triangulation.js +33 -0
- package/es/image/index.d.ts +9 -0
- package/es/image/index.js +28 -0
- package/es/image/models/image.d.ts +31 -0
- package/es/image/models/image.js +113 -0
- package/es/image/models/index.d.ts +5 -0
- package/es/image/models/index.js +5 -0
- package/es/image/shaders/dataImage_frag.glsl +32 -0
- package/es/image/shaders/image_frag.glsl +38 -0
- package/es/image/shaders/image_vert.glsl +20 -0
- package/es/index.d.ts +18 -0
- package/es/index.js +18 -0
- package/es/line/index.d.ts +36 -0
- package/es/line/index.js +90 -0
- package/es/line/models/arc.d.ts +40 -0
- package/es/line/models/arc.js +279 -0
- package/es/line/models/arc_3d.d.ts +40 -0
- package/es/line/models/arc_3d.js +269 -0
- package/es/line/models/flow.d.ts +31 -0
- package/es/line/models/flow.js +140 -0
- package/es/line/models/great_circle.d.ts +34 -0
- package/es/line/models/great_circle.js +240 -0
- package/es/line/models/index.d.ts +5 -0
- package/es/line/models/index.js +18 -0
- package/es/line/models/line.d.ts +44 -0
- package/es/line/models/line.js +273 -0
- package/es/line/models/simple_line.d.ts +33 -0
- package/es/line/models/simple_line.js +118 -0
- package/es/line/models/wall.d.ts +34 -0
- package/es/line/models/wall.js +223 -0
- package/es/line/shaders/arc/line_arc_frag.glsl +92 -0
- package/es/line/shaders/arc/line_arc_vert.glsl +156 -0
- package/es/line/shaders/arc3d/line_arc_3d_frag.glsl +108 -0
- package/es/line/shaders/arc3d/line_arc_3d_vert.glsl +177 -0
- package/es/line/shaders/flow/flow_line_frag.glsl +13 -0
- package/es/line/shaders/flow/flow_line_vert.glsl +76 -0
- package/es/line/shaders/greatCircle/line_arc_great_circle_frag.glsl +99 -0
- package/es/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +165 -0
- package/es/line/shaders/line/line_frag.glsl +122 -0
- package/es/line/shaders/line/line_vert.glsl +101 -0
- package/es/line/shaders/simple/simpleline_frag.glsl +30 -0
- package/es/line/shaders/simple/simpleline_vert.glsl +45 -0
- package/es/line/shaders/wall/wall_frag.glsl +94 -0
- package/es/line/shaders/wall/wall_vert.glsl +90 -0
- package/es/mask/index.d.ts +16 -0
- package/es/mask/index.js +21 -0
- package/es/mask/models/fill.d.ts +18 -0
- package/es/mask/models/fill.js +61 -0
- package/es/mask/models/index.d.ts +5 -0
- package/es/mask/models/index.js +5 -0
- package/es/mask/shaders/mask_vert.glsl +14 -0
- package/es/plugins/DataMappingPlugin.d.ts +12 -0
- package/es/plugins/DataMappingPlugin.js +226 -0
- package/es/plugins/DataSourcePlugin.d.ts +6 -0
- package/es/plugins/DataSourcePlugin.js +75 -0
- package/es/plugins/FeatureScalePlugin.d.ts +20 -0
- package/es/plugins/FeatureScalePlugin.js +295 -0
- package/es/plugins/LayerAnimateStylePlugin.d.ts +4 -0
- package/es/plugins/LayerAnimateStylePlugin.js +14 -0
- package/es/plugins/LayerMaskPlugin.d.ts +7 -0
- package/es/plugins/LayerMaskPlugin.js +19 -0
- package/es/plugins/LayerModelPlugin.d.ts +10 -0
- package/es/plugins/LayerModelPlugin.js +60 -0
- package/es/plugins/LayerStylePlugin.d.ts +7 -0
- package/es/plugins/LayerStylePlugin.js +18 -0
- package/es/plugins/LightingPlugin.d.ts +35 -0
- package/es/plugins/LightingPlugin.js +84 -0
- package/es/plugins/MultiPassRendererPlugin.d.ts +22 -0
- package/es/plugins/MultiPassRendererPlugin.js +52 -0
- package/es/plugins/PixelPickingPlugin.d.ts +11 -0
- package/es/plugins/PixelPickingPlugin.js +146 -0
- package/es/plugins/RegisterStyleAttributePlugin.d.ts +10 -0
- package/es/plugins/RegisterStyleAttributePlugin.js +72 -0
- package/es/plugins/ShaderUniformPlugin.d.ts +17 -0
- package/es/plugins/ShaderUniformPlugin.js +196 -0
- package/es/plugins/UpdateModelPlugin.d.ts +7 -0
- package/es/plugins/UpdateModelPlugin.js +20 -0
- package/es/plugins/UpdateStyleAttributePlugin.d.ts +9 -0
- package/es/plugins/UpdateStyleAttributePlugin.js +54 -0
- package/es/plugins/index.d.ts +15 -0
- package/es/plugins/index.js +18 -0
- package/es/point/index.d.ts +35 -0
- package/es/point/index.js +153 -0
- package/es/point/models/billboard_point.d.ts +35 -0
- package/es/point/models/billboard_point.js +95 -0
- package/es/point/models/earthExtrude.d.ts +32 -0
- package/es/point/models/earthExtrude.js +199 -0
- package/es/point/models/earthFill.d.ts +31 -0
- package/es/point/models/earthFill.js +158 -0
- package/es/point/models/extrude.d.ts +32 -0
- package/es/point/models/extrude.js +195 -0
- package/es/point/models/fill.d.ts +47 -0
- package/es/point/models/fill.js +180 -0
- package/es/point/models/fillImage.d.ts +42 -0
- package/es/point/models/fillImage.js +189 -0
- package/es/point/models/image.d.ts +48 -0
- package/es/point/models/image.js +293 -0
- package/es/point/models/index.d.ts +5 -0
- package/es/point/models/index.js +24 -0
- package/es/point/models/normal.d.ts +36 -0
- package/es/point/models/normal.js +89 -0
- package/es/point/models/radar.d.ts +37 -0
- package/es/point/models/radar.js +115 -0
- package/es/point/models/text.d.ts +85 -0
- package/es/point/models/text.js +503 -0
- package/es/point/shaders/billboard/billboard_point_frag.glsl +48 -0
- package/es/point/shaders/billboard/billboard_point_vert.glsl +33 -0
- package/es/point/shaders/earthExtrude/earthExtrude_frag.glsl +36 -0
- package/es/point/shaders/earthExtrude/earthExtrude_vert.glsl +118 -0
- package/es/point/shaders/earthFill/earthFill_frag.glsl +79 -0
- package/es/point/shaders/earthFill/earthFill_vert.glsl +46 -0
- package/es/point/shaders/extrude/extrude_frag.glsl +29 -0
- package/es/point/shaders/extrude/extrude_vert.glsl +95 -0
- package/es/point/shaders/fill/fill_frag.glsl +97 -0
- package/es/point/shaders/fill/fill_vert.glsl +79 -0
- package/es/point/shaders/fillImage/fillImage_frag.glsl +23 -0
- package/es/point/shaders/fillImage/fillImage_vert.glsl +46 -0
- package/es/point/shaders/image/image_frag.glsl +45 -0
- package/es/point/shaders/image/image_vert.glsl +47 -0
- package/es/point/shaders/normal/normal_frag.glsl +5 -0
- package/es/point/shaders/normal/normal_vert.glsl +22 -0
- package/es/point/shaders/radar/radar_frag.glsl +52 -0
- package/es/point/shaders/radar/radar_vert.glsl +53 -0
- package/es/point/shaders/text/text_frag.glsl +47 -0
- package/es/point/shaders/text/text_vert.glsl +65 -0
- package/es/point/shape/extrude.d.ts +15 -0
- package/es/point/shape/extrude.js +48 -0
- package/es/polygon/index.d.ts +18 -0
- package/es/polygon/index.js +71 -0
- package/es/polygon/models/extrude.d.ts +41 -0
- package/es/polygon/models/extrude.js +248 -0
- package/es/polygon/models/extrusion.d.ts +40 -0
- package/es/polygon/models/extrusion.js +137 -0
- package/es/polygon/models/fill.d.ts +32 -0
- package/es/polygon/models/fill.js +127 -0
- package/es/polygon/models/index.d.ts +5 -0
- package/es/polygon/models/index.js +26 -0
- package/es/polygon/models/ocean.d.ts +37 -0
- package/es/polygon/models/ocean.js +172 -0
- package/es/polygon/models/water.d.ts +35 -0
- package/es/polygon/models/water.js +150 -0
- package/es/polygon/shaders/extrude/polygon_extrude_frag.glsl +24 -0
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +49 -0
- package/es/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +53 -0
- package/es/polygon/shaders/extrude/polygon_extrude_vert.glsl +74 -0
- package/es/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +55 -0
- package/es/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +54 -0
- package/es/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +8 -0
- package/es/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +24 -0
- package/es/polygon/shaders/fill/fill_frag.glsl +8 -0
- package/es/polygon/shaders/fill/fill_linear_frag.glsl +23 -0
- package/es/polygon/shaders/fill/fill_linear_vert.glsl +36 -0
- package/es/polygon/shaders/fill/fill_vert.glsl +35 -0
- package/es/polygon/shaders/ocean/ocean_frag.glsl +277 -0
- package/es/polygon/shaders/ocean/ocean_vert.glsl +21 -0
- package/es/polygon/shaders/water/polygon_water_frag.glsl +78 -0
- package/es/polygon/shaders/water/polygon_water_vert.glsl +22 -0
- package/es/raster/buffers/triangulation.d.ts +6 -0
- package/es/raster/buffers/triangulation.js +25 -0
- package/es/raster/index.d.ts +11 -0
- package/es/raster/index.js +55 -0
- package/es/raster/models/index.d.ts +5 -0
- package/es/raster/models/index.js +10 -0
- package/es/raster/models/raster.d.ts +35 -0
- package/es/raster/models/raster.js +156 -0
- package/es/raster/models/rasterRgb.d.ts +35 -0
- package/es/raster/models/rasterRgb.js +158 -0
- package/es/raster/models/rasterTerrainRgb.d.ts +30 -0
- package/es/raster/models/rasterTerrainRgb.js +118 -0
- package/es/raster/shaders/raster/raster_2d_frag.glsl +37 -0
- package/es/raster/shaders/raster/raster_2d_vert.glsl +21 -0
- package/es/raster/shaders/rgb/raster_rgb_frag.glsl +30 -0
- package/es/raster/shaders/rgb/raster_rgb_vert.glsl +21 -0
- package/es/raster/shaders/terrain/terrain_rgb_frag.glsl +40 -0
- package/es/raster/shaders/terrain/terrain_rgb_vert.glsl +19 -0
- package/es/shader/minify_frag.glsl +11 -0
- package/es/shader/minify_picking_frag.glsl +10 -0
- package/es/tile/core/BaseLayer.d.ts +50 -0
- package/es/tile/core/BaseLayer.js +256 -0
- package/es/tile/core/TileDebugLayer.d.ts +15 -0
- package/es/tile/core/TileDebugLayer.js +23 -0
- package/es/tile/interaction/getFeatureData.d.ts +0 -0
- package/es/tile/interaction/getFeatureData.js +0 -0
- package/es/tile/interaction/getRasterData.d.ts +4 -0
- package/es/tile/interaction/getRasterData.js +45 -0
- package/es/tile/interaction/utils.d.ts +11 -0
- package/es/tile/interaction/utils.js +69 -0
- package/es/tile/interface.d.ts +29 -0
- package/es/tile/interface.js +1 -0
- package/es/tile/service/TileLayerService.d.ts +58 -0
- package/es/tile/service/TileLayerService.js +195 -0
- package/es/tile/service/TilePickService.d.ts +26 -0
- package/es/tile/service/TilePickService.js +126 -0
- package/es/tile/service/TileSourceService.d.ts +7 -0
- package/es/tile/service/TileSourceService.js +26 -0
- package/es/tile/tile/DebugTile.d.ts +16 -0
- package/es/tile/tile/DebugTile.js +47 -0
- package/es/tile/tile/ImageTile.d.ts +14 -0
- package/es/tile/tile/ImageTile.js +39 -0
- package/es/tile/tile/MaskTile.d.ts +18 -0
- package/es/tile/tile/MaskTile.js +54 -0
- package/es/tile/tile/RasterRGBTile.d.ts +11 -0
- package/es/tile/tile/RasterRGBTile.js +47 -0
- package/es/tile/tile/RasterTerrainRGBTile.d.ts +14 -0
- package/es/tile/tile/RasterTerrainRGBTile.js +39 -0
- package/es/tile/tile/RasterTile.d.ts +18 -0
- package/es/tile/tile/RasterTile.js +81 -0
- package/es/tile/tile/Tile.d.ts +112 -0
- package/es/tile/tile/Tile.js +166 -0
- package/es/tile/tile/VectorTile.d.ts +26 -0
- package/es/tile/tile/VectorTile.js +87 -0
- package/es/tile/tile/index.d.ts +12 -0
- package/es/tile/tile/index.js +44 -0
- package/es/tile/tile/util.d.ts +5 -0
- package/es/tile/tile/util.js +18 -0
- package/es/tile/utils/constants.d.ts +1 -0
- package/es/tile/utils/constants.js +8 -0
- package/es/tile/utils/utils.d.ts +8 -0
- package/es/tile/utils/utils.js +11 -0
- package/es/utils/blend.d.ts +2 -0
- package/es/utils/blend.js +57 -0
- package/es/utils/collision-index.d.ts +47 -0
- package/es/utils/collision-index.js +87 -0
- package/es/utils/extrude_polyline.d.ts +53 -0
- package/es/utils/extrude_polyline.js +319 -0
- package/es/utils/grid-index.d.ts +28 -0
- package/es/utils/grid-index.js +128 -0
- package/es/utils/identityScale.d.ts +8 -0
- package/es/utils/identityScale.js +26 -0
- package/es/utils/load-image.d.ts +1 -0
- package/es/utils/load-image.js +22 -0
- package/es/utils/multiPassRender.d.ts +16 -0
- package/es/utils/multiPassRender.js +37 -0
- package/es/utils/polylineNormal.d.ts +9 -0
- package/es/utils/polylineNormal.js +182 -0
- package/es/utils/rampcolor_legend.d.ts +6 -0
- package/es/utils/rampcolor_legend.js +12 -0
- package/es/utils/scale.d.ts +87 -0
- package/es/utils/scale.js +595 -0
- package/es/utils/simpleLine.d.ts +23 -0
- package/es/utils/simpleLine.js +76 -0
- package/es/utils/stencil.d.ts +7 -0
- package/es/utils/stencil.js +49 -0
- package/es/utils/symbol-layout.d.ts +43 -0
- package/es/utils/symbol-layout.js +251 -0
- package/es/wind/index.d.ts +11 -0
- package/es/wind/index.js +34 -0
- package/es/wind/models/index.d.ts +5 -0
- package/es/wind/models/index.js +5 -0
- package/es/wind/models/utils.d.ts +19 -0
- package/es/wind/models/utils.js +213 -0
- package/es/wind/models/wind.d.ts +38 -0
- package/es/wind/models/wind.js +240 -0
- package/es/wind/models/windRender.d.ts +104 -0
- package/es/wind/models/windRender.js +333 -0
- package/es/wind/models/windShader.d.ts +12 -0
- package/es/wind/models/windShader.js +151 -0
- package/es/wind/shaders/wind_frag.glsl +9 -0
- package/es/wind/shaders/wind_vert.glsl +14 -0
- package/lib/canvas/index.d.ts +18 -0
- package/lib/canvas/index.js +79 -0
- package/lib/canvas/models/canvas.d.ts +23 -0
- package/lib/canvas/models/canvas.js +149 -0
- package/lib/canvas/models/constants.d.ts +2 -0
- package/lib/canvas/models/constants.js +12 -0
- package/lib/canvas/models/index.d.ts +2 -0
- package/lib/canvas/models/index.js +27 -0
- package/lib/citybuilding/building.d.ts +7 -0
- package/lib/citybuilding/building.js +33 -0
- package/lib/citybuilding/models/build.d.ts +33 -0
- package/lib/citybuilding/models/build.js +168 -0
- package/lib/citybuilding/shaders/build_frag.glsl +123 -0
- package/lib/citybuilding/shaders/build_vert.glsl +58 -0
- package/lib/core/BaseLayer.d.ts +265 -0
- package/lib/core/BaseLayer.js +1317 -0
- package/lib/core/BaseModel.d.ts +95 -0
- package/lib/core/BaseModel.js +375 -0
- package/lib/core/CommonStyleAttribute.d.ts +16 -0
- package/lib/core/CommonStyleAttribute.js +120 -0
- package/lib/core/LayerPickService.d.ts +12 -0
- package/lib/core/LayerPickService.js +110 -0
- package/lib/core/TextureService.d.ts +15 -0
- package/lib/core/TextureService.js +73 -0
- package/lib/core/constant.d.ts +6 -0
- package/lib/core/constant.js +25 -0
- package/lib/core/interface.d.ts +284 -0
- package/lib/core/interface.js +34 -0
- package/lib/core/line_trangluation.d.ts +19 -0
- package/lib/core/line_trangluation.js +94 -0
- package/lib/core/schema.d.ts +27 -0
- package/lib/core/schema.js +31 -0
- package/lib/core/shape/Path.d.ts +40 -0
- package/lib/core/shape/Path.js +81 -0
- package/lib/core/shape/arrow.d.ts +25 -0
- package/lib/core/shape/arrow.js +158 -0
- package/lib/core/shape/extrude.d.ts +17 -0
- package/lib/core/shape/extrude.js +142 -0
- package/lib/core/triangulation.d.ts +136 -0
- package/lib/core/triangulation.js +628 -0
- package/lib/core/utils.d.ts +5 -0
- package/lib/core/utils.js +44 -0
- package/lib/earth/index.d.ts +22 -0
- package/lib/earth/index.js +62 -0
- package/lib/earth/models/atmosphere.d.ts +30 -0
- package/lib/earth/models/atmosphere.js +124 -0
- package/lib/earth/models/base.d.ts +37 -0
- package/lib/earth/models/base.js +180 -0
- package/lib/earth/models/bloomsphere.d.ts +30 -0
- package/lib/earth/models/bloomsphere.js +123 -0
- package/lib/earth/shaders/atmosphere/atmosphere_frag.glsl +17 -0
- package/lib/earth/shaders/atmosphere/atmosphere_vert.glsl +24 -0
- package/lib/earth/shaders/base/base_frag.glsl +11 -0
- package/lib/earth/shaders/base/base_vert.glsl +52 -0
- package/lib/earth/shaders/bloomshpere/bloomsphere_frag.glsl +15 -0
- package/lib/earth/shaders/bloomshpere/bloomsphere_vert.glsl +20 -0
- package/lib/earth/utils.d.ts +26 -0
- package/lib/earth/utils.js +107 -0
- package/lib/geometry/index.d.ts +22 -0
- package/lib/geometry/index.js +61 -0
- package/lib/geometry/models/billboard.d.ts +39 -0
- package/lib/geometry/models/billboard.js +183 -0
- package/lib/geometry/models/index.d.ts +5 -0
- package/lib/geometry/models/index.js +16 -0
- package/lib/geometry/models/plane.d.ts +58 -0
- package/lib/geometry/models/plane.js +316 -0
- package/lib/geometry/models/sprite.d.ts +48 -0
- package/lib/geometry/models/sprite.js +233 -0
- package/lib/geometry/shaders/billboard_frag.glsl +18 -0
- package/lib/geometry/shaders/billboard_vert.glsl +43 -0
- package/lib/geometry/shaders/plane_frag.glsl +23 -0
- package/lib/geometry/shaders/plane_vert.glsl +31 -0
- package/lib/geometry/shaders/sprite_frag.glsl +23 -0
- package/lib/geometry/shaders/sprite_vert.glsl +21 -0
- package/lib/heatmap/index.d.ts +13 -0
- package/lib/heatmap/index.js +95 -0
- package/lib/heatmap/models/grid.d.ts +29 -0
- package/lib/heatmap/models/grid.js +91 -0
- package/lib/heatmap/models/grid3d.d.ts +31 -0
- package/lib/heatmap/models/grid3d.js +130 -0
- package/lib/heatmap/models/heatmap.d.ts +46 -0
- package/lib/heatmap/models/heatmap.js +455 -0
- package/lib/heatmap/models/hexagon.d.ts +29 -0
- package/lib/heatmap/models/hexagon.js +91 -0
- package/lib/heatmap/models/index.d.ts +5 -0
- package/lib/heatmap/models/index.js +19 -0
- package/lib/heatmap/shaders/grid/grid_frag.glsl +9 -0
- package/lib/heatmap/shaders/grid/grid_vert.glsl +30 -0
- package/lib/heatmap/shaders/grid3d/grid_3d_frag.glsl +17 -0
- package/lib/heatmap/shaders/grid3d/grid_3d_vert.glsl +34 -0
- package/lib/heatmap/shaders/heatmap/heatmap_3d_frag.glsl +23 -0
- package/lib/heatmap/shaders/heatmap/heatmap_3d_vert.glsl +59 -0
- package/lib/heatmap/shaders/heatmap/heatmap_frag.glsl +40 -0
- package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_frag.glsl +17 -0
- package/lib/heatmap/shaders/heatmap/heatmap_framebuffer_vert.glsl +36 -0
- package/lib/heatmap/shaders/heatmap/heatmap_vert.glsl +21 -0
- package/lib/heatmap/shaders/hexagon/hexagon_frag.glsl +8 -0
- package/lib/heatmap/shaders/hexagon/hexagon_vert.glsl +30 -0
- package/lib/heatmap/triangulation.d.ts +5 -0
- package/lib/heatmap/triangulation.js +39 -0
- package/lib/image/index.d.ts +9 -0
- package/lib/image/index.js +36 -0
- package/lib/image/models/image.d.ts +31 -0
- package/lib/image/models/image.js +121 -0
- package/lib/image/models/index.d.ts +5 -0
- package/lib/image/models/index.js +12 -0
- package/lib/image/shaders/dataImage_frag.glsl +32 -0
- package/lib/image/shaders/image_frag.glsl +38 -0
- package/lib/image/shaders/image_vert.glsl +20 -0
- package/lib/index.d.ts +18 -0
- package/lib/index.js +148 -0
- package/lib/line/index.d.ts +36 -0
- package/lib/line/index.js +98 -0
- package/lib/line/models/arc.d.ts +40 -0
- package/lib/line/models/arc.js +287 -0
- package/lib/line/models/arc_3d.d.ts +40 -0
- package/lib/line/models/arc_3d.js +277 -0
- package/lib/line/models/flow.d.ts +31 -0
- package/lib/line/models/flow.js +148 -0
- package/lib/line/models/great_circle.d.ts +34 -0
- package/lib/line/models/great_circle.js +248 -0
- package/lib/line/models/index.d.ts +5 -0
- package/lib/line/models/index.js +25 -0
- package/lib/line/models/line.d.ts +44 -0
- package/lib/line/models/line.js +281 -0
- package/lib/line/models/simple_line.d.ts +33 -0
- package/lib/line/models/simple_line.js +126 -0
- package/lib/line/models/wall.d.ts +34 -0
- package/lib/line/models/wall.js +231 -0
- package/lib/line/shaders/arc/line_arc_frag.glsl +92 -0
- package/lib/line/shaders/arc/line_arc_vert.glsl +156 -0
- package/lib/line/shaders/arc3d/line_arc_3d_frag.glsl +108 -0
- package/lib/line/shaders/arc3d/line_arc_3d_vert.glsl +177 -0
- package/lib/line/shaders/flow/flow_line_frag.glsl +13 -0
- package/lib/line/shaders/flow/flow_line_vert.glsl +76 -0
- package/lib/line/shaders/greatCircle/line_arc_great_circle_frag.glsl +99 -0
- package/lib/line/shaders/greatCircle/line_arc_great_circle_vert.glsl +165 -0
- package/lib/line/shaders/line/line_frag.glsl +122 -0
- package/lib/line/shaders/line/line_vert.glsl +101 -0
- package/lib/line/shaders/simple/simpleline_frag.glsl +30 -0
- package/lib/line/shaders/simple/simpleline_vert.glsl +45 -0
- package/lib/line/shaders/wall/wall_frag.glsl +94 -0
- package/lib/line/shaders/wall/wall_vert.glsl +90 -0
- package/lib/mask/index.d.ts +16 -0
- package/lib/mask/index.js +29 -0
- package/lib/mask/models/fill.d.ts +18 -0
- package/lib/mask/models/fill.js +69 -0
- package/lib/mask/models/index.d.ts +5 -0
- package/lib/mask/models/index.js +12 -0
- package/lib/mask/shaders/mask_vert.glsl +14 -0
- package/lib/plugins/DataMappingPlugin.d.ts +12 -0
- package/lib/plugins/DataMappingPlugin.js +234 -0
- package/lib/plugins/DataSourcePlugin.d.ts +6 -0
- package/lib/plugins/DataSourcePlugin.js +83 -0
- package/lib/plugins/FeatureScalePlugin.d.ts +20 -0
- package/lib/plugins/FeatureScalePlugin.js +303 -0
- package/lib/plugins/LayerAnimateStylePlugin.d.ts +4 -0
- package/lib/plugins/LayerAnimateStylePlugin.js +22 -0
- package/lib/plugins/LayerMaskPlugin.d.ts +7 -0
- package/lib/plugins/LayerMaskPlugin.js +26 -0
- package/lib/plugins/LayerModelPlugin.d.ts +10 -0
- package/lib/plugins/LayerModelPlugin.js +68 -0
- package/lib/plugins/LayerStylePlugin.d.ts +7 -0
- package/lib/plugins/LayerStylePlugin.js +25 -0
- package/lib/plugins/LightingPlugin.d.ts +35 -0
- package/lib/plugins/LightingPlugin.js +93 -0
- package/lib/plugins/MultiPassRendererPlugin.d.ts +22 -0
- package/lib/plugins/MultiPassRendererPlugin.js +59 -0
- package/lib/plugins/PixelPickingPlugin.d.ts +11 -0
- package/lib/plugins/PixelPickingPlugin.js +154 -0
- package/lib/plugins/RegisterStyleAttributePlugin.d.ts +10 -0
- package/lib/plugins/RegisterStyleAttributePlugin.js +78 -0
- package/lib/plugins/ShaderUniformPlugin.d.ts +17 -0
- package/lib/plugins/ShaderUniformPlugin.js +203 -0
- package/lib/plugins/UpdateModelPlugin.d.ts +7 -0
- package/lib/plugins/UpdateModelPlugin.js +27 -0
- package/lib/plugins/UpdateStyleAttributePlugin.d.ts +9 -0
- package/lib/plugins/UpdateStyleAttributePlugin.js +61 -0
- package/lib/plugins/index.d.ts +15 -0
- package/lib/plugins/index.js +26 -0
- package/lib/point/index.d.ts +35 -0
- package/lib/point/index.js +161 -0
- package/lib/point/models/billboard_point.d.ts +35 -0
- package/lib/point/models/billboard_point.js +104 -0
- package/lib/point/models/earthExtrude.d.ts +32 -0
- package/lib/point/models/earthExtrude.js +207 -0
- package/lib/point/models/earthFill.d.ts +31 -0
- package/lib/point/models/earthFill.js +166 -0
- package/lib/point/models/extrude.d.ts +32 -0
- package/lib/point/models/extrude.js +203 -0
- package/lib/point/models/fill.d.ts +47 -0
- package/lib/point/models/fill.js +188 -0
- package/lib/point/models/fillImage.d.ts +42 -0
- package/lib/point/models/fillImage.js +197 -0
- package/lib/point/models/image.d.ts +48 -0
- package/lib/point/models/image.js +301 -0
- package/lib/point/models/index.d.ts +5 -0
- package/lib/point/models/index.js +32 -0
- package/lib/point/models/normal.d.ts +36 -0
- package/lib/point/models/normal.js +98 -0
- package/lib/point/models/radar.d.ts +37 -0
- package/lib/point/models/radar.js +123 -0
- package/lib/point/models/text.d.ts +85 -0
- package/lib/point/models/text.js +512 -0
- package/lib/point/shaders/billboard/billboard_point_frag.glsl +48 -0
- package/lib/point/shaders/billboard/billboard_point_vert.glsl +33 -0
- package/lib/point/shaders/earthExtrude/earthExtrude_frag.glsl +36 -0
- package/lib/point/shaders/earthExtrude/earthExtrude_vert.glsl +118 -0
- package/lib/point/shaders/earthFill/earthFill_frag.glsl +79 -0
- package/lib/point/shaders/earthFill/earthFill_vert.glsl +46 -0
- package/lib/point/shaders/extrude/extrude_frag.glsl +29 -0
- package/lib/point/shaders/extrude/extrude_vert.glsl +95 -0
- package/lib/point/shaders/fill/fill_frag.glsl +97 -0
- package/lib/point/shaders/fill/fill_vert.glsl +79 -0
- package/lib/point/shaders/fillImage/fillImage_frag.glsl +23 -0
- package/lib/point/shaders/fillImage/fillImage_vert.glsl +46 -0
- package/lib/point/shaders/image/image_frag.glsl +45 -0
- package/lib/point/shaders/image/image_vert.glsl +47 -0
- package/lib/point/shaders/normal/normal_frag.glsl +5 -0
- package/lib/point/shaders/normal/normal_vert.glsl +22 -0
- package/lib/point/shaders/radar/radar_frag.glsl +52 -0
- package/lib/point/shaders/radar/radar_vert.glsl +53 -0
- package/lib/point/shaders/text/text_frag.glsl +47 -0
- package/lib/point/shaders/text/text_vert.glsl +65 -0
- package/lib/point/shape/extrude.d.ts +15 -0
- package/lib/point/shape/extrude.js +56 -0
- package/lib/polygon/index.d.ts +18 -0
- package/lib/polygon/index.js +79 -0
- package/lib/polygon/models/extrude.d.ts +41 -0
- package/lib/polygon/models/extrude.js +256 -0
- package/lib/polygon/models/extrusion.d.ts +40 -0
- package/lib/polygon/models/extrusion.js +145 -0
- package/lib/polygon/models/fill.d.ts +32 -0
- package/lib/polygon/models/fill.js +135 -0
- package/lib/polygon/models/index.d.ts +5 -0
- package/lib/polygon/models/index.js +33 -0
- package/lib/polygon/models/ocean.d.ts +37 -0
- package/lib/polygon/models/ocean.js +180 -0
- package/lib/polygon/models/water.d.ts +35 -0
- package/lib/polygon/models/water.js +158 -0
- package/lib/polygon/shaders/extrude/polygon_extrude_frag.glsl +24 -0
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +49 -0
- package/lib/polygon/shaders/extrude/polygon_extrude_picklight_vert.glsl +53 -0
- package/lib/polygon/shaders/extrude/polygon_extrude_vert.glsl +74 -0
- package/lib/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +55 -0
- package/lib/polygon/shaders/extrude/polygon_extrudetex_vert.glsl +54 -0
- package/lib/polygon/shaders/extrusion/polygon_extrusion_frag.glsl +8 -0
- package/lib/polygon/shaders/extrusion/polygon_extrusion_vert.glsl +24 -0
- package/lib/polygon/shaders/fill/fill_frag.glsl +8 -0
- package/lib/polygon/shaders/fill/fill_linear_frag.glsl +23 -0
- package/lib/polygon/shaders/fill/fill_linear_vert.glsl +36 -0
- package/lib/polygon/shaders/fill/fill_vert.glsl +35 -0
- package/lib/polygon/shaders/ocean/ocean_frag.glsl +277 -0
- package/lib/polygon/shaders/ocean/ocean_vert.glsl +21 -0
- package/lib/polygon/shaders/water/polygon_water_frag.glsl +78 -0
- package/lib/polygon/shaders/water/polygon_water_vert.glsl +22 -0
- package/lib/raster/buffers/triangulation.d.ts +6 -0
- package/lib/raster/buffers/triangulation.js +33 -0
- package/lib/raster/index.d.ts +11 -0
- package/lib/raster/index.js +63 -0
- package/lib/raster/models/index.d.ts +5 -0
- package/lib/raster/models/index.js +17 -0
- package/lib/raster/models/raster.d.ts +35 -0
- package/lib/raster/models/raster.js +164 -0
- package/lib/raster/models/rasterRgb.d.ts +35 -0
- package/lib/raster/models/rasterRgb.js +166 -0
- package/lib/raster/models/rasterTerrainRgb.d.ts +30 -0
- package/lib/raster/models/rasterTerrainRgb.js +126 -0
- package/lib/raster/shaders/raster/raster_2d_frag.glsl +37 -0
- package/lib/raster/shaders/raster/raster_2d_vert.glsl +21 -0
- package/lib/raster/shaders/rgb/raster_rgb_frag.glsl +30 -0
- package/lib/raster/shaders/rgb/raster_rgb_vert.glsl +21 -0
- package/lib/raster/shaders/terrain/terrain_rgb_frag.glsl +40 -0
- package/lib/raster/shaders/terrain/terrain_rgb_vert.glsl +19 -0
- package/lib/shader/minify_frag.glsl +11 -0
- package/lib/shader/minify_picking_frag.glsl +10 -0
- package/lib/tile/core/BaseLayer.d.ts +50 -0
- package/lib/tile/core/BaseLayer.js +264 -0
- package/lib/tile/core/TileDebugLayer.d.ts +15 -0
- package/lib/tile/core/TileDebugLayer.js +31 -0
- package/lib/tile/interaction/getFeatureData.d.ts +0 -0
- package/lib/tile/interaction/getFeatureData.js +1 -0
- package/lib/tile/interaction/getRasterData.d.ts +4 -0
- package/lib/tile/interaction/getRasterData.js +52 -0
- package/lib/tile/interaction/utils.d.ts +11 -0
- package/lib/tile/interaction/utils.js +81 -0
- package/lib/tile/interface.d.ts +29 -0
- package/lib/tile/interface.js +5 -0
- package/lib/tile/service/TileLayerService.d.ts +58 -0
- package/lib/tile/service/TileLayerService.js +203 -0
- package/lib/tile/service/TilePickService.d.ts +26 -0
- package/lib/tile/service/TilePickService.js +134 -0
- package/lib/tile/service/TileSourceService.d.ts +7 -0
- package/lib/tile/service/TileSourceService.js +35 -0
- package/lib/tile/tile/DebugTile.d.ts +16 -0
- package/lib/tile/tile/DebugTile.js +55 -0
- package/lib/tile/tile/ImageTile.d.ts +14 -0
- package/lib/tile/tile/ImageTile.js +47 -0
- package/lib/tile/tile/MaskTile.d.ts +18 -0
- package/lib/tile/tile/MaskTile.js +62 -0
- package/lib/tile/tile/RasterRGBTile.d.ts +11 -0
- package/lib/tile/tile/RasterRGBTile.js +55 -0
- package/lib/tile/tile/RasterTerrainRGBTile.d.ts +14 -0
- package/lib/tile/tile/RasterTerrainRGBTile.js +47 -0
- package/lib/tile/tile/RasterTile.d.ts +18 -0
- package/lib/tile/tile/RasterTile.js +89 -0
- package/lib/tile/tile/Tile.d.ts +112 -0
- package/lib/tile/tile/Tile.js +174 -0
- package/lib/tile/tile/VectorTile.d.ts +26 -0
- package/lib/tile/tile/VectorTile.js +95 -0
- package/lib/tile/tile/index.d.ts +12 -0
- package/lib/tile/tile/index.js +76 -0
- package/lib/tile/tile/util.d.ts +5 -0
- package/lib/tile/tile/util.js +26 -0
- package/lib/tile/utils/constants.d.ts +1 -0
- package/lib/tile/utils/constants.js +14 -0
- package/lib/tile/utils/utils.d.ts +8 -0
- package/lib/tile/utils/utils.js +18 -0
- package/lib/utils/blend.d.ts +2 -0
- package/lib/utils/blend.js +63 -0
- package/lib/utils/collision-index.d.ts +47 -0
- package/lib/utils/collision-index.js +96 -0
- package/lib/utils/extrude_polyline.d.ts +53 -0
- package/lib/utils/extrude_polyline.js +331 -0
- package/lib/utils/grid-index.d.ts +28 -0
- package/lib/utils/grid-index.js +135 -0
- package/lib/utils/identityScale.d.ts +8 -0
- package/lib/utils/identityScale.js +32 -0
- package/lib/utils/load-image.d.ts +1 -0
- package/lib/utils/load-image.js +29 -0
- package/lib/utils/multiPassRender.d.ts +16 -0
- package/lib/utils/multiPassRender.js +44 -0
- package/lib/utils/polylineNormal.d.ts +9 -0
- package/lib/utils/polylineNormal.js +191 -0
- package/lib/utils/rampcolor_legend.d.ts +6 -0
- package/lib/utils/rampcolor_legend.js +18 -0
- package/lib/utils/scale.d.ts +87 -0
- package/lib/utils/scale.js +610 -0
- package/lib/utils/simpleLine.d.ts +23 -0
- package/lib/utils/simpleLine.js +85 -0
- package/lib/utils/stencil.d.ts +7 -0
- package/lib/utils/stencil.js +56 -0
- package/lib/utils/symbol-layout.d.ts +43 -0
- package/lib/utils/symbol-layout.js +258 -0
- package/lib/wind/index.d.ts +11 -0
- package/lib/wind/index.js +42 -0
- package/lib/wind/models/index.d.ts +5 -0
- package/lib/wind/models/index.js +12 -0
- package/lib/wind/models/utils.d.ts +19 -0
- package/lib/wind/models/utils.js +229 -0
- package/lib/wind/models/wind.d.ts +38 -0
- package/lib/wind/models/wind.js +248 -0
- package/lib/wind/models/windRender.d.ts +104 -0
- package/lib/wind/models/windRender.js +343 -0
- package/lib/wind/models/windShader.d.ts +12 -0
- package/lib/wind/models/windShader.js +157 -0
- package/lib/wind/shaders/wind_frag.glsl +9 -0
- package/lib/wind/shaders/wind_vert.glsl +14 -0
- package/package.json +6 -6
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
+
import { AttributeType, gl } from '@antv/l7-core';
|
|
4
|
+
import { FrequencyController } from '@antv/l7-utils';
|
|
5
|
+
import BaseModel from "../../core/BaseModel";
|
|
6
|
+
import { RasterImageTriangulation } from "../../core/triangulation";
|
|
7
|
+
/* babel-plugin-inline-import '../shaders/wind_frag.glsl' */
|
|
8
|
+
const WindFrag = "precision mediump float;\nuniform float u_opacity: 1.0;\nuniform sampler2D u_texture;\nvarying vec2 v_texCoord;\nvoid main() {\n vec4 color = texture2D(u_texture,vec2(v_texCoord.x,v_texCoord.y));\n gl_FragColor = color;\n gl_FragColor.a *= u_opacity;\n}\n";
|
|
9
|
+
/* babel-plugin-inline-import '../shaders/wind_vert.glsl' */
|
|
10
|
+
const WindVert = "precision highp float;\nuniform mat4 u_ModelMatrix;\n\nlayout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\nvarying vec2 v_texCoord;\n#pragma include \"projection\"\nvoid main() {\n v_texCoord = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, 0.0, 1.0));\n}\n";
|
|
11
|
+
import { Wind } from "./windRender";
|
|
12
|
+
const defaultRampColors = {
|
|
13
|
+
0.0: '#3288bd',
|
|
14
|
+
0.1: '#66c2a5',
|
|
15
|
+
0.2: '#abdda4',
|
|
16
|
+
0.3: '#e6f598',
|
|
17
|
+
0.4: '#fee08b',
|
|
18
|
+
0.5: '#fdae61',
|
|
19
|
+
0.6: '#f46d43',
|
|
20
|
+
1.0: '#d53e4f'
|
|
21
|
+
};
|
|
22
|
+
export default class WindModel extends BaseModel {
|
|
23
|
+
constructor(...args) {
|
|
24
|
+
super(...args);
|
|
25
|
+
_defineProperty(this, "texture", void 0);
|
|
26
|
+
_defineProperty(this, "colorModel", void 0);
|
|
27
|
+
_defineProperty(this, "wind", void 0);
|
|
28
|
+
_defineProperty(this, "imageCoords", void 0);
|
|
29
|
+
_defineProperty(this, "sizeScale", 0.5);
|
|
30
|
+
// https://mapbox.github.io/webgl-wind/demo/
|
|
31
|
+
// source: 'http://nomads.ncep.noaa.gov',
|
|
32
|
+
_defineProperty(this, "frequency", new FrequencyController(7.2));
|
|
33
|
+
_defineProperty(this, "cacheZoom", void 0);
|
|
34
|
+
}
|
|
35
|
+
get attributeLocation() {
|
|
36
|
+
return Object.assign(super.attributeLocation, {
|
|
37
|
+
MAX: super.attributeLocation.MAX,
|
|
38
|
+
UV: 9
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
render(options) {
|
|
42
|
+
this.drawColorMode(options);
|
|
43
|
+
// Tip: 控制风场的平均更新频率
|
|
44
|
+
this.frequency.run(() => {
|
|
45
|
+
this.drawWind();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
getUninforms() {
|
|
49
|
+
throw new Error('Method not implemented.');
|
|
50
|
+
}
|
|
51
|
+
initModels() {
|
|
52
|
+
var _this = this;
|
|
53
|
+
return _asyncToGenerator(function* () {
|
|
54
|
+
var _source$data, _source$data2;
|
|
55
|
+
const {
|
|
56
|
+
uMin = -21.32,
|
|
57
|
+
uMax = 26.8,
|
|
58
|
+
vMin = -21.57,
|
|
59
|
+
vMax = 21.42,
|
|
60
|
+
fadeOpacity = 0.996,
|
|
61
|
+
speedFactor = 0.25,
|
|
62
|
+
dropRate = 0.003,
|
|
63
|
+
dropRateBump = 0.01,
|
|
64
|
+
rampColors = defaultRampColors,
|
|
65
|
+
sizeScale = 0.5
|
|
66
|
+
// mask
|
|
67
|
+
} = _this.layer.getLayerConfig();
|
|
68
|
+
const {
|
|
69
|
+
createTexture2D
|
|
70
|
+
} = _this.rendererService;
|
|
71
|
+
const source = _this.layer.getSource();
|
|
72
|
+
_this.texture = createTexture2D({
|
|
73
|
+
height: 0,
|
|
74
|
+
width: 0
|
|
75
|
+
});
|
|
76
|
+
_this.cacheZoom = Math.floor(_this.mapService.getZoom());
|
|
77
|
+
const glContext = _this.rendererService.getGLContext();
|
|
78
|
+
_this.imageCoords = (_source$data = source.data) === null || _source$data === void 0 ? void 0 : _source$data.dataArray[0].coordinates;
|
|
79
|
+
(_source$data2 = source.data) === null || _source$data2 === void 0 || (_source$data2 = _source$data2.images) === null || _source$data2 === void 0 || _source$data2.then(imageData => {
|
|
80
|
+
var _this$texture;
|
|
81
|
+
_this.sizeScale = sizeScale * _this.getZoomScale();
|
|
82
|
+
const {
|
|
83
|
+
imageWidth,
|
|
84
|
+
imageHeight
|
|
85
|
+
} = _this.getWindSize();
|
|
86
|
+
const options = {
|
|
87
|
+
glContext,
|
|
88
|
+
imageWidth,
|
|
89
|
+
imageHeight,
|
|
90
|
+
fadeOpacity,
|
|
91
|
+
speedFactor,
|
|
92
|
+
dropRate,
|
|
93
|
+
dropRateBump,
|
|
94
|
+
rampColors
|
|
95
|
+
};
|
|
96
|
+
_this.wind = new Wind(options);
|
|
97
|
+
|
|
98
|
+
// imageData[0] 风场图
|
|
99
|
+
_this.wind.setWind({
|
|
100
|
+
uMin,
|
|
101
|
+
uMax,
|
|
102
|
+
vMin,
|
|
103
|
+
vMax,
|
|
104
|
+
image: imageData[0]
|
|
105
|
+
});
|
|
106
|
+
(_this$texture = _this.texture) === null || _this$texture === void 0 || _this$texture.destroy();
|
|
107
|
+
_this.texture = createTexture2D({
|
|
108
|
+
width: imageWidth,
|
|
109
|
+
height: imageHeight
|
|
110
|
+
});
|
|
111
|
+
_this.layerService.reRender();
|
|
112
|
+
});
|
|
113
|
+
const model = yield _this.layer.buildLayerModel({
|
|
114
|
+
moduleName: 'wind',
|
|
115
|
+
vertexShader: WindVert,
|
|
116
|
+
fragmentShader: WindFrag,
|
|
117
|
+
defines: _this.getDefines(),
|
|
118
|
+
triangulation: RasterImageTriangulation,
|
|
119
|
+
primitive: gl.TRIANGLES,
|
|
120
|
+
depth: {
|
|
121
|
+
enable: false
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
_this.colorModel = model;
|
|
125
|
+
return [model];
|
|
126
|
+
})();
|
|
127
|
+
}
|
|
128
|
+
getWindSize() {
|
|
129
|
+
const p1 = this.mapService.lngLatToPixel(this.imageCoords[0]);
|
|
130
|
+
const p2 = this.mapService.lngLatToPixel(this.imageCoords[1]);
|
|
131
|
+
const imageWidth = Math.min(Math.floor((p2.x - p1.x) * this.sizeScale), 2048);
|
|
132
|
+
const imageHeight = Math.min(Math.floor((p1.y - p2.y) * this.sizeScale), 2048);
|
|
133
|
+
return {
|
|
134
|
+
imageWidth,
|
|
135
|
+
imageHeight
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
buildModels() {
|
|
139
|
+
var _this2 = this;
|
|
140
|
+
return _asyncToGenerator(function* () {
|
|
141
|
+
return _this2.initModels();
|
|
142
|
+
})();
|
|
143
|
+
}
|
|
144
|
+
clearModels() {
|
|
145
|
+
var _this$texture2, _this$wind;
|
|
146
|
+
(_this$texture2 = this.texture) === null || _this$texture2 === void 0 || _this$texture2.destroy();
|
|
147
|
+
(_this$wind = this.wind) === null || _this$wind === void 0 || _this$wind.destroy();
|
|
148
|
+
}
|
|
149
|
+
registerBuiltinAttributes() {
|
|
150
|
+
// point layer size;
|
|
151
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
152
|
+
name: 'uv',
|
|
153
|
+
type: AttributeType.Attribute,
|
|
154
|
+
descriptor: {
|
|
155
|
+
name: 'a_Uv',
|
|
156
|
+
shaderLocation: this.attributeLocation.UV,
|
|
157
|
+
buffer: {
|
|
158
|
+
// give the WebGL driver a hint that this buffer may change
|
|
159
|
+
usage: gl.DYNAMIC_DRAW,
|
|
160
|
+
data: [],
|
|
161
|
+
type: gl.FLOAT
|
|
162
|
+
},
|
|
163
|
+
size: 2,
|
|
164
|
+
update: (feature, featureIdx, vertex) => {
|
|
165
|
+
return [vertex[3], vertex[4]];
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
getZoomScale() {
|
|
171
|
+
return Math.min((this.cacheZoom + 4) / 30 * 2, 2);
|
|
172
|
+
}
|
|
173
|
+
drawWind() {
|
|
174
|
+
if (this.wind) {
|
|
175
|
+
const {
|
|
176
|
+
uMin = -21.32,
|
|
177
|
+
uMax = 26.8,
|
|
178
|
+
vMin = -21.57,
|
|
179
|
+
vMax = 21.42,
|
|
180
|
+
numParticles = 65535,
|
|
181
|
+
fadeOpacity = 0.996,
|
|
182
|
+
speedFactor = 0.25,
|
|
183
|
+
dropRate = 0.003,
|
|
184
|
+
dropRateBump = 0.01,
|
|
185
|
+
rampColors = defaultRampColors,
|
|
186
|
+
sizeScale = 0.5
|
|
187
|
+
} = this.layer.getLayerConfig();
|
|
188
|
+
let newNumParticles = numParticles;
|
|
189
|
+
const currentZoom = Math.floor(this.mapService.getZoom());
|
|
190
|
+
if (typeof sizeScale === 'number' && sizeScale !== this.sizeScale || currentZoom !== this.cacheZoom) {
|
|
191
|
+
const zoomScale = this.getZoomScale();
|
|
192
|
+
this.sizeScale = sizeScale;
|
|
193
|
+
newNumParticles *= zoomScale;
|
|
194
|
+
const {
|
|
195
|
+
imageWidth,
|
|
196
|
+
imageHeight
|
|
197
|
+
} = this.getWindSize();
|
|
198
|
+
this.wind.reSize(imageWidth, imageHeight);
|
|
199
|
+
this.cacheZoom = currentZoom;
|
|
200
|
+
}
|
|
201
|
+
this.wind.updateWindDir(uMin, uMax, vMin, vMax);
|
|
202
|
+
this.wind.updateParticelNum(newNumParticles);
|
|
203
|
+
this.wind.updateColorRampTexture(rampColors);
|
|
204
|
+
this.wind.fadeOpacity = fadeOpacity;
|
|
205
|
+
this.wind.speedFactor = speedFactor;
|
|
206
|
+
this.wind.dropRate = dropRate;
|
|
207
|
+
this.wind.dropRateBump = dropRateBump;
|
|
208
|
+
const {
|
|
209
|
+
d,
|
|
210
|
+
w,
|
|
211
|
+
h
|
|
212
|
+
} = this.wind.draw();
|
|
213
|
+
// 恢复 L7 渲染流程中 gl 状态
|
|
214
|
+
this.rendererService.setBaseState();
|
|
215
|
+
this.texture.update({
|
|
216
|
+
data: d,
|
|
217
|
+
width: w,
|
|
218
|
+
height: h
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
drawColorMode(options = {}) {
|
|
223
|
+
var _this$colorModel;
|
|
224
|
+
const {
|
|
225
|
+
opacity
|
|
226
|
+
} = this.layer.getLayerConfig();
|
|
227
|
+
this.layerService.beforeRenderData(this.layer);
|
|
228
|
+
this.layer.hooks.beforeRender.call();
|
|
229
|
+
this.layerService.renderMask(this.layer.masks);
|
|
230
|
+
(_this$colorModel = this.colorModel) === null || _this$colorModel === void 0 || _this$colorModel.draw({
|
|
231
|
+
uniforms: {
|
|
232
|
+
u_opacity: opacity || 1.0,
|
|
233
|
+
u_texture: this.texture
|
|
234
|
+
},
|
|
235
|
+
blend: this.getBlend(),
|
|
236
|
+
stencil: this.getStencil(options)
|
|
237
|
+
});
|
|
238
|
+
this.layer.hooks.afterRender.call();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export interface IWindData {
|
|
2
|
+
uMin: number;
|
|
3
|
+
uMax: number;
|
|
4
|
+
vMin: number;
|
|
5
|
+
vMax: number;
|
|
6
|
+
image: HTMLImageElement;
|
|
7
|
+
}
|
|
8
|
+
export interface IWind {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
fadeOpacity: number;
|
|
12
|
+
speedFactor: number;
|
|
13
|
+
dropRate: number;
|
|
14
|
+
dropRateBump: number;
|
|
15
|
+
setWind: (windData: IWindData) => void;
|
|
16
|
+
draw: () => {
|
|
17
|
+
d: Uint8Array;
|
|
18
|
+
w: number;
|
|
19
|
+
h: number;
|
|
20
|
+
};
|
|
21
|
+
updateParticelNum: (num: number) => void;
|
|
22
|
+
updateWindDir: (uMin: number, uMax: number, vMin: number, vMax: number) => void;
|
|
23
|
+
updateColorRampTexture: (rampColors: {
|
|
24
|
+
[key: number]: string;
|
|
25
|
+
}) => void;
|
|
26
|
+
reSize: (width: number, height: number) => void;
|
|
27
|
+
destroy: () => void;
|
|
28
|
+
}
|
|
29
|
+
export interface IWindProps {
|
|
30
|
+
glContext: WebGLRenderingContext;
|
|
31
|
+
imageWidth: number;
|
|
32
|
+
imageHeight: number;
|
|
33
|
+
fadeOpacity: number;
|
|
34
|
+
speedFactor: number;
|
|
35
|
+
dropRate: number;
|
|
36
|
+
dropRateBump: number;
|
|
37
|
+
rampColors: {
|
|
38
|
+
[key: number]: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export declare class Wind {
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
pixels: Uint8Array;
|
|
45
|
+
fadeOpacity: number;
|
|
46
|
+
speedFactor: number;
|
|
47
|
+
dropRate: number;
|
|
48
|
+
dropRateBump: number;
|
|
49
|
+
private gl;
|
|
50
|
+
private drawProgram;
|
|
51
|
+
private fullScreenProgram;
|
|
52
|
+
private updateProgram;
|
|
53
|
+
private rampColors;
|
|
54
|
+
private numParticles;
|
|
55
|
+
private numParticlesSize;
|
|
56
|
+
private particleStateResolution;
|
|
57
|
+
private quadBuffer;
|
|
58
|
+
private particleIndexBuffer;
|
|
59
|
+
private framebuffer;
|
|
60
|
+
private colorRampTexture;
|
|
61
|
+
private backgroundTexture;
|
|
62
|
+
private screenTexture;
|
|
63
|
+
private particleStateTexture0;
|
|
64
|
+
private particleStateTexture1;
|
|
65
|
+
private windTexture;
|
|
66
|
+
private windData;
|
|
67
|
+
constructor(options: IWindProps);
|
|
68
|
+
init(): void;
|
|
69
|
+
setWind(windData: IWindData): void;
|
|
70
|
+
/**
|
|
71
|
+
* 更新风场粒子数量
|
|
72
|
+
* @param num
|
|
73
|
+
*/
|
|
74
|
+
updateParticelNum(num: number): void;
|
|
75
|
+
/**
|
|
76
|
+
* 更新风场风向风速
|
|
77
|
+
* @param uMin
|
|
78
|
+
* @param uMax
|
|
79
|
+
* @param vMin
|
|
80
|
+
* @param vMax
|
|
81
|
+
*/
|
|
82
|
+
updateWindDir(uMin: number, uMax: number, vMin: number, vMax: number): void;
|
|
83
|
+
/**
|
|
84
|
+
* update rampColors
|
|
85
|
+
* @param rampColors
|
|
86
|
+
*/
|
|
87
|
+
updateColorRampTexture(rampColors: {
|
|
88
|
+
[key: number]: string;
|
|
89
|
+
}): void;
|
|
90
|
+
isColorChanged(rampColors: {
|
|
91
|
+
[key: number]: string;
|
|
92
|
+
}): boolean;
|
|
93
|
+
reSize(width: number, height: number): void;
|
|
94
|
+
draw(): {
|
|
95
|
+
d: Uint8Array;
|
|
96
|
+
w: number;
|
|
97
|
+
h: number;
|
|
98
|
+
};
|
|
99
|
+
drawScreen(): void;
|
|
100
|
+
drawFullTexture(texture: any, opacity: number): void;
|
|
101
|
+
drawParticles(): void;
|
|
102
|
+
updateParticles(): void;
|
|
103
|
+
destroy(): void;
|
|
104
|
+
}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import * as glUtils from "./utils";
|
|
3
|
+
import { drawFrag, drawVert, fullScreenFrag, fullScreenVert, updateFrag, updateVert } from "./windShader";
|
|
4
|
+
function getColorRamp(colors) {
|
|
5
|
+
let canvas = document.createElement('canvas');
|
|
6
|
+
const ctx = canvas.getContext('2d');
|
|
7
|
+
canvas.width = 256;
|
|
8
|
+
canvas.height = 1;
|
|
9
|
+
const gradient = ctx.createLinearGradient(0, 0, 256, 0);
|
|
10
|
+
for (const stop of Object.keys(colors)) {
|
|
11
|
+
gradient.addColorStop(+stop, colors[+stop]);
|
|
12
|
+
}
|
|
13
|
+
ctx.fillStyle = gradient;
|
|
14
|
+
ctx.fillRect(0, 0, 256, 1);
|
|
15
|
+
|
|
16
|
+
// @ts-ignore dispose canvas element
|
|
17
|
+
canvas = null;
|
|
18
|
+
return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);
|
|
19
|
+
}
|
|
20
|
+
function bindAttribute(gl, buffer, attribute, numComponents) {
|
|
21
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
22
|
+
gl.enableVertexAttribArray(attribute);
|
|
23
|
+
gl.vertexAttribPointer(attribute, numComponents, gl.FLOAT, false, 0, 0);
|
|
24
|
+
}
|
|
25
|
+
function bindFramebuffer(gl, framebuffer, texture) {
|
|
26
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
|
|
27
|
+
if (texture) {
|
|
28
|
+
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export class Wind {
|
|
32
|
+
constructor(options) {
|
|
33
|
+
_defineProperty(this, "width", 512);
|
|
34
|
+
_defineProperty(this, "height", 512);
|
|
35
|
+
_defineProperty(this, "pixels", void 0);
|
|
36
|
+
_defineProperty(this, "fadeOpacity", void 0);
|
|
37
|
+
_defineProperty(this, "speedFactor", void 0);
|
|
38
|
+
_defineProperty(this, "dropRate", void 0);
|
|
39
|
+
_defineProperty(this, "dropRateBump", void 0);
|
|
40
|
+
_defineProperty(this, "gl", void 0);
|
|
41
|
+
_defineProperty(this, "drawProgram", void 0);
|
|
42
|
+
_defineProperty(this, "fullScreenProgram", void 0);
|
|
43
|
+
_defineProperty(this, "updateProgram", void 0);
|
|
44
|
+
_defineProperty(this, "rampColors", void 0);
|
|
45
|
+
_defineProperty(this, "numParticles", 65536);
|
|
46
|
+
_defineProperty(this, "numParticlesSize", void 0);
|
|
47
|
+
_defineProperty(this, "particleStateResolution", void 0);
|
|
48
|
+
_defineProperty(this, "quadBuffer", void 0);
|
|
49
|
+
_defineProperty(this, "particleIndexBuffer", void 0);
|
|
50
|
+
_defineProperty(this, "framebuffer", void 0);
|
|
51
|
+
_defineProperty(this, "colorRampTexture", void 0);
|
|
52
|
+
_defineProperty(this, "backgroundTexture", void 0);
|
|
53
|
+
_defineProperty(this, "screenTexture", void 0);
|
|
54
|
+
_defineProperty(this, "particleStateTexture0", void 0);
|
|
55
|
+
_defineProperty(this, "particleStateTexture1", void 0);
|
|
56
|
+
_defineProperty(this, "windTexture", void 0);
|
|
57
|
+
_defineProperty(this, "windData", void 0);
|
|
58
|
+
this.gl = options.glContext;
|
|
59
|
+
this.width = options.imageWidth;
|
|
60
|
+
this.height = options.imageHeight;
|
|
61
|
+
this.fadeOpacity = options.fadeOpacity;
|
|
62
|
+
this.speedFactor = options.speedFactor;
|
|
63
|
+
this.dropRate = options.dropRate;
|
|
64
|
+
this.dropRateBump = options.dropRateBump;
|
|
65
|
+
this.rampColors = options.rampColors;
|
|
66
|
+
this.init();
|
|
67
|
+
}
|
|
68
|
+
init() {
|
|
69
|
+
const gl = this.gl;
|
|
70
|
+
this.fadeOpacity = 0.996; // how fast the particle trails fade on each frame
|
|
71
|
+
this.speedFactor = 0.25; // how fast the particles move
|
|
72
|
+
this.dropRate = 0.003; // how often the particles move to a random place
|
|
73
|
+
this.dropRateBump = 0.01; // drop rate increase relative to individual particle speed
|
|
74
|
+
|
|
75
|
+
this.drawProgram = glUtils.createProgram(gl, drawVert, drawFrag);
|
|
76
|
+
this.fullScreenProgram = glUtils.createProgram(gl, fullScreenVert, fullScreenFrag);
|
|
77
|
+
this.updateProgram = glUtils.createProgram(gl, updateVert, updateFrag);
|
|
78
|
+
this.quadBuffer = glUtils.createBuffer(gl, new Float32Array([0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]));
|
|
79
|
+
this.framebuffer = gl.createFramebuffer();
|
|
80
|
+
this.colorRampTexture = glUtils.createTexture(this.gl, this.gl.LINEAR, getColorRamp(this.rampColors), 16, 16);
|
|
81
|
+
const emptyPixels = new Uint8Array(this.width * this.height * 4);
|
|
82
|
+
|
|
83
|
+
// screen textures to hold the drawn screen for the previous and the current frame
|
|
84
|
+
|
|
85
|
+
this.backgroundTexture = glUtils.createTexture(gl, gl.NEAREST, emptyPixels, this.width, this.height);
|
|
86
|
+
this.screenTexture = glUtils.createTexture(gl, gl.NEAREST, emptyPixels, this.width, this.height);
|
|
87
|
+
|
|
88
|
+
// we create a square texture where each pixel will hold a particle position encoded as RGBA
|
|
89
|
+
const particleRes = this.particleStateResolution = Math.ceil(Math.sqrt(this.numParticles));
|
|
90
|
+
// particleRes size
|
|
91
|
+
this.numParticlesSize = particleRes * particleRes;
|
|
92
|
+
const particleState = new Uint8Array(this.numParticlesSize * 4);
|
|
93
|
+
for (let i = 0; i < particleState.length; i++) {
|
|
94
|
+
particleState[i] = Math.floor(Math.random() * 256); // randomize the initial particle positions
|
|
95
|
+
}
|
|
96
|
+
// textures to hold the particle state for the current and the next frame
|
|
97
|
+
this.particleStateTexture0 = glUtils.createTexture(gl, gl.NEAREST, particleState, particleRes, particleRes);
|
|
98
|
+
this.particleStateTexture1 = glUtils.createTexture(gl, gl.NEAREST, particleState, particleRes, particleRes);
|
|
99
|
+
const particleIndices = new Float32Array(this.numParticlesSize);
|
|
100
|
+
for (let i$1 = 0; i$1 < this.numParticlesSize; i$1++) {
|
|
101
|
+
particleIndices[i$1] = i$1;
|
|
102
|
+
}
|
|
103
|
+
this.particleIndexBuffer = glUtils.createBuffer(gl, particleIndices);
|
|
104
|
+
}
|
|
105
|
+
setWind(windData) {
|
|
106
|
+
this.windData = windData;
|
|
107
|
+
this.windTexture = glUtils.createDataTexture(this.gl, this.gl.LINEAR, windData.image);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 更新风场粒子数量
|
|
112
|
+
* @param num
|
|
113
|
+
*/
|
|
114
|
+
updateParticelNum(num) {
|
|
115
|
+
const gl = this.gl;
|
|
116
|
+
if (num !== this.numParticles) {
|
|
117
|
+
this.numParticles = num; // params number
|
|
118
|
+
|
|
119
|
+
// we create a square texture where each pixel will hold a particle position encoded as RGBA
|
|
120
|
+
const particleRes = this.particleStateResolution = Math.ceil(Math.sqrt(this.numParticles));
|
|
121
|
+
this.numParticlesSize = particleRes * particleRes;
|
|
122
|
+
const particleState = new Uint8Array(this.numParticlesSize * 4);
|
|
123
|
+
for (let i = 0; i < particleState.length; i++) {
|
|
124
|
+
particleState[i] = Math.floor(Math.random() * 256); // randomize the initial particle positions
|
|
125
|
+
}
|
|
126
|
+
// textures to hold the particle state for the current and the next frame
|
|
127
|
+
this.particleStateTexture0 = glUtils.createTexture(gl, gl.NEAREST, particleState, particleRes, particleRes);
|
|
128
|
+
this.particleStateTexture1 = glUtils.createTexture(gl, gl.NEAREST, particleState, particleRes, particleRes);
|
|
129
|
+
const particleIndices = new Float32Array(this.numParticlesSize);
|
|
130
|
+
for (let i$1 = 0; i$1 < this.numParticlesSize; i$1++) {
|
|
131
|
+
particleIndices[i$1] = i$1;
|
|
132
|
+
}
|
|
133
|
+
this.particleIndexBuffer = glUtils.createBuffer(gl, particleIndices);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 更新风场风向风速
|
|
139
|
+
* @param uMin
|
|
140
|
+
* @param uMax
|
|
141
|
+
* @param vMin
|
|
142
|
+
* @param vMax
|
|
143
|
+
*/
|
|
144
|
+
updateWindDir(uMin, uMax, vMin, vMax) {
|
|
145
|
+
this.windData.uMin = uMin;
|
|
146
|
+
this.windData.uMax = uMax;
|
|
147
|
+
this.windData.vMin = vMin;
|
|
148
|
+
this.windData.vMax = vMax;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* update rampColors
|
|
153
|
+
* @param rampColors
|
|
154
|
+
*/
|
|
155
|
+
updateColorRampTexture(rampColors) {
|
|
156
|
+
if (this.isColorChanged(rampColors)) {
|
|
157
|
+
this.rampColors = rampColors;
|
|
158
|
+
const gl = this.gl;
|
|
159
|
+
gl.deleteTexture(this.colorRampTexture);
|
|
160
|
+
this.colorRampTexture = glUtils.createTexture(gl, gl.LINEAR, getColorRamp(rampColors), 16, 16);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
isColorChanged(rampColors) {
|
|
164
|
+
const keys = Object.keys(rampColors);
|
|
165
|
+
for (const item of keys) {
|
|
166
|
+
const key = Number(item);
|
|
167
|
+
// exist new key -> color need update
|
|
168
|
+
if (!this.rampColors[key]) {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
// value changed -> color need update
|
|
172
|
+
if (this.rampColors[key] && this.rampColors[key] !== rampColors[key]) {
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
reSize(width, height) {
|
|
179
|
+
if (width !== this.width || height !== this.height) {
|
|
180
|
+
const gl = this.gl;
|
|
181
|
+
gl.deleteTexture(this.backgroundTexture);
|
|
182
|
+
gl.deleteTexture(this.screenTexture);
|
|
183
|
+
this.width = width;
|
|
184
|
+
this.height = height;
|
|
185
|
+
const emptyPixels = new Uint8Array(width * height * 4);
|
|
186
|
+
// screen textures to hold the drawn screen for the previous and the current frame
|
|
187
|
+
this.backgroundTexture = glUtils.createTexture(gl, gl.NEAREST, emptyPixels, width, height);
|
|
188
|
+
this.screenTexture = glUtils.createTexture(gl, gl.NEAREST, emptyPixels, width, height);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
draw() {
|
|
192
|
+
var _this$windData;
|
|
193
|
+
if ((_this$windData = this.windData) !== null && _this$windData !== void 0 && _this$windData.image) {
|
|
194
|
+
const gl = this.gl;
|
|
195
|
+
glUtils.bindTexture(gl, this.windTexture, 0);
|
|
196
|
+
glUtils.bindTexture(gl, this.particleStateTexture0, 1);
|
|
197
|
+
this.drawScreen(); // draw Particles into framebuffer
|
|
198
|
+
this.updateParticles();
|
|
199
|
+
return {
|
|
200
|
+
d: this.pixels,
|
|
201
|
+
w: this.width,
|
|
202
|
+
h: this.height
|
|
203
|
+
};
|
|
204
|
+
} else {
|
|
205
|
+
return {
|
|
206
|
+
d: new Uint8Array([0, 0, 0, 0]),
|
|
207
|
+
w: 1,
|
|
208
|
+
h: 1
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
drawScreen() {
|
|
213
|
+
const gl = this.gl;
|
|
214
|
+
|
|
215
|
+
// draw the screen into a temporary framebuffer to retain it as the background on the next frame
|
|
216
|
+
bindFramebuffer(gl, this.framebuffer, this.screenTexture);
|
|
217
|
+
gl.viewport(0, 0, this.width, this.height);
|
|
218
|
+
gl.disable(gl.BLEND);
|
|
219
|
+
this.drawFullTexture(this.backgroundTexture, this.fadeOpacity);
|
|
220
|
+
this.drawParticles();
|
|
221
|
+
this.pixels = new Uint8Array(4 * this.width * this.height);
|
|
222
|
+
gl.readPixels(0, 0, this.width, this.height, gl.RGBA, gl.UNSIGNED_BYTE, this.pixels);
|
|
223
|
+
bindFramebuffer(gl, null, null);
|
|
224
|
+
gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);
|
|
225
|
+
|
|
226
|
+
// save the current screen as the background for the next frame
|
|
227
|
+
const temp = this.backgroundTexture;
|
|
228
|
+
this.backgroundTexture = this.screenTexture;
|
|
229
|
+
this.screenTexture = temp;
|
|
230
|
+
}
|
|
231
|
+
drawFullTexture(texture, opacity) {
|
|
232
|
+
const gl = this.gl;
|
|
233
|
+
const program = this.fullScreenProgram;
|
|
234
|
+
gl.useProgram(program);
|
|
235
|
+
|
|
236
|
+
// bindAttribute(gl, this.quadBuffer, program.a_pos, 2);
|
|
237
|
+
|
|
238
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this.quadBuffer);
|
|
239
|
+
gl.vertexAttribPointer(program.a_pos, 2, gl.FLOAT, false, 0, 0);
|
|
240
|
+
gl.enableVertexAttribArray(program.a_pos);
|
|
241
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
242
|
+
glUtils.bindTexture(gl, texture, 2);
|
|
243
|
+
gl.uniform1i(program.u_screen, 2);
|
|
244
|
+
gl.uniform1f(program.u_opacity, opacity);
|
|
245
|
+
gl.drawArrays(gl.TRIANGLES, 0, 6);
|
|
246
|
+
// gl.drawArrays(gl.POINTS, 0, 6);
|
|
247
|
+
}
|
|
248
|
+
drawParticles() {
|
|
249
|
+
const gl = this.gl;
|
|
250
|
+
const program = this.drawProgram;
|
|
251
|
+
gl.useProgram(program);
|
|
252
|
+
bindAttribute(gl, this.particleIndexBuffer, program.a_index, 1);
|
|
253
|
+
glUtils.bindTexture(gl, this.colorRampTexture, 2);
|
|
254
|
+
gl.uniform1i(program.u_wind, 0);
|
|
255
|
+
gl.uniform1i(program.u_particles, 1);
|
|
256
|
+
gl.uniform1i(program.u_color_ramp, 2);
|
|
257
|
+
gl.uniform1f(program.u_particles_res, this.particleStateResolution);
|
|
258
|
+
gl.uniform2f(program.u_wind_min, this.windData.uMin, this.windData.vMin);
|
|
259
|
+
gl.uniform2f(program.u_wind_max, this.windData.uMax, this.windData.vMax);
|
|
260
|
+
gl.drawArrays(gl.POINTS, 0, this.numParticlesSize);
|
|
261
|
+
}
|
|
262
|
+
updateParticles() {
|
|
263
|
+
const gl = this.gl;
|
|
264
|
+
bindFramebuffer(gl, this.framebuffer, this.particleStateTexture1);
|
|
265
|
+
gl.viewport(0, 0, this.particleStateResolution, this.particleStateResolution);
|
|
266
|
+
const program = this.updateProgram;
|
|
267
|
+
gl.useProgram(program);
|
|
268
|
+
bindAttribute(gl, this.quadBuffer, program.a_pos, 2);
|
|
269
|
+
gl.uniform1i(program.u_wind, 0);
|
|
270
|
+
gl.uniform1i(program.u_particles, 1);
|
|
271
|
+
gl.uniform1f(program.u_rand_seed, Math.random());
|
|
272
|
+
gl.uniform2f(program.u_wind_res, this.windData.image.width * 2, this.windData.image.height * 2);
|
|
273
|
+
gl.uniform2f(program.u_wind_min, this.windData.uMin, this.windData.vMin);
|
|
274
|
+
gl.uniform2f(program.u_wind_max, this.windData.uMax, this.windData.vMax);
|
|
275
|
+
gl.uniform1f(program.u_speed_factor, this.speedFactor);
|
|
276
|
+
gl.uniform1f(program.u_drop_rate, this.dropRate);
|
|
277
|
+
gl.uniform1f(program.u_drop_rate_bump, this.dropRateBump);
|
|
278
|
+
gl.drawArrays(gl.TRIANGLES, 0, 6);
|
|
279
|
+
|
|
280
|
+
// swap the particle state textures so the new one becomes the current one
|
|
281
|
+
const temp = this.particleStateTexture0;
|
|
282
|
+
this.particleStateTexture0 = this.particleStateTexture1;
|
|
283
|
+
this.particleStateTexture1 = temp;
|
|
284
|
+
bindFramebuffer(gl, null, null);
|
|
285
|
+
|
|
286
|
+
// gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);
|
|
287
|
+
}
|
|
288
|
+
destroy() {
|
|
289
|
+
// private drawProgram: WebGLProgram;
|
|
290
|
+
// private fullScreenProgram: WebGLProgram;
|
|
291
|
+
// private updateProgram: WebGLProgram;
|
|
292
|
+
|
|
293
|
+
// private quadBuffer: WebGLBuffer | null;
|
|
294
|
+
// private particleIndexBuffer: WebGLBuffer | null;
|
|
295
|
+
|
|
296
|
+
// private framebuffer: WebGLFramebuffer | null;
|
|
297
|
+
|
|
298
|
+
// private colorRampTexture: WebGLTexture | null;
|
|
299
|
+
// private backgroundTexture: WebGLTexture | null;
|
|
300
|
+
// private screenTexture: WebGLTexture | null;
|
|
301
|
+
// private particleStateTexture0: WebGLTexture | null;
|
|
302
|
+
// private particleStateTexture1: WebGLTexture | null;
|
|
303
|
+
// private windTexture: WebGLTexture | null;
|
|
304
|
+
|
|
305
|
+
this.gl.deleteBuffer(this.quadBuffer);
|
|
306
|
+
this.gl.deleteBuffer(this.particleIndexBuffer);
|
|
307
|
+
this.gl.deleteFramebuffer(this.framebuffer);
|
|
308
|
+
|
|
309
|
+
// @ts-ignore
|
|
310
|
+
this.gl.deleteShader(this.drawProgram.vertexShader);
|
|
311
|
+
// @ts-ignore
|
|
312
|
+
this.gl.deleteShader(this.drawProgram.fragmentShader);
|
|
313
|
+
this.gl.deleteProgram(this.drawProgram);
|
|
314
|
+
|
|
315
|
+
// @ts-ignore
|
|
316
|
+
this.gl.deleteShader(this.fullScreenProgram.vertexShader);
|
|
317
|
+
// @ts-ignore
|
|
318
|
+
this.gl.deleteShader(this.fullScreenProgram.fragmentShader);
|
|
319
|
+
this.gl.deleteProgram(this.fullScreenProgram);
|
|
320
|
+
|
|
321
|
+
// @ts-ignore
|
|
322
|
+
this.gl.deleteShader(this.updateProgram.vertexShader);
|
|
323
|
+
// @ts-ignore
|
|
324
|
+
this.gl.deleteShader(this.updateProgram.fragmentShader);
|
|
325
|
+
this.gl.deleteProgram(this.updateProgram);
|
|
326
|
+
this.gl.deleteTexture(this.colorRampTexture);
|
|
327
|
+
this.gl.deleteTexture(this.backgroundTexture);
|
|
328
|
+
this.gl.deleteTexture(this.screenTexture);
|
|
329
|
+
this.gl.deleteTexture(this.particleStateTexture0);
|
|
330
|
+
this.gl.deleteTexture(this.particleStateTexture1);
|
|
331
|
+
this.gl.deleteTexture(this.windTexture);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* drawProgram drawVert drawFrag
|
|
3
|
+
* screenProgram screenVert screenFrag
|
|
4
|
+
* updateProgram updateVert updateFrag
|
|
5
|
+
* fullScreenProgram fullScreenVert fullScreenFrag
|
|
6
|
+
*/
|
|
7
|
+
export declare const drawVert = "\n precision mediump float;\n\n attribute float a_index;\n\n uniform sampler2D u_particles;\n uniform float u_particles_res;\n\n varying vec2 v_particle_pos;\n\n void main() {\n vec4 color = texture2D(u_particles, vec2(\n fract(a_index / u_particles_res),\n floor(a_index / u_particles_res) / u_particles_res)\n );\n\n // decode current particle position from the pixel's RGBA value\n v_particle_pos = vec2( color.r / 255.0 + color.b, color.g / 255.0 + color.a);\n\n gl_PointSize = 1.0;\n gl_Position = vec4(2.0 * v_particle_pos.x - 1.0, 1.0 - 2.0 * v_particle_pos.y, 0, 1);\n }";
|
|
8
|
+
export declare const drawFrag = "\n precision mediump float;\n\n uniform sampler2D u_wind;\n uniform vec2 u_wind_min;\n uniform vec2 u_wind_max;\n uniform sampler2D u_color_ramp;\n\n varying vec2 v_particle_pos;\n\n void main() {\n vec2 velocity = mix(u_wind_min, u_wind_max, texture2D(u_wind, v_particle_pos).rg);\n float speed_t = length(velocity) / length(u_wind_max);\n\n // color ramp is encoded in a 16x16 texture\n vec2 ramp_pos = vec2( fract(16.0 * speed_t), floor(16.0 * speed_t) / 16.0);\n\n gl_FragColor = texture2D(u_color_ramp, ramp_pos);\n }";
|
|
9
|
+
export declare const updateVert = "\n precision mediump float;\n\n attribute vec2 a_pos;\n\n varying vec2 v_tex_pos;\n\n void main() {\n v_tex_pos = a_pos;\n gl_Position = vec4(1.0 - 2.0 * a_pos, 0, 1);\n // framebuffer \u59CB\u7EC8\u7528\u94FA\u6EE1\u5C4F\u5E55\u7684 texture\n }";
|
|
10
|
+
export declare const updateFrag = "\n precision highp float;\n\n uniform sampler2D u_particles;\n uniform sampler2D u_wind;\n uniform vec2 u_wind_res;\n uniform vec2 u_wind_min;\n uniform vec2 u_wind_max;\n uniform float u_rand_seed;\n uniform float u_speed_factor;\n uniform float u_drop_rate;\n uniform float u_drop_rate_bump;\n\n varying vec2 v_tex_pos;\n\n // pseudo-random generator\n const vec3 rand_constants = vec3(12.9898, 78.233, 4375.85453);\n float rand(const vec2 co) {\n float t = dot(rand_constants.xy, co);\n return fract(sin(t) * (rand_constants.z + t));\n }\n\n // wind speed lookup; use manual bilinear filtering based on 4 adjacent pixels for smooth interpolation\n vec2 lookup_wind(const vec2 uv) {\n // return texture2D(u_wind, uv).rg; // lower-res hardware filtering\n vec2 px = 1.0 / u_wind_res;\n vec2 vc = (floor(uv * u_wind_res)) * px;\n vec2 f = fract(uv * u_wind_res);\n vec2 tl = texture2D(u_wind, vc).rg;\n vec2 tr = texture2D(u_wind, vc + vec2(px.x, 0)).rg;\n vec2 bl = texture2D(u_wind, vc + vec2(0, px.y)).rg;\n vec2 br = texture2D(u_wind, vc + px).rg;\n return mix(mix(tl, tr, f.x), mix(bl, br, f.x), f.y);\n }\n\n void main() {\n vec4 color = texture2D(u_particles, v_tex_pos);\n vec2 pos = vec2(\n color.r / 255.0 + color.b,\n color.g / 255.0 + color.a); // decode particle position from pixel RGBA\n vec2 velocity = mix(u_wind_min, u_wind_max, lookup_wind(pos));\n float speed_t = length(velocity) / length(u_wind_max);\n\n // take EPSG:4236 distortion into account for calculating where the particle moved\n float distortion = cos(radians(pos.y * 180.0 - 90.0));\n vec2 offset = vec2(velocity.x / distortion, -velocity.y) * 0.0001 * u_speed_factor;\n\n // update particle position, wrapping around the date line\n pos = fract(1.0 + pos + offset);\n\n // a random seed to use for the particle drop\n vec2 seed = (pos + v_tex_pos) * u_rand_seed;\n\n // drop rate is a chance a particle will restart at random position, to avoid degeneration\n float drop_rate = u_drop_rate + speed_t * u_drop_rate_bump;\n float drop = step(1.0 - drop_rate, rand(seed));\n\n vec2 random_pos = vec2(\n rand(seed + 1.3),\n rand(seed + 2.1));\n pos = mix(pos, random_pos, drop);\n\n // encode the new particle position back into RGBA\n gl_FragColor = vec4(\n fract(pos * 255.0),\n floor(pos * 255.0) / 255.0);\n }";
|
|
11
|
+
export declare const fullScreenVert = "\n precision mediump float;\n\n attribute vec2 a_pos;\n\n varying vec2 v_tex_pos;\n\n void main() {\n v_tex_pos = a_pos;\n gl_Position = vec4(1.0 - 2.0 * a_pos, 0.0, 1.0);\n gl_PointSize = 100.0;\n }";
|
|
12
|
+
export declare const fullScreenFrag = "\n precision mediump float;\n\n uniform sampler2D u_screen;\n uniform float u_opacity;\n varying vec2 v_tex_pos;\n\n void main() {\n vec4 color = texture2D(u_screen, 1.0 - v_tex_pos);\n\n // a hack to guarantee opacity fade out even with a value close to 1.0\n gl_FragColor = vec4(floor(255.0 * color * u_opacity) / 255.0);\n }";
|