@npm9912/v-map 0.1.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 +21 -0
- package/README.md +185 -0
- package/dist/cjs/_commonjsHelpers-B83fTs8d.js +36 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
- package/dist/cjs/cesium-provider-BiFFyAl9.js +2598 -0
- package/dist/cjs/deck-provider-Ctq3Q8a1.js +47824 -0
- package/dist/cjs/geotiff-CEwvF9cG.js +47 -0
- package/dist/cjs/geotiff-source-RaNzzWkC.js +1522 -0
- package/dist/cjs/index-B1oGO1g-.js +10658 -0
- package/dist/cjs/index-B8LHqjyg.js +1765 -0
- package/dist/cjs/index-BIL4VsgP.js +310 -0
- package/dist/cjs/index-Blku2QY8.js +167 -0
- package/dist/cjs/index-CJvvX4yx.js +21 -0
- package/dist/cjs/index-CbVT-Con.js +699 -0
- package/dist/cjs/index-ISOEpMC3.js +20478 -0
- package/dist/cjs/index-JSwBbvGA.js +1621 -0
- package/dist/cjs/index.browser-DQhD8Jwl.js +6873 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/layer-extension-B_olS0rc.js +65 -0
- package/dist/cjs/leaflet-provider-DOqfs7g5.js +1815 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/cjs/main-dist-7TykwFci.js +2655 -0
- package/dist/cjs/messages-D7h4m8Tx.js +186 -0
- package/dist/cjs/openlayers-provider-Dfeg6L4n.js +1604 -0
- package/dist/cjs/polygon-layer-B9PrN7vr.js +1300 -0
- package/dist/cjs/scenegraph-layer-DwNoxQdi.js +2530 -0
- package/dist/cjs/styleconfig-CVRqArk-.js +23 -0
- package/dist/cjs/v-map-builder.cjs.entry.js +3786 -0
- package/dist/cjs/v-map-layer-geojson_12.cjs.entry.js +40894 -0
- package/dist/cjs/v-map-layer-helper-iAzxAg9I.js +285 -0
- package/dist/cjs/v-map-layer-terrain-geotiff.cjs.entry.js +258 -0
- package/dist/cjs/v-map-layercontrol.cjs.entry.js +247 -0
- package/dist/cjs/v-map.cjs.js +25 -0
- package/dist/cjs/v-map.v-map-layer-osm.v-map-layergroup-BsXp3BoL.js +582 -0
- package/dist/cjs/v-map_3.cjs.entry.js +12 -0
- package/dist/collection/collection-manifest.json +30 -0
- package/dist/collection/components/v-map/v-map.css +3 -0
- package/dist/collection/components/v-map/v-map.js +467 -0
- package/dist/collection/components/v-map/v-map.test.js +33 -0
- package/dist/collection/components/v-map-builder/v-map-builder.css +1 -0
- package/dist/collection/components/v-map-builder/v-map-builder.js +913 -0
- package/dist/collection/components/v-map-builder/v-map-builder.test.js +56 -0
- package/dist/collection/components/v-map-layer-geojson/v-map-layer-geojson.js +862 -0
- package/dist/collection/components/v-map-layer-geojson/v-map-layer-geojson.test.js +42 -0
- package/dist/collection/components/v-map-layer-geotiff/v-map-layer-geotiff.css +4 -0
- package/dist/collection/components/v-map-layer-geotiff/v-map-layer-geotiff.js +500 -0
- package/dist/collection/components/v-map-layer-geotiff/v-map-layer-geotiff.test.js +38 -0
- package/dist/collection/components/v-map-layer-google/v-map-layer-google.css +1 -0
- package/dist/collection/components/v-map-layer-google/v-map-layer-google.js +442 -0
- package/dist/collection/components/v-map-layer-osm/error-api.test.js +108 -0
- package/dist/collection/components/v-map-layer-osm/v-map-layer-osm.css +4 -0
- package/dist/collection/components/v-map-layer-osm/v-map-layer-osm.js +311 -0
- package/dist/collection/components/v-map-layer-osm/v-map-layer-osm.test.js +36 -0
- package/dist/collection/components/v-map-layer-scatterplot/v-map-layer-scatterplot.css +1 -0
- package/dist/collection/components/v-map-layer-scatterplot/v-map-layer-scatterplot.js +305 -0
- package/dist/collection/components/v-map-layer-terrain/v-map-layer-terrain.css +3 -0
- package/dist/collection/components/v-map-layer-terrain/v-map-layer-terrain.js +548 -0
- package/dist/collection/components/v-map-layer-terrain/v-map-layer-terrain.test.js +36 -0
- package/dist/collection/components/v-map-layer-terrain-geotiff/v-map-layer-terrain-geotiff.css +3 -0
- package/dist/collection/components/v-map-layer-terrain-geotiff/v-map-layer-terrain-geotiff.js +735 -0
- package/dist/collection/components/v-map-layer-terrain-geotiff/v-map-layer-terrain-geotiff.test.js +42 -0
- package/dist/collection/components/v-map-layer-tile3d/v-map-layer-tile3d.css +3 -0
- package/dist/collection/components/v-map-layer-tile3d/v-map-layer-tile3d.js +449 -0
- package/dist/collection/components/v-map-layer-tile3d/v-map-layer-tile3d.test.js +50 -0
- package/dist/collection/components/v-map-layer-wcs/v-map-layer-wcs.css +1 -0
- package/dist/collection/components/v-map-layer-wcs/v-map-layer-wcs.js +448 -0
- package/dist/collection/components/v-map-layer-wcs/v-map-layer-wcs.test.js +39 -0
- package/dist/collection/components/v-map-layer-wfs/v-map-layer-wfs.css +1 -0
- package/dist/collection/components/v-map-layer-wfs/v-map-layer-wfs.js +489 -0
- package/dist/collection/components/v-map-layer-wfs/v-map-layer-wfs.test.js +43 -0
- package/dist/collection/components/v-map-layer-wkt/v-map-layer-wkt.css +1 -0
- package/dist/collection/components/v-map-layer-wkt/v-map-layer-wkt.js +811 -0
- package/dist/collection/components/v-map-layer-wkt/v-map-layer-wkt.test.js +34 -0
- package/dist/collection/components/v-map-layer-wms/v-map-layer-wms.css +1 -0
- package/dist/collection/components/v-map-layer-wms/v-map-layer-wms.js +453 -0
- package/dist/collection/components/v-map-layer-wms/v-map-layer-wms.test.js +36 -0
- package/dist/collection/components/v-map-layer-xyz/v-map-layer-xyz.css +1 -0
- package/dist/collection/components/v-map-layer-xyz/v-map-layer-xyz.js +331 -0
- package/dist/collection/components/v-map-layer-xyz/v-map-layer-xyz.test.js +28 -0
- package/dist/collection/components/v-map-layercontrol/v-map-layercontrol.css +74 -0
- package/dist/collection/components/v-map-layercontrol/v-map-layercontrol.js +277 -0
- package/dist/collection/components/v-map-layercontrol/v-map-layercontrol.test.js +134 -0
- package/dist/collection/components/v-map-layergroup/v-map-layergroup.css +4 -0
- package/dist/collection/components/v-map-layergroup/v-map-layergroup.js +212 -0
- package/dist/collection/components/v-map-layergroup/v-map-layergroup.test.js +39 -0
- package/dist/collection/components/v-map-style/v-map-style.css +38 -0
- package/dist/collection/components/v-map-style/v-map-style.js +492 -0
- package/dist/collection/components/v-map-style/v-map-style.unit.js +62 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/layer/v-map-layer-helper.js +281 -0
- package/dist/collection/layer/v-map-layer-helper.unit.js +234 -0
- package/dist/collection/lib/cesium-loader.js +58 -0
- package/dist/collection/lib/ensure-importmap.js +12 -0
- package/dist/collection/lib/ensure-importmap.unit.js +57 -0
- package/dist/collection/lib/versions.gen.js +6 -0
- package/dist/collection/lib/vstyle.js +8 -0
- package/dist/collection/map-provider/cesium/CesiumGeoTIFFTerrainProvider.js +285 -0
- package/dist/collection/map-provider/cesium/CesiumLayerGroups.js +159 -0
- package/dist/collection/map-provider/cesium/GeoTIFFImageryProvider.js +192 -0
- package/dist/collection/map-provider/cesium/GeoTIFFImageryProvider.test.js +57 -0
- package/dist/collection/map-provider/cesium/cesium-provider.js +1408 -0
- package/dist/collection/map-provider/cesium/i-layer.js +1 -0
- package/dist/collection/map-provider/cesium/layer-manager.js +467 -0
- package/dist/collection/map-provider/deck/DeckGLGeoTIFFLayer.js +483 -0
- package/dist/collection/map-provider/deck/DeckGLGeoTIFFTerrainLayer.js +410 -0
- package/dist/collection/map-provider/deck/LayerGroupWithModel.js +169 -0
- package/dist/collection/map-provider/deck/LayerGroups.js +192 -0
- package/dist/collection/map-provider/deck/LayerModel.js +1 -0
- package/dist/collection/map-provider/deck/RenderableGroup.js +1 -0
- package/dist/collection/map-provider/deck/deck-provider.js +1563 -0
- package/dist/collection/map-provider/geotiff/geotiff-source.js +172 -0
- package/dist/collection/map-provider/geotiff/utils/AABB2D.js +24 -0
- package/dist/collection/map-provider/geotiff/utils/BVHNode2D.js +166 -0
- package/dist/collection/map-provider/geotiff/utils/GeoTIFFTileProcessor.js +484 -0
- package/dist/collection/map-provider/geotiff/utils/Triangle.js +1 -0
- package/dist/collection/map-provider/geotiff/utils/Triangulation.js +321 -0
- package/dist/collection/map-provider/geotiff/utils/colormap-utils.js +190 -0
- package/dist/collection/map-provider/geotiff/utils/normalization-utils.js +122 -0
- package/dist/collection/map-provider/geotiff/utils/sampling-utils.js +108 -0
- package/dist/collection/map-provider/leaflet/GeoTIFFGridLayer.js +147 -0
- package/dist/collection/map-provider/leaflet/WCSGridLayer.js +124 -0
- package/dist/collection/map-provider/leaflet/google-map-tiles-layer.js +352 -0
- package/dist/collection/map-provider/leaflet/leaflet-helpers.js +94 -0
- package/dist/collection/map-provider/leaflet/leaflet-provider.js +1095 -0
- package/dist/collection/map-provider/ol/CustomGeoTiff.js +145 -0
- package/dist/collection/map-provider/ol/openlayers-helper.js +26 -0
- package/dist/collection/map-provider/ol/openlayers-provider.js +1427 -0
- package/dist/collection/map-provider/provider-factory.js +44 -0
- package/dist/collection/map-provider/provider-factory.unit.js +66 -0
- package/dist/collection/testing/browser-test-utils.js +49 -0
- package/dist/collection/testing/e2e-testing.js +122 -0
- package/dist/collection/testing/e2e-utils.js +70 -0
- package/dist/collection/testing/geotiff-test-server.js +100 -0
- package/dist/collection/testing/mocks/geostyler-lyrx-parser.js +12 -0
- package/dist/collection/testing/mocks/geostyler-mapbox-parser.js +12 -0
- package/dist/collection/testing/mocks/geostyler-qgis-parser.js +12 -0
- package/dist/collection/testing/mocks/geostyler-sld-parser.js +13 -0
- package/dist/collection/testing/mocks/geostyler-style.js +5 -0
- package/dist/collection/testing/setupTests.browser.js +1 -0
- package/dist/collection/testing/setupTests.stencil.js +20 -0
- package/dist/collection/testing/setupTests.vitest.js +59 -0
- package/dist/collection/testing/stencil-testing-wrapper.js +43 -0
- package/dist/collection/testing/styleMock.js +1 -0
- package/dist/collection/types/color.js +1 -0
- package/dist/collection/types/cssmode.js +1 -0
- package/dist/collection/types/flavour.js +1 -0
- package/dist/collection/types/layerconfig.js +1 -0
- package/dist/collection/types/lonlat.js +1 -0
- package/dist/collection/types/mapinitoptions.js +1 -0
- package/dist/collection/types/mapprovider.js +1 -0
- package/dist/collection/types/provideroptions.js +1 -0
- package/dist/collection/types/styleconfig.js +19 -0
- package/dist/collection/types/styling.js +13 -0
- package/dist/collection/types/styling.unit.js +37 -0
- package/dist/collection/types/vmaplayer.js +1 -0
- package/dist/collection/utils/async-mutex.js +28 -0
- package/dist/collection/utils/diff.js +142 -0
- package/dist/collection/utils/diff.unit.js +59 -0
- package/dist/collection/utils/dom-env.js +43 -0
- package/dist/collection/utils/dom-env.unit.js +92 -0
- package/dist/collection/utils/events.js +8 -0
- package/dist/collection/utils/logger.js +183 -0
- package/dist/collection/utils/logger.unit.js +98 -0
- package/dist/collection/utils/messages.js +12 -0
- package/dist/collection/utils/spatial-utils.js +27 -0
- package/dist/collection/utils/spatial-utils.unit.js +24 -0
- package/dist/components/_commonjsHelpers.js +1 -0
- package/dist/components/cesium-provider.js +1 -0
- package/dist/components/deck-provider.js +1 -0
- package/dist/components/events.js +1 -0
- package/dist/components/geotiff-source.js +1 -0
- package/dist/components/geotiff.js +4 -0
- package/dist/components/index.browser.js +15 -0
- package/dist/components/index.d.ts +35 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index2.js +1 -0
- package/dist/components/index3.js +1 -0
- package/dist/components/index4.js +1 -0
- package/dist/components/index5.js +1 -0
- package/dist/components/index6.js +1 -0
- package/dist/components/index7.js +1 -0
- package/dist/components/index8.js +7 -0
- package/dist/components/layer-extension.js +1 -0
- package/dist/components/leaflet-provider.js +1 -0
- package/dist/components/main-dist.js +1 -0
- package/dist/components/messages.js +1 -0
- package/dist/components/openlayers-provider.js +1 -0
- package/dist/components/polygon-layer.js +1 -0
- package/dist/components/scenegraph-layer.js +1 -0
- package/dist/components/styleconfig.js +1 -0
- package/dist/components/styling.js +1 -0
- package/dist/components/v-map-builder.d.ts +11 -0
- package/dist/components/v-map-builder.js +2 -0
- package/dist/components/v-map-layer-geojson.d.ts +11 -0
- package/dist/components/v-map-layer-geojson.js +1 -0
- package/dist/components/v-map-layer-geojson2.js +1 -0
- package/dist/components/v-map-layer-geotiff.d.ts +11 -0
- package/dist/components/v-map-layer-geotiff.js +1 -0
- package/dist/components/v-map-layer-geotiff2.js +1 -0
- package/dist/components/v-map-layer-google.d.ts +11 -0
- package/dist/components/v-map-layer-google.js +1 -0
- package/dist/components/v-map-layer-google2.js +1 -0
- package/dist/components/v-map-layer-helper.js +1 -0
- package/dist/components/v-map-layer-osm.d.ts +11 -0
- package/dist/components/v-map-layer-osm.js +1 -0
- package/dist/components/v-map-layer-osm2.js +1 -0
- package/dist/components/v-map-layer-scatterplot.d.ts +11 -0
- package/dist/components/v-map-layer-scatterplot.js +1 -0
- package/dist/components/v-map-layer-scatterplot2.js +1 -0
- package/dist/components/v-map-layer-terrain-geotiff.d.ts +11 -0
- package/dist/components/v-map-layer-terrain-geotiff.js +1 -0
- package/dist/components/v-map-layer-terrain.d.ts +11 -0
- package/dist/components/v-map-layer-terrain.js +1 -0
- package/dist/components/v-map-layer-terrain2.js +1 -0
- package/dist/components/v-map-layer-tile3d.d.ts +11 -0
- package/dist/components/v-map-layer-tile3d.js +1 -0
- package/dist/components/v-map-layer-tile3d2.js +1 -0
- package/dist/components/v-map-layer-wcs.d.ts +11 -0
- package/dist/components/v-map-layer-wcs.js +1 -0
- package/dist/components/v-map-layer-wcs2.js +1 -0
- package/dist/components/v-map-layer-wfs.d.ts +11 -0
- package/dist/components/v-map-layer-wfs.js +1 -0
- package/dist/components/v-map-layer-wfs2.js +1 -0
- package/dist/components/v-map-layer-wkt.d.ts +11 -0
- package/dist/components/v-map-layer-wkt.js +1 -0
- package/dist/components/v-map-layer-wkt2.js +1 -0
- package/dist/components/v-map-layer-wms.d.ts +11 -0
- package/dist/components/v-map-layer-wms.js +1 -0
- package/dist/components/v-map-layer-wms2.js +1 -0
- package/dist/components/v-map-layer-xyz.d.ts +11 -0
- package/dist/components/v-map-layer-xyz.js +1 -0
- package/dist/components/v-map-layer-xyz2.js +1 -0
- package/dist/components/v-map-layercontrol.d.ts +11 -0
- package/dist/components/v-map-layercontrol.js +1 -0
- package/dist/components/v-map-layergroup.d.ts +11 -0
- package/dist/components/v-map-layergroup.js +1 -0
- package/dist/components/v-map-layergroup2.js +1 -0
- package/dist/components/v-map-style.d.ts +11 -0
- package/dist/components/v-map-style.js +1 -0
- package/dist/components/v-map-style2.js +10 -0
- package/dist/components/v-map.d.ts +11 -0
- package/dist/components/v-map.js +1 -0
- package/dist/components/v-map2.js +1 -0
- package/dist/esm/_commonjsHelpers-E-ZsRS8r.js +32 -0
- package/dist/esm/app-globals-DQuL1Twl.js +3 -0
- package/dist/esm/cesium-provider-BJfAup3w.js +2596 -0
- package/dist/esm/deck-provider-C7U9VDEq.js +47709 -0
- package/dist/esm/geotiff-BEWxTIfH.js +45 -0
- package/dist/esm/geotiff-source-esnDnC-u.js +1516 -0
- package/dist/esm/index-B1zwA4IC.js +685 -0
- package/dist/esm/index-BBpiaTpT.js +165 -0
- package/dist/esm/index-BIEmlzCf.js +1697 -0
- package/dist/esm/index-BUHa4Jj0.js +307 -0
- package/dist/esm/index-DbSdn93t.js +20461 -0
- package/dist/esm/index-RpJarvr_.js +10656 -0
- package/dist/esm/index-jN06TXUp.js +14 -0
- package/dist/esm/index-jzneDarq.js +1613 -0
- package/dist/esm/index.browser-DhQAXuA7.js +6860 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/layer-extension-CZXK5goK.js +63 -0
- package/dist/esm/leaflet-provider-Q41TB6ku.js +1794 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/main-dist-CwnA7_Xn.js +2652 -0
- package/dist/esm/messages-CMKJzsgL.js +180 -0
- package/dist/esm/openlayers-provider-CMsDsQTQ.js +1602 -0
- package/dist/esm/polygon-layer-ByhxGhWC.js +1295 -0
- package/dist/esm/scenegraph-layer-09K_B6DT.js +2526 -0
- package/dist/esm/styleconfig-B-bAcABs.js +21 -0
- package/dist/esm/v-map-builder.entry.js +3784 -0
- package/dist/esm/v-map-layer-geojson_12.entry.js +40881 -0
- package/dist/esm/v-map-layer-helper-Dys44Cgo.js +283 -0
- package/dist/esm/v-map-layer-terrain-geotiff.entry.js +256 -0
- package/dist/esm/v-map-layercontrol.entry.js +245 -0
- package/dist/esm/v-map.js +21 -0
- package/dist/esm/v-map.v-map-layer-osm.v-map-layergroup-B4pFHuSf.js +572 -0
- package/dist/esm/v-map_3.entry.js +4 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/cesium-augment.d.ts +5 -0
- package/dist/types/components/v-map/v-map.d.ts +70 -0
- package/dist/types/components/v-map/v-map.test.d.ts +1 -0
- package/dist/types/components/v-map-builder/v-map-builder.d.ts +48 -0
- package/dist/types/components/v-map-builder/v-map-builder.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-geojson/v-map-layer-geojson.d.ts +129 -0
- package/dist/types/components/v-map-layer-geojson/v-map-layer-geojson.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-geotiff/v-map-layer-geotiff.d.ts +74 -0
- package/dist/types/components/v-map-layer-geotiff/v-map-layer-geotiff.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-google/v-map-layer-google.d.ts +78 -0
- package/dist/types/components/v-map-layer-osm/error-api.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-osm/v-map-layer-osm.d.ts +50 -0
- package/dist/types/components/v-map-layer-osm/v-map-layer-osm.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-scatterplot/v-map-layer-scatterplot.d.ts +54 -0
- package/dist/types/components/v-map-layer-terrain/v-map-layer-terrain.d.ts +74 -0
- package/dist/types/components/v-map-layer-terrain/v-map-layer-terrain.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-terrain-geotiff/v-map-layer-terrain-geotiff.d.ts +117 -0
- package/dist/types/components/v-map-layer-terrain-geotiff/v-map-layer-terrain-geotiff.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-tile3d/v-map-layer-tile3d.d.ts +69 -0
- package/dist/types/components/v-map-layer-tile3d/v-map-layer-tile3d.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-wcs/v-map-layer-wcs.d.ts +47 -0
- package/dist/types/components/v-map-layer-wcs/v-map-layer-wcs.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-wfs/v-map-layer-wfs.d.ts +59 -0
- package/dist/types/components/v-map-layer-wfs/v-map-layer-wfs.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-wkt/v-map-layer-wkt.d.ts +132 -0
- package/dist/types/components/v-map-layer-wkt/v-map-layer-wkt.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-wms/v-map-layer-wms.d.ts +76 -0
- package/dist/types/components/v-map-layer-wms/v-map-layer-wms.test.d.ts +1 -0
- package/dist/types/components/v-map-layer-xyz/v-map-layer-xyz.d.ts +59 -0
- package/dist/types/components/v-map-layer-xyz/v-map-layer-xyz.test.d.ts +1 -0
- package/dist/types/components/v-map-layercontrol/v-map-layercontrol.d.ts +44 -0
- package/dist/types/components/v-map-layercontrol/v-map-layercontrol.test.d.ts +1 -0
- package/dist/types/components/v-map-layergroup/v-map-layergroup.d.ts +31 -0
- package/dist/types/components/v-map-layergroup/v-map-layergroup.test.d.ts +1 -0
- package/dist/types/components/v-map-style/v-map-style.d.ts +75 -0
- package/dist/types/components/v-map-style/v-map-style.unit.d.ts +1 -0
- package/dist/types/components.d.ts +2391 -0
- package/dist/types/globals.d.ts +16 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/layer/v-map-layer-helper.d.ts +45 -0
- package/dist/types/layer/v-map-layer-helper.unit.d.ts +1 -0
- package/dist/types/leaflet-augment.d.ts +15 -0
- package/dist/types/lib/cesium-loader.d.ts +3 -0
- package/dist/types/lib/ensure-importmap.d.ts +3 -0
- package/dist/types/lib/ensure-importmap.unit.d.ts +1 -0
- package/dist/types/lib/versions.gen.d.ts +5 -0
- package/dist/types/lib/vstyle.d.ts +44 -0
- package/dist/types/map-provider/cesium/CesiumGeoTIFFTerrainProvider.d.ts +92 -0
- package/dist/types/map-provider/cesium/CesiumLayerGroups.d.ts +64 -0
- package/dist/types/map-provider/cesium/GeoTIFFImageryProvider.d.ts +75 -0
- package/dist/types/map-provider/cesium/GeoTIFFImageryProvider.test.d.ts +1 -0
- package/dist/types/map-provider/cesium/cesium-provider.d.ts +87 -0
- package/dist/types/map-provider/cesium/i-layer.d.ts +11 -0
- package/dist/types/map-provider/cesium/layer-manager.d.ts +31 -0
- package/dist/types/map-provider/deck/DeckGLGeoTIFFLayer.d.ts +91 -0
- package/dist/types/map-provider/deck/DeckGLGeoTIFFTerrainLayer.d.ts +82 -0
- package/dist/types/map-provider/deck/LayerGroupWithModel.d.ts +55 -0
- package/dist/types/map-provider/deck/LayerGroups.d.ts +63 -0
- package/dist/types/map-provider/deck/LayerModel.d.ts +8 -0
- package/dist/types/map-provider/deck/RenderableGroup.d.ts +20 -0
- package/dist/types/map-provider/deck/deck-provider.d.ts +92 -0
- package/dist/types/map-provider/geotiff/geotiff-source.d.ts +30 -0
- package/dist/types/map-provider/geotiff/utils/AABB2D.d.ts +28 -0
- package/dist/types/map-provider/geotiff/utils/BVHNode2D.d.ts +36 -0
- package/dist/types/map-provider/geotiff/utils/GeoTIFFTileProcessor.d.ts +116 -0
- package/dist/types/map-provider/geotiff/utils/Triangle.d.ts +5 -0
- package/dist/types/map-provider/geotiff/utils/Triangulation.d.ts +94 -0
- package/dist/types/map-provider/geotiff/utils/colormap-utils.d.ts +47 -0
- package/dist/types/map-provider/geotiff/utils/normalization-utils.d.ts +39 -0
- package/dist/types/map-provider/geotiff/utils/sampling-utils.d.ts +13 -0
- package/dist/types/map-provider/leaflet/GeoTIFFGridLayer.d.ts +34 -0
- package/dist/types/map-provider/leaflet/WCSGridLayer.d.ts +38 -0
- package/dist/types/map-provider/leaflet/google-map-tiles-layer.d.ts +73 -0
- package/dist/types/map-provider/leaflet/leaflet-helpers.d.ts +6 -0
- package/dist/types/map-provider/leaflet/leaflet-provider.d.ts +73 -0
- package/dist/types/map-provider/ol/CustomGeoTiff.d.ts +14 -0
- package/dist/types/map-provider/ol/openlayers-helper.d.ts +2 -0
- package/dist/types/map-provider/ol/openlayers-provider.d.ts +80 -0
- package/dist/types/map-provider/provider-factory.d.ts +12 -0
- package/dist/types/map-provider/provider-factory.unit.d.ts +1 -0
- package/dist/types/namespaces.d.ts +3 -0
- package/dist/types/ol-augment.d.ts +3 -0
- package/dist/types/ol-override.d.ts +7 -0
- package/dist/types/ol.d.ts +10 -0
- package/dist/types/stencil-public-runtime.d.ts +1860 -0
- package/dist/types/testing/browser-test-utils.d.ts +6 -0
- package/dist/types/testing/e2e-testing.d.ts +5 -0
- package/dist/types/testing/e2e-utils.d.ts +4 -0
- package/dist/types/testing/geotiff-test-server.d.ts +5 -0
- package/dist/types/testing/mocks/geostyler-lyrx-parser.d.ts +11 -0
- package/dist/types/testing/mocks/geostyler-mapbox-parser.d.ts +11 -0
- package/dist/types/testing/mocks/geostyler-qgis-parser.d.ts +11 -0
- package/dist/types/testing/mocks/geostyler-sld-parser.d.ts +11 -0
- package/dist/types/testing/mocks/geostyler-style.d.ts +5 -0
- package/dist/types/testing/setupTests.browser.d.ts +1 -0
- package/dist/types/testing/setupTests.stencil.d.ts +1 -0
- package/dist/types/testing/setupTests.vitest.d.ts +1 -0
- package/dist/types/testing/stencil-testing-wrapper.d.ts +3 -0
- package/dist/types/types/color.d.ts +1 -0
- package/dist/types/types/cssmode.d.ts +1 -0
- package/dist/types/types/flavour.d.ts +1 -0
- package/dist/types/types/layerconfig.d.ts +207 -0
- package/dist/types/types/lonlat.d.ts +1 -0
- package/dist/types/types/mapinitoptions.d.ts +4 -0
- package/dist/types/types/mapprovider.d.ts +46 -0
- package/dist/types/types/provideroptions.d.ts +8 -0
- package/dist/types/types/styleconfig.d.ts +27 -0
- package/dist/types/types/styling.d.ts +24 -0
- package/dist/types/types/styling.unit.d.ts +1 -0
- package/dist/types/types/vmaplayer.d.ts +10 -0
- package/dist/types/utils/async-mutex.d.ts +7 -0
- package/dist/types/utils/diff.d.ts +64 -0
- package/dist/types/utils/diff.unit.d.ts +1 -0
- package/dist/types/utils/dom-env.d.ts +5 -0
- package/dist/types/utils/dom-env.unit.d.ts +1 -0
- package/dist/types/utils/events.d.ts +29 -0
- package/dist/types/utils/logger.d.ts +47 -0
- package/dist/types/utils/logger.unit.d.ts +1 -0
- package/dist/types/utils/messages.d.ts +12 -0
- package/dist/types/utils/spatial-utils.d.ts +6 -0
- package/dist/types/utils/spatial-utils.unit.d.ts +1 -0
- package/dist/types/versions.d.ts +7 -0
- package/dist/v-map/index.esm.js +0 -0
- package/dist/v-map/p--vVleK-M.js +1 -0
- package/dist/v-map/p-09d10db0.entry.js +1 -0
- package/dist/v-map/p-5eba6058.entry.js +10 -0
- package/dist/v-map/p-6b102336.entry.js +1 -0
- package/dist/v-map/p-B-bAcABs.js +1 -0
- package/dist/v-map/p-BBpiaTpT.js +1 -0
- package/dist/v-map/p-BdijL4Av.js +1 -0
- package/dist/v-map/p-Be3r33VF.js +4 -0
- package/dist/v-map/p-BeFu0ap4.js +1 -0
- package/dist/v-map/p-BxFJezdK.js +1 -0
- package/dist/v-map/p-CMKJzsgL.js +1 -0
- package/dist/v-map/p-CXfA_q8m.js +1 -0
- package/dist/v-map/p-CZqY0yW4.js +1 -0
- package/dist/v-map/p-CafTHT9i.js +1 -0
- package/dist/v-map/p-DCTHyf58.js +1 -0
- package/dist/v-map/p-DQuL1Twl.js +1 -0
- package/dist/v-map/p-DR9McdNX.js +1 -0
- package/dist/v-map/p-Dckgonw8.js +1 -0
- package/dist/v-map/p-DhQAXuA7.js +15 -0
- package/dist/v-map/p-DmICdG34.js +7 -0
- package/dist/v-map/p-DrOQ9V4h.js +1 -0
- package/dist/v-map/p-DvHXtWUg.js +1 -0
- package/dist/v-map/p-E-ZsRS8r.js +1 -0
- package/dist/v-map/p-MyTSFnEk.js +1 -0
- package/dist/v-map/p-RpJarvr_.js +1 -0
- package/dist/v-map/p-WaMDUuAz.js +1 -0
- package/dist/v-map/p-aa410e64.entry.js +2 -0
- package/dist/v-map/p-c21c93fe.entry.js +1 -0
- package/dist/v-map/p-jzneDarq.js +2 -0
- package/dist/v-map/p-uiIP-taz.js +1 -0
- package/dist/v-map/v-map.esm.js +1 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +193 -0
|
@@ -0,0 +1,1765 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var deckProvider = require('./deck-provider-Ctq3Q8a1.js');
|
|
4
|
+
var layerExtension = require('./layer-extension-B_olS0rc.js');
|
|
5
|
+
require('./styleconfig-CVRqArk-.js');
|
|
6
|
+
require('./index.browser-DQhD8Jwl.js');
|
|
7
|
+
require('./index-BIL4VsgP.js');
|
|
8
|
+
require('./_commonjsHelpers-B83fTs8d.js');
|
|
9
|
+
require('./messages-D7h4m8Tx.js');
|
|
10
|
+
require('./geotiff-source-RaNzzWkC.js');
|
|
11
|
+
require('@loaders.gl/core');
|
|
12
|
+
require('@loaders.gl/images');
|
|
13
|
+
require('@loaders.gl/loader-utils');
|
|
14
|
+
require('@loaders.gl/terrain');
|
|
15
|
+
require('@loaders.gl/schema');
|
|
16
|
+
|
|
17
|
+
// math.gl
|
|
18
|
+
// SPDX-License-Identifier: MIT
|
|
19
|
+
// Copyright (c) vis.gl contributors
|
|
20
|
+
// Copyright (c) 2017 Uber Technologies, Inc.
|
|
21
|
+
// TODO - import epsilon
|
|
22
|
+
const EPSILON$1 = 0.000001;
|
|
23
|
+
const EARTH_RADIUS_METERS = 6371000;
|
|
24
|
+
/**
|
|
25
|
+
* The poles (phi) are at the positive and negative y axis.
|
|
26
|
+
* The equator starts at positive z.
|
|
27
|
+
* @link https://en.wikipedia.org/wiki/Spherical_coordinate_system
|
|
28
|
+
*/
|
|
29
|
+
class SphericalCoordinates {
|
|
30
|
+
// bearing: number;
|
|
31
|
+
// pitch: number;
|
|
32
|
+
// altitude: number;
|
|
33
|
+
// lnglatZ coordinates
|
|
34
|
+
// longitude: number;
|
|
35
|
+
// latitude: number;
|
|
36
|
+
// lng: number;
|
|
37
|
+
// lat: number;
|
|
38
|
+
// z: number;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a new SphericalCoordinates object
|
|
41
|
+
* @param options
|
|
42
|
+
* @param [options.phi] =0 - rotation around X (latitude)
|
|
43
|
+
* @param [options.theta] =0 - rotation around Y (longitude)
|
|
44
|
+
* @param [options.radius] =1 - Distance from center
|
|
45
|
+
* @param [options.bearing]
|
|
46
|
+
* @param [options.pitch]
|
|
47
|
+
* @param [options.altitude]
|
|
48
|
+
* @param [options.radiusScale] =1
|
|
49
|
+
*/
|
|
50
|
+
// eslint-disable-next-line complexity
|
|
51
|
+
constructor({ phi = 0, theta = 0, radius = 1, bearing, pitch, altitude, radiusScale = EARTH_RADIUS_METERS } = {}) {
|
|
52
|
+
this.phi = phi;
|
|
53
|
+
this.theta = theta;
|
|
54
|
+
// TODO - silently accepts illegal 0
|
|
55
|
+
this.radius = radius || altitude || 1; // radial distance from center
|
|
56
|
+
this.radiusScale = radiusScale || 1; // Used by lngLatZ
|
|
57
|
+
if (bearing !== undefined) {
|
|
58
|
+
this.bearing = bearing; // up / down towards top and bottom pole
|
|
59
|
+
}
|
|
60
|
+
if (pitch !== undefined) {
|
|
61
|
+
this.pitch = pitch; // around the equator of the sphere
|
|
62
|
+
}
|
|
63
|
+
this.check();
|
|
64
|
+
}
|
|
65
|
+
toString() {
|
|
66
|
+
return this.formatString(deckProvider.config);
|
|
67
|
+
}
|
|
68
|
+
formatString({ printTypes = false }) {
|
|
69
|
+
const f = deckProvider.formatValue;
|
|
70
|
+
return `${printTypes ? 'Spherical' : ''}\
|
|
71
|
+
[rho:${f(this.radius)},theta:${f(this.theta)},phi:${f(this.phi)}]`;
|
|
72
|
+
}
|
|
73
|
+
equals(other) {
|
|
74
|
+
return (deckProvider.equals(this.radius, other.radius) &&
|
|
75
|
+
deckProvider.equals(this.theta, other.theta) &&
|
|
76
|
+
deckProvider.equals(this.phi, other.phi));
|
|
77
|
+
}
|
|
78
|
+
exactEquals(other) {
|
|
79
|
+
return this.radius === other.radius && this.theta === other.theta && this.phi === other.phi;
|
|
80
|
+
}
|
|
81
|
+
/* eslint-disable brace-style */
|
|
82
|
+
// Cartographic (bearing 0 north, pitch 0 look from above)
|
|
83
|
+
get bearing() {
|
|
84
|
+
return 180 - deckProvider.degrees(this.phi);
|
|
85
|
+
}
|
|
86
|
+
set bearing(v) {
|
|
87
|
+
this.phi = Math.PI - deckProvider.radians(v);
|
|
88
|
+
}
|
|
89
|
+
get pitch() {
|
|
90
|
+
return deckProvider.degrees(this.theta);
|
|
91
|
+
}
|
|
92
|
+
set pitch(v) {
|
|
93
|
+
this.theta = deckProvider.radians(v);
|
|
94
|
+
}
|
|
95
|
+
// get pitch() { return 90 - degrees(this.phi); }
|
|
96
|
+
// set pitch(v) { this.phi = radians(v) + Math.PI / 2; }
|
|
97
|
+
// get altitude() { return this.radius - 1; } // relative altitude
|
|
98
|
+
// lnglatZ coordinates
|
|
99
|
+
get longitude() {
|
|
100
|
+
return deckProvider.degrees(this.phi);
|
|
101
|
+
}
|
|
102
|
+
get latitude() {
|
|
103
|
+
return deckProvider.degrees(this.theta);
|
|
104
|
+
}
|
|
105
|
+
get lng() {
|
|
106
|
+
return deckProvider.degrees(this.phi);
|
|
107
|
+
}
|
|
108
|
+
get lat() {
|
|
109
|
+
return deckProvider.degrees(this.theta);
|
|
110
|
+
}
|
|
111
|
+
get z() {
|
|
112
|
+
return (this.radius - 1) * this.radiusScale;
|
|
113
|
+
}
|
|
114
|
+
/* eslint-enable brace-style */
|
|
115
|
+
set(radius, phi, theta) {
|
|
116
|
+
this.radius = radius;
|
|
117
|
+
this.phi = phi;
|
|
118
|
+
this.theta = theta;
|
|
119
|
+
return this.check();
|
|
120
|
+
}
|
|
121
|
+
clone() {
|
|
122
|
+
return new SphericalCoordinates().copy(this);
|
|
123
|
+
}
|
|
124
|
+
copy(other) {
|
|
125
|
+
this.radius = other.radius;
|
|
126
|
+
this.phi = other.phi;
|
|
127
|
+
this.theta = other.theta;
|
|
128
|
+
return this.check();
|
|
129
|
+
}
|
|
130
|
+
fromLngLatZ([lng, lat, z]) {
|
|
131
|
+
this.radius = 1 + z / this.radiusScale;
|
|
132
|
+
this.phi = deckProvider.radians(lat);
|
|
133
|
+
this.theta = deckProvider.radians(lng);
|
|
134
|
+
return this.check();
|
|
135
|
+
}
|
|
136
|
+
fromVector3(v) {
|
|
137
|
+
this.radius = deckProvider.length(v);
|
|
138
|
+
if (this.radius > 0) {
|
|
139
|
+
this.theta = Math.atan2(v[0], v[1]); // equator angle around y-up axis
|
|
140
|
+
this.phi = Math.acos(deckProvider.clamp(v[2] / this.radius, -1, 1)); // polar angle
|
|
141
|
+
}
|
|
142
|
+
return this.check();
|
|
143
|
+
}
|
|
144
|
+
toVector3() {
|
|
145
|
+
return new deckProvider.Vector3(0, 0, this.radius)
|
|
146
|
+
.rotateX({ radians: this.theta })
|
|
147
|
+
.rotateZ({ radians: this.phi });
|
|
148
|
+
}
|
|
149
|
+
// restrict phi to be betwee EPS and PI-EPS
|
|
150
|
+
makeSafe() {
|
|
151
|
+
this.phi = Math.max(EPSILON$1, Math.min(Math.PI - EPSILON$1, this.phi));
|
|
152
|
+
return this;
|
|
153
|
+
}
|
|
154
|
+
check() {
|
|
155
|
+
// this.makeSafe();
|
|
156
|
+
if (!Number.isFinite(this.phi) || !Number.isFinite(this.theta) || !(this.radius > 0)) {
|
|
157
|
+
throw new Error('SphericalCoordinates: some fields set to invalid numbers');
|
|
158
|
+
}
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const EPSILON = 0.01;
|
|
164
|
+
const VIEWPORT_TRANSITION_PROPS = ['longitude', 'latitude', 'zoom'];
|
|
165
|
+
const DEFAULT_OPTS$1 = {
|
|
166
|
+
curve: 1.414,
|
|
167
|
+
speed: 1.2
|
|
168
|
+
// screenSpeed and maxDuration are used only if specified
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* mapbox-gl-js flyTo : https://www.mapbox.com/mapbox-gl-js/api/#map#flyto.
|
|
172
|
+
* It implements “Smooth and efficient zooming and panning.” algorithm by
|
|
173
|
+
* "Jarke J. van Wijk and Wim A.A. Nuij"
|
|
174
|
+
*/
|
|
175
|
+
function flyToViewport(startProps, endProps, t, options) {
|
|
176
|
+
// Equations from above paper are referred where needed.
|
|
177
|
+
const { startZoom, startCenterXY, uDelta, w0, u1, S, rho, rho2, r0 } = getFlyToTransitionParams(startProps, endProps, options);
|
|
178
|
+
// If change in center is too small, do linear interpolaiton.
|
|
179
|
+
if (u1 < EPSILON) {
|
|
180
|
+
const viewport = {};
|
|
181
|
+
for (const key of VIEWPORT_TRANSITION_PROPS) {
|
|
182
|
+
const startValue = startProps[key];
|
|
183
|
+
const endValue = endProps[key];
|
|
184
|
+
// @ts-ignore-error properties are populated dynamically
|
|
185
|
+
viewport[key] = deckProvider.lerp(startValue, endValue, t);
|
|
186
|
+
}
|
|
187
|
+
// @ts-expect-error properties are populated dynamically
|
|
188
|
+
return viewport;
|
|
189
|
+
}
|
|
190
|
+
const s = t * S;
|
|
191
|
+
const w = Math.cosh(r0) / Math.cosh(r0 + rho * s);
|
|
192
|
+
const u = (w0 * ((Math.cosh(r0) * Math.tanh(r0 + rho * s) - Math.sinh(r0)) / rho2)) / u1;
|
|
193
|
+
const scaleIncrement = 1 / w; // Using w method for scaling.
|
|
194
|
+
const newZoom = startZoom + deckProvider.scaleToZoom(scaleIncrement);
|
|
195
|
+
const newCenterWorld = deckProvider.scale([], uDelta, u);
|
|
196
|
+
deckProvider.add(newCenterWorld, newCenterWorld, startCenterXY);
|
|
197
|
+
const newCenter = deckProvider.worldToLngLat(newCenterWorld);
|
|
198
|
+
return {
|
|
199
|
+
longitude: newCenter[0],
|
|
200
|
+
latitude: newCenter[1],
|
|
201
|
+
zoom: newZoom
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
// returns transition duration in milliseconds
|
|
205
|
+
function getFlyToDuration(startProps, endProps, options) {
|
|
206
|
+
const opts = { ...DEFAULT_OPTS$1, ...options };
|
|
207
|
+
const { screenSpeed, speed, maxDuration } = opts;
|
|
208
|
+
const { S, rho } = getFlyToTransitionParams(startProps, endProps, opts);
|
|
209
|
+
const length = 1000 * S;
|
|
210
|
+
let duration;
|
|
211
|
+
if (Number.isFinite(screenSpeed)) {
|
|
212
|
+
duration = length / (screenSpeed / rho);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
duration = length / speed;
|
|
216
|
+
}
|
|
217
|
+
return Number.isFinite(maxDuration) && duration > maxDuration ? 0 : duration;
|
|
218
|
+
}
|
|
219
|
+
// Private Methods
|
|
220
|
+
// Calculate all parameters that are static for given startProps and endProps
|
|
221
|
+
function getFlyToTransitionParams(startProps, endProps, opts) {
|
|
222
|
+
opts = Object.assign({}, DEFAULT_OPTS$1, opts);
|
|
223
|
+
const rho = opts.curve;
|
|
224
|
+
const startZoom = startProps.zoom;
|
|
225
|
+
const startCenter = [startProps.longitude, startProps.latitude];
|
|
226
|
+
const startScale = deckProvider.zoomToScale(startZoom);
|
|
227
|
+
const endZoom = endProps.zoom;
|
|
228
|
+
const endCenter = [endProps.longitude, endProps.latitude];
|
|
229
|
+
const scale = deckProvider.zoomToScale(endZoom - startZoom);
|
|
230
|
+
const startCenterXY = deckProvider.lngLatToWorld(startCenter);
|
|
231
|
+
const endCenterXY = deckProvider.lngLatToWorld(endCenter);
|
|
232
|
+
const uDelta = deckProvider.sub([], endCenterXY, startCenterXY);
|
|
233
|
+
const w0 = Math.max(startProps.width, startProps.height);
|
|
234
|
+
const w1 = w0 / scale;
|
|
235
|
+
const u1 = deckProvider.length$1(uDelta) * startScale;
|
|
236
|
+
// u0 is treated as '0' in Eq (9).
|
|
237
|
+
// If u1 is too small, will generate invalid number
|
|
238
|
+
const _u1 = Math.max(u1, EPSILON);
|
|
239
|
+
// Implement Equation (9) from above algorithm.
|
|
240
|
+
const rho2 = rho * rho;
|
|
241
|
+
const b0 = (w1 * w1 - w0 * w0 + rho2 * rho2 * _u1 * _u1) / (2 * w0 * rho2 * _u1);
|
|
242
|
+
const b1 = (w1 * w1 - w0 * w0 - rho2 * rho2 * _u1 * _u1) / (2 * w1 * rho2 * _u1);
|
|
243
|
+
const r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0);
|
|
244
|
+
const r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);
|
|
245
|
+
const S = (r1 - r0) / rho;
|
|
246
|
+
return { startZoom, startCenterXY, uDelta, w0, u1, S, rho, rho2, r0, r1 };
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// deck.gl
|
|
250
|
+
// SPDX-License-Identifier: MIT
|
|
251
|
+
// Copyright (c) vis.gl contributors
|
|
252
|
+
const DEFAULT_LIGHT_COLOR = [255, 255, 255];
|
|
253
|
+
const DEFAULT_LIGHT_INTENSITY = 1.0;
|
|
254
|
+
const DEFAULT_ATTENUATION = [1, 0, 0];
|
|
255
|
+
const DEFAULT_LIGHT_POSITION = [0.0, 0.0, 1.0];
|
|
256
|
+
let idCount = 0;
|
|
257
|
+
class PointLight {
|
|
258
|
+
constructor(props = {}) {
|
|
259
|
+
this.type = 'point';
|
|
260
|
+
const { color = DEFAULT_LIGHT_COLOR } = props;
|
|
261
|
+
const { intensity = DEFAULT_LIGHT_INTENSITY } = props;
|
|
262
|
+
const { position = DEFAULT_LIGHT_POSITION } = props;
|
|
263
|
+
this.id = props.id || `point-${idCount++}`;
|
|
264
|
+
this.color = color;
|
|
265
|
+
this.intensity = intensity;
|
|
266
|
+
this.type = 'point';
|
|
267
|
+
this.position = position;
|
|
268
|
+
this.attenuation = getAttenuation(props);
|
|
269
|
+
this.projectedLight = { ...this };
|
|
270
|
+
}
|
|
271
|
+
getProjectedLight({ layer }) {
|
|
272
|
+
const { projectedLight } = this;
|
|
273
|
+
const viewport = layer.context.viewport;
|
|
274
|
+
const { coordinateSystem, coordinateOrigin } = layer.props;
|
|
275
|
+
const position = deckProvider.projectPosition(this.position, {
|
|
276
|
+
viewport,
|
|
277
|
+
coordinateSystem,
|
|
278
|
+
coordinateOrigin,
|
|
279
|
+
fromCoordinateSystem: viewport.isGeospatial
|
|
280
|
+
? deckProvider.COORDINATE_SYSTEM.LNGLAT
|
|
281
|
+
: deckProvider.COORDINATE_SYSTEM.CARTESIAN,
|
|
282
|
+
fromCoordinateOrigin: [0, 0, 0]
|
|
283
|
+
});
|
|
284
|
+
projectedLight.color = this.color;
|
|
285
|
+
projectedLight.intensity = this.intensity;
|
|
286
|
+
projectedLight.position = position;
|
|
287
|
+
return projectedLight;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
function getAttenuation(props) {
|
|
291
|
+
if (props.attenuation) {
|
|
292
|
+
return props.attenuation;
|
|
293
|
+
}
|
|
294
|
+
return DEFAULT_ATTENUATION;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// deck.gl
|
|
298
|
+
// SPDX-License-Identifier: MIT
|
|
299
|
+
// Copyright (c) vis.gl contributors
|
|
300
|
+
class CameraLight extends PointLight {
|
|
301
|
+
getProjectedLight({ layer }) {
|
|
302
|
+
const { projectedLight } = this;
|
|
303
|
+
const viewport = layer.context.viewport;
|
|
304
|
+
const { coordinateSystem, coordinateOrigin, modelMatrix } = layer.props;
|
|
305
|
+
const { cameraPosition } = deckProvider.getUniformsFromViewport({
|
|
306
|
+
viewport,
|
|
307
|
+
modelMatrix: modelMatrix,
|
|
308
|
+
coordinateSystem,
|
|
309
|
+
coordinateOrigin
|
|
310
|
+
});
|
|
311
|
+
projectedLight.color = this.color;
|
|
312
|
+
projectedLight.intensity = this.intensity;
|
|
313
|
+
projectedLight.position = cameraPosition;
|
|
314
|
+
return projectedLight;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const DEGREES_TO_RADIANS$1 = Math.PI / 180;
|
|
319
|
+
const DAY_IN_MS = 1000 * 60 * 60 * 24;
|
|
320
|
+
const JD1970 = 2440588; // Julian Day year 1970
|
|
321
|
+
const JD2000 = 2451545; // Julian Day year 2000
|
|
322
|
+
// This angle ε [epsilon] is called the obliquity of the ecliptic and its value at the beginning of 2000 was 23.4397°
|
|
323
|
+
const e = DEGREES_TO_RADIANS$1 * 23.4397; // obliquity of the Earth
|
|
324
|
+
// Refer https://www.aa.quae.nl/en/reken/zonpositie.html
|
|
325
|
+
// "The Mean Anomaly" section for explanation
|
|
326
|
+
const M0 = 357.5291; // Earth mean anomaly on start day
|
|
327
|
+
const M1 = 0.98560028; // Earth angle traverses on average per day seen from the sun
|
|
328
|
+
const THETA0 = 280.147; // The sidereal time (in degrees) at longitude 0° at the instant defined by JD2000
|
|
329
|
+
const THETA1 = 360.9856235; // The rate of change of the sidereal time, in degrees per day.
|
|
330
|
+
/**
|
|
331
|
+
* Calculate sun position
|
|
332
|
+
* based on https://www.aa.quae.nl/en/reken/zonpositie.html
|
|
333
|
+
* inspired by https://github.com/mourner/suncalc/blob/master/suncalc.js
|
|
334
|
+
*/
|
|
335
|
+
function getSunPosition(timestamp, latitude, longitude) {
|
|
336
|
+
const longitudeWestInRadians = DEGREES_TO_RADIANS$1 * -longitude;
|
|
337
|
+
const phi = DEGREES_TO_RADIANS$1 * latitude;
|
|
338
|
+
const d = toDays(timestamp);
|
|
339
|
+
const c = getSunCoords(d);
|
|
340
|
+
// hour angle
|
|
341
|
+
const H = getSiderealTime(d, longitudeWestInRadians) - c.rightAscension;
|
|
342
|
+
return {
|
|
343
|
+
azimuth: getAzimuth(H, phi, c.declination),
|
|
344
|
+
altitude: getAltitude(H, phi, c.declination)
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
function getSunDirection(timestamp, latitude, longitude) {
|
|
348
|
+
const { azimuth, altitude } = getSunPosition(timestamp, latitude, longitude);
|
|
349
|
+
// solar position to light direction
|
|
350
|
+
return [
|
|
351
|
+
Math.sin(azimuth) * Math.cos(altitude),
|
|
352
|
+
Math.cos(azimuth) * Math.cos(altitude),
|
|
353
|
+
-Math.sin(altitude)
|
|
354
|
+
];
|
|
355
|
+
}
|
|
356
|
+
function toJulianDay(timestamp) {
|
|
357
|
+
const ts = typeof timestamp === 'number' ? timestamp : timestamp.getTime();
|
|
358
|
+
return ts / DAY_IN_MS - 0.5 + JD1970;
|
|
359
|
+
}
|
|
360
|
+
function toDays(timestamp) {
|
|
361
|
+
return toJulianDay(timestamp) - JD2000;
|
|
362
|
+
}
|
|
363
|
+
function getRightAscension(eclipticLongitude, b) {
|
|
364
|
+
const lambda = eclipticLongitude;
|
|
365
|
+
return Math.atan2(Math.sin(lambda) * Math.cos(e) - Math.tan(b) * Math.sin(e), Math.cos(lambda));
|
|
366
|
+
}
|
|
367
|
+
function getDeclination(eclipticLongitude, b) {
|
|
368
|
+
const lambda = eclipticLongitude;
|
|
369
|
+
return Math.asin(Math.sin(b) * Math.cos(e) + Math.cos(b) * Math.sin(e) * Math.sin(lambda));
|
|
370
|
+
}
|
|
371
|
+
function getAzimuth(hourAngle, latitudeInRadians, declination) {
|
|
372
|
+
const H = hourAngle;
|
|
373
|
+
const phi = latitudeInRadians;
|
|
374
|
+
const delta = declination;
|
|
375
|
+
return Math.atan2(Math.sin(H), Math.cos(H) * Math.sin(phi) - Math.tan(delta) * Math.cos(phi));
|
|
376
|
+
}
|
|
377
|
+
function getAltitude(hourAngle, latitudeInRadians, declination) {
|
|
378
|
+
const H = hourAngle;
|
|
379
|
+
const phi = latitudeInRadians;
|
|
380
|
+
const delta = declination;
|
|
381
|
+
return Math.asin(Math.sin(phi) * Math.sin(delta) + Math.cos(phi) * Math.cos(delta) * Math.cos(H));
|
|
382
|
+
}
|
|
383
|
+
// https://www.aa.quae.nl/en/reken/zonpositie.html
|
|
384
|
+
// "The Observer section"
|
|
385
|
+
function getSiderealTime(dates, longitudeWestInRadians) {
|
|
386
|
+
return DEGREES_TO_RADIANS$1 * (THETA0 + THETA1 * dates) - longitudeWestInRadians;
|
|
387
|
+
}
|
|
388
|
+
function getSolarMeanAnomaly(days) {
|
|
389
|
+
return DEGREES_TO_RADIANS$1 * (M0 + M1 * days);
|
|
390
|
+
}
|
|
391
|
+
function getEclipticLongitude(meanAnomaly) {
|
|
392
|
+
const M = meanAnomaly;
|
|
393
|
+
// equation of center
|
|
394
|
+
const C = DEGREES_TO_RADIANS$1 * (1.9148 * Math.sin(M) + 0.02 * Math.sin(2 * M) + 0.0003 * Math.sin(3 * M));
|
|
395
|
+
// perihelion of the Earth
|
|
396
|
+
const P = DEGREES_TO_RADIANS$1 * 102.9372;
|
|
397
|
+
return M + C + P + Math.PI;
|
|
398
|
+
}
|
|
399
|
+
function getSunCoords(dates) {
|
|
400
|
+
const M = getSolarMeanAnomaly(dates);
|
|
401
|
+
const L = getEclipticLongitude(M);
|
|
402
|
+
return {
|
|
403
|
+
declination: getDeclination(L, 0),
|
|
404
|
+
rightAscension: getRightAscension(L, 0)
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// deck.gl
|
|
409
|
+
// SPDX-License-Identifier: MIT
|
|
410
|
+
// Copyright (c) vis.gl contributors
|
|
411
|
+
class SunLight extends deckProvider.DirectionalLight {
|
|
412
|
+
constructor(opts) {
|
|
413
|
+
super(opts);
|
|
414
|
+
this.timestamp = opts.timestamp;
|
|
415
|
+
}
|
|
416
|
+
getProjectedLight({ layer }) {
|
|
417
|
+
const { viewport } = layer.context;
|
|
418
|
+
const isGlobe = viewport.resolution && viewport.resolution > 0;
|
|
419
|
+
if (isGlobe) {
|
|
420
|
+
// Rotate vector to align with the direction of the globe projection (up at lon:0,lat:0 is [0, -1, 0])
|
|
421
|
+
const [x, y, z] = getSunDirection(this.timestamp, 0, 0);
|
|
422
|
+
this.direction = [x, -z, y];
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
// @ts-expect-error longitude and latitude are not defined on all viewports
|
|
426
|
+
const { latitude, longitude } = viewport;
|
|
427
|
+
this.direction = getSunDirection(this.timestamp, latitude, longitude);
|
|
428
|
+
}
|
|
429
|
+
return this;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// luma.gl
|
|
434
|
+
// SPDX-License-Identifier: MIT
|
|
435
|
+
// Copyright (c) vis.gl contributors
|
|
436
|
+
const CLIPSPACE_VERTEX_SHADER_WGSL = /* wgsl */ `\
|
|
437
|
+
struct VertexInputs {
|
|
438
|
+
@location(0) clipSpacePosition: vec2<f32>,
|
|
439
|
+
@location(1) texCoord: vec2<f32>,
|
|
440
|
+
@location(2) coordinate: vec2<f32>
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
struct FragmentInputs {
|
|
444
|
+
@builtin(position) Position : vec4<f32>,
|
|
445
|
+
@location(0) position : vec2<f32>,
|
|
446
|
+
@location(1) coordinate : vec2<f32>,
|
|
447
|
+
@location(2) uv : vec2<f32>
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
@vertex
|
|
451
|
+
fn vertexMain(inputs: VertexInputs) -> FragmentInputs {
|
|
452
|
+
var outputs: FragmentInputs;
|
|
453
|
+
outputs.Position = vec4(inputs.clipSpacePosition, 0., 1.);
|
|
454
|
+
outputs.position = inputs.clipSpacePosition;
|
|
455
|
+
outputs.coordinate = inputs.coordinate;
|
|
456
|
+
outputs.uv = inputs.texCoord;
|
|
457
|
+
return outputs;
|
|
458
|
+
}
|
|
459
|
+
`;
|
|
460
|
+
const CLIPSPACE_VERTEX_SHADER = /* glsl */ `\
|
|
461
|
+
#version 300 es
|
|
462
|
+
in vec2 clipSpacePositions;
|
|
463
|
+
in vec2 texCoords;
|
|
464
|
+
in vec2 coordinates;
|
|
465
|
+
|
|
466
|
+
out vec2 position;
|
|
467
|
+
out vec2 coordinate;
|
|
468
|
+
out vec2 uv;
|
|
469
|
+
|
|
470
|
+
void main(void) {
|
|
471
|
+
gl_Position = vec4(clipSpacePositions, 0., 1.);
|
|
472
|
+
position = clipSpacePositions;
|
|
473
|
+
coordinate = coordinates;
|
|
474
|
+
uv = texCoords;
|
|
475
|
+
}
|
|
476
|
+
`;
|
|
477
|
+
/* eslint-disable indent, no-multi-spaces */
|
|
478
|
+
const POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];
|
|
479
|
+
/**
|
|
480
|
+
* A flat geometry that covers the "visible area" that the GPU renders.
|
|
481
|
+
*/
|
|
482
|
+
class ClipSpace extends deckProvider.Model {
|
|
483
|
+
constructor(device, props) {
|
|
484
|
+
const TEX_COORDS = POSITIONS.map(coord => (coord === -1 ? 0 : coord));
|
|
485
|
+
// For WGSL we need to append the supplied fragment shader to the default vertex shader source
|
|
486
|
+
if (props.source) {
|
|
487
|
+
props = { ...props, source: `${CLIPSPACE_VERTEX_SHADER_WGSL}\n${props.source}` };
|
|
488
|
+
}
|
|
489
|
+
super(device, {
|
|
490
|
+
id: props.id || deckProvider.uid('clip-space'),
|
|
491
|
+
...props,
|
|
492
|
+
vs: CLIPSPACE_VERTEX_SHADER,
|
|
493
|
+
vertexCount: 4,
|
|
494
|
+
geometry: new deckProvider.Geometry({
|
|
495
|
+
topology: 'triangle-strip',
|
|
496
|
+
vertexCount: 4,
|
|
497
|
+
attributes: {
|
|
498
|
+
clipSpacePositions: { size: 2, value: new Float32Array(POSITIONS) },
|
|
499
|
+
texCoords: { size: 2, value: new Float32Array(TEX_COORDS) },
|
|
500
|
+
coordinates: { size: 2, value: new Float32Array(TEX_COORDS) }
|
|
501
|
+
}
|
|
502
|
+
})
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// deck.gl
|
|
508
|
+
// SPDX-License-Identifier: MIT
|
|
509
|
+
// Copyright (c) vis.gl contributors
|
|
510
|
+
const uniformBlock = `\
|
|
511
|
+
uniform screenUniforms {
|
|
512
|
+
vec2 texSize;
|
|
513
|
+
} screen;
|
|
514
|
+
`;
|
|
515
|
+
const screenUniforms = {
|
|
516
|
+
name: 'screen',
|
|
517
|
+
fs: uniformBlock,
|
|
518
|
+
uniformTypes: {
|
|
519
|
+
texSize: 'vec2<f32>'
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
// deck.gl
|
|
524
|
+
// SPDX-License-Identifier: MIT
|
|
525
|
+
// Copyright (c) vis.gl contributors
|
|
526
|
+
/** A base render pass. */
|
|
527
|
+
class ScreenPass extends deckProvider.Pass {
|
|
528
|
+
constructor(device, props) {
|
|
529
|
+
super(device, props);
|
|
530
|
+
const { module, fs, id } = props;
|
|
531
|
+
const parameters = {
|
|
532
|
+
depthWriteEnabled: false,
|
|
533
|
+
depthCompare: 'always',
|
|
534
|
+
depthBias: 0,
|
|
535
|
+
blend: true,
|
|
536
|
+
blendColorSrcFactor: 'one',
|
|
537
|
+
blendColorDstFactor: 'one-minus-src-alpha',
|
|
538
|
+
blendAlphaSrcFactor: 'one',
|
|
539
|
+
blendAlphaDstFactor: 'one-minus-src-alpha',
|
|
540
|
+
blendColorOperation: 'add',
|
|
541
|
+
blendAlphaOperation: 'add'
|
|
542
|
+
};
|
|
543
|
+
this.model = new ClipSpace(device, { id, fs, modules: [module, screenUniforms], parameters });
|
|
544
|
+
}
|
|
545
|
+
render(params) {
|
|
546
|
+
this._renderPass(this.device, params);
|
|
547
|
+
}
|
|
548
|
+
delete() {
|
|
549
|
+
this.model.destroy();
|
|
550
|
+
this.model = null;
|
|
551
|
+
}
|
|
552
|
+
// Private methods
|
|
553
|
+
/**
|
|
554
|
+
* Renders the pass.
|
|
555
|
+
* This is an abstract method that should be overridden.
|
|
556
|
+
* @param inputBuffer - Frame buffer that contains the result of the previous pass
|
|
557
|
+
* @param outputBuffer - Frame buffer that serves as the output render target
|
|
558
|
+
*/
|
|
559
|
+
_renderPass(device, options) {
|
|
560
|
+
const { clearCanvas, inputBuffer, outputBuffer } = options;
|
|
561
|
+
const texSize = [inputBuffer.width, inputBuffer.height];
|
|
562
|
+
const screenProps = {
|
|
563
|
+
texSrc: inputBuffer.colorAttachments[0],
|
|
564
|
+
texSize
|
|
565
|
+
};
|
|
566
|
+
this.model.shaderInputs.setProps({
|
|
567
|
+
screen: screenProps,
|
|
568
|
+
...options.moduleProps
|
|
569
|
+
});
|
|
570
|
+
const renderPass = this.device.beginRenderPass({
|
|
571
|
+
framebuffer: outputBuffer,
|
|
572
|
+
parameters: { viewport: [0, 0, ...texSize] },
|
|
573
|
+
clearColor: clearCanvas ? [0, 0, 0, 0] : false,
|
|
574
|
+
clearDepth: 1,
|
|
575
|
+
clearStencil: false
|
|
576
|
+
});
|
|
577
|
+
this.model.draw(renderPass);
|
|
578
|
+
renderPass.end();
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// deck.gl
|
|
583
|
+
// SPDX-License-Identifier: MIT
|
|
584
|
+
// Copyright (c) vis.gl contributors
|
|
585
|
+
class PostProcessEffect {
|
|
586
|
+
constructor(module, props) {
|
|
587
|
+
this.id = `${module.name}-pass`;
|
|
588
|
+
this.props = props;
|
|
589
|
+
deckProvider.initializeShaderModule(module);
|
|
590
|
+
this.module = module;
|
|
591
|
+
}
|
|
592
|
+
setup({ device }) {
|
|
593
|
+
this.passes = createPasses(device, this.module, this.id);
|
|
594
|
+
}
|
|
595
|
+
setProps(props) {
|
|
596
|
+
this.props = props;
|
|
597
|
+
}
|
|
598
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
599
|
+
preRender() { }
|
|
600
|
+
postRender(params) {
|
|
601
|
+
const passes = this.passes;
|
|
602
|
+
const { target } = params;
|
|
603
|
+
let inputBuffer = params.inputBuffer;
|
|
604
|
+
let outputBuffer = params.swapBuffer;
|
|
605
|
+
for (let index = 0; index < passes.length; index++) {
|
|
606
|
+
const isLastPass = index === passes.length - 1;
|
|
607
|
+
const renderToTarget = target !== undefined && isLastPass;
|
|
608
|
+
if (renderToTarget) {
|
|
609
|
+
outputBuffer = target;
|
|
610
|
+
}
|
|
611
|
+
const clearCanvas = !renderToTarget || Boolean(params.clearCanvas);
|
|
612
|
+
const moduleProps = {};
|
|
613
|
+
const uniforms = this.module.passes[index].uniforms;
|
|
614
|
+
moduleProps[this.module.name] = { ...this.props, ...uniforms };
|
|
615
|
+
passes[index].render({ clearCanvas, inputBuffer, outputBuffer, moduleProps });
|
|
616
|
+
const switchBuffer = outputBuffer;
|
|
617
|
+
outputBuffer = inputBuffer;
|
|
618
|
+
inputBuffer = switchBuffer;
|
|
619
|
+
}
|
|
620
|
+
return inputBuffer;
|
|
621
|
+
}
|
|
622
|
+
cleanup() {
|
|
623
|
+
if (this.passes) {
|
|
624
|
+
for (const pass of this.passes) {
|
|
625
|
+
pass.delete();
|
|
626
|
+
}
|
|
627
|
+
this.passes = undefined;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
function createPasses(device, module, id) {
|
|
632
|
+
return module.passes.map((pass, index) => {
|
|
633
|
+
const fs = getFragmentShaderForRenderPass(module, pass);
|
|
634
|
+
const idn = `${id}-${index}`;
|
|
635
|
+
return new ScreenPass(device, { id: idn, module, fs });
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
const FS_TEMPLATE_INPUTS = `\
|
|
639
|
+
#version 300 es
|
|
640
|
+
uniform sampler2D texSrc;
|
|
641
|
+
|
|
642
|
+
in vec2 position;
|
|
643
|
+
in vec2 coordinate;
|
|
644
|
+
in vec2 uv;
|
|
645
|
+
|
|
646
|
+
out vec4 fragColor;
|
|
647
|
+
`;
|
|
648
|
+
const FILTER_FS_TEMPLATE = (func) => `\
|
|
649
|
+
${FS_TEMPLATE_INPUTS}
|
|
650
|
+
void main() {
|
|
651
|
+
fragColor = texture(texSrc, coordinate);
|
|
652
|
+
fragColor = ${func}(fragColor, screen.texSize, coordinate);
|
|
653
|
+
}
|
|
654
|
+
`;
|
|
655
|
+
const SAMPLER_FS_TEMPLATE = (func) => `\
|
|
656
|
+
${FS_TEMPLATE_INPUTS}
|
|
657
|
+
void main() {
|
|
658
|
+
fragColor = ${func}(texSrc, screen.texSize, coordinate);
|
|
659
|
+
}
|
|
660
|
+
`;
|
|
661
|
+
function getFragmentShaderForRenderPass(module, pass) {
|
|
662
|
+
if (pass.filter) {
|
|
663
|
+
const func = typeof pass.filter === 'string' ? pass.filter : `${module.name}_filterColor_ext`;
|
|
664
|
+
return FILTER_FS_TEMPLATE(func);
|
|
665
|
+
}
|
|
666
|
+
if (pass.sampler) {
|
|
667
|
+
const func = typeof pass.sampler === 'string' ? pass.sampler : `${module.name}_sampleColor`;
|
|
668
|
+
return SAMPLER_FS_TEMPLATE(func);
|
|
669
|
+
}
|
|
670
|
+
// console.error(`${module.name} no fragment shader generated`);
|
|
671
|
+
return '';
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
// deck.gl
|
|
675
|
+
// SPDX-License-Identifier: MIT
|
|
676
|
+
// Copyright (c) vis.gl contributors
|
|
677
|
+
const DEGREES_TO_RADIANS = Math.PI / 180;
|
|
678
|
+
function getViewMatrix({ height, focalDistance, orbitAxis, rotationX, rotationOrbit, zoom }) {
|
|
679
|
+
// We position the camera so that one common space unit (world space unit scaled by zoom)
|
|
680
|
+
// at the target maps to one screen pixel.
|
|
681
|
+
// This is a similar technique to that used in web mercator projection
|
|
682
|
+
// By doing so we are able to convert between common space and screen space sizes efficiently
|
|
683
|
+
// in the vertex shader.
|
|
684
|
+
const up = orbitAxis === 'Z' ? [0, 0, 1] : [0, 1, 0];
|
|
685
|
+
const eye = orbitAxis === 'Z' ? [0, -focalDistance, 0] : [0, 0, focalDistance];
|
|
686
|
+
const viewMatrix = new deckProvider.Matrix4().lookAt({ eye, up });
|
|
687
|
+
viewMatrix.rotateX(rotationX * DEGREES_TO_RADIANS);
|
|
688
|
+
if (orbitAxis === 'Z') {
|
|
689
|
+
viewMatrix.rotateZ(rotationOrbit * DEGREES_TO_RADIANS);
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
viewMatrix.rotateY(rotationOrbit * DEGREES_TO_RADIANS);
|
|
693
|
+
}
|
|
694
|
+
// When height increases, we need to increase the distance from the camera to the target to
|
|
695
|
+
// keep the 1:1 mapping. However, this also changes the projected depth of each position by
|
|
696
|
+
// moving them further away between the near/far plane.
|
|
697
|
+
// Without modifying the default near/far planes, we instead scale down the common space to
|
|
698
|
+
// remove the distortion to the depth field.
|
|
699
|
+
const projectionScale = Math.pow(2, zoom) / height;
|
|
700
|
+
viewMatrix.scale(projectionScale);
|
|
701
|
+
return viewMatrix;
|
|
702
|
+
}
|
|
703
|
+
class OrbitViewport extends deckProvider.Viewport {
|
|
704
|
+
constructor(props) {
|
|
705
|
+
const { height, projectionMatrix, fovy = 50, // For setting camera position
|
|
706
|
+
orbitAxis = 'Z', // Orbit axis with 360 degrees rotating freedom, can only be 'Y' or 'Z'
|
|
707
|
+
target = [0, 0, 0], // Which point is camera looking at, default origin
|
|
708
|
+
rotationX = 0, // Rotating angle around X axis
|
|
709
|
+
rotationOrbit = 0, // Rotating angle around orbit axis
|
|
710
|
+
zoom = 0 } = props;
|
|
711
|
+
const focalDistance = projectionMatrix ? projectionMatrix[5] / 2 : deckProvider.fovyToAltitude(fovy);
|
|
712
|
+
super({
|
|
713
|
+
...props,
|
|
714
|
+
// in case viewState contains longitude/latitude values,
|
|
715
|
+
// make sure that the base Viewport class does not treat this as a geospatial viewport
|
|
716
|
+
longitude: undefined,
|
|
717
|
+
viewMatrix: getViewMatrix({
|
|
718
|
+
height: height || 1,
|
|
719
|
+
focalDistance,
|
|
720
|
+
orbitAxis,
|
|
721
|
+
rotationX,
|
|
722
|
+
rotationOrbit,
|
|
723
|
+
zoom
|
|
724
|
+
}),
|
|
725
|
+
fovy,
|
|
726
|
+
focalDistance,
|
|
727
|
+
position: target,
|
|
728
|
+
zoom
|
|
729
|
+
});
|
|
730
|
+
this.target = target;
|
|
731
|
+
this.orbitAxis = orbitAxis;
|
|
732
|
+
this.rotationX = rotationX;
|
|
733
|
+
this.rotationOrbit = rotationOrbit;
|
|
734
|
+
this.fovy = fovy;
|
|
735
|
+
this.projectedCenter = this.project(this.center);
|
|
736
|
+
}
|
|
737
|
+
unproject(xyz, { topLeft = true } = {}) {
|
|
738
|
+
const [x, y, z = this.projectedCenter[2]] = xyz;
|
|
739
|
+
const y2 = topLeft ? y : this.height - y;
|
|
740
|
+
const [X, Y, Z] = deckProvider.pixelsToWorld([x, y2, z], this.pixelUnprojectionMatrix);
|
|
741
|
+
return [X, Y, Z];
|
|
742
|
+
}
|
|
743
|
+
panByPosition(coords, pixel, startPixel) {
|
|
744
|
+
const p0 = this.project(coords);
|
|
745
|
+
const nextCenter = [
|
|
746
|
+
this.width / 2 + p0[0] - pixel[0],
|
|
747
|
+
this.height / 2 + p0[1] - pixel[1],
|
|
748
|
+
this.projectedCenter[2]
|
|
749
|
+
];
|
|
750
|
+
return {
|
|
751
|
+
target: this.unproject(nextCenter)
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
OrbitViewport.displayName = 'OrbitViewport';
|
|
756
|
+
|
|
757
|
+
// deck.gl
|
|
758
|
+
// SPDX-License-Identifier: MIT
|
|
759
|
+
// Copyright (c) vis.gl contributors
|
|
760
|
+
const viewMatrix = new deckProvider.Matrix4().lookAt({ eye: [0, 0, 1] });
|
|
761
|
+
function getProjectionMatrix({ width, height, near, far, padding }) {
|
|
762
|
+
let left = -width / 2;
|
|
763
|
+
let right = width / 2;
|
|
764
|
+
let bottom = -height / 2;
|
|
765
|
+
let top = height / 2;
|
|
766
|
+
if (padding) {
|
|
767
|
+
const { left: l = 0, right: r = 0, top: t = 0, bottom: b = 0 } = padding;
|
|
768
|
+
const offsetX = deckProvider.clamp((l + width - r) / 2, 0, width) - width / 2;
|
|
769
|
+
const offsetY = deckProvider.clamp((t + height - b) / 2, 0, height) - height / 2;
|
|
770
|
+
left -= offsetX;
|
|
771
|
+
right -= offsetX;
|
|
772
|
+
bottom += offsetY;
|
|
773
|
+
top += offsetY;
|
|
774
|
+
}
|
|
775
|
+
return new deckProvider.Matrix4().ortho({
|
|
776
|
+
left,
|
|
777
|
+
right,
|
|
778
|
+
bottom,
|
|
779
|
+
top,
|
|
780
|
+
near,
|
|
781
|
+
far
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
class OrthographicViewport extends deckProvider.Viewport {
|
|
785
|
+
constructor(props) {
|
|
786
|
+
const { width, height, near = 0.1, far = 1000, zoom = 0, target = [0, 0, 0], padding = null, flipY = true } = props;
|
|
787
|
+
const zoomX = props.zoomX ?? (Array.isArray(zoom) ? zoom[0] : zoom);
|
|
788
|
+
const zoomY = props.zoomY ?? (Array.isArray(zoom) ? zoom[1] : zoom);
|
|
789
|
+
const zoom_ = Math.min(zoomX, zoomY);
|
|
790
|
+
const scale = Math.pow(2, zoom_);
|
|
791
|
+
let distanceScales;
|
|
792
|
+
if (zoomX !== zoomY) {
|
|
793
|
+
const scaleX = Math.pow(2, zoomX);
|
|
794
|
+
const scaleY = Math.pow(2, zoomY);
|
|
795
|
+
distanceScales = {
|
|
796
|
+
unitsPerMeter: [scaleX / scale, scaleY / scale, 1],
|
|
797
|
+
metersPerUnit: [scale / scaleX, scale / scaleY, 1]
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
super({
|
|
801
|
+
...props,
|
|
802
|
+
// in case viewState contains longitude/latitude values,
|
|
803
|
+
// make sure that the base Viewport class does not treat this as a geospatial viewport
|
|
804
|
+
longitude: undefined,
|
|
805
|
+
position: target,
|
|
806
|
+
viewMatrix: viewMatrix.clone().scale([scale, scale * (flipY ? -1 : 1), scale]),
|
|
807
|
+
projectionMatrix: getProjectionMatrix({
|
|
808
|
+
width: width || 1,
|
|
809
|
+
height: height || 1,
|
|
810
|
+
padding,
|
|
811
|
+
near,
|
|
812
|
+
far
|
|
813
|
+
}),
|
|
814
|
+
zoom: zoom_,
|
|
815
|
+
distanceScales
|
|
816
|
+
});
|
|
817
|
+
this.target = target;
|
|
818
|
+
this.zoomX = zoomX;
|
|
819
|
+
this.zoomY = zoomY;
|
|
820
|
+
this.flipY = flipY;
|
|
821
|
+
}
|
|
822
|
+
projectFlat([X, Y]) {
|
|
823
|
+
const { unitsPerMeter } = this.distanceScales;
|
|
824
|
+
return [X * unitsPerMeter[0], Y * unitsPerMeter[1]];
|
|
825
|
+
}
|
|
826
|
+
unprojectFlat([x, y]) {
|
|
827
|
+
const { metersPerUnit } = this.distanceScales;
|
|
828
|
+
return [x * metersPerUnit[0], y * metersPerUnit[1]];
|
|
829
|
+
}
|
|
830
|
+
/* Needed by LinearInterpolator */
|
|
831
|
+
panByPosition(coords, pixel, startPixel) {
|
|
832
|
+
const fromLocation = deckProvider.pixelsToWorld(pixel, this.pixelUnprojectionMatrix);
|
|
833
|
+
const toLocation = this.projectFlat(coords);
|
|
834
|
+
const translate = deckProvider.add([], toLocation, deckProvider.negate([], fromLocation));
|
|
835
|
+
const newCenter = deckProvider.add([], this.center, translate);
|
|
836
|
+
return { target: this.unprojectFlat(newCenter) };
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
OrthographicViewport.displayName = 'OrthographicViewport';
|
|
840
|
+
|
|
841
|
+
// deck.gl
|
|
842
|
+
// SPDX-License-Identifier: MIT
|
|
843
|
+
// Copyright (c) vis.gl contributors
|
|
844
|
+
class FirstPersonViewport extends deckProvider.Viewport {
|
|
845
|
+
constructor(props) {
|
|
846
|
+
// TODO - push direction handling into Matrix4.lookAt
|
|
847
|
+
const { longitude, latitude, modelMatrix, bearing = 0, pitch = 0, up = [0, 0, 1] } = props;
|
|
848
|
+
// Always calculate direction from bearing and pitch
|
|
849
|
+
const spherical = new SphericalCoordinates({
|
|
850
|
+
bearing,
|
|
851
|
+
// Avoid "pixel project matrix not invertible" error
|
|
852
|
+
pitch: pitch === -90 ? 0.0001 : 90 + pitch
|
|
853
|
+
});
|
|
854
|
+
const dir = spherical.toVector3().normalize();
|
|
855
|
+
// Direction is relative to model coordinates, of course
|
|
856
|
+
const center = modelMatrix ? new deckProvider.Matrix4(modelMatrix).transformAsVector(dir) : dir;
|
|
857
|
+
// Just the direction. All the positioning is done in viewport.js
|
|
858
|
+
const zoom = Number.isFinite(latitude) ? deckProvider.getMeterZoom({ latitude: latitude }) : 0;
|
|
859
|
+
const scale = Math.pow(2, zoom);
|
|
860
|
+
const viewMatrix = new deckProvider.Matrix4().lookAt({ eye: [0, 0, 0], center, up }).scale(scale);
|
|
861
|
+
super({
|
|
862
|
+
...props,
|
|
863
|
+
zoom,
|
|
864
|
+
viewMatrix
|
|
865
|
+
});
|
|
866
|
+
this.latitude = latitude;
|
|
867
|
+
this.longitude = longitude;
|
|
868
|
+
this.pitch = pitch;
|
|
869
|
+
this.bearing = bearing;
|
|
870
|
+
this.up = up;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
FirstPersonViewport.displayName = 'FirstPersonViewport';
|
|
874
|
+
|
|
875
|
+
// deck.gl
|
|
876
|
+
// SPDX-License-Identifier: MIT
|
|
877
|
+
// Copyright (c) vis.gl contributors
|
|
878
|
+
const MOVEMENT_SPEED = 20;
|
|
879
|
+
const PAN_SPEED = 500;
|
|
880
|
+
class FirstPersonState extends deckProvider.ViewState {
|
|
881
|
+
constructor(options) {
|
|
882
|
+
const {
|
|
883
|
+
/* Viewport arguments */
|
|
884
|
+
width, // Width of viewport
|
|
885
|
+
height, // Height of viewport
|
|
886
|
+
// Position and orientation
|
|
887
|
+
position = [0, 0, 0], // typically in meters from anchor point
|
|
888
|
+
bearing = 0, // Rotation around y axis
|
|
889
|
+
pitch = 0, // Rotation around x axis
|
|
890
|
+
// Geospatial anchor
|
|
891
|
+
longitude = null, latitude = null, maxPitch = 90, minPitch = -90,
|
|
892
|
+
// Model state when the rotate operation first started
|
|
893
|
+
startRotatePos, startBearing, startPitch, startZoomPosition, startPanPos, startPanPosition } = options;
|
|
894
|
+
super({
|
|
895
|
+
width,
|
|
896
|
+
height,
|
|
897
|
+
position,
|
|
898
|
+
bearing,
|
|
899
|
+
pitch,
|
|
900
|
+
longitude,
|
|
901
|
+
latitude,
|
|
902
|
+
maxPitch,
|
|
903
|
+
minPitch
|
|
904
|
+
}, {
|
|
905
|
+
startRotatePos,
|
|
906
|
+
startBearing,
|
|
907
|
+
startPitch,
|
|
908
|
+
startZoomPosition,
|
|
909
|
+
startPanPos,
|
|
910
|
+
startPanPosition
|
|
911
|
+
});
|
|
912
|
+
this.makeViewport = options.makeViewport;
|
|
913
|
+
}
|
|
914
|
+
/* Public API */
|
|
915
|
+
/**
|
|
916
|
+
* Start panning
|
|
917
|
+
* @param {[Number, Number]} pos - position on screen where the pointer grabs
|
|
918
|
+
*/
|
|
919
|
+
panStart({ pos }) {
|
|
920
|
+
const { position } = this.getViewportProps();
|
|
921
|
+
return this._getUpdatedState({
|
|
922
|
+
startPanPos: pos,
|
|
923
|
+
startPanPosition: position
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Pan
|
|
928
|
+
* @param {[Number, Number]} pos - position on screen where the pointer is
|
|
929
|
+
*/
|
|
930
|
+
pan({ pos }) {
|
|
931
|
+
if (!pos) {
|
|
932
|
+
return this;
|
|
933
|
+
}
|
|
934
|
+
const { startPanPos = [0, 0], startPanPosition = [0, 0] } = this.getState();
|
|
935
|
+
const { width, height, bearing, pitch } = this.getViewportProps();
|
|
936
|
+
const deltaScaleX = (PAN_SPEED * (pos[0] - startPanPos[0])) / width;
|
|
937
|
+
const deltaScaleY = (PAN_SPEED * (pos[1] - startPanPos[1])) / height;
|
|
938
|
+
const up = new SphericalCoordinates({ bearing, pitch });
|
|
939
|
+
const forward = new SphericalCoordinates({ bearing, pitch: -90 });
|
|
940
|
+
const yDirection = up.toVector3().normalize();
|
|
941
|
+
const xDirection = forward.toVector3().cross(yDirection).normalize();
|
|
942
|
+
return this._getUpdatedState({
|
|
943
|
+
position: new deckProvider.Vector3(startPanPosition)
|
|
944
|
+
.add(xDirection.scale(deltaScaleX))
|
|
945
|
+
.add(yDirection.scale(deltaScaleY))
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
/**
|
|
949
|
+
* End panning
|
|
950
|
+
* Must call if `panStart()` was called
|
|
951
|
+
*/
|
|
952
|
+
panEnd() {
|
|
953
|
+
return this._getUpdatedState({
|
|
954
|
+
startPanPos: null,
|
|
955
|
+
startPanPosition: null
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Start rotating
|
|
960
|
+
* @param {[Number, Number]} pos - position on screen where the pointer grabs
|
|
961
|
+
*/
|
|
962
|
+
rotateStart({ pos }) {
|
|
963
|
+
return this._getUpdatedState({
|
|
964
|
+
startRotatePos: pos,
|
|
965
|
+
startBearing: this.getViewportProps().bearing,
|
|
966
|
+
startPitch: this.getViewportProps().pitch
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Rotate
|
|
971
|
+
* @param {[Number, Number]} pos - position on screen where the pointer is
|
|
972
|
+
*/
|
|
973
|
+
rotate({ pos, deltaAngleX = 0, deltaAngleY = 0 }) {
|
|
974
|
+
const { startRotatePos, startBearing, startPitch } = this.getState();
|
|
975
|
+
const { width, height } = this.getViewportProps();
|
|
976
|
+
if (!startRotatePos || startBearing === undefined || startPitch === undefined) {
|
|
977
|
+
return this;
|
|
978
|
+
}
|
|
979
|
+
let newRotation;
|
|
980
|
+
if (pos) {
|
|
981
|
+
const deltaScaleX = (pos[0] - startRotatePos[0]) / width;
|
|
982
|
+
const deltaScaleY = (pos[1] - startRotatePos[1]) / height;
|
|
983
|
+
newRotation = {
|
|
984
|
+
bearing: startBearing - deltaScaleX * 180,
|
|
985
|
+
pitch: startPitch - deltaScaleY * 90
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
else {
|
|
989
|
+
newRotation = {
|
|
990
|
+
bearing: startBearing - deltaAngleX,
|
|
991
|
+
pitch: startPitch - deltaAngleY
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
return this._getUpdatedState(newRotation);
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* End rotating
|
|
998
|
+
* Must call if `rotateStart()` was called
|
|
999
|
+
*/
|
|
1000
|
+
rotateEnd() {
|
|
1001
|
+
return this._getUpdatedState({
|
|
1002
|
+
startRotatePos: null,
|
|
1003
|
+
startBearing: null,
|
|
1004
|
+
startPitch: null
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* Start zooming
|
|
1009
|
+
* @param {[Number, Number]} pos - position on screen where the pointer grabs
|
|
1010
|
+
*/
|
|
1011
|
+
zoomStart() {
|
|
1012
|
+
return this._getUpdatedState({
|
|
1013
|
+
startZoomPosition: this.getViewportProps().position
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Zoom
|
|
1018
|
+
* @param {[Number, Number]} pos - position on screen where the current center is
|
|
1019
|
+
* @param {[Number, Number]} startPos - the center position at
|
|
1020
|
+
* the start of the operation. Must be supplied of `zoomStart()` was not called
|
|
1021
|
+
* @param {Number} scale - a number between [0, 1] specifying the accumulated
|
|
1022
|
+
* relative scale.
|
|
1023
|
+
*/
|
|
1024
|
+
zoom({ pos, scale }) {
|
|
1025
|
+
const viewportProps = this.getViewportProps();
|
|
1026
|
+
const startZoomPosition = this.getState().startZoomPosition || viewportProps.position;
|
|
1027
|
+
const viewport = this.makeViewport(viewportProps);
|
|
1028
|
+
const { projectionMatrix, width } = viewport;
|
|
1029
|
+
const fovxRadians = 2.0 * Math.atan(1.0 / projectionMatrix[0]);
|
|
1030
|
+
const angle = fovxRadians * (pos[0] / width - 0.5);
|
|
1031
|
+
const direction = this.getDirection(true);
|
|
1032
|
+
return this._move(direction.rotateZ({ radians: -angle }), Math.log2(scale) * MOVEMENT_SPEED, startZoomPosition);
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
* End zooming
|
|
1036
|
+
* Must call if `zoomStart()` was called
|
|
1037
|
+
*/
|
|
1038
|
+
zoomEnd() {
|
|
1039
|
+
return this._getUpdatedState({
|
|
1040
|
+
startZoomPosition: null
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
moveLeft(speed = MOVEMENT_SPEED) {
|
|
1044
|
+
const direction = this.getDirection(true);
|
|
1045
|
+
return this._move(direction.rotateZ({ radians: Math.PI / 2 }), speed);
|
|
1046
|
+
}
|
|
1047
|
+
moveRight(speed = MOVEMENT_SPEED) {
|
|
1048
|
+
const direction = this.getDirection(true);
|
|
1049
|
+
return this._move(direction.rotateZ({ radians: -Math.PI / 2 }), speed);
|
|
1050
|
+
}
|
|
1051
|
+
// forward
|
|
1052
|
+
moveUp(speed = MOVEMENT_SPEED) {
|
|
1053
|
+
const direction = this.getDirection(true);
|
|
1054
|
+
return this._move(direction, speed);
|
|
1055
|
+
}
|
|
1056
|
+
// backward
|
|
1057
|
+
moveDown(speed = MOVEMENT_SPEED) {
|
|
1058
|
+
const direction = this.getDirection(true);
|
|
1059
|
+
return this._move(direction.negate(), speed);
|
|
1060
|
+
}
|
|
1061
|
+
rotateLeft(speed = 15) {
|
|
1062
|
+
return this._getUpdatedState({
|
|
1063
|
+
bearing: this.getViewportProps().bearing - speed
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
rotateRight(speed = 15) {
|
|
1067
|
+
return this._getUpdatedState({
|
|
1068
|
+
bearing: this.getViewportProps().bearing + speed
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1071
|
+
rotateUp(speed = 10) {
|
|
1072
|
+
return this._getUpdatedState({
|
|
1073
|
+
pitch: this.getViewportProps().pitch + speed
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
rotateDown(speed = 10) {
|
|
1077
|
+
return this._getUpdatedState({
|
|
1078
|
+
pitch: this.getViewportProps().pitch - speed
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
zoomIn(speed = MOVEMENT_SPEED) {
|
|
1082
|
+
return this._move(new deckProvider.Vector3(0, 0, 1), speed);
|
|
1083
|
+
}
|
|
1084
|
+
zoomOut(speed = MOVEMENT_SPEED) {
|
|
1085
|
+
return this._move(new deckProvider.Vector3(0, 0, -1), speed);
|
|
1086
|
+
}
|
|
1087
|
+
// shortest path between two view states
|
|
1088
|
+
shortestPathFrom(viewState) {
|
|
1089
|
+
const fromProps = viewState.getViewportProps();
|
|
1090
|
+
const props = { ...this.getViewportProps() };
|
|
1091
|
+
const { bearing, longitude } = props;
|
|
1092
|
+
if (Math.abs(bearing - fromProps.bearing) > 180) {
|
|
1093
|
+
props.bearing = bearing < 0 ? bearing + 360 : bearing - 360;
|
|
1094
|
+
}
|
|
1095
|
+
if (longitude !== null &&
|
|
1096
|
+
fromProps.longitude !== null &&
|
|
1097
|
+
Math.abs(longitude - fromProps.longitude) > 180) {
|
|
1098
|
+
props.longitude = longitude < 0 ? longitude + 360 : longitude - 360;
|
|
1099
|
+
}
|
|
1100
|
+
return props;
|
|
1101
|
+
}
|
|
1102
|
+
/* Private methods */
|
|
1103
|
+
_move(direction, speed, fromPosition = this.getViewportProps().position) {
|
|
1104
|
+
const delta = direction.scale(speed);
|
|
1105
|
+
return this._getUpdatedState({
|
|
1106
|
+
position: new deckProvider.Vector3(fromPosition).add(delta)
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
getDirection(use2D = false) {
|
|
1110
|
+
const spherical = new SphericalCoordinates({
|
|
1111
|
+
bearing: this.getViewportProps().bearing,
|
|
1112
|
+
pitch: use2D ? 90 : 90 + this.getViewportProps().pitch
|
|
1113
|
+
});
|
|
1114
|
+
const direction = spherical.toVector3().normalize();
|
|
1115
|
+
return direction;
|
|
1116
|
+
}
|
|
1117
|
+
_getUpdatedState(newProps) {
|
|
1118
|
+
// Update _viewportProps
|
|
1119
|
+
return new FirstPersonState({
|
|
1120
|
+
makeViewport: this.makeViewport,
|
|
1121
|
+
...this.getViewportProps(),
|
|
1122
|
+
...this.getState(),
|
|
1123
|
+
...newProps
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
// Apply any constraints (mathematical or defined by _viewportProps) to map state
|
|
1127
|
+
applyConstraints(props) {
|
|
1128
|
+
// Ensure pitch and zoom are within specified range
|
|
1129
|
+
const { pitch, maxPitch, minPitch, longitude, bearing } = props;
|
|
1130
|
+
props.pitch = deckProvider.clamp(pitch, minPitch, maxPitch);
|
|
1131
|
+
// Normalize degrees
|
|
1132
|
+
if (longitude !== null && (longitude < -180 || longitude > 180)) {
|
|
1133
|
+
props.longitude = deckProvider.mod(longitude + 180, 360) - 180;
|
|
1134
|
+
}
|
|
1135
|
+
if (bearing < -180 || bearing > 180) {
|
|
1136
|
+
props.bearing = deckProvider.mod(bearing + 180, 360) - 180;
|
|
1137
|
+
}
|
|
1138
|
+
return props;
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
class FirstPersonController extends deckProvider.Controller {
|
|
1142
|
+
constructor() {
|
|
1143
|
+
super(...arguments);
|
|
1144
|
+
this.ControllerState = FirstPersonState;
|
|
1145
|
+
this.transition = {
|
|
1146
|
+
transitionDuration: 300,
|
|
1147
|
+
transitionInterpolator: new deckProvider.LinearInterpolator(['position', 'pitch', 'bearing'])
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
// deck.gl
|
|
1153
|
+
// SPDX-License-Identifier: MIT
|
|
1154
|
+
// Copyright (c) vis.gl contributors
|
|
1155
|
+
class FirstPersonView extends deckProvider.View {
|
|
1156
|
+
constructor(props = {}) {
|
|
1157
|
+
super(props);
|
|
1158
|
+
}
|
|
1159
|
+
getViewportType() {
|
|
1160
|
+
return FirstPersonViewport;
|
|
1161
|
+
}
|
|
1162
|
+
get ControllerType() {
|
|
1163
|
+
return FirstPersonController;
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
FirstPersonView.displayName = 'FirstPersonView';
|
|
1167
|
+
|
|
1168
|
+
// deck.gl
|
|
1169
|
+
// SPDX-License-Identifier: MIT
|
|
1170
|
+
// Copyright (c) vis.gl contributors
|
|
1171
|
+
class OrbitState extends deckProvider.ViewState {
|
|
1172
|
+
constructor(options) {
|
|
1173
|
+
const {
|
|
1174
|
+
/* Viewport arguments */
|
|
1175
|
+
width, // Width of viewport
|
|
1176
|
+
height, // Height of viewport
|
|
1177
|
+
rotationX = 0, // Rotation around x axis
|
|
1178
|
+
rotationOrbit = 0, // Rotation around orbit axis
|
|
1179
|
+
target = [0, 0, 0], zoom = 0,
|
|
1180
|
+
/* Viewport constraints */
|
|
1181
|
+
minRotationX = -90, maxRotationX = 90, minZoom = -Infinity, maxZoom = Infinity,
|
|
1182
|
+
/** Interaction states, required to calculate change during transform */
|
|
1183
|
+
// Model state when the pan operation first started
|
|
1184
|
+
startPanPosition,
|
|
1185
|
+
// Model state when the rotate operation first started
|
|
1186
|
+
startRotatePos, startRotationX, startRotationOrbit,
|
|
1187
|
+
// Model state when the zoom operation first started
|
|
1188
|
+
startZoomPosition, startZoom } = options;
|
|
1189
|
+
super({
|
|
1190
|
+
width,
|
|
1191
|
+
height,
|
|
1192
|
+
rotationX,
|
|
1193
|
+
rotationOrbit,
|
|
1194
|
+
target,
|
|
1195
|
+
zoom,
|
|
1196
|
+
minRotationX,
|
|
1197
|
+
maxRotationX,
|
|
1198
|
+
minZoom,
|
|
1199
|
+
maxZoom
|
|
1200
|
+
}, {
|
|
1201
|
+
startPanPosition,
|
|
1202
|
+
startRotatePos,
|
|
1203
|
+
startRotationX,
|
|
1204
|
+
startRotationOrbit,
|
|
1205
|
+
startZoomPosition,
|
|
1206
|
+
startZoom
|
|
1207
|
+
});
|
|
1208
|
+
this.makeViewport = options.makeViewport;
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* Start panning
|
|
1212
|
+
* @param {[Number, Number]} pos - position on screen where the pointer grabs
|
|
1213
|
+
*/
|
|
1214
|
+
panStart({ pos }) {
|
|
1215
|
+
return this._getUpdatedState({
|
|
1216
|
+
startPanPosition: this._unproject(pos)
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
/**
|
|
1220
|
+
* Pan
|
|
1221
|
+
* @param {[Number, Number]} pos - position on screen where the pointer is
|
|
1222
|
+
*/
|
|
1223
|
+
pan({ pos, startPosition }) {
|
|
1224
|
+
const startPanPosition = this.getState().startPanPosition || startPosition;
|
|
1225
|
+
if (!startPanPosition) {
|
|
1226
|
+
return this;
|
|
1227
|
+
}
|
|
1228
|
+
const viewport = this.makeViewport(this.getViewportProps());
|
|
1229
|
+
const newProps = viewport.panByPosition(startPanPosition, pos);
|
|
1230
|
+
return this._getUpdatedState(newProps);
|
|
1231
|
+
}
|
|
1232
|
+
/**
|
|
1233
|
+
* End panning
|
|
1234
|
+
* Must call if `panStart()` was called
|
|
1235
|
+
*/
|
|
1236
|
+
panEnd() {
|
|
1237
|
+
return this._getUpdatedState({
|
|
1238
|
+
startPanPosition: null
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* Start rotating
|
|
1243
|
+
* @param {[Number, Number]} pos - position on screen where the pointer grabs
|
|
1244
|
+
*/
|
|
1245
|
+
rotateStart({ pos }) {
|
|
1246
|
+
return this._getUpdatedState({
|
|
1247
|
+
startRotatePos: pos,
|
|
1248
|
+
startRotationX: this.getViewportProps().rotationX,
|
|
1249
|
+
startRotationOrbit: this.getViewportProps().rotationOrbit
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* Rotate
|
|
1254
|
+
* @param {[Number, Number]} pos - position on screen where the pointer is
|
|
1255
|
+
*/
|
|
1256
|
+
rotate({ pos, deltaAngleX = 0, deltaAngleY = 0 }) {
|
|
1257
|
+
const { startRotatePos, startRotationX, startRotationOrbit } = this.getState();
|
|
1258
|
+
const { width, height } = this.getViewportProps();
|
|
1259
|
+
if (!startRotatePos || startRotationX === undefined || startRotationOrbit === undefined) {
|
|
1260
|
+
return this;
|
|
1261
|
+
}
|
|
1262
|
+
let newRotation;
|
|
1263
|
+
if (pos) {
|
|
1264
|
+
let deltaScaleX = (pos[0] - startRotatePos[0]) / width;
|
|
1265
|
+
const deltaScaleY = (pos[1] - startRotatePos[1]) / height;
|
|
1266
|
+
if (startRotationX < -90 || startRotationX > 90) {
|
|
1267
|
+
// When looking at the "back" side of the scene, invert horizontal drag
|
|
1268
|
+
// so that the camera movement follows user input
|
|
1269
|
+
deltaScaleX *= -1;
|
|
1270
|
+
}
|
|
1271
|
+
newRotation = {
|
|
1272
|
+
rotationX: startRotationX + deltaScaleY * 180,
|
|
1273
|
+
rotationOrbit: startRotationOrbit + deltaScaleX * 180
|
|
1274
|
+
};
|
|
1275
|
+
}
|
|
1276
|
+
else {
|
|
1277
|
+
newRotation = {
|
|
1278
|
+
rotationX: startRotationX + deltaAngleY,
|
|
1279
|
+
rotationOrbit: startRotationOrbit + deltaAngleX
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1282
|
+
return this._getUpdatedState(newRotation);
|
|
1283
|
+
}
|
|
1284
|
+
/**
|
|
1285
|
+
* End rotating
|
|
1286
|
+
* Must call if `rotateStart()` was called
|
|
1287
|
+
*/
|
|
1288
|
+
rotateEnd() {
|
|
1289
|
+
return this._getUpdatedState({
|
|
1290
|
+
startRotationX: null,
|
|
1291
|
+
startRotationOrbit: null
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
// shortest path between two view states
|
|
1295
|
+
shortestPathFrom(viewState) {
|
|
1296
|
+
const fromProps = viewState.getViewportProps();
|
|
1297
|
+
const props = { ...this.getViewportProps() };
|
|
1298
|
+
const { rotationOrbit } = props;
|
|
1299
|
+
if (Math.abs(rotationOrbit - fromProps.rotationOrbit) > 180) {
|
|
1300
|
+
props.rotationOrbit = rotationOrbit < 0 ? rotationOrbit + 360 : rotationOrbit - 360;
|
|
1301
|
+
}
|
|
1302
|
+
return props;
|
|
1303
|
+
}
|
|
1304
|
+
/**
|
|
1305
|
+
* Start zooming
|
|
1306
|
+
* @param {[Number, Number]} pos - position on screen where the pointer grabs
|
|
1307
|
+
*/
|
|
1308
|
+
zoomStart({ pos }) {
|
|
1309
|
+
return this._getUpdatedState({
|
|
1310
|
+
startZoomPosition: this._unproject(pos),
|
|
1311
|
+
startZoom: this.getViewportProps().zoom
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
/**
|
|
1315
|
+
* Zoom
|
|
1316
|
+
* @param {[Number, Number]} pos - position on screen where the current target is
|
|
1317
|
+
* @param {[Number, Number]} startPos - the target position at
|
|
1318
|
+
* the start of the operation. Must be supplied of `zoomStart()` was not called
|
|
1319
|
+
* @param {Number} scale - a number between [0, 1] specifying the accumulated
|
|
1320
|
+
* relative scale.
|
|
1321
|
+
*/
|
|
1322
|
+
zoom({ pos, startPos, scale }) {
|
|
1323
|
+
let { startZoom, startZoomPosition } = this.getState();
|
|
1324
|
+
if (!startZoomPosition) {
|
|
1325
|
+
// We have two modes of zoom:
|
|
1326
|
+
// scroll zoom that are discrete events (transform from the current zoom level),
|
|
1327
|
+
// and pinch zoom that are continuous events (transform from the zoom level when
|
|
1328
|
+
// pinch started).
|
|
1329
|
+
// If startZoom state is defined, then use the startZoom state;
|
|
1330
|
+
// otherwise assume discrete zooming
|
|
1331
|
+
startZoom = this.getViewportProps().zoom;
|
|
1332
|
+
startZoomPosition = this._unproject(startPos || pos);
|
|
1333
|
+
}
|
|
1334
|
+
if (!startZoomPosition) {
|
|
1335
|
+
return this;
|
|
1336
|
+
}
|
|
1337
|
+
const newZoom = this._calculateNewZoom({ scale, startZoom });
|
|
1338
|
+
const zoomedViewport = this.makeViewport({ ...this.getViewportProps(), zoom: newZoom });
|
|
1339
|
+
return this._getUpdatedState({
|
|
1340
|
+
zoom: newZoom,
|
|
1341
|
+
...zoomedViewport.panByPosition(startZoomPosition, pos)
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* End zooming
|
|
1346
|
+
* Must call if `zoomStart()` was called
|
|
1347
|
+
*/
|
|
1348
|
+
zoomEnd() {
|
|
1349
|
+
return this._getUpdatedState({
|
|
1350
|
+
startZoomPosition: null,
|
|
1351
|
+
startZoom: null
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
zoomIn(speed = 2) {
|
|
1355
|
+
return this._getUpdatedState({
|
|
1356
|
+
zoom: this._calculateNewZoom({ scale: speed })
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1359
|
+
zoomOut(speed = 2) {
|
|
1360
|
+
return this._getUpdatedState({
|
|
1361
|
+
zoom: this._calculateNewZoom({ scale: 1 / speed })
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
moveLeft(speed = 50) {
|
|
1365
|
+
return this._panFromCenter([-speed, 0]);
|
|
1366
|
+
}
|
|
1367
|
+
moveRight(speed = 50) {
|
|
1368
|
+
return this._panFromCenter([speed, 0]);
|
|
1369
|
+
}
|
|
1370
|
+
moveUp(speed = 50) {
|
|
1371
|
+
return this._panFromCenter([0, -speed]);
|
|
1372
|
+
}
|
|
1373
|
+
moveDown(speed = 50) {
|
|
1374
|
+
return this._panFromCenter([0, speed]);
|
|
1375
|
+
}
|
|
1376
|
+
rotateLeft(speed = 15) {
|
|
1377
|
+
return this._getUpdatedState({
|
|
1378
|
+
rotationOrbit: this.getViewportProps().rotationOrbit - speed
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
rotateRight(speed = 15) {
|
|
1382
|
+
return this._getUpdatedState({
|
|
1383
|
+
rotationOrbit: this.getViewportProps().rotationOrbit + speed
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1386
|
+
rotateUp(speed = 10) {
|
|
1387
|
+
return this._getUpdatedState({
|
|
1388
|
+
rotationX: this.getViewportProps().rotationX - speed
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
rotateDown(speed = 10) {
|
|
1392
|
+
return this._getUpdatedState({
|
|
1393
|
+
rotationX: this.getViewportProps().rotationX + speed
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1396
|
+
/* Private methods */
|
|
1397
|
+
_project(pos) {
|
|
1398
|
+
const viewport = this.makeViewport(this.getViewportProps());
|
|
1399
|
+
return viewport.project(pos);
|
|
1400
|
+
}
|
|
1401
|
+
_unproject(pos) {
|
|
1402
|
+
const viewport = this.makeViewport(this.getViewportProps());
|
|
1403
|
+
return viewport.unproject(pos);
|
|
1404
|
+
}
|
|
1405
|
+
// Calculates new zoom
|
|
1406
|
+
_calculateNewZoom({ scale, startZoom }) {
|
|
1407
|
+
const { maxZoom, minZoom } = this.getViewportProps();
|
|
1408
|
+
if (startZoom === undefined) {
|
|
1409
|
+
startZoom = this.getViewportProps().zoom;
|
|
1410
|
+
}
|
|
1411
|
+
const zoom = startZoom + Math.log2(scale);
|
|
1412
|
+
return deckProvider.clamp(zoom, minZoom, maxZoom);
|
|
1413
|
+
}
|
|
1414
|
+
_panFromCenter(offset) {
|
|
1415
|
+
const { target } = this.getViewportProps();
|
|
1416
|
+
const center = this._project(target);
|
|
1417
|
+
return this.pan({
|
|
1418
|
+
startPosition: target,
|
|
1419
|
+
pos: [center[0] + offset[0], center[1] + offset[1]]
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
_getUpdatedState(newProps) {
|
|
1423
|
+
// @ts-ignore
|
|
1424
|
+
return new this.constructor({
|
|
1425
|
+
makeViewport: this.makeViewport,
|
|
1426
|
+
...this.getViewportProps(),
|
|
1427
|
+
...this.getState(),
|
|
1428
|
+
...newProps
|
|
1429
|
+
});
|
|
1430
|
+
}
|
|
1431
|
+
// Apply any constraints (mathematical or defined by _viewportProps) to map state
|
|
1432
|
+
applyConstraints(props) {
|
|
1433
|
+
// Ensure zoom is within specified range
|
|
1434
|
+
const { maxZoom, minZoom, zoom, maxRotationX, minRotationX, rotationOrbit } = props;
|
|
1435
|
+
props.zoom = Array.isArray(zoom)
|
|
1436
|
+
? [deckProvider.clamp(zoom[0], minZoom, maxZoom), deckProvider.clamp(zoom[1], minZoom, maxZoom)]
|
|
1437
|
+
: deckProvider.clamp(zoom, minZoom, maxZoom);
|
|
1438
|
+
props.rotationX = deckProvider.clamp(props.rotationX, minRotationX, maxRotationX);
|
|
1439
|
+
if (rotationOrbit < -180 || rotationOrbit > 180) {
|
|
1440
|
+
props.rotationOrbit = deckProvider.mod(rotationOrbit + 180, 360) - 180;
|
|
1441
|
+
}
|
|
1442
|
+
return props;
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
class OrbitController extends deckProvider.Controller {
|
|
1446
|
+
constructor() {
|
|
1447
|
+
super(...arguments);
|
|
1448
|
+
this.ControllerState = OrbitState;
|
|
1449
|
+
this.transition = {
|
|
1450
|
+
transitionDuration: 300,
|
|
1451
|
+
transitionInterpolator: new deckProvider.LinearInterpolator({
|
|
1452
|
+
transitionProps: {
|
|
1453
|
+
compare: ['target', 'zoom', 'rotationX', 'rotationOrbit'],
|
|
1454
|
+
required: ['target', 'zoom']
|
|
1455
|
+
}
|
|
1456
|
+
})
|
|
1457
|
+
};
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
// deck.gl
|
|
1462
|
+
// SPDX-License-Identifier: MIT
|
|
1463
|
+
// Copyright (c) vis.gl contributors
|
|
1464
|
+
class OrbitView extends deckProvider.View {
|
|
1465
|
+
constructor(props = {}) {
|
|
1466
|
+
super(props);
|
|
1467
|
+
this.props.orbitAxis = props.orbitAxis || 'Z';
|
|
1468
|
+
}
|
|
1469
|
+
getViewportType() {
|
|
1470
|
+
return OrbitViewport;
|
|
1471
|
+
}
|
|
1472
|
+
get ControllerType() {
|
|
1473
|
+
return OrbitController;
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
OrbitView.displayName = 'OrbitView';
|
|
1477
|
+
|
|
1478
|
+
// deck.gl
|
|
1479
|
+
// SPDX-License-Identifier: MIT
|
|
1480
|
+
// Copyright (c) vis.gl contributors
|
|
1481
|
+
class OrthographicState extends OrbitState {
|
|
1482
|
+
constructor(props) {
|
|
1483
|
+
super(props);
|
|
1484
|
+
this.zoomAxis = props.zoomAxis || 'all';
|
|
1485
|
+
}
|
|
1486
|
+
_calculateNewZoom({ scale, startZoom }) {
|
|
1487
|
+
const { maxZoom, minZoom } = this.getViewportProps();
|
|
1488
|
+
if (startZoom === undefined) {
|
|
1489
|
+
startZoom = this.getViewportProps().zoom;
|
|
1490
|
+
}
|
|
1491
|
+
let deltaZoom = Math.log2(scale);
|
|
1492
|
+
if (Array.isArray(startZoom)) {
|
|
1493
|
+
let [newZoomX, newZoomY] = startZoom;
|
|
1494
|
+
switch (this.zoomAxis) {
|
|
1495
|
+
case 'X':
|
|
1496
|
+
// Scale x only
|
|
1497
|
+
newZoomX = deckProvider.clamp(newZoomX + deltaZoom, minZoom, maxZoom);
|
|
1498
|
+
break;
|
|
1499
|
+
case 'Y':
|
|
1500
|
+
// Scale y only
|
|
1501
|
+
newZoomY = deckProvider.clamp(newZoomY + deltaZoom, minZoom, maxZoom);
|
|
1502
|
+
break;
|
|
1503
|
+
default:
|
|
1504
|
+
// Lock aspect ratio
|
|
1505
|
+
let z = Math.min(newZoomX + deltaZoom, newZoomY + deltaZoom);
|
|
1506
|
+
if (z < minZoom) {
|
|
1507
|
+
deltaZoom += minZoom - z;
|
|
1508
|
+
}
|
|
1509
|
+
z = Math.max(newZoomX + deltaZoom, newZoomY + deltaZoom);
|
|
1510
|
+
if (z > maxZoom) {
|
|
1511
|
+
deltaZoom += maxZoom - z;
|
|
1512
|
+
}
|
|
1513
|
+
newZoomX += deltaZoom;
|
|
1514
|
+
newZoomY += deltaZoom;
|
|
1515
|
+
}
|
|
1516
|
+
return [newZoomX, newZoomY];
|
|
1517
|
+
}
|
|
1518
|
+
// Ignore `zoomAxis`
|
|
1519
|
+
// `LinearTransitionInterpolator` does not support interpolation between a number and an array
|
|
1520
|
+
// So if zoom is a number (legacy use case), new zoom still has to be a number
|
|
1521
|
+
return deckProvider.clamp(startZoom + deltaZoom, minZoom, maxZoom);
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
class OrthographicController extends deckProvider.Controller {
|
|
1525
|
+
constructor() {
|
|
1526
|
+
super(...arguments);
|
|
1527
|
+
this.ControllerState = OrthographicState;
|
|
1528
|
+
this.transition = {
|
|
1529
|
+
transitionDuration: 300,
|
|
1530
|
+
transitionInterpolator: new deckProvider.LinearInterpolator(['target', 'zoom'])
|
|
1531
|
+
};
|
|
1532
|
+
this.dragMode = 'pan';
|
|
1533
|
+
}
|
|
1534
|
+
_onPanRotate() {
|
|
1535
|
+
// No rotation in orthographic view
|
|
1536
|
+
return false;
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
// deck.gl
|
|
1541
|
+
// SPDX-License-Identifier: MIT
|
|
1542
|
+
// Copyright (c) vis.gl contributors
|
|
1543
|
+
class OrthographicView extends deckProvider.View {
|
|
1544
|
+
constructor(props = {}) {
|
|
1545
|
+
super(props);
|
|
1546
|
+
}
|
|
1547
|
+
getViewportType() {
|
|
1548
|
+
return OrthographicViewport;
|
|
1549
|
+
}
|
|
1550
|
+
get ControllerType() {
|
|
1551
|
+
return OrthographicController;
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
OrthographicView.displayName = 'OrthographicView';
|
|
1555
|
+
|
|
1556
|
+
// deck.gl
|
|
1557
|
+
// SPDX-License-Identifier: MIT
|
|
1558
|
+
// Copyright (c) vis.gl contributors
|
|
1559
|
+
class GlobeState extends deckProvider.MapState {
|
|
1560
|
+
constructor(options) {
|
|
1561
|
+
const { startPanPos, ...mapStateOptions } = options;
|
|
1562
|
+
super(mapStateOptions);
|
|
1563
|
+
if (startPanPos !== undefined) {
|
|
1564
|
+
this._state.startPanPos = startPanPos;
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
panStart({ pos }) {
|
|
1568
|
+
const { latitude, longitude, zoom } = this.getViewportProps();
|
|
1569
|
+
return this._getUpdatedState({
|
|
1570
|
+
startPanLngLat: [longitude, latitude],
|
|
1571
|
+
startPanPos: pos,
|
|
1572
|
+
startZoom: zoom
|
|
1573
|
+
});
|
|
1574
|
+
}
|
|
1575
|
+
pan({ pos, startPos }) {
|
|
1576
|
+
const state = this.getState();
|
|
1577
|
+
const startPanLngLat = state.startPanLngLat || this._unproject(startPos);
|
|
1578
|
+
if (!startPanLngLat)
|
|
1579
|
+
return this;
|
|
1580
|
+
const startZoom = state.startZoom ?? this.getViewportProps().zoom;
|
|
1581
|
+
const startPanPos = state.startPanPos || startPos;
|
|
1582
|
+
const coords = [startPanLngLat[0], startPanLngLat[1], startZoom];
|
|
1583
|
+
const viewport = this.makeViewport(this.getViewportProps());
|
|
1584
|
+
const newProps = viewport.panByPosition(coords, pos, startPanPos);
|
|
1585
|
+
return this._getUpdatedState(newProps);
|
|
1586
|
+
}
|
|
1587
|
+
panEnd() {
|
|
1588
|
+
return this._getUpdatedState({
|
|
1589
|
+
startPanLngLat: null,
|
|
1590
|
+
startPanPos: null,
|
|
1591
|
+
startZoom: null
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
1594
|
+
zoom({ scale }) {
|
|
1595
|
+
// In Globe view zoom does not take into account the mouse position
|
|
1596
|
+
const startZoom = this.getState().startZoom || this.getViewportProps().zoom;
|
|
1597
|
+
const zoom = startZoom + Math.log2(scale);
|
|
1598
|
+
return this._getUpdatedState({ zoom });
|
|
1599
|
+
}
|
|
1600
|
+
applyConstraints(props) {
|
|
1601
|
+
// Ensure zoom is within specified range
|
|
1602
|
+
const { longitude, latitude, maxZoom, minZoom, zoom } = props;
|
|
1603
|
+
const ZOOM0 = deckProvider.zoomAdjust(0);
|
|
1604
|
+
const zoomAdjustment = deckProvider.zoomAdjust(latitude) - ZOOM0;
|
|
1605
|
+
props.zoom = deckProvider.clamp(zoom, minZoom + zoomAdjustment, maxZoom + zoomAdjustment);
|
|
1606
|
+
if (longitude < -180 || longitude > 180) {
|
|
1607
|
+
props.longitude = deckProvider.mod(longitude + 180, 360) - 180;
|
|
1608
|
+
}
|
|
1609
|
+
props.latitude = deckProvider.clamp(latitude, -deckProvider.MAX_LATITUDE, deckProvider.MAX_LATITUDE);
|
|
1610
|
+
return props;
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
class GlobeController extends deckProvider.Controller {
|
|
1614
|
+
constructor() {
|
|
1615
|
+
super(...arguments);
|
|
1616
|
+
this.ControllerState = GlobeState;
|
|
1617
|
+
this.transition = {
|
|
1618
|
+
transitionDuration: 300,
|
|
1619
|
+
transitionInterpolator: new deckProvider.LinearInterpolator(['longitude', 'latitude', 'zoom'])
|
|
1620
|
+
};
|
|
1621
|
+
this.dragMode = 'pan';
|
|
1622
|
+
}
|
|
1623
|
+
setProps(props) {
|
|
1624
|
+
super.setProps(props);
|
|
1625
|
+
// TODO - support pitching?
|
|
1626
|
+
this.dragRotate = false;
|
|
1627
|
+
this.touchRotate = false;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
// deck.gl
|
|
1632
|
+
// SPDX-License-Identifier: MIT
|
|
1633
|
+
// Copyright (c) vis.gl contributors
|
|
1634
|
+
class GlobeView extends deckProvider.View {
|
|
1635
|
+
constructor(props = {}) {
|
|
1636
|
+
super(props);
|
|
1637
|
+
}
|
|
1638
|
+
getViewportType(viewState) {
|
|
1639
|
+
return viewState.zoom > 12 ? deckProvider.WebMercatorViewport : deckProvider.GlobeViewport;
|
|
1640
|
+
}
|
|
1641
|
+
get ControllerType() {
|
|
1642
|
+
return GlobeController;
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
GlobeView.displayName = 'GlobeView';
|
|
1646
|
+
|
|
1647
|
+
// deck.gl
|
|
1648
|
+
// SPDX-License-Identifier: MIT
|
|
1649
|
+
// Copyright (c) vis.gl contributors
|
|
1650
|
+
const LINEARLY_INTERPOLATED_PROPS = {
|
|
1651
|
+
bearing: 0,
|
|
1652
|
+
pitch: 0,
|
|
1653
|
+
position: [0, 0, 0]
|
|
1654
|
+
};
|
|
1655
|
+
const DEFAULT_OPTS = {
|
|
1656
|
+
speed: 1.2,
|
|
1657
|
+
curve: 1.414
|
|
1658
|
+
};
|
|
1659
|
+
/**
|
|
1660
|
+
* This class adapts mapbox-gl-js Map#flyTo animation so it can be used in
|
|
1661
|
+
* react/redux architecture.
|
|
1662
|
+
* mapbox-gl-js flyTo : https://www.mapbox.com/mapbox-gl-js/api/#map#flyto.
|
|
1663
|
+
* It implements “Smooth and efficient zooming and panning.” algorithm by
|
|
1664
|
+
* "Jarke J. van Wijk and Wim A.A. Nuij"
|
|
1665
|
+
*/
|
|
1666
|
+
class FlyToInterpolator extends deckProvider.TransitionInterpolator {
|
|
1667
|
+
constructor(opts = {}) {
|
|
1668
|
+
super({
|
|
1669
|
+
compare: ['longitude', 'latitude', 'zoom', 'bearing', 'pitch', 'position'],
|
|
1670
|
+
extract: ['width', 'height', 'longitude', 'latitude', 'zoom', 'bearing', 'pitch', 'position'],
|
|
1671
|
+
required: ['width', 'height', 'latitude', 'longitude', 'zoom']
|
|
1672
|
+
});
|
|
1673
|
+
this.opts = { ...DEFAULT_OPTS, ...opts };
|
|
1674
|
+
}
|
|
1675
|
+
interpolateProps(startProps, endProps, t) {
|
|
1676
|
+
const viewport = flyToViewport(startProps, endProps, t, this.opts);
|
|
1677
|
+
// Linearly interpolate 'bearing', 'pitch' and 'position'.
|
|
1678
|
+
// If they are not supplied, they are interpreted as zeros in viewport calculation
|
|
1679
|
+
// (fallback defined in WebMercatorViewport)
|
|
1680
|
+
// Because there is no guarantee that the current controller's ViewState normalizes
|
|
1681
|
+
// these props, safe guard is needed to avoid generating NaNs
|
|
1682
|
+
for (const key in LINEARLY_INTERPOLATED_PROPS) {
|
|
1683
|
+
viewport[key] = deckProvider.lerp$1(startProps[key] || LINEARLY_INTERPOLATED_PROPS[key], endProps[key] || LINEARLY_INTERPOLATED_PROPS[key], t);
|
|
1684
|
+
}
|
|
1685
|
+
return viewport;
|
|
1686
|
+
}
|
|
1687
|
+
// computes the transition duration
|
|
1688
|
+
getDuration(startProps, endProps) {
|
|
1689
|
+
let { transitionDuration } = endProps;
|
|
1690
|
+
if (transitionDuration === 'auto') {
|
|
1691
|
+
// auto calculate duration based on start and end props
|
|
1692
|
+
transitionDuration = getFlyToDuration(startProps, endProps, this.opts);
|
|
1693
|
+
}
|
|
1694
|
+
return transitionDuration;
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
exports.AmbientLight = deckProvider.AmbientLight;
|
|
1699
|
+
exports.Attribute = deckProvider.Attribute;
|
|
1700
|
+
exports.AttributeManager = deckProvider.AttributeManager;
|
|
1701
|
+
exports.COORDINATE_SYSTEM = deckProvider.COORDINATE_SYSTEM;
|
|
1702
|
+
exports.CompositeLayer = deckProvider.CompositeLayer;
|
|
1703
|
+
exports.Controller = deckProvider.Controller;
|
|
1704
|
+
exports.Deck = deckProvider.Deck;
|
|
1705
|
+
exports.DeckRenderer = deckProvider.DeckRenderer;
|
|
1706
|
+
exports.DirectionalLight = deckProvider.DirectionalLight;
|
|
1707
|
+
exports.Layer = deckProvider.Layer;
|
|
1708
|
+
exports.LayerManager = deckProvider.LayerManager;
|
|
1709
|
+
exports.LightingEffect = deckProvider.LightingEffect;
|
|
1710
|
+
exports.LinearInterpolator = deckProvider.LinearInterpolator;
|
|
1711
|
+
exports.MapController = deckProvider.MapController;
|
|
1712
|
+
exports.MapView = deckProvider.MapView;
|
|
1713
|
+
exports.OPERATION = deckProvider.OPERATION;
|
|
1714
|
+
exports.TRANSITION_EVENTS = deckProvider.TRANSITION_EVENTS;
|
|
1715
|
+
exports.Tesselator = deckProvider.Tesselator;
|
|
1716
|
+
exports.TransitionInterpolator = deckProvider.TransitionInterpolator;
|
|
1717
|
+
exports.UNIT = deckProvider.UNIT;
|
|
1718
|
+
exports.VERSION = deckProvider.VERSION;
|
|
1719
|
+
exports.View = deckProvider.View;
|
|
1720
|
+
exports.Viewport = deckProvider.Viewport;
|
|
1721
|
+
exports.WebMercatorViewport = deckProvider.WebMercatorViewport;
|
|
1722
|
+
exports.Widget = deckProvider.Widget;
|
|
1723
|
+
exports._Component = deckProvider.Component;
|
|
1724
|
+
exports._ComponentState = deckProvider.ComponentState;
|
|
1725
|
+
exports._GlobeViewport = deckProvider.GlobeViewport;
|
|
1726
|
+
exports._LayersPass = deckProvider.LayersPass;
|
|
1727
|
+
exports._PickLayersPass = deckProvider.PickLayersPass;
|
|
1728
|
+
exports._applyStyles = deckProvider.applyStyles;
|
|
1729
|
+
exports._compareProps = deckProvider.compareProps;
|
|
1730
|
+
exports._count = deckProvider.count;
|
|
1731
|
+
exports._deepEqual = deckProvider.deepEqual;
|
|
1732
|
+
exports._fillArray = deckProvider.fillArray;
|
|
1733
|
+
exports._flatten = deckProvider.flatten;
|
|
1734
|
+
exports._memoize = deckProvider.memoize;
|
|
1735
|
+
exports._mergeShaders = deckProvider.mergeShaders;
|
|
1736
|
+
exports._removeStyles = deckProvider.removeStyles;
|
|
1737
|
+
exports.assert = deckProvider.assert;
|
|
1738
|
+
exports.color = deckProvider.color;
|
|
1739
|
+
exports.createIterable = deckProvider.createIterable;
|
|
1740
|
+
exports.fp64LowPart = deckProvider.fp64LowPart;
|
|
1741
|
+
exports.getShaderAssembler = deckProvider.getShaderAssembler;
|
|
1742
|
+
exports.gouraudMaterial = deckProvider.gouraudMaterial;
|
|
1743
|
+
exports.log = deckProvider.defaultLogger;
|
|
1744
|
+
exports.phongMaterial = deckProvider.phongMaterial;
|
|
1745
|
+
exports.picking = deckProvider.picking;
|
|
1746
|
+
exports.project = deckProvider.project;
|
|
1747
|
+
exports.project32 = deckProvider.project32;
|
|
1748
|
+
exports.shadow = deckProvider.shadow;
|
|
1749
|
+
exports.LayerExtension = layerExtension.LayerExtension;
|
|
1750
|
+
exports.FirstPersonController = FirstPersonController;
|
|
1751
|
+
exports.FirstPersonView = FirstPersonView;
|
|
1752
|
+
exports.FirstPersonViewport = FirstPersonViewport;
|
|
1753
|
+
exports.FlyToInterpolator = FlyToInterpolator;
|
|
1754
|
+
exports.OrbitController = OrbitController;
|
|
1755
|
+
exports.OrbitView = OrbitView;
|
|
1756
|
+
exports.OrbitViewport = OrbitViewport;
|
|
1757
|
+
exports.OrthographicController = OrthographicController;
|
|
1758
|
+
exports.OrthographicView = OrthographicView;
|
|
1759
|
+
exports.OrthographicViewport = OrthographicViewport;
|
|
1760
|
+
exports.PointLight = PointLight;
|
|
1761
|
+
exports.PostProcessEffect = PostProcessEffect;
|
|
1762
|
+
exports._CameraLight = CameraLight;
|
|
1763
|
+
exports._GlobeController = GlobeController;
|
|
1764
|
+
exports._GlobeView = GlobeView;
|
|
1765
|
+
exports._SunLight = SunLight;
|