@scoova/mgl 1.0.0
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/LICENSE.txt +116 -0
- package/README.md +174 -0
- package/build/banner.ts +12 -0
- package/build/bump-version-changelog.js +26 -0
- package/build/check-bundle-size.js +77 -0
- package/build/generate-dist-package.js +26 -0
- package/build/generate-doc-images.ts +78 -0
- package/build/generate-docs.ts +190 -0
- package/build/generate-shaders.ts +68 -0
- package/build/generate-struct-arrays.ts +438 -0
- package/build/generate-style-code.ts +283 -0
- package/build/readme.md +56 -0
- package/build/release-notes.js +45 -0
- package/build/rollup/bundle_prelude.js +29 -0
- package/build/rollup/maplibregl.js +22 -0
- package/build/rollup_plugins.ts +58 -0
- package/dist/LICENSE.txt +116 -0
- package/dist/maplibre-gl.css +1 -0
- package/dist/maplibre-gl.d.ts +13304 -0
- package/dist/maplibre-gl.js +59 -0
- package/dist/maplibre-gl.js.map +1 -0
- package/dist/package.json +1 -0
- package/package.json +192 -0
- package/src/css/maplibre-gl.css +854 -0
- package/src/css/svg/maplibregl-ctrl-attrib.svg +3 -0
- package/src/css/svg/maplibregl-ctrl-compass.svg +4 -0
- package/src/css/svg/maplibregl-ctrl-fullscreen.svg +3 -0
- package/src/css/svg/maplibregl-ctrl-geolocate.svg +5 -0
- package/src/css/svg/maplibregl-ctrl-logo.svg +11 -0
- package/src/css/svg/maplibregl-ctrl-shrink.svg +3 -0
- package/src/css/svg/maplibregl-ctrl-terrain.svg +3 -0
- package/src/css/svg/maplibregl-ctrl-zoom-in.svg +3 -0
- package/src/css/svg/maplibregl-ctrl-zoom-out.svg +3 -0
- package/src/data/array_types.g.ts +1130 -0
- package/src/data/bucket/circle_attributes.ts +8 -0
- package/src/data/bucket/circle_bucket.ts +197 -0
- package/src/data/bucket/fill_attributes.ts +8 -0
- package/src/data/bucket/fill_bucket.test.ts +95 -0
- package/src/data/bucket/fill_bucket.ts +228 -0
- package/src/data/bucket/fill_extrusion_attributes.ts +13 -0
- package/src/data/bucket/fill_extrusion_bucket.ts +305 -0
- package/src/data/bucket/heatmap_bucket.ts +12 -0
- package/src/data/bucket/line_attributes.ts +8 -0
- package/src/data/bucket/line_attributes_ext.ts +8 -0
- package/src/data/bucket/line_bucket.test.ts +142 -0
- package/src/data/bucket/line_bucket.ts +592 -0
- package/src/data/bucket/pattern_attributes.ts +9 -0
- package/src/data/bucket/pattern_bucket_features.ts +57 -0
- package/src/data/bucket/symbol_attributes.ts +122 -0
- package/src/data/bucket/symbol_bucket.test.ts +243 -0
- package/src/data/bucket/symbol_bucket.ts +975 -0
- package/src/data/bucket.ts +123 -0
- package/src/data/dem_data.test.ts +237 -0
- package/src/data/dem_data.ts +171 -0
- package/src/data/evaluation_feature.ts +18 -0
- package/src/data/extent.ts +13 -0
- package/src/data/feature_index.ts +337 -0
- package/src/data/feature_position_map.test.ts +33 -0
- package/src/data/feature_position_map.ts +126 -0
- package/src/data/index_array_type.ts +9 -0
- package/src/data/load_geometry.test.ts +49 -0
- package/src/data/load_geometry.ts +44 -0
- package/src/data/pos3d_attributes.ts +5 -0
- package/src/data/pos_attributes.ts +5 -0
- package/src/data/program_configuration.ts +735 -0
- package/src/data/raster_bounds_attributes.ts +6 -0
- package/src/data/segment.ts +89 -0
- package/src/geo/edge_insets.test.ts +83 -0
- package/src/geo/edge_insets.ts +146 -0
- package/src/geo/lng_lat.test.ts +65 -0
- package/src/geo/lng_lat.ts +169 -0
- package/src/geo/lng_lat_bounds.test.ts +357 -0
- package/src/geo/lng_lat_bounds.ts +356 -0
- package/src/geo/mercator_coordinate.test.ts +34 -0
- package/src/geo/mercator_coordinate.ts +157 -0
- package/src/geo/projection/projection.ts +72 -0
- package/src/geo/transform.test.ts +509 -0
- package/src/geo/transform.ts +1072 -0
- package/src/gl/color_mode.ts +31 -0
- package/src/gl/context.ts +321 -0
- package/src/gl/cull_face_mode.ts +22 -0
- package/src/gl/depth_mode.ts +26 -0
- package/src/gl/framebuffer.ts +48 -0
- package/src/gl/index_buffer.ts +55 -0
- package/src/gl/render_pool.test.ts +69 -0
- package/src/gl/render_pool.ts +93 -0
- package/src/gl/state.test.ts +125 -0
- package/src/gl/stencil_mode.ts +27 -0
- package/src/gl/types.ts +59 -0
- package/src/gl/value.ts +534 -0
- package/src/gl/vertex_buffer.test.ts +57 -0
- package/src/gl/vertex_buffer.ts +111 -0
- package/src/gl/webgl2.ts +12 -0
- package/src/index.test.ts +121 -0
- package/src/index.ts +250 -0
- package/src/render/draw_background.ts +53 -0
- package/src/render/draw_circle.ts +113 -0
- package/src/render/draw_collision_debug.ts +168 -0
- package/src/render/draw_custom.test.ts +73 -0
- package/src/render/draw_custom.ts +45 -0
- package/src/render/draw_debug.test.ts +122 -0
- package/src/render/draw_debug.ts +148 -0
- package/src/render/draw_fill.test.ts +137 -0
- package/src/render/draw_fill.ts +128 -0
- package/src/render/draw_fill_extrusion.ts +97 -0
- package/src/render/draw_heatmap.ts +228 -0
- package/src/render/draw_hillshade.ts +119 -0
- package/src/render/draw_line.ts +125 -0
- package/src/render/draw_raster.ts +133 -0
- package/src/render/draw_sky.ts +44 -0
- package/src/render/draw_symbol.test.ts +223 -0
- package/src/render/draw_symbol.ts +499 -0
- package/src/render/draw_terrain.ts +99 -0
- package/src/render/glyph_atlas.ts +83 -0
- package/src/render/glyph_manager.test.ts +147 -0
- package/src/render/glyph_manager.ts +198 -0
- package/src/render/image_atlas.ts +159 -0
- package/src/render/image_manager.ts +337 -0
- package/src/render/line_atlas.test.ts +38 -0
- package/src/render/line_atlas.ts +214 -0
- package/src/render/mesh.ts +25 -0
- package/src/render/painter.test.ts +51 -0
- package/src/render/painter.ts +666 -0
- package/src/render/program/background_program.ts +100 -0
- package/src/render/program/circle_program.ts +61 -0
- package/src/render/program/clipping_mask_program.ts +19 -0
- package/src/render/program/collision_program.ts +47 -0
- package/src/render/program/debug_program.ts +29 -0
- package/src/render/program/fill_extrusion_program.ts +120 -0
- package/src/render/program/fill_program.ts +121 -0
- package/src/render/program/heatmap_program.ts +76 -0
- package/src/render/program/hillshade_program.ts +116 -0
- package/src/render/program/line_program.ts +207 -0
- package/src/render/program/pattern.ts +102 -0
- package/src/render/program/program_uniforms.ts +46 -0
- package/src/render/program/raster_program.ts +88 -0
- package/src/render/program/sky_program.ts +28 -0
- package/src/render/program/symbol_program.ts +266 -0
- package/src/render/program/terrain_program.ts +116 -0
- package/src/render/program.ts +233 -0
- package/src/render/render_to_texture.test.ts +151 -0
- package/src/render/render_to_texture.ts +197 -0
- package/src/render/terrain.test.ts +322 -0
- package/src/render/terrain.ts +464 -0
- package/src/render/texture.ts +114 -0
- package/src/render/uniform_binding.test.ts +122 -0
- package/src/render/uniform_binding.ts +157 -0
- package/src/render/update_pattern_positions_in_program.test.ts +74 -0
- package/src/render/update_pattern_positions_in_program.ts +50 -0
- package/src/render/vertex_array_object.ts +163 -0
- package/src/shaders/README.md +42 -0
- package/src/shaders/_prelude.fragment.glsl +19 -0
- package/src/shaders/_prelude.fragment.glsl.g.ts +2 -0
- package/src/shaders/_prelude.vertex.glsl +148 -0
- package/src/shaders/_prelude.vertex.glsl.g.ts +2 -0
- package/src/shaders/background.fragment.glsl +10 -0
- package/src/shaders/background.fragment.glsl.g.ts +2 -0
- package/src/shaders/background.vertex.glsl +7 -0
- package/src/shaders/background.vertex.glsl.g.ts +2 -0
- package/src/shaders/background_pattern.fragment.glsl +28 -0
- package/src/shaders/background_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/background_pattern.vertex.glsl +19 -0
- package/src/shaders/background_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/circle.fragment.glsl +34 -0
- package/src/shaders/circle.fragment.glsl.g.ts +2 -0
- package/src/shaders/circle.vertex.glsl +68 -0
- package/src/shaders/circle.vertex.glsl.g.ts +2 -0
- package/src/shaders/clipping_mask.fragment.glsl +3 -0
- package/src/shaders/clipping_mask.fragment.glsl.g.ts +2 -0
- package/src/shaders/clipping_mask.vertex.glsl +7 -0
- package/src/shaders/clipping_mask.vertex.glsl.g.ts +2 -0
- package/src/shaders/collision_box.fragment.glsl +20 -0
- package/src/shaders/collision_box.fragment.glsl.g.ts +2 -0
- package/src/shaders/collision_box.vertex.glsl +27 -0
- package/src/shaders/collision_box.vertex.glsl.g.ts +2 -0
- package/src/shaders/collision_circle.fragment.glsl +17 -0
- package/src/shaders/collision_circle.fragment.glsl.g.ts +2 -0
- package/src/shaders/collision_circle.vertex.glsl +59 -0
- package/src/shaders/collision_circle.vertex.glsl.g.ts +2 -0
- package/src/shaders/debug.fragment.glsl +9 -0
- package/src/shaders/debug.fragment.glsl.g.ts +2 -0
- package/src/shaders/debug.vertex.glsl +12 -0
- package/src/shaders/debug.vertex.glsl.g.ts +2 -0
- package/src/shaders/encode_attribute.test.ts +11 -0
- package/src/shaders/encode_attribute.ts +13 -0
- package/src/shaders/fill.fragment.glsl +13 -0
- package/src/shaders/fill.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill.vertex.glsl +13 -0
- package/src/shaders/fill.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion.fragment.glsl +9 -0
- package/src/shaders/fill_extrusion.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion.vertex.glsl +84 -0
- package/src/shaders/fill_extrusion.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion_pattern.fragment.glsl +47 -0
- package/src/shaders/fill_extrusion_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion_pattern.vertex.glsl +96 -0
- package/src/shaders/fill_extrusion_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_outline.fragment.glsl +17 -0
- package/src/shaders/fill_outline.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_outline.vertex.glsl +17 -0
- package/src/shaders/fill_outline.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_outline_pattern.fragment.glsl +43 -0
- package/src/shaders/fill_outline_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_outline_pattern.vertex.glsl +44 -0
- package/src/shaders/fill_outline_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_pattern.fragment.glsl +39 -0
- package/src/shaders/fill_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_pattern.vertex.glsl +39 -0
- package/src/shaders/fill_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/heatmap.fragment.glsl +22 -0
- package/src/shaders/heatmap.fragment.glsl.g.ts +2 -0
- package/src/shaders/heatmap.vertex.glsl +54 -0
- package/src/shaders/heatmap.vertex.glsl.g.ts +2 -0
- package/src/shaders/heatmap_texture.fragment.glsl +15 -0
- package/src/shaders/heatmap_texture.fragment.glsl.g.ts +2 -0
- package/src/shaders/heatmap_texture.vertex.glsl +11 -0
- package/src/shaders/heatmap_texture.vertex.glsl.g.ts +2 -0
- package/src/shaders/hillshade.fragment.glsl +52 -0
- package/src/shaders/hillshade.fragment.glsl.g.ts +2 -0
- package/src/shaders/hillshade.vertex.glsl +11 -0
- package/src/shaders/hillshade.vertex.glsl.g.ts +2 -0
- package/src/shaders/hillshade_prepare.fragment.glsl +77 -0
- package/src/shaders/hillshade_prepare.fragment.glsl.g.ts +2 -0
- package/src/shaders/hillshade_prepare.vertex.glsl +15 -0
- package/src/shaders/hillshade_prepare.vertex.glsl.g.ts +2 -0
- package/src/shaders/line.fragment.glsl +30 -0
- package/src/shaders/line.fragment.glsl.g.ts +2 -0
- package/src/shaders/line.vertex.glsl +89 -0
- package/src/shaders/line.vertex.glsl.g.ts +2 -0
- package/src/shaders/line_gradient.fragment.glsl +34 -0
- package/src/shaders/line_gradient.fragment.glsl.g.ts +2 -0
- package/src/shaders/line_gradient.vertex.glsl +92 -0
- package/src/shaders/line_gradient.vertex.glsl.g.ts +2 -0
- package/src/shaders/line_pattern.fragment.glsl +77 -0
- package/src/shaders/line_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/line_pattern.vertex.glsl +103 -0
- package/src/shaders/line_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/line_sdf.fragment.glsl +45 -0
- package/src/shaders/line_sdf.fragment.glsl.g.ts +2 -0
- package/src/shaders/line_sdf.vertex.glsl +101 -0
- package/src/shaders/line_sdf.vertex.glsl.g.ts +2 -0
- package/src/shaders/raster.fragment.glsl +53 -0
- package/src/shaders/raster.fragment.glsl.g.ts +2 -0
- package/src/shaders/raster.vertex.glsl +21 -0
- package/src/shaders/raster.vertex.glsl.g.ts +2 -0
- package/src/shaders/shaders.ts +197 -0
- package/src/shaders/sky.fragment.glsl +17 -0
- package/src/shaders/sky.fragment.glsl.g.ts +2 -0
- package/src/shaders/sky.vertex.glsl +5 -0
- package/src/shaders/sky.vertex.glsl.g.ts +2 -0
- package/src/shaders/symbol_icon.fragment.glsl +17 -0
- package/src/shaders/symbol_icon.fragment.glsl.g.ts +2 -0
- package/src/shaders/symbol_icon.vertex.glsl +117 -0
- package/src/shaders/symbol_icon.vertex.glsl.g.ts +2 -0
- package/src/shaders/symbol_sdf.fragment.glsl +58 -0
- package/src/shaders/symbol_sdf.fragment.glsl.g.ts +2 -0
- package/src/shaders/symbol_sdf.vertex.glsl +142 -0
- package/src/shaders/symbol_sdf.vertex.glsl.g.ts +2 -0
- package/src/shaders/symbol_text_and_icon.fragment.glsl +68 -0
- package/src/shaders/symbol_text_and_icon.fragment.glsl.g.ts +2 -0
- package/src/shaders/symbol_text_and_icon.vertex.glsl +140 -0
- package/src/shaders/symbol_text_and_icon.vertex.glsl.g.ts +2 -0
- package/src/shaders/terrain.fragment.glsl +32 -0
- package/src/shaders/terrain.fragment.glsl.g.ts +2 -0
- package/src/shaders/terrain.vertex.glsl +17 -0
- package/src/shaders/terrain.vertex.glsl.g.ts +2 -0
- package/src/shaders/terrain_coords.fragment.glsl +11 -0
- package/src/shaders/terrain_coords.fragment.glsl.g.ts +2 -0
- package/src/shaders/terrain_coords.vertex.glsl +13 -0
- package/src/shaders/terrain_coords.vertex.glsl.g.ts +2 -0
- package/src/shaders/terrain_depth.fragment.glsl +15 -0
- package/src/shaders/terrain_depth.fragment.glsl.g.ts +2 -0
- package/src/shaders/terrain_depth.vertex.glsl +13 -0
- package/src/shaders/terrain_depth.vertex.glsl.g.ts +2 -0
- package/src/source/canvas_source.test.ts +210 -0
- package/src/source/canvas_source.ts +227 -0
- package/src/source/geojson_source.test.ts +492 -0
- package/src/source/geojson_source.ts +431 -0
- package/src/source/geojson_source_diff.test.ts +364 -0
- package/src/source/geojson_source_diff.ts +172 -0
- package/src/source/geojson_worker_source.test.ts +399 -0
- package/src/source/geojson_worker_source.ts +303 -0
- package/src/source/geojson_wrapper.test.ts +32 -0
- package/src/source/geojson_wrapper.ts +81 -0
- package/src/source/image_source.test.ts +235 -0
- package/src/source/image_source.ts +338 -0
- package/src/source/load_tilejson.ts +47 -0
- package/src/source/pixels_to_tile_units.ts +25 -0
- package/src/source/protocol_crud.ts +48 -0
- package/src/source/query_features.test.ts +31 -0
- package/src/source/query_features.ts +252 -0
- package/src/source/raster_dem_tile_source.test.ts +158 -0
- package/src/source/raster_dem_tile_source.ts +166 -0
- package/src/source/raster_dem_tile_worker_source.test.ts +36 -0
- package/src/source/raster_dem_tile_worker_source.ts +38 -0
- package/src/source/raster_tile_source.test.ts +206 -0
- package/src/source/raster_tile_source.ts +227 -0
- package/src/source/rtl_text_plugin_main_thread.test.ts +170 -0
- package/src/source/rtl_text_plugin_main_thread.ts +89 -0
- package/src/source/rtl_text_plugin_status.ts +33 -0
- package/src/source/rtl_text_plugin_worker.ts +49 -0
- package/src/source/source.test.ts +41 -0
- package/src/source/source.ts +186 -0
- package/src/source/source_cache.test.ts +2069 -0
- package/src/source/source_cache.ts +1102 -0
- package/src/source/source_state.ts +157 -0
- package/src/source/terrain_source_cache.test.ts +105 -0
- package/src/source/terrain_source_cache.ts +204 -0
- package/src/source/tile.test.ts +290 -0
- package/src/source/tile.ts +478 -0
- package/src/source/tile_bounds.ts +34 -0
- package/src/source/tile_cache.test.ts +130 -0
- package/src/source/tile_cache.ts +208 -0
- package/src/source/tile_id.test.ts +112 -0
- package/src/source/tile_id.ts +221 -0
- package/src/source/vector_tile_source.test.ts +401 -0
- package/src/source/vector_tile_source.ts +283 -0
- package/src/source/vector_tile_worker_source.test.ts +396 -0
- package/src/source/vector_tile_worker_source.ts +199 -0
- package/src/source/video_source.test.ts +124 -0
- package/src/source/video_source.ts +204 -0
- package/src/source/worker.test.ts +233 -0
- package/src/source/worker.ts +301 -0
- package/src/source/worker_source.ts +117 -0
- package/src/source/worker_tile.test.ts +226 -0
- package/src/source/worker_tile.ts +208 -0
- package/src/style/create_style_layer.ts +39 -0
- package/src/style/evaluation_parameters.ts +62 -0
- package/src/style/format_section_override.test.ts +62 -0
- package/src/style/format_section_override.ts +50 -0
- package/src/style/light.test.ts +86 -0
- package/src/style/light.ts +135 -0
- package/src/style/load_glyph_range.test.ts +40 -0
- package/src/style/load_glyph_range.ts +32 -0
- package/src/style/load_sprite.test.ts +227 -0
- package/src/style/load_sprite.ts +71 -0
- package/src/style/parse_glyph_pbf.ts +42 -0
- package/src/style/pauseable_placement.ts +138 -0
- package/src/style/properties.ts +726 -0
- package/src/style/query_utils.test.ts +107 -0
- package/src/style/query_utils.ts +70 -0
- package/src/style/sky.ts +127 -0
- package/src/style/style.test.ts +2654 -0
- package/src/style/style.ts +1814 -0
- package/src/style/style_glyph.ts +25 -0
- package/src/style/style_image.ts +188 -0
- package/src/style/style_layer/background_style_layer.ts +17 -0
- package/src/style/style_layer/background_style_layer_properties.g.ts +40 -0
- package/src/style/style_layer/circle_style_layer.ts +98 -0
- package/src/style/style_layer/circle_style_layer_properties.g.ts +76 -0
- package/src/style/style_layer/custom_style_layer.ts +233 -0
- package/src/style/style_layer/fill_extrusion_style_layer.ts +224 -0
- package/src/style/style_layer/fill_extrusion_style_layer_properties.g.ts +55 -0
- package/src/style/style_layer/fill_style_layer.test.ts +37 -0
- package/src/style/style_layer/fill_style_layer.ts +65 -0
- package/src/style/style_layer/fill_style_layer_properties.g.ts +64 -0
- package/src/style/style_layer/heatmap_style_layer.ts +74 -0
- package/src/style/style_layer/heatmap_style_layer_properties.g.ts +46 -0
- package/src/style/style_layer/hillshade_style_layer.ts +21 -0
- package/src/style/style_layer/hillshade_style_layer_properties.g.ts +49 -0
- package/src/style/style_layer/line_style_layer.test.ts +50 -0
- package/src/style/style_layer/line_style_layer.ts +131 -0
- package/src/style/style_layer/line_style_layer_properties.g.ts +88 -0
- package/src/style/style_layer/overlap_mode.test.ts +57 -0
- package/src/style/style_layer/overlap_mode.ts +25 -0
- package/src/style/style_layer/raster_style_layer.ts +17 -0
- package/src/style/style_layer/raster_style_layer_properties.g.ts +55 -0
- package/src/style/style_layer/symbol_style_layer.ts +195 -0
- package/src/style/style_layer/symbol_style_layer_properties.g.ts +218 -0
- package/src/style/style_layer/typed_style_layer.ts +9 -0
- package/src/style/style_layer/variable_text_anchor.test.ts +117 -0
- package/src/style/style_layer/variable_text_anchor.ts +163 -0
- package/src/style/style_layer.test.ts +372 -0
- package/src/style/style_layer.ts +287 -0
- package/src/style/style_layer_index.test.ts +99 -0
- package/src/style/style_layer_index.ts +78 -0
- package/src/style/validate_style.ts +53 -0
- package/src/style/zoom_history.ts +40 -0
- package/src/symbol/anchor.test.ts +14 -0
- package/src/symbol/anchor.ts +22 -0
- package/src/symbol/check_max_angle.test.ts +54 -0
- package/src/symbol/check_max_angle.ts +76 -0
- package/src/symbol/clip_line.test.ts +154 -0
- package/src/symbol/clip_line.ts +66 -0
- package/src/symbol/collision_feature.test.ts +98 -0
- package/src/symbol/collision_feature.ts +114 -0
- package/src/symbol/collision_index.test.ts +19 -0
- package/src/symbol/collision_index.ts +618 -0
- package/src/symbol/cross_tile_symbol_index.test.ts +260 -0
- package/src/symbol/cross_tile_symbol_index.ts +367 -0
- package/src/symbol/get_anchors.test.ts +113 -0
- package/src/symbol/get_anchors.ts +167 -0
- package/src/symbol/grid_index.test.ts +75 -0
- package/src/symbol/grid_index.ts +414 -0
- package/src/symbol/merge_lines.test.ts +30 -0
- package/src/symbol/merge_lines.ts +80 -0
- package/src/symbol/one_em.ts +3 -0
- package/src/symbol/opacity_state.ts +23 -0
- package/src/symbol/path_interpolator.test.ts +134 -0
- package/src/symbol/path_interpolator.ts +55 -0
- package/src/symbol/placement.ts +1371 -0
- package/src/symbol/projection.test.ts +171 -0
- package/src/symbol/projection.ts +833 -0
- package/src/symbol/quads.test.ts +157 -0
- package/src/symbol/quads.ts +349 -0
- package/src/symbol/shaping.test.ts +360 -0
- package/src/symbol/shaping.ts +911 -0
- package/src/symbol/symbol_layout.ts +739 -0
- package/src/symbol/symbol_size.ts +129 -0
- package/src/symbol/symbol_style_layer.test.ts +103 -0
- package/src/symbol/transform_text.ts +27 -0
- package/src/ui/anchor.ts +27 -0
- package/src/ui/camera.test.ts +2301 -0
- package/src/ui/camera.ts +1520 -0
- package/src/ui/control/attribution_control.test.ts +543 -0
- package/src/ui/control/attribution_control.ts +209 -0
- package/src/ui/control/control.ts +67 -0
- package/src/ui/control/fullscreen_control.test.ts +114 -0
- package/src/ui/control/fullscreen_control.ts +189 -0
- package/src/ui/control/geolocate_control.test.ts +619 -0
- package/src/ui/control/geolocate_control.ts +725 -0
- package/src/ui/control/logo_control.test.ts +88 -0
- package/src/ui/control/logo_control.ts +86 -0
- package/src/ui/control/navigation_control.test.ts +238 -0
- package/src/ui/control/navigation_control.ts +294 -0
- package/src/ui/control/scale_control.test.ts +52 -0
- package/src/ui/control/scale_control.ts +152 -0
- package/src/ui/control/terrain_control.test.ts +58 -0
- package/src/ui/control/terrain_control.ts +74 -0
- package/src/ui/default_locale.ts +25 -0
- package/src/ui/events.ts +758 -0
- package/src/ui/handler/box_zoom.test.ts +163 -0
- package/src/ui/handler/box_zoom.ts +171 -0
- package/src/ui/handler/click_zoom.ts +55 -0
- package/src/ui/handler/cooperative_gestures.test.ts +338 -0
- package/src/ui/handler/cooperative_gestures.ts +111 -0
- package/src/ui/handler/dblclick_zoom.test.ts +151 -0
- package/src/ui/handler/drag_handler.ts +174 -0
- package/src/ui/handler/drag_move_state_manager.ts +115 -0
- package/src/ui/handler/drag_pan.test.ts +487 -0
- package/src/ui/handler/drag_rotate.test.ts +859 -0
- package/src/ui/handler/handler_util.ts +10 -0
- package/src/ui/handler/keyboard.test.ts +235 -0
- package/src/ui/handler/keyboard.ts +212 -0
- package/src/ui/handler/map_event.test.ts +158 -0
- package/src/ui/handler/map_event.ts +161 -0
- package/src/ui/handler/mouse.ts +92 -0
- package/src/ui/handler/mouse_handler_interface.test.ts +111 -0
- package/src/ui/handler/mouse_rotate.test.ts +62 -0
- package/src/ui/handler/one_finger_touch_drag.ts +45 -0
- package/src/ui/handler/one_finger_touch_drag_handler_interface.test.ts +77 -0
- package/src/ui/handler/scroll_zoom.test.ts +382 -0
- package/src/ui/handler/scroll_zoom.ts +379 -0
- package/src/ui/handler/shim/dblclick_zoom.ts +64 -0
- package/src/ui/handler/shim/drag_pan.ts +104 -0
- package/src/ui/handler/shim/drag_rotate.ts +76 -0
- package/src/ui/handler/shim/two_fingers_touch.ts +112 -0
- package/src/ui/handler/tap_drag_zoom.test.ts +113 -0
- package/src/ui/handler/tap_drag_zoom.ts +112 -0
- package/src/ui/handler/tap_recognizer.ts +138 -0
- package/src/ui/handler/tap_zoom.ts +98 -0
- package/src/ui/handler/touch_pan.ts +115 -0
- package/src/ui/handler/transform-provider.ts +44 -0
- package/src/ui/handler/two_fingers_touch.test.ts +283 -0
- package/src/ui/handler/two_fingers_touch.ts +336 -0
- package/src/ui/handler_inertia.ts +157 -0
- package/src/ui/handler_manager.ts +637 -0
- package/src/ui/hash.test.ts +404 -0
- package/src/ui/hash.ts +153 -0
- package/src/ui/map.ts +3393 -0
- package/src/ui/map_tests/map_animation.test.ts +61 -0
- package/src/ui/map_tests/map_basic.test.ts +223 -0
- package/src/ui/map_tests/map_bounds.test.ts +123 -0
- package/src/ui/map_tests/map_calculate_camera_options.test.ts +113 -0
- package/src/ui/map_tests/map_canvas.test.ts +59 -0
- package/src/ui/map_tests/map_control.test.ts +61 -0
- package/src/ui/map_tests/map_disable_handlers.test.ts +38 -0
- package/src/ui/map_tests/map_events.test.ts +1001 -0
- package/src/ui/map_tests/map_feature_state.test.ts +421 -0
- package/src/ui/map_tests/map_images.test.ts +175 -0
- package/src/ui/map_tests/map_is_moving.test.ts +164 -0
- package/src/ui/map_tests/map_is_rotating.test.ts +62 -0
- package/src/ui/map_tests/map_is_zooming.test.ts +86 -0
- package/src/ui/map_tests/map_layer.test.ts +457 -0
- package/src/ui/map_tests/map_options.test.ts +64 -0
- package/src/ui/map_tests/map_pitch.test.ts +90 -0
- package/src/ui/map_tests/map_pixel_ratio.test.ts +75 -0
- package/src/ui/map_tests/map_query_rendered_features.test.ts +93 -0
- package/src/ui/map_tests/map_render.test.ts +90 -0
- package/src/ui/map_tests/map_request_render_frame.test.ts +51 -0
- package/src/ui/map_tests/map_resize.test.ts +120 -0
- package/src/ui/map_tests/map_style.test.ts +541 -0
- package/src/ui/map_tests/map_terrian.test.ts +104 -0
- package/src/ui/map_tests/map_webgl.test.ts +72 -0
- package/src/ui/map_tests/map_world_copies.test.ts +103 -0
- package/src/ui/map_tests/map_zoom.test.ts +95 -0
- package/src/ui/marker.test.ts +1149 -0
- package/src/ui/marker.ts +880 -0
- package/src/ui/popup.test.ts +827 -0
- package/src/ui/popup.ts +717 -0
- package/src/util/abort_error.ts +21 -0
- package/src/util/actor.test.ts +218 -0
- package/src/util/actor.ts +241 -0
- package/src/util/actor_messages.ts +149 -0
- package/src/util/ajax.test.ts +237 -0
- package/src/util/ajax.ts +297 -0
- package/src/util/browser.test.ts +23 -0
- package/src/util/browser.ts +63 -0
- package/src/util/color_ramp.test.ts +105 -0
- package/src/util/color_ramp.ts +56 -0
- package/src/util/config.ts +29 -0
- package/src/util/dictionary_coder.ts +23 -0
- package/src/util/dispatcher.test.ts +76 -0
- package/src/util/dispatcher.ts +78 -0
- package/src/util/dom.ts +135 -0
- package/src/util/evented.test.ts +231 -0
- package/src/util/evented.ts +178 -0
- package/src/util/find_pole_of_inaccessibility.test.ts +21 -0
- package/src/util/find_pole_of_inaccessibility.ts +130 -0
- package/src/util/geolocation_support.test.ts +43 -0
- package/src/util/geolocation_support.ts +23 -0
- package/src/util/global_worker_pool.ts +65 -0
- package/src/util/image.ts +150 -0
- package/src/util/image_request.test.ts +408 -0
- package/src/util/image_request.ts +246 -0
- package/src/util/intersection_tests.ts +206 -0
- package/src/util/is_char_in_unicode_block.test.ts +15 -0
- package/src/util/is_char_in_unicode_block.ts +345 -0
- package/src/util/offscreen_canvas_distorted.test.ts +13 -0
- package/src/util/offscreen_canvas_distorted.ts +39 -0
- package/src/util/offscreen_canvas_supported.ts +11 -0
- package/src/util/performance.ts +117 -0
- package/src/util/primitives.test.ts +140 -0
- package/src/util/primitives.ts +143 -0
- package/src/util/request_manager.ts +42 -0
- package/src/util/resolve_tokens.test.ts +45 -0
- package/src/util/resolve_tokens.ts +17 -0
- package/src/util/script_detection.test.ts +138 -0
- package/src/util/script_detection.ts +376 -0
- package/src/util/smart_wrap.test.ts +97 -0
- package/src/util/smart_wrap.ts +58 -0
- package/src/util/struct_array.test.ts +101 -0
- package/src/util/struct_array.ts +246 -0
- package/src/util/style.test.ts +34 -0
- package/src/util/style.ts +28 -0
- package/src/util/task_queue.test.ts +114 -0
- package/src/util/task_queue.ts +64 -0
- package/src/util/test/util.ts +185 -0
- package/src/util/throttle.test.ts +42 -0
- package/src/util/throttle.ts +28 -0
- package/src/util/throttled_invoker.ts +41 -0
- package/src/util/transferable_grid_index.test.ts +56 -0
- package/src/util/transferable_grid_index.ts +214 -0
- package/src/util/util.test.ts +414 -0
- package/src/util/util.ts +724 -0
- package/src/util/vectortile_to_geojson.ts +72 -0
- package/src/util/verticalize_punctuation.ts +110 -0
- package/src/util/web_worker.ts +16 -0
- package/src/util/web_worker_transfer.test.ts +153 -0
- package/src/util/web_worker_transfer.ts +254 -0
- package/src/util/webp_supported.ts +63 -0
- package/src/util/worker_pool.test.ts +43 -0
- package/src/util/worker_pool.ts +58 -0
- package/src/util/world_bounds.test.ts +59 -0
- package/src/util/world_bounds.ts +46 -0
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
|
|
2
|
+
import {Tile} from '../source/tile';
|
|
3
|
+
import {mat4, vec2} from 'gl-matrix';
|
|
4
|
+
import {OverscaledTileID} from '../source/tile_id';
|
|
5
|
+
import {RGBAImage} from '../util/image';
|
|
6
|
+
import {warnOnce} from '../util/util';
|
|
7
|
+
import {Pos3dArray, TriangleIndexArray} from '../data/array_types.g';
|
|
8
|
+
import pos3dAttributes from '../data/pos3d_attributes';
|
|
9
|
+
import {SegmentVector} from '../data/segment';
|
|
10
|
+
import {Painter} from './painter';
|
|
11
|
+
import {Texture} from '../render/texture';
|
|
12
|
+
import type {Framebuffer} from '../gl/framebuffer';
|
|
13
|
+
import Point from '@mapbox/point-geometry';
|
|
14
|
+
import {MercatorCoordinate} from '../geo/mercator_coordinate';
|
|
15
|
+
import {TerrainSourceCache} from '../source/terrain_source_cache';
|
|
16
|
+
import {SourceCache} from '../source/source_cache';
|
|
17
|
+
import {EXTENT} from '../data/extent';
|
|
18
|
+
import type {TerrainSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
19
|
+
import {LngLat, earthRadius} from '../geo/lng_lat';
|
|
20
|
+
import {Mesh} from './mesh';
|
|
21
|
+
import {isInBoundsForZoomLngLat} from '../util/world_bounds';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
* A terrain GPU related object
|
|
26
|
+
*/
|
|
27
|
+
export type TerrainData = {
|
|
28
|
+
'u_depth': number;
|
|
29
|
+
'u_terrain': number;
|
|
30
|
+
'u_terrain_dim': number;
|
|
31
|
+
'u_terrain_matrix': mat4;
|
|
32
|
+
'u_terrain_unpack': number[];
|
|
33
|
+
'u_terrain_exaggeration': number;
|
|
34
|
+
texture: WebGLTexture;
|
|
35
|
+
depthTexture: WebGLTexture;
|
|
36
|
+
tile: Tile;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @internal
|
|
41
|
+
* This is the main class which handles most of the 3D Terrain logic. It has the following topics:
|
|
42
|
+
*
|
|
43
|
+
* 1. loads raster-dem tiles via the internal sourceCache this.sourceCache
|
|
44
|
+
* 2. creates a depth-framebuffer, which is used to calculate the visibility of coordinates
|
|
45
|
+
* 3. creates a coords-framebuffer, which is used the get to tile-coordinate for a screen-pixel
|
|
46
|
+
* 4. stores all render-to-texture tiles in the this.sourceCache._tiles
|
|
47
|
+
* 5. calculates the elevation for a specific tile-coordinate
|
|
48
|
+
* 6. creates a terrain-mesh
|
|
49
|
+
*
|
|
50
|
+
* A note about the GPU resource-usage:
|
|
51
|
+
*
|
|
52
|
+
* Framebuffers:
|
|
53
|
+
*
|
|
54
|
+
* - one for the depth & coords framebuffer with the size of the map-div.
|
|
55
|
+
* - one for rendering a tile to texture with the size of tileSize (= 512x512).
|
|
56
|
+
*
|
|
57
|
+
* Textures:
|
|
58
|
+
*
|
|
59
|
+
* - one texture for an empty raster-dem tile with size 1x1
|
|
60
|
+
* - one texture for an empty depth-buffer, when terrain is disabled with size 1x1
|
|
61
|
+
* - one texture for an each loaded raster-dem with size of the source.tileSize
|
|
62
|
+
* - one texture for the coords-framebuffer with the size of the map-div.
|
|
63
|
+
* - one texture for the depth-framebuffer with the size of the map-div.
|
|
64
|
+
* - one texture for the encoded tile-coords with the size 2*tileSize (=1024x1024)
|
|
65
|
+
* - finally for each render-to-texture tile (= this._tiles) a set of textures
|
|
66
|
+
* for each render stack (The stack-concept is documented in painter.ts).
|
|
67
|
+
*
|
|
68
|
+
* Normally there exists 1-3 Textures per tile, depending on the stylesheet.
|
|
69
|
+
* Each Textures has the size 2*tileSize (= 1024x1024). Also there exists a
|
|
70
|
+
* cache of the last 150 newest rendered tiles.
|
|
71
|
+
*
|
|
72
|
+
*/
|
|
73
|
+
export class Terrain {
|
|
74
|
+
/**
|
|
75
|
+
* The style this terrain corresponds to
|
|
76
|
+
*/
|
|
77
|
+
painter: Painter;
|
|
78
|
+
/**
|
|
79
|
+
* the sourcecache this terrain is based on
|
|
80
|
+
*/
|
|
81
|
+
sourceCache: TerrainSourceCache;
|
|
82
|
+
/**
|
|
83
|
+
* the TerrainSpecification object passed to this instance
|
|
84
|
+
*/
|
|
85
|
+
options: TerrainSpecification;
|
|
86
|
+
/**
|
|
87
|
+
* define the meshSize per tile.
|
|
88
|
+
*/
|
|
89
|
+
meshSize: number;
|
|
90
|
+
/**
|
|
91
|
+
* multiplicator for the elevation. Used to make terrain more "extreme".
|
|
92
|
+
*/
|
|
93
|
+
exaggeration: number;
|
|
94
|
+
/**
|
|
95
|
+
* to not see pixels in the render-to-texture tiles it is good to render them bigger
|
|
96
|
+
* this number is the multiplicator (must be a power of 2) for the current tileSize.
|
|
97
|
+
* So to get good results with not too much memory footprint a value of 2 should be fine.
|
|
98
|
+
*/
|
|
99
|
+
qualityFactor: number;
|
|
100
|
+
/**
|
|
101
|
+
* holds the framebuffer object in size of the screen to render the coords & depth into a texture.
|
|
102
|
+
*/
|
|
103
|
+
_fbo: Framebuffer;
|
|
104
|
+
_fboCoordsTexture: Texture;
|
|
105
|
+
_fboDepthTexture: Texture;
|
|
106
|
+
_emptyDepthTexture: Texture;
|
|
107
|
+
/**
|
|
108
|
+
* GL Objects for the terrain-mesh
|
|
109
|
+
* The mesh is a regular mesh, which has the advantage that it can be reused for all tiles.
|
|
110
|
+
*/
|
|
111
|
+
_mesh: Mesh;
|
|
112
|
+
/**
|
|
113
|
+
* coords index contains a list of tileID.keys. This index is used to identify
|
|
114
|
+
* the tile via the alpha-cannel in the coords-texture.
|
|
115
|
+
* As the alpha-channel has 1 Byte a max of 255 tiles can rendered without an error.
|
|
116
|
+
*/
|
|
117
|
+
coordsIndex: Array<string>;
|
|
118
|
+
/**
|
|
119
|
+
* tile-coords encoded in the rgb channel, _coordsIndex is in the alpha-channel.
|
|
120
|
+
*/
|
|
121
|
+
_coordsTexture: Texture;
|
|
122
|
+
/**
|
|
123
|
+
* accuracy of the coords. 2 * tileSize should be enough.
|
|
124
|
+
*/
|
|
125
|
+
_coordsTextureSize: number;
|
|
126
|
+
/**
|
|
127
|
+
* variables for an empty dem texture, which is used while the raster-dem tile is loading.
|
|
128
|
+
*/
|
|
129
|
+
_emptyDemUnpack: number[];
|
|
130
|
+
_emptyDemTexture: Texture;
|
|
131
|
+
_emptyDemMatrix: mat4;
|
|
132
|
+
/**
|
|
133
|
+
* as of overzooming of raster-dem tiles in high zoomlevels, this cache contains
|
|
134
|
+
* matrices to transform from vector-tile coords to raster-dem-tile coords.
|
|
135
|
+
*/
|
|
136
|
+
_demMatrixCache: {[_: string]: { matrix: mat4; coord: OverscaledTileID }};
|
|
137
|
+
|
|
138
|
+
constructor(painter: Painter, sourceCache: SourceCache, options: TerrainSpecification) {
|
|
139
|
+
this.painter = painter;
|
|
140
|
+
this.sourceCache = new TerrainSourceCache(sourceCache);
|
|
141
|
+
this.options = options;
|
|
142
|
+
this.exaggeration = typeof options.exaggeration === 'number' ? options.exaggeration : 1.0;
|
|
143
|
+
this.qualityFactor = 2;
|
|
144
|
+
this.meshSize = 128;
|
|
145
|
+
this._demMatrixCache = {};
|
|
146
|
+
this.coordsIndex = [];
|
|
147
|
+
this._coordsTextureSize = 1024;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* get the elevation-value from original dem-data for a given tile-coordinate
|
|
152
|
+
* @param tileID - the tile to get elevation for
|
|
153
|
+
* @param x - between 0 .. EXTENT
|
|
154
|
+
* @param y - between 0 .. EXTENT
|
|
155
|
+
* @param extent - optional, default 8192
|
|
156
|
+
* @returns the elevation
|
|
157
|
+
*/
|
|
158
|
+
getDEMElevation(tileID: OverscaledTileID, x: number, y: number, extent: number = EXTENT): number {
|
|
159
|
+
if (!(x >= 0 && x < extent && y >= 0 && y < extent)) return 0;
|
|
160
|
+
const terrain = this.getTerrainData(tileID);
|
|
161
|
+
const dem = terrain.tile?.dem;
|
|
162
|
+
if (!dem)
|
|
163
|
+
return 0;
|
|
164
|
+
|
|
165
|
+
const pos = vec2.transformMat4([] as any, [x / extent * EXTENT, y / extent * EXTENT], terrain.u_terrain_matrix);
|
|
166
|
+
const coord = [pos[0] * dem.dim, pos[1] * dem.dim];
|
|
167
|
+
|
|
168
|
+
// bilinear interpolation
|
|
169
|
+
const cx = Math.floor(coord[0]),
|
|
170
|
+
cy = Math.floor(coord[1]),
|
|
171
|
+
tx = coord[0] - cx,
|
|
172
|
+
ty = coord[1] - cy;
|
|
173
|
+
return (
|
|
174
|
+
dem.get(cx, cy) * (1 - tx) * (1 - ty) +
|
|
175
|
+
dem.get(cx + 1, cy) * (tx) * (1 - ty) +
|
|
176
|
+
dem.get(cx, cy + 1) * (1 - tx) * (ty) +
|
|
177
|
+
dem.get(cx + 1, cy + 1) * (tx) * (ty)
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Get the elevation for given {@link LngLat} in respect of exaggeration.
|
|
183
|
+
* @param lnglat - the location
|
|
184
|
+
* @param zoom - the zoom
|
|
185
|
+
* @returns the elevation
|
|
186
|
+
*/
|
|
187
|
+
getElevationForLngLatZoom(lnglat: LngLat, zoom: number) {
|
|
188
|
+
if (!isInBoundsForZoomLngLat(zoom, lnglat.wrap())) return 0;
|
|
189
|
+
const {tileID, mercatorX, mercatorY} = this._getOverscaledTileIDFromLngLatZoom(lnglat, zoom);
|
|
190
|
+
return this.getElevation(tileID, mercatorX % EXTENT, mercatorY % EXTENT, EXTENT);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Get the elevation for given coordinate in respect of exaggeration.
|
|
195
|
+
* @param tileID - the tile id
|
|
196
|
+
* @param x - between 0 .. EXTENT
|
|
197
|
+
* @param y - between 0 .. EXTENT
|
|
198
|
+
* @param extent - optional, default 8192
|
|
199
|
+
* @returns the elevation
|
|
200
|
+
*/
|
|
201
|
+
getElevation(tileID: OverscaledTileID, x: number, y: number, extent: number = EXTENT): number {
|
|
202
|
+
return this.getDEMElevation(tileID, x, y, extent) * this.exaggeration;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* returns a Terrain Object for a tile. Unless the tile corresponds to data (e.g. tile is loading), return a flat dem object
|
|
207
|
+
* @param tileID - the tile to get the terrain for
|
|
208
|
+
* @returns the terrain data to use in the program
|
|
209
|
+
*/
|
|
210
|
+
getTerrainData(tileID: OverscaledTileID): TerrainData {
|
|
211
|
+
// create empty DEM Objects, which will used while raster-dem tiles are loading.
|
|
212
|
+
// creates an empty depth-buffer texture which is needed, during the initialization process of the 3d mesh..
|
|
213
|
+
if (!this._emptyDemTexture) {
|
|
214
|
+
const context = this.painter.context;
|
|
215
|
+
const image = new RGBAImage({width: 1, height: 1}, new Uint8Array(1 * 4));
|
|
216
|
+
this._emptyDepthTexture = new Texture(context, image, context.gl.RGBA, {premultiply: false});
|
|
217
|
+
this._emptyDemUnpack = [0, 0, 0, 0];
|
|
218
|
+
this._emptyDemTexture = new Texture(context, new RGBAImage({width: 1, height: 1}), context.gl.RGBA, {premultiply: false});
|
|
219
|
+
this._emptyDemTexture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE);
|
|
220
|
+
this._emptyDemMatrix = mat4.identity([] as any);
|
|
221
|
+
}
|
|
222
|
+
// find covering dem tile and prepare demTexture
|
|
223
|
+
const sourceTile = this.sourceCache.getSourceTile(tileID, true);
|
|
224
|
+
if (sourceTile && sourceTile.dem && (!sourceTile.demTexture || sourceTile.needsTerrainPrepare)) {
|
|
225
|
+
const context = this.painter.context;
|
|
226
|
+
sourceTile.demTexture = this.painter.getTileTexture(sourceTile.dem.stride);
|
|
227
|
+
if (sourceTile.demTexture) sourceTile.demTexture.update(sourceTile.dem.getPixels(), {premultiply: false});
|
|
228
|
+
else sourceTile.demTexture = new Texture(context, sourceTile.dem.getPixels(), context.gl.RGBA, {premultiply: false});
|
|
229
|
+
sourceTile.demTexture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE);
|
|
230
|
+
sourceTile.needsTerrainPrepare = false;
|
|
231
|
+
}
|
|
232
|
+
// create matrix for lookup in dem data
|
|
233
|
+
const matrixKey = sourceTile && (sourceTile + sourceTile.tileID.key) + tileID.key;
|
|
234
|
+
if (matrixKey && !this._demMatrixCache[matrixKey]) {
|
|
235
|
+
const maxzoom = this.sourceCache.sourceCache._source.maxzoom;
|
|
236
|
+
let dz = tileID.canonical.z - sourceTile.tileID.canonical.z;
|
|
237
|
+
if (tileID.overscaledZ > tileID.canonical.z) {
|
|
238
|
+
if (tileID.canonical.z >= maxzoom) dz = tileID.canonical.z - maxzoom;
|
|
239
|
+
else warnOnce('cannot calculate elevation if elevation maxzoom > source.maxzoom');
|
|
240
|
+
}
|
|
241
|
+
const dx = tileID.canonical.x - (tileID.canonical.x >> dz << dz);
|
|
242
|
+
const dy = tileID.canonical.y - (tileID.canonical.y >> dz << dz);
|
|
243
|
+
const demMatrix = mat4.fromScaling(new Float64Array(16) as any, [1 / (EXTENT << dz), 1 / (EXTENT << dz), 0]);
|
|
244
|
+
mat4.translate(demMatrix, demMatrix, [dx * EXTENT, dy * EXTENT, 0]);
|
|
245
|
+
this._demMatrixCache[tileID.key] = {matrix: demMatrix, coord: tileID};
|
|
246
|
+
}
|
|
247
|
+
// return uniform values & textures
|
|
248
|
+
return {
|
|
249
|
+
'u_depth': 2,
|
|
250
|
+
'u_terrain': 3,
|
|
251
|
+
'u_terrain_dim': sourceTile && sourceTile.dem && sourceTile.dem.dim || 1,
|
|
252
|
+
'u_terrain_matrix': matrixKey ? this._demMatrixCache[tileID.key].matrix : this._emptyDemMatrix,
|
|
253
|
+
'u_terrain_unpack': sourceTile && sourceTile.dem && sourceTile.dem.getUnpackVector() || this._emptyDemUnpack,
|
|
254
|
+
'u_terrain_exaggeration': this.exaggeration,
|
|
255
|
+
texture: (sourceTile && sourceTile.demTexture || this._emptyDemTexture).texture,
|
|
256
|
+
depthTexture: (this._fboDepthTexture || this._emptyDepthTexture).texture,
|
|
257
|
+
tile: sourceTile
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* get a framebuffer as big as the map-div, which will be used to render depth & coords into a texture
|
|
263
|
+
* @param texture - the texture
|
|
264
|
+
* @returns the frame buffer
|
|
265
|
+
*/
|
|
266
|
+
getFramebuffer(texture: string): Framebuffer {
|
|
267
|
+
const painter = this.painter;
|
|
268
|
+
const width = painter.width / devicePixelRatio;
|
|
269
|
+
const height = painter.height / devicePixelRatio;
|
|
270
|
+
if (this._fbo && (this._fbo.width !== width || this._fbo.height !== height)) {
|
|
271
|
+
this._fbo.destroy();
|
|
272
|
+
this._fboCoordsTexture.destroy();
|
|
273
|
+
this._fboDepthTexture.destroy();
|
|
274
|
+
delete this._fbo;
|
|
275
|
+
delete this._fboDepthTexture;
|
|
276
|
+
delete this._fboCoordsTexture;
|
|
277
|
+
}
|
|
278
|
+
if (!this._fboCoordsTexture) {
|
|
279
|
+
this._fboCoordsTexture = new Texture(painter.context, {width, height, data: null}, painter.context.gl.RGBA, {premultiply: false});
|
|
280
|
+
this._fboCoordsTexture.bind(painter.context.gl.NEAREST, painter.context.gl.CLAMP_TO_EDGE);
|
|
281
|
+
}
|
|
282
|
+
if (!this._fboDepthTexture) {
|
|
283
|
+
this._fboDepthTexture = new Texture(painter.context, {width, height, data: null}, painter.context.gl.RGBA, {premultiply: false});
|
|
284
|
+
this._fboDepthTexture.bind(painter.context.gl.NEAREST, painter.context.gl.CLAMP_TO_EDGE);
|
|
285
|
+
}
|
|
286
|
+
if (!this._fbo) {
|
|
287
|
+
this._fbo = painter.context.createFramebuffer(width, height, true, false);
|
|
288
|
+
this._fbo.depthAttachment.set(painter.context.createRenderbuffer(painter.context.gl.DEPTH_COMPONENT16, width, height));
|
|
289
|
+
}
|
|
290
|
+
this._fbo.colorAttachment.set(texture === 'coords' ? this._fboCoordsTexture.texture : this._fboDepthTexture.texture);
|
|
291
|
+
return this._fbo;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* create coords texture, needed to grab coordinates from canvas
|
|
296
|
+
* encode coords coordinate into 4 bytes:
|
|
297
|
+
* - 8 lower bits for x
|
|
298
|
+
* - 8 lower bits for y
|
|
299
|
+
* - 4 higher bits for x
|
|
300
|
+
* - 4 higher bits for y
|
|
301
|
+
* - 8 bits for coordsIndex (1 .. 255) (= number of terraintile), is later setted in draw_terrain uniform value
|
|
302
|
+
* @returns the texture
|
|
303
|
+
*/
|
|
304
|
+
getCoordsTexture(): Texture {
|
|
305
|
+
const context = this.painter.context;
|
|
306
|
+
if (this._coordsTexture) return this._coordsTexture;
|
|
307
|
+
const data = new Uint8Array(this._coordsTextureSize * this._coordsTextureSize * 4);
|
|
308
|
+
for (let y = 0, i = 0; y < this._coordsTextureSize; y++) for (let x = 0; x < this._coordsTextureSize; x++, i += 4) {
|
|
309
|
+
data[i + 0] = x & 255;
|
|
310
|
+
data[i + 1] = y & 255;
|
|
311
|
+
data[i + 2] = ((x >> 8) << 4) | (y >> 8);
|
|
312
|
+
data[i + 3] = 0;
|
|
313
|
+
}
|
|
314
|
+
const image = new RGBAImage({width: this._coordsTextureSize, height: this._coordsTextureSize}, new Uint8Array(data.buffer));
|
|
315
|
+
const texture = new Texture(context, image, context.gl.RGBA, {premultiply: false});
|
|
316
|
+
texture.bind(context.gl.NEAREST, context.gl.CLAMP_TO_EDGE);
|
|
317
|
+
this._coordsTexture = texture;
|
|
318
|
+
return texture;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Reads a pixel from the coords-framebuffer and translate this to mercator.
|
|
323
|
+
* @param p - Screen-Coordinate
|
|
324
|
+
* @returns mercator coordinate for a screen pixel
|
|
325
|
+
*/
|
|
326
|
+
pointCoordinate(p: Point): MercatorCoordinate {
|
|
327
|
+
// First, ensure the coords framebuffer is up to date.
|
|
328
|
+
this.painter.maybeDrawDepthAndCoords(true);
|
|
329
|
+
|
|
330
|
+
const rgba = new Uint8Array(4);
|
|
331
|
+
const context = this.painter.context, gl = context.gl;
|
|
332
|
+
const px = Math.round(p.x * this.painter.pixelRatio / devicePixelRatio);
|
|
333
|
+
const py = Math.round(p.y * this.painter.pixelRatio / devicePixelRatio);
|
|
334
|
+
const fbHeight = Math.round(this.painter.height / devicePixelRatio);
|
|
335
|
+
// grab coordinate pixel from coordinates framebuffer
|
|
336
|
+
context.bindFramebuffer.set(this.getFramebuffer('coords').framebuffer);
|
|
337
|
+
gl.readPixels(px, fbHeight - py - 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, rgba);
|
|
338
|
+
context.bindFramebuffer.set(null);
|
|
339
|
+
// decode coordinates (encoding see getCoordsTexture)
|
|
340
|
+
const x = rgba[0] + ((rgba[2] >> 4) << 8);
|
|
341
|
+
const y = rgba[1] + ((rgba[2] & 15) << 8);
|
|
342
|
+
const tileID = this.coordsIndex[255 - rgba[3]];
|
|
343
|
+
const tile = tileID && this.sourceCache.getTileByID(tileID);
|
|
344
|
+
if (!tile) return null;
|
|
345
|
+
const coordsSize = this._coordsTextureSize;
|
|
346
|
+
const worldSize = (1 << tile.tileID.canonical.z) * coordsSize;
|
|
347
|
+
return new MercatorCoordinate(
|
|
348
|
+
(tile.tileID.canonical.x * coordsSize + x) / worldSize + tile.tileID.wrap,
|
|
349
|
+
(tile.tileID.canonical.y * coordsSize + y) / worldSize,
|
|
350
|
+
this.getElevation(tile.tileID, x, y, coordsSize)
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Reads the depth value from the depth-framebuffer at a given screen pixel
|
|
356
|
+
* @param p - Screen coordinate
|
|
357
|
+
* @returns depth value in clip space (between 0 and 1)
|
|
358
|
+
*/
|
|
359
|
+
|
|
360
|
+
depthAtPoint(p: Point): number {
|
|
361
|
+
const rgba = new Uint8Array(4);
|
|
362
|
+
const context = this.painter.context, gl = context.gl;
|
|
363
|
+
context.bindFramebuffer.set(this.getFramebuffer('depth').framebuffer);
|
|
364
|
+
gl.readPixels(p.x, this.painter.height / devicePixelRatio - p.y - 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, rgba);
|
|
365
|
+
context.bindFramebuffer.set(null);
|
|
366
|
+
// decode coordinates (encoding see terran_depth.fragment.glsl)
|
|
367
|
+
const depthValue = (rgba[0] / (256 * 256 * 256) + rgba[1] / (256 * 256) + rgba[2] / 256 + rgba[3]) / 256;
|
|
368
|
+
return depthValue;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* create a regular mesh which will be used by all terrain-tiles
|
|
373
|
+
* @returns the created regular mesh
|
|
374
|
+
*/
|
|
375
|
+
getTerrainMesh(): Mesh {
|
|
376
|
+
if (this._mesh) return this._mesh;
|
|
377
|
+
const context = this.painter.context;
|
|
378
|
+
const vertexArray = new Pos3dArray();
|
|
379
|
+
const indexArray = new TriangleIndexArray();
|
|
380
|
+
const meshSize = this.meshSize;
|
|
381
|
+
const delta = EXTENT / meshSize;
|
|
382
|
+
const meshSize2 = meshSize * meshSize;
|
|
383
|
+
for (let y = 0; y <= meshSize; y++) for (let x = 0; x <= meshSize; x++)
|
|
384
|
+
vertexArray.emplaceBack(x * delta, y * delta, 0);
|
|
385
|
+
for (let y = 0; y < meshSize2; y += meshSize + 1) for (let x = 0; x < meshSize; x++) {
|
|
386
|
+
indexArray.emplaceBack(x + y, meshSize + x + y + 1, meshSize + x + y + 2);
|
|
387
|
+
indexArray.emplaceBack(x + y, meshSize + x + y + 2, x + y + 1);
|
|
388
|
+
}
|
|
389
|
+
// add an extra frame around the mesh to avoid stiching on tile boundaries with different zoomlevels
|
|
390
|
+
// first code-block is for top-bottom frame and second for left-right frame
|
|
391
|
+
const offsetTop = vertexArray.length, offsetBottom = offsetTop + (meshSize + 1) * 2;
|
|
392
|
+
for (const y of [0, 1]) for (let x = 0; x <= meshSize; x++) for (const z of [0, 1])
|
|
393
|
+
vertexArray.emplaceBack(x * delta, y * EXTENT, z);
|
|
394
|
+
for (let x = 0; x < meshSize * 2; x += 2) {
|
|
395
|
+
indexArray.emplaceBack(offsetBottom + x, offsetBottom + x + 1, offsetBottom + x + 3);
|
|
396
|
+
indexArray.emplaceBack(offsetBottom + x, offsetBottom + x + 3, offsetBottom + x + 2);
|
|
397
|
+
indexArray.emplaceBack(offsetTop + x, offsetTop + x + 3, offsetTop + x + 1);
|
|
398
|
+
indexArray.emplaceBack(offsetTop + x, offsetTop + x + 2, offsetTop + x + 3);
|
|
399
|
+
}
|
|
400
|
+
const offsetLeft = vertexArray.length, offsetRight = offsetLeft + (meshSize + 1) * 2;
|
|
401
|
+
for (const x of [0, 1]) for (let y = 0; y <= meshSize; y++) for (const z of [0, 1])
|
|
402
|
+
vertexArray.emplaceBack(x * EXTENT, y * delta, z);
|
|
403
|
+
for (let y = 0; y < meshSize * 2; y += 2) {
|
|
404
|
+
indexArray.emplaceBack(offsetLeft + y, offsetLeft + y + 1, offsetLeft + y + 3);
|
|
405
|
+
indexArray.emplaceBack(offsetLeft + y, offsetLeft + y + 3, offsetLeft + y + 2);
|
|
406
|
+
indexArray.emplaceBack(offsetRight + y, offsetRight + y + 3, offsetRight + y + 1);
|
|
407
|
+
indexArray.emplaceBack(offsetRight + y, offsetRight + y + 2, offsetRight + y + 3);
|
|
408
|
+
}
|
|
409
|
+
this._mesh = new Mesh(
|
|
410
|
+
context.createVertexBuffer(vertexArray, pos3dAttributes.members),
|
|
411
|
+
context.createIndexBuffer(indexArray),
|
|
412
|
+
SegmentVector.simpleSegment(0, 0, vertexArray.length, indexArray.length)
|
|
413
|
+
);
|
|
414
|
+
return this._mesh;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Calculates a height of the frame around the terrain-mesh to avoid stiching between
|
|
419
|
+
* tile boundaries in different zoomlevels.
|
|
420
|
+
* @param zoom - current zoomlevel
|
|
421
|
+
* @returns the elevation delta in meters
|
|
422
|
+
*/
|
|
423
|
+
getMeshFrameDelta(zoom: number): number {
|
|
424
|
+
// divide by 5 is evaluated by trial & error to get a frame in the right height
|
|
425
|
+
return 2 * Math.PI * earthRadius / Math.pow(2, zoom) / 5;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
getMinTileElevationForLngLatZoom(lnglat: LngLat, zoom: number) {
|
|
429
|
+
const {tileID} = this._getOverscaledTileIDFromLngLatZoom(lnglat, zoom);
|
|
430
|
+
return this.getMinMaxElevation(tileID).minElevation ?? 0;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Get the minimum and maximum elevation contained in a tile. This includes any
|
|
435
|
+
* exaggeration included in the terrain.
|
|
436
|
+
*
|
|
437
|
+
* @param tileID - ID of the tile to be used as a source for the min/max elevation
|
|
438
|
+
* @returns the minimum and maximum elevation found in the tile, including the terrain's
|
|
439
|
+
* exaggeration
|
|
440
|
+
*/
|
|
441
|
+
getMinMaxElevation(tileID: OverscaledTileID): {minElevation: number | null; maxElevation: number | null} {
|
|
442
|
+
const tile = this.getTerrainData(tileID).tile;
|
|
443
|
+
const minMax = {minElevation: null, maxElevation: null};
|
|
444
|
+
if (tile && tile.dem) {
|
|
445
|
+
minMax.minElevation = tile.dem.min * this.exaggeration;
|
|
446
|
+
minMax.maxElevation = tile.dem.max * this.exaggeration;
|
|
447
|
+
}
|
|
448
|
+
return minMax;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
_getOverscaledTileIDFromLngLatZoom(lnglat: LngLat, zoom: number): { tileID: OverscaledTileID; mercatorX: number; mercatorY: number} {
|
|
452
|
+
const mercatorCoordinate = MercatorCoordinate.fromLngLat(lnglat.wrap());
|
|
453
|
+
const worldSize = (1 << zoom) * EXTENT;
|
|
454
|
+
const mercatorX = mercatorCoordinate.x * worldSize;
|
|
455
|
+
const mercatorY = mercatorCoordinate.y * worldSize;
|
|
456
|
+
const tileX = Math.floor(mercatorX / EXTENT), tileY = Math.floor(mercatorY / EXTENT);
|
|
457
|
+
const tileID = new OverscaledTileID(zoom, 0, zoom, tileX, tileY);
|
|
458
|
+
return {
|
|
459
|
+
tileID,
|
|
460
|
+
mercatorX,
|
|
461
|
+
mercatorY
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type {Context} from '../gl/context';
|
|
2
|
+
import type {RGBAImage, AlphaImage} from '../util/image';
|
|
3
|
+
import {isImageBitmap} from '../util/util';
|
|
4
|
+
|
|
5
|
+
export type TextureFormat = WebGLRenderingContextBase['RGBA'] | WebGLRenderingContextBase['ALPHA'];
|
|
6
|
+
export type TextureFilter = WebGLRenderingContextBase['LINEAR'] | WebGLRenderingContextBase['LINEAR_MIPMAP_NEAREST'] | WebGLRenderingContextBase['NEAREST'];
|
|
7
|
+
export type TextureWrap = WebGLRenderingContextBase['REPEAT'] | WebGLRenderingContextBase['CLAMP_TO_EDGE'] | WebGLRenderingContextBase['MIRRORED_REPEAT'];
|
|
8
|
+
|
|
9
|
+
type EmptyImage = {
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
data: null;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type DataTextureImage = RGBAImage | AlphaImage | EmptyImage;
|
|
16
|
+
export type TextureImage = TexImageSource | DataTextureImage;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
* A `Texture` GL related object
|
|
21
|
+
*/
|
|
22
|
+
export class Texture {
|
|
23
|
+
context: Context;
|
|
24
|
+
size: [number, number];
|
|
25
|
+
texture: WebGLTexture;
|
|
26
|
+
format: TextureFormat;
|
|
27
|
+
filter: TextureFilter;
|
|
28
|
+
wrap: TextureWrap;
|
|
29
|
+
useMipmap: boolean;
|
|
30
|
+
|
|
31
|
+
constructor(context: Context, image: TextureImage, format: TextureFormat, options?: {
|
|
32
|
+
premultiply?: boolean;
|
|
33
|
+
useMipmap?: boolean;
|
|
34
|
+
} | null) {
|
|
35
|
+
this.context = context;
|
|
36
|
+
this.format = format;
|
|
37
|
+
this.texture = context.gl.createTexture();
|
|
38
|
+
this.update(image, options);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
update(image: TextureImage, options?: {
|
|
42
|
+
premultiply?: boolean;
|
|
43
|
+
useMipmap?: boolean;
|
|
44
|
+
} | null, position?: {
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
}) {
|
|
48
|
+
const {width, height} = image as {width: number; height: number};
|
|
49
|
+
const resize = (!this.size || this.size[0] !== width || this.size[1] !== height) && !position;
|
|
50
|
+
const {context} = this;
|
|
51
|
+
const {gl} = context;
|
|
52
|
+
|
|
53
|
+
this.useMipmap = Boolean(options && options.useMipmap);
|
|
54
|
+
gl.bindTexture(gl.TEXTURE_2D, this.texture);
|
|
55
|
+
|
|
56
|
+
context.pixelStoreUnpackFlipY.set(false);
|
|
57
|
+
context.pixelStoreUnpack.set(1);
|
|
58
|
+
context.pixelStoreUnpackPremultiplyAlpha.set(this.format === gl.RGBA && (!options || options.premultiply !== false));
|
|
59
|
+
|
|
60
|
+
if (resize) {
|
|
61
|
+
this.size = [width, height];
|
|
62
|
+
|
|
63
|
+
if (image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof HTMLVideoElement || image instanceof ImageData || isImageBitmap(image)) {
|
|
64
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.format, gl.UNSIGNED_BYTE, image);
|
|
65
|
+
} else {
|
|
66
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, this.format, width, height, 0, this.format, gl.UNSIGNED_BYTE, (image as DataTextureImage).data);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
} else {
|
|
70
|
+
const {x, y} = position || {x: 0, y: 0};
|
|
71
|
+
if (image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof HTMLVideoElement || image instanceof ImageData || isImageBitmap(image)) {
|
|
72
|
+
gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
73
|
+
} else {
|
|
74
|
+
gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, width, height, gl.RGBA, gl.UNSIGNED_BYTE, (image as DataTextureImage).data);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (this.useMipmap && this.isSizePowerOfTwo()) {
|
|
79
|
+
gl.generateMipmap(gl.TEXTURE_2D);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
bind(filter: TextureFilter, wrap: TextureWrap, minFilter?: TextureFilter | null) {
|
|
84
|
+
const {context} = this;
|
|
85
|
+
const {gl} = context;
|
|
86
|
+
gl.bindTexture(gl.TEXTURE_2D, this.texture);
|
|
87
|
+
|
|
88
|
+
if (minFilter === gl.LINEAR_MIPMAP_NEAREST && !this.isSizePowerOfTwo()) {
|
|
89
|
+
minFilter = gl.LINEAR;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (filter !== this.filter) {
|
|
93
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);
|
|
94
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter || filter);
|
|
95
|
+
this.filter = filter;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (wrap !== this.wrap) {
|
|
99
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrap);
|
|
100
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrap);
|
|
101
|
+
this.wrap = wrap;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
isSizePowerOfTwo() {
|
|
106
|
+
return this.size[0] === this.size[1] && (Math.log(this.size[0]) / Math.LN2) % 1 === 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
destroy() {
|
|
110
|
+
const {gl} = this.context;
|
|
111
|
+
gl.deleteTexture(this.texture);
|
|
112
|
+
this.texture = null;
|
|
113
|
+
}
|
|
114
|
+
}
|