@math.gl/geospatial 5.0.0-beta.1 → 5.0.0-beta.10
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/H3-LICENSE.TXT +201 -0
- package/H3-NOTICE.TXT +17 -0
- package/README.md +192 -2
- package/THIRD-PARTY-NOTICES.md +203 -26
- package/dist/crs/crs-identifier.d.ts +23 -0
- package/dist/crs/crs-identifier.d.ts.map +1 -0
- package/dist/crs/crs-identifier.js +74 -0
- package/dist/crs/crs-identifier.js.map +1 -0
- package/dist/crs/index.cjs +48 -0
- package/dist/crs/index.cjs.map +2 -2
- package/dist/crs/index.d.ts +1 -0
- package/dist/crs/index.d.ts.map +1 -1
- package/dist/crs/index.js +1 -0
- package/dist/crs/index.js.map +1 -1
- package/dist/elastic.cjs +3 -3
- package/dist/elastic.cjs.map +1 -1
- package/dist/elastic.d.ts +3 -3
- package/dist/elastic.d.ts.map +1 -1
- package/dist/elastic.js +3 -3
- package/dist/elastic.js.map +1 -1
- package/dist/expressions.d.ts +1 -1
- package/dist/expressions.d.ts.map +1 -1
- package/dist/index.cjs +10004 -10720
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +82 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +51 -5
- package/dist/index.js.map +1 -1
- package/dist/maps/air-ocean-mesh.d.ts.map +1 -0
- package/dist/maps/air-ocean-mesh.js.map +1 -0
- package/dist/maps/albers-usa.d.ts.map +1 -0
- package/dist/maps/albers-usa.js.map +1 -0
- package/dist/maps/cap-map.d.ts.map +1 -0
- package/dist/maps/cap-map.js +498 -0
- package/dist/maps/cap-map.js.map +1 -0
- package/dist/maps/elastic/data.d.ts.map +1 -0
- package/dist/maps/elastic/data.js.map +1 -0
- package/dist/maps/elastic/elasticI.d.ts.map +1 -0
- package/dist/maps/elastic/elasticI.js.map +1 -0
- package/dist/maps/elastic/elasticII.d.ts.map +1 -0
- package/dist/maps/elastic/elasticII.js.map +1 -0
- package/dist/maps/elastic/elasticIII.d.ts.map +1 -0
- package/dist/maps/elastic/elasticIII.js.map +1 -0
- package/dist/maps/elastic/geometry.d.ts +22 -0
- package/dist/maps/elastic/geometry.d.ts.map +1 -0
- package/dist/maps/elastic/geometry.js +131 -0
- package/dist/maps/elastic/geometry.js.map +1 -0
- package/dist/maps/elastic/grid.d.ts.map +1 -0
- package/dist/maps/elastic/grid.js.map +1 -0
- package/dist/maps/elastic/map.d.ts.map +1 -0
- package/dist/maps/elastic/map.js +500 -0
- package/dist/maps/elastic/map.js.map +1 -0
- package/dist/maps/elastic/source-arc.d.ts +10 -0
- package/dist/maps/elastic/source-arc.d.ts.map +1 -0
- package/dist/maps/elastic/source-arc.js +111 -0
- package/dist/maps/elastic/source-arc.js.map +1 -0
- package/dist/maps/geometry.cjs +1028 -0
- package/dist/maps/geometry.cjs.map +6 -0
- package/dist/maps/geometry.d.ts +12 -0
- package/dist/maps/geometry.d.ts.map +1 -0
- package/dist/maps/geometry.js +13 -0
- package/dist/maps/geometry.js.map +1 -0
- package/dist/maps/global-polygons.d.ts +35 -0
- package/dist/maps/global-polygons.d.ts.map +1 -0
- package/dist/maps/global-polygons.js +263 -0
- package/dist/maps/global-polygons.js.map +1 -0
- package/dist/maps/gray-fuller.d.ts.map +1 -0
- package/dist/maps/gray-fuller.js.map +1 -0
- package/dist/maps/gringorten-kernel.d.ts.map +1 -0
- package/dist/maps/gringorten-kernel.js.map +1 -0
- package/dist/maps/h3-face-map.d.ts +7 -0
- package/dist/maps/h3-face-map.d.ts.map +1 -0
- package/dist/maps/h3-face-map.js +200 -0
- package/dist/maps/h3-face-map.js.map +1 -0
- package/dist/maps/healpix.d.ts.map +1 -0
- package/dist/maps/healpix.js.map +1 -0
- package/dist/maps/layout.d.ts.map +1 -0
- package/dist/maps/layout.js.map +1 -0
- package/dist/maps/map-engine.d.ts +239 -0
- package/dist/maps/map-engine.d.ts.map +1 -0
- package/dist/maps/map-engine.js +299 -0
- package/dist/maps/map-engine.js.map +1 -0
- package/dist/maps/map-layout.d.ts +119 -0
- package/dist/maps/map-layout.d.ts.map +1 -0
- package/dist/maps/map-layout.js +612 -0
- package/dist/maps/map-layout.js.map +1 -0
- package/dist/maps/map-surface-mesh.d.ts +44 -0
- package/dist/maps/map-surface-mesh.d.ts.map +1 -0
- package/dist/maps/map-surface-mesh.js +150 -0
- package/dist/maps/map-surface-mesh.js.map +1 -0
- package/dist/maps/map-transition-mesh.d.ts +51 -0
- package/dist/maps/map-transition-mesh.d.ts.map +1 -0
- package/dist/maps/map-transition-mesh.js +313 -0
- package/dist/maps/map-transition-mesh.js.map +1 -0
- package/dist/maps/map-transition.d.ts.map +1 -0
- package/dist/maps/map-transition.js +346 -0
- package/dist/maps/map-transition.js.map +1 -0
- package/dist/maps/math.d.ts.map +1 -0
- package/dist/maps/math.js.map +1 -0
- package/dist/maps/mercator-map.d.ts +24 -0
- package/dist/maps/mercator-map.d.ts.map +1 -0
- package/dist/maps/mercator-map.js +245 -0
- package/dist/maps/mercator-map.js.map +1 -0
- package/dist/maps/myriahedral/graticule.d.ts.map +1 -0
- package/dist/maps/myriahedral/graticule.js.map +1 -0
- package/dist/maps/myriahedral/mesh.d.ts.map +1 -0
- package/dist/maps/myriahedral/mesh.js.map +1 -0
- package/dist/maps/myriahedral/unfold.d.ts.map +1 -0
- package/dist/maps/myriahedral/unfold.js.map +1 -0
- package/dist/maps/myriahedral.d.ts.map +1 -0
- package/dist/maps/myriahedral.js.map +1 -0
- package/dist/maps/petroff.d.ts.map +1 -0
- package/dist/maps/petroff.js.map +1 -0
- package/dist/maps/polygon-constraints.d.ts +16 -0
- package/dist/maps/polygon-constraints.d.ts.map +1 -0
- package/dist/maps/polygon-constraints.js +157 -0
- package/dist/maps/polygon-constraints.js.map +1 -0
- package/dist/maps/polyhedral.d.ts.map +1 -0
- package/dist/maps/polyhedral.js.map +1 -0
- package/dist/maps/prepare-features.d.ts +108 -0
- package/dist/maps/prepare-features.d.ts.map +1 -0
- package/dist/maps/prepare-features.js +250 -0
- package/dist/maps/prepare-features.js.map +1 -0
- package/dist/maps/preset-kernels.d.ts +71 -0
- package/dist/maps/preset-kernels.d.ts.map +1 -0
- package/dist/maps/preset-kernels.js +372 -0
- package/dist/maps/preset-kernels.js.map +1 -0
- package/dist/maps/presets.cjs +7437 -0
- package/dist/maps/presets.cjs.map +6 -0
- package/dist/maps/presets.d.ts +37 -0
- package/dist/maps/presets.d.ts.map +1 -0
- package/dist/maps/presets.js +294 -0
- package/dist/maps/presets.js.map +1 -0
- package/dist/maps/projection-catalog.d.ts.map +1 -0
- package/dist/maps/projection-catalog.js +96 -0
- package/dist/maps/projection-catalog.js.map +1 -0
- package/dist/maps/projection-surface.d.ts +14 -0
- package/dist/maps/projection-surface.d.ts.map +1 -0
- package/dist/maps/projection-surface.js +50 -0
- package/dist/maps/projection-surface.js.map +1 -0
- package/dist/maps/quincuncial-kernel.d.ts.map +1 -0
- package/dist/maps/quincuncial-kernel.js.map +1 -0
- package/dist/maps/quincuncial-star.d.ts.map +1 -0
- package/dist/maps/quincuncial-star.js.map +1 -0
- package/dist/maps/regional-map.d.ts.map +1 -0
- package/dist/maps/regional-map.js.map +1 -0
- package/dist/maps/retroazimuthal-map.d.ts.map +1 -0
- package/dist/maps/retroazimuthal-map.js.map +1 -0
- package/dist/maps/rotated-map.d.ts +42 -0
- package/dist/maps/rotated-map.d.ts.map +1 -0
- package/dist/maps/rotated-map.js +72 -0
- package/dist/maps/rotated-map.js.map +1 -0
- package/dist/maps/snyder-mesh.d.ts.map +1 -0
- package/dist/maps/snyder-mesh.js.map +1 -0
- package/dist/maps/snyder.d.ts.map +1 -0
- package/dist/maps/snyder.js.map +1 -0
- package/dist/maps/source-arc.d.ts +4 -0
- package/dist/maps/source-arc.d.ts.map +1 -0
- package/dist/maps/source-arc.js +23 -0
- package/dist/maps/source-arc.js.map +1 -0
- package/dist/maps/spherical-clip/cartesian.d.ts +8 -0
- package/dist/maps/spherical-clip/cartesian.d.ts.map +1 -0
- package/dist/maps/spherical-clip/cartesian.js.map +1 -0
- package/dist/maps/spherical-clip/circle.d.ts.map +1 -0
- package/dist/maps/spherical-clip/circle.js.map +1 -0
- package/dist/maps/spherical-clip/clip-buffer.d.ts.map +1 -0
- package/dist/maps/spherical-clip/clip-buffer.js.map +1 -0
- package/dist/maps/spherical-clip/clip-circle.d.ts.map +1 -0
- package/dist/maps/spherical-clip/clip-circle.js.map +1 -0
- package/dist/maps/spherical-clip/clip-index.d.ts.map +1 -0
- package/dist/maps/spherical-clip/clip-index.js.map +1 -0
- package/dist/maps/spherical-clip/clip-rejoin.d.ts.map +1 -0
- package/dist/maps/spherical-clip/clip-rejoin.js.map +1 -0
- package/dist/maps/spherical-clip/helpers.d.ts.map +1 -0
- package/dist/maps/spherical-clip/helpers.js.map +1 -0
- package/dist/maps/spherical-clip/math.d.ts +26 -0
- package/dist/maps/spherical-clip/math.d.ts.map +1 -0
- package/dist/maps/spherical-clip/math.js.map +1 -0
- package/dist/maps/spherical-clip/noop.d.ts.map +1 -0
- package/dist/maps/spherical-clip/noop.js.map +1 -0
- package/dist/maps/spherical-clip/pointEqual.d.ts +2 -0
- package/dist/maps/spherical-clip/pointEqual.d.ts.map +1 -0
- package/dist/maps/spherical-clip/pointEqual.js.map +1 -0
- package/dist/maps/spherical-clip/polygonContains.d.ts.map +1 -0
- package/dist/maps/spherical-clip/polygonContains.js.map +1 -0
- package/dist/maps/surfaces.cjs +183 -0
- package/dist/maps/surfaces.cjs.map +6 -0
- package/dist/maps/surfaces.d.ts +5 -0
- package/dist/maps/surfaces.d.ts.map +1 -0
- package/dist/maps/surfaces.js +6 -0
- package/dist/maps/surfaces.js.map +1 -0
- package/dist/maps/transitions.cjs +660 -0
- package/dist/maps/transitions.cjs.map +6 -0
- package/dist/maps/transitions.d.ts +8 -0
- package/dist/maps/transitions.d.ts.map +1 -0
- package/dist/maps/transitions.js +9 -0
- package/dist/maps/transitions.js.map +1 -0
- package/dist/maps/world-composite-kernels.d.ts.map +1 -0
- package/dist/maps/world-composite-kernels.js.map +1 -0
- package/dist/maps/world-kernels/airy.d.ts.map +1 -0
- package/dist/maps/world-kernels/airy.js.map +1 -0
- package/dist/maps/world-kernels/aitoff.d.ts.map +1 -0
- package/dist/maps/world-kernels/aitoff.js.map +1 -0
- package/dist/maps/world-kernels/armadillo.d.ts.map +1 -0
- package/dist/maps/world-kernels/armadillo.js.map +1 -0
- package/dist/maps/world-kernels/august.d.ts.map +1 -0
- package/dist/maps/world-kernels/august.js.map +1 -0
- package/dist/maps/world-kernels/baker.d.ts.map +1 -0
- package/dist/maps/world-kernels/baker.js.map +1 -0
- package/dist/maps/world-kernels/bertin.d.ts.map +1 -0
- package/dist/maps/world-kernels/bertin.js.map +1 -0
- package/dist/maps/world-kernels/boggs.d.ts.map +1 -0
- package/dist/maps/world-kernels/boggs.js.map +1 -0
- package/dist/maps/world-kernels/bonne.d.ts.map +1 -0
- package/dist/maps/world-kernels/bonne.js.map +1 -0
- package/dist/maps/world-kernels/bottomley.d.ts.map +1 -0
- package/dist/maps/world-kernels/bottomley.js.map +1 -0
- package/dist/maps/world-kernels/bromley.d.ts.map +1 -0
- package/dist/maps/world-kernels/bromley.js.map +1 -0
- package/dist/maps/world-kernels/chamberlin.d.ts.map +1 -0
- package/dist/maps/world-kernels/chamberlin.js.map +1 -0
- package/dist/maps/world-kernels/collignon.d.ts +5 -0
- package/dist/maps/world-kernels/collignon.d.ts.map +1 -0
- package/dist/maps/world-kernels/collignon.js.map +1 -0
- package/dist/maps/world-kernels/craig.d.ts.map +1 -0
- package/dist/maps/world-kernels/craig.js.map +1 -0
- package/dist/maps/world-kernels/craster.d.ts +5 -0
- package/dist/maps/world-kernels/craster.d.ts.map +1 -0
- package/dist/maps/world-kernels/craster.js.map +1 -0
- package/dist/maps/world-kernels/cylindricalEqualArea.d.ts.map +1 -0
- package/dist/maps/world-kernels/cylindricalEqualArea.js.map +1 -0
- package/dist/maps/world-kernels/cylindricalStereographic.d.ts.map +1 -0
- package/dist/maps/world-kernels/cylindricalStereographic.js.map +1 -0
- package/dist/maps/world-kernels/d3-geo-raw.d.ts.map +1 -0
- package/dist/maps/world-kernels/d3-geo-raw.js.map +1 -0
- package/dist/maps/world-kernels/eckert1.d.ts +5 -0
- package/dist/maps/world-kernels/eckert1.d.ts.map +1 -0
- package/dist/maps/world-kernels/eckert1.js.map +1 -0
- package/dist/maps/world-kernels/eckert2.d.ts +5 -0
- package/dist/maps/world-kernels/eckert2.d.ts.map +1 -0
- package/dist/maps/world-kernels/eckert2.js.map +1 -0
- package/dist/maps/world-kernels/eckert3.d.ts +5 -0
- package/dist/maps/world-kernels/eckert3.d.ts.map +1 -0
- package/dist/maps/world-kernels/eckert3.js.map +1 -0
- package/dist/maps/world-kernels/eckert4.d.ts +5 -0
- package/dist/maps/world-kernels/eckert4.d.ts.map +1 -0
- package/dist/maps/world-kernels/eckert4.js.map +1 -0
- package/dist/maps/world-kernels/eckert5.d.ts +5 -0
- package/dist/maps/world-kernels/eckert5.d.ts.map +1 -0
- package/dist/maps/world-kernels/eckert5.js.map +1 -0
- package/dist/maps/world-kernels/eckert6.d.ts +5 -0
- package/dist/maps/world-kernels/eckert6.d.ts.map +1 -0
- package/dist/maps/world-kernels/eckert6.js.map +1 -0
- package/dist/maps/world-kernels/eisenlohr.d.ts.map +1 -0
- package/dist/maps/world-kernels/eisenlohr.js.map +1 -0
- package/dist/maps/world-kernels/fahey.d.ts +5 -0
- package/dist/maps/world-kernels/fahey.d.ts.map +1 -0
- package/dist/maps/world-kernels/fahey.js.map +1 -0
- package/dist/maps/world-kernels/foucaut.d.ts +5 -0
- package/dist/maps/world-kernels/foucaut.d.ts.map +1 -0
- package/dist/maps/world-kernels/foucaut.js.map +1 -0
- package/dist/maps/world-kernels/foucautSinusoidal.d.ts.map +1 -0
- package/dist/maps/world-kernels/foucautSinusoidal.js.map +1 -0
- package/dist/maps/world-kernels/ginzburg4.d.ts.map +1 -0
- package/dist/maps/world-kernels/ginzburg4.js.map +1 -0
- package/dist/maps/world-kernels/ginzburg5.d.ts.map +1 -0
- package/dist/maps/world-kernels/ginzburg5.js.map +1 -0
- package/dist/maps/world-kernels/ginzburg6.d.ts.map +1 -0
- package/dist/maps/world-kernels/ginzburg6.js.map +1 -0
- package/dist/maps/world-kernels/ginzburg8.d.ts.map +1 -0
- package/dist/maps/world-kernels/ginzburg8.js.map +1 -0
- package/dist/maps/world-kernels/ginzburg9.d.ts.map +1 -0
- package/dist/maps/world-kernels/ginzburg9.js.map +1 -0
- package/dist/maps/world-kernels/ginzburgPolyconic.d.ts.map +1 -0
- package/dist/maps/world-kernels/ginzburgPolyconic.js.map +1 -0
- package/dist/maps/world-kernels/hammer.d.ts.map +1 -0
- package/dist/maps/world-kernels/hammer.js.map +1 -0
- package/dist/maps/world-kernels/hammerRetroazimuthal.d.ts.map +1 -0
- package/dist/maps/world-kernels/hammerRetroazimuthal.js.map +1 -0
- package/dist/maps/world-kernels/hill.d.ts.map +1 -0
- package/dist/maps/world-kernels/hill.js.map +1 -0
- package/dist/maps/world-kernels/homolosine.d.ts +5 -0
- package/dist/maps/world-kernels/homolosine.d.ts.map +1 -0
- package/dist/maps/world-kernels/homolosine.js.map +1 -0
- package/dist/maps/world-kernels/hufnagel.d.ts.map +1 -0
- package/dist/maps/world-kernels/hufnagel.js.map +1 -0
- package/dist/maps/world-kernels/hyperelliptical.d.ts.map +1 -0
- package/dist/maps/world-kernels/hyperelliptical.js.map +1 -0
- package/dist/maps/world-kernels/integrate.d.ts.map +1 -0
- package/dist/maps/world-kernels/integrate.js.map +1 -0
- package/dist/maps/world-kernels/kavrayskiy7.d.ts +5 -0
- package/dist/maps/world-kernels/kavrayskiy7.d.ts.map +1 -0
- package/dist/maps/world-kernels/kavrayskiy7.js.map +1 -0
- package/dist/maps/world-kernels/lagrange.d.ts.map +1 -0
- package/dist/maps/world-kernels/lagrange.js.map +1 -0
- package/dist/maps/world-kernels/larrivee.d.ts.map +1 -0
- package/dist/maps/world-kernels/larrivee.js.map +1 -0
- package/dist/maps/world-kernels/laskowski.d.ts.map +1 -0
- package/dist/maps/world-kernels/laskowski.js.map +1 -0
- package/dist/maps/world-kernels/littrow.d.ts.map +1 -0
- package/dist/maps/world-kernels/littrow.js.map +1 -0
- package/dist/maps/world-kernels/loximuthal.d.ts.map +1 -0
- package/dist/maps/world-kernels/loximuthal.js.map +1 -0
- package/dist/maps/world-kernels/math.d.ts +36 -0
- package/dist/maps/world-kernels/math.d.ts.map +1 -0
- package/dist/maps/world-kernels/math.js.map +1 -0
- package/dist/maps/world-kernels/miller.d.ts +5 -0
- package/dist/maps/world-kernels/miller.d.ts.map +1 -0
- package/dist/maps/world-kernels/miller.js.map +1 -0
- package/dist/maps/world-kernels/modifiedStereographic.d.ts.map +1 -0
- package/dist/maps/world-kernels/modifiedStereographic.js.map +1 -0
- package/dist/maps/world-kernels/mollweide.d.ts.map +1 -0
- package/dist/maps/world-kernels/mollweide.js.map +1 -0
- package/dist/maps/world-kernels/mtFlatPolarParabolic.d.ts.map +1 -0
- package/dist/maps/world-kernels/mtFlatPolarParabolic.js.map +1 -0
- package/dist/maps/world-kernels/mtFlatPolarQuartic.d.ts.map +1 -0
- package/dist/maps/world-kernels/mtFlatPolarQuartic.js.map +1 -0
- package/dist/maps/world-kernels/mtFlatPolarSinusoidal.d.ts.map +1 -0
- package/dist/maps/world-kernels/mtFlatPolarSinusoidal.js.map +1 -0
- package/dist/maps/world-kernels/naturalEarth2.d.ts.map +1 -0
- package/dist/maps/world-kernels/naturalEarth2.js.map +1 -0
- package/dist/maps/world-kernels/nellHammer.d.ts.map +1 -0
- package/dist/maps/world-kernels/nellHammer.js.map +1 -0
- package/dist/maps/world-kernels/newton.d.ts.map +1 -0
- package/dist/maps/world-kernels/newton.js.map +1 -0
- package/dist/maps/world-kernels/nicolosi.d.ts.map +1 -0
- package/dist/maps/world-kernels/nicolosi.js.map +1 -0
- package/dist/maps/world-kernels/patterson.d.ts.map +1 -0
- package/dist/maps/world-kernels/patterson.js.map +1 -0
- package/dist/maps/world-kernels/polyconic.d.ts.map +1 -0
- package/dist/maps/world-kernels/polyconic.js.map +1 -0
- package/dist/maps/world-kernels/rectangularPolyconic.d.ts.map +1 -0
- package/dist/maps/world-kernels/rectangularPolyconic.js.map +1 -0
- package/dist/maps/world-kernels/robinson.d.ts.map +1 -0
- package/dist/maps/world-kernels/robinson.js.map +1 -0
- package/dist/maps/world-kernels/satellite.d.ts.map +1 -0
- package/dist/maps/world-kernels/satellite.js.map +1 -0
- package/dist/maps/world-kernels/sinuMollweide.d.ts +7 -0
- package/dist/maps/world-kernels/sinuMollweide.d.ts.map +1 -0
- package/dist/maps/world-kernels/sinuMollweide.js.map +1 -0
- package/dist/maps/world-kernels/sinusoidal.d.ts +5 -0
- package/dist/maps/world-kernels/sinusoidal.d.ts.map +1 -0
- package/dist/maps/world-kernels/sinusoidal.js.map +1 -0
- package/dist/maps/world-kernels/times.d.ts.map +1 -0
- package/dist/maps/world-kernels/times.js.map +1 -0
- package/dist/maps/world-kernels/twoPointEquidistant.d.ts.map +1 -0
- package/dist/maps/world-kernels/twoPointEquidistant.js.map +1 -0
- package/dist/maps/world-kernels/vanDerGrinten.d.ts.map +1 -0
- package/dist/maps/world-kernels/vanDerGrinten.js.map +1 -0
- package/dist/maps/world-kernels/vanDerGrinten2.d.ts.map +1 -0
- package/dist/maps/world-kernels/vanDerGrinten2.js.map +1 -0
- package/dist/maps/world-kernels/vanDerGrinten3.d.ts.map +1 -0
- package/dist/maps/world-kernels/vanDerGrinten3.js.map +1 -0
- package/dist/maps/world-kernels/vanDerGrinten4.d.ts.map +1 -0
- package/dist/maps/world-kernels/vanDerGrinten4.js.map +1 -0
- package/dist/maps/world-kernels/wagner.d.ts.map +1 -0
- package/dist/maps/world-kernels/wagner.js.map +1 -0
- package/dist/maps/world-kernels/wagner4.d.ts.map +1 -0
- package/dist/maps/world-kernels/wagner4.js.map +1 -0
- package/dist/maps/world-kernels/wagner6.d.ts +5 -0
- package/dist/maps/world-kernels/wagner6.d.ts.map +1 -0
- package/dist/maps/world-kernels/wagner6.js.map +1 -0
- package/dist/maps/world-kernels/wiechel.d.ts.map +1 -0
- package/dist/maps/world-kernels/wiechel.js.map +1 -0
- package/dist/maps/world-kernels/winkel3.d.ts.map +1 -0
- package/dist/maps/world-kernels/winkel3.js.map +1 -0
- package/dist/maps/world-kernels.d.ts +150 -0
- package/dist/maps/world-kernels.d.ts.map +1 -0
- package/dist/maps/world-kernels.js.map +1 -0
- package/dist/maps/world-map.d.ts.map +1 -0
- package/dist/maps/world-map.js.map +1 -0
- package/dist/maps.cjs +9153 -0
- package/dist/maps.cjs.map +6 -0
- package/dist/maps.d.ts +63 -0
- package/dist/maps.d.ts.map +1 -0
- package/dist/maps.js +43 -0
- package/dist/maps.js.map +1 -0
- package/dist/projection/experimental/common/adjust_lat.js +1 -1
- package/dist/projection/experimental/common/adjust_lat.js.map +1 -1
- package/dist/projection/experimental/common/adjust_lon.js +1 -1
- package/dist/projection/experimental/common/adjust_lon.js.map +1 -1
- package/dist/projection/experimental/common/asinhy.js +1 -1
- package/dist/projection/experimental/common/asinhy.js.map +1 -1
- package/dist/projection/experimental/common/asinz.js +1 -1
- package/dist/projection/experimental/common/asinz.js.map +1 -1
- package/dist/projection/experimental/common/authlat.js +1 -1
- package/dist/projection/experimental/common/authlat.js.map +1 -1
- package/dist/projection/experimental/common/authset.js +1 -1
- package/dist/projection/experimental/common/authset.js.map +1 -1
- package/dist/projection/experimental/common/clens.js +1 -1
- package/dist/projection/experimental/common/clens.js.map +1 -1
- package/dist/projection/experimental/common/clens_cmplx.js +1 -1
- package/dist/projection/experimental/common/clens_cmplx.js.map +1 -1
- package/dist/projection/experimental/common/constants.js +1 -1
- package/dist/projection/experimental/common/constants.js.map +1 -1
- package/dist/projection/experimental/common/cosh.js +1 -1
- package/dist/projection/experimental/common/cosh.js.map +1 -1
- package/dist/projection/experimental/common/e0fn.js +1 -1
- package/dist/projection/experimental/common/e0fn.js.map +1 -1
- package/dist/projection/experimental/common/e1fn.js +1 -1
- package/dist/projection/experimental/common/e1fn.js.map +1 -1
- package/dist/projection/experimental/common/e2fn.js +1 -1
- package/dist/projection/experimental/common/e2fn.js.map +1 -1
- package/dist/projection/experimental/common/e3fn.js +1 -1
- package/dist/projection/experimental/common/e3fn.js.map +1 -1
- package/dist/projection/experimental/common/fL.js +1 -1
- package/dist/projection/experimental/common/fL.js.map +1 -1
- package/dist/projection/experimental/common/gN.js +1 -1
- package/dist/projection/experimental/common/gN.js.map +1 -1
- package/dist/projection/experimental/common/gatg.js +1 -1
- package/dist/projection/experimental/common/gatg.js.map +1 -1
- package/dist/projection/experimental/common/hypot.js +1 -1
- package/dist/projection/experimental/common/hypot.js.map +1 -1
- package/dist/projection/experimental/common/imlfn.js +1 -1
- package/dist/projection/experimental/common/imlfn.js.map +1 -1
- package/dist/projection/experimental/common/invlatiso.js +1 -1
- package/dist/projection/experimental/common/invlatiso.js.map +1 -1
- package/dist/projection/experimental/common/iqsfnz.js +1 -1
- package/dist/projection/experimental/common/iqsfnz.js.map +1 -1
- package/dist/projection/experimental/common/latiso.js +1 -1
- package/dist/projection/experimental/common/latiso.js.map +1 -1
- package/dist/projection/experimental/common/log1py.js +1 -1
- package/dist/projection/experimental/common/log1py.js.map +1 -1
- package/dist/projection/experimental/common/mlfn.js +1 -1
- package/dist/projection/experimental/common/mlfn.js.map +1 -1
- package/dist/projection/experimental/common/msfnz.js +1 -1
- package/dist/projection/experimental/common/msfnz.js.map +1 -1
- package/dist/projection/experimental/common/phi2z.js +1 -1
- package/dist/projection/experimental/common/phi2z.js.map +1 -1
- package/dist/projection/experimental/common/pj_enfn.js +1 -1
- package/dist/projection/experimental/common/pj_enfn.js.map +1 -1
- package/dist/projection/experimental/common/pj_inv_mlfn.js +1 -1
- package/dist/projection/experimental/common/pj_inv_mlfn.js.map +1 -1
- package/dist/projection/experimental/common/pj_mlfn.js +1 -1
- package/dist/projection/experimental/common/pj_mlfn.js.map +1 -1
- package/dist/projection/experimental/common/qsfnz.js +1 -1
- package/dist/projection/experimental/common/qsfnz.js.map +1 -1
- package/dist/projection/experimental/common/sign.js +1 -1
- package/dist/projection/experimental/common/sign.js.map +1 -1
- package/dist/projection/experimental/common/sinh.js +1 -1
- package/dist/projection/experimental/common/sinh.js.map +1 -1
- package/dist/projection/experimental/common/srat.js +1 -1
- package/dist/projection/experimental/common/srat.js.map +1 -1
- package/dist/projection/experimental/common/tsfnz.js +1 -1
- package/dist/projection/experimental/common/tsfnz.js.map +1 -1
- package/dist/projection/experimental/common/vincenty.js +1 -1
- package/dist/projection/experimental/common/vincenty.js.map +1 -1
- package/dist/projection/experimental/core.cjs +100 -2
- package/dist/projection/experimental/core.cjs.map +2 -2
- package/dist/projection/experimental/core.d.ts +1 -0
- package/dist/projection/experimental/core.d.ts.map +1 -1
- package/dist/projection/experimental/crs/datum-table.js +1 -1
- package/dist/projection/experimental/crs/datum-table.js.map +1 -1
- package/dist/projection/experimental/crs/ellipsoid-table.js +1 -1
- package/dist/projection/experimental/crs/ellipsoid-table.js.map +1 -1
- package/dist/projection/experimental/crs/primemeridian-table.js +1 -1
- package/dist/projection/experimental/crs/primemeridian-table.js.map +1 -1
- package/dist/projection/experimental/crs/structured.js +1 -1
- package/dist/projection/experimental/crs/structured.js.map +1 -1
- package/dist/projection/experimental/crs/wkt.js +1 -1
- package/dist/projection/experimental/crs/wkt.js.map +1 -1
- package/dist/projection/experimental/datum.js +1 -1
- package/dist/projection/experimental/datum.js.map +1 -1
- package/dist/projection/experimental/ellipsoidal-gnomonic.js +1 -1
- package/dist/projection/experimental/ellipsoidal-gnomonic.js.map +1 -1
- package/dist/projection/experimental/entries/projections/eqc.cjs +1 -0
- package/dist/projection/experimental/entries/projections/eqc.cjs.map +1 -1
- package/dist/projection/experimental/entries/projections/merc.cjs +1 -0
- package/dist/projection/experimental/entries/projections/merc.cjs.map +1 -1
- package/dist/projection/experimental/grids/geotiff.js +1 -1
- package/dist/projection/experimental/grids/geotiff.js.map +1 -1
- package/dist/projection/experimental/grids/ntv2.js +1 -1
- package/dist/projection/experimental/grids/ntv2.js.map +1 -1
- package/dist/projection/experimental/index.cjs +102 -2
- package/dist/projection/experimental/index.cjs.map +3 -3
- package/dist/projection/experimental/kernels/aea.js +1 -1
- package/dist/projection/experimental/kernels/aea.js.map +1 -1
- package/dist/projection/experimental/kernels/aeqd.js +1 -1
- package/dist/projection/experimental/kernels/aeqd.js.map +1 -1
- package/dist/projection/experimental/kernels/bonne.js +1 -1
- package/dist/projection/experimental/kernels/bonne.js.map +1 -1
- package/dist/projection/experimental/kernels/cass.js +1 -1
- package/dist/projection/experimental/kernels/cass.js.map +1 -1
- package/dist/projection/experimental/kernels/cea.js +1 -1
- package/dist/projection/experimental/kernels/cea.js.map +1 -1
- package/dist/projection/experimental/kernels/eck6.js +1 -1
- package/dist/projection/experimental/kernels/eck6.js.map +1 -1
- package/dist/projection/experimental/kernels/eqdc.js +1 -1
- package/dist/projection/experimental/kernels/eqdc.js.map +1 -1
- package/dist/projection/experimental/kernels/eqearth.js +1 -1
- package/dist/projection/experimental/kernels/eqearth.js.map +1 -1
- package/dist/projection/experimental/kernels/equi.js +1 -1
- package/dist/projection/experimental/kernels/equi.js.map +1 -1
- package/dist/projection/experimental/kernels/etmerc.js +1 -1
- package/dist/projection/experimental/kernels/etmerc.js.map +1 -1
- package/dist/projection/experimental/kernels/gauss.js +1 -1
- package/dist/projection/experimental/kernels/gauss.js.map +1 -1
- package/dist/projection/experimental/kernels/geos.js +1 -1
- package/dist/projection/experimental/kernels/geos.js.map +1 -1
- package/dist/projection/experimental/kernels/gnom.js +1 -1
- package/dist/projection/experimental/kernels/gnom.js.map +1 -1
- package/dist/projection/experimental/kernels/gstmerc.js +1 -1
- package/dist/projection/experimental/kernels/gstmerc.js.map +1 -1
- package/dist/projection/experimental/kernels/krovak.js +1 -1
- package/dist/projection/experimental/kernels/krovak.js.map +1 -1
- package/dist/projection/experimental/kernels/laea.js +1 -1
- package/dist/projection/experimental/kernels/laea.js.map +1 -1
- package/dist/projection/experimental/kernels/lcc.js +1 -1
- package/dist/projection/experimental/kernels/lcc.js.map +1 -1
- package/dist/projection/experimental/kernels/mill.js +1 -1
- package/dist/projection/experimental/kernels/mill.js.map +1 -1
- package/dist/projection/experimental/kernels/moll.js +1 -1
- package/dist/projection/experimental/kernels/moll.js.map +1 -1
- package/dist/projection/experimental/kernels/nzmg.js +1 -1
- package/dist/projection/experimental/kernels/nzmg.js.map +1 -1
- package/dist/projection/experimental/kernels/omerc.js +1 -1
- package/dist/projection/experimental/kernels/omerc.js.map +1 -1
- package/dist/projection/experimental/kernels/poly.js +1 -1
- package/dist/projection/experimental/kernels/poly.js.map +1 -1
- package/dist/projection/experimental/kernels/qsc.js +1 -1
- package/dist/projection/experimental/kernels/qsc.js.map +1 -1
- package/dist/projection/experimental/kernels/robin.js +1 -1
- package/dist/projection/experimental/kernels/robin.js.map +1 -1
- package/dist/projection/experimental/kernels/sinu.js +1 -1
- package/dist/projection/experimental/kernels/sinu.js.map +1 -1
- package/dist/projection/experimental/kernels/somerc.js +1 -1
- package/dist/projection/experimental/kernels/somerc.js.map +1 -1
- package/dist/projection/experimental/kernels/stere.js +1 -1
- package/dist/projection/experimental/kernels/stere.js.map +1 -1
- package/dist/projection/experimental/kernels/sterea.js +1 -1
- package/dist/projection/experimental/kernels/sterea.js.map +1 -1
- package/dist/projection/experimental/kernels/tmerc.js +1 -1
- package/dist/projection/experimental/kernels/tmerc.js.map +1 -1
- package/dist/projection/experimental/kernels/tpers.js +1 -1
- package/dist/projection/experimental/kernels/tpers.js.map +1 -1
- package/dist/projection/experimental/kernels/vandg.js +1 -1
- package/dist/projection/experimental/kernels/vandg.js.map +1 -1
- package/dist/projection/experimental/kinematic-helmert.js +1 -1
- package/dist/projection/experimental/kinematic-helmert.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/index.cjs +100 -2
- package/dist/projection/experimental/lazy-projections/index.cjs.map +2 -2
- package/dist/projection/experimental/projections/equidistant-cylindrical.d.ts.map +1 -1
- package/dist/projection/experimental/projections/equidistant-cylindrical.js +1 -0
- package/dist/projection/experimental/projections/equidistant-cylindrical.js.map +1 -1
- package/dist/projection/experimental/projections/mercator.d.ts.map +1 -1
- package/dist/projection/experimental/projections/mercator.js +1 -0
- package/dist/projection/experimental/projections/mercator.js.map +1 -1
- package/dist/projection/experimental/transform-description.d.ts +8 -0
- package/dist/projection/experimental/transform-description.d.ts.map +1 -0
- package/dist/projection/experimental/transform-description.js +57 -0
- package/dist/projection/experimental/transform-description.js.map +1 -0
- package/dist/projection/experimental/types.d.ts +5 -0
- package/dist/projection/experimental/types.d.ts.map +1 -1
- package/dist/projection/experimental/typescript-projection.d.ts +4 -0
- package/dist/projection/experimental/typescript-projection.d.ts.map +1 -1
- package/dist/projection/experimental/typescript-projection.js +54 -5
- package/dist/projection/experimental/typescript-projection.js.map +1 -1
- package/dist/projection/index.cjs +102 -2
- package/dist/projection/index.cjs.map +3 -3
- package/dist/projection/transform-analysis.cjs +100 -2
- package/dist/projection/transform-analysis.cjs.map +2 -2
- package/dist/projection/transform-description.d.ts +44 -0
- package/dist/projection/transform-description.d.ts.map +1 -0
- package/dist/projection/transform-description.js +5 -0
- package/dist/projection/transform-description.js.map +1 -0
- package/dist/projection/types.d.ts +4 -0
- package/dist/projection/types.d.ts.map +1 -1
- package/dist/tasks/definitions.d.ts +90 -0
- package/dist/tasks/definitions.d.ts.map +1 -0
- package/dist/tasks/definitions.js +54 -0
- package/dist/tasks/definitions.js.map +1 -0
- package/dist/tasks/index.cjs +23439 -0
- package/dist/tasks/index.cjs.map +6 -0
- package/dist/tasks/index.d.ts +24 -0
- package/dist/tasks/index.d.ts.map +1 -0
- package/dist/tasks/index.js +56 -0
- package/dist/tasks/index.js.map +1 -0
- package/dist/tasks/map-worker.d.ts.map +1 -0
- package/dist/tasks/map-worker.js +7 -0
- package/dist/tasks/map-worker.js.map +1 -0
- package/dist/tasks/operations.d.ts +17 -0
- package/dist/tasks/operations.d.ts.map +1 -0
- package/dist/tasks/operations.js +52 -0
- package/dist/tasks/operations.js.map +1 -0
- package/dist/tasks/projection-worker.d.ts.map +1 -0
- package/dist/tasks/projection-worker.js +7 -0
- package/dist/tasks/projection-worker.js.map +1 -0
- package/dist/tasks/terrain-coverage-worker.d.ts +2 -0
- package/dist/tasks/terrain-coverage-worker.d.ts.map +1 -0
- package/dist/tasks/terrain-coverage-worker.js +7 -0
- package/dist/tasks/terrain-coverage-worker.js.map +1 -0
- package/dist/tasks/terrain-coverage.d.ts +25 -0
- package/dist/tasks/terrain-coverage.d.ts.map +1 -0
- package/dist/tasks/terrain-coverage.js +15 -0
- package/dist/tasks/terrain-coverage.js.map +1 -0
- package/dist/tasks/terrain-residency-worker.d.ts +2 -0
- package/dist/tasks/terrain-residency-worker.d.ts.map +1 -0
- package/dist/tasks/terrain-residency-worker.js +7 -0
- package/dist/tasks/terrain-residency-worker.js.map +1 -0
- package/dist/tasks/terrain-residency.d.ts +73 -0
- package/dist/tasks/terrain-residency.d.ts.map +1 -0
- package/dist/tasks/terrain-residency.js +141 -0
- package/dist/tasks/terrain-residency.js.map +1 -0
- package/dist/terrain/bounds-regions.d.ts +15 -0
- package/dist/terrain/bounds-regions.d.ts.map +1 -0
- package/dist/terrain/bounds-regions.js +84 -0
- package/dist/terrain/bounds-regions.js.map +1 -0
- package/dist/terrain/bounds-update.d.ts +11 -0
- package/dist/terrain/bounds-update.d.ts.map +1 -0
- package/dist/terrain/bounds-update.js +10 -0
- package/dist/terrain/bounds-update.js.map +1 -0
- package/dist/terrain/box-index.d.ts +9 -0
- package/dist/terrain/box-index.d.ts.map +1 -0
- package/dist/terrain/box-index.js +43 -0
- package/dist/terrain/box-index.js.map +1 -0
- package/dist/terrain/breakline-mesh.d.ts +18 -0
- package/dist/terrain/breakline-mesh.d.ts.map +1 -0
- package/dist/terrain/breakline-mesh.js +126 -0
- package/dist/terrain/breakline-mesh.js.map +1 -0
- package/dist/terrain/breakline-preprocess.d.ts +11 -0
- package/dist/terrain/breakline-preprocess.d.ts.map +1 -0
- package/dist/terrain/breakline-preprocess.js +94 -0
- package/dist/terrain/breakline-preprocess.js.map +1 -0
- package/dist/terrain/continuous-mesh-error.d.ts +34 -0
- package/dist/terrain/continuous-mesh-error.d.ts.map +1 -0
- package/dist/terrain/continuous-mesh-error.js +221 -0
- package/dist/terrain/continuous-mesh-error.js.map +1 -0
- package/dist/terrain/contour-boundary-diagnostics.d.ts +23 -0
- package/dist/terrain/contour-boundary-diagnostics.d.ts.map +1 -0
- package/dist/terrain/contour-boundary-diagnostics.js +62 -0
- package/dist/terrain/contour-boundary-diagnostics.js.map +1 -0
- package/dist/terrain/contour-mixed-weld.d.ts +25 -0
- package/dist/terrain/contour-mixed-weld.d.ts.map +1 -0
- package/dist/terrain/contour-mixed-weld.js +194 -0
- package/dist/terrain/contour-mixed-weld.js.map +1 -0
- package/dist/terrain/contour-simplify.d.ts +1 -0
- package/dist/terrain/contour-simplify.d.ts.map +1 -1
- package/dist/terrain/contour-simplify.js +5 -1
- package/dist/terrain/contour-simplify.js.map +1 -1
- package/dist/terrain/contour-tile-paths.d.ts +7 -0
- package/dist/terrain/contour-tile-paths.d.ts.map +1 -0
- package/dist/terrain/contour-tile-paths.js +12 -0
- package/dist/terrain/contour-tile-paths.js.map +1 -0
- package/dist/terrain/contour-tile-weld.d.ts +24 -0
- package/dist/terrain/contour-tile-weld.d.ts.map +1 -0
- package/dist/terrain/contour-tile-weld.js +147 -0
- package/dist/terrain/contour-tile-weld.js.map +1 -0
- package/dist/terrain/contour-topology.d.ts +30 -0
- package/dist/terrain/contour-topology.d.ts.map +1 -0
- package/dist/terrain/contour-topology.js +236 -0
- package/dist/terrain/contour-topology.js.map +1 -0
- package/dist/terrain/delatin-regions.d.ts +14 -0
- package/dist/terrain/delatin-regions.d.ts.map +1 -0
- package/dist/terrain/delatin-regions.js +15 -0
- package/dist/terrain/delatin-regions.js.map +1 -0
- package/dist/terrain/dirty-regions.d.ts +11 -0
- package/dist/terrain/dirty-regions.d.ts.map +1 -0
- package/dist/terrain/dirty-regions.js +34 -0
- package/dist/terrain/dirty-regions.js.map +1 -0
- package/dist/terrain/filtered-pyramid.d.ts +22 -0
- package/dist/terrain/filtered-pyramid.d.ts.map +1 -0
- package/dist/terrain/filtered-pyramid.js +71 -0
- package/dist/terrain/filtered-pyramid.js.map +1 -0
- package/dist/terrain/geographic-lod-seams.d.ts +10 -0
- package/dist/terrain/geographic-lod-seams.d.ts.map +1 -0
- package/dist/terrain/geographic-lod-seams.js +100 -0
- package/dist/terrain/geographic-lod-seams.js.map +1 -0
- package/dist/terrain/geographic-neighbor.d.ts +18 -0
- package/dist/terrain/geographic-neighbor.d.ts.map +1 -0
- package/dist/terrain/geographic-neighbor.js +44 -0
- package/dist/terrain/geographic-neighbor.js.map +1 -0
- package/dist/terrain/geographic-poles.d.ts +24 -0
- package/dist/terrain/geographic-poles.d.ts.map +1 -0
- package/dist/terrain/geographic-poles.js +34 -0
- package/dist/terrain/geographic-poles.js.map +1 -0
- package/dist/terrain/geographic-seam.d.ts +21 -0
- package/dist/terrain/geographic-seam.d.ts.map +1 -0
- package/dist/terrain/geographic-seam.js +52 -0
- package/dist/terrain/geographic-seam.js.map +1 -0
- package/dist/terrain/gradient-pyramid-regions.d.ts +15 -0
- package/dist/terrain/gradient-pyramid-regions.d.ts.map +1 -0
- package/dist/terrain/gradient-pyramid-regions.js +112 -0
- package/dist/terrain/gradient-pyramid-regions.js.map +1 -0
- package/dist/terrain/gradient-pyramid-update.d.ts +11 -0
- package/dist/terrain/gradient-pyramid-update.d.ts.map +1 -0
- package/dist/terrain/gradient-pyramid-update.js +17 -0
- package/dist/terrain/gradient-pyramid-update.js.map +1 -0
- package/dist/terrain/gradient-pyramid.d.ts +29 -0
- package/dist/terrain/gradient-pyramid.d.ts.map +1 -0
- package/dist/terrain/gradient-pyramid.js +94 -0
- package/dist/terrain/gradient-pyramid.js.map +1 -0
- package/dist/terrain/height-field.d.ts.map +1 -1
- package/dist/terrain/height-field.js +48 -5
- package/dist/terrain/height-field.js.map +1 -1
- package/dist/terrain/index.cjs +3961 -105
- package/dist/terrain/index.cjs.map +3 -3
- package/dist/terrain/index.d.ts +81 -0
- package/dist/terrain/index.d.ts.map +1 -1
- package/dist/terrain/index.js +50 -0
- package/dist/terrain/index.js.map +1 -1
- package/dist/terrain/isobands-mixed.d.ts +18 -0
- package/dist/terrain/isobands-mixed.d.ts.map +1 -0
- package/dist/terrain/isobands-mixed.js +34 -0
- package/dist/terrain/isobands-mixed.js.map +1 -0
- package/dist/terrain/isobands.d.ts +24 -0
- package/dist/terrain/isobands.d.ts.map +1 -0
- package/dist/terrain/isobands.js +281 -0
- package/dist/terrain/isobands.js.map +1 -0
- package/dist/terrain/lod-coordinate.d.ts +15 -0
- package/dist/terrain/lod-coordinate.d.ts.map +1 -0
- package/dist/terrain/lod-coordinate.js +40 -0
- package/dist/terrain/lod-coordinate.js.map +1 -0
- package/dist/terrain/lod-morph-evaluate.d.ts +8 -0
- package/dist/terrain/lod-morph-evaluate.d.ts.map +1 -0
- package/dist/terrain/lod-morph-evaluate.js +30 -0
- package/dist/terrain/lod-morph-evaluate.js.map +1 -0
- package/dist/terrain/lod-morph.d.ts +35 -0
- package/dist/terrain/lod-morph.d.ts.map +1 -0
- package/dist/terrain/lod-morph.js +87 -0
- package/dist/terrain/lod-morph.js.map +1 -0
- package/dist/terrain/lod-select.d.ts +32 -0
- package/dist/terrain/lod-select.d.ts.map +1 -0
- package/dist/terrain/lod-select.js +60 -0
- package/dist/terrain/lod-select.js.map +1 -0
- package/dist/terrain/lod-stitch.d.ts +15 -0
- package/dist/terrain/lod-stitch.d.ts.map +1 -0
- package/dist/terrain/lod-stitch.js +64 -0
- package/dist/terrain/lod-stitch.js.map +1 -0
- package/dist/terrain/martini-regions.d.ts +14 -0
- package/dist/terrain/martini-regions.d.ts.map +1 -0
- package/dist/terrain/martini-regions.js +26 -0
- package/dist/terrain/martini-regions.js.map +1 -0
- package/dist/terrain/mesh-coverage.d.ts +35 -0
- package/dist/terrain/mesh-coverage.d.ts.map +1 -0
- package/dist/terrain/mesh-coverage.js +186 -0
- package/dist/terrain/mesh-coverage.js.map +1 -0
- package/dist/terrain/mesh-error.d.ts.map +1 -1
- package/dist/terrain/mesh-error.js +9 -1
- package/dist/terrain/mesh-error.js.map +1 -1
- package/dist/terrain/mesh-regions-data.d.ts +24 -0
- package/dist/terrain/mesh-regions-data.d.ts.map +1 -0
- package/dist/terrain/mesh-regions-data.js +90 -0
- package/dist/terrain/mesh-regions-data.js.map +1 -0
- package/dist/terrain/mesh-regions.d.ts +12 -0
- package/dist/terrain/mesh-regions.d.ts.map +1 -0
- package/dist/terrain/mesh-regions.js +10 -0
- package/dist/terrain/mesh-regions.js.map +1 -0
- package/dist/terrain/mesh-update.d.ts +11 -0
- package/dist/terrain/mesh-update.d.ts.map +1 -0
- package/dist/terrain/mesh-update.js +10 -0
- package/dist/terrain/mesh-update.js.map +1 -0
- package/dist/terrain/mixed-gradient-update.d.ts +15 -0
- package/dist/terrain/mixed-gradient-update.d.ts.map +1 -0
- package/dist/terrain/mixed-gradient-update.js +24 -0
- package/dist/terrain/mixed-gradient-update.js.map +1 -0
- package/dist/terrain/mixed-halo-update.d.ts +16 -0
- package/dist/terrain/mixed-halo-update.d.ts.map +1 -0
- package/dist/terrain/mixed-halo-update.js +123 -0
- package/dist/terrain/mixed-halo-update.js.map +1 -0
- package/dist/terrain/mixed-surface.d.ts +27 -0
- package/dist/terrain/mixed-surface.d.ts.map +1 -0
- package/dist/terrain/mixed-surface.js +160 -0
- package/dist/terrain/mixed-surface.js.map +1 -0
- package/dist/terrain/mixed-vertex-halos.d.ts +42 -0
- package/dist/terrain/mixed-vertex-halos.d.ts.map +1 -0
- package/dist/terrain/mixed-vertex-halos.js +163 -0
- package/dist/terrain/mixed-vertex-halos.js.map +1 -0
- package/dist/terrain/persistent-bounds.d.ts +16 -0
- package/dist/terrain/persistent-bounds.d.ts.map +1 -0
- package/dist/terrain/persistent-bounds.js +51 -0
- package/dist/terrain/persistent-bounds.js.map +1 -0
- package/dist/terrain/persistent-gradients.d.ts +16 -0
- package/dist/terrain/persistent-gradients.d.ts.map +1 -0
- package/dist/terrain/persistent-gradients.js +69 -0
- package/dist/terrain/persistent-gradients.js.map +1 -0
- package/dist/terrain/persistent-hierarchy-data.d.ts +41 -0
- package/dist/terrain/persistent-hierarchy-data.d.ts.map +1 -0
- package/dist/terrain/persistent-hierarchy-data.js +130 -0
- package/dist/terrain/persistent-hierarchy-data.js.map +1 -0
- package/dist/terrain/profile-horizon.d.ts +20 -0
- package/dist/terrain/profile-horizon.d.ts.map +1 -0
- package/dist/terrain/profile-horizon.js +69 -0
- package/dist/terrain/profile-horizon.js.map +1 -0
- package/dist/terrain/profile-slope.d.ts +3 -0
- package/dist/terrain/profile-slope.d.ts.map +1 -0
- package/dist/terrain/profile-slope.js +35 -0
- package/dist/terrain/profile-slope.js.map +1 -0
- package/dist/terrain/profile-viewshed.d.ts +17 -0
- package/dist/terrain/profile-viewshed.d.ts.map +1 -0
- package/dist/terrain/profile-viewshed.js +51 -0
- package/dist/terrain/profile-viewshed.js.map +1 -0
- package/dist/terrain/profile-visibility.d.ts +21 -0
- package/dist/terrain/profile-visibility.d.ts.map +1 -0
- package/dist/terrain/profile-visibility.js +61 -0
- package/dist/terrain/profile-visibility.js.map +1 -0
- package/dist/terrain/sample-triangle-height.d.ts +4 -0
- package/dist/terrain/sample-triangle-height.d.ts.map +1 -0
- package/dist/terrain/sample-triangle-height.js +46 -0
- package/dist/terrain/sample-triangle-height.js.map +1 -0
- package/dist/terrain/sweep-capsule.d.ts +27 -0
- package/dist/terrain/sweep-capsule.d.ts.map +1 -0
- package/dist/terrain/sweep-capsule.js +104 -0
- package/dist/terrain/sweep-capsule.js.map +1 -0
- package/dist/terrain/sweep-cylinder.d.ts +16 -0
- package/dist/terrain/sweep-cylinder.d.ts.map +1 -0
- package/dist/terrain/sweep-cylinder.js +52 -0
- package/dist/terrain/sweep-cylinder.js.map +1 -0
- package/dist/terrain/sweep-plane.d.ts +9 -0
- package/dist/terrain/sweep-plane.d.ts.map +1 -0
- package/dist/terrain/sweep-plane.js +52 -0
- package/dist/terrain/sweep-plane.js.map +1 -0
- package/dist/terrain/sweep-polytope.d.ts +38 -0
- package/dist/terrain/sweep-polytope.d.ts.map +1 -0
- package/dist/terrain/sweep-polytope.js +179 -0
- package/dist/terrain/sweep-polytope.js.map +1 -0
- package/dist/terrain/sweep-sphere.d.ts +27 -0
- package/dist/terrain/sweep-sphere.d.ts.map +1 -0
- package/dist/terrain/sweep-sphere.js +69 -0
- package/dist/terrain/sweep-sphere.js.map +1 -0
- package/dist/terrain/tile-update-data.d.ts +14 -0
- package/dist/terrain/tile-update-data.d.ts.map +1 -0
- package/dist/terrain/tile-update-data.js +23 -0
- package/dist/terrain/tile-update-data.js.map +1 -0
- package/dist/terrain/tiled.d.ts +10 -2
- package/dist/terrain/tiled.d.ts.map +1 -1
- package/dist/terrain/tiled.js +5 -1
- package/dist/terrain/tiled.js.map +1 -1
- package/dist/terrain/types.d.ts +6 -0
- package/dist/terrain/types.d.ts.map +1 -1
- package/dist/terrain/valid-domain-mesh.d.ts +29 -0
- package/dist/terrain/valid-domain-mesh.d.ts.map +1 -0
- package/dist/terrain/valid-domain-mesh.js +183 -0
- package/dist/terrain/valid-domain-mesh.js.map +1 -0
- package/dist/terrain/valid-domain-regions.d.ts +16 -0
- package/dist/terrain/valid-domain-regions.d.ts.map +1 -0
- package/dist/terrain/valid-domain-regions.js +19 -0
- package/dist/terrain/valid-domain-regions.js.map +1 -0
- package/dist/terrain/vertex-halo-invalidation.d.ts +16 -0
- package/dist/terrain/vertex-halo-invalidation.d.ts.map +1 -0
- package/dist/terrain/vertex-halo-invalidation.js +50 -0
- package/dist/terrain/vertex-halo-invalidation.js.map +1 -0
- package/dist/terrain/vertex-halo-update.d.ts +18 -0
- package/dist/terrain/vertex-halo-update.d.ts.map +1 -0
- package/dist/terrain/vertex-halo-update.js +76 -0
- package/dist/terrain/vertex-halo-update.js.map +1 -0
- package/dist/terrain/vertex-halos.d.ts +26 -0
- package/dist/terrain/vertex-halos.d.ts.map +1 -0
- package/dist/terrain/vertex-halos.js +80 -0
- package/dist/terrain/vertex-halos.js.map +1 -0
- package/dist/turf/expressions.cjs +87 -0
- package/dist/turf/expressions.cjs.map +6 -0
- package/dist/turf/expressions.d.ts +24 -0
- package/dist/turf/expressions.d.ts.map +1 -0
- package/dist/turf/expressions.js +76 -0
- package/dist/turf/expressions.js.map +1 -0
- package/dist/turf.cjs +94 -676
- package/dist/turf.cjs.map +3 -3
- package/dist/turf.d.ts +10 -1
- package/dist/turf.d.ts.map +1 -1
- package/dist/turf.js +69 -2
- package/dist/turf.js.map +1 -1
- package/package.json +52 -32
- package/src/crs/crs-identifier.ts +86 -0
- package/src/crs/index.ts +1 -0
- package/src/elastic.ts +3 -3
- package/src/expressions.ts +1 -1
- package/src/index.ts +173 -123
- package/src/maps/cap-map.ts +635 -0
- package/src/maps/elastic/geometry.ts +183 -0
- package/src/maps/elastic/map.ts +621 -0
- package/src/maps/elastic/source-arc.ts +129 -0
- package/src/maps/geometry.ts +12 -0
- package/src/maps/global-polygons.ts +327 -0
- package/src/maps/h3-face-map.ts +251 -0
- package/src/maps/map-engine.ts +484 -0
- package/src/maps/map-layout.ts +777 -0
- package/src/maps/map-surface-mesh.ts +229 -0
- package/src/maps/map-transition-mesh.ts +421 -0
- package/src/maps/map-transition.ts +403 -0
- package/src/maps/mercator-map.ts +298 -0
- package/src/maps/polygon-constraints.ts +184 -0
- package/src/maps/prepare-features.ts +393 -0
- package/src/maps/presets.ts +355 -0
- package/src/maps/projection-catalog.ts +132 -0
- package/src/maps/projection-surface.ts +70 -0
- package/src/maps/rotated-map.ts +92 -0
- package/src/maps/source-arc.ts +31 -0
- package/src/maps/spherical-clip/cartesian.ts +43 -0
- package/src/maps/spherical-clip/math.ts +45 -0
- package/src/maps/spherical-clip/pointEqual.ts +10 -0
- package/src/maps/surfaces.ts +7 -0
- package/src/maps/transitions.ts +8 -0
- package/src/maps/world-kernels/collignon.ts +17 -0
- package/src/maps/world-kernels/craster.ts +18 -0
- package/src/maps/world-kernels/eckert1.ts +18 -0
- package/src/maps/world-kernels/eckert2.ts +17 -0
- package/src/maps/world-kernels/eckert3.ts +17 -0
- package/src/maps/world-kernels/eckert4.ts +24 -0
- package/src/maps/world-kernels/eckert5.ts +17 -0
- package/src/maps/world-kernels/eckert6.ts +22 -0
- package/src/maps/world-kernels/fahey.ts +19 -0
- package/src/maps/world-kernels/foucaut.ts +20 -0
- package/src/maps/world-kernels/kavrayskiy7.ts +15 -0
- package/src/maps/world-kernels/math.ts +98 -0
- package/src/maps/world-kernels/miller.ts +15 -0
- package/src/maps/world-kernels/sinusoidal.ts +15 -0
- package/src/maps/world-kernels/wagner6.ts +15 -0
- package/src/maps.ts +168 -0
- package/src/projection/experimental/common/adjust_lat.ts +1 -1
- package/src/projection/experimental/common/adjust_lon.ts +1 -1
- package/src/projection/experimental/common/asinhy.ts +1 -1
- package/src/projection/experimental/common/asinz.ts +1 -1
- package/src/projection/experimental/common/authlat.ts +1 -1
- package/src/projection/experimental/common/authset.ts +1 -1
- package/src/projection/experimental/common/clens.ts +1 -1
- package/src/projection/experimental/common/clens_cmplx.ts +1 -1
- package/src/projection/experimental/common/constants.ts +1 -1
- package/src/projection/experimental/common/cosh.ts +1 -1
- package/src/projection/experimental/common/e0fn.ts +1 -1
- package/src/projection/experimental/common/e1fn.ts +1 -1
- package/src/projection/experimental/common/e2fn.ts +1 -1
- package/src/projection/experimental/common/e3fn.ts +1 -1
- package/src/projection/experimental/common/fL.ts +1 -1
- package/src/projection/experimental/common/gN.ts +1 -1
- package/src/projection/experimental/common/gatg.ts +1 -1
- package/src/projection/experimental/common/hypot.ts +1 -1
- package/src/projection/experimental/common/imlfn.ts +1 -1
- package/src/projection/experimental/common/invlatiso.ts +1 -1
- package/src/projection/experimental/common/iqsfnz.ts +1 -1
- package/src/projection/experimental/common/latiso.ts +1 -1
- package/src/projection/experimental/common/log1py.ts +1 -1
- package/src/projection/experimental/common/mlfn.ts +1 -1
- package/src/projection/experimental/common/msfnz.ts +1 -1
- package/src/projection/experimental/common/phi2z.ts +1 -1
- package/src/projection/experimental/common/pj_enfn.ts +1 -1
- package/src/projection/experimental/common/pj_inv_mlfn.ts +1 -1
- package/src/projection/experimental/common/pj_mlfn.ts +1 -1
- package/src/projection/experimental/common/qsfnz.ts +1 -1
- package/src/projection/experimental/common/sign.ts +1 -1
- package/src/projection/experimental/common/sinh.ts +1 -1
- package/src/projection/experimental/common/srat.ts +1 -1
- package/src/projection/experimental/common/tsfnz.ts +1 -1
- package/src/projection/experimental/common/vincenty.ts +1 -1
- package/src/projection/experimental/core.ts +8 -0
- package/src/projection/experimental/crs/datum-table.ts +1 -1
- package/src/projection/experimental/crs/ellipsoid-table.ts +1 -1
- package/src/projection/experimental/crs/primemeridian-table.ts +1 -1
- package/src/projection/experimental/crs/structured.ts +1 -1
- package/src/projection/experimental/crs/wkt.ts +1 -1
- package/src/projection/experimental/datum.ts +1 -1
- package/src/projection/experimental/ellipsoidal-gnomonic.ts +1 -1
- package/src/projection/experimental/exact-helmert.ts +1 -1
- package/src/projection/experimental/grids/geotiff.ts +1 -1
- package/src/projection/experimental/grids/grid.ts +1 -1
- package/src/projection/experimental/grids/ntv2.ts +1 -1
- package/src/projection/experimental/helmert-flat.ts +1 -1
- package/src/projection/experimental/kernels/aea.ts +1 -1
- package/src/projection/experimental/kernels/aeqd.ts +1 -1
- package/src/projection/experimental/kernels/bonne.ts +1 -1
- package/src/projection/experimental/kernels/cass.ts +1 -1
- package/src/projection/experimental/kernels/cea.ts +1 -1
- package/src/projection/experimental/kernels/eck6.ts +1 -1
- package/src/projection/experimental/kernels/eqdc.ts +1 -1
- package/src/projection/experimental/kernels/eqearth.ts +1 -1
- package/src/projection/experimental/kernels/equi.ts +1 -1
- package/src/projection/experimental/kernels/etmerc.ts +1 -1
- package/src/projection/experimental/kernels/gauss.ts +1 -1
- package/src/projection/experimental/kernels/geos.ts +1 -1
- package/src/projection/experimental/kernels/gnom.ts +1 -1
- package/src/projection/experimental/kernels/gstmerc.ts +1 -1
- package/src/projection/experimental/kernels/krovak.ts +1 -1
- package/src/projection/experimental/kernels/laea.ts +1 -1
- package/src/projection/experimental/kernels/lcc.ts +1 -1
- package/src/projection/experimental/kernels/mill.ts +1 -1
- package/src/projection/experimental/kernels/moll.ts +1 -1
- package/src/projection/experimental/kernels/nzmg.ts +1 -1
- package/src/projection/experimental/kernels/omerc.ts +1 -1
- package/src/projection/experimental/kernels/ortho.ts +1 -1
- package/src/projection/experimental/kernels/poly.ts +1 -1
- package/src/projection/experimental/kernels/qsc.ts +1 -1
- package/src/projection/experimental/kernels/robin.ts +1 -1
- package/src/projection/experimental/kernels/sinu.ts +1 -1
- package/src/projection/experimental/kernels/somerc.ts +1 -1
- package/src/projection/experimental/kernels/stere.ts +1 -1
- package/src/projection/experimental/kernels/sterea.ts +1 -1
- package/src/projection/experimental/kernels/tmerc.ts +1 -1
- package/src/projection/experimental/kernels/tpers.ts +1 -1
- package/src/projection/experimental/kernels/vandg.ts +1 -1
- package/src/projection/experimental/kinematic-helmert-flat.ts +1 -1
- package/src/projection/experimental/kinematic-helmert.ts +1 -1
- package/src/projection/experimental/projection-pipeline.ts +1 -1
- package/src/projection/experimental/projections/equidistant-cylindrical.ts +1 -0
- package/src/projection/experimental/projections/mercator.ts +1 -0
- package/src/projection/experimental/projections/ob-tran.ts +1 -1
- package/src/projection/experimental/transform-description.ts +82 -0
- package/src/projection/experimental/types.ts +5 -0
- package/src/projection/experimental/typescript-projection.ts +54 -6
- package/src/projection/transform-description.ts +69 -0
- package/src/projection/types.ts +11 -0
- package/src/tasks/definitions.ts +89 -0
- package/src/tasks/index.ts +73 -0
- package/src/tasks/map-worker.ts +6 -0
- package/src/tasks/operations.ts +77 -0
- package/src/tasks/projection-worker.ts +6 -0
- package/src/tasks/terrain-coverage-worker.ts +6 -0
- package/src/tasks/terrain-coverage.ts +25 -0
- package/src/tasks/terrain-residency-worker.ts +6 -0
- package/src/tasks/terrain-residency.ts +185 -0
- package/src/terrain/bounds-regions.ts +106 -0
- package/src/terrain/bounds-update.ts +19 -0
- package/src/terrain/box-index.ts +47 -0
- package/src/terrain/breakline-mesh.ts +164 -0
- package/src/terrain/breakline-preprocess.ts +106 -0
- package/src/terrain/cdt2d.d.ts +10 -0
- package/src/terrain/continuous-mesh-error.ts +321 -0
- package/src/terrain/contour-boundary-diagnostics.ts +90 -0
- package/src/terrain/contour-mixed-weld.ts +254 -0
- package/src/terrain/contour-simplify.ts +10 -2
- package/src/terrain/contour-tile-paths.ts +20 -0
- package/src/terrain/contour-tile-weld.ts +182 -0
- package/src/terrain/contour-topology.ts +263 -0
- package/src/terrain/delatin-regions.ts +25 -0
- package/src/terrain/dirty-regions.ts +61 -0
- package/src/terrain/filtered-pyramid.ts +95 -0
- package/src/terrain/geographic-lod-seams.ts +109 -0
- package/src/terrain/geographic-neighbor.ts +58 -0
- package/src/terrain/geographic-poles.ts +52 -0
- package/src/terrain/geographic-seam.ts +73 -0
- package/src/terrain/gradient-pyramid-regions.ts +140 -0
- package/src/terrain/gradient-pyramid-update.ts +25 -0
- package/src/terrain/gradient-pyramid.ts +129 -0
- package/src/terrain/height-field.ts +45 -5
- package/src/terrain/index.ts +162 -0
- package/src/terrain/isobands-mixed.ts +49 -0
- package/src/terrain/isobands.ts +348 -0
- package/src/terrain/lod-coordinate.ts +57 -0
- package/src/terrain/lod-morph-evaluate.ts +36 -0
- package/src/terrain/lod-morph.ts +138 -0
- package/src/terrain/lod-select.ts +95 -0
- package/src/terrain/lod-stitch.ts +88 -0
- package/src/terrain/martini-regions.ts +38 -0
- package/src/terrain/mesh-coverage.ts +215 -0
- package/src/terrain/mesh-error.ts +14 -1
- package/src/terrain/mesh-regions-data.ts +121 -0
- package/src/terrain/mesh-regions.ts +18 -0
- package/src/terrain/mesh-update.ts +15 -0
- package/src/terrain/mixed-gradient-update.ts +40 -0
- package/src/terrain/mixed-halo-update.ts +144 -0
- package/src/terrain/mixed-surface.ts +232 -0
- package/src/terrain/mixed-vertex-halos.ts +224 -0
- package/src/terrain/persistent-bounds.ts +95 -0
- package/src/terrain/persistent-gradients.ts +117 -0
- package/src/terrain/persistent-hierarchy-data.ts +196 -0
- package/src/terrain/profile-horizon.ts +86 -0
- package/src/terrain/profile-slope.ts +32 -0
- package/src/terrain/profile-viewshed.ts +57 -0
- package/src/terrain/profile-visibility.ts +81 -0
- package/src/terrain/sample-triangle-height.ts +50 -0
- package/src/terrain/sweep-capsule.ts +148 -0
- package/src/terrain/sweep-cylinder.ts +64 -0
- package/src/terrain/sweep-plane.ts +61 -0
- package/src/terrain/sweep-polytope.ts +229 -0
- package/src/terrain/sweep-sphere.ts +100 -0
- package/src/terrain/tile-update-data.ts +32 -0
- package/src/terrain/tiled.ts +16 -3
- package/src/terrain/types.ts +9 -1
- package/src/terrain/valid-domain-mesh.ts +221 -0
- package/src/terrain/valid-domain-regions.ts +41 -0
- package/src/terrain/vertex-halo-invalidation.ts +57 -0
- package/src/terrain/vertex-halo-update.ts +91 -0
- package/src/terrain/vertex-halos.ts +101 -0
- package/src/turf/expressions.ts +97 -0
- package/src/turf.ts +93 -3
- package/crs/README.md +0 -84
- package/crs/schemas/README.md +0 -9
- package/dist/discontinuous/air-ocean-mesh.d.ts.map +0 -1
- package/dist/discontinuous/air-ocean-mesh.js.map +0 -1
- package/dist/discontinuous/albers-usa.d.ts.map +0 -1
- package/dist/discontinuous/albers-usa.js.map +0 -1
- package/dist/discontinuous/cap-map.d.ts.map +0 -1
- package/dist/discontinuous/cap-map.js +0 -314
- package/dist/discontinuous/cap-map.js.map +0 -1
- package/dist/discontinuous/elastic/data.d.ts.map +0 -1
- package/dist/discontinuous/elastic/data.js.map +0 -1
- package/dist/discontinuous/elastic/elasticI.d.ts.map +0 -1
- package/dist/discontinuous/elastic/elasticI.js.map +0 -1
- package/dist/discontinuous/elastic/elasticII.d.ts.map +0 -1
- package/dist/discontinuous/elastic/elasticII.js.map +0 -1
- package/dist/discontinuous/elastic/elasticIII.d.ts.map +0 -1
- package/dist/discontinuous/elastic/elasticIII.js.map +0 -1
- package/dist/discontinuous/elastic/geometry.d.ts +0 -22
- package/dist/discontinuous/elastic/geometry.d.ts.map +0 -1
- package/dist/discontinuous/elastic/geometry.js +0 -131
- package/dist/discontinuous/elastic/geometry.js.map +0 -1
- package/dist/discontinuous/elastic/grid.d.ts.map +0 -1
- package/dist/discontinuous/elastic/grid.js.map +0 -1
- package/dist/discontinuous/elastic/map.d.ts.map +0 -1
- package/dist/discontinuous/elastic/map.js +0 -260
- package/dist/discontinuous/elastic/map.js.map +0 -1
- package/dist/discontinuous/global-polygons.d.ts +0 -35
- package/dist/discontinuous/global-polygons.d.ts.map +0 -1
- package/dist/discontinuous/global-polygons.js +0 -215
- package/dist/discontinuous/global-polygons.js.map +0 -1
- package/dist/discontinuous/gray-fuller.d.ts.map +0 -1
- package/dist/discontinuous/gray-fuller.js.map +0 -1
- package/dist/discontinuous/gringorten-kernel.d.ts.map +0 -1
- package/dist/discontinuous/gringorten-kernel.js.map +0 -1
- package/dist/discontinuous/healpix.d.ts.map +0 -1
- package/dist/discontinuous/healpix.js.map +0 -1
- package/dist/discontinuous/layout.d.ts.map +0 -1
- package/dist/discontinuous/layout.js.map +0 -1
- package/dist/discontinuous/map-engine.d.ts +0 -214
- package/dist/discontinuous/map-engine.d.ts.map +0 -1
- package/dist/discontinuous/map-engine.js +0 -408
- package/dist/discontinuous/map-engine.js.map +0 -1
- package/dist/discontinuous/map-layout.d.ts +0 -93
- package/dist/discontinuous/map-layout.d.ts.map +0 -1
- package/dist/discontinuous/map-layout.js +0 -490
- package/dist/discontinuous/map-layout.js.map +0 -1
- package/dist/discontinuous/map-transition.d.ts.map +0 -1
- package/dist/discontinuous/map-transition.js +0 -283
- package/dist/discontinuous/map-transition.js.map +0 -1
- package/dist/discontinuous/math.d.ts.map +0 -1
- package/dist/discontinuous/math.js.map +0 -1
- package/dist/discontinuous/mercator-map.d.ts +0 -24
- package/dist/discontinuous/mercator-map.d.ts.map +0 -1
- package/dist/discontinuous/mercator-map.js +0 -134
- package/dist/discontinuous/mercator-map.js.map +0 -1
- package/dist/discontinuous/myriahedral/graticule.d.ts.map +0 -1
- package/dist/discontinuous/myriahedral/graticule.js.map +0 -1
- package/dist/discontinuous/myriahedral/mesh.d.ts.map +0 -1
- package/dist/discontinuous/myriahedral/mesh.js.map +0 -1
- package/dist/discontinuous/myriahedral/unfold.d.ts.map +0 -1
- package/dist/discontinuous/myriahedral/unfold.js.map +0 -1
- package/dist/discontinuous/myriahedral.d.ts.map +0 -1
- package/dist/discontinuous/myriahedral.js.map +0 -1
- package/dist/discontinuous/petroff.d.ts.map +0 -1
- package/dist/discontinuous/petroff.js.map +0 -1
- package/dist/discontinuous/polyhedral.d.ts.map +0 -1
- package/dist/discontinuous/polyhedral.js.map +0 -1
- package/dist/discontinuous/prepare-features.d.ts +0 -81
- package/dist/discontinuous/prepare-features.d.ts.map +0 -1
- package/dist/discontinuous/prepare-features.js +0 -149
- package/dist/discontinuous/prepare-features.js.map +0 -1
- package/dist/discontinuous/presets.d.ts +0 -71
- package/dist/discontinuous/presets.d.ts.map +0 -1
- package/dist/discontinuous/presets.js +0 -372
- package/dist/discontinuous/presets.js.map +0 -1
- package/dist/discontinuous/projection-catalog.d.ts.map +0 -1
- package/dist/discontinuous/projection-catalog.js +0 -96
- package/dist/discontinuous/projection-catalog.js.map +0 -1
- package/dist/discontinuous/quincuncial-kernel.d.ts.map +0 -1
- package/dist/discontinuous/quincuncial-kernel.js.map +0 -1
- package/dist/discontinuous/quincuncial-star.d.ts.map +0 -1
- package/dist/discontinuous/quincuncial-star.js.map +0 -1
- package/dist/discontinuous/regional-map.d.ts.map +0 -1
- package/dist/discontinuous/regional-map.js.map +0 -1
- package/dist/discontinuous/retroazimuthal-map.d.ts.map +0 -1
- package/dist/discontinuous/retroazimuthal-map.js.map +0 -1
- package/dist/discontinuous/rotated-map.d.ts +0 -31
- package/dist/discontinuous/rotated-map.d.ts.map +0 -1
- package/dist/discontinuous/rotated-map.js +0 -66
- package/dist/discontinuous/rotated-map.js.map +0 -1
- package/dist/discontinuous/snyder-mesh.d.ts.map +0 -1
- package/dist/discontinuous/snyder-mesh.js.map +0 -1
- package/dist/discontinuous/snyder.d.ts.map +0 -1
- package/dist/discontinuous/snyder.js.map +0 -1
- package/dist/discontinuous/spherical-clip/cartesian.d.ts +0 -8
- package/dist/discontinuous/spherical-clip/cartesian.d.ts.map +0 -1
- package/dist/discontinuous/spherical-clip/cartesian.js.map +0 -1
- package/dist/discontinuous/spherical-clip/circle.d.ts.map +0 -1
- package/dist/discontinuous/spherical-clip/circle.js.map +0 -1
- package/dist/discontinuous/spherical-clip/clip-buffer.d.ts.map +0 -1
- package/dist/discontinuous/spherical-clip/clip-buffer.js.map +0 -1
- package/dist/discontinuous/spherical-clip/clip-circle.d.ts.map +0 -1
- package/dist/discontinuous/spherical-clip/clip-circle.js.map +0 -1
- package/dist/discontinuous/spherical-clip/clip-index.d.ts.map +0 -1
- package/dist/discontinuous/spherical-clip/clip-index.js.map +0 -1
- package/dist/discontinuous/spherical-clip/clip-rejoin.d.ts.map +0 -1
- package/dist/discontinuous/spherical-clip/clip-rejoin.js.map +0 -1
- package/dist/discontinuous/spherical-clip/helpers.d.ts.map +0 -1
- package/dist/discontinuous/spherical-clip/helpers.js.map +0 -1
- package/dist/discontinuous/spherical-clip/math.d.ts +0 -26
- package/dist/discontinuous/spherical-clip/math.d.ts.map +0 -1
- package/dist/discontinuous/spherical-clip/math.js.map +0 -1
- package/dist/discontinuous/spherical-clip/noop.d.ts.map +0 -1
- package/dist/discontinuous/spherical-clip/noop.js.map +0 -1
- package/dist/discontinuous/spherical-clip/pointEqual.d.ts +0 -2
- package/dist/discontinuous/spherical-clip/pointEqual.d.ts.map +0 -1
- package/dist/discontinuous/spherical-clip/pointEqual.js.map +0 -1
- package/dist/discontinuous/spherical-clip/polygonContains.d.ts.map +0 -1
- package/dist/discontinuous/spherical-clip/polygonContains.js.map +0 -1
- package/dist/discontinuous/world-composite-kernels.d.ts.map +0 -1
- package/dist/discontinuous/world-composite-kernels.js.map +0 -1
- package/dist/discontinuous/world-kernels/airy.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/airy.js.map +0 -1
- package/dist/discontinuous/world-kernels/aitoff.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/aitoff.js.map +0 -1
- package/dist/discontinuous/world-kernels/armadillo.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/armadillo.js.map +0 -1
- package/dist/discontinuous/world-kernels/august.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/august.js.map +0 -1
- package/dist/discontinuous/world-kernels/baker.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/baker.js.map +0 -1
- package/dist/discontinuous/world-kernels/bertin.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/bertin.js.map +0 -1
- package/dist/discontinuous/world-kernels/boggs.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/boggs.js.map +0 -1
- package/dist/discontinuous/world-kernels/bonne.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/bonne.js.map +0 -1
- package/dist/discontinuous/world-kernels/bottomley.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/bottomley.js.map +0 -1
- package/dist/discontinuous/world-kernels/bromley.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/bromley.js.map +0 -1
- package/dist/discontinuous/world-kernels/chamberlin.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/chamberlin.js.map +0 -1
- package/dist/discontinuous/world-kernels/collignon.d.ts +0 -5
- package/dist/discontinuous/world-kernels/collignon.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/collignon.js.map +0 -1
- package/dist/discontinuous/world-kernels/craig.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/craig.js.map +0 -1
- package/dist/discontinuous/world-kernels/craster.d.ts +0 -5
- package/dist/discontinuous/world-kernels/craster.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/craster.js.map +0 -1
- package/dist/discontinuous/world-kernels/cylindricalEqualArea.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/cylindricalEqualArea.js.map +0 -1
- package/dist/discontinuous/world-kernels/cylindricalStereographic.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/cylindricalStereographic.js.map +0 -1
- package/dist/discontinuous/world-kernels/d3-geo-raw.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/d3-geo-raw.js.map +0 -1
- package/dist/discontinuous/world-kernels/eckert1.d.ts +0 -5
- package/dist/discontinuous/world-kernels/eckert1.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/eckert1.js.map +0 -1
- package/dist/discontinuous/world-kernels/eckert2.d.ts +0 -5
- package/dist/discontinuous/world-kernels/eckert2.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/eckert2.js.map +0 -1
- package/dist/discontinuous/world-kernels/eckert3.d.ts +0 -5
- package/dist/discontinuous/world-kernels/eckert3.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/eckert3.js.map +0 -1
- package/dist/discontinuous/world-kernels/eckert4.d.ts +0 -5
- package/dist/discontinuous/world-kernels/eckert4.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/eckert4.js.map +0 -1
- package/dist/discontinuous/world-kernels/eckert5.d.ts +0 -5
- package/dist/discontinuous/world-kernels/eckert5.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/eckert5.js.map +0 -1
- package/dist/discontinuous/world-kernels/eckert6.d.ts +0 -5
- package/dist/discontinuous/world-kernels/eckert6.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/eckert6.js.map +0 -1
- package/dist/discontinuous/world-kernels/eisenlohr.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/eisenlohr.js.map +0 -1
- package/dist/discontinuous/world-kernels/fahey.d.ts +0 -5
- package/dist/discontinuous/world-kernels/fahey.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/fahey.js.map +0 -1
- package/dist/discontinuous/world-kernels/foucaut.d.ts +0 -5
- package/dist/discontinuous/world-kernels/foucaut.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/foucaut.js.map +0 -1
- package/dist/discontinuous/world-kernels/foucautSinusoidal.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/foucautSinusoidal.js.map +0 -1
- package/dist/discontinuous/world-kernels/ginzburg4.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/ginzburg4.js.map +0 -1
- package/dist/discontinuous/world-kernels/ginzburg5.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/ginzburg5.js.map +0 -1
- package/dist/discontinuous/world-kernels/ginzburg6.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/ginzburg6.js.map +0 -1
- package/dist/discontinuous/world-kernels/ginzburg8.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/ginzburg8.js.map +0 -1
- package/dist/discontinuous/world-kernels/ginzburg9.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/ginzburg9.js.map +0 -1
- package/dist/discontinuous/world-kernels/ginzburgPolyconic.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/ginzburgPolyconic.js.map +0 -1
- package/dist/discontinuous/world-kernels/hammer.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/hammer.js.map +0 -1
- package/dist/discontinuous/world-kernels/hammerRetroazimuthal.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/hammerRetroazimuthal.js.map +0 -1
- package/dist/discontinuous/world-kernels/hill.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/hill.js.map +0 -1
- package/dist/discontinuous/world-kernels/homolosine.d.ts +0 -5
- package/dist/discontinuous/world-kernels/homolosine.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/homolosine.js.map +0 -1
- package/dist/discontinuous/world-kernels/hufnagel.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/hufnagel.js.map +0 -1
- package/dist/discontinuous/world-kernels/hyperelliptical.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/hyperelliptical.js.map +0 -1
- package/dist/discontinuous/world-kernels/integrate.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/integrate.js.map +0 -1
- package/dist/discontinuous/world-kernels/kavrayskiy7.d.ts +0 -5
- package/dist/discontinuous/world-kernels/kavrayskiy7.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/kavrayskiy7.js.map +0 -1
- package/dist/discontinuous/world-kernels/lagrange.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/lagrange.js.map +0 -1
- package/dist/discontinuous/world-kernels/larrivee.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/larrivee.js.map +0 -1
- package/dist/discontinuous/world-kernels/laskowski.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/laskowski.js.map +0 -1
- package/dist/discontinuous/world-kernels/littrow.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/littrow.js.map +0 -1
- package/dist/discontinuous/world-kernels/loximuthal.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/loximuthal.js.map +0 -1
- package/dist/discontinuous/world-kernels/math.d.ts +0 -36
- package/dist/discontinuous/world-kernels/math.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/math.js.map +0 -1
- package/dist/discontinuous/world-kernels/miller.d.ts +0 -5
- package/dist/discontinuous/world-kernels/miller.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/miller.js.map +0 -1
- package/dist/discontinuous/world-kernels/modifiedStereographic.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/modifiedStereographic.js.map +0 -1
- package/dist/discontinuous/world-kernels/mollweide.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/mollweide.js.map +0 -1
- package/dist/discontinuous/world-kernels/mtFlatPolarParabolic.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/mtFlatPolarParabolic.js.map +0 -1
- package/dist/discontinuous/world-kernels/mtFlatPolarQuartic.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/mtFlatPolarQuartic.js.map +0 -1
- package/dist/discontinuous/world-kernels/mtFlatPolarSinusoidal.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/mtFlatPolarSinusoidal.js.map +0 -1
- package/dist/discontinuous/world-kernels/naturalEarth2.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/naturalEarth2.js.map +0 -1
- package/dist/discontinuous/world-kernels/nellHammer.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/nellHammer.js.map +0 -1
- package/dist/discontinuous/world-kernels/newton.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/newton.js.map +0 -1
- package/dist/discontinuous/world-kernels/nicolosi.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/nicolosi.js.map +0 -1
- package/dist/discontinuous/world-kernels/patterson.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/patterson.js.map +0 -1
- package/dist/discontinuous/world-kernels/polyconic.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/polyconic.js.map +0 -1
- package/dist/discontinuous/world-kernels/rectangularPolyconic.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/rectangularPolyconic.js.map +0 -1
- package/dist/discontinuous/world-kernels/robinson.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/robinson.js.map +0 -1
- package/dist/discontinuous/world-kernels/satellite.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/satellite.js.map +0 -1
- package/dist/discontinuous/world-kernels/sinuMollweide.d.ts +0 -7
- package/dist/discontinuous/world-kernels/sinuMollweide.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/sinuMollweide.js.map +0 -1
- package/dist/discontinuous/world-kernels/sinusoidal.d.ts +0 -5
- package/dist/discontinuous/world-kernels/sinusoidal.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/sinusoidal.js.map +0 -1
- package/dist/discontinuous/world-kernels/times.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/times.js.map +0 -1
- package/dist/discontinuous/world-kernels/twoPointEquidistant.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/twoPointEquidistant.js.map +0 -1
- package/dist/discontinuous/world-kernels/vanDerGrinten.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/vanDerGrinten.js.map +0 -1
- package/dist/discontinuous/world-kernels/vanDerGrinten2.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/vanDerGrinten2.js.map +0 -1
- package/dist/discontinuous/world-kernels/vanDerGrinten3.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/vanDerGrinten3.js.map +0 -1
- package/dist/discontinuous/world-kernels/vanDerGrinten4.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/vanDerGrinten4.js.map +0 -1
- package/dist/discontinuous/world-kernels/wagner.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/wagner.js.map +0 -1
- package/dist/discontinuous/world-kernels/wagner4.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/wagner4.js.map +0 -1
- package/dist/discontinuous/world-kernels/wagner6.d.ts +0 -5
- package/dist/discontinuous/world-kernels/wagner6.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/wagner6.js.map +0 -1
- package/dist/discontinuous/world-kernels/wiechel.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/wiechel.js.map +0 -1
- package/dist/discontinuous/world-kernels/winkel3.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels/winkel3.js.map +0 -1
- package/dist/discontinuous/world-kernels.d.ts +0 -150
- package/dist/discontinuous/world-kernels.d.ts.map +0 -1
- package/dist/discontinuous/world-kernels.js.map +0 -1
- package/dist/discontinuous/world-map.d.ts.map +0 -1
- package/dist/discontinuous/world-map.js.map +0 -1
- package/dist/discontinuous.cjs +0 -7310
- package/dist/discontinuous.cjs.map +0 -6
- package/dist/discontinuous.d.ts +0 -52
- package/dist/discontinuous.d.ts.map +0 -1
- package/dist/discontinuous.js +0 -36
- package/dist/discontinuous.js.map +0 -1
- package/dist/geoarrow/builder-entry.d.ts +0 -4
- package/dist/geoarrow/builder-entry.d.ts.map +0 -1
- package/dist/geoarrow/builder-entry.js +0 -5
- package/dist/geoarrow/builder-entry.js.map +0 -1
- package/dist/geoarrow/builder.d.ts +0 -106
- package/dist/geoarrow/builder.d.ts.map +0 -1
- package/dist/geoarrow/builder.js +0 -668
- package/dist/geoarrow/builder.js.map +0 -1
- package/dist/geoarrow/codecs.d.ts +0 -24
- package/dist/geoarrow/codecs.d.ts.map +0 -1
- package/dist/geoarrow/codecs.js +0 -916
- package/dist/geoarrow/codecs.js.map +0 -1
- package/dist/geoarrow/index.cjs +0 -4352
- package/dist/geoarrow/index.cjs.map +0 -6
- package/dist/geoarrow/index.d.ts +0 -21
- package/dist/geoarrow/index.d.ts.map +0 -1
- package/dist/geoarrow/index.js +0 -15
- package/dist/geoarrow/index.js.map +0 -1
- package/dist/geoarrow/kernels.d.ts +0 -56
- package/dist/geoarrow/kernels.d.ts.map +0 -1
- package/dist/geoarrow/kernels.js +0 -982
- package/dist/geoarrow/kernels.js.map +0 -1
- package/dist/geoarrow/layout.d.ts +0 -66
- package/dist/geoarrow/layout.d.ts.map +0 -1
- package/dist/geoarrow/layout.js +0 -723
- package/dist/geoarrow/layout.js.map +0 -1
- package/dist/geoarrow/stream-tessellate.d.ts +0 -34
- package/dist/geoarrow/stream-tessellate.d.ts.map +0 -1
- package/dist/geoarrow/stream-tessellate.js +0 -171
- package/dist/geoarrow/stream-tessellate.js.map +0 -1
- package/dist/geoarrow/stream.d.ts +0 -29
- package/dist/geoarrow/stream.d.ts.map +0 -1
- package/dist/geoarrow/stream.js +0 -100
- package/dist/geoarrow/stream.js.map +0 -1
- package/dist/geoarrow/tessellate.d.ts +0 -31
- package/dist/geoarrow/tessellate.d.ts.map +0 -1
- package/dist/geoarrow/tessellate.js +0 -102
- package/dist/geoarrow/tessellate.js.map +0 -1
- package/dist/geoarrow/tessellation-entry.d.ts +0 -4
- package/dist/geoarrow/tessellation-entry.d.ts.map +0 -1
- package/dist/geoarrow/tessellation-entry.js +0 -5
- package/dist/geoarrow/tessellation-entry.js.map +0 -1
- package/dist/geoarrow/types.d.ts +0 -155
- package/dist/geoarrow/types.d.ts.map +0 -1
- package/dist/geoarrow/types.js +0 -71
- package/dist/geoarrow/types.js.map +0 -1
- package/dist/geoarrow/views.d.ts +0 -45
- package/dist/geoarrow/views.d.ts.map +0 -1
- package/dist/geoarrow/views.js +0 -114
- package/dist/geoarrow/views.js.map +0 -1
- package/dist/geoarrow/wkb-entry.d.ts +0 -4
- package/dist/geoarrow/wkb-entry.d.ts.map +0 -1
- package/dist/geoarrow/wkb-entry.js +0 -6
- package/dist/geoarrow/wkb-entry.js.map +0 -1
- package/dist/geoarrow/worker.d.ts +0 -11
- package/dist/geoarrow/worker.d.ts.map +0 -1
- package/dist/geoarrow/worker.js +0 -10
- package/dist/geoarrow/worker.js.map +0 -1
- package/dist/wkb/index.d.ts +0 -11
- package/dist/wkb/index.d.ts.map +0 -1
- package/dist/wkb/index.js +0 -9
- package/dist/wkb/index.js.map +0 -1
- package/dist/wkb/types.d.ts +0 -30
- package/dist/wkb/types.d.ts.map +0 -1
- package/dist/wkb/types.js +0 -34
- package/dist/wkb/types.js.map +0 -1
- package/dist/wkb/wkb-builder.d.ts +0 -91
- package/dist/wkb/wkb-builder.d.ts.map +0 -1
- package/dist/wkb/wkb-builder.js +0 -283
- package/dist/wkb/wkb-builder.js.map +0 -1
- package/dist/wkb/wkb-reader.d.ts +0 -74
- package/dist/wkb/wkb-reader.d.ts.map +0 -1
- package/dist/wkb/wkb-reader.js +0 -251
- package/dist/wkb/wkb-reader.js.map +0 -1
- package/dist/wkb/wkb.d.ts +0 -21
- package/dist/wkb/wkb.d.ts.map +0 -1
- package/dist/wkb/wkb.js +0 -204
- package/dist/wkb/wkb.js.map +0 -1
- package/dist/wkb/wkt.d.ts +0 -19
- package/dist/wkb/wkt.d.ts.map +0 -1
- package/dist/wkb/wkt.js +0 -321
- package/dist/wkb/wkt.js.map +0 -1
- package/dist/workers/index.cjs +0 -20879
- package/dist/workers/index.cjs.map +0 -6
- package/dist/workers/index.d.ts +0 -12
- package/dist/workers/index.d.ts.map +0 -1
- package/dist/workers/index.js +0 -41
- package/dist/workers/index.js.map +0 -1
- package/dist/workers/map-worker.d.ts.map +0 -1
- package/dist/workers/map-worker.js +0 -7
- package/dist/workers/map-worker.js.map +0 -1
- package/dist/workers/operations.cjs +0 -20036
- package/dist/workers/operations.cjs.map +0 -6
- package/dist/workers/operations.d.ts +0 -15
- package/dist/workers/operations.d.ts.map +0 -1
- package/dist/workers/operations.js +0 -46
- package/dist/workers/operations.js.map +0 -1
- package/dist/workers/projection-worker.d.ts.map +0 -1
- package/dist/workers/projection-worker.js +0 -7
- package/dist/workers/projection-worker.js.map +0 -1
- package/projection/THIRD-PARTY-NOTICES.md +0 -210
- package/src/discontinuous/cap-map.ts +0 -406
- package/src/discontinuous/elastic/README.md +0 -20
- package/src/discontinuous/elastic/geometry.ts +0 -172
- package/src/discontinuous/elastic/map.ts +0 -317
- package/src/discontinuous/global-polygons.ts +0 -273
- package/src/discontinuous/map-engine.ts +0 -602
- package/src/discontinuous/map-layout.ts +0 -605
- package/src/discontinuous/map-transition.ts +0 -339
- package/src/discontinuous/mercator-map.ts +0 -160
- package/src/discontinuous/prepare-features.ts +0 -245
- package/src/discontinuous/projection-catalog.ts +0 -132
- package/src/discontinuous/rotated-map.ts +0 -86
- package/src/discontinuous/spherical-clip/README.md +0 -16
- package/src/discontinuous/spherical-clip/cartesian.js +0 -43
- package/src/discontinuous/spherical-clip/math.js +0 -45
- package/src/discontinuous/spherical-clip/pointEqual.js +0 -10
- package/src/discontinuous/world-kernels/README.md +0 -24
- package/src/discontinuous/world-kernels/collignon.js +0 -17
- package/src/discontinuous/world-kernels/craster.js +0 -18
- package/src/discontinuous/world-kernels/eckert1.js +0 -18
- package/src/discontinuous/world-kernels/eckert2.js +0 -17
- package/src/discontinuous/world-kernels/eckert3.js +0 -17
- package/src/discontinuous/world-kernels/eckert4.js +0 -24
- package/src/discontinuous/world-kernels/eckert5.js +0 -17
- package/src/discontinuous/world-kernels/eckert6.js +0 -22
- package/src/discontinuous/world-kernels/fahey.js +0 -19
- package/src/discontinuous/world-kernels/foucaut.js +0 -20
- package/src/discontinuous/world-kernels/kavrayskiy7.js +0 -15
- package/src/discontinuous/world-kernels/math.js +0 -98
- package/src/discontinuous/world-kernels/miller.js +0 -15
- package/src/discontinuous/world-kernels/sinusoidal.js +0 -15
- package/src/discontinuous/world-kernels/wagner6.js +0 -15
- package/src/discontinuous.ts +0 -142
- package/src/geoarrow/builder-entry.ts +0 -18
- package/src/geoarrow/builder.ts +0 -860
- package/src/geoarrow/codecs.ts +0 -1268
- package/src/geoarrow/index.ts +0 -111
- package/src/geoarrow/kernels.ts +0 -1290
- package/src/geoarrow/layout.ts +0 -900
- package/src/geoarrow/stream-tessellate.ts +0 -205
- package/src/geoarrow/stream.ts +0 -130
- package/src/geoarrow/tessellate.ts +0 -133
- package/src/geoarrow/tessellation-entry.ts +0 -7
- package/src/geoarrow/types.ts +0 -259
- package/src/geoarrow/views.ts +0 -150
- package/src/geoarrow/wkb-entry.ts +0 -13
- package/src/geoarrow/worker.ts +0 -20
- package/src/terrain/vendor/README.md +0 -20
- package/src/vendor/geographiclib-geodesic/README.md +0 -26
- package/src/wkb/index.ts +0 -38
- package/src/wkb/types.ts +0 -54
- package/src/wkb/wkb-builder.ts +0 -395
- package/src/wkb/wkb-reader.ts +0 -401
- package/src/wkb/wkb.ts +0 -255
- package/src/wkb/wkt.ts +0 -375
- package/src/workers/index.ts +0 -59
- package/src/workers/map-worker.ts +0 -7
- package/src/workers/operations.ts +0 -65
- package/src/workers/projection-worker.ts +0 -7
- /package/{projection/APACHE-2.0-LICENSE.txt → APACHE-2.0-LICENSE.txt} +0 -0
- /package/{projection/PROJ-LICENSE.txt → PROJ-LICENSE.txt} +0 -0
- /package/{projection/PROJ4-LICENSE.md → PROJ4-LICENSE.md} +0 -0
- /package/dist/{discontinuous → maps}/air-ocean-mesh.d.ts +0 -0
- /package/dist/{discontinuous → maps}/air-ocean-mesh.js +0 -0
- /package/dist/{discontinuous → maps}/albers-usa.d.ts +0 -0
- /package/dist/{discontinuous → maps}/albers-usa.js +0 -0
- /package/dist/{discontinuous → maps}/cap-map.d.ts +0 -0
- /package/dist/{discontinuous → maps}/elastic/data.d.ts +0 -0
- /package/dist/{discontinuous → maps}/elastic/data.js +0 -0
- /package/dist/{discontinuous → maps}/elastic/elasticI.d.ts +0 -0
- /package/dist/{discontinuous → maps}/elastic/elasticI.js +0 -0
- /package/dist/{discontinuous → maps}/elastic/elasticII.d.ts +0 -0
- /package/dist/{discontinuous → maps}/elastic/elasticII.js +0 -0
- /package/dist/{discontinuous → maps}/elastic/elasticIII.d.ts +0 -0
- /package/dist/{discontinuous → maps}/elastic/elasticIII.js +0 -0
- /package/dist/{discontinuous → maps}/elastic/grid.d.ts +0 -0
- /package/dist/{discontinuous → maps}/elastic/grid.js +0 -0
- /package/dist/{discontinuous → maps}/elastic/map.d.ts +0 -0
- /package/dist/{discontinuous → maps}/gray-fuller.d.ts +0 -0
- /package/dist/{discontinuous → maps}/gray-fuller.js +0 -0
- /package/dist/{discontinuous → maps}/gringorten-kernel.d.ts +0 -0
- /package/dist/{discontinuous → maps}/gringorten-kernel.js +0 -0
- /package/dist/{discontinuous → maps}/healpix.d.ts +0 -0
- /package/dist/{discontinuous → maps}/healpix.js +0 -0
- /package/dist/{discontinuous → maps}/layout.d.ts +0 -0
- /package/dist/{discontinuous → maps}/layout.js +0 -0
- /package/dist/{discontinuous → maps}/map-transition.d.ts +0 -0
- /package/dist/{discontinuous → maps}/math.d.ts +0 -0
- /package/dist/{discontinuous → maps}/math.js +0 -0
- /package/dist/{discontinuous → maps}/myriahedral/graticule.d.ts +0 -0
- /package/dist/{discontinuous → maps}/myriahedral/graticule.js +0 -0
- /package/dist/{discontinuous → maps}/myriahedral/mesh.d.ts +0 -0
- /package/dist/{discontinuous → maps}/myriahedral/mesh.js +0 -0
- /package/dist/{discontinuous → maps}/myriahedral/unfold.d.ts +0 -0
- /package/dist/{discontinuous → maps}/myriahedral/unfold.js +0 -0
- /package/dist/{discontinuous → maps}/myriahedral.d.ts +0 -0
- /package/dist/{discontinuous → maps}/myriahedral.js +0 -0
- /package/dist/{discontinuous → maps}/petroff.d.ts +0 -0
- /package/dist/{discontinuous → maps}/petroff.js +0 -0
- /package/dist/{discontinuous → maps}/polyhedral.d.ts +0 -0
- /package/dist/{discontinuous → maps}/polyhedral.js +0 -0
- /package/dist/{discontinuous → maps}/projection-catalog.d.ts +0 -0
- /package/dist/{discontinuous → maps}/quincuncial-kernel.d.ts +0 -0
- /package/dist/{discontinuous → maps}/quincuncial-kernel.js +0 -0
- /package/dist/{discontinuous → maps}/quincuncial-star.d.ts +0 -0
- /package/dist/{discontinuous → maps}/quincuncial-star.js +0 -0
- /package/dist/{discontinuous → maps}/regional-map.d.ts +0 -0
- /package/dist/{discontinuous → maps}/regional-map.js +0 -0
- /package/dist/{discontinuous → maps}/retroazimuthal-map.d.ts +0 -0
- /package/dist/{discontinuous → maps}/retroazimuthal-map.js +0 -0
- /package/dist/{discontinuous → maps}/snyder-mesh.d.ts +0 -0
- /package/dist/{discontinuous → maps}/snyder-mesh.js +0 -0
- /package/dist/{discontinuous → maps}/snyder.d.ts +0 -0
- /package/dist/{discontinuous → maps}/snyder.js +0 -0
- /package/dist/{discontinuous → maps}/spherical-clip/cartesian.js +0 -0
- /package/dist/{discontinuous → maps}/spherical-clip/circle.d.ts +0 -0
- /package/dist/{discontinuous → maps}/spherical-clip/circle.js +0 -0
- /package/dist/{discontinuous → maps}/spherical-clip/clip-buffer.d.ts +0 -0
- /package/dist/{discontinuous → maps}/spherical-clip/clip-buffer.js +0 -0
- /package/dist/{discontinuous → maps}/spherical-clip/clip-circle.d.ts +0 -0
- /package/dist/{discontinuous → maps}/spherical-clip/clip-circle.js +0 -0
- /package/dist/{discontinuous → maps}/spherical-clip/clip-index.d.ts +0 -0
- /package/dist/{discontinuous → maps}/spherical-clip/clip-index.js +0 -0
- /package/dist/{discontinuous → maps}/spherical-clip/clip-rejoin.d.ts +0 -0
- /package/dist/{discontinuous → maps}/spherical-clip/clip-rejoin.js +0 -0
- /package/dist/{discontinuous → maps}/spherical-clip/helpers.d.ts +0 -0
- /package/dist/{discontinuous → maps}/spherical-clip/helpers.js +0 -0
- /package/dist/{discontinuous → maps}/spherical-clip/math.js +0 -0
- /package/dist/{discontinuous → maps}/spherical-clip/noop.d.ts +0 -0
- /package/dist/{discontinuous → maps}/spherical-clip/noop.js +0 -0
- /package/dist/{discontinuous → maps}/spherical-clip/pointEqual.js +0 -0
- /package/dist/{discontinuous → maps}/spherical-clip/polygonContains.d.ts +0 -0
- /package/dist/{discontinuous → maps}/spherical-clip/polygonContains.js +0 -0
- /package/dist/{discontinuous → maps}/world-composite-kernels.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-composite-kernels.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/airy.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/airy.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/aitoff.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/aitoff.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/armadillo.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/armadillo.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/august.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/august.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/baker.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/baker.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/bertin.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/bertin.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/boggs.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/boggs.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/bonne.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/bonne.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/bottomley.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/bottomley.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/bromley.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/bromley.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/chamberlin.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/chamberlin.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/collignon.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/craig.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/craig.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/craster.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/cylindricalEqualArea.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/cylindricalEqualArea.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/cylindricalStereographic.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/cylindricalStereographic.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/d3-geo-raw.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/d3-geo-raw.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/eckert1.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/eckert2.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/eckert3.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/eckert4.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/eckert5.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/eckert6.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/eisenlohr.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/eisenlohr.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/fahey.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/foucaut.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/foucautSinusoidal.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/foucautSinusoidal.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/ginzburg4.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/ginzburg4.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/ginzburg5.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/ginzburg5.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/ginzburg6.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/ginzburg6.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/ginzburg8.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/ginzburg8.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/ginzburg9.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/ginzburg9.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/ginzburgPolyconic.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/ginzburgPolyconic.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/hammer.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/hammer.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/hammerRetroazimuthal.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/hammerRetroazimuthal.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/hill.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/hill.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/homolosine.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/hufnagel.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/hufnagel.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/hyperelliptical.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/hyperelliptical.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/integrate.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/integrate.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/kavrayskiy7.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/lagrange.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/lagrange.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/larrivee.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/larrivee.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/laskowski.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/laskowski.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/littrow.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/littrow.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/loximuthal.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/loximuthal.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/math.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/miller.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/modifiedStereographic.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/modifiedStereographic.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/mollweide.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/mollweide.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/mtFlatPolarParabolic.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/mtFlatPolarParabolic.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/mtFlatPolarQuartic.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/mtFlatPolarQuartic.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/mtFlatPolarSinusoidal.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/mtFlatPolarSinusoidal.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/naturalEarth2.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/naturalEarth2.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/nellHammer.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/nellHammer.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/newton.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/newton.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/nicolosi.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/nicolosi.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/patterson.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/patterson.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/polyconic.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/polyconic.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/rectangularPolyconic.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/rectangularPolyconic.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/robinson.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/robinson.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/satellite.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/satellite.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/sinuMollweide.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/sinusoidal.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/times.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/times.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/twoPointEquidistant.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/twoPointEquidistant.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/vanDerGrinten.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/vanDerGrinten.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/vanDerGrinten2.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/vanDerGrinten2.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/vanDerGrinten3.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/vanDerGrinten3.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/vanDerGrinten4.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/vanDerGrinten4.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/wagner.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/wagner.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/wagner4.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/wagner4.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/wagner6.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/wiechel.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/wiechel.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/winkel3.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-kernels/winkel3.js +0 -0
- /package/dist/{discontinuous → maps}/world-kernels.js +0 -0
- /package/dist/{discontinuous → maps}/world-map.d.ts +0 -0
- /package/dist/{discontinuous → maps}/world-map.js +0 -0
- /package/dist/{workers → tasks}/map-worker.d.ts +0 -0
- /package/dist/{workers → tasks}/projection-worker.d.ts +0 -0
- /package/{crs/schemas → src/crs}/projjson.schema.json +0 -0
- /package/src/{discontinuous → maps}/AIR-OCEAN-LICENSE.txt +0 -0
- /package/src/{discontinuous → maps}/D3-LICENSE.txt +0 -0
- /package/src/{discontinuous → maps}/PETROFF-LICENSE.txt +0 -0
- /package/src/{discontinuous → maps}/PROJ-LICENSE.txt +0 -0
- /package/src/{discontinuous → maps}/air-ocean-mesh.ts +0 -0
- /package/src/{discontinuous → maps}/albers-usa.ts +0 -0
- /package/src/{discontinuous → maps}/elastic/UNLICENSE.txt +0 -0
- /package/src/{discontinuous → maps}/elastic/data.ts +0 -0
- /package/src/{discontinuous → maps}/elastic/elasticI.ts +0 -0
- /package/src/{discontinuous → maps}/elastic/elasticII.ts +0 -0
- /package/src/{discontinuous → maps}/elastic/elasticIII.ts +0 -0
- /package/src/{discontinuous → maps}/elastic/grid.ts +0 -0
- /package/src/{discontinuous → maps}/gray-fuller.ts +0 -0
- /package/src/{discontinuous → maps}/gringorten-kernel.ts +0 -0
- /package/src/{discontinuous → maps}/healpix.ts +0 -0
- /package/src/{discontinuous → maps}/layout.ts +0 -0
- /package/src/{discontinuous → maps}/math.ts +0 -0
- /package/src/{discontinuous → maps}/myriahedral/graticule.ts +0 -0
- /package/src/{discontinuous → maps}/myriahedral/mesh.ts +0 -0
- /package/src/{discontinuous → maps}/myriahedral/unfold.ts +0 -0
- /package/src/{discontinuous → maps}/myriahedral.ts +0 -0
- /package/src/{discontinuous → maps}/petroff.ts +0 -0
- /package/src/{discontinuous → maps}/polyhedral.ts +0 -0
- /package/src/{discontinuous/presets.ts → maps/preset-kernels.ts} +0 -0
- /package/src/{discontinuous → maps}/quincuncial-kernel.ts +0 -0
- /package/src/{discontinuous → maps}/quincuncial-star.ts +0 -0
- /package/src/{discontinuous → maps}/regional-map.ts +0 -0
- /package/src/{discontinuous → maps}/retroazimuthal-map.ts +0 -0
- /package/src/{discontinuous → maps}/snyder-mesh.ts +0 -0
- /package/src/{discontinuous → maps}/snyder.ts +0 -0
- /package/src/{discontinuous → maps}/spherical-clip/D3-GEO-LICENSE.txt +0 -0
- /package/src/{discontinuous → maps}/spherical-clip/circle.js +0 -0
- /package/src/{discontinuous → maps}/spherical-clip/clip-buffer.js +0 -0
- /package/src/{discontinuous → maps}/spherical-clip/clip-circle.js +0 -0
- /package/src/{discontinuous → maps}/spherical-clip/clip-index.js +0 -0
- /package/src/{discontinuous → maps}/spherical-clip/clip-rejoin.js +0 -0
- /package/src/{discontinuous → maps}/spherical-clip/helpers.js +0 -0
- /package/src/{discontinuous/spherical-clip/noop.js → maps/spherical-clip/noop.ts} +0 -0
- /package/src/{discontinuous → maps}/spherical-clip/polygonContains.js +0 -0
- /package/src/{discontinuous → maps}/world-composite-kernels.ts +0 -0
- /package/src/{discontinuous → maps}/world-kernels/INTEGRATE-LICENSE.txt +0 -0
- /package/src/{discontinuous → maps}/world-kernels/airy.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/aitoff.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/armadillo.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/august.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/baker.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/bertin.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/boggs.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/bonne.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/bottomley.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/bromley.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/chamberlin.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/craig.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/cylindricalEqualArea.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/cylindricalStereographic.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/d3-geo-raw.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/eisenlohr.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/foucautSinusoidal.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/ginzburg4.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/ginzburg5.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/ginzburg6.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/ginzburg8.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/ginzburg9.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/ginzburgPolyconic.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/hammer.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/hammerRetroazimuthal.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/hill.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/homolosine.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/hufnagel.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/hyperelliptical.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/integrate.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/lagrange.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/larrivee.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/laskowski.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/littrow.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/loximuthal.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/modifiedStereographic.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/mollweide.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/mtFlatPolarParabolic.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/mtFlatPolarQuartic.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/mtFlatPolarSinusoidal.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/naturalEarth2.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/nellHammer.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/newton.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/nicolosi.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/patterson.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/polyconic.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/rectangularPolyconic.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/robinson.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/satellite.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/sinuMollweide.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/times.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/twoPointEquidistant.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/vanDerGrinten.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/vanDerGrinten2.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/vanDerGrinten3.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/vanDerGrinten4.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/wagner.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/wagner4.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/wiechel.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels/winkel3.js +0 -0
- /package/src/{discontinuous → maps}/world-kernels.ts +0 -0
- /package/src/{discontinuous → maps}/world-map.ts +0 -0
package/dist/terrain/index.cjs
CHANGED
|
@@ -10,9 +10,9 @@ var __export = (target, all) => {
|
|
|
10
10
|
};
|
|
11
11
|
var __copyProps = (to, from, except, desc) => {
|
|
12
12
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let
|
|
14
|
-
if (!__hasOwnProp.call(to,
|
|
15
|
-
__defProp(to,
|
|
13
|
+
for (let key2 of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key2) && key2 !== except)
|
|
15
|
+
__defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
@@ -34,28 +34,85 @@ __export(index_exports, {
|
|
|
34
34
|
HeightFieldGeometry: () => HeightFieldGeometry,
|
|
35
35
|
HeightFieldMinMax: () => HeightFieldMinMax,
|
|
36
36
|
TERRAIN_BUFFER_VERSION: () => TERRAIN_BUFFER_VERSION,
|
|
37
|
+
TerrainContourBoundaryAxis: () => TerrainContourBoundaryAxis,
|
|
38
|
+
TerrainMorphStatus: () => TerrainMorphStatus,
|
|
39
|
+
TerrainProfileViewStatus: () => TerrainProfileViewStatus,
|
|
37
40
|
TerrainSampleStatus: () => TerrainSampleStatus,
|
|
38
41
|
TerrainSurface: () => TerrainSurface,
|
|
42
|
+
TerrainVertexHaloStatus: () => TerrainVertexHaloStatus,
|
|
39
43
|
TiledHeightField: () => TiledHeightField,
|
|
44
|
+
boundTerrainMeshError: () => boundTerrainMeshError,
|
|
45
|
+
certifyTerrainMeshCoverage: () => certifyTerrainMeshCoverage,
|
|
46
|
+
coordinateTerrainLodMorphs: () => coordinateTerrainLodMorphs,
|
|
47
|
+
createBreaklineTerrainMesh: () => createBreaklineTerrainMesh,
|
|
40
48
|
createDelatinTerrainMesh: () => createDelatinTerrainMesh,
|
|
41
49
|
createMartiniTerrainMesh: () => createMartiniTerrainMesh,
|
|
42
50
|
createTerrainContours: () => createTerrainContours,
|
|
51
|
+
createTerrainFilteredPyramid: () => createTerrainFilteredPyramid,
|
|
43
52
|
createTerrainGradientGrid: () => createTerrainGradientGrid,
|
|
53
|
+
createTerrainGradientPyramid: () => createTerrainGradientPyramid,
|
|
54
|
+
createTerrainIsobands: () => createTerrainIsobands,
|
|
55
|
+
createTerrainLodMorph: () => createTerrainLodMorph,
|
|
44
56
|
createTerrainMesh: () => createTerrainMesh,
|
|
57
|
+
createTerrainMixedIsobands: () => createTerrainMixedIsobands,
|
|
58
|
+
createTerrainMixedVertexTileHalos: () => createTerrainMixedVertexTileHalos,
|
|
45
59
|
createTerrainSkirt: () => createTerrainSkirt,
|
|
46
60
|
createTerrainSlopeAspectGrid: () => createTerrainSlopeAspectGrid,
|
|
47
61
|
createTerrainSurface: () => createTerrainSurface,
|
|
62
|
+
createTerrainVertexTileHalos: () => createTerrainVertexTileHalos,
|
|
63
|
+
createValidDomainTerrainMesh: () => createValidDomainTerrainMesh,
|
|
64
|
+
diagnoseTerrainContourBoundaries: () => diagnoseTerrainContourBoundaries,
|
|
65
|
+
discoverGeographicTerrainLodSeams: () => discoverGeographicTerrainLodSeams,
|
|
66
|
+
discoverGeographicTerrainPoles: () => discoverGeographicTerrainPoles,
|
|
67
|
+
evaluateTerrainLodMorph: () => evaluateTerrainLodMorph,
|
|
68
|
+
getGeographicTerrainNeighbor: () => getGeographicTerrainNeighbor,
|
|
69
|
+
getTerrainHierarchyNode: () => getTerrainHierarchyNode,
|
|
48
70
|
getTerrainMeshEdge: () => getTerrainMeshEdge,
|
|
71
|
+
getTerrainProfileHorizon: () => getTerrainProfileHorizon,
|
|
72
|
+
getTerrainProfileViewshed: () => getTerrainProfileViewshed,
|
|
73
|
+
getTerrainProfileVisibility: () => getTerrainProfileVisibility,
|
|
49
74
|
getTerrainSlopeAspect: () => getTerrainSlopeAspect,
|
|
75
|
+
getTerrainVertexHaloAffectedTiles: () => getTerrainVertexHaloAffectedTiles,
|
|
76
|
+
measureGeographicTerrainSeam: () => measureGeographicTerrainSeam,
|
|
50
77
|
measureTerrainMeshError: () => measureTerrainMeshError,
|
|
51
78
|
measureTerrainProfile: () => measureTerrainProfile,
|
|
52
79
|
packTerrainHeightField: () => packTerrainHeightField,
|
|
53
80
|
reconcileTerrainVertexTiles: () => reconcileTerrainVertexTiles,
|
|
54
81
|
sampleTerrainProfile: () => sampleTerrainProfile,
|
|
82
|
+
selectTerrainLod: () => selectTerrainLod,
|
|
55
83
|
simplifyTerrainContourPaths: () => simplifyTerrainContourPaths,
|
|
84
|
+
simplifyTerrainContourPathsTopology: () => simplifyTerrainContourPathsTopology,
|
|
85
|
+
splitTerrainBreaklines: () => splitTerrainBreaklines,
|
|
86
|
+
stitchTerrainContourTiles: () => stitchTerrainContourTiles,
|
|
56
87
|
stitchTerrainContours: () => stitchTerrainContours,
|
|
88
|
+
stitchTerrainLodCut: () => stitchTerrainLodCut,
|
|
57
89
|
stitchTerrainMeshEdges: () => stitchTerrainMeshEdges,
|
|
58
|
-
|
|
90
|
+
sweepTerrainBox: () => sweepTerrainBox,
|
|
91
|
+
sweepTerrainCapsule: () => sweepTerrainCapsule,
|
|
92
|
+
sweepTerrainCylinder: () => sweepTerrainCylinder,
|
|
93
|
+
sweepTerrainPlane: () => sweepTerrainPlane,
|
|
94
|
+
sweepTerrainPolytope: () => sweepTerrainPolytope,
|
|
95
|
+
sweepTerrainSphere: () => sweepTerrainSphere,
|
|
96
|
+
sweepTerrainTaperedCapsule: () => sweepTerrainTaperedCapsule,
|
|
97
|
+
sweepTerrainTriangleMesh: () => sweepTerrainTriangleMesh,
|
|
98
|
+
unpackTerrainHeightField: () => unpackTerrainHeightField,
|
|
99
|
+
updateTerrainBounds: () => updateTerrainBounds,
|
|
100
|
+
updateTerrainBoundsRegions: () => updateTerrainBoundsRegions,
|
|
101
|
+
updateTerrainDelatinMeshRegions: () => updateTerrainDelatinMeshRegions,
|
|
102
|
+
updateTerrainGradientPyramidRegions: () => updateTerrainGradientPyramidRegions,
|
|
103
|
+
updateTerrainGradientPyramids: () => updateTerrainGradientPyramids,
|
|
104
|
+
updateTerrainMartiniMeshRegions: () => updateTerrainMartiniMeshRegions,
|
|
105
|
+
updateTerrainMeshRegions: () => updateTerrainMeshRegions,
|
|
106
|
+
updateTerrainMeshes: () => updateTerrainMeshes,
|
|
107
|
+
updateTerrainMixedGradientGrids: () => updateTerrainMixedGradientGrids,
|
|
108
|
+
updateTerrainMixedVertexTileHalos: () => updateTerrainMixedVertexTileHalos,
|
|
109
|
+
updateTerrainPersistentBounds: () => updateTerrainPersistentBounds,
|
|
110
|
+
updateTerrainPersistentGradients: () => updateTerrainPersistentGradients,
|
|
111
|
+
updateTerrainValidDomainMeshRegions: () => updateTerrainValidDomainMeshRegions,
|
|
112
|
+
updateTerrainVertexTileHalos: () => updateTerrainVertexTileHalos,
|
|
113
|
+
weldTerrainContourTiles: () => weldTerrainContourTiles,
|
|
114
|
+
weldTerrainMixedContourTiles: () => weldTerrainMixedContourTiles,
|
|
115
|
+
wrapTerrainLongitude: () => wrapTerrainLongitude
|
|
59
116
|
});
|
|
60
117
|
module.exports = __toCommonJS(index_exports);
|
|
61
118
|
|
|
@@ -156,6 +213,12 @@ var HeightField = class {
|
|
|
156
213
|
if (interpolation !== "nearest" && interpolation !== "bilinear" && interpolation !== "triangle") {
|
|
157
214
|
throw new Error("Unknown terrain interpolation");
|
|
158
215
|
}
|
|
216
|
+
const domain = (options == null ? void 0 : options.domain) ?? "samples";
|
|
217
|
+
const noData = (options == null ? void 0 : options.noData) ?? "cell";
|
|
218
|
+
if (domain !== "samples" && domain !== "footprint")
|
|
219
|
+
throw new Error("Unknown terrain sample domain");
|
|
220
|
+
if (noData !== "cell" && noData !== "support")
|
|
221
|
+
throw new Error("Unknown terrain nodata policy");
|
|
159
222
|
if (!Number.isFinite(x) || !Number.isFinite(y))
|
|
160
223
|
return result;
|
|
161
224
|
const dx = x - this.origin[0];
|
|
@@ -170,11 +233,23 @@ var HeightField = class {
|
|
|
170
233
|
const errorY = 4 * Number.EPSILON * Math.abs(y) + 4 * Number.EPSILON * Math.abs(this.origin[1]);
|
|
171
234
|
const toleranceU = tolerance + Math.abs(this.inverse[0]) * errorX + Math.abs(this.inverse[1]) * errorY;
|
|
172
235
|
const toleranceV = tolerance + Math.abs(this.inverse[2]) * errorX + Math.abs(this.inverse[3]) * errorY;
|
|
173
|
-
|
|
236
|
+
const margin = domain === "footprint" && this.registration === "cell" ? 0.5 : 0;
|
|
237
|
+
if (u < -margin - toleranceU || v < -margin - toleranceV || u > this.width - 1 + margin + toleranceU || v > this.height - 1 + margin + toleranceV) {
|
|
174
238
|
return resetSample(result, TerrainSampleStatus.OUTSIDE_DOMAIN);
|
|
175
239
|
}
|
|
240
|
+
const edgeToleranceU = Math.min(1e-6, toleranceU);
|
|
241
|
+
const edgeToleranceV = Math.min(1e-6, toleranceV);
|
|
242
|
+
const clampedColumn = margin > 0 && (u < -edgeToleranceU || u > this.width - 1 + edgeToleranceU);
|
|
243
|
+
const clampedRow = margin > 0 && (v < -edgeToleranceV || v > this.height - 1 + edgeToleranceV);
|
|
176
244
|
u = Math.max(0, Math.min(this.width - 1, u));
|
|
177
245
|
v = Math.max(0, Math.min(this.height - 1, v));
|
|
246
|
+
if (noData === "support" && interpolation === "bilinear") {
|
|
247
|
+
const column2 = Math.round(u), row2 = Math.round(v);
|
|
248
|
+
if (Math.abs(u - column2) <= Math.min(1e-6, toleranceU))
|
|
249
|
+
u = column2;
|
|
250
|
+
if (Math.abs(v - row2) <= Math.min(1e-6, toleranceV))
|
|
251
|
+
v = row2;
|
|
252
|
+
}
|
|
178
253
|
if (interpolation === "nearest") {
|
|
179
254
|
const value = this.getHeight(Math.floor(u + 0.5), Math.floor(v + 0.5));
|
|
180
255
|
if (value === void 0)
|
|
@@ -200,7 +275,21 @@ var HeightField = class {
|
|
|
200
275
|
let dv;
|
|
201
276
|
if (interpolation === "bilinear") {
|
|
202
277
|
if (!this.validity[a] || !this.validity[b] || !this.validity[c] || !this.validity[d]) {
|
|
203
|
-
|
|
278
|
+
if (noData === "cell")
|
|
279
|
+
return resetSample(result, TerrainSampleStatus.NO_DATA);
|
|
280
|
+
const weightA = (1 - u) * (1 - v);
|
|
281
|
+
const weightB = u * (1 - v);
|
|
282
|
+
const weightC = (1 - u) * v;
|
|
283
|
+
const weightD = u * v;
|
|
284
|
+
if (weightA > 0 && !this.validity[a] || weightB > 0 && !this.validity[b] || weightC > 0 && !this.validity[c] || weightD > 0 && !this.validity[d])
|
|
285
|
+
return resetSample(result, TerrainSampleStatus.NO_DATA);
|
|
286
|
+
const height = weightA * za + weightB * zb + weightC * zc + weightD * zd;
|
|
287
|
+
if (!Number.isFinite(height))
|
|
288
|
+
return resetSample(result, TerrainSampleStatus.NUMERIC_ERROR);
|
|
289
|
+
result.status = TerrainSampleStatus.VALID;
|
|
290
|
+
result.height = height;
|
|
291
|
+
result.gradientStatus = TerrainSampleStatus.NO_DATA;
|
|
292
|
+
return result;
|
|
204
293
|
}
|
|
205
294
|
result.height = (1 - v) * ((1 - u) * za + u * zb) + v * ((1 - u) * zc + u * zd);
|
|
206
295
|
du = (1 - v) * (zb - za) + v * (zd - zc);
|
|
@@ -225,6 +314,10 @@ var HeightField = class {
|
|
|
225
314
|
if (!Number.isFinite(result.height))
|
|
226
315
|
return resetSample(result, TerrainSampleStatus.NUMERIC_ERROR);
|
|
227
316
|
result.status = TerrainSampleStatus.VALID;
|
|
317
|
+
if (clampedColumn)
|
|
318
|
+
du = 0;
|
|
319
|
+
if (clampedRow)
|
|
320
|
+
dv = 0;
|
|
228
321
|
const gx = du * this.inverse[0] + dv * this.inverse[2];
|
|
229
322
|
const gy = du * this.inverse[1] + dv * this.inverse[3];
|
|
230
323
|
if (!Number.isFinite(gx) || !Number.isFinite(gy)) {
|
|
@@ -307,19 +400,19 @@ function validateBatch(positions, output) {
|
|
|
307
400
|
}
|
|
308
401
|
const count = positions.length / 2;
|
|
309
402
|
const buffers = [positions];
|
|
310
|
-
for (const [
|
|
403
|
+
for (const [key2, size] of [
|
|
311
404
|
["heights", 1],
|
|
312
405
|
["statuses", 1],
|
|
313
406
|
["gradients", 2],
|
|
314
407
|
["normals", 3],
|
|
315
408
|
["gradientStatuses", 1]
|
|
316
409
|
]) {
|
|
317
|
-
const buffer = output[
|
|
318
|
-
if (buffer === void 0 &&
|
|
410
|
+
const buffer = output[key2];
|
|
411
|
+
if (buffer === void 0 && key2 !== "heights" && key2 !== "statuses")
|
|
319
412
|
continue;
|
|
320
|
-
const byte =
|
|
413
|
+
const byte = key2 === "statuses" || key2 === "gradientStatuses";
|
|
321
414
|
if ((byte ? !(buffer instanceof Uint8Array) : !isTerrainArray(buffer)) || buffer.length < count * size) {
|
|
322
|
-
throw new Error(`Terrain batch ${
|
|
415
|
+
throw new Error(`Terrain batch ${key2} has an invalid type or insufficient length`);
|
|
323
416
|
}
|
|
324
417
|
for (const other of buffers) {
|
|
325
418
|
if (buffer.buffer === other.buffer && buffer.byteOffset < other.byteOffset + other.byteLength && other.byteOffset < buffer.byteOffset + buffer.byteLength) {
|
|
@@ -335,13 +428,13 @@ function validateBatch(positions, output) {
|
|
|
335
428
|
|
|
336
429
|
// dist/terrain/mesh-skirts.js
|
|
337
430
|
function createTerrainSkirt(mesh, options) {
|
|
338
|
-
const { positions, indices } = mesh, { height, edges } = options;
|
|
431
|
+
const { positions, indices } = mesh, { height, edges: edges2 } = options;
|
|
339
432
|
const maxVertices = options.maxVertices ?? 2e6, maxTriangles = options.maxTriangles ?? 4e6;
|
|
340
433
|
if (!Number.isFinite(height) || height <= 0 || !Number.isSafeInteger(maxVertices) || maxVertices < 0 || maxVertices > 4294967295 || !Number.isSafeInteger(maxTriangles) || maxTriangles < 0 || maxTriangles > 4294967295)
|
|
341
434
|
throw new Error("Invalid terrain skirt height or capacity");
|
|
342
435
|
if (!(positions instanceof Float32Array || positions instanceof Float64Array) || positions.length < 3 || positions.length % 3 || !positions.every(Number.isFinite) || !(indices instanceof Uint16Array || indices instanceof Uint32Array) || indices.length % 3 || positions.length / 3 > maxVertices || indices.length / 3 > maxTriangles)
|
|
343
436
|
throw new Error("Invalid terrain skirt mesh or capacity");
|
|
344
|
-
if (
|
|
437
|
+
if (edges2 !== void 0 && (!(edges2 instanceof Uint16Array || edges2 instanceof Uint32Array) || edges2.length % 2))
|
|
345
438
|
throw new Error("Invalid terrain skirt edge pairs");
|
|
346
439
|
const vertexCount = positions.length / 3, triangleCount = indices.length / 3;
|
|
347
440
|
const boundary = /* @__PURE__ */ new Map();
|
|
@@ -354,9 +447,9 @@ function createTerrainSkirt(mesh, options) {
|
|
|
354
447
|
if (!Number.isFinite(area) || area <= 0)
|
|
355
448
|
throw new Error("Terrain skirt requires upward nondegenerate XY triangles");
|
|
356
449
|
for (let j = 0; j < 3; j++) {
|
|
357
|
-
const u = ids[j], v = ids[(j + 1) % 3],
|
|
450
|
+
const u = ids[j], v = ids[(j + 1) % 3], key2 = edgeKey(u, v), prior = boundary.get(key2);
|
|
358
451
|
if (!prior)
|
|
359
|
-
boundary.set(
|
|
452
|
+
boundary.set(key2, { a: u, b: v, count: 1 });
|
|
360
453
|
else {
|
|
361
454
|
if (prior.count !== 1 || prior.a !== v || prior.b !== u)
|
|
362
455
|
throw new Error("Terrain skirt mesh has nonmanifold or inconsistent edges");
|
|
@@ -365,18 +458,18 @@ function createTerrainSkirt(mesh, options) {
|
|
|
365
458
|
}
|
|
366
459
|
}
|
|
367
460
|
let selected;
|
|
368
|
-
if (
|
|
461
|
+
if (edges2) {
|
|
369
462
|
selected = [];
|
|
370
463
|
const used = /* @__PURE__ */ new Set();
|
|
371
|
-
for (let i = 0; i <
|
|
372
|
-
const
|
|
373
|
-
if (!
|
|
464
|
+
for (let i = 0; i < edges2.length; i += 2) {
|
|
465
|
+
const key2 = edgeKey(edges2[i], edges2[i + 1]), edge2 = boundary.get(key2);
|
|
466
|
+
if (!edge2 || edge2.count !== 1 || used.has(key2))
|
|
374
467
|
throw new Error("Terrain skirt selection must contain unique boundary edges");
|
|
375
|
-
used.add(
|
|
376
|
-
selected.push(
|
|
468
|
+
used.add(key2);
|
|
469
|
+
selected.push(edge2);
|
|
377
470
|
}
|
|
378
471
|
} else
|
|
379
|
-
selected = [...boundary.values()].filter((
|
|
472
|
+
selected = [...boundary.values()].filter((edge2) => edge2.count === 1);
|
|
380
473
|
const outputVertices = vertexCount + selected.length * 2, outputTriangles = triangleCount + selected.length * 2;
|
|
381
474
|
if (!Number.isSafeInteger(outputVertices) || outputVertices > maxVertices || outputVertices > 4294967295 || !Number.isSafeInteger(outputTriangles) || outputTriangles > maxTriangles)
|
|
382
475
|
throw new Error("Terrain skirt output capacity exceeded");
|
|
@@ -527,11 +620,11 @@ var ECCENTRICITY_SQUARED = 0.0066943799901413165;
|
|
|
527
620
|
var MAX_MERCATOR_LATITUDE = Math.atan(Math.sinh(Math.PI)) / RADIANS;
|
|
528
621
|
var GeographicHeightField = class {
|
|
529
622
|
constructor(props) {
|
|
530
|
-
const { bounds } = props;
|
|
623
|
+
const { bounds: bounds2 } = props;
|
|
531
624
|
this.projection = props.projection ?? "geographic";
|
|
532
625
|
this.heightReference = props.heightReference ?? "unknown";
|
|
533
626
|
const limit = this.projection === "web-mercator" ? MAX_MERCATOR_LATITUDE : 90;
|
|
534
|
-
if (
|
|
627
|
+
if (bounds2.length !== 4 || !bounds2.every(Number.isFinite) || bounds2[2] <= bounds2[0] || bounds2[2] - bounds2[0] > 360 || bounds2[3] <= bounds2[1] || bounds2[1] < -limit || bounds2[3] > limit || this.projection === "geographic" && (bounds2[1] === -90 || bounds2[3] === 90)) {
|
|
535
628
|
throw new Error("Terrain bounds must be increasing, span at most 360 degrees and exclude the projection limits");
|
|
536
629
|
}
|
|
537
630
|
if (this.projection !== "geographic" && this.projection !== "web-mercator")
|
|
@@ -539,11 +632,11 @@ var GeographicHeightField = class {
|
|
|
539
632
|
const direction = props.rowDirection ?? "north-to-south";
|
|
540
633
|
if (direction !== "north-to-south" && direction !== "south-to-north")
|
|
541
634
|
throw new Error("Unknown terrain row direction");
|
|
542
|
-
this.bounds = Object.freeze([...
|
|
543
|
-
const west = this.projectX(
|
|
544
|
-
const east = this.projectX(
|
|
545
|
-
const south = this.projectY(
|
|
546
|
-
const north = this.projectY(
|
|
635
|
+
this.bounds = Object.freeze([...bounds2]);
|
|
636
|
+
const west = this.projectX(bounds2[0]);
|
|
637
|
+
const east = this.projectX(bounds2[2]);
|
|
638
|
+
const south = this.projectY(bounds2[1]);
|
|
639
|
+
const north = this.projectY(bounds2[3]);
|
|
547
640
|
const cell = props.registration === "cell";
|
|
548
641
|
const descending = direction === "north-to-south";
|
|
549
642
|
this.field = new HeightField({
|
|
@@ -657,10 +750,10 @@ var TiledHeightField = class _TiledHeightField {
|
|
|
657
750
|
throw new Error("Terrain requires unique matrix identifiers");
|
|
658
751
|
for (const tile of props.tiles) {
|
|
659
752
|
const matrix = this.validateTileId(tile);
|
|
660
|
-
const
|
|
661
|
-
if (this.tiles.has(
|
|
753
|
+
const key2 = tileKey(tile.matrixId, tile.column, tile.row);
|
|
754
|
+
if (this.tiles.has(key2))
|
|
662
755
|
throw new Error("Duplicate terrain tile");
|
|
663
|
-
this.tiles.set(
|
|
756
|
+
this.tiles.set(key2, copyTileData(tile, matrix));
|
|
664
757
|
}
|
|
665
758
|
for (const tile of props.tiles)
|
|
666
759
|
this.buildHalo(this.getMatrix(tile.matrixId), tile.column, tile.row, props.diagonal);
|
|
@@ -689,10 +782,10 @@ var TiledHeightField = class _TiledHeightField {
|
|
|
689
782
|
const touched = /* @__PURE__ */ new Map();
|
|
690
783
|
for (const tile of [...update.tiles ?? [], ...update.remove ?? []]) {
|
|
691
784
|
this.validateTileId(tile);
|
|
692
|
-
const
|
|
693
|
-
if (touched.has(
|
|
785
|
+
const key2 = tileKey(tile.matrixId, tile.column, tile.row);
|
|
786
|
+
if (touched.has(key2))
|
|
694
787
|
throw new Error("Terrain update contains duplicate or conflicting tile identifiers");
|
|
695
|
-
touched.set(
|
|
788
|
+
touched.set(key2, tile);
|
|
696
789
|
}
|
|
697
790
|
for (const tile of update.tiles ?? [])
|
|
698
791
|
replacements.set(tileKey(tile.matrixId, tile.column, tile.row), copyTileData(tile, this.getMatrix(tile.matrixId)));
|
|
@@ -703,18 +796,18 @@ var TiledHeightField = class _TiledHeightField {
|
|
|
703
796
|
diagonal: this.diagonal,
|
|
704
797
|
heightReference: this.heightReference
|
|
705
798
|
});
|
|
706
|
-
for (const [
|
|
707
|
-
next.tiles.set(
|
|
708
|
-
for (const [
|
|
709
|
-
next.halos.set(
|
|
799
|
+
for (const [key2, tile] of this.tiles)
|
|
800
|
+
next.tiles.set(key2, tile);
|
|
801
|
+
for (const [key2, halo] of this.halos)
|
|
802
|
+
next.halos.set(key2, halo);
|
|
710
803
|
const affected = /* @__PURE__ */ new Map();
|
|
711
|
-
for (const [
|
|
712
|
-
if (replacements.has(
|
|
713
|
-
next.tiles.set(
|
|
804
|
+
for (const [key2, tile] of touched) {
|
|
805
|
+
if (replacements.has(key2))
|
|
806
|
+
next.tiles.set(key2, replacements.get(key2));
|
|
714
807
|
else {
|
|
715
|
-
if (!next.tiles.delete(
|
|
808
|
+
if (!next.tiles.delete(key2))
|
|
716
809
|
continue;
|
|
717
|
-
next.halos.delete(
|
|
810
|
+
next.halos.delete(key2);
|
|
718
811
|
}
|
|
719
812
|
for (let row = tile.row - 1; row <= tile.row + 1; row++)
|
|
720
813
|
for (let column = tile.column - 1; column <= tile.column + 1; column++) {
|
|
@@ -727,11 +820,11 @@ var TiledHeightField = class _TiledHeightField {
|
|
|
727
820
|
}
|
|
728
821
|
}
|
|
729
822
|
const changes = [];
|
|
730
|
-
for (const [
|
|
731
|
-
if (next.tiles.has(
|
|
823
|
+
for (const [key2, tile] of affected) {
|
|
824
|
+
if (next.tiles.has(key2)) {
|
|
732
825
|
next.buildHalo(next.getMatrix(tile.matrixId), tile.column, tile.row, this.diagonal);
|
|
733
826
|
changes.push({ ...tile, resident: true });
|
|
734
|
-
} else if (this.tiles.has(
|
|
827
|
+
} else if (this.tiles.has(key2))
|
|
735
828
|
changes.push(tile);
|
|
736
829
|
}
|
|
737
830
|
next.changes = freezeChanges(changes);
|
|
@@ -762,8 +855,12 @@ var TiledHeightField = class _TiledHeightField {
|
|
|
762
855
|
heightReference: this.heightReference
|
|
763
856
|
};
|
|
764
857
|
}
|
|
765
|
-
/** Queries never mix resolutions. Only absent residency permits coarser fallback.
|
|
858
|
+
/** Queries never mix resolutions. Only absent residency permits coarser fallback.
|
|
859
|
+
* Raster footprint/masked-support policies are specific to HeightField, not tiled halos.
|
|
860
|
+
*/
|
|
766
861
|
sample(x, y, options) {
|
|
862
|
+
if ("domain" in options || "noData" in options)
|
|
863
|
+
throw new Error("Raster sampling policies require a HeightField");
|
|
767
864
|
const requested = this.getMatrix(options.matrixId);
|
|
768
865
|
if (options.fallback !== void 0 && options.fallback !== "none" && options.fallback !== "coarser")
|
|
769
866
|
throw new Error("Unknown terrain fallback");
|
|
@@ -1120,7 +1217,7 @@ function createTerrainMesh(field, options = {}) {
|
|
|
1120
1217
|
coordinates.set([column, row], (row * field.width + column) * 2);
|
|
1121
1218
|
const output = new Uint32Array((field.width - 1) * (field.height - 1) * 6);
|
|
1122
1219
|
let used = 0;
|
|
1123
|
-
const
|
|
1220
|
+
const add2 = (a, b, c) => {
|
|
1124
1221
|
for (const i of [a, b, c])
|
|
1125
1222
|
if (field.getHeight(i % field.width, Math.floor(i / field.width)) === void 0)
|
|
1126
1223
|
return;
|
|
@@ -1132,11 +1229,11 @@ function createTerrainMesh(field, options = {}) {
|
|
|
1132
1229
|
for (let column = 0; column < field.width - 1; column++) {
|
|
1133
1230
|
const a = row * field.width + column, b = a + 1, c = a + field.width, d = c + 1;
|
|
1134
1231
|
if (field.diagonal === "00-11") {
|
|
1135
|
-
|
|
1136
|
-
|
|
1232
|
+
add2(a, b, d);
|
|
1233
|
+
add2(a, d, c);
|
|
1137
1234
|
} else {
|
|
1138
|
-
|
|
1139
|
-
|
|
1235
|
+
add2(a, b, c);
|
|
1236
|
+
add2(b, d, c);
|
|
1140
1237
|
}
|
|
1141
1238
|
}
|
|
1142
1239
|
return assembleTerrainMesh(field, coordinates, used === output.length ? output : output.slice(0, used), options);
|
|
@@ -1169,11 +1266,11 @@ var TerrainSurface = class {
|
|
|
1169
1266
|
throw new Error("Terrain vertex index out of bounds");
|
|
1170
1267
|
this.gradients = new Float64Array(this.triangleCount * 2);
|
|
1171
1268
|
this.normals = new Float64Array(this.triangleCount * 3);
|
|
1172
|
-
const
|
|
1269
|
+
const bounds2 = new Float64Array(this.triangleCount * 4);
|
|
1173
1270
|
let active = 0;
|
|
1174
1271
|
for (let i = 0; i < this.triangleCount; i++) {
|
|
1175
1272
|
const [a, b, c] = this.triangle(i);
|
|
1176
|
-
|
|
1273
|
+
bounds2.set([
|
|
1177
1274
|
Math.min(a[0], b[0], c[0]),
|
|
1178
1275
|
Math.min(a[1], b[1], c[1]),
|
|
1179
1276
|
Math.max(a[0], b[0], c[0]),
|
|
@@ -1199,7 +1296,7 @@ var TerrainSurface = class {
|
|
|
1199
1296
|
}
|
|
1200
1297
|
this.activeTriangleCount = active;
|
|
1201
1298
|
this.topology = buildTopology(this.indices, this.validity);
|
|
1202
|
-
this.xyIndex = new import_geometry2.BoxIndex({ bounds, dimension: 2 });
|
|
1299
|
+
this.xyIndex = new import_geometry2.BoxIndex({ bounds: bounds2, dimension: 2 });
|
|
1203
1300
|
this.bvh = new import_geometry2.TriangleBVH({ positions: this.positions, indices: this.indices });
|
|
1204
1301
|
}
|
|
1205
1302
|
/** Detached source data; changing these buffers never changes this surface. */
|
|
@@ -1444,16 +1541,16 @@ var TerrainSurface = class {
|
|
|
1444
1541
|
};
|
|
1445
1542
|
function buildTopology(indices, validity) {
|
|
1446
1543
|
const halfedges = new Int32Array(indices.length).fill(-1);
|
|
1447
|
-
const
|
|
1544
|
+
const edges2 = /* @__PURE__ */ new Map();
|
|
1448
1545
|
for (let i = 0; i < indices.length; i++) {
|
|
1449
1546
|
const triangle = Math.floor(i / 3);
|
|
1450
1547
|
if (!validity[triangle])
|
|
1451
1548
|
continue;
|
|
1452
1549
|
const a = indices[i], b = indices[triangle * 3 + (i % 3 + 1) % 3];
|
|
1453
|
-
const
|
|
1454
|
-
const opposite =
|
|
1550
|
+
const key2 = a < b ? `${a}/${b}` : `${b}/${a}`;
|
|
1551
|
+
const opposite = edges2.get(key2);
|
|
1455
1552
|
if (opposite === void 0)
|
|
1456
|
-
|
|
1553
|
+
edges2.set(key2, i);
|
|
1457
1554
|
else {
|
|
1458
1555
|
if (halfedges[opposite] !== -1)
|
|
1459
1556
|
throw new Error("Nonmanifold terrain edge");
|
|
@@ -1623,7 +1720,8 @@ function measureTerrainMeshError(field, mesh, options = {}) {
|
|
|
1623
1720
|
const x = mesh.gridCoordinates[i * 2] + shift, y = mesh.gridCoordinates[i * 2 + 1] + shift;
|
|
1624
1721
|
for (let axis = 0; axis < 2; axis++) {
|
|
1625
1722
|
const expected = field.origin[axis] - mesh.origin[axis] + x * field.columnStep[axis] + y * field.rowStep[axis];
|
|
1626
|
-
|
|
1723
|
+
const tolerance = Math.min(16 * Number.EPSILON * (Math.abs(field.origin[axis] - mesh.origin[axis]) + Math.abs(x * field.columnStep[axis]) + Math.abs(y * field.rowStep[axis])), 1e-9 * Math.max(Math.abs(field.columnStep[axis]), Math.abs(field.rowStep[axis])));
|
|
1724
|
+
if (!Number.isFinite(expected) || Math.abs(mesh.positions[i * 3 + axis] - expected) > tolerance)
|
|
1627
1725
|
throw new Error("Terrain mesh XY does not match the source grid frame");
|
|
1628
1726
|
}
|
|
1629
1727
|
}
|
|
@@ -1658,9 +1756,9 @@ function measureTerrainMeshError(field, mesh, options = {}) {
|
|
|
1658
1756
|
throw new Error("Terrain mesh sample-test budget exceeded");
|
|
1659
1757
|
const dx = baseX + (column + shift) * columnX + (row + shift) * rowX - px;
|
|
1660
1758
|
const dy = baseY + (column + shift) * columnY + (row + shift) * rowY - py;
|
|
1661
|
-
const
|
|
1662
|
-
const nu = (dx * vy - dy * vx) *
|
|
1663
|
-
const nv = (ux * dy - uy * dx) *
|
|
1759
|
+
const sign2 = Math.sign(xyArea), area = Math.abs(xyArea);
|
|
1760
|
+
const nu = (dx * vy - dy * vx) * sign2;
|
|
1761
|
+
const nv = (ux * dy - uy * dx) * sign2;
|
|
1664
1762
|
const tolerance = 16 * Number.EPSILON * (Math.abs(dx * vy) + Math.abs(dy * vx) + Math.abs(ux * dy) + Math.abs(uy * dx) + area);
|
|
1665
1763
|
if (nu < -tolerance || nv < -tolerance || nu + nv > area + tolerance)
|
|
1666
1764
|
continue;
|
|
@@ -1698,13 +1796,13 @@ function measureTerrainMeshError(field, mesh, options = {}) {
|
|
|
1698
1796
|
}
|
|
1699
1797
|
|
|
1700
1798
|
// dist/terrain/mesh-edges.js
|
|
1701
|
-
function getTerrainMeshEdge(mesh,
|
|
1799
|
+
function getTerrainMeshEdge(mesh, edge2) {
|
|
1702
1800
|
validateTerrainGridMesh(mesh);
|
|
1703
|
-
if (!["minColumn", "maxColumn", "minRow", "maxRow"].includes(
|
|
1801
|
+
if (!["minColumn", "maxColumn", "minRow", "maxRow"].includes(edge2))
|
|
1704
1802
|
throw new Error("Unknown terrain mesh edge");
|
|
1705
|
-
const column =
|
|
1803
|
+
const column = edge2 === "minColumn" || edge2 === "maxColumn";
|
|
1706
1804
|
const axis = column ? 0 : 1;
|
|
1707
|
-
const value =
|
|
1805
|
+
const value = edge2.startsWith("min") ? 0 : (column ? mesh.width : mesh.height) - 1;
|
|
1708
1806
|
const vertices = /* @__PURE__ */ new Set();
|
|
1709
1807
|
for (const index of mesh.indices)
|
|
1710
1808
|
if (mesh.gridCoordinates[2 * index + axis] === value)
|
|
@@ -1728,19 +1826,19 @@ function createMartiniTerrainMesh(field, options) {
|
|
|
1728
1826
|
throw new Error("Adaptive terrain sample capacity exceeded");
|
|
1729
1827
|
if (field.validCount !== size * size)
|
|
1730
1828
|
throw new Error("Adaptive terrain requires complete source data; use a regular mesh for holes");
|
|
1731
|
-
const
|
|
1732
|
-
for (const
|
|
1733
|
-
if (!["minColumn", "maxColumn", "minRow", "maxRow"].includes(
|
|
1829
|
+
const edges2 = options.fullEdges ?? [];
|
|
1830
|
+
for (const edge2 of edges2)
|
|
1831
|
+
if (!["minColumn", "maxColumn", "minRow", "maxRow"].includes(edge2))
|
|
1734
1832
|
throw new Error("Unknown adaptive terrain edge");
|
|
1735
1833
|
const { heights } = field.copyData();
|
|
1736
1834
|
const tile = new import_martini.default(size).createTile(heights);
|
|
1737
|
-
for (const
|
|
1835
|
+
for (const edge2 of edges2)
|
|
1738
1836
|
for (let i = 0; i < size; i++) {
|
|
1739
|
-
const column =
|
|
1740
|
-
const row =
|
|
1837
|
+
const column = edge2 === "minColumn" ? 0 : edge2 === "maxColumn" ? cells : i;
|
|
1838
|
+
const row = edge2 === "minRow" ? 0 : edge2 === "maxRow" ? cells : i;
|
|
1741
1839
|
tile.errors[row * size + column] = Infinity;
|
|
1742
1840
|
}
|
|
1743
|
-
if (
|
|
1841
|
+
if (edges2.length)
|
|
1744
1842
|
tile.update();
|
|
1745
1843
|
let threshold = options.maxError;
|
|
1746
1844
|
for (let pass = 0; pass <= 8; pass++) {
|
|
@@ -2361,16 +2459,16 @@ function createTerrainContours(field, levels, options = {}) {
|
|
|
2361
2459
|
const outputLevels = Float64Array.from(levels), positions = [], coordinates = [], segments = [], levelIndices = [];
|
|
2362
2460
|
const shift = field.registration === "cell" ? 0.5 : 0;
|
|
2363
2461
|
for (let levelIndex = 0; levelIndex < outputLevels.length; levelIndex++) {
|
|
2364
|
-
const level = outputLevels[levelIndex], vertices = /* @__PURE__ */ new Map(),
|
|
2462
|
+
const level = outputLevels[levelIndex], vertices = /* @__PURE__ */ new Map(), edges2 = /* @__PURE__ */ new Set();
|
|
2365
2463
|
const height = (i) => field.getHeight(i % field.width, Math.floor(i / field.width));
|
|
2366
2464
|
const intersection = (a, b) => {
|
|
2367
2465
|
if (a > b)
|
|
2368
2466
|
[a, b] = [b, a];
|
|
2369
|
-
const
|
|
2370
|
-
return
|
|
2467
|
+
const exact2 = height(a) === level ? a : height(b) === level ? b : void 0;
|
|
2468
|
+
return exact2 === void 0 ? { a, b, key: `e${a}/${b}` } : { a: exact2, b: exact2, key: `v${exact2}` };
|
|
2371
2469
|
};
|
|
2372
|
-
const vertex = ({ a, b, key }) => {
|
|
2373
|
-
const existing = vertices.get(
|
|
2470
|
+
const vertex = ({ a, b, key: key2 }) => {
|
|
2471
|
+
const existing = vertices.get(key2);
|
|
2374
2472
|
if (existing !== void 0)
|
|
2375
2473
|
return existing;
|
|
2376
2474
|
if (positions.length / 3 >= maxVertices)
|
|
@@ -2397,7 +2495,7 @@ function createTerrainContours(field, levels, options = {}) {
|
|
|
2397
2495
|
const index = positions.length / 3;
|
|
2398
2496
|
positions.push(px, py, pz);
|
|
2399
2497
|
coordinates.push(x, y);
|
|
2400
|
-
vertices.set(
|
|
2498
|
+
vertices.set(key2, index);
|
|
2401
2499
|
return index;
|
|
2402
2500
|
};
|
|
2403
2501
|
const triangle = (a, b, c) => {
|
|
@@ -2414,14 +2512,14 @@ function createTerrainContours(field, levels, options = {}) {
|
|
|
2414
2512
|
if (hits.length !== 2 || hits[0].key === hits[1].key)
|
|
2415
2513
|
return;
|
|
2416
2514
|
const va = vertex(hits[0]), vb = vertex(hits[1]);
|
|
2417
|
-
const
|
|
2418
|
-
if (
|
|
2515
|
+
const key2 = va < vb ? `${va}/${vb}` : `${vb}/${va}`;
|
|
2516
|
+
if (edges2.has(key2))
|
|
2419
2517
|
return;
|
|
2420
2518
|
if (segments.length / 2 >= maxSegments)
|
|
2421
2519
|
throw new Error("Terrain contour segment capacity exceeded");
|
|
2422
2520
|
if (positions[3 * va] === positions[3 * vb] && positions[3 * va + 1] === positions[3 * vb + 1])
|
|
2423
2521
|
throw new Error("Terrain contour segment collapses; use a local origin");
|
|
2424
|
-
|
|
2522
|
+
edges2.add(key2);
|
|
2425
2523
|
segments.push(va, vb);
|
|
2426
2524
|
levelIndices.push(levelIndex);
|
|
2427
2525
|
};
|
|
@@ -2508,10 +2606,10 @@ function stitchTerrainContours(contours, options = {}) {
|
|
|
2508
2606
|
validateContourVertex(contours, b, level, assignments);
|
|
2509
2607
|
if (a === b || contours.positions[3 * a] === contours.positions[3 * b] && contours.positions[3 * a + 1] === contours.positions[3 * b + 1])
|
|
2510
2608
|
throw new Error("Degenerate terrain contour segment");
|
|
2511
|
-
const
|
|
2512
|
-
if (unique.has(
|
|
2609
|
+
const key2 = a < b ? `${a}/${b}` : `${b}/${a}`;
|
|
2610
|
+
if (unique.has(key2))
|
|
2513
2611
|
throw new Error("Duplicate terrain contour segment");
|
|
2514
|
-
unique.add(
|
|
2612
|
+
unique.add(key2);
|
|
2515
2613
|
degrees[a]++;
|
|
2516
2614
|
degrees[b]++;
|
|
2517
2615
|
}
|
|
@@ -2533,16 +2631,16 @@ function stitchTerrainContours(contours, options = {}) {
|
|
|
2533
2631
|
throw new Error("Terrain contour path capacity exceeded");
|
|
2534
2632
|
levels.push(assignments[start]);
|
|
2535
2633
|
append(start);
|
|
2536
|
-
let vertex = start,
|
|
2537
|
-
while (!visited[
|
|
2538
|
-
visited[
|
|
2539
|
-
const a = contours.segments[2 *
|
|
2634
|
+
let vertex = start, edge2 = firstEdge;
|
|
2635
|
+
while (!visited[edge2]) {
|
|
2636
|
+
visited[edge2] = 1;
|
|
2637
|
+
const a = contours.segments[2 * edge2], b = contours.segments[2 * edge2 + 1];
|
|
2540
2638
|
vertex = vertex === a ? b : a;
|
|
2541
2639
|
append(vertex);
|
|
2542
2640
|
if (vertex === start || degrees[vertex] !== 2)
|
|
2543
2641
|
break;
|
|
2544
2642
|
const e0 = adjacency[starts[vertex]], e1 = adjacency[starts[vertex] + 1];
|
|
2545
|
-
|
|
2643
|
+
edge2 = visited[e0] ? e1 : e0;
|
|
2546
2644
|
}
|
|
2547
2645
|
closed.push(vertex === start ? 1 : 0);
|
|
2548
2646
|
offsets.push(indices.length);
|
|
@@ -2566,6 +2664,245 @@ function stitchTerrainContours(contours, options = {}) {
|
|
|
2566
2664
|
};
|
|
2567
2665
|
}
|
|
2568
2666
|
|
|
2667
|
+
// dist/terrain/contour-tile-weld.js
|
|
2668
|
+
function weldTerrainContourTiles(tiles, options) {
|
|
2669
|
+
const { width, height } = options;
|
|
2670
|
+
const limits = contourPathLimits(options);
|
|
2671
|
+
const tolerance = options.maxPositionDifference ?? 0;
|
|
2672
|
+
const maxTiles = options.maxTiles ?? 4096;
|
|
2673
|
+
if (!Number.isSafeInteger(width) || width < 2 || !Number.isSafeInteger(height) || height < 2 || !Number.isFinite(tolerance) || tolerance < 0 || !Number.isSafeInteger(maxTiles) || maxTiles < 1 || tiles.length > maxTiles || !tiles.length)
|
|
2674
|
+
throw new Error("Invalid terrain contour tile dimensions or tolerance");
|
|
2675
|
+
const sorted = [...tiles].sort((a, b) => a.column - b.column || a.row - b.row);
|
|
2676
|
+
const first = sorted[0].contours;
|
|
2677
|
+
const origin = [...first.origin];
|
|
2678
|
+
const levels = first.levels.slice();
|
|
2679
|
+
const positions = [], grid = [], segments = [], levelIndices = [];
|
|
2680
|
+
const vertices = /* @__PURE__ */ new Map();
|
|
2681
|
+
const edges2 = /* @__PURE__ */ new Map();
|
|
2682
|
+
const addresses = /* @__PURE__ */ new Set();
|
|
2683
|
+
let inputVertices = 0;
|
|
2684
|
+
let inputSegments = 0;
|
|
2685
|
+
for (let tileIndex = 0; tileIndex < sorted.length; tileIndex++) {
|
|
2686
|
+
const tile = sorted[tileIndex], data = tile.contours;
|
|
2687
|
+
const id = `${tile.column},${tile.row}`;
|
|
2688
|
+
if (!Number.isSafeInteger(tile.column) || !Number.isSafeInteger(tile.row) || addresses.has(id))
|
|
2689
|
+
throw new Error("Invalid or duplicate terrain contour tile address");
|
|
2690
|
+
addresses.add(id);
|
|
2691
|
+
const x0 = tile.column * (width - 1), y0 = tile.row * (height - 1);
|
|
2692
|
+
if (![x0, y0, x0 + width - 1, y0 + height - 1].every(Number.isSafeInteger))
|
|
2693
|
+
throw new Error("Terrain contour tile lattice overflow");
|
|
2694
|
+
const count = validateContourData(data, limits);
|
|
2695
|
+
inputVertices += count;
|
|
2696
|
+
if (inputVertices > limits.maxVertices)
|
|
2697
|
+
throw new Error("Terrain contour input vertex capacity exceeded");
|
|
2698
|
+
if (data.heightReference !== first.heightReference || data.levels.length !== levels.length || !data.levels.every((level, i) => level === levels[i]))
|
|
2699
|
+
throw new Error("Terrain contour tile levels or height reference differ");
|
|
2700
|
+
if (!(data.segments instanceof Uint32Array) || data.segments.length % 2 || !(data.levelIndices instanceof Uint32Array) || data.levelIndices.length !== data.segments.length / 2 || data.levelIndices.length > limits.maxSegments)
|
|
2701
|
+
throw new Error("Invalid terrain contour tile segments");
|
|
2702
|
+
inputSegments += data.levelIndices.length;
|
|
2703
|
+
if (inputSegments > limits.maxSegments)
|
|
2704
|
+
throw new Error("Terrain contour input segment capacity exceeded");
|
|
2705
|
+
const assigned = new Uint32Array(count).fill(4294967295);
|
|
2706
|
+
const remap = new Uint32Array(count).fill(4294967295);
|
|
2707
|
+
const localBoundary = /* @__PURE__ */ new Set();
|
|
2708
|
+
const mapVertex = (source, level) => {
|
|
2709
|
+
validateContourVertex(data, source, level, assigned);
|
|
2710
|
+
if (remap[source] !== 4294967295)
|
|
2711
|
+
return remap[source];
|
|
2712
|
+
const x = data.gridCoordinates[2 * source], y = data.gridCoordinates[2 * source + 1];
|
|
2713
|
+
if (x < 0 || x > width - 1 || y < 0 || y > height - 1)
|
|
2714
|
+
throw new Error("Terrain contour vertex outside tile lattice");
|
|
2715
|
+
const gx = x0 + x, gy = y0 + y;
|
|
2716
|
+
if (!Number.isFinite(gx) || !Number.isFinite(gy) || x % 1 !== 0 && Number.isInteger(gx) || y % 1 !== 0 && Number.isInteger(gy))
|
|
2717
|
+
throw new Error("Terrain contour tile lattice loses precision");
|
|
2718
|
+
const px = data.positions[3 * source] + (data.origin[0] - origin[0]);
|
|
2719
|
+
const py = data.positions[3 * source + 1] + (data.origin[1] - origin[1]);
|
|
2720
|
+
if (!Number.isFinite(px) || !Number.isFinite(py))
|
|
2721
|
+
throw new Error("Terrain contour frame overflow");
|
|
2722
|
+
const boundary = x === 0 || y === 0 || x === width - 1 || y === height - 1;
|
|
2723
|
+
const xi = Math.floor(x), yi = Math.floor(y);
|
|
2724
|
+
const vertexKey = `${level}/${x0 + xi}/${x - xi}/${y0 + yi}/${y - yi}`;
|
|
2725
|
+
if (boundary) {
|
|
2726
|
+
if (localBoundary.has(vertexKey))
|
|
2727
|
+
throw new Error("Duplicate terrain contour boundary vertex");
|
|
2728
|
+
localBoundary.add(vertexKey);
|
|
2729
|
+
}
|
|
2730
|
+
const found = boundary ? vertices.get(vertexKey) : void 0;
|
|
2731
|
+
if (found) {
|
|
2732
|
+
if (found.tile === tileIndex)
|
|
2733
|
+
throw new Error("Duplicate terrain contour boundary vertex");
|
|
2734
|
+
const delta = Math.hypot(px - positions[3 * found.id], py - positions[3 * found.id + 1]);
|
|
2735
|
+
if (!Number.isFinite(delta) || delta > tolerance)
|
|
2736
|
+
throw new Error("Terrain contour boundary positions disagree");
|
|
2737
|
+
remap[source] = found.id;
|
|
2738
|
+
return found.id;
|
|
2739
|
+
}
|
|
2740
|
+
if (positions.length / 3 >= limits.maxVertices)
|
|
2741
|
+
throw new Error("Terrain contour vertex capacity exceeded");
|
|
2742
|
+
const output = positions.length / 3;
|
|
2743
|
+
const pz = levels[level] - origin[2];
|
|
2744
|
+
if (!Number.isFinite(pz))
|
|
2745
|
+
throw new Error("Terrain contour frame overflow");
|
|
2746
|
+
positions.push(px, py, pz);
|
|
2747
|
+
grid.push(gx, gy);
|
|
2748
|
+
if (boundary)
|
|
2749
|
+
vertices.set(vertexKey, { id: output, tile: tileIndex });
|
|
2750
|
+
remap[source] = output;
|
|
2751
|
+
return output;
|
|
2752
|
+
};
|
|
2753
|
+
for (let i = 0; i < data.levelIndices.length; i++) {
|
|
2754
|
+
const level = data.levelIndices[i], a = mapVertex(data.segments[2 * i], level), b = mapVertex(data.segments[2 * i + 1], level);
|
|
2755
|
+
if (a === b || positions[3 * a] === positions[3 * b] && positions[3 * a + 1] === positions[3 * b + 1])
|
|
2756
|
+
throw new Error("Degenerate terrain contour segment after rebasing");
|
|
2757
|
+
const edge2 = a < b ? `${a}/${b}` : `${b}/${a}`;
|
|
2758
|
+
const previous = edges2.get(edge2);
|
|
2759
|
+
if (previous !== void 0) {
|
|
2760
|
+
if (previous === tileIndex)
|
|
2761
|
+
throw new Error("Duplicate terrain contour segment");
|
|
2762
|
+
continue;
|
|
2763
|
+
}
|
|
2764
|
+
if (levelIndices.length >= limits.maxSegments)
|
|
2765
|
+
throw new Error("Terrain contour segment capacity exceeded");
|
|
2766
|
+
edges2.set(edge2, tileIndex);
|
|
2767
|
+
segments.push(a, b);
|
|
2768
|
+
levelIndices.push(level);
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2771
|
+
return {
|
|
2772
|
+
positions: Float64Array.from(positions),
|
|
2773
|
+
gridCoordinates: Float64Array.from(grid),
|
|
2774
|
+
segments: Uint32Array.from(segments),
|
|
2775
|
+
levelIndices: Uint32Array.from(levelIndices),
|
|
2776
|
+
levels,
|
|
2777
|
+
origin,
|
|
2778
|
+
heightReference: first.heightReference
|
|
2779
|
+
};
|
|
2780
|
+
}
|
|
2781
|
+
|
|
2782
|
+
// dist/terrain/contour-boundary-diagnostics.js
|
|
2783
|
+
var TerrainContourBoundaryAxis = { COLUMN: 1, ROW: 2 };
|
|
2784
|
+
function diagnoseTerrainContourBoundaries(contours, options) {
|
|
2785
|
+
const { width, height } = options;
|
|
2786
|
+
if (!Number.isSafeInteger(width) || width < 2 || !Number.isSafeInteger(height) || height < 2)
|
|
2787
|
+
throw new Error("Invalid terrain contour boundary tile dimensions");
|
|
2788
|
+
const limits = contourPathLimits(options);
|
|
2789
|
+
const count = validateContourData(contours, limits);
|
|
2790
|
+
if (!(contours.segments instanceof Uint32Array) || contours.segments.length % 2 || !(contours.levelIndices instanceof Uint32Array) || contours.levelIndices.length !== contours.segments.length / 2 || contours.levelIndices.length > limits.maxSegments)
|
|
2791
|
+
throw new Error("Invalid terrain contour boundary segments or capacity");
|
|
2792
|
+
const degrees = new Uint32Array(count), assignments = new Uint32Array(count).fill(4294967295);
|
|
2793
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2794
|
+
for (let i = 0; i < contours.levelIndices.length; i++) {
|
|
2795
|
+
const a = contours.segments[2 * i], b = contours.segments[2 * i + 1], level = contours.levelIndices[i];
|
|
2796
|
+
validateContourVertex(contours, a, level, assignments);
|
|
2797
|
+
validateContourVertex(contours, b, level, assignments);
|
|
2798
|
+
if (a === b || contours.positions[3 * a] === contours.positions[3 * b] && contours.positions[3 * a + 1] === contours.positions[3 * b + 1])
|
|
2799
|
+
throw new Error("Degenerate terrain contour segment");
|
|
2800
|
+
const key2 = a < b ? `${a}/${b}` : `${b}/${a}`;
|
|
2801
|
+
if (seen.has(key2))
|
|
2802
|
+
throw new Error("Duplicate terrain contour segment");
|
|
2803
|
+
seen.add(key2);
|
|
2804
|
+
degrees[a]++;
|
|
2805
|
+
degrees[b]++;
|
|
2806
|
+
}
|
|
2807
|
+
const vertices = [], resultDegrees = [], levels = [], axes = [];
|
|
2808
|
+
for (let i = 0; i < count; i++) {
|
|
2809
|
+
if (degrees[i] !== 1 && degrees[i] <= 2)
|
|
2810
|
+
continue;
|
|
2811
|
+
const x = contours.gridCoordinates[2 * i], y = contours.gridCoordinates[2 * i + 1];
|
|
2812
|
+
if (Math.abs(x) > Number.MAX_SAFE_INTEGER || Math.abs(y) > Number.MAX_SAFE_INTEGER)
|
|
2813
|
+
throw new Error("Terrain contour boundary lattice exceeds safe integer range");
|
|
2814
|
+
const axis = (Number.isSafeInteger(x) && x % (width - 1) === 0 ? TerrainContourBoundaryAxis.COLUMN : 0) | (Number.isSafeInteger(y) && y % (height - 1) === 0 ? TerrainContourBoundaryAxis.ROW : 0);
|
|
2815
|
+
if (!axis)
|
|
2816
|
+
continue;
|
|
2817
|
+
vertices.push(i);
|
|
2818
|
+
resultDegrees.push(degrees[i]);
|
|
2819
|
+
levels.push(assignments[i]);
|
|
2820
|
+
axes.push(axis);
|
|
2821
|
+
}
|
|
2822
|
+
return {
|
|
2823
|
+
vertexIndices: Uint32Array.from(vertices),
|
|
2824
|
+
degrees: Uint32Array.from(resultDegrees),
|
|
2825
|
+
levelIndices: Uint32Array.from(levels),
|
|
2826
|
+
boundaryAxes: Uint8Array.from(axes)
|
|
2827
|
+
};
|
|
2828
|
+
}
|
|
2829
|
+
|
|
2830
|
+
// dist/terrain/contour-tile-paths.js
|
|
2831
|
+
function stitchTerrainContourTiles(tiles, options) {
|
|
2832
|
+
return stitchTerrainContours(weldTerrainContourTiles(tiles, options), options);
|
|
2833
|
+
}
|
|
2834
|
+
|
|
2835
|
+
// dist/terrain/gradient-pyramid.js
|
|
2836
|
+
function createTerrainGradientPyramid(grid, options = {}) {
|
|
2837
|
+
const { width, height, gradients, statuses } = grid;
|
|
2838
|
+
const count = width * height, limit = options.maxSamples ?? 4e6;
|
|
2839
|
+
if (!Number.isSafeInteger(width) || width < 1 || !Number.isSafeInteger(height) || height < 1 || !Number.isSafeInteger(count) || count > 4294967295 || !Number.isSafeInteger(limit) || limit < count || !(gradients instanceof Float64Array) || gradients.length !== 2 * count || !(statuses instanceof Uint8Array) || statuses.length !== count || grid.method !== "horn" && grid.method !== "zevenbergen-thorne" || grid.registration !== "cell" && grid.registration !== "vertex" || typeof grid.heightReference !== "string" || ![grid.origin, grid.columnStep, grid.rowStep].every((v) => v.length === 2 && v.every(Number.isFinite)))
|
|
2840
|
+
throw new Error("Invalid terrain gradient pyramid input or capacity");
|
|
2841
|
+
const base = {
|
|
2842
|
+
width,
|
|
2843
|
+
height,
|
|
2844
|
+
blockSize: 1,
|
|
2845
|
+
gradients: new Float64Array(2 * count),
|
|
2846
|
+
validCounts: new Uint32Array(count),
|
|
2847
|
+
sampleCounts: new Uint32Array(count).fill(1)
|
|
2848
|
+
};
|
|
2849
|
+
for (let i = 0; i < count; i++) {
|
|
2850
|
+
if (statuses[i] > TerrainSampleStatus.NOT_RESIDENT)
|
|
2851
|
+
throw new Error("Invalid terrain gradient status");
|
|
2852
|
+
if (statuses[i] === TerrainSampleStatus.VALID) {
|
|
2853
|
+
if (!Number.isFinite(gradients[2 * i]) || !Number.isFinite(gradients[2 * i + 1]))
|
|
2854
|
+
throw new Error("Invalid terrain gradient value");
|
|
2855
|
+
base.gradients[2 * i] = gradients[2 * i];
|
|
2856
|
+
base.gradients[2 * i + 1] = gradients[2 * i + 1];
|
|
2857
|
+
base.validCounts[i] = 1;
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
const levels = [base];
|
|
2861
|
+
let source = base;
|
|
2862
|
+
while (source.width > 1 || source.height > 1) {
|
|
2863
|
+
const w = Math.ceil(source.width / 2), h = Math.ceil(source.height / 2);
|
|
2864
|
+
const next = {
|
|
2865
|
+
width: w,
|
|
2866
|
+
height: h,
|
|
2867
|
+
blockSize: source.blockSize * 2,
|
|
2868
|
+
gradients: new Float64Array(2 * w * h),
|
|
2869
|
+
validCounts: new Uint32Array(w * h),
|
|
2870
|
+
sampleCounts: new Uint32Array(w * h)
|
|
2871
|
+
};
|
|
2872
|
+
for (let y = 0; y < h; y++)
|
|
2873
|
+
for (let x = 0; x < w; x++) {
|
|
2874
|
+
const out = y * w + x;
|
|
2875
|
+
for (let dy = 0; dy < 2; dy++)
|
|
2876
|
+
for (let dx = 0; dx < 2; dx++) {
|
|
2877
|
+
const sx = 2 * x + dx, sy = 2 * y + dy;
|
|
2878
|
+
if (sx >= source.width || sy >= source.height)
|
|
2879
|
+
continue;
|
|
2880
|
+
const index = sy * source.width + sx, n = source.validCounts[index], old = next.validCounts[out];
|
|
2881
|
+
next.sampleCounts[out] += source.sampleCounts[index];
|
|
2882
|
+
if (n) {
|
|
2883
|
+
const total = old + n;
|
|
2884
|
+
for (let axis = 0; axis < 2; axis++) {
|
|
2885
|
+
const a = next.gradients[2 * out + axis], b = source.gradients[2 * index + axis];
|
|
2886
|
+
next.gradients[2 * out + axis] = old ? a * (old / total) + b * (n / total) : b;
|
|
2887
|
+
}
|
|
2888
|
+
next.validCounts[out] = total;
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
levels.push(next);
|
|
2893
|
+
source = next;
|
|
2894
|
+
}
|
|
2895
|
+
return {
|
|
2896
|
+
levels,
|
|
2897
|
+
method: grid.method,
|
|
2898
|
+
origin: [...grid.origin],
|
|
2899
|
+
columnStep: [...grid.columnStep],
|
|
2900
|
+
rowStep: [...grid.rowStep],
|
|
2901
|
+
registration: grid.registration,
|
|
2902
|
+
heightReference: grid.heightReference
|
|
2903
|
+
};
|
|
2904
|
+
}
|
|
2905
|
+
|
|
2569
2906
|
// dist/terrain/contour-simplify.js
|
|
2570
2907
|
function simplifyTerrainContourPaths(paths, options) {
|
|
2571
2908
|
const limits = contourPathLimits(options), count = validateContourData(paths, limits);
|
|
@@ -2599,6 +2936,10 @@ function simplifyTerrainContourPaths(paths, options) {
|
|
|
2599
2936
|
uses[vertex]++;
|
|
2600
2937
|
}
|
|
2601
2938
|
}
|
|
2939
|
+
const protectedIds = new Set(options.protectedVertexIndices);
|
|
2940
|
+
for (const id of protectedIds)
|
|
2941
|
+
if (id >= count)
|
|
2942
|
+
throw new Error("Invalid protected contour vertex");
|
|
2602
2943
|
const keep = new Uint8Array(paths.indices.length);
|
|
2603
2944
|
let distanceTests = 0, maxDeviation = 0;
|
|
2604
2945
|
for (let p = 0; p < pathCount; p++) {
|
|
@@ -2609,7 +2950,7 @@ function simplifyTerrainContourPaths(paths, options) {
|
|
|
2609
2950
|
keep[start + Math.floor(2 * (end - start) / 3)] = 1;
|
|
2610
2951
|
}
|
|
2611
2952
|
for (let i = start; i <= end; i++)
|
|
2612
|
-
if (uses[paths.indices[i]] > 1)
|
|
2953
|
+
if (uses[paths.indices[i]] > 1 || protectedIds.has(paths.indices[i]))
|
|
2613
2954
|
keep[i] = 1;
|
|
2614
2955
|
const stack = [];
|
|
2615
2956
|
let previous = start;
|
|
@@ -2704,7 +3045,7 @@ function measureTerrainProfile(profile, options = {}) {
|
|
|
2704
3045
|
let validSampleCount = 0, minimum = Infinity, maximum = -Infinity, coveredSegmentCount = 0, missingSegmentCount = 0;
|
|
2705
3046
|
let meanHeight = 0;
|
|
2706
3047
|
const sums = new Float64Array(6), corrections = new Float64Array(6);
|
|
2707
|
-
const
|
|
3048
|
+
const add2 = (index, value) => {
|
|
2708
3049
|
const y = value - corrections[index], next = sums[index] + y;
|
|
2709
3050
|
if (!Number.isFinite(value) || !Number.isFinite(next))
|
|
2710
3051
|
throw new Error("Terrain profile measurement arithmetic overflow");
|
|
@@ -2729,17 +3070,17 @@ function measureTerrainProfile(profile, options = {}) {
|
|
|
2729
3070
|
const ds = distance - profile.distances[i - 1];
|
|
2730
3071
|
if (status !== TerrainSampleStatus.VALID || profile.statuses[i - 1] !== TerrainSampleStatus.VALID) {
|
|
2731
3072
|
missingSegmentCount++;
|
|
2732
|
-
|
|
3073
|
+
add2(1, ds);
|
|
2733
3074
|
continue;
|
|
2734
3075
|
}
|
|
2735
3076
|
coveredSegmentCount++;
|
|
2736
3077
|
const previousCovered = sums[0];
|
|
2737
|
-
|
|
3078
|
+
add2(0, ds);
|
|
2738
3079
|
const previous = profile.heights[i - 1], dh = height - previous;
|
|
2739
|
-
|
|
2740
|
-
|
|
3080
|
+
add2(dh >= 0 ? 2 : 3, Math.abs(dh));
|
|
3081
|
+
add2(4, Math.hypot(ds, dh));
|
|
2741
3082
|
const average = previous + dh / 2;
|
|
2742
|
-
|
|
3083
|
+
add2(5, average * ds);
|
|
2743
3084
|
if (previousCovered === 0)
|
|
2744
3085
|
meanHeight = average;
|
|
2745
3086
|
else {
|
|
@@ -2777,6 +3118,156 @@ function weighted(value, part, total) {
|
|
|
2777
3118
|
return value * ratio;
|
|
2778
3119
|
}
|
|
2779
3120
|
|
|
3121
|
+
// dist/terrain/profile-visibility.js
|
|
3122
|
+
function getTerrainProfileVisibility(profile, options) {
|
|
3123
|
+
const { observerHeight, targetHeight } = options;
|
|
3124
|
+
const limit = options.maxSamples ?? 1e6;
|
|
3125
|
+
const { distances, heights, statuses, length } = profile;
|
|
3126
|
+
const count = distances.length;
|
|
3127
|
+
if (!(distances instanceof Float64Array) || !(heights instanceof Float64Array) || !(statuses instanceof Uint8Array) || count < 2 || heights.length !== count || statuses.length !== count || !Number.isSafeInteger(limit) || limit < count || !Number.isFinite(observerHeight) || !Number.isFinite(targetHeight) || !Number.isFinite(length) || length <= 0 || distances[0] !== 0 || distances[count - 1] !== length)
|
|
3128
|
+
throw new Error("Invalid terrain visibility profile or options");
|
|
3129
|
+
let missingSampleCount = 0;
|
|
3130
|
+
let firstBlockingSample;
|
|
3131
|
+
let minimumClearance = Infinity;
|
|
3132
|
+
for (let i = 0; i < count; i++) {
|
|
3133
|
+
const distance = distances[i], status = statuses[i];
|
|
3134
|
+
if (!Number.isFinite(distance) || i > 0 && distance <= distances[i - 1])
|
|
3135
|
+
throw new Error("Invalid terrain visibility stationing");
|
|
3136
|
+
if (status > TerrainSampleStatus.NOT_RESIDENT)
|
|
3137
|
+
throw new Error("Invalid terrain visibility status");
|
|
3138
|
+
if (status !== TerrainSampleStatus.VALID) {
|
|
3139
|
+
missingSampleCount++;
|
|
3140
|
+
continue;
|
|
3141
|
+
}
|
|
3142
|
+
if (!Number.isFinite(heights[i]))
|
|
3143
|
+
throw new Error("Invalid terrain visibility height");
|
|
3144
|
+
const fraction = distance / length;
|
|
3145
|
+
const lineHeight = observerHeight * (1 - fraction) + targetHeight * fraction;
|
|
3146
|
+
const clearance = lineHeight - heights[i];
|
|
3147
|
+
if (!Number.isFinite(clearance))
|
|
3148
|
+
throw new Error("Terrain visibility arithmetic overflow");
|
|
3149
|
+
minimumClearance = Math.min(minimumClearance, clearance);
|
|
3150
|
+
if (clearance <= 0 && firstBlockingSample === void 0)
|
|
3151
|
+
firstBlockingSample = i;
|
|
3152
|
+
}
|
|
3153
|
+
return {
|
|
3154
|
+
status: firstBlockingSample !== void 0 ? "blocked" : missingSampleCount ? "unknown" : "clear",
|
|
3155
|
+
firstBlockingSample,
|
|
3156
|
+
missingSampleCount,
|
|
3157
|
+
minimumClearance: minimumClearance === Infinity ? void 0 : minimumClearance
|
|
3158
|
+
};
|
|
3159
|
+
}
|
|
3160
|
+
|
|
3161
|
+
// dist/terrain/profile-slope.js
|
|
3162
|
+
function compareTerrainSlopes(a, ad, b, bd) {
|
|
3163
|
+
const as = a / ad;
|
|
3164
|
+
const bs = b / bd;
|
|
3165
|
+
if (as < bs)
|
|
3166
|
+
return -1;
|
|
3167
|
+
if (as > bs)
|
|
3168
|
+
return 1;
|
|
3169
|
+
if (a === 0 || b === 0 || Math.sign(a) !== Math.sign(b))
|
|
3170
|
+
return Math.sign(a) - Math.sign(b);
|
|
3171
|
+
const bytes = new DataView(new ArrayBuffer(8));
|
|
3172
|
+
const parts = (value) => {
|
|
3173
|
+
bytes.setFloat64(0, Math.abs(value));
|
|
3174
|
+
const bits2 = bytes.getBigUint64(0);
|
|
3175
|
+
const exponent = Number(bits2 >> 52n & 0x7ffn);
|
|
3176
|
+
const fraction = bits2 & 0xfffffffffffffn;
|
|
3177
|
+
return exponent ? [fraction | 0x10000000000000n, exponent - 1075] : [fraction, -1074];
|
|
3178
|
+
};
|
|
3179
|
+
const [am, ae] = parts(a), [bdm, bde] = parts(bd);
|
|
3180
|
+
const [bm, be] = parts(b), [adm, ade] = parts(ad);
|
|
3181
|
+
let left = am * bdm;
|
|
3182
|
+
let right = bm * adm;
|
|
3183
|
+
const shift = ae + bde - be - ade;
|
|
3184
|
+
if (shift > 0)
|
|
3185
|
+
left <<= BigInt(shift);
|
|
3186
|
+
else if (shift < 0)
|
|
3187
|
+
right <<= BigInt(-shift);
|
|
3188
|
+
return (left < right ? -1 : left > right ? 1 : 0) * Math.sign(a);
|
|
3189
|
+
}
|
|
3190
|
+
|
|
3191
|
+
// dist/terrain/profile-horizon.js
|
|
3192
|
+
function getTerrainProfileHorizon(profile, options) {
|
|
3193
|
+
const { distances, heights, statuses, length } = profile;
|
|
3194
|
+
const count = distances.length;
|
|
3195
|
+
const limit = options.maxSamples ?? 1e6;
|
|
3196
|
+
if (!(distances instanceof Float64Array) || !(heights instanceof Float64Array) || !(statuses instanceof Uint8Array) || count < 2 || heights.length !== count || statuses.length !== count || !Number.isSafeInteger(limit) || limit < count || !Number.isFinite(options.observerHeight) || !Number.isFinite(length) || length <= 0 || distances[0] !== 0 || distances[count - 1] !== length)
|
|
3197
|
+
throw new Error("Invalid terrain horizon profile or options");
|
|
3198
|
+
let winningRise = 0;
|
|
3199
|
+
let winningDistance = 1;
|
|
3200
|
+
let sampleIndex;
|
|
3201
|
+
let missingSampleCount = 0;
|
|
3202
|
+
for (let i = 0; i < count; i++) {
|
|
3203
|
+
const distance = distances[i];
|
|
3204
|
+
const status = statuses[i];
|
|
3205
|
+
if (!Number.isFinite(distance) || i > 0 && distance <= distances[i - 1])
|
|
3206
|
+
throw new Error("Invalid terrain horizon stationing");
|
|
3207
|
+
if (status > TerrainSampleStatus.NOT_RESIDENT)
|
|
3208
|
+
throw new Error("Invalid terrain horizon status");
|
|
3209
|
+
if (status !== TerrainSampleStatus.VALID) {
|
|
3210
|
+
missingSampleCount++;
|
|
3211
|
+
continue;
|
|
3212
|
+
}
|
|
3213
|
+
if (!Number.isFinite(heights[i]))
|
|
3214
|
+
throw new Error("Invalid terrain horizon height");
|
|
3215
|
+
if (i === 0) {
|
|
3216
|
+
if (options.observerHeight <= heights[i])
|
|
3217
|
+
throw new Error("Terrain horizon observer must be above ground");
|
|
3218
|
+
continue;
|
|
3219
|
+
}
|
|
3220
|
+
const delta = heights[i] - options.observerHeight;
|
|
3221
|
+
if (!Number.isFinite(delta))
|
|
3222
|
+
throw new Error("Terrain horizon arithmetic overflow");
|
|
3223
|
+
if (sampleIndex === void 0 || compareTerrainSlopes(delta, distance, winningRise, winningDistance) > 0) {
|
|
3224
|
+
winningRise = delta;
|
|
3225
|
+
winningDistance = distance;
|
|
3226
|
+
sampleIndex = i;
|
|
3227
|
+
}
|
|
3228
|
+
}
|
|
3229
|
+
return {
|
|
3230
|
+
angle: sampleIndex === void 0 ? void 0 : Math.atan2(winningRise, winningDistance),
|
|
3231
|
+
sampleIndex,
|
|
3232
|
+
missingSampleCount,
|
|
3233
|
+
complete: missingSampleCount === 0
|
|
3234
|
+
};
|
|
3235
|
+
}
|
|
3236
|
+
|
|
3237
|
+
// dist/terrain/profile-viewshed.js
|
|
3238
|
+
var TerrainProfileViewStatus = {
|
|
3239
|
+
OBSERVER: 0,
|
|
3240
|
+
VISIBLE: 1,
|
|
3241
|
+
BLOCKED: 2,
|
|
3242
|
+
UNKNOWN: 3,
|
|
3243
|
+
MISSING: 4
|
|
3244
|
+
};
|
|
3245
|
+
function getTerrainProfileViewshed(profile, options) {
|
|
3246
|
+
getTerrainProfileHorizon(profile, options);
|
|
3247
|
+
const result = new Uint8Array(profile.distances.length);
|
|
3248
|
+
let maxRise = 0;
|
|
3249
|
+
let maxDistance = 1;
|
|
3250
|
+
let hasHorizon = false;
|
|
3251
|
+
let missingBefore = profile.statuses[0] !== TerrainSampleStatus.VALID;
|
|
3252
|
+
for (let i = 1; i < result.length; i++) {
|
|
3253
|
+
if (profile.statuses[i] !== TerrainSampleStatus.VALID) {
|
|
3254
|
+
result[i] = TerrainProfileViewStatus.MISSING;
|
|
3255
|
+
missingBefore = true;
|
|
3256
|
+
continue;
|
|
3257
|
+
}
|
|
3258
|
+
const rise = profile.heights[i] - options.observerHeight;
|
|
3259
|
+
const distance = profile.distances[i];
|
|
3260
|
+
const comparison = hasHorizon ? compareTerrainSlopes(rise, distance, maxRise, maxDistance) : 1;
|
|
3261
|
+
result[i] = comparison <= 0 ? TerrainProfileViewStatus.BLOCKED : missingBefore ? TerrainProfileViewStatus.UNKNOWN : TerrainProfileViewStatus.VISIBLE;
|
|
3262
|
+
if (comparison > 0) {
|
|
3263
|
+
maxRise = rise;
|
|
3264
|
+
maxDistance = distance;
|
|
3265
|
+
hasHorizon = true;
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
return result;
|
|
3269
|
+
}
|
|
3270
|
+
|
|
2780
3271
|
// dist/terrain/vertex-tiles.js
|
|
2781
3272
|
function reconcileTerrainVertexTiles(tiles, options) {
|
|
2782
3273
|
const { width, height } = options;
|
|
@@ -2799,10 +3290,10 @@ function reconcileTerrainVertexTiles(tiles, options) {
|
|
|
2799
3290
|
const shared = /* @__PURE__ */ new Map();
|
|
2800
3291
|
const result = [];
|
|
2801
3292
|
for (const tile of sorted) {
|
|
2802
|
-
const
|
|
2803
|
-
if (!Number.isSafeInteger(tile.column) || !Number.isSafeInteger(tile.row) || seen.has(
|
|
3293
|
+
const key2 = `${tile.column},${tile.row}`;
|
|
3294
|
+
if (!Number.isSafeInteger(tile.column) || !Number.isSafeInteger(tile.row) || seen.has(key2))
|
|
2804
3295
|
throw new Error("Invalid or duplicate vertex tile address");
|
|
2805
|
-
seen.add(
|
|
3296
|
+
seen.add(key2);
|
|
2806
3297
|
const x = tile.column * (width - 1), y = tile.row * (height - 1);
|
|
2807
3298
|
if (![x, y, x + width - 1, y + height - 1].every(Number.isSafeInteger))
|
|
2808
3299
|
throw new Error("Vertex tile lattice overflow");
|
|
@@ -2877,6 +3368,221 @@ function reconcileTerrainVertexTiles(tiles, options) {
|
|
|
2877
3368
|
return { tiles: result, sharedVertices, maxHeightDifference };
|
|
2878
3369
|
}
|
|
2879
3370
|
|
|
3371
|
+
// dist/terrain/vertex-halos.js
|
|
3372
|
+
var TerrainVertexHaloStatus = { NOT_RESIDENT: 0, NO_DATA: 1, VALID: 2 };
|
|
3373
|
+
function createTerrainVertexTileHalos(tiles, options) {
|
|
3374
|
+
const { width, height } = options;
|
|
3375
|
+
const paddedWidth = width + 2, paddedHeight = height + 2;
|
|
3376
|
+
const paddedCount = paddedWidth * paddedHeight * tiles.length;
|
|
3377
|
+
if (!Number.isSafeInteger(paddedCount) || paddedCount > (options.maxSamples ?? 4e6))
|
|
3378
|
+
throw new Error("Vertex tile halo sample capacity exceeded");
|
|
3379
|
+
const reconciled = reconcileTerrainVertexTiles(tiles, options);
|
|
3380
|
+
const lattice = /* @__PURE__ */ new Map();
|
|
3381
|
+
for (const tile of reconciled.tiles) {
|
|
3382
|
+
const x = tile.column * (width - 1), y = tile.row * (height - 1);
|
|
3383
|
+
if (![x - 1, y - 1, x + width, y + height].every(Number.isSafeInteger))
|
|
3384
|
+
throw new Error("Vertex tile halo lattice overflow");
|
|
3385
|
+
for (let row = 0; row < height; row++) {
|
|
3386
|
+
for (let col = 0; col < width; col++) {
|
|
3387
|
+
const index = row * width + col;
|
|
3388
|
+
lattice.set(`${x + col},${y + row}`, {
|
|
3389
|
+
height: tile.field.heights[index],
|
|
3390
|
+
valid: tile.field.validity[index] !== 0
|
|
3391
|
+
});
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3394
|
+
}
|
|
3395
|
+
const result = reconciled.tiles.map((tile) => {
|
|
3396
|
+
const x = tile.column * (width - 1), y = tile.row * (height - 1);
|
|
3397
|
+
const heights = new Float64Array(paddedWidth * paddedHeight);
|
|
3398
|
+
const validity = new Uint8Array(heights.length);
|
|
3399
|
+
const statuses = new Uint8Array(heights.length);
|
|
3400
|
+
for (let row = 0; row < paddedHeight; row++) {
|
|
3401
|
+
for (let col = 0; col < paddedWidth; col++) {
|
|
3402
|
+
const index = row * paddedWidth + col;
|
|
3403
|
+
const value = lattice.get(`${x + col - 1},${y + row - 1}`);
|
|
3404
|
+
if (value) {
|
|
3405
|
+
statuses[index] = value.valid ? TerrainVertexHaloStatus.VALID : TerrainVertexHaloStatus.NO_DATA;
|
|
3406
|
+
if (value.valid) {
|
|
3407
|
+
heights[index] = value.height;
|
|
3408
|
+
validity[index] = 1;
|
|
3409
|
+
}
|
|
3410
|
+
}
|
|
3411
|
+
}
|
|
3412
|
+
}
|
|
3413
|
+
const origin = tile.field.origin, columnStep = tile.field.columnStep, rowStep = tile.field.rowStep;
|
|
3414
|
+
const paddedOrigin = [
|
|
3415
|
+
origin[0] - columnStep[0] - rowStep[0],
|
|
3416
|
+
origin[1] - columnStep[1] - rowStep[1]
|
|
3417
|
+
];
|
|
3418
|
+
if (!paddedOrigin.every(Number.isFinite))
|
|
3419
|
+
throw new Error("Vertex tile halo coordinate overflow");
|
|
3420
|
+
return {
|
|
3421
|
+
column: tile.column,
|
|
3422
|
+
row: tile.row,
|
|
3423
|
+
statuses,
|
|
3424
|
+
field: {
|
|
3425
|
+
...tile.field,
|
|
3426
|
+
width: paddedWidth,
|
|
3427
|
+
height: paddedHeight,
|
|
3428
|
+
heights,
|
|
3429
|
+
validity,
|
|
3430
|
+
origin: paddedOrigin
|
|
3431
|
+
}
|
|
3432
|
+
};
|
|
3433
|
+
});
|
|
3434
|
+
return {
|
|
3435
|
+
tiles: result,
|
|
3436
|
+
sharedVertices: reconciled.sharedVertices,
|
|
3437
|
+
maxHeightDifference: reconciled.maxHeightDifference
|
|
3438
|
+
};
|
|
3439
|
+
}
|
|
3440
|
+
|
|
3441
|
+
// dist/terrain/vertex-halo-invalidation.js
|
|
3442
|
+
function getTerrainVertexHaloAffectedTiles(resident, changed, options) {
|
|
3443
|
+
const limit = options.maxTiles ?? 4096;
|
|
3444
|
+
if (!Number.isSafeInteger(limit) || limit < 0 || resident.length > limit || changed.length > limit || !Number.isSafeInteger(options.width) || options.width < 2 || !Number.isSafeInteger(options.height) || options.height < 2)
|
|
3445
|
+
throw new Error("Invalid vertex halo tile capacity");
|
|
3446
|
+
const addresses = /* @__PURE__ */ new Map();
|
|
3447
|
+
const key2 = (tile) => {
|
|
3448
|
+
if (!Number.isSafeInteger(tile.column) || !Number.isSafeInteger(tile.row))
|
|
3449
|
+
throw new Error("Invalid vertex tile address");
|
|
3450
|
+
return `${tile.column},${tile.row}`;
|
|
3451
|
+
};
|
|
3452
|
+
for (const tile of resident) {
|
|
3453
|
+
const id = key2(tile);
|
|
3454
|
+
if (addresses.has(id))
|
|
3455
|
+
throw new Error("Duplicate resident vertex tile address");
|
|
3456
|
+
addresses.set(id, { column: tile.column, row: tile.row });
|
|
3457
|
+
}
|
|
3458
|
+
const affected = /* @__PURE__ */ new Map();
|
|
3459
|
+
for (const tile of changed) {
|
|
3460
|
+
key2(tile);
|
|
3461
|
+
const rx = options.width === 2 ? 2 : 1, ry = options.height === 2 ? 2 : 1;
|
|
3462
|
+
for (let x = -rx; x <= rx; x++)
|
|
3463
|
+
for (let y = -ry; y <= ry; y++) {
|
|
3464
|
+
const column = tile.column + x, row = tile.row + y;
|
|
3465
|
+
if (!Number.isSafeInteger(column) || !Number.isSafeInteger(row))
|
|
3466
|
+
continue;
|
|
3467
|
+
const id = `${column},${row}`;
|
|
3468
|
+
const target = addresses.get(id);
|
|
3469
|
+
if (target)
|
|
3470
|
+
affected.set(id, target);
|
|
3471
|
+
}
|
|
3472
|
+
}
|
|
3473
|
+
return [...affected.values()].sort((a, b) => a.column - b.column || a.row - b.row);
|
|
3474
|
+
}
|
|
3475
|
+
|
|
3476
|
+
// dist/terrain/vertex-halo-update.js
|
|
3477
|
+
function updateTerrainVertexTileHalos(previous, resident, changed, options) {
|
|
3478
|
+
const prior = options.previousOptions;
|
|
3479
|
+
if (!prior)
|
|
3480
|
+
throw new Error("Previous vertex tile options are required");
|
|
3481
|
+
const paddedCount = (options.width + 2) * (options.height + 2) * resident.length;
|
|
3482
|
+
if (!Number.isSafeInteger(paddedCount) || paddedCount > (options.maxSamples ?? 4e6))
|
|
3483
|
+
throw new Error("Vertex tile halo sample capacity exceeded");
|
|
3484
|
+
const equalPair = (a, b) => a[0] === b[0] && a[1] === b[1];
|
|
3485
|
+
if (prior.width !== options.width || prior.height !== options.height || !equalPair(prior.origin ?? [0, 0], options.origin ?? [0, 0]) || !equalPair(prior.columnStep ?? [1, 0], options.columnStep ?? [1, 0]) || !equalPair(prior.rowStep ?? [0, 1], options.rowStep ?? [0, 1]) || (prior.heightReference ?? "unknown") !== (options.heightReference ?? "unknown") || (prior.maxHeightDifference ?? 0) !== (options.maxHeightDifference ?? 0))
|
|
3486
|
+
throw new Error("Vertex tile options changed; rebuild the full snapshot");
|
|
3487
|
+
const key2 = (t) => `${t.column},${t.row}`;
|
|
3488
|
+
const affected = getTerrainVertexHaloAffectedTiles(resident, changed, options);
|
|
3489
|
+
getTerrainVertexHaloAffectedTiles(previous, [], options);
|
|
3490
|
+
const previousMap = new Map(previous.map((tile) => [key2(tile), tile]));
|
|
3491
|
+
const currentKeys = new Set(resident.map(key2));
|
|
3492
|
+
const changedKeys = new Set(changed.map(key2));
|
|
3493
|
+
for (const tile of resident) {
|
|
3494
|
+
if (!previousMap.has(key2(tile)) && !changedKeys.has(key2(tile)))
|
|
3495
|
+
throw new Error("Unreported vertex tile arrival");
|
|
3496
|
+
}
|
|
3497
|
+
const removed = [];
|
|
3498
|
+
for (const tile of previous) {
|
|
3499
|
+
if (!currentKeys.has(key2(tile))) {
|
|
3500
|
+
if (!changedKeys.has(key2(tile)))
|
|
3501
|
+
throw new Error("Unreported vertex tile eviction");
|
|
3502
|
+
removed.push({ column: tile.column, row: tile.row });
|
|
3503
|
+
}
|
|
3504
|
+
}
|
|
3505
|
+
removed.sort((a, b) => a.column - b.column || a.row - b.row);
|
|
3506
|
+
const affectedKeys = new Set(affected.map(key2));
|
|
3507
|
+
const rx = options.width === 2 ? 2 : 1;
|
|
3508
|
+
const ry = options.height === 2 ? 2 : 1;
|
|
3509
|
+
const needed = /* @__PURE__ */ new Set();
|
|
3510
|
+
for (const tile of affected)
|
|
3511
|
+
for (let x = -rx; x <= rx; x++)
|
|
3512
|
+
for (let y = -ry; y <= ry; y++) {
|
|
3513
|
+
const column = tile.column + x, row = tile.row + y;
|
|
3514
|
+
if (Number.isSafeInteger(column) && Number.isSafeInteger(row))
|
|
3515
|
+
needed.add(`${column},${row}`);
|
|
3516
|
+
}
|
|
3517
|
+
const source = resident.filter((tile) => needed.has(key2(tile)));
|
|
3518
|
+
const rebuilt = createTerrainVertexTileHalos(source, options).tiles;
|
|
3519
|
+
const results = new Map(previous.filter((tile) => currentKeys.has(key2(tile)) && !affectedKeys.has(key2(tile))).map((tile) => [key2(tile), tile]));
|
|
3520
|
+
for (const tile of rebuilt)
|
|
3521
|
+
if (affectedKeys.has(key2(tile)))
|
|
3522
|
+
results.set(key2(tile), tile);
|
|
3523
|
+
if (results.size !== resident.length)
|
|
3524
|
+
throw new Error("Incomplete vertex halo update");
|
|
3525
|
+
return {
|
|
3526
|
+
tiles: [...results.values()].sort((a, b) => a.column - b.column || a.row - b.row),
|
|
3527
|
+
rebuilt: affected,
|
|
3528
|
+
removed
|
|
3529
|
+
};
|
|
3530
|
+
}
|
|
3531
|
+
|
|
3532
|
+
// dist/terrain/filtered-pyramid.js
|
|
3533
|
+
function createTerrainFilteredPyramid(input, options = {}) {
|
|
3534
|
+
const { width, height, heights, validity } = input;
|
|
3535
|
+
const count = width * height;
|
|
3536
|
+
const limit = options.maxSamples ?? 4e6;
|
|
3537
|
+
if (!Number.isSafeInteger(width) || width < 1 || !Number.isSafeInteger(height) || height < 1 || !Number.isSafeInteger(count) || count > 4294967295 || !Number.isSafeInteger(limit) || limit < count || !(heights instanceof Float32Array || heights instanceof Float64Array) || heights.length !== count || validity !== void 0 && (!(validity instanceof Uint8Array) || validity.length !== count))
|
|
3538
|
+
throw new Error("Invalid terrain filtered pyramid input or capacity");
|
|
3539
|
+
const base = {
|
|
3540
|
+
width,
|
|
3541
|
+
height,
|
|
3542
|
+
heights: new Float64Array(count),
|
|
3543
|
+
validCounts: new Uint32Array(count),
|
|
3544
|
+
sampleCounts: new Uint32Array(count).fill(1)
|
|
3545
|
+
};
|
|
3546
|
+
for (let i = 0; i < count; i++)
|
|
3547
|
+
if ((!validity || validity[i] !== 0) && Number.isFinite(heights[i])) {
|
|
3548
|
+
base.heights[i] = heights[i];
|
|
3549
|
+
base.validCounts[i] = 1;
|
|
3550
|
+
}
|
|
3551
|
+
const levels = [base];
|
|
3552
|
+
let source = base;
|
|
3553
|
+
while (source.width > 1 || source.height > 1) {
|
|
3554
|
+
const w = Math.ceil(source.width / 2), h = Math.ceil(source.height / 2);
|
|
3555
|
+
const next = {
|
|
3556
|
+
width: w,
|
|
3557
|
+
height: h,
|
|
3558
|
+
heights: new Float64Array(w * h),
|
|
3559
|
+
validCounts: new Uint32Array(w * h),
|
|
3560
|
+
sampleCounts: new Uint32Array(w * h)
|
|
3561
|
+
};
|
|
3562
|
+
for (let y = 0; y < h; y++)
|
|
3563
|
+
for (let x = 0; x < w; x++) {
|
|
3564
|
+
const out = y * w + x;
|
|
3565
|
+
for (let dy = 0; dy < 2; dy++)
|
|
3566
|
+
for (let dx = 0; dx < 2; dx++) {
|
|
3567
|
+
const sx = x * 2 + dx, sy = y * 2 + dy;
|
|
3568
|
+
if (sx >= source.width || sy >= source.height)
|
|
3569
|
+
continue;
|
|
3570
|
+
const index = sy * source.width + sx;
|
|
3571
|
+
const n = source.validCounts[index], old = next.validCounts[out];
|
|
3572
|
+
next.sampleCounts[out] += source.sampleCounts[index];
|
|
3573
|
+
if (n) {
|
|
3574
|
+
const total = old + n, a = next.heights[out], b = source.heights[index];
|
|
3575
|
+
next.heights[out] = old ? a * (old / total) + b * (n / total) : b;
|
|
3576
|
+
next.validCounts[out] = total;
|
|
3577
|
+
}
|
|
3578
|
+
}
|
|
3579
|
+
}
|
|
3580
|
+
levels.push(next);
|
|
3581
|
+
source = next;
|
|
3582
|
+
}
|
|
3583
|
+
return levels;
|
|
3584
|
+
}
|
|
3585
|
+
|
|
2880
3586
|
// dist/terrain/mesh-stitch.js
|
|
2881
3587
|
function stitchTerrainMeshEdges(a, edgeA, b, edgeB, options = {}) {
|
|
2882
3588
|
const maxVertices = options.maxVertices ?? 2e6, maxTriangles = options.maxTriangles ?? 4e6, maxBoundary = options.maxBoundaryVertices ?? 1e5;
|
|
@@ -2924,9 +3630,9 @@ function stitchTerrainMeshEdges(a, edgeA, b, edgeB, options = {}) {
|
|
|
2924
3630
|
let direction = 0;
|
|
2925
3631
|
for (let i = 0; i < mesh.indices.length; i += 3)
|
|
2926
3632
|
for (let j = 0; j < 3; j++) {
|
|
2927
|
-
const u = mesh.indices[i + j], v = mesh.indices[i + (j + 1) % 3],
|
|
2928
|
-
if (pairs.has(
|
|
2929
|
-
pairs.set(
|
|
3633
|
+
const u = mesh.indices[i + j], v = mesh.indices[i + (j + 1) % 3], key2 = pair(u, v);
|
|
3634
|
+
if (pairs.has(key2)) {
|
|
3635
|
+
pairs.set(key2, pairs.get(key2) + 1);
|
|
2930
3636
|
const nextDirection = Math.sign(mesh.gridCoordinates[2 * v + 1 - axis] - mesh.gridCoordinates[2 * u + 1 - axis]);
|
|
2931
3637
|
if (direction && direction !== nextDirection)
|
|
2932
3638
|
throw new Error("Inconsistent stitching boundary orientation");
|
|
@@ -3096,4 +3802,3154 @@ function stitchTerrainMeshEdges(a, edgeA, b, edgeB, options = {}) {
|
|
|
3096
3802
|
function pair(a, b) {
|
|
3097
3803
|
return a < b ? `${a},${b}` : `${b},${a}`;
|
|
3098
3804
|
}
|
|
3805
|
+
|
|
3806
|
+
// dist/terrain/contour-mixed-weld.js
|
|
3807
|
+
function weldTerrainMixedContourTiles(tiles, options = {}) {
|
|
3808
|
+
const limits = contourPathLimits(options);
|
|
3809
|
+
const maxTiles = options.maxTiles ?? 4096;
|
|
3810
|
+
const budget = options.maxBoundaryTests ?? 1e7;
|
|
3811
|
+
const tolerance = options.maxPositionDifference ?? 0;
|
|
3812
|
+
if (!Number.isSafeInteger(maxTiles) || maxTiles < 1 || !tiles.length || tiles.length > maxTiles || !Number.isSafeInteger(budget) || budget < 0 || !Number.isFinite(tolerance) || tolerance < 0)
|
|
3813
|
+
throw new Error("Invalid mixed contour capacity or tolerance");
|
|
3814
|
+
let tests = 0;
|
|
3815
|
+
const charge = () => {
|
|
3816
|
+
if (++tests > budget)
|
|
3817
|
+
throw new Error("Mixed contour boundary-test budget exceeded");
|
|
3818
|
+
};
|
|
3819
|
+
const sorted = [...tiles].sort((a, b) => a.column - b.column || a.row - b.row || a.spacing - b.spacing);
|
|
3820
|
+
const bounds2 = sorted.map((t) => {
|
|
3821
|
+
if (![t.column, t.row, t.width, t.height, t.spacing].every(Number.isSafeInteger) || t.width < 2 || t.height < 2 || t.spacing < 1 || 2 ** Math.round(Math.log2(t.spacing)) !== t.spacing)
|
|
3822
|
+
throw new Error("Invalid mixed contour tile lattice");
|
|
3823
|
+
const x1 = t.column + (t.width - 1) * t.spacing, y1 = t.row + (t.height - 1) * t.spacing;
|
|
3824
|
+
if (![(t.width - 1) * t.spacing, (t.height - 1) * t.spacing, x1, y1].every(Number.isSafeInteger))
|
|
3825
|
+
throw new Error("Mixed contour lattice overflow");
|
|
3826
|
+
return [t.column, t.row, x1, y1];
|
|
3827
|
+
});
|
|
3828
|
+
for (let i = 0; i < bounds2.length; i++)
|
|
3829
|
+
for (let j = 0; j < i; j++) {
|
|
3830
|
+
charge();
|
|
3831
|
+
const a = bounds2[i], b = bounds2[j];
|
|
3832
|
+
if (Math.max(a[0], b[0]) < Math.min(a[2], b[2]) && Math.max(a[1], b[1]) < Math.min(a[3], b[3]))
|
|
3833
|
+
throw new Error("Mixed contour tile interiors overlap");
|
|
3834
|
+
}
|
|
3835
|
+
const first = sorted[0].contours, origin = [...first.origin];
|
|
3836
|
+
const positions = [], grid = [], vertexLevels = [];
|
|
3837
|
+
const roundedBoundary = /* @__PURE__ */ new Map();
|
|
3838
|
+
const boundary = /* @__PURE__ */ new Set(), shared = /* @__PURE__ */ new Map();
|
|
3839
|
+
const edges2 = [];
|
|
3840
|
+
let inputVertices = 0, inputSegments = 0;
|
|
3841
|
+
for (let ti = 0; ti < sorted.length; ti++) {
|
|
3842
|
+
const tile = sorted[ti], data = tile.contours;
|
|
3843
|
+
const count = validateContourData(data, limits);
|
|
3844
|
+
inputVertices += count;
|
|
3845
|
+
if (inputVertices > limits.maxVertices)
|
|
3846
|
+
throw new Error("Mixed contour input vertex capacity exceeded");
|
|
3847
|
+
if (data.heightReference !== first.heightReference || data.levels.length !== first.levels.length || !data.levels.every((v, i) => v === first.levels[i]))
|
|
3848
|
+
throw new Error("Mixed contour levels or height reference differ");
|
|
3849
|
+
if (!(data.segments instanceof Uint32Array) || data.segments.length % 2 || !(data.levelIndices instanceof Uint32Array) || data.levelIndices.length !== data.segments.length / 2)
|
|
3850
|
+
throw new Error("Invalid mixed contour segments");
|
|
3851
|
+
inputSegments += data.levelIndices.length;
|
|
3852
|
+
if (inputSegments > limits.maxSegments)
|
|
3853
|
+
throw new Error("Mixed contour input segment capacity exceeded");
|
|
3854
|
+
const assigned = new Uint32Array(count).fill(4294967295), remap = /* @__PURE__ */ new Map();
|
|
3855
|
+
const local = /* @__PURE__ */ new Set();
|
|
3856
|
+
const vertex = (v, level) => {
|
|
3857
|
+
validateContourVertex(data, v, level, assigned);
|
|
3858
|
+
const existing = remap.get(v);
|
|
3859
|
+
if (existing !== void 0)
|
|
3860
|
+
return existing;
|
|
3861
|
+
const x = data.gridCoordinates[2 * v], y = data.gridCoordinates[2 * v + 1];
|
|
3862
|
+
if (x < 0 || x > tile.width - 1 || y < 0 || y > tile.height - 1)
|
|
3863
|
+
throw new Error("Mixed contour vertex outside tile");
|
|
3864
|
+
const sx = x * tile.spacing, sy = y * tile.spacing;
|
|
3865
|
+
const gx = tile.column + sx, gy = tile.row + sy;
|
|
3866
|
+
if (Math.abs(gx - tile.column - sx) > 8 * Number.EPSILON * Math.max(1, Math.abs(sx)) || Math.abs(gy - tile.row - sy) > 8 * Number.EPSILON * Math.max(1, Math.abs(sy)))
|
|
3867
|
+
throw new Error("Mixed contour lattice loses precision");
|
|
3868
|
+
const px = data.positions[3 * v] + (data.origin[0] - origin[0]), py = data.positions[3 * v + 1] + (data.origin[1] - origin[1]);
|
|
3869
|
+
const pz = data.levels[level] - origin[2];
|
|
3870
|
+
if (![gx, gy, px, py, pz].every(Number.isFinite))
|
|
3871
|
+
throw new Error("Mixed contour frame overflow");
|
|
3872
|
+
const onEdge = x === 0 || y === 0 || x === tile.width - 1 || y === tile.height - 1;
|
|
3873
|
+
const xi = Math.floor(sx), yi = Math.floor(sy);
|
|
3874
|
+
const key2 = `${level}/${tile.column + xi}/${sx - xi}/${tile.row + yi}/${sy - yi}`;
|
|
3875
|
+
if (onEdge) {
|
|
3876
|
+
const rounded = `${level}/${gx}/${gy}`;
|
|
3877
|
+
const identity = roundedBoundary.get(rounded);
|
|
3878
|
+
if (identity !== void 0 && identity !== key2)
|
|
3879
|
+
throw new Error("Mixed contour lattice loses precision");
|
|
3880
|
+
roundedBoundary.set(rounded, key2);
|
|
3881
|
+
}
|
|
3882
|
+
if (onEdge && local.has(key2))
|
|
3883
|
+
throw new Error("Duplicate mixed contour boundary vertex");
|
|
3884
|
+
if (onEdge)
|
|
3885
|
+
local.add(key2);
|
|
3886
|
+
let id = onEdge ? shared.get(key2) : void 0;
|
|
3887
|
+
if (id !== void 0) {
|
|
3888
|
+
if (Math.hypot(px - positions[3 * id], py - positions[3 * id + 1]) > tolerance)
|
|
3889
|
+
throw new Error("Mixed contour boundary positions disagree");
|
|
3890
|
+
} else {
|
|
3891
|
+
id = positions.length / 3;
|
|
3892
|
+
if (id >= limits.maxVertices)
|
|
3893
|
+
throw new Error("Mixed contour vertex capacity exceeded");
|
|
3894
|
+
positions.push(px, py, pz);
|
|
3895
|
+
grid.push(gx, gy);
|
|
3896
|
+
vertexLevels.push(level);
|
|
3897
|
+
if (onEdge) {
|
|
3898
|
+
shared.set(key2, id);
|
|
3899
|
+
boundary.add(id);
|
|
3900
|
+
}
|
|
3901
|
+
}
|
|
3902
|
+
remap.set(v, id);
|
|
3903
|
+
return id;
|
|
3904
|
+
};
|
|
3905
|
+
const localEdges = /* @__PURE__ */ new Set();
|
|
3906
|
+
for (let i = 0; i < data.levelIndices.length; i++) {
|
|
3907
|
+
const level = data.levelIndices[i], a = vertex(data.segments[2 * i], level), b = vertex(data.segments[2 * i + 1], level);
|
|
3908
|
+
if (a === b || positions[3 * a] === positions[3 * b] && positions[3 * a + 1] === positions[3 * b + 1])
|
|
3909
|
+
throw new Error("Degenerate mixed contour segment");
|
|
3910
|
+
const key2 = a < b ? `${a}/${b}` : `${b}/${a}`;
|
|
3911
|
+
if (localEdges.has(key2))
|
|
3912
|
+
throw new Error("Duplicate mixed contour segment");
|
|
3913
|
+
localEdges.add(key2);
|
|
3914
|
+
const box = bounds2[ti];
|
|
3915
|
+
const seam = grid[2 * a] === grid[2 * b] && (grid[2 * a] === box[0] || grid[2 * a] === box[2]) || grid[2 * a + 1] === grid[2 * b + 1] && (grid[2 * a + 1] === box[1] || grid[2 * a + 1] === box[3]);
|
|
3916
|
+
edges2.push({ a, b, level, tile: ti, seam });
|
|
3917
|
+
}
|
|
3918
|
+
}
|
|
3919
|
+
const segments = [], levels = [], emitted = /* @__PURE__ */ new Map();
|
|
3920
|
+
for (const edge2 of edges2) {
|
|
3921
|
+
const { a, b, level } = edge2;
|
|
3922
|
+
const axis = grid[2 * a] === grid[2 * b] ? 1 : 0;
|
|
3923
|
+
const start = grid[2 * a + axis], end = grid[2 * b + axis];
|
|
3924
|
+
const cuts = [a, b];
|
|
3925
|
+
if (edge2.seam)
|
|
3926
|
+
for (const v of boundary) {
|
|
3927
|
+
charge();
|
|
3928
|
+
const value = grid[2 * v + axis];
|
|
3929
|
+
if (vertexLevels[v] !== level || grid[2 * v + 1 - axis] !== grid[2 * a + 1 - axis] || value <= Math.min(start, end) || value >= Math.max(start, end))
|
|
3930
|
+
continue;
|
|
3931
|
+
const f = (value - start) / (end - start);
|
|
3932
|
+
const px = positions[3 * a] + f * (positions[3 * b] - positions[3 * a]);
|
|
3933
|
+
const py = positions[3 * a + 1] + f * (positions[3 * b + 1] - positions[3 * a + 1]);
|
|
3934
|
+
if (Math.hypot(px - positions[3 * v], py - positions[3 * v + 1]) > tolerance)
|
|
3935
|
+
throw new Error("Mixed contour boundary positions disagree");
|
|
3936
|
+
cuts.push(v);
|
|
3937
|
+
}
|
|
3938
|
+
cuts.sort((u, v) => grid[2 * u + axis] - grid[2 * v + axis]);
|
|
3939
|
+
for (let i = 1; i < cuts.length; i++) {
|
|
3940
|
+
const u = cuts[i - 1], v = cuts[i], key2 = u < v ? `${u}/${v}` : `${v}/${u}`;
|
|
3941
|
+
const prior = emitted.get(key2);
|
|
3942
|
+
if (prior !== void 0) {
|
|
3943
|
+
if (prior === edge2.tile)
|
|
3944
|
+
throw new Error("Overlapping mixed contour segments within tile");
|
|
3945
|
+
continue;
|
|
3946
|
+
}
|
|
3947
|
+
if (levels.length >= limits.maxSegments)
|
|
3948
|
+
throw new Error("Mixed contour output segment capacity exceeded");
|
|
3949
|
+
emitted.set(key2, edge2.tile);
|
|
3950
|
+
segments.push(u, v);
|
|
3951
|
+
levels.push(level);
|
|
3952
|
+
}
|
|
3953
|
+
}
|
|
3954
|
+
return {
|
|
3955
|
+
positions: Float64Array.from(positions),
|
|
3956
|
+
gridCoordinates: Float64Array.from(grid),
|
|
3957
|
+
segments: Uint32Array.from(segments),
|
|
3958
|
+
levelIndices: Uint32Array.from(levels),
|
|
3959
|
+
levels: first.levels.slice(),
|
|
3960
|
+
origin,
|
|
3961
|
+
heightReference: first.heightReference
|
|
3962
|
+
};
|
|
3963
|
+
}
|
|
3964
|
+
|
|
3965
|
+
// dist/terrain/box-index.js
|
|
3966
|
+
var overlaps = (a, b) => a.minX <= b.maxX && b.minX <= a.maxX && a.minY <= b.maxY && b.minY <= a.maxY;
|
|
3967
|
+
function createTerrainBoxIndex(boxes) {
|
|
3968
|
+
const build = (ids) => {
|
|
3969
|
+
const box = { minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity };
|
|
3970
|
+
for (const id of ids) {
|
|
3971
|
+
const b = boxes[id];
|
|
3972
|
+
box.minX = Math.min(box.minX, b.minX);
|
|
3973
|
+
box.minY = Math.min(box.minY, b.minY);
|
|
3974
|
+
box.maxX = Math.max(box.maxX, b.maxX);
|
|
3975
|
+
box.maxY = Math.max(box.maxY, b.maxY);
|
|
3976
|
+
}
|
|
3977
|
+
if (ids.length <= 8)
|
|
3978
|
+
return { ...box, ids };
|
|
3979
|
+
const axis = box.maxX - box.minX >= box.maxY - box.minY ? "X" : "Y";
|
|
3980
|
+
ids.sort((a, b) => boxes[a][`min${axis}`] / 2 + boxes[a][`max${axis}`] / 2 - (boxes[b][`min${axis}`] / 2 + boxes[b][`max${axis}`] / 2) || a - b);
|
|
3981
|
+
const mid = ids.length >>> 1;
|
|
3982
|
+
return { ...box, left: build(ids.slice(0, mid)), right: build(ids.slice(mid)) };
|
|
3983
|
+
};
|
|
3984
|
+
const root = build(boxes.map((_, i) => i));
|
|
3985
|
+
return (query, charge) => {
|
|
3986
|
+
const found = [], stack = [root];
|
|
3987
|
+
while (stack.length) {
|
|
3988
|
+
charge();
|
|
3989
|
+
const node = stack.pop();
|
|
3990
|
+
if (!overlaps(node, query))
|
|
3991
|
+
continue;
|
|
3992
|
+
if (node.ids) {
|
|
3993
|
+
for (const id of node.ids) {
|
|
3994
|
+
charge();
|
|
3995
|
+
if (overlaps(boxes[id], query))
|
|
3996
|
+
found.push(id);
|
|
3997
|
+
}
|
|
3998
|
+
} else
|
|
3999
|
+
stack.push(node.right, node.left);
|
|
4000
|
+
}
|
|
4001
|
+
return found.sort((a, b) => a - b);
|
|
4002
|
+
};
|
|
4003
|
+
}
|
|
4004
|
+
|
|
4005
|
+
// dist/terrain/sample-triangle-height.js
|
|
4006
|
+
function sampleTerrainTriangleHeight(field, x, y) {
|
|
4007
|
+
if (Number.isInteger(x) && Number.isInteger(y))
|
|
4008
|
+
return field.getHeight(x, y);
|
|
4009
|
+
const column = Math.min(Math.floor(x), field.width - 2);
|
|
4010
|
+
const row = Math.min(Math.floor(y), field.height - 2);
|
|
4011
|
+
const u = x - column, v = y - row;
|
|
4012
|
+
let a, b, c, d;
|
|
4013
|
+
if (field.diagonal === "00-11") {
|
|
4014
|
+
if (v <= u) {
|
|
4015
|
+
a = 1 - u;
|
|
4016
|
+
b = u - v;
|
|
4017
|
+
c = 0;
|
|
4018
|
+
d = v;
|
|
4019
|
+
} else {
|
|
4020
|
+
a = 1 - v;
|
|
4021
|
+
b = 0;
|
|
4022
|
+
c = v - u;
|
|
4023
|
+
d = u;
|
|
4024
|
+
}
|
|
4025
|
+
} else if (u + v <= 1) {
|
|
4026
|
+
a = 1 - u - v;
|
|
4027
|
+
b = u;
|
|
4028
|
+
c = v;
|
|
4029
|
+
d = 0;
|
|
4030
|
+
} else {
|
|
4031
|
+
a = 0;
|
|
4032
|
+
b = 1 - v;
|
|
4033
|
+
c = 1 - u;
|
|
4034
|
+
d = u + v - 1;
|
|
4035
|
+
}
|
|
4036
|
+
const za = a ? field.getHeight(column, row) : 0;
|
|
4037
|
+
const zb = b ? field.getHeight(column + 1, row) : 0;
|
|
4038
|
+
const zc = c ? field.getHeight(column, row + 1) : 0;
|
|
4039
|
+
const zd = d ? field.getHeight(column + 1, row + 1) : 0;
|
|
4040
|
+
if (za === void 0 || zb === void 0 || zc === void 0 || zd === void 0)
|
|
4041
|
+
return void 0;
|
|
4042
|
+
const height = a * za + b * zb + c * zc + d * zd;
|
|
4043
|
+
if (!Number.isFinite(height))
|
|
4044
|
+
throw new Error("Terrain triangle numeric sampling failure");
|
|
4045
|
+
return height;
|
|
4046
|
+
}
|
|
4047
|
+
|
|
4048
|
+
// dist/terrain/mixed-vertex-halos.js
|
|
4049
|
+
function createTerrainMixedVertexTileHalos(tiles, options = {}) {
|
|
4050
|
+
return buildMixedVertexTileHalos(tiles, options);
|
|
4051
|
+
}
|
|
4052
|
+
function buildMixedVertexTileHalos(tiles, options = {}, targets, preparation) {
|
|
4053
|
+
const maxSamples = options.maxSamples ?? 4e6, maxTests = options.maxTileTests ?? 1e7;
|
|
4054
|
+
if (![maxSamples, maxTests].every((v) => Number.isSafeInteger(v) && v >= 0))
|
|
4055
|
+
throw new Error("Invalid mixed halo capacity");
|
|
4056
|
+
let count = 0;
|
|
4057
|
+
const addresses = /* @__PURE__ */ new Set();
|
|
4058
|
+
let frame;
|
|
4059
|
+
const sources = [...tiles].sort((a, b) => a.spacing - b.spacing || a.column - b.column || a.row - b.row).map((tile) => {
|
|
4060
|
+
if (![tile.column, tile.row, tile.spacing].every(Number.isSafeInteger) || tile.spacing < 1 || 2 ** Math.round(Math.log2(tile.spacing)) !== tile.spacing)
|
|
4061
|
+
throw new Error("Invalid mixed halo lattice");
|
|
4062
|
+
const key2 = `${tile.spacing}/${tile.column}/${tile.row}`;
|
|
4063
|
+
if (addresses.has(key2))
|
|
4064
|
+
throw new Error("Duplicate mixed halo tile");
|
|
4065
|
+
addresses.add(key2);
|
|
4066
|
+
count += (tile.field.width + 2) * (tile.field.height + 2);
|
|
4067
|
+
if (!Number.isSafeInteger(count) || count > maxSamples)
|
|
4068
|
+
throw new Error("Mixed halo sample capacity exceeded");
|
|
4069
|
+
let field = preparation == null ? void 0 : preparation.fields.get(tile);
|
|
4070
|
+
if (!field) {
|
|
4071
|
+
field = new HeightField(tile.field);
|
|
4072
|
+
preparation == null ? void 0 : preparation.fields.set(tile, field);
|
|
4073
|
+
}
|
|
4074
|
+
if (field.registration !== "vertex")
|
|
4075
|
+
throw new Error("Mixed halos require vertex registration");
|
|
4076
|
+
const column = field.columnStep.map((v) => v / tile.spacing);
|
|
4077
|
+
const row = field.rowStep.map((v) => v / tile.spacing);
|
|
4078
|
+
const origin = field.origin.map((v, axis) => v - tile.column * column[axis] - tile.row * row[axis]);
|
|
4079
|
+
const scale = field.origin.map((v, i) => Math.max(1, Math.abs(v), Math.abs(tile.column * column[i]), Math.abs(tile.row * row[i])));
|
|
4080
|
+
if (!origin.every(Number.isFinite))
|
|
4081
|
+
throw new Error("Mixed halo coordinate overflow");
|
|
4082
|
+
if (frame && (frame.reference !== field.heightReference || column.some((v, i) => v !== frame.column[i]) || row.some((v, i) => v !== frame.row[i]) || origin.some((v, i) => Math.abs(v - frame.origin[i]) > Math.min(16 * Number.EPSILON * Math.max(scale[i], frame.scale[i]), 1e-9 * Math.max(Math.abs(column[i]), Math.abs(row[i]))))))
|
|
4083
|
+
throw new Error("Mixed halo frames or height references differ");
|
|
4084
|
+
frame ?? (frame = { origin, column, row, reference: field.heightReference, scale });
|
|
4085
|
+
return { ...tile, source: field };
|
|
4086
|
+
});
|
|
4087
|
+
for (const axis of ["column", "row"]) {
|
|
4088
|
+
let min = Infinity, max = -Infinity;
|
|
4089
|
+
for (const tile of sources) {
|
|
4090
|
+
const size = axis === "column" ? tile.source.width : tile.source.height;
|
|
4091
|
+
const low = tile[axis] - tile.spacing, high = tile[axis] + size * tile.spacing;
|
|
4092
|
+
if (![low, high].every(Number.isSafeInteger))
|
|
4093
|
+
throw new Error("Mixed halo lattice overflow");
|
|
4094
|
+
min = Math.min(min, low);
|
|
4095
|
+
max = Math.max(max, high);
|
|
4096
|
+
}
|
|
4097
|
+
if (sources.length && !Number.isSafeInteger(max - min))
|
|
4098
|
+
throw new Error("Mixed halo lattice span overflow");
|
|
4099
|
+
}
|
|
4100
|
+
if (targets && targets.size === 0)
|
|
4101
|
+
return { tiles: [] };
|
|
4102
|
+
let index;
|
|
4103
|
+
if (sources.length > 8) {
|
|
4104
|
+
const keys = preparation && sources.map((tile) => `${tile.spacing}/${tile.column}/${tile.row}/${tile.source.width}/${tile.source.height}`);
|
|
4105
|
+
const cached = preparation == null ? void 0 : preparation.layout;
|
|
4106
|
+
if (keys && cached && keys.length === cached.keys.length && keys.every((key2, i) => key2 === cached.keys[i])) {
|
|
4107
|
+
index = cached.query;
|
|
4108
|
+
} else {
|
|
4109
|
+
index = createTerrainBoxIndex(sources.map((tile) => ({
|
|
4110
|
+
minX: tile.column,
|
|
4111
|
+
minY: tile.row,
|
|
4112
|
+
maxX: tile.column + (tile.source.width - 1) * tile.spacing,
|
|
4113
|
+
maxY: tile.row + (tile.source.height - 1) * tile.spacing
|
|
4114
|
+
})));
|
|
4115
|
+
if (preparation && keys)
|
|
4116
|
+
preparation.layout = { keys, query: index };
|
|
4117
|
+
}
|
|
4118
|
+
}
|
|
4119
|
+
let tests = 0;
|
|
4120
|
+
const charge = () => {
|
|
4121
|
+
if (++tests > maxTests)
|
|
4122
|
+
throw new Error("Mixed halo tile-test budget exceeded");
|
|
4123
|
+
};
|
|
4124
|
+
return {
|
|
4125
|
+
tiles: sources.filter((tile) => !targets || targets.has(`${tile.spacing}/${tile.column}/${tile.row}`)).map((tile) => {
|
|
4126
|
+
const source = tile.source, width = source.width + 2, height = source.height + 2;
|
|
4127
|
+
const heights = new Float64Array(width * height), validity = new Uint8Array(heights.length), statuses = new Uint8Array(heights.length);
|
|
4128
|
+
const candidates = (index == null ? void 0 : index({
|
|
4129
|
+
minX: tile.column - tile.spacing,
|
|
4130
|
+
minY: tile.row - tile.spacing,
|
|
4131
|
+
maxX: tile.column + source.width * tile.spacing,
|
|
4132
|
+
maxY: tile.row + source.height * tile.spacing
|
|
4133
|
+
}, charge).map((id) => sources[id])) ?? sources;
|
|
4134
|
+
for (let y = 0; y < height; y++)
|
|
4135
|
+
for (let x = 0; x < width; x++) {
|
|
4136
|
+
const gx = tile.column + (x - 1) * tile.spacing, gy = tile.row + (y - 1) * tile.spacing;
|
|
4137
|
+
if (![gx, gy].every(Number.isSafeInteger))
|
|
4138
|
+
throw new Error("Mixed halo lattice overflow");
|
|
4139
|
+
for (const candidate of candidates) {
|
|
4140
|
+
charge();
|
|
4141
|
+
const cx = (gx - candidate.column) / candidate.spacing, cy = (gy - candidate.row) / candidate.spacing;
|
|
4142
|
+
const f = candidate.source;
|
|
4143
|
+
if (cx < 0 || cy < 0 || cx > f.width - 1 || cy > f.height - 1)
|
|
4144
|
+
continue;
|
|
4145
|
+
const value = sampleTerrainTriangleHeight(f, cx, cy);
|
|
4146
|
+
const i = y * width + x;
|
|
4147
|
+
statuses[i] = value === void 0 ? 1 : 2;
|
|
4148
|
+
if (value !== void 0) {
|
|
4149
|
+
heights[i] = value;
|
|
4150
|
+
validity[i] = 1;
|
|
4151
|
+
}
|
|
4152
|
+
break;
|
|
4153
|
+
}
|
|
4154
|
+
}
|
|
4155
|
+
const origin = [
|
|
4156
|
+
source.origin[0] - source.columnStep[0] - source.rowStep[0],
|
|
4157
|
+
source.origin[1] - source.columnStep[1] - source.rowStep[1]
|
|
4158
|
+
];
|
|
4159
|
+
if (!origin.every(Number.isFinite))
|
|
4160
|
+
throw new Error("Mixed halo coordinate overflow");
|
|
4161
|
+
return {
|
|
4162
|
+
column: tile.column,
|
|
4163
|
+
row: tile.row,
|
|
4164
|
+
spacing: tile.spacing,
|
|
4165
|
+
statuses,
|
|
4166
|
+
field: {
|
|
4167
|
+
...tile.field,
|
|
4168
|
+
width,
|
|
4169
|
+
height,
|
|
4170
|
+
heights,
|
|
4171
|
+
validity,
|
|
4172
|
+
offset: 0,
|
|
4173
|
+
stride: width,
|
|
4174
|
+
origin,
|
|
4175
|
+
columnStep: [...source.columnStep],
|
|
4176
|
+
rowStep: [...source.rowStep]
|
|
4177
|
+
}
|
|
4178
|
+
};
|
|
4179
|
+
})
|
|
4180
|
+
};
|
|
4181
|
+
}
|
|
4182
|
+
|
|
4183
|
+
// dist/terrain/mixed-halo-update.js
|
|
4184
|
+
var key = (t) => `${t.spacing}/${t.column}/${t.row}`;
|
|
4185
|
+
var bounds = (tile, padding = 0) => ({
|
|
4186
|
+
minX: tile.column - padding,
|
|
4187
|
+
minY: tile.row - padding,
|
|
4188
|
+
maxX: tile.column + (tile.field.width - 1) * tile.spacing + padding,
|
|
4189
|
+
maxY: tile.row + (tile.field.height - 1) * tile.spacing + padding
|
|
4190
|
+
});
|
|
4191
|
+
var preparations = /* @__PURE__ */ new WeakMap();
|
|
4192
|
+
var targetIndexes = /* @__PURE__ */ new WeakMap();
|
|
4193
|
+
function editedBounds(old, next) {
|
|
4194
|
+
const a = old.field;
|
|
4195
|
+
const b = next.field;
|
|
4196
|
+
if (a.width !== b.width || a.height !== b.height || (a.diagonal ?? "00-11") !== (b.diagonal ?? "00-11"))
|
|
4197
|
+
return bounds(next);
|
|
4198
|
+
const sample = (field, x, y) => {
|
|
4199
|
+
const i = (field.offset ?? 0) + y * (field.stride ?? field.width) + x;
|
|
4200
|
+
const z = field.heights[i];
|
|
4201
|
+
return Number.isFinite(z) && (field.validity === void 0 || field.validity[i] !== 0) ? z : void 0;
|
|
4202
|
+
};
|
|
4203
|
+
let left = b.width, right = -1, top = b.height, bottom = -1;
|
|
4204
|
+
for (let y = 0; y < b.height; y++) {
|
|
4205
|
+
for (let x = 0; x < b.width; x++) {
|
|
4206
|
+
if (Object.is(sample(a, x, y), sample(b, x, y)))
|
|
4207
|
+
continue;
|
|
4208
|
+
left = Math.min(left, x);
|
|
4209
|
+
right = Math.max(right, x);
|
|
4210
|
+
top = Math.min(top, y);
|
|
4211
|
+
bottom = Math.max(bottom, y);
|
|
4212
|
+
}
|
|
4213
|
+
}
|
|
4214
|
+
if (right < 0)
|
|
4215
|
+
return null;
|
|
4216
|
+
return {
|
|
4217
|
+
minX: next.column + Math.max(0, left - 1) * next.spacing,
|
|
4218
|
+
maxX: next.column + Math.min(b.width - 1, right + 1) * next.spacing,
|
|
4219
|
+
minY: next.row + Math.max(0, top - 1) * next.spacing,
|
|
4220
|
+
maxY: next.row + Math.min(b.height - 1, bottom + 1) * next.spacing
|
|
4221
|
+
};
|
|
4222
|
+
}
|
|
4223
|
+
function updateTerrainMixedVertexTileHalos(previous, resident, options = {}) {
|
|
4224
|
+
const budget = options.maxDependencyTests ?? 1e7;
|
|
4225
|
+
if (!Number.isSafeInteger(budget) || budget < 0)
|
|
4226
|
+
throw new Error("Invalid mixed halo dependency budget");
|
|
4227
|
+
const old = new Map(previous == null ? void 0 : previous.sources.map((t) => [key(t), t]));
|
|
4228
|
+
const current = new Map(resident.map((t) => [key(t), t]));
|
|
4229
|
+
const cached = new Map(previous == null ? void 0 : previous.tiles.map((t) => [key(t), t]));
|
|
4230
|
+
const targets = /* @__PURE__ */ new Set();
|
|
4231
|
+
const unchangedLayout = (previous == null ? void 0 : previous.sources.length) === resident.length && resident.every((tile, i) => {
|
|
4232
|
+
const prior = previous.sources[i];
|
|
4233
|
+
return key(prior) === key(tile) && prior.field.width === tile.field.width && prior.field.height === tile.field.height;
|
|
4234
|
+
});
|
|
4235
|
+
let index = unchangedLayout && previous ? targetIndexes.get(previous) : void 0;
|
|
4236
|
+
let tests = 0;
|
|
4237
|
+
const charge = () => {
|
|
4238
|
+
if (++tests > budget)
|
|
4239
|
+
throw new Error("Mixed halo dependency budget exceeded");
|
|
4240
|
+
};
|
|
4241
|
+
function invalidate(box) {
|
|
4242
|
+
index ?? (index = createTerrainBoxIndex(resident.map((tile) => bounds(tile, tile.spacing))));
|
|
4243
|
+
for (const id of index(box, charge))
|
|
4244
|
+
targets.add(key(resident[id]));
|
|
4245
|
+
}
|
|
4246
|
+
for (const tile of resident) {
|
|
4247
|
+
const address = key(tile);
|
|
4248
|
+
const prior = old.get(address);
|
|
4249
|
+
if (!cached.has(address) || prior !== tile)
|
|
4250
|
+
targets.add(address);
|
|
4251
|
+
if (prior === tile || !previous)
|
|
4252
|
+
continue;
|
|
4253
|
+
if (!prior) {
|
|
4254
|
+
invalidate(bounds(tile));
|
|
4255
|
+
} else if (prior.field.width !== tile.field.width || prior.field.height !== tile.field.height) {
|
|
4256
|
+
invalidate(bounds(prior));
|
|
4257
|
+
invalidate(bounds(tile));
|
|
4258
|
+
} else {
|
|
4259
|
+
const dirty = editedBounds(prior, tile);
|
|
4260
|
+
if (dirty)
|
|
4261
|
+
invalidate(dirty);
|
|
4262
|
+
}
|
|
4263
|
+
}
|
|
4264
|
+
for (const [address, tile] of old) {
|
|
4265
|
+
if (!current.has(address) && resident.length)
|
|
4266
|
+
invalidate(bounds(tile));
|
|
4267
|
+
}
|
|
4268
|
+
const priorPreparation = previous && preparations.get(previous);
|
|
4269
|
+
const preparation = {
|
|
4270
|
+
fields: (priorPreparation == null ? void 0 : priorPreparation.fields) ?? /* @__PURE__ */ new WeakMap(),
|
|
4271
|
+
layout: priorPreparation == null ? void 0 : priorPreparation.layout
|
|
4272
|
+
};
|
|
4273
|
+
const built = buildMixedVertexTileHalos(resident, options, targets, preparation).tiles;
|
|
4274
|
+
for (const tile of built)
|
|
4275
|
+
cached.set(key(tile), tile);
|
|
4276
|
+
const tiles = resident.map((t) => cached.get(key(t))).sort((a, b) => a.spacing - b.spacing || a.column - b.column || a.row - b.row);
|
|
4277
|
+
const snapshot = {
|
|
4278
|
+
sources: resident.slice(),
|
|
4279
|
+
tiles,
|
|
4280
|
+
rebuilt: built.map(key),
|
|
4281
|
+
removed: [...old.keys()].filter((k) => !current.has(k)).sort()
|
|
4282
|
+
};
|
|
4283
|
+
preparations.set(snapshot, preparation);
|
|
4284
|
+
if (index)
|
|
4285
|
+
targetIndexes.set(snapshot, index);
|
|
4286
|
+
return snapshot;
|
|
4287
|
+
}
|
|
4288
|
+
|
|
4289
|
+
// dist/terrain/mixed-gradient-update.js
|
|
4290
|
+
function updateTerrainMixedGradientGrids(previous, halos, options = {}) {
|
|
4291
|
+
const method = options.method ?? "horn";
|
|
4292
|
+
if (method !== "horn" && method !== "zevenbergen-thorne")
|
|
4293
|
+
throw new Error("Unknown terrain gradient method");
|
|
4294
|
+
const limit = options.maxSamples ?? 4e6;
|
|
4295
|
+
const count = halos.tiles.reduce((n, t) => n + t.field.width * t.field.height, 0);
|
|
4296
|
+
if (!Number.isSafeInteger(limit) || limit < 0 || !Number.isSafeInteger(count) || count > limit)
|
|
4297
|
+
throw new Error("Mixed gradient sample capacity exceeded");
|
|
4298
|
+
const cache = new Map((previous == null ? void 0 : previous.method) === method ? previous.tiles.map((t) => [t.halo, t]) : []);
|
|
4299
|
+
return {
|
|
4300
|
+
method,
|
|
4301
|
+
tiles: halos.tiles.map((halo) => cache.get(halo) ?? {
|
|
4302
|
+
halo,
|
|
4303
|
+
grid: createTerrainGradientGrid(new HeightField(halo.field), { method, maxSamples: limit })
|
|
4304
|
+
})
|
|
4305
|
+
};
|
|
4306
|
+
}
|
|
4307
|
+
|
|
4308
|
+
// dist/terrain/contour-topology.js
|
|
4309
|
+
var bits = new DataView(new ArrayBuffer(8));
|
|
4310
|
+
function integer(x) {
|
|
4311
|
+
bits.setFloat64(0, x);
|
|
4312
|
+
const high = bits.getUint32(0), low = bits.getUint32(4);
|
|
4313
|
+
const exponent = high >>> 20 & 2047;
|
|
4314
|
+
const mantissa = BigInt(high & 1048575) << 32n | BigInt(low);
|
|
4315
|
+
const value = exponent ? (1n << 52n | mantissa) << BigInt(exponent - 1) : mantissa;
|
|
4316
|
+
return high >>> 31 ? -value : value;
|
|
4317
|
+
}
|
|
4318
|
+
var orientation = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
|
|
4319
|
+
var sign = (v) => v < 0n ? -1 : v > 0n ? 1 : 0;
|
|
4320
|
+
var between = (a, b, p) => p >= (a < b ? a : b) && p <= (a > b ? a : b);
|
|
4321
|
+
var on = (a, b, p) => orientation(a, b, p) === 0n && between(a.x, b.x, p.x) && between(a.y, b.y, p.y);
|
|
4322
|
+
function intersects(a, b, c, d) {
|
|
4323
|
+
return on(a, b, c) || on(a, b, d) || on(c, d, a) || on(c, d, b) || sign(orientation(a, b, c)) * sign(orientation(a, b, d)) < 0 && sign(orientation(c, d, a)) * sign(orientation(c, d, b)) < 0;
|
|
4324
|
+
}
|
|
4325
|
+
function simplifyTerrainContourPathsTopology(paths, options) {
|
|
4326
|
+
if (options.rejection !== void 0 && options.rejection !== "batch" && options.rejection !== "path")
|
|
4327
|
+
throw new Error("Invalid contour rejection policy");
|
|
4328
|
+
const candidate = simplifyTerrainContourPaths(paths, options);
|
|
4329
|
+
const budget = options.maxTopologyTests ?? 1e6;
|
|
4330
|
+
if (!Number.isSafeInteger(budget) || budget < 0)
|
|
4331
|
+
throw new Error("Invalid contour topology budget");
|
|
4332
|
+
let topologyTests = 0;
|
|
4333
|
+
const charge = () => {
|
|
4334
|
+
if (++topologyTests > budget)
|
|
4335
|
+
throw new Error("Contour topology work budget exceeded");
|
|
4336
|
+
};
|
|
4337
|
+
const points = new Array(paths.positions.length / 3);
|
|
4338
|
+
for (const i of new Set(paths.indices))
|
|
4339
|
+
points[i] = { x: integer(paths.positions[3 * i]), y: integer(paths.positions[3 * i + 1]) };
|
|
4340
|
+
const edges2 = [];
|
|
4341
|
+
for (let p = 0; p < paths.closed.length; p++)
|
|
4342
|
+
for (let i = paths.offsets[p]; i + 1 < paths.offsets[p + 1]; i++)
|
|
4343
|
+
edges2.push({ a: paths.indices[i], b: paths.indices[i + 1], p, i });
|
|
4344
|
+
const box = (a, b) => ({
|
|
4345
|
+
minX: Math.min(paths.positions[3 * a], paths.positions[3 * b]),
|
|
4346
|
+
maxX: Math.max(paths.positions[3 * a], paths.positions[3 * b]),
|
|
4347
|
+
minY: Math.min(paths.positions[3 * a + 1], paths.positions[3 * b + 1]),
|
|
4348
|
+
maxY: Math.max(paths.positions[3 * a + 1], paths.positions[3 * b + 1])
|
|
4349
|
+
});
|
|
4350
|
+
const edgeBoxes = edges2.map((e) => box(e.a, e.b)), edgeIndex = createTerrainBoxIndex(edgeBoxes);
|
|
4351
|
+
const vertexIds = [...new Set(paths.indices)], vertexIndex = createTerrainBoxIndex(vertexIds.map((v) => box(v, v)));
|
|
4352
|
+
for (let i = 0; i < edges2.length; i++)
|
|
4353
|
+
for (const j of edgeIndex(edgeBoxes[i], charge)) {
|
|
4354
|
+
if (j <= i)
|
|
4355
|
+
continue;
|
|
4356
|
+
charge();
|
|
4357
|
+
const a = edges2[i], b = edges2[j];
|
|
4358
|
+
const common = [a.a, a.b].filter((v) => v === b.a || v === b.b);
|
|
4359
|
+
if (common.length === 1) {
|
|
4360
|
+
const v = common[0], x = a.a === v ? a.b : a.a, y = b.a === v ? b.b : b.a;
|
|
4361
|
+
if (on(points[v], points[x], points[y]) || on(points[v], points[y], points[x]))
|
|
4362
|
+
throw new Error("Overlapping contour edges");
|
|
4363
|
+
} else if (intersects(points[a.a], points[a.b], points[b.a], points[b.b]))
|
|
4364
|
+
throw new Error("Contour input has crossings or unshared touches");
|
|
4365
|
+
}
|
|
4366
|
+
let rejected = false;
|
|
4367
|
+
const rejectedPaths = /* @__PURE__ */ new Set();
|
|
4368
|
+
for (let p = 0; p < paths.closed.length; p++) {
|
|
4369
|
+
let start = paths.offsets[p];
|
|
4370
|
+
for (let k = candidate.offsets[p] + 1; k < candidate.offsets[p + 1]; k++) {
|
|
4371
|
+
const endId = candidate.sourceVertexIndices[candidate.indices[k]];
|
|
4372
|
+
let end = start + 1;
|
|
4373
|
+
while (paths.indices[end] !== endId)
|
|
4374
|
+
end++;
|
|
4375
|
+
if (end > start + 1) {
|
|
4376
|
+
const a = paths.indices[start], b = paths.indices[end];
|
|
4377
|
+
const pa = points[a], pb = points[b];
|
|
4378
|
+
const axis = pa.x !== pb.x ? "x" : "y";
|
|
4379
|
+
const direction = sign(pb[axis] - pa[axis]);
|
|
4380
|
+
let straight = true;
|
|
4381
|
+
for (let i = start + 1; i <= end; i++) {
|
|
4382
|
+
charge();
|
|
4383
|
+
const q = points[paths.indices[i]], prior = points[paths.indices[i - 1]];
|
|
4384
|
+
if (!on(pa, pb, q) || sign(q[axis] - prior[axis]) !== direction)
|
|
4385
|
+
straight = false;
|
|
4386
|
+
}
|
|
4387
|
+
const interior = new Set(Array.from(paths.indices.subarray(start + 1, end)));
|
|
4388
|
+
let unsafe = false;
|
|
4389
|
+
for (const edgeId of edgeIndex(box(a, b), charge)) {
|
|
4390
|
+
const edge2 = edges2[edgeId];
|
|
4391
|
+
if (edge2.p === p && edge2.i >= start && edge2.i < end) {
|
|
4392
|
+
if (straight)
|
|
4393
|
+
continue;
|
|
4394
|
+
charge();
|
|
4395
|
+
const others2 = [edge2.a, edge2.b].filter((v) => v !== a && v !== b);
|
|
4396
|
+
if (others2.some((v) => on(points[a], points[b], points[v])) || others2.length === 2 && intersects(points[a], points[b], points[edge2.a], points[edge2.b]))
|
|
4397
|
+
unsafe = true;
|
|
4398
|
+
continue;
|
|
4399
|
+
}
|
|
4400
|
+
charge();
|
|
4401
|
+
const others = [edge2.a, edge2.b].filter((v) => v !== a && v !== b);
|
|
4402
|
+
if (others.some((v) => on(points[a], points[b], points[v])) || others.length === 2 && intersects(points[a], points[b], points[edge2.a], points[edge2.b]))
|
|
4403
|
+
unsafe = true;
|
|
4404
|
+
}
|
|
4405
|
+
const swept = { minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity };
|
|
4406
|
+
for (let i = start; i <= end; i++) {
|
|
4407
|
+
const v = paths.indices[i];
|
|
4408
|
+
swept.minX = Math.min(swept.minX, paths.positions[3 * v]);
|
|
4409
|
+
swept.maxX = Math.max(swept.maxX, paths.positions[3 * v]);
|
|
4410
|
+
swept.minY = Math.min(swept.minY, paths.positions[3 * v + 1]);
|
|
4411
|
+
swept.maxY = Math.max(swept.maxY, paths.positions[3 * v + 1]);
|
|
4412
|
+
}
|
|
4413
|
+
for (const vertexId of vertexIndex(swept, charge)) {
|
|
4414
|
+
const vertex = vertexIds[vertexId];
|
|
4415
|
+
if (vertex === a || vertex === b || interior.has(vertex))
|
|
4416
|
+
continue;
|
|
4417
|
+
let inside = false;
|
|
4418
|
+
for (let i = start, j = end; i <= end; j = i++) {
|
|
4419
|
+
charge();
|
|
4420
|
+
const u = points[paths.indices[i]], v = points[paths.indices[j]], q = points[vertex];
|
|
4421
|
+
if (on(u, v, q)) {
|
|
4422
|
+
unsafe = true;
|
|
4423
|
+
break;
|
|
4424
|
+
}
|
|
4425
|
+
if (u.y > q.y !== v.y > q.y && orientation(u, v, q) > 0n === v.y > u.y)
|
|
4426
|
+
inside = !inside;
|
|
4427
|
+
}
|
|
4428
|
+
if (inside)
|
|
4429
|
+
unsafe = true;
|
|
4430
|
+
}
|
|
4431
|
+
if (unsafe) {
|
|
4432
|
+
rejected = true;
|
|
4433
|
+
rejectedPaths.add(p);
|
|
4434
|
+
}
|
|
4435
|
+
}
|
|
4436
|
+
start = end;
|
|
4437
|
+
}
|
|
4438
|
+
}
|
|
4439
|
+
const outputEdges = [];
|
|
4440
|
+
for (let p = 0; p < candidate.closed.length; p++)
|
|
4441
|
+
for (let i = candidate.offsets[p]; i + 1 < candidate.offsets[p + 1]; i++)
|
|
4442
|
+
outputEdges.push({
|
|
4443
|
+
p,
|
|
4444
|
+
a: candidate.sourceVertexIndices[candidate.indices[i]],
|
|
4445
|
+
b: candidate.sourceVertexIndices[candidate.indices[i + 1]]
|
|
4446
|
+
});
|
|
4447
|
+
const outputBoxes = outputEdges.map((e) => box(e.a, e.b)), outputIndex = createTerrainBoxIndex(outputBoxes);
|
|
4448
|
+
for (let i = 0; i < outputEdges.length; i++)
|
|
4449
|
+
for (const j of outputIndex(outputBoxes[i], charge)) {
|
|
4450
|
+
if (j <= i)
|
|
4451
|
+
continue;
|
|
4452
|
+
charge();
|
|
4453
|
+
const a = outputEdges[i], b = outputEdges[j];
|
|
4454
|
+
const common = [a.a, a.b].filter((v) => v === b.a || v === b.b);
|
|
4455
|
+
if (common.length === 1) {
|
|
4456
|
+
const v = common[0], x = a.a === v ? a.b : a.a, y = b.a === v ? b.b : b.a;
|
|
4457
|
+
if (on(points[v], points[x], points[y]) || on(points[v], points[y], points[x])) {
|
|
4458
|
+
rejected = true;
|
|
4459
|
+
rejectedPaths.add(a.p);
|
|
4460
|
+
rejectedPaths.add(b.p);
|
|
4461
|
+
}
|
|
4462
|
+
} else if (intersects(points[a.a], points[a.b], points[b.a], points[b.b])) {
|
|
4463
|
+
rejected = true;
|
|
4464
|
+
rejectedPaths.add(a.p);
|
|
4465
|
+
rejectedPaths.add(b.p);
|
|
4466
|
+
}
|
|
4467
|
+
}
|
|
4468
|
+
if (rejected && options.rejection === "path") {
|
|
4469
|
+
const indices = [], offsets = [0];
|
|
4470
|
+
for (let p = 0; p < paths.closed.length; p++) {
|
|
4471
|
+
if (rejectedPaths.has(p))
|
|
4472
|
+
for (let i = paths.offsets[p]; i < paths.offsets[p + 1]; i++)
|
|
4473
|
+
indices.push(paths.indices[i]);
|
|
4474
|
+
else
|
|
4475
|
+
for (let i = candidate.offsets[p]; i < candidate.offsets[p + 1]; i++)
|
|
4476
|
+
indices.push(candidate.sourceVertexIndices[candidate.indices[i]]);
|
|
4477
|
+
offsets.push(indices.length);
|
|
4478
|
+
}
|
|
4479
|
+
return {
|
|
4480
|
+
...paths,
|
|
4481
|
+
positions: paths.positions.slice(),
|
|
4482
|
+
gridCoordinates: paths.gridCoordinates.slice(),
|
|
4483
|
+
indices: Uint32Array.from(indices),
|
|
4484
|
+
offsets: Uint32Array.from(offsets),
|
|
4485
|
+
closed: paths.closed.slice(),
|
|
4486
|
+
levelIndices: paths.levelIndices.slice(),
|
|
4487
|
+
levels: paths.levels.slice(),
|
|
4488
|
+
origin: Object.freeze([...paths.origin]),
|
|
4489
|
+
sourceVertexIndices: Uint32Array.from({ length: points.length }, (_, i) => i),
|
|
4490
|
+
maxDeviation: candidate.maxDeviation,
|
|
4491
|
+
requestedMaxError: options.maxError,
|
|
4492
|
+
distanceTests: candidate.distanceTests,
|
|
4493
|
+
topologyTests,
|
|
4494
|
+
rejected: true
|
|
4495
|
+
};
|
|
4496
|
+
}
|
|
4497
|
+
if (!rejected)
|
|
4498
|
+
return { ...candidate, topologyTests, rejected: false };
|
|
4499
|
+
return {
|
|
4500
|
+
...paths,
|
|
4501
|
+
positions: paths.positions.slice(),
|
|
4502
|
+
gridCoordinates: paths.gridCoordinates.slice(),
|
|
4503
|
+
indices: paths.indices.slice(),
|
|
4504
|
+
offsets: paths.offsets.slice(),
|
|
4505
|
+
levelIndices: paths.levelIndices.slice(),
|
|
4506
|
+
closed: paths.closed.slice(),
|
|
4507
|
+
levels: paths.levels.slice(),
|
|
4508
|
+
origin: Object.freeze([...paths.origin]),
|
|
4509
|
+
sourceVertexIndices: Uint32Array.from({ length: points.length }, (_, i) => i),
|
|
4510
|
+
maxDeviation: 0,
|
|
4511
|
+
requestedMaxError: options.maxError,
|
|
4512
|
+
distanceTests: candidate.distanceTests,
|
|
4513
|
+
topologyTests,
|
|
4514
|
+
rejected: true
|
|
4515
|
+
};
|
|
4516
|
+
}
|
|
4517
|
+
|
|
4518
|
+
// dist/terrain/isobands.js
|
|
4519
|
+
function createTerrainIsobands(fields, levels, options = {}) {
|
|
4520
|
+
const maxLevels = options.maxLevels ?? 256;
|
|
4521
|
+
if (!Number.isSafeInteger(maxLevels) || maxLevels < 2 || levels.length > maxLevels)
|
|
4522
|
+
throw new Error("Isoband level capacity exceeded");
|
|
4523
|
+
if (levels.length < 2 || levels.some((v, i) => !Number.isFinite(v) || i > 0 && v <= levels[i - 1]))
|
|
4524
|
+
throw new Error("Invalid isoband levels");
|
|
4525
|
+
const maxTriangles = options.maxTriangles ?? 2e6, maxVertices = options.maxVertices ?? 2e6, maxEdges = options.maxEdges ?? 6 * maxTriangles, maxTests = options.maxTests ?? 32 * maxTriangles;
|
|
4526
|
+
if (![maxTriangles, maxVertices, maxEdges, maxTests].every((n) => Number.isSafeInteger(n) && n >= 0))
|
|
4527
|
+
throw new Error("Invalid isoband capacity");
|
|
4528
|
+
const count = fields.reduce((n, f) => n + 2 * (f.width - 1) * (f.height - 1), 0);
|
|
4529
|
+
if (!Number.isSafeInteger(count) || count > maxTriangles)
|
|
4530
|
+
throw new Error("Isoband triangle capacity exceeded");
|
|
4531
|
+
const originals = /* @__PURE__ */ new Map(), vertices = /* @__PURE__ */ new Map();
|
|
4532
|
+
const frame = fields[0];
|
|
4533
|
+
for (const f of fields)
|
|
4534
|
+
if (f.heightReference !== frame.heightReference)
|
|
4535
|
+
throw new Error("Isoband height references differ");
|
|
4536
|
+
let tests = 0, edgeCount = 0;
|
|
4537
|
+
const charge = () => {
|
|
4538
|
+
if (++tests > maxTests)
|
|
4539
|
+
throw new Error("Isoband work budget exceeded");
|
|
4540
|
+
};
|
|
4541
|
+
const rectangles = fields.map((f) => {
|
|
4542
|
+
if (f.registration !== frame.registration || f.columnStep.some((v, i) => v !== frame.columnStep[i]) || f.rowStep.some((v, i) => v !== frame.rowStep[i]))
|
|
4543
|
+
throw new Error("Isoband tiles require a conforming common frame");
|
|
4544
|
+
const dx = f.origin[0] - frame.origin[0], dy = f.origin[1] - frame.origin[1];
|
|
4545
|
+
const determinant = frame.columnStep[0] * frame.rowStep[1] - frame.columnStep[1] * frame.rowStep[0];
|
|
4546
|
+
const x = Math.round((dx * frame.rowStep[1] - dy * frame.rowStep[0]) / determinant), y = Math.round((dy * frame.columnStep[0] - dx * frame.columnStep[1]) / determinant);
|
|
4547
|
+
if (!Number.isSafeInteger(x) || !Number.isSafeInteger(y))
|
|
4548
|
+
throw new Error("Isoband tiles require integral lattice origins");
|
|
4549
|
+
for (let axis = 0; axis < 2; axis++) {
|
|
4550
|
+
const a = x * frame.columnStep[axis], b = y * frame.rowStep[axis];
|
|
4551
|
+
const expected = frame.origin[axis] + a + b;
|
|
4552
|
+
const tolerance = Math.min(16 * Number.EPSILON * Math.max(1, Math.abs(f.origin[axis]), Math.abs(frame.origin[axis]), Math.abs(a), Math.abs(b)), 1e-9 * Math.max(Math.abs(frame.columnStep[axis]), Math.abs(frame.rowStep[axis])));
|
|
4553
|
+
if (!Number.isFinite(expected) || Math.abs(f.origin[axis] - expected) > tolerance)
|
|
4554
|
+
throw new Error("Isoband tiles require integral lattice origins");
|
|
4555
|
+
}
|
|
4556
|
+
return { x, y, right: x + f.width - 1, top: y + f.height - 1 };
|
|
4557
|
+
});
|
|
4558
|
+
const rectangleBoxes = rectangles.map((r) => ({ minX: r.x, minY: r.y, maxX: r.right, maxY: r.top })), rectangleIndex = createTerrainBoxIndex(rectangleBoxes);
|
|
4559
|
+
const rangeIndex = createTerrainBoxIndex(fields.map((f) => {
|
|
4560
|
+
var _a, _b;
|
|
4561
|
+
return {
|
|
4562
|
+
minX: ((_a = f.heightRange) == null ? void 0 : _a[0]) ?? Infinity,
|
|
4563
|
+
maxX: ((_b = f.heightRange) == null ? void 0 : _b[1]) ?? -Infinity,
|
|
4564
|
+
minY: 0,
|
|
4565
|
+
maxY: 0
|
|
4566
|
+
};
|
|
4567
|
+
}));
|
|
4568
|
+
for (let i = 0; i < rectangles.length; i++)
|
|
4569
|
+
for (const j of rectangleIndex(rectangleBoxes[i], charge)) {
|
|
4570
|
+
if (j <= i)
|
|
4571
|
+
continue;
|
|
4572
|
+
charge();
|
|
4573
|
+
const a = rectangles[i], b = rectangles[j];
|
|
4574
|
+
if (a.x < b.right && b.x < a.right && a.y < b.top && b.y < a.top)
|
|
4575
|
+
throw new Error("Overlapping isoband tiles");
|
|
4576
|
+
for (let y = Math.max(a.y, b.y); y <= Math.min(a.top, b.top); y++)
|
|
4577
|
+
for (let x = Math.max(a.x, b.x); x <= Math.min(a.right, b.right); x++) {
|
|
4578
|
+
charge();
|
|
4579
|
+
const u = fields[i].getHeight(x - a.x, y - a.y), v = fields[j].getHeight(x - b.x, y - b.y);
|
|
4580
|
+
if (u !== void 0 && v !== void 0 && u !== v)
|
|
4581
|
+
throw new Error("Isoband shared heights differ");
|
|
4582
|
+
}
|
|
4583
|
+
}
|
|
4584
|
+
const rings = [], bands = [];
|
|
4585
|
+
const register = (v) => {
|
|
4586
|
+
if (!vertices.has(v.key)) {
|
|
4587
|
+
if (vertices.size >= maxVertices)
|
|
4588
|
+
throw new Error("Isoband vertex capacity exceeded");
|
|
4589
|
+
vertices.set(v.key, v);
|
|
4590
|
+
}
|
|
4591
|
+
return vertices.get(v.key);
|
|
4592
|
+
};
|
|
4593
|
+
const clip = (poly, level, above) => {
|
|
4594
|
+
const out = [];
|
|
4595
|
+
for (let i = 0; i < poly.length; i++) {
|
|
4596
|
+
charge();
|
|
4597
|
+
const a = poly[i], b = poly[(i + 1) % poly.length], ia = above ? a.z >= level : a.z <= level, ib = above ? b.z >= level : b.z <= level;
|
|
4598
|
+
if (ia)
|
|
4599
|
+
out.push(a);
|
|
4600
|
+
if (ia !== ib) {
|
|
4601
|
+
if (a.z === level) {
|
|
4602
|
+
out.push(a);
|
|
4603
|
+
continue;
|
|
4604
|
+
}
|
|
4605
|
+
if (b.z === level) {
|
|
4606
|
+
out.push(b);
|
|
4607
|
+
continue;
|
|
4608
|
+
}
|
|
4609
|
+
const support = [.../* @__PURE__ */ new Set([...a.support, ...b.support])].sort();
|
|
4610
|
+
if (support.length !== 2)
|
|
4611
|
+
throw new Error("Invalid isoband intersection support");
|
|
4612
|
+
const u = originals.get(support[0]), v = originals.get(support[1]);
|
|
4613
|
+
const scale = Math.max(Math.abs(u.z), Math.abs(v.z), Math.abs(level), 1);
|
|
4614
|
+
const t = (level / scale - u.z / scale) / (v.z / scale - u.z / scale);
|
|
4615
|
+
const point = {
|
|
4616
|
+
x: u.x * (1 - t) + v.x * t,
|
|
4617
|
+
y: u.y * (1 - t) + v.y * t,
|
|
4618
|
+
z: level,
|
|
4619
|
+
key: `e:${support.join("|")}:${level}`,
|
|
4620
|
+
support
|
|
4621
|
+
};
|
|
4622
|
+
if (![point.x, point.y, t].every(Number.isFinite))
|
|
4623
|
+
throw new Error("Isoband arithmetic overflow");
|
|
4624
|
+
out.push(register(point));
|
|
4625
|
+
}
|
|
4626
|
+
}
|
|
4627
|
+
return out.filter((v, i) => v.key !== out[(i + 1) % out.length].key);
|
|
4628
|
+
};
|
|
4629
|
+
for (let band = 0; band + 1 < levels.length; band++) {
|
|
4630
|
+
const edges2 = /* @__PURE__ */ new Map();
|
|
4631
|
+
for (const fieldId of rangeIndex({ minX: levels[band], maxX: levels[band + 1], minY: 0, maxY: 0 }, charge))
|
|
4632
|
+
for (let y = 0; y < fields[fieldId].height - 1; y++)
|
|
4633
|
+
for (let x = 0; x < fields[fieldId].width - 1; x++) {
|
|
4634
|
+
const f = fields[fieldId];
|
|
4635
|
+
const nodes = [
|
|
4636
|
+
[x, y],
|
|
4637
|
+
[x + 1, y],
|
|
4638
|
+
[x, y + 1],
|
|
4639
|
+
[x + 1, y + 1]
|
|
4640
|
+
].map(([c, r]) => {
|
|
4641
|
+
const z = f.getHeight(c, r);
|
|
4642
|
+
if (z === void 0)
|
|
4643
|
+
return void 0;
|
|
4644
|
+
const shift = f.registration === "cell" ? 0.5 : 0;
|
|
4645
|
+
const px = frame.origin[0] + (rectangles[fieldId].x + c + shift) * frame.columnStep[0] + (rectangles[fieldId].y + r + shift) * frame.rowStep[0], py = frame.origin[1] + (rectangles[fieldId].x + c + shift) * frame.columnStep[1] + (rectangles[fieldId].y + r + shift) * frame.rowStep[1];
|
|
4646
|
+
if (![px, py].every(Number.isFinite))
|
|
4647
|
+
throw new Error("Isoband coordinate overflow");
|
|
4648
|
+
const key2 = `v:${px},${py}`, v = { x: px, y: py, z, key: key2, support: [key2] };
|
|
4649
|
+
const old = originals.get(key2);
|
|
4650
|
+
if (old && old.z !== z)
|
|
4651
|
+
throw new Error("Isoband shared heights differ");
|
|
4652
|
+
originals.set(key2, v);
|
|
4653
|
+
return v;
|
|
4654
|
+
});
|
|
4655
|
+
for (const ids of f.diagonal === "00-11" ? [
|
|
4656
|
+
[0, 1, 3],
|
|
4657
|
+
[0, 3, 2]
|
|
4658
|
+
] : [
|
|
4659
|
+
[0, 1, 2],
|
|
4660
|
+
[1, 3, 2]
|
|
4661
|
+
]) {
|
|
4662
|
+
charge();
|
|
4663
|
+
if (ids.some((i) => !nodes[i]))
|
|
4664
|
+
continue;
|
|
4665
|
+
let poly = ids.map((i) => nodes[i]);
|
|
4666
|
+
if (poly.every((v) => v.z === levels[band + 1]) && band + 2 < levels.length)
|
|
4667
|
+
continue;
|
|
4668
|
+
if ((poly[1].x - poly[0].x) * (poly[2].y - poly[0].y) - (poly[1].y - poly[0].y) * (poly[2].x - poly[0].x) < 0)
|
|
4669
|
+
poly.reverse();
|
|
4670
|
+
poly = clip(clip(poly, levels[band], true), levels[band + 1], false);
|
|
4671
|
+
if (poly.length < 3)
|
|
4672
|
+
continue;
|
|
4673
|
+
const area2 = poly.reduce((n, a, i) => {
|
|
4674
|
+
const b = poly[(i + 1) % poly.length], o = poly[0];
|
|
4675
|
+
return n + (a.x - o.x) * (b.y - o.y) - (b.x - o.x) * (a.y - o.y);
|
|
4676
|
+
}, 0);
|
|
4677
|
+
if (!Number.isFinite(area2))
|
|
4678
|
+
throw new Error("Isoband area arithmetic overflow");
|
|
4679
|
+
if (area2 === 0)
|
|
4680
|
+
continue;
|
|
4681
|
+
for (let i = 0; i < poly.length; i++) {
|
|
4682
|
+
const a = register(poly[i]), b = register(poly[(i + 1) % poly.length]);
|
|
4683
|
+
if (++edgeCount > maxEdges)
|
|
4684
|
+
throw new Error("Isoband edge capacity exceeded");
|
|
4685
|
+
const key2 = `${a.key}>${b.key}`, reverse = `${b.key}>${a.key}`;
|
|
4686
|
+
if (edges2.has(reverse))
|
|
4687
|
+
edges2.delete(reverse);
|
|
4688
|
+
else {
|
|
4689
|
+
if (edges2.has(key2))
|
|
4690
|
+
throw new Error("Overlapping isoband tiles");
|
|
4691
|
+
edges2.set(key2, { a, b });
|
|
4692
|
+
}
|
|
4693
|
+
}
|
|
4694
|
+
}
|
|
4695
|
+
}
|
|
4696
|
+
const outgoing = /* @__PURE__ */ new Map();
|
|
4697
|
+
for (const [key2, e] of edges2) {
|
|
4698
|
+
if (!outgoing.has(e.a.key))
|
|
4699
|
+
outgoing.set(e.a.key, /* @__PURE__ */ new Set());
|
|
4700
|
+
outgoing.get(e.a.key).add(key2);
|
|
4701
|
+
}
|
|
4702
|
+
while (edges2.size) {
|
|
4703
|
+
const first = edges2.values().next().value, ring = [];
|
|
4704
|
+
let edge2 = first;
|
|
4705
|
+
for (; ; ) {
|
|
4706
|
+
charge();
|
|
4707
|
+
ring.push(edge2.a);
|
|
4708
|
+
edges2.delete(`${edge2.a.key}>${edge2.b.key}`);
|
|
4709
|
+
outgoing.get(edge2.a.key).delete(`${edge2.a.key}>${edge2.b.key}`);
|
|
4710
|
+
if (edge2.b.key === first.a.key)
|
|
4711
|
+
break;
|
|
4712
|
+
const choices = [...outgoing.get(edge2.b.key) ?? []].map((k) => edges2.get(k));
|
|
4713
|
+
if (!choices.length)
|
|
4714
|
+
throw new Error("Open isoband boundary");
|
|
4715
|
+
const angle = (e) => Math.atan2((edge2.b.x - edge2.a.x) * (e.b.y - e.a.y) - (edge2.b.y - edge2.a.y) * (e.b.x - e.a.x), (edge2.b.x - edge2.a.x) * (e.b.x - e.a.x) + (edge2.b.y - edge2.a.y) * (e.b.y - e.a.y));
|
|
4716
|
+
choices.sort((a, b) => angle(b) - angle(a) || a.b.key.localeCompare(b.b.key));
|
|
4717
|
+
edge2 = choices[0];
|
|
4718
|
+
}
|
|
4719
|
+
rings.push(ring);
|
|
4720
|
+
bands.push(band);
|
|
4721
|
+
}
|
|
4722
|
+
}
|
|
4723
|
+
const area = (ring) => ring.reduce((n, a, i) => {
|
|
4724
|
+
const b = ring[(i + 1) % ring.length], o = ring[0];
|
|
4725
|
+
return n + (a.x - o.x) * (b.y - o.y) - (b.x - o.x) * (a.y - o.y);
|
|
4726
|
+
}, 0);
|
|
4727
|
+
const areas = rings.map(area), parents = new Int32Array(rings.length).fill(-1);
|
|
4728
|
+
const ringBoxes = rings.map((r) => r.reduce((b, v) => ({
|
|
4729
|
+
minX: Math.min(b.minX, v.x),
|
|
4730
|
+
minY: Math.min(b.minY, v.y),
|
|
4731
|
+
maxX: Math.max(b.maxX, v.x),
|
|
4732
|
+
maxY: Math.max(b.maxY, v.y)
|
|
4733
|
+
}), { minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity }));
|
|
4734
|
+
const ringIndex = createTerrainBoxIndex(ringBoxes);
|
|
4735
|
+
for (let i = 0; i < rings.length; i++)
|
|
4736
|
+
if (areas[i] < 0) {
|
|
4737
|
+
let best = Infinity;
|
|
4738
|
+
const q = rings[i][0];
|
|
4739
|
+
for (const j of ringIndex({ minX: q.x, maxX: q.x, minY: q.y, maxY: q.y }, charge))
|
|
4740
|
+
if (bands[j] === bands[i] && areas[j] > 0) {
|
|
4741
|
+
let inside = false;
|
|
4742
|
+
const ring = rings[j];
|
|
4743
|
+
for (let k = 0, l = ring.length - 1; k < ring.length; l = k++) {
|
|
4744
|
+
charge();
|
|
4745
|
+
const a = ring[k], b = ring[l];
|
|
4746
|
+
if (a.y > q.y !== b.y > q.y && q.x < (b.x - a.x) * (q.y - a.y) / (b.y - a.y) + a.x)
|
|
4747
|
+
inside = !inside;
|
|
4748
|
+
}
|
|
4749
|
+
if (inside && areas[j] < best) {
|
|
4750
|
+
parents[i] = j;
|
|
4751
|
+
best = areas[j];
|
|
4752
|
+
}
|
|
4753
|
+
}
|
|
4754
|
+
if (parents[i] < 0)
|
|
4755
|
+
throw new Error("Uncontained isoband hole");
|
|
4756
|
+
}
|
|
4757
|
+
const used = /* @__PURE__ */ new Map(), positions = [], indices = [], offsets = [0];
|
|
4758
|
+
for (const ring of rings) {
|
|
4759
|
+
for (const v of [...ring, ring[0]]) {
|
|
4760
|
+
if (!used.has(v.key)) {
|
|
4761
|
+
used.set(v.key, used.size);
|
|
4762
|
+
positions.push(v.x, v.y);
|
|
4763
|
+
}
|
|
4764
|
+
indices.push(used.get(v.key));
|
|
4765
|
+
}
|
|
4766
|
+
offsets.push(indices.length);
|
|
4767
|
+
}
|
|
4768
|
+
return {
|
|
4769
|
+
positions: Float64Array.from(positions),
|
|
4770
|
+
indices: Uint32Array.from(indices),
|
|
4771
|
+
offsets: Uint32Array.from(offsets),
|
|
4772
|
+
bandIndices: Uint32Array.from(bands),
|
|
4773
|
+
parents,
|
|
4774
|
+
levels: Float64Array.from(levels),
|
|
4775
|
+
heightReference: (frame == null ? void 0 : frame.heightReference) ?? "unknown"
|
|
4776
|
+
};
|
|
4777
|
+
}
|
|
4778
|
+
|
|
4779
|
+
// dist/terrain/tile-update-data.js
|
|
4780
|
+
function updateTerrainTileData(previous, resident, create, maxSamples = 4e6) {
|
|
4781
|
+
if (!Number.isSafeInteger(maxSamples) || maxSamples < 0)
|
|
4782
|
+
throw new Error("Invalid terrain update sample capacity");
|
|
4783
|
+
let count = 0;
|
|
4784
|
+
const ids = /* @__PURE__ */ new Set();
|
|
4785
|
+
for (const tile of resident) {
|
|
4786
|
+
if (typeof tile.id !== "string" || ids.has(tile.id))
|
|
4787
|
+
throw new Error("Invalid or duplicate terrain update tile");
|
|
4788
|
+
ids.add(tile.id);
|
|
4789
|
+
count += tile.field.width * tile.field.height;
|
|
4790
|
+
if (!Number.isSafeInteger(count) || count > maxSamples)
|
|
4791
|
+
throw new Error("Terrain update sample capacity exceeded");
|
|
4792
|
+
}
|
|
4793
|
+
const cached = new Map(previous == null ? void 0 : previous.map((t) => [t.source.id, t]));
|
|
4794
|
+
return resident.map((source) => {
|
|
4795
|
+
const old = cached.get(source.id);
|
|
4796
|
+
return (old == null ? void 0 : old.source.field) === source.field ? { source, data: old.data } : { source, data: create(source.field) };
|
|
4797
|
+
});
|
|
4798
|
+
}
|
|
4799
|
+
|
|
4800
|
+
// dist/terrain/mesh-update.js
|
|
4801
|
+
function updateTerrainMeshes(previous, resident, options = {}) {
|
|
4802
|
+
return updateTerrainTileData(previous, resident, createTerrainMesh, options.maxSamples);
|
|
4803
|
+
}
|
|
4804
|
+
|
|
4805
|
+
// dist/terrain/bounds-update.js
|
|
4806
|
+
function updateTerrainBounds(previous, resident, options = {}) {
|
|
4807
|
+
return updateTerrainTileData(previous, resident, (f) => new HeightFieldMinMax(f), options.maxSamples);
|
|
4808
|
+
}
|
|
4809
|
+
|
|
4810
|
+
// dist/terrain/gradient-pyramid-update.js
|
|
4811
|
+
function updateTerrainGradientPyramids(previous, gradients, options = {}) {
|
|
4812
|
+
const limit = options.maxSamples ?? 4e6;
|
|
4813
|
+
const count = gradients.tiles.reduce((n, t) => n + t.grid.width * t.grid.height, 0);
|
|
4814
|
+
if (!Number.isSafeInteger(limit) || limit < 0 || !Number.isSafeInteger(count) || count > limit)
|
|
4815
|
+
throw new Error("Gradient pyramid update sample capacity exceeded");
|
|
4816
|
+
const cached = new Map(previous == null ? void 0 : previous.map((t) => [t.source.grid, t.data]));
|
|
4817
|
+
return gradients.tiles.map((source) => ({
|
|
4818
|
+
source,
|
|
4819
|
+
data: cached.get(source.grid) ?? createTerrainGradientPyramid(source.grid, { maxSamples: limit })
|
|
4820
|
+
}));
|
|
4821
|
+
}
|
|
4822
|
+
|
|
4823
|
+
// dist/terrain/dirty-regions.js
|
|
4824
|
+
function validateTerrainDirtyWindows(windows, width, height, maxWindows = 1e5) {
|
|
4825
|
+
if (windows.length > maxWindows)
|
|
4826
|
+
throw new Error("Terrain dirty window capacity exceeded");
|
|
4827
|
+
for (const w of windows)
|
|
4828
|
+
if (![w.minColumn, w.minRow, w.maxColumn, w.maxRow].every(Number.isSafeInteger) || w.minColumn < 0 || w.minRow < 0 || w.maxColumn >= width || w.maxRow >= height || w.minColumn > w.maxColumn || w.minRow > w.maxRow)
|
|
4829
|
+
throw new Error("Invalid terrain dirty sample window");
|
|
4830
|
+
}
|
|
4831
|
+
function sameTerrainFrame(a, b) {
|
|
4832
|
+
return a.width === b.width && a.height === b.height && a.registration === b.registration && a.diagonal === b.diagonal && a.heightReference === b.heightReference && a.origin.every((v, i) => v === b.origin[i]) && a.columnStep.every((v, i) => v === b.columnStep[i]) && a.rowStep.every((v, i) => v === b.rowStep[i]);
|
|
4833
|
+
}
|
|
4834
|
+
function terrainDirtyIndices(windows, width, height, expand, charge) {
|
|
4835
|
+
const ids = /* @__PURE__ */ new Set();
|
|
4836
|
+
for (const w of windows)
|
|
4837
|
+
for (let y = Math.max(0, w.minRow - expand); y <= Math.min(height - 1, w.maxRow + expand); y++)
|
|
4838
|
+
for (let x = Math.max(0, w.minColumn - expand); x <= Math.min(width - 1, w.maxColumn + expand); x++) {
|
|
4839
|
+
charge();
|
|
4840
|
+
ids.add(y * width + x);
|
|
4841
|
+
}
|
|
4842
|
+
return ids;
|
|
4843
|
+
}
|
|
4844
|
+
|
|
4845
|
+
// dist/terrain/mesh-regions-data.js
|
|
4846
|
+
function updateMeshRegions(previous, field, dirty, options, configuration, create) {
|
|
4847
|
+
const cells = options.cellsPerRegion ?? 32, limit = options.maxSamples ?? 4e6, budget = options.maxTests ?? 1e7;
|
|
4848
|
+
if (![cells, limit, budget].every(Number.isSafeInteger) || cells < 1 || limit < 0 || budget < 0)
|
|
4849
|
+
throw new Error("Invalid terrain mesh region capacity");
|
|
4850
|
+
validateTerrainDirtyWindows(dirty, field.width, field.height);
|
|
4851
|
+
let count = 0, tests = 0;
|
|
4852
|
+
const regions = [], rebuilt = [];
|
|
4853
|
+
const reusable = previous && sameTerrainFrame(previous.field, field) && previous.cellsPerRegion === cells && previous.configuration === configuration;
|
|
4854
|
+
const affectedRegions = /* @__PURE__ */ new Set();
|
|
4855
|
+
const columns = Math.ceil((field.width - 1) / cells);
|
|
4856
|
+
const rows = Math.ceil((field.height - 1) / cells);
|
|
4857
|
+
if (reusable) {
|
|
4858
|
+
for (const window of dirty) {
|
|
4859
|
+
const firstColumn = Math.max(0, Math.ceil(window.minColumn / cells) - 1);
|
|
4860
|
+
const firstRow = Math.max(0, Math.ceil(window.minRow / cells) - 1);
|
|
4861
|
+
const lastColumn = Math.min(columns - 1, Math.floor(window.maxColumn / cells));
|
|
4862
|
+
const lastRow = Math.min(rows - 1, Math.floor(window.maxRow / cells));
|
|
4863
|
+
for (let y = firstRow; y <= lastRow; y++) {
|
|
4864
|
+
for (let x = firstColumn; x <= lastColumn; x++) {
|
|
4865
|
+
if (++tests > budget)
|
|
4866
|
+
throw new Error("Terrain mesh region work budget exceeded");
|
|
4867
|
+
affectedRegions.add(y * columns + x);
|
|
4868
|
+
}
|
|
4869
|
+
}
|
|
4870
|
+
}
|
|
4871
|
+
}
|
|
4872
|
+
const cache = new Map(previous == null ? void 0 : previous.regions.map((r) => [`${r.column},${r.row}`, r]));
|
|
4873
|
+
for (let row = 0; row < field.height - 1; row += cells)
|
|
4874
|
+
for (let column = 0; column < field.width - 1; column += cells) {
|
|
4875
|
+
const width = Math.min(cells, field.width - 1 - column) + 1, height = Math.min(cells, field.height - 1 - row) + 1;
|
|
4876
|
+
count += width * height;
|
|
4877
|
+
if (!Number.isSafeInteger(count) || count > limit)
|
|
4878
|
+
throw new Error("Terrain mesh region sample capacity exceeded");
|
|
4879
|
+
const affected = !reusable || affectedRegions.has(row / cells * columns + column / cells);
|
|
4880
|
+
const old = cache.get(`${column},${row}`);
|
|
4881
|
+
if (!affected && old) {
|
|
4882
|
+
regions.push(old);
|
|
4883
|
+
continue;
|
|
4884
|
+
}
|
|
4885
|
+
const heights = Float64Array.from({ length: width * height }, (_, i) => field.getHeight(column + i % width, row + Math.floor(i / width)) ?? NaN);
|
|
4886
|
+
const source = new HeightField({
|
|
4887
|
+
width,
|
|
4888
|
+
height,
|
|
4889
|
+
heights,
|
|
4890
|
+
origin: [
|
|
4891
|
+
column * field.columnStep[0] + row * field.rowStep[0],
|
|
4892
|
+
column * field.columnStep[1] + row * field.rowStep[1]
|
|
4893
|
+
],
|
|
4894
|
+
columnStep: field.columnStep,
|
|
4895
|
+
rowStep: field.rowStep,
|
|
4896
|
+
registration: field.registration,
|
|
4897
|
+
diagonal: field.diagonal,
|
|
4898
|
+
heightReference: field.heightReference
|
|
4899
|
+
});
|
|
4900
|
+
rebuilt.push(regions.length);
|
|
4901
|
+
let data = create(source);
|
|
4902
|
+
if (data) {
|
|
4903
|
+
const mesh = data;
|
|
4904
|
+
const positions = mesh.positions.map((value, i) => {
|
|
4905
|
+
const axis = i % 3;
|
|
4906
|
+
if (axis === 2)
|
|
4907
|
+
return value;
|
|
4908
|
+
const vertex = Math.floor(i / 3), shift = field.registration === "cell" ? 0.5 : 0;
|
|
4909
|
+
const c = column + mesh.gridCoordinates[2 * vertex] + shift, r = row + mesh.gridCoordinates[2 * vertex + 1] + shift;
|
|
4910
|
+
const coordinate = c * field.columnStep[axis] + r * field.rowStep[axis];
|
|
4911
|
+
if (!Number.isFinite(coordinate))
|
|
4912
|
+
throw new Error("Terrain region coordinate overflow");
|
|
4913
|
+
return coordinate;
|
|
4914
|
+
});
|
|
4915
|
+
data = { ...mesh, origin: [0, 0, 0], positions };
|
|
4916
|
+
}
|
|
4917
|
+
regions.push({ column, row, field: source, data });
|
|
4918
|
+
}
|
|
4919
|
+
return {
|
|
4920
|
+
field,
|
|
4921
|
+
origin: [field.origin[0], field.origin[1], 0],
|
|
4922
|
+
cellsPerRegion: cells,
|
|
4923
|
+
configuration,
|
|
4924
|
+
regions,
|
|
4925
|
+
rebuilt: Uint32Array.from(rebuilt)
|
|
4926
|
+
};
|
|
4927
|
+
}
|
|
4928
|
+
|
|
4929
|
+
// dist/terrain/mesh-regions.js
|
|
4930
|
+
function updateTerrainMeshRegions(previous, field, dirty, options = {}) {
|
|
4931
|
+
return updateMeshRegions(previous, field, dirty, options, "regular", createTerrainMesh);
|
|
4932
|
+
}
|
|
4933
|
+
|
|
4934
|
+
// dist/terrain/martini-regions.js
|
|
4935
|
+
function updateTerrainMartiniMeshRegions(previous, field, dirty, options) {
|
|
4936
|
+
const cells = options.cellsPerRegion ?? 32;
|
|
4937
|
+
if (!Number.isSafeInteger(cells) || cells < 1 || cells > 32768 || (cells & cells - 1) !== 0 || (field.width - 1) % cells || (field.height - 1) % cells || !Number.isFinite(options.maxError) || options.maxError < 0)
|
|
4938
|
+
throw new Error("Invalid MARTINI region dimensions or error");
|
|
4939
|
+
return updateMeshRegions(previous, field, dirty, options, `martini:${options.maxError}`, (f) => f.validCount !== f.width * f.height ? null : createMartiniTerrainMesh(f, {
|
|
4940
|
+
maxError: options.maxError,
|
|
4941
|
+
fullEdges: ["minColumn", "maxColumn", "minRow", "maxRow"]
|
|
4942
|
+
}));
|
|
4943
|
+
}
|
|
4944
|
+
|
|
4945
|
+
// dist/terrain/delatin-regions.js
|
|
4946
|
+
function updateTerrainDelatinMeshRegions(previous, field, dirty, options) {
|
|
4947
|
+
if (!Number.isFinite(options.maxError) || options.maxError < 0)
|
|
4948
|
+
throw new Error("Invalid Delatin region error");
|
|
4949
|
+
return updateMeshRegions(previous, field, dirty, options, `delatin:${options.maxError}`, (f) => f.validCount !== f.width * f.height ? null : createDelatinTerrainMesh(f, { maxError: options.maxError }));
|
|
4950
|
+
}
|
|
4951
|
+
|
|
4952
|
+
// dist/terrain/bounds-regions.js
|
|
4953
|
+
function updateTerrainBoundsRegions(previous, field, dirty, options = {}) {
|
|
4954
|
+
const limit = options.maxSamples ?? 4e6, budget = options.maxTests ?? 1e7;
|
|
4955
|
+
if (![limit, budget].every(Number.isSafeInteger) || limit < 0 || budget < 0 || field.width * field.height > limit)
|
|
4956
|
+
throw new Error("Invalid bounds region capacity");
|
|
4957
|
+
validateTerrainDirtyWindows(dirty, field.width, field.height);
|
|
4958
|
+
if (!previous || !sameTerrainFrame(previous.field, field)) {
|
|
4959
|
+
const bounds2 = new HeightFieldMinMax(field), levels2 = Array.from({ length: bounds2.levelCount }, (_, i) => bounds2.copyLevel(i));
|
|
4960
|
+
return { field, levels: levels2, updatedCounts: Uint32Array.from(levels2, (l) => l.width * l.height) };
|
|
4961
|
+
}
|
|
4962
|
+
let tests = 0;
|
|
4963
|
+
const charge = () => {
|
|
4964
|
+
if (++tests > budget)
|
|
4965
|
+
throw new Error("Bounds region work budget exceeded");
|
|
4966
|
+
};
|
|
4967
|
+
let ids = terrainDirtyIndices(dirty, field.width - 1, field.height - 1, 1, charge);
|
|
4968
|
+
const counts = [], levels = previous.levels.slice();
|
|
4969
|
+
for (let l = 0; l < levels.length; l++) {
|
|
4970
|
+
counts.push(ids.size);
|
|
4971
|
+
if (!ids.size)
|
|
4972
|
+
continue;
|
|
4973
|
+
const old = levels[l], next = {
|
|
4974
|
+
...old,
|
|
4975
|
+
minimums: old.minimums.slice(),
|
|
4976
|
+
maximums: old.maximums.slice(),
|
|
4977
|
+
populatedCellCounts: old.populatedCellCounts.slice(),
|
|
4978
|
+
completeCellCounts: old.completeCellCounts.slice()
|
|
4979
|
+
};
|
|
4980
|
+
const parents = /* @__PURE__ */ new Set();
|
|
4981
|
+
for (const id of ids) {
|
|
4982
|
+
charge();
|
|
4983
|
+
const x = id % next.width, y = Math.floor(id / next.width);
|
|
4984
|
+
let min = Infinity, max = -Infinity, populated = 0, complete = 0;
|
|
4985
|
+
if (l === 0) {
|
|
4986
|
+
let valid = 0;
|
|
4987
|
+
for (let dy = 0; dy < 2; dy++)
|
|
4988
|
+
for (let dx = 0; dx < 2; dx++) {
|
|
4989
|
+
const h = field.getHeight(x + dx, y + dy);
|
|
4990
|
+
if (h !== void 0) {
|
|
4991
|
+
valid++;
|
|
4992
|
+
min = Math.min(min, h);
|
|
4993
|
+
max = Math.max(max, h);
|
|
4994
|
+
}
|
|
4995
|
+
}
|
|
4996
|
+
populated = valid ? 1 : 0;
|
|
4997
|
+
complete = valid === 4 ? 1 : 0;
|
|
4998
|
+
} else {
|
|
4999
|
+
const child = levels[l - 1];
|
|
5000
|
+
for (let dy = 0; dy < 2; dy++)
|
|
5001
|
+
for (let dx = 0; dx < 2; dx++) {
|
|
5002
|
+
const cx = x * 2 + dx, cy = y * 2 + dy;
|
|
5003
|
+
if (cx >= child.width || cy >= child.height)
|
|
5004
|
+
continue;
|
|
5005
|
+
const i = cy * child.width + cx;
|
|
5006
|
+
if (child.populatedCellCounts[i]) {
|
|
5007
|
+
min = Math.min(min, child.minimums[i]);
|
|
5008
|
+
max = Math.max(max, child.maximums[i]);
|
|
5009
|
+
}
|
|
5010
|
+
populated += child.populatedCellCounts[i];
|
|
5011
|
+
complete += child.completeCellCounts[i];
|
|
5012
|
+
}
|
|
5013
|
+
}
|
|
5014
|
+
next.minimums[id] = populated ? min : 0;
|
|
5015
|
+
next.maximums[id] = populated ? max : 0;
|
|
5016
|
+
next.populatedCellCounts[id] = populated;
|
|
5017
|
+
next.completeCellCounts[id] = complete;
|
|
5018
|
+
parents.add(Math.floor(y / 2) * Math.ceil(next.width / 2) + Math.floor(x / 2));
|
|
5019
|
+
}
|
|
5020
|
+
levels[l] = next;
|
|
5021
|
+
ids = parents;
|
|
5022
|
+
}
|
|
5023
|
+
return { field, levels, updatedCounts: Uint32Array.from(counts) };
|
|
5024
|
+
}
|
|
5025
|
+
|
|
5026
|
+
// dist/terrain/gradient-pyramid-regions.js
|
|
5027
|
+
function updateTerrainGradientPyramidRegions(previous, grid, dirty, options = {}) {
|
|
5028
|
+
const limit = options.maxSamples ?? 4e6, budget = options.maxTests ?? 1e7;
|
|
5029
|
+
if (![limit, budget].every(Number.isSafeInteger) || limit < 0 || budget < 0 || !Number.isSafeInteger(grid.width) || grid.width < 1 || !Number.isSafeInteger(grid.height) || grid.height < 1 || grid.width * grid.height > limit)
|
|
5030
|
+
throw new Error("Invalid gradient region capacity");
|
|
5031
|
+
if (grid.method !== "horn" && grid.method !== "zevenbergen-thorne" || grid.registration !== "vertex" && grid.registration !== "cell" || typeof grid.heightReference !== "string" || ![grid.origin, grid.columnStep, grid.rowStep].every((v) => v.length === 2 && v.every(Number.isFinite)))
|
|
5032
|
+
throw new Error("Invalid gradient region metadata");
|
|
5033
|
+
validateTerrainDirtyWindows(dirty, grid.width, grid.height);
|
|
5034
|
+
const old = previous == null ? void 0 : previous.source;
|
|
5035
|
+
if (!old || old.width !== grid.width || old.height !== grid.height || old.method !== grid.method || old.registration !== grid.registration || old.heightReference !== grid.heightReference || !old.origin.every((v, i) => v === grid.origin[i]) || !old.columnStep.every((v, i) => v === grid.columnStep[i]) || !old.rowStep.every((v, i) => v === grid.rowStep[i])) {
|
|
5036
|
+
const pyramid = createTerrainGradientPyramid(grid, { maxSamples: limit });
|
|
5037
|
+
return {
|
|
5038
|
+
source: grid,
|
|
5039
|
+
pyramid,
|
|
5040
|
+
updatedCounts: Uint32Array.from(pyramid.levels, (l) => l.width * l.height)
|
|
5041
|
+
};
|
|
5042
|
+
}
|
|
5043
|
+
if (!(grid.gradients instanceof Float64Array) || grid.gradients.length !== 2 * grid.width * grid.height || !(grid.statuses instanceof Uint8Array) || grid.statuses.length !== grid.width * grid.height)
|
|
5044
|
+
throw new Error("Invalid gradient region buffers");
|
|
5045
|
+
const levels = previous.pyramid.levels.slice();
|
|
5046
|
+
let tests = 0;
|
|
5047
|
+
const charge = () => {
|
|
5048
|
+
if (++tests > budget)
|
|
5049
|
+
throw new Error("Gradient region work budget exceeded");
|
|
5050
|
+
};
|
|
5051
|
+
let ids = terrainDirtyIndices(dirty, grid.width, grid.height, 0, charge);
|
|
5052
|
+
const counts = [];
|
|
5053
|
+
for (let l = 0; l < levels.length; l++) {
|
|
5054
|
+
counts.push(ids.size);
|
|
5055
|
+
if (!ids.size)
|
|
5056
|
+
continue;
|
|
5057
|
+
const oldLevel = levels[l], next = {
|
|
5058
|
+
...oldLevel,
|
|
5059
|
+
gradients: oldLevel.gradients.slice(),
|
|
5060
|
+
validCounts: oldLevel.validCounts.slice(),
|
|
5061
|
+
sampleCounts: oldLevel.sampleCounts
|
|
5062
|
+
};
|
|
5063
|
+
const parents = /* @__PURE__ */ new Set();
|
|
5064
|
+
for (const id of ids) {
|
|
5065
|
+
charge();
|
|
5066
|
+
const x = id % next.width, y = Math.floor(id / next.width);
|
|
5067
|
+
next.validCounts[id] = 0;
|
|
5068
|
+
next.gradients[2 * id] = next.gradients[2 * id + 1] = 0;
|
|
5069
|
+
if (l === 0) {
|
|
5070
|
+
if (grid.statuses[id] > 6)
|
|
5071
|
+
throw new Error("Invalid terrain gradient status");
|
|
5072
|
+
if (grid.statuses[id] === 0) {
|
|
5073
|
+
if (!Number.isFinite(grid.gradients[2 * id]) || !Number.isFinite(grid.gradients[2 * id + 1]))
|
|
5074
|
+
throw new Error("Invalid terrain gradient value");
|
|
5075
|
+
next.validCounts[id] = 1;
|
|
5076
|
+
next.gradients[2 * id] = grid.gradients[2 * id];
|
|
5077
|
+
next.gradients[2 * id + 1] = grid.gradients[2 * id + 1];
|
|
5078
|
+
}
|
|
5079
|
+
} else {
|
|
5080
|
+
const child = levels[l - 1];
|
|
5081
|
+
for (let dy = 0; dy < 2; dy++)
|
|
5082
|
+
for (let dx = 0; dx < 2; dx++) {
|
|
5083
|
+
const cx = x * 2 + dx, cy = y * 2 + dy;
|
|
5084
|
+
if (cx >= child.width || cy >= child.height)
|
|
5085
|
+
continue;
|
|
5086
|
+
const i = cy * child.width + cx, n = child.validCounts[i], count = next.validCounts[id];
|
|
5087
|
+
if (n) {
|
|
5088
|
+
const total = count + n;
|
|
5089
|
+
for (let axis = 0; axis < 2; axis++) {
|
|
5090
|
+
const a = next.gradients[2 * id + axis], b = child.gradients[2 * i + axis];
|
|
5091
|
+
next.gradients[2 * id + axis] = count ? a * (count / total) + b * (n / total) : b;
|
|
5092
|
+
}
|
|
5093
|
+
next.validCounts[id] = total;
|
|
5094
|
+
}
|
|
5095
|
+
}
|
|
5096
|
+
}
|
|
5097
|
+
parents.add(Math.floor(y / 2) * Math.ceil(next.width / 2) + Math.floor(x / 2));
|
|
5098
|
+
}
|
|
5099
|
+
levels[l] = next;
|
|
5100
|
+
ids = parents;
|
|
5101
|
+
}
|
|
5102
|
+
return {
|
|
5103
|
+
source: grid,
|
|
5104
|
+
pyramid: { ...previous.pyramid, levels },
|
|
5105
|
+
updatedCounts: Uint32Array.from(counts)
|
|
5106
|
+
};
|
|
5107
|
+
}
|
|
5108
|
+
|
|
5109
|
+
// dist/terrain/persistent-hierarchy-data.js
|
|
5110
|
+
function getTerrainHierarchyNode(level, column, row) {
|
|
5111
|
+
if (!Number.isSafeInteger(level.width) || level.width < 1 || !Number.isSafeInteger(level.height) || level.height < 1 || !Number.isSafeInteger(level.nodesPerBlock) || level.nodesPerBlock < 1 || !Array.isArray(level.blocks))
|
|
5112
|
+
throw new Error("Invalid persistent hierarchy level");
|
|
5113
|
+
if (!Number.isSafeInteger(column) || !Number.isSafeInteger(row) || column < 0 || row < 0 || column >= level.width || row >= level.height)
|
|
5114
|
+
throw new Error("Invalid persistent hierarchy node");
|
|
5115
|
+
const id = row * level.width + column, block = level.blocks[Math.floor(id / level.nodesPerBlock)], i = block ? 2 * (id - block.offset) : -1;
|
|
5116
|
+
const expectedOffset = Math.floor(id / level.nodesPerBlock) * level.nodesPerBlock;
|
|
5117
|
+
if (!block || block.offset !== expectedOffset || block.count !== Math.min(level.nodesPerBlock, level.width * level.height - expectedOffset) || !(block.values instanceof Float64Array) || !(block.counts instanceof Uint32Array) || block.values.length !== 2 * block.count || block.counts.length !== 2 * block.count)
|
|
5118
|
+
throw new Error("Invalid persistent hierarchy block");
|
|
5119
|
+
return {
|
|
5120
|
+
values: [block.values[i], block.values[i + 1]],
|
|
5121
|
+
counts: [block.counts[i], block.counts[i + 1]]
|
|
5122
|
+
};
|
|
5123
|
+
}
|
|
5124
|
+
function packTerrainHierarchyLevel(width, height, blockSize, values, counts, nodesPerBlock) {
|
|
5125
|
+
if (values.length !== 2 * width * height || counts.length !== values.length || !values.every(Number.isFinite))
|
|
5126
|
+
throw new Error("Invalid persistent hierarchy buffers");
|
|
5127
|
+
const blocks = [];
|
|
5128
|
+
for (let offset = 0; offset < width * height; offset += nodesPerBlock) {
|
|
5129
|
+
const count = Math.min(nodesPerBlock, width * height - offset);
|
|
5130
|
+
blocks.push({
|
|
5131
|
+
offset,
|
|
5132
|
+
count,
|
|
5133
|
+
values: values.slice(2 * offset, 2 * (offset + count)),
|
|
5134
|
+
counts: counts.slice(2 * offset, 2 * (offset + count))
|
|
5135
|
+
});
|
|
5136
|
+
}
|
|
5137
|
+
return { width, height, blockSize, nodesPerBlock, blocks };
|
|
5138
|
+
}
|
|
5139
|
+
function persistentHierarchyOptions(options, count) {
|
|
5140
|
+
const nodesPerBlock = options.nodesPerBlock ?? 256, maxSamples = options.maxSamples ?? 4e6, maxTests = options.maxTests ?? 1e7;
|
|
5141
|
+
if (![nodesPerBlock, maxSamples, maxTests, count].every(Number.isSafeInteger) || nodesPerBlock < 1 || maxSamples < 0 || maxTests < 0 || count < 1 || count > maxSamples)
|
|
5142
|
+
throw new Error("Invalid persistent terrain hierarchy capacity");
|
|
5143
|
+
let tests = 0;
|
|
5144
|
+
return {
|
|
5145
|
+
nodesPerBlock,
|
|
5146
|
+
maxSamples,
|
|
5147
|
+
charge: () => {
|
|
5148
|
+
if (++tests > maxTests)
|
|
5149
|
+
throw new Error("Persistent hierarchy work budget exceeded");
|
|
5150
|
+
}
|
|
5151
|
+
};
|
|
5152
|
+
}
|
|
5153
|
+
function updatePersistentHierarchy(previous, ids, mode, base, charge) {
|
|
5154
|
+
const levels = previous.slice(), updatedNodes = [];
|
|
5155
|
+
let copiedBlocks = 0, copiedBytes = 0;
|
|
5156
|
+
for (let l = 0; l < levels.length; l++) {
|
|
5157
|
+
updatedNodes.push(ids.size);
|
|
5158
|
+
if (!ids.size)
|
|
5159
|
+
continue;
|
|
5160
|
+
const old = levels[l], blocks = old.blocks.slice(), cloned = /* @__PURE__ */ new Set(), parents = /* @__PURE__ */ new Set();
|
|
5161
|
+
const node = (level, x, y) => getTerrainHierarchyNode(level, x, y);
|
|
5162
|
+
for (const id of ids) {
|
|
5163
|
+
charge();
|
|
5164
|
+
const x = id % old.width, y = Math.floor(id / old.width);
|
|
5165
|
+
let value;
|
|
5166
|
+
if (l === 0)
|
|
5167
|
+
value = base(x, y);
|
|
5168
|
+
else {
|
|
5169
|
+
const child = levels[l - 1];
|
|
5170
|
+
let a = mode === "bounds" ? Infinity : 0, b = mode === "bounds" ? -Infinity : 0, c = 0, d = 0;
|
|
5171
|
+
for (let dy = 0; dy < 2; dy++)
|
|
5172
|
+
for (let dx = 0; dx < 2; dx++) {
|
|
5173
|
+
const cx = x * 2 + dx, cy = y * 2 + dy;
|
|
5174
|
+
if (cx >= child.width || cy >= child.height)
|
|
5175
|
+
continue;
|
|
5176
|
+
const v = node(child, cx, cy), n = v.counts[0];
|
|
5177
|
+
d += v.counts[1];
|
|
5178
|
+
if (n) {
|
|
5179
|
+
if (mode === "bounds") {
|
|
5180
|
+
a = Math.min(a, v.values[0]);
|
|
5181
|
+
b = Math.max(b, v.values[1]);
|
|
5182
|
+
} else {
|
|
5183
|
+
const total = c + n;
|
|
5184
|
+
a = c ? a * (c / total) + v.values[0] * (n / total) : v.values[0];
|
|
5185
|
+
b = c ? b * (c / total) + v.values[1] * (n / total) : v.values[1];
|
|
5186
|
+
}
|
|
5187
|
+
c += n;
|
|
5188
|
+
}
|
|
5189
|
+
}
|
|
5190
|
+
if (c && (!Number.isFinite(a) || !Number.isFinite(b)))
|
|
5191
|
+
throw new Error("Persistent hierarchy arithmetic overflow");
|
|
5192
|
+
value = { values: c ? [a, b] : [0, 0], counts: [c, d] };
|
|
5193
|
+
}
|
|
5194
|
+
const blockId = Math.floor(id / old.nodesPerBlock);
|
|
5195
|
+
if (!cloned.has(blockId)) {
|
|
5196
|
+
const source = blocks[blockId];
|
|
5197
|
+
blocks[blockId] = { ...source, values: source.values.slice(), counts: source.counts.slice() };
|
|
5198
|
+
cloned.add(blockId);
|
|
5199
|
+
copiedBlocks++;
|
|
5200
|
+
copiedBytes += blocks[blockId].values.byteLength + blocks[blockId].counts.byteLength;
|
|
5201
|
+
}
|
|
5202
|
+
const block = blocks[blockId], i = 2 * (id - block.offset);
|
|
5203
|
+
block.values[i] = value.values[0];
|
|
5204
|
+
block.values[i + 1] = value.values[1];
|
|
5205
|
+
block.counts[i] = value.counts[0];
|
|
5206
|
+
block.counts[i + 1] = value.counts[1];
|
|
5207
|
+
parents.add(Math.floor(y / 2) * Math.ceil(old.width / 2) + Math.floor(x / 2));
|
|
5208
|
+
}
|
|
5209
|
+
levels[l] = { ...old, blocks };
|
|
5210
|
+
ids = parents;
|
|
5211
|
+
}
|
|
5212
|
+
return { levels, stats: { copiedBlocks, copiedBytes, updatedNodes: Uint32Array.from(updatedNodes) } };
|
|
5213
|
+
}
|
|
5214
|
+
|
|
5215
|
+
// dist/terrain/persistent-bounds.js
|
|
5216
|
+
function updateTerrainPersistentBounds(previous, field, dirty, options = {}) {
|
|
5217
|
+
const { nodesPerBlock, charge } = persistentHierarchyOptions(options, field.width * field.height);
|
|
5218
|
+
validateTerrainDirtyWindows(dirty, field.width, field.height);
|
|
5219
|
+
if (!previous || !sameTerrainFrame(previous.field, field) || previous.levels[0].nodesPerBlock !== nodesPerBlock) {
|
|
5220
|
+
const bounds2 = new HeightFieldMinMax(field), levels = Array.from({ length: bounds2.levelCount }, (_, i) => {
|
|
5221
|
+
const l = bounds2.copyLevel(i), values = new Float64Array(2 * l.width * l.height), counts = new Uint32Array(values.length);
|
|
5222
|
+
for (let j = 0; j < l.width * l.height; j++) {
|
|
5223
|
+
values[2 * j] = l.minimums[j];
|
|
5224
|
+
values[2 * j + 1] = l.maximums[j];
|
|
5225
|
+
counts[2 * j] = l.populatedCellCounts[j];
|
|
5226
|
+
counts[2 * j + 1] = l.completeCellCounts[j];
|
|
5227
|
+
}
|
|
5228
|
+
return packTerrainHierarchyLevel(l.width, l.height, l.blockSize, values, counts, nodesPerBlock);
|
|
5229
|
+
});
|
|
5230
|
+
return {
|
|
5231
|
+
field,
|
|
5232
|
+
levels,
|
|
5233
|
+
stats: {
|
|
5234
|
+
copiedBlocks: levels.reduce((n, l) => n + l.blocks.length, 0),
|
|
5235
|
+
copiedBytes: levels.reduce((n, l) => n + l.blocks.reduce((s, b) => s + b.values.byteLength + b.counts.byteLength, 0), 0),
|
|
5236
|
+
updatedNodes: Uint32Array.from(levels, (l) => l.width * l.height)
|
|
5237
|
+
}
|
|
5238
|
+
};
|
|
5239
|
+
}
|
|
5240
|
+
const ids = terrainDirtyIndices(dirty, field.width - 1, field.height - 1, 1, charge);
|
|
5241
|
+
const result = updatePersistentHierarchy(previous.levels, ids, "bounds", (x, y) => {
|
|
5242
|
+
let min = Infinity, max = -Infinity, n = 0;
|
|
5243
|
+
for (let dy = 0; dy < 2; dy++)
|
|
5244
|
+
for (let dx = 0; dx < 2; dx++) {
|
|
5245
|
+
const z = field.getHeight(x + dx, y + dy);
|
|
5246
|
+
if (z !== void 0) {
|
|
5247
|
+
min = Math.min(min, z);
|
|
5248
|
+
max = Math.max(max, z);
|
|
5249
|
+
n++;
|
|
5250
|
+
}
|
|
5251
|
+
}
|
|
5252
|
+
return { values: n ? [min, max] : [0, 0], counts: [n ? 1 : 0, n === 4 ? 1 : 0] };
|
|
5253
|
+
}, charge);
|
|
5254
|
+
return { field, ...result };
|
|
5255
|
+
}
|
|
5256
|
+
|
|
5257
|
+
// dist/terrain/persistent-gradients.js
|
|
5258
|
+
function updateTerrainPersistentGradients(previous, grid, dirty, options = {}) {
|
|
5259
|
+
const { nodesPerBlock, maxSamples, charge } = persistentHierarchyOptions(options, grid.width * grid.height);
|
|
5260
|
+
if (!Number.isSafeInteger(grid.width) || grid.width < 1 || !Number.isSafeInteger(grid.height) || grid.height < 1 || !(grid.gradients instanceof Float64Array) || grid.gradients.length !== 2 * grid.width * grid.height || !(grid.statuses instanceof Uint8Array) || grid.statuses.length !== grid.width * grid.height || grid.method !== "horn" && grid.method !== "zevenbergen-thorne" || grid.registration !== "vertex" && grid.registration !== "cell" || typeof grid.heightReference !== "string" || ![grid.origin, grid.columnStep, grid.rowStep].every((v) => v.length === 2 && v.every(Number.isFinite)))
|
|
5261
|
+
throw new Error("Invalid persistent gradient grid");
|
|
5262
|
+
validateTerrainDirtyWindows(dirty, grid.width, grid.height);
|
|
5263
|
+
const old = previous == null ? void 0 : previous.source;
|
|
5264
|
+
if (!old || old.width !== grid.width || old.height !== grid.height || old.method !== grid.method || old.registration !== grid.registration || old.heightReference !== grid.heightReference || !old.origin.every((v, i) => v === grid.origin[i]) || !old.columnStep.every((v, i) => v === grid.columnStep[i]) || !old.rowStep.every((v, i) => v === grid.rowStep[i]) || previous.levels[0].nodesPerBlock !== nodesPerBlock) {
|
|
5265
|
+
const pyramid = createTerrainGradientPyramid(grid, { maxSamples }), levels = pyramid.levels.map((l) => {
|
|
5266
|
+
const counts = new Uint32Array(2 * l.width * l.height);
|
|
5267
|
+
for (let i = 0; i < l.width * l.height; i++) {
|
|
5268
|
+
counts[2 * i] = l.validCounts[i];
|
|
5269
|
+
counts[2 * i + 1] = l.sampleCounts[i];
|
|
5270
|
+
}
|
|
5271
|
+
return packTerrainHierarchyLevel(l.width, l.height, l.blockSize, l.gradients, counts, nodesPerBlock);
|
|
5272
|
+
});
|
|
5273
|
+
return {
|
|
5274
|
+
source: grid,
|
|
5275
|
+
levels,
|
|
5276
|
+
stats: {
|
|
5277
|
+
copiedBlocks: levels.reduce((n, l) => n + l.blocks.length, 0),
|
|
5278
|
+
copiedBytes: levels.reduce((n, l) => n + l.blocks.reduce((s, b) => s + b.values.byteLength + b.counts.byteLength, 0), 0),
|
|
5279
|
+
updatedNodes: Uint32Array.from(levels, (l) => l.width * l.height)
|
|
5280
|
+
}
|
|
5281
|
+
};
|
|
5282
|
+
}
|
|
5283
|
+
const ids = terrainDirtyIndices(dirty, grid.width, grid.height, 0, charge);
|
|
5284
|
+
const result = updatePersistentHierarchy(previous.levels, ids, "gradient", (x, y) => {
|
|
5285
|
+
const i = y * grid.width + x, s = grid.statuses[i];
|
|
5286
|
+
if (s > 6)
|
|
5287
|
+
throw new Error("Invalid terrain gradient status");
|
|
5288
|
+
if (s === 0 && (!Number.isFinite(grid.gradients[2 * i]) || !Number.isFinite(grid.gradients[2 * i + 1])))
|
|
5289
|
+
throw new Error("Invalid terrain gradient value");
|
|
5290
|
+
return {
|
|
5291
|
+
values: s === 0 ? [grid.gradients[2 * i], grid.gradients[2 * i + 1]] : [0, 0],
|
|
5292
|
+
counts: [s === 0 ? 1 : 0, 1]
|
|
5293
|
+
};
|
|
5294
|
+
}, charge);
|
|
5295
|
+
return { source: grid, ...result };
|
|
5296
|
+
}
|
|
5297
|
+
|
|
5298
|
+
// dist/terrain/lod-morph.js
|
|
5299
|
+
var TerrainMorphStatus = {
|
|
5300
|
+
VALID: 0,
|
|
5301
|
+
FINE_NO_DATA: 1,
|
|
5302
|
+
COARSE_NO_DATA: 2,
|
|
5303
|
+
OUTSIDE_COARSE: 3
|
|
5304
|
+
};
|
|
5305
|
+
function createTerrainLodMorph(fine, coarse, options) {
|
|
5306
|
+
const { ratio } = options, offset = options.coarseOrigin ?? [0, 0], limit = options.maxSamples ?? 4e6, count = fine.width * fine.height;
|
|
5307
|
+
if (!Number.isSafeInteger(ratio) || ratio < 2 || 2 ** Math.round(Math.log2(ratio)) !== ratio || offset.length !== 2 || !offset.every(Number.isSafeInteger) || !Number.isSafeInteger(limit) || limit < 0 || count > limit)
|
|
5308
|
+
throw new Error("Invalid terrain LOD ratio, origin or sample capacity");
|
|
5309
|
+
if (fine.registration !== "vertex" || coarse.registration !== "vertex" || fine.diagonal !== coarse.diagonal || fine.heightReference !== coarse.heightReference)
|
|
5310
|
+
throw new Error("Incompatible terrain LOD registration, diagonal or height reference");
|
|
5311
|
+
for (let axis = 0; axis < 2; axis++) {
|
|
5312
|
+
if (fine.columnStep[axis] * ratio !== coarse.columnStep[axis] || fine.rowStep[axis] * ratio !== coarse.rowStep[axis])
|
|
5313
|
+
throw new Error("Terrain LOD steps differ");
|
|
5314
|
+
const a = offset[0] * fine.columnStep[axis], b = offset[1] * fine.rowStep[axis], expected = fine.origin[axis] + a + b;
|
|
5315
|
+
const tolerance = Math.min(16 * Number.EPSILON * Math.max(1, Math.abs(fine.origin[axis]), Math.abs(coarse.origin[axis]), Math.abs(a), Math.abs(b)), 1e-9 * Math.max(Math.abs(fine.columnStep[axis]), Math.abs(fine.rowStep[axis])));
|
|
5316
|
+
if (!Number.isFinite(expected) || Math.abs(coarse.origin[axis] - expected) > tolerance)
|
|
5317
|
+
throw new Error("Terrain LOD origins differ");
|
|
5318
|
+
}
|
|
5319
|
+
const fineHeights = new Float64Array(count), coarseHeights = new Float64Array(count), deltas = new Float64Array(count), statuses = new Uint8Array(count), coarseCoordinates = new Float64Array(2 * count);
|
|
5320
|
+
let maxNodalDisplacement = 0;
|
|
5321
|
+
for (let y = 0; y < fine.height; y++)
|
|
5322
|
+
for (let x = 0; x < fine.width; x++) {
|
|
5323
|
+
const i = y * fine.width + x, u = (x - offset[0]) / ratio, v = (y - offset[1]) / ratio;
|
|
5324
|
+
if (!Number.isSafeInteger(x - offset[0]) || !Number.isSafeInteger(y - offset[1]))
|
|
5325
|
+
throw new Error("Terrain LOD lattice overflow");
|
|
5326
|
+
coarseCoordinates[2 * i] = u;
|
|
5327
|
+
coarseCoordinates[2 * i + 1] = v;
|
|
5328
|
+
const source = fine.getHeight(x, y);
|
|
5329
|
+
if (source === void 0) {
|
|
5330
|
+
statuses[i] = TerrainMorphStatus.FINE_NO_DATA;
|
|
5331
|
+
continue;
|
|
5332
|
+
}
|
|
5333
|
+
fineHeights[i] = source;
|
|
5334
|
+
if (u < 0 || v < 0 || u > coarse.width - 1 || v > coarse.height - 1) {
|
|
5335
|
+
statuses[i] = TerrainMorphStatus.OUTSIDE_COARSE;
|
|
5336
|
+
continue;
|
|
5337
|
+
}
|
|
5338
|
+
const target = sampleTerrainTriangleHeight(coarse, u, v);
|
|
5339
|
+
if (target === void 0) {
|
|
5340
|
+
statuses[i] = TerrainMorphStatus.COARSE_NO_DATA;
|
|
5341
|
+
continue;
|
|
5342
|
+
}
|
|
5343
|
+
const delta = target - source;
|
|
5344
|
+
if (!Number.isFinite(delta))
|
|
5345
|
+
throw new Error("Terrain LOD displacement overflow");
|
|
5346
|
+
coarseHeights[i] = target;
|
|
5347
|
+
deltas[i] = delta;
|
|
5348
|
+
maxNodalDisplacement = Math.max(maxNodalDisplacement, Math.abs(delta));
|
|
5349
|
+
}
|
|
5350
|
+
return {
|
|
5351
|
+
width: fine.width,
|
|
5352
|
+
height: fine.height,
|
|
5353
|
+
origin: [...fine.origin],
|
|
5354
|
+
columnStep: [...fine.columnStep],
|
|
5355
|
+
rowStep: [...fine.rowStep],
|
|
5356
|
+
heightReference: fine.heightReference,
|
|
5357
|
+
fineHeights,
|
|
5358
|
+
coarseHeights,
|
|
5359
|
+
deltas,
|
|
5360
|
+
statuses,
|
|
5361
|
+
coarseCoordinates,
|
|
5362
|
+
maxNodalDisplacement,
|
|
5363
|
+
ratio,
|
|
5364
|
+
coarseOrigin: [...offset],
|
|
5365
|
+
diagonal: fine.diagonal
|
|
5366
|
+
};
|
|
5367
|
+
}
|
|
5368
|
+
|
|
5369
|
+
// dist/terrain/lod-morph-evaluate.js
|
|
5370
|
+
function evaluateTerrainLodMorph(morph, factor) {
|
|
5371
|
+
const count = morph.width * morph.height;
|
|
5372
|
+
if (!Number.isFinite(factor) || factor < 0 || factor > 1 || !Number.isSafeInteger(count) || count < 1 || morph.fineHeights.length !== count || morph.coarseHeights.length !== count || morph.statuses.length !== count)
|
|
5373
|
+
throw new Error("Invalid terrain morph evaluation");
|
|
5374
|
+
const heights = new Float64Array(count), validity = new Uint8Array(count);
|
|
5375
|
+
for (let i = 0; i < count; i++) {
|
|
5376
|
+
if (morph.statuses[i] > 3)
|
|
5377
|
+
throw new Error("Invalid terrain morph status");
|
|
5378
|
+
if (morph.statuses[i] !== 0)
|
|
5379
|
+
continue;
|
|
5380
|
+
const a = morph.fineHeights[i], b = morph.coarseHeights[i];
|
|
5381
|
+
if (!Number.isFinite(a) || !Number.isFinite(b))
|
|
5382
|
+
throw new Error("Invalid terrain morph height");
|
|
5383
|
+
heights[i] = factor === 0 ? a : factor === 1 ? b : a * (1 - factor) + b * factor;
|
|
5384
|
+
if (!Number.isFinite(heights[i]))
|
|
5385
|
+
throw new Error("Terrain morph arithmetic overflow");
|
|
5386
|
+
validity[i] = 1;
|
|
5387
|
+
}
|
|
5388
|
+
return { heights, validity };
|
|
5389
|
+
}
|
|
5390
|
+
|
|
5391
|
+
// dist/terrain/mixed-surface.js
|
|
5392
|
+
function reconcileMixedSurface(tiles, options = {}) {
|
|
5393
|
+
const limit = options.maxSamples ?? 4e6, budget = options.maxTests ?? 2e7, adjustment = options.maxHeightAdjustment ?? 0;
|
|
5394
|
+
if (![limit, budget].every(Number.isSafeInteger) || limit < 0 || budget < 0 || Number.isNaN(adjustment) || adjustment < 0)
|
|
5395
|
+
throw new Error("Invalid mixed surface capacity or adjustment");
|
|
5396
|
+
let count = 0, tests = 0, maxHeightAdjustment = 0, sharedSamples = 0;
|
|
5397
|
+
const charge = () => {
|
|
5398
|
+
if (++tests > budget)
|
|
5399
|
+
throw new Error("Mixed surface work budget exceeded");
|
|
5400
|
+
};
|
|
5401
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5402
|
+
const sorted = [...tiles].sort((a, b) => b.spacing - a.spacing || a.column - b.column || a.row - b.row);
|
|
5403
|
+
const sources = sorted.map((t) => {
|
|
5404
|
+
if (![t.column, t.row, t.spacing].every(Number.isSafeInteger) || t.spacing < 1 || 2 ** Math.round(Math.log2(t.spacing)) !== t.spacing)
|
|
5405
|
+
throw new Error("Invalid mixed surface lattice");
|
|
5406
|
+
const key2 = `${t.spacing}/${t.column}/${t.row}`;
|
|
5407
|
+
if (seen.has(key2))
|
|
5408
|
+
throw new Error("Duplicate mixed surface tile");
|
|
5409
|
+
seen.add(key2);
|
|
5410
|
+
const width = (t.field.width - 1) * t.spacing + 1, height = (t.field.height - 1) * t.spacing + 1;
|
|
5411
|
+
count += width * height;
|
|
5412
|
+
if (![width, height, count, t.column + width - 1, t.row + height - 1].every(Number.isSafeInteger) || width < 2 || height < 2 || count > limit)
|
|
5413
|
+
throw new Error("Mixed surface sample capacity or lattice overflow");
|
|
5414
|
+
const field = new HeightField(t.field);
|
|
5415
|
+
if (field.registration !== "vertex")
|
|
5416
|
+
throw new Error("Mixed surfaces require vertex registration");
|
|
5417
|
+
return { ...t, field, width, height };
|
|
5418
|
+
});
|
|
5419
|
+
const first = sources[0];
|
|
5420
|
+
const columnStep = (first == null ? void 0 : first.field.columnStep.map((v) => v / first.spacing)) ?? [1, 0], rowStep = (first == null ? void 0 : first.field.rowStep.map((v) => v / first.spacing)) ?? [0, 1];
|
|
5421
|
+
const origin = (first == null ? void 0 : first.field.origin.map((v, i) => v - first.column * columnStep[i] - first.row * rowStep[i])) ?? [0, 0];
|
|
5422
|
+
if (!origin.every(Number.isFinite))
|
|
5423
|
+
throw new Error("Mixed surface frame overflow");
|
|
5424
|
+
for (const t of sources)
|
|
5425
|
+
for (let axis = 0; axis < 2; axis++) {
|
|
5426
|
+
const expected = origin[axis] + t.column * columnStep[axis] + t.row * rowStep[axis];
|
|
5427
|
+
const tolerance = Math.min(32 * Number.EPSILON * Math.max(1, Math.abs(t.field.origin[axis]), Math.abs(origin[axis]), Math.abs(t.column * columnStep[axis]), Math.abs(t.row * rowStep[axis])), 1e-9 * Math.max(Math.abs(columnStep[axis]), Math.abs(rowStep[axis])));
|
|
5428
|
+
if (t.field.diagonal !== first.field.diagonal || t.field.heightReference !== first.field.heightReference || t.field.columnStep[axis] / t.spacing !== columnStep[axis] || t.field.rowStep[axis] / t.spacing !== rowStep[axis] || !Number.isFinite(expected) || Math.abs(t.field.origin[axis] - expected) > tolerance)
|
|
5429
|
+
throw new Error("Mixed surface frames, diagonals or height references differ");
|
|
5430
|
+
}
|
|
5431
|
+
for (const axis of ["column", "row"]) {
|
|
5432
|
+
let min = Infinity, max = -Infinity;
|
|
5433
|
+
for (const t of sources) {
|
|
5434
|
+
min = Math.min(min, t[axis]);
|
|
5435
|
+
max = Math.max(max, t[axis] + (axis === "column" ? t.width : t.height) - 1);
|
|
5436
|
+
}
|
|
5437
|
+
if (sources.length && !Number.isSafeInteger(max - min))
|
|
5438
|
+
throw new Error("Mixed surface lattice span overflow");
|
|
5439
|
+
}
|
|
5440
|
+
const boxes = sources.map((t) => ({
|
|
5441
|
+
minX: t.column,
|
|
5442
|
+
minY: t.row,
|
|
5443
|
+
maxX: t.column + t.width - 1,
|
|
5444
|
+
maxY: t.row + t.height - 1
|
|
5445
|
+
})), index = createTerrainBoxIndex(boxes);
|
|
5446
|
+
const neighbors = boxes.map((box, i) => index(box, charge).filter((j) => {
|
|
5447
|
+
if (i !== j && box.minX < boxes[j].maxX && boxes[j].minX < box.maxX && box.minY < boxes[j].maxY && boxes[j].minY < box.maxY)
|
|
5448
|
+
throw new Error("Overlapping mixed surface interiors");
|
|
5449
|
+
return j !== i;
|
|
5450
|
+
}));
|
|
5451
|
+
const fields = sources.map((t, i) => {
|
|
5452
|
+
const heights = new Float64Array(t.width * t.height), validity = new Uint8Array(heights.length);
|
|
5453
|
+
for (let y = 0; y < t.height; y++)
|
|
5454
|
+
for (let x = 0; x < t.width; x++) {
|
|
5455
|
+
charge();
|
|
5456
|
+
const gx = t.column + x, gy = t.row + y, local = sampleTerrainTriangleHeight(t.field, x / t.spacing, y / t.spacing);
|
|
5457
|
+
let owner = i, shared = false, missing = local === void 0;
|
|
5458
|
+
if (x === 0 || y === 0 || x === t.width - 1 || y === t.height - 1)
|
|
5459
|
+
for (const j of neighbors[i]) {
|
|
5460
|
+
charge();
|
|
5461
|
+
const b = boxes[j];
|
|
5462
|
+
if (gx >= b.minX && gx <= b.maxX && gy >= b.minY && gy <= b.maxY) {
|
|
5463
|
+
shared = true;
|
|
5464
|
+
const neighbor = sources[j];
|
|
5465
|
+
if (sampleTerrainTriangleHeight(neighbor.field, (gx - neighbor.column) / neighbor.spacing, (gy - neighbor.row) / neighbor.spacing) === void 0)
|
|
5466
|
+
missing = true;
|
|
5467
|
+
owner = Math.min(owner, j);
|
|
5468
|
+
}
|
|
5469
|
+
}
|
|
5470
|
+
const source = sources[owner], value = missing ? void 0 : owner === i ? local : sampleTerrainTriangleHeight(source.field, (gx - source.column) / source.spacing, (gy - source.row) / source.spacing);
|
|
5471
|
+
if (shared)
|
|
5472
|
+
sharedSamples++;
|
|
5473
|
+
if (local !== void 0 && value !== void 0) {
|
|
5474
|
+
const delta = Math.abs(value - local);
|
|
5475
|
+
if (!Number.isFinite(delta) || delta > adjustment)
|
|
5476
|
+
throw new Error("Mixed surface height adjustment exceeded");
|
|
5477
|
+
maxHeightAdjustment = Math.max(maxHeightAdjustment, delta);
|
|
5478
|
+
}
|
|
5479
|
+
if (value !== void 0) {
|
|
5480
|
+
const id = y * t.width + x;
|
|
5481
|
+
heights[id] = value;
|
|
5482
|
+
validity[id] = 1;
|
|
5483
|
+
}
|
|
5484
|
+
}
|
|
5485
|
+
const props = {
|
|
5486
|
+
width: t.width,
|
|
5487
|
+
height: t.height,
|
|
5488
|
+
heights,
|
|
5489
|
+
validity,
|
|
5490
|
+
origin: [
|
|
5491
|
+
origin[0] + t.column * columnStep[0] + t.row * rowStep[0],
|
|
5492
|
+
origin[1] + t.column * columnStep[1] + t.row * rowStep[1]
|
|
5493
|
+
],
|
|
5494
|
+
columnStep: [...columnStep],
|
|
5495
|
+
rowStep: [...rowStep],
|
|
5496
|
+
registration: "vertex",
|
|
5497
|
+
diagonal: t.field.diagonal,
|
|
5498
|
+
heightReference: t.field.heightReference
|
|
5499
|
+
};
|
|
5500
|
+
return {
|
|
5501
|
+
column: t.column,
|
|
5502
|
+
row: t.row,
|
|
5503
|
+
spacing: 1,
|
|
5504
|
+
sourceSpacing: t.spacing,
|
|
5505
|
+
field: props
|
|
5506
|
+
};
|
|
5507
|
+
});
|
|
5508
|
+
return {
|
|
5509
|
+
origin,
|
|
5510
|
+
columnStep,
|
|
5511
|
+
rowStep,
|
|
5512
|
+
tiles: fields,
|
|
5513
|
+
maxHeightAdjustment,
|
|
5514
|
+
sharedSamples,
|
|
5515
|
+
tests
|
|
5516
|
+
};
|
|
5517
|
+
}
|
|
5518
|
+
|
|
5519
|
+
// dist/terrain/lod-coordinate.js
|
|
5520
|
+
function coordinateTerrainLodMorphs(tiles, options = {}) {
|
|
5521
|
+
const limit = options.maxSamples ?? 4e6;
|
|
5522
|
+
if (!Number.isSafeInteger(limit) || limit < 0)
|
|
5523
|
+
throw new Error("Invalid coordinated morph sample capacity");
|
|
5524
|
+
let count = 0;
|
|
5525
|
+
for (const t of tiles) {
|
|
5526
|
+
count += t.morph.width * t.morph.height;
|
|
5527
|
+
if (!Number.isSafeInteger(count) || count > limit)
|
|
5528
|
+
throw new Error("Coordinated morph sample capacity exceeded");
|
|
5529
|
+
}
|
|
5530
|
+
return reconcileMixedSurface(tiles.map((t) => {
|
|
5531
|
+
const evaluated = evaluateTerrainLodMorph(t.morph, t.factor);
|
|
5532
|
+
return {
|
|
5533
|
+
column: t.column,
|
|
5534
|
+
row: t.row,
|
|
5535
|
+
spacing: t.spacing,
|
|
5536
|
+
field: {
|
|
5537
|
+
...evaluated,
|
|
5538
|
+
width: t.morph.width,
|
|
5539
|
+
height: t.morph.height,
|
|
5540
|
+
origin: t.morph.origin,
|
|
5541
|
+
columnStep: t.morph.columnStep,
|
|
5542
|
+
rowStep: t.morph.rowStep,
|
|
5543
|
+
registration: "vertex",
|
|
5544
|
+
diagonal: t.morph.diagonal,
|
|
5545
|
+
heightReference: t.morph.heightReference
|
|
5546
|
+
}
|
|
5547
|
+
};
|
|
5548
|
+
}), { ...options, maxHeightAdjustment: options.maxHeightAdjustment ?? Infinity });
|
|
5549
|
+
}
|
|
5550
|
+
|
|
5551
|
+
// dist/terrain/isobands-mixed.js
|
|
5552
|
+
function createTerrainMixedIsobands(tiles, levels, options = {}) {
|
|
5553
|
+
const maxLevels = options.maxLevels ?? 256;
|
|
5554
|
+
if (!Number.isSafeInteger(maxLevels) || maxLevels < 2 || levels.length < 2 || levels.length > maxLevels || levels.some((v, i) => !Number.isFinite(v) || i > 0 && v <= levels[i - 1]))
|
|
5555
|
+
throw new Error("Invalid mixed isoband levels or capacity");
|
|
5556
|
+
const triangles = tiles.reduce((n, t) => n + 2 * (t.field.width - 1) * (t.field.height - 1) * t.spacing * t.spacing, 0);
|
|
5557
|
+
const maxTriangles = options.maxTriangles ?? 2e6;
|
|
5558
|
+
if (!Number.isSafeInteger(triangles) || !Number.isSafeInteger(maxTriangles) || maxTriangles < 0 || triangles > maxTriangles)
|
|
5559
|
+
throw new Error("Mixed isoband triangle capacity exceeded");
|
|
5560
|
+
const maxTests = options.maxTests ?? 2e7;
|
|
5561
|
+
const surface = reconcileMixedSurface(tiles, { ...options, maxTests });
|
|
5562
|
+
const bands = createTerrainIsobands(surface.tiles.map((t) => new HeightField(t.field)), levels, { ...options, maxTests: maxTests - surface.tests });
|
|
5563
|
+
return {
|
|
5564
|
+
...bands,
|
|
5565
|
+
maxHeightAdjustment: surface.maxHeightAdjustment,
|
|
5566
|
+
sharedSamples: surface.sharedSamples
|
|
5567
|
+
};
|
|
5568
|
+
}
|
|
5569
|
+
|
|
5570
|
+
// dist/terrain/valid-domain-mesh.js
|
|
5571
|
+
var import_cdt2d = __toESM(require("cdt2d"), 1);
|
|
5572
|
+
function capacity(value) {
|
|
5573
|
+
if (!Number.isSafeInteger(value) || value < 1)
|
|
5574
|
+
throw new Error("Invalid mesh work limit");
|
|
5575
|
+
return value;
|
|
5576
|
+
}
|
|
5577
|
+
function createValidDomainTerrainMesh(field, options) {
|
|
5578
|
+
return meshValidDomain(field, options);
|
|
5579
|
+
}
|
|
5580
|
+
function meshValidDomain(field, options, constraints) {
|
|
5581
|
+
const { maxError } = options;
|
|
5582
|
+
const count = field.width * field.height;
|
|
5583
|
+
if (!Number.isFinite(maxError) || maxError < 0)
|
|
5584
|
+
throw new Error("Invalid maximum error");
|
|
5585
|
+
if (count > capacity(options.maxSamples ?? 11e5))
|
|
5586
|
+
throw new Error("Sample limit exceeded");
|
|
5587
|
+
const maxTriangles = capacity(options.maxTriangles ?? 22e5);
|
|
5588
|
+
const maxTests = capacity(options.maxSampleTests ?? 4e7);
|
|
5589
|
+
const regular = createTerrainMesh(field, options);
|
|
5590
|
+
const { width, height, origin, heightReference } = regular;
|
|
5591
|
+
const active = new Uint8Array(count);
|
|
5592
|
+
const boundary = /* @__PURE__ */ new Map();
|
|
5593
|
+
const edgeKey2 = (a, b) => Math.min(a, b) * count + Math.max(a, b);
|
|
5594
|
+
for (let i = 0; i < regular.indices.length; i += 3) {
|
|
5595
|
+
for (let j = 0; j < 3; j++) {
|
|
5596
|
+
const a = regular.indices[i + j], b = regular.indices[i + (j + 1) % 3];
|
|
5597
|
+
active[a] = 1;
|
|
5598
|
+
const key2 = edgeKey2(a, b);
|
|
5599
|
+
if (!boundary.delete(key2))
|
|
5600
|
+
boundary.set(key2, [a, b]);
|
|
5601
|
+
}
|
|
5602
|
+
}
|
|
5603
|
+
const selected = new Int32Array(count).fill(-1);
|
|
5604
|
+
const points = [];
|
|
5605
|
+
const heights = [];
|
|
5606
|
+
const add2 = (i) => {
|
|
5607
|
+
if (selected[i] < 0) {
|
|
5608
|
+
selected[i] = points.length;
|
|
5609
|
+
points.push([i % width, Math.floor(i / width)]);
|
|
5610
|
+
heights.push(regular.positions[3 * i + 2]);
|
|
5611
|
+
}
|
|
5612
|
+
return selected[i];
|
|
5613
|
+
};
|
|
5614
|
+
const edges2 = Array.from(boundary.values(), ([a, b]) => [add2(a), add2(b)]);
|
|
5615
|
+
const extra = constraints == null ? void 0 : constraints(points, heights, edges2, selected, origin[2]);
|
|
5616
|
+
const inDomain = ([a, b, c]) => {
|
|
5617
|
+
const x = (points[a][0] + points[b][0] + points[c][0]) / 3;
|
|
5618
|
+
const y = (points[a][1] + points[b][1] + points[c][1]) / 3;
|
|
5619
|
+
const i = Math.floor(x), j = Math.floor(y);
|
|
5620
|
+
const u = x - i, v = y - j;
|
|
5621
|
+
const valid = (dx, dy) => field.getHeight(i + dx, j + dy) !== void 0;
|
|
5622
|
+
if (field.diagonal === "00-11") {
|
|
5623
|
+
return valid(0, 0) && valid(1, 1) && (u > v ? valid(1, 0) : valid(0, 1));
|
|
5624
|
+
}
|
|
5625
|
+
return valid(1, 0) && valid(0, 1) && (u + v < 1 ? valid(0, 0) : valid(1, 1));
|
|
5626
|
+
};
|
|
5627
|
+
const covered = new Uint8Array(count);
|
|
5628
|
+
let triangles = [];
|
|
5629
|
+
let maxSampleError = 0;
|
|
5630
|
+
let certifiedSamples = 0;
|
|
5631
|
+
let tests = 0;
|
|
5632
|
+
for (let pass = 0; points.length; pass++) {
|
|
5633
|
+
triangles = (0, import_cdt2d.default)(points, (extra == null ? void 0 : extra.edges) ?? edges2, {
|
|
5634
|
+
exterior: Boolean(extra),
|
|
5635
|
+
delaunay: false
|
|
5636
|
+
});
|
|
5637
|
+
if (extra)
|
|
5638
|
+
triangles = triangles.filter(inDomain);
|
|
5639
|
+
if (triangles.length > maxTriangles)
|
|
5640
|
+
throw new Error("Triangle limit exceeded");
|
|
5641
|
+
covered.fill(0);
|
|
5642
|
+
const refine = /* @__PURE__ */ new Set();
|
|
5643
|
+
maxSampleError = 0;
|
|
5644
|
+
certifiedSamples = 0;
|
|
5645
|
+
for (const [a, b, c] of triangles) {
|
|
5646
|
+
const [ax, ay] = points[a], [bx, by] = points[b], [cx, cy] = points[c];
|
|
5647
|
+
const det = (bx - ax) * (cy - ay) - (by - ay) * (cx - ax);
|
|
5648
|
+
if (det === 0)
|
|
5649
|
+
throw new Error("Degenerate triangulation");
|
|
5650
|
+
let worst = maxError;
|
|
5651
|
+
let candidate = -1;
|
|
5652
|
+
const sides = [
|
|
5653
|
+
[ax, ay, bx, by],
|
|
5654
|
+
[bx, by, cx, cy],
|
|
5655
|
+
[cx, cy, ax, ay]
|
|
5656
|
+
];
|
|
5657
|
+
for (let y = Math.ceil(Math.min(ay, by, cy)); y <= Math.floor(Math.max(ay, by, cy)); y++) {
|
|
5658
|
+
let left = Infinity;
|
|
5659
|
+
let right = -Infinity;
|
|
5660
|
+
for (const [x0, y0, x1, y1] of sides) {
|
|
5661
|
+
if (y < Math.min(y0, y1) || y > Math.max(y0, y1))
|
|
5662
|
+
continue;
|
|
5663
|
+
const x = y0 === y1 ? x0 : x0 + (x1 - x0) * (y - y0) / (y1 - y0);
|
|
5664
|
+
left = Math.min(left, x);
|
|
5665
|
+
right = Math.max(right, y0 === y1 ? Math.max(x0, x1) : x);
|
|
5666
|
+
if (y0 === y1)
|
|
5667
|
+
left = Math.min(left, x1);
|
|
5668
|
+
}
|
|
5669
|
+
for (let x = Math.ceil(left - 1e-10); x <= Math.floor(right + 1e-10); x++) {
|
|
5670
|
+
if (++tests > maxTests)
|
|
5671
|
+
throw new Error("Sample test limit exceeded");
|
|
5672
|
+
const i = y * width + x;
|
|
5673
|
+
if (!active[i] || (extra == null ? void 0 : extra.excluded.has(i)))
|
|
5674
|
+
continue;
|
|
5675
|
+
const u = ((x - ax) * (cy - ay) - (y - ay) * (cx - ax)) / det;
|
|
5676
|
+
const v = ((bx - ax) * (y - ay) - (by - ay) * (x - ax)) / det;
|
|
5677
|
+
const w = 1 - u - v;
|
|
5678
|
+
if (Math.min(u, v, w) < -1e-12)
|
|
5679
|
+
continue;
|
|
5680
|
+
if (!covered[i])
|
|
5681
|
+
certifiedSamples++;
|
|
5682
|
+
covered[i] = 1;
|
|
5683
|
+
const error = !extra && (selected[i] === a || selected[i] === b || selected[i] === c) ? 0 : Math.abs(w * heights[a] + u * heights[b] + v * heights[c] - regular.positions[3 * i + 2]);
|
|
5684
|
+
maxSampleError = Math.max(maxSampleError, error);
|
|
5685
|
+
if (error > worst && !(extra == null ? void 0 : extra.fixedSamples.has(i))) {
|
|
5686
|
+
worst = error;
|
|
5687
|
+
candidate = i;
|
|
5688
|
+
}
|
|
5689
|
+
}
|
|
5690
|
+
}
|
|
5691
|
+
if (candidate >= 0)
|
|
5692
|
+
refine.add(candidate);
|
|
5693
|
+
}
|
|
5694
|
+
if (active.some((value, i) => value && !covered[i] && !(extra == null ? void 0 : extra.excluded.has(i))))
|
|
5695
|
+
throw new Error("Incomplete domain triangulation");
|
|
5696
|
+
if (maxSampleError <= maxError)
|
|
5697
|
+
break;
|
|
5698
|
+
if (!Array.from(refine).some((i) => selected[i] < 0))
|
|
5699
|
+
throw new Error("Cannot certify mesh tolerance");
|
|
5700
|
+
if (pass === 63) {
|
|
5701
|
+
for (let i = 0; i < count; i++)
|
|
5702
|
+
if (active[i] && !(extra == null ? void 0 : extra.fixedSamples.has(i)))
|
|
5703
|
+
add2(i);
|
|
5704
|
+
} else {
|
|
5705
|
+
for (const i of refine)
|
|
5706
|
+
add2(i);
|
|
5707
|
+
}
|
|
5708
|
+
}
|
|
5709
|
+
const reverse = field.columnStep[0] * field.rowStep[1] - field.columnStep[1] * field.rowStep[0] < 0;
|
|
5710
|
+
const positions = new Float64Array(points.length * 3);
|
|
5711
|
+
const shift = field.registration === "cell" ? 0.5 : 0;
|
|
5712
|
+
for (let i = 0; i < points.length; i++) {
|
|
5713
|
+
const [x, y] = points[i];
|
|
5714
|
+
positions.set([
|
|
5715
|
+
field.origin[0] - origin[0] + (x + shift) * field.columnStep[0] + (y + shift) * field.rowStep[0],
|
|
5716
|
+
field.origin[1] - origin[1] + (x + shift) * field.columnStep[1] + (y + shift) * field.rowStep[1],
|
|
5717
|
+
heights[i]
|
|
5718
|
+
], i * 3);
|
|
5719
|
+
}
|
|
5720
|
+
const indices = new Uint32Array(triangles.length * 3);
|
|
5721
|
+
for (let i = 0; i < triangles.length; i++) {
|
|
5722
|
+
const [a, b, c] = triangles[i];
|
|
5723
|
+
const [ax, ay] = points[a], [bx, by] = points[b], [cx, cy] = points[c];
|
|
5724
|
+
const clockwise = (bx - ax) * (cy - ay) - (by - ay) * (cx - ax) < 0;
|
|
5725
|
+
indices.set(reverse === clockwise ? [a, b, c] : [a, c, b], 3 * i);
|
|
5726
|
+
}
|
|
5727
|
+
return {
|
|
5728
|
+
positions,
|
|
5729
|
+
indices,
|
|
5730
|
+
gridCoordinates: Float64Array.from(points.flat()),
|
|
5731
|
+
origin,
|
|
5732
|
+
width,
|
|
5733
|
+
height,
|
|
5734
|
+
heightReference,
|
|
5735
|
+
maxSampleError,
|
|
5736
|
+
certifiedSamples
|
|
5737
|
+
};
|
|
5738
|
+
}
|
|
5739
|
+
|
|
5740
|
+
// dist/terrain/breakline-mesh.js
|
|
5741
|
+
var cross = (a, b, c) => (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
|
|
5742
|
+
var onSegment = (a, b, p) => Math.abs(cross(a, b, p)) <= 8 * Number.EPSILON * (Math.abs((b[0] - a[0]) * (p[1] - a[1])) + Math.abs((b[1] - a[1]) * (p[0] - a[0]))) && p[0] >= Math.min(a[0], b[0]) && p[0] <= Math.max(a[0], b[0]) && p[1] >= Math.min(a[1], b[1]) && p[1] <= Math.max(a[1], b[1]);
|
|
5743
|
+
function createBreaklineTerrainMesh(field, options) {
|
|
5744
|
+
const breaklineEdges = [];
|
|
5745
|
+
let overriddenSamples = 0;
|
|
5746
|
+
const mesh = meshValidDomain(field, options, (points, heights, boundary, selected, originZ) => {
|
|
5747
|
+
const ids = new Map(points.map(([x, y], i) => [`${x},${y}`, i]));
|
|
5748
|
+
const fixed = /* @__PURE__ */ new Map();
|
|
5749
|
+
const excluded = /* @__PURE__ */ new Set();
|
|
5750
|
+
const fixedSamples = /* @__PURE__ */ new Set();
|
|
5751
|
+
const add2 = ([x, y, z]) => {
|
|
5752
|
+
if (![x, y, z, z - originZ].every(Number.isFinite) || x < 0 || y < 0 || x > field.width - 1 || y > field.height - 1) {
|
|
5753
|
+
throw new Error("Breakline endpoint is outside the sample rectangle or nonfinite");
|
|
5754
|
+
}
|
|
5755
|
+
const key2 = `${x},${y}`;
|
|
5756
|
+
const id = ids.get(key2) ?? points.length;
|
|
5757
|
+
if (fixed.has(id) && fixed.get(id) !== z)
|
|
5758
|
+
throw new Error("Conflicting breakline heights");
|
|
5759
|
+
if (!ids.has(key2)) {
|
|
5760
|
+
points.push([x, y]);
|
|
5761
|
+
ids.set(key2, id);
|
|
5762
|
+
}
|
|
5763
|
+
fixed.set(id, z);
|
|
5764
|
+
heights[id] = z - originZ;
|
|
5765
|
+
if (Number.isInteger(x) && Number.isInteger(y))
|
|
5766
|
+
selected[y * field.width + x] = id;
|
|
5767
|
+
return id;
|
|
5768
|
+
};
|
|
5769
|
+
if (options.breaklines.length > 2048)
|
|
5770
|
+
throw new Error("Breakline limit exceeded");
|
|
5771
|
+
for (const [a, b] of options.breaklines) {
|
|
5772
|
+
const p = add2(a), q = add2(b);
|
|
5773
|
+
if (p === q)
|
|
5774
|
+
throw new Error("Zero-length breakline");
|
|
5775
|
+
breaklineEdges.push([p, q]);
|
|
5776
|
+
}
|
|
5777
|
+
const edges3 = [];
|
|
5778
|
+
for (const [a, b] of boundary) {
|
|
5779
|
+
const split = [
|
|
5780
|
+
a,
|
|
5781
|
+
...Array.from(fixed.keys()).filter((id) => id !== a && id !== b && onSegment(points[a], points[b], points[id])),
|
|
5782
|
+
b
|
|
5783
|
+
];
|
|
5784
|
+
const [x, y] = points[a];
|
|
5785
|
+
split.sort((i, j) => Math.hypot(points[i][0] - x, points[i][1] - y) - Math.hypot(points[j][0] - x, points[j][1] - y));
|
|
5786
|
+
for (let i = 1; i < split.length; i++)
|
|
5787
|
+
edges3.push([split[i - 1], split[i]]);
|
|
5788
|
+
}
|
|
5789
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5790
|
+
for (const [a, b] of breaklineEdges) {
|
|
5791
|
+
const key2 = `${Math.min(a, b)},${Math.max(a, b)}`;
|
|
5792
|
+
if (seen.has(key2))
|
|
5793
|
+
throw new Error("Duplicate breakline");
|
|
5794
|
+
seen.add(key2);
|
|
5795
|
+
const p = points[a], q = points[b];
|
|
5796
|
+
let coincident = false;
|
|
5797
|
+
for (const [c, d] of edges3) {
|
|
5798
|
+
if (a === c && b === d || a === d && b === c) {
|
|
5799
|
+
coincident = true;
|
|
5800
|
+
continue;
|
|
5801
|
+
}
|
|
5802
|
+
const r = points[c], s = points[d];
|
|
5803
|
+
const intersects2 = Math.sign(cross(p, q, r)) * Math.sign(cross(p, q, s)) < 0 && Math.sign(cross(r, s, p)) * Math.sign(cross(r, s, q)) < 0;
|
|
5804
|
+
if (intersects2 || c !== a && c !== b && onSegment(p, q, r) || d !== a && d !== b && onSegment(p, q, s) || a !== c && a !== d && onSegment(r, s, p) || b !== c && b !== d && onSegment(r, s, q)) {
|
|
5805
|
+
throw new Error("Breaklines and domain edges must meet only at shared endpoints");
|
|
5806
|
+
}
|
|
5807
|
+
}
|
|
5808
|
+
if (!coincident)
|
|
5809
|
+
edges3.push([a, b]);
|
|
5810
|
+
for (let y = Math.ceil(Math.min(p[1], q[1])); y <= Math.floor(Math.max(p[1], q[1])); y++) {
|
|
5811
|
+
for (let x = Math.ceil(Math.min(p[0], q[0])); x <= Math.floor(Math.max(p[0], q[0])); x++) {
|
|
5812
|
+
const source = field.getHeight(x, y);
|
|
5813
|
+
if (source === void 0 || !onSegment(p, q, [x, y]))
|
|
5814
|
+
continue;
|
|
5815
|
+
fixedSamples.add(y * field.width + x);
|
|
5816
|
+
const dx = q[0] - p[0], dy = q[1] - p[1];
|
|
5817
|
+
const f = Math.abs(dx) >= Math.abs(dy) ? (x - p[0]) / dx : (y - p[1]) / dy;
|
|
5818
|
+
const z = (1 - f) * heights[a] + f * heights[b] + originZ;
|
|
5819
|
+
if (Math.abs(source - z) <= options.maxError)
|
|
5820
|
+
continue;
|
|
5821
|
+
if (!options.breaklinesOverrideSamples)
|
|
5822
|
+
throw new Error("Breakline conflicts with source tolerance");
|
|
5823
|
+
excluded.add(y * field.width + x);
|
|
5824
|
+
}
|
|
5825
|
+
}
|
|
5826
|
+
}
|
|
5827
|
+
overriddenSamples = excluded.size;
|
|
5828
|
+
return { edges: edges3, excluded, fixedSamples };
|
|
5829
|
+
});
|
|
5830
|
+
const edges2 = /* @__PURE__ */ new Set();
|
|
5831
|
+
for (let i = 0; i < mesh.indices.length; i += 3) {
|
|
5832
|
+
for (let j = 0; j < 3; j++) {
|
|
5833
|
+
const a = mesh.indices[i + j], b = mesh.indices[i + (j + 1) % 3];
|
|
5834
|
+
edges2.add(`${Math.min(a, b)},${Math.max(a, b)}`);
|
|
5835
|
+
}
|
|
5836
|
+
}
|
|
5837
|
+
if (breaklineEdges.some(([a, b]) => !edges2.has(`${Math.min(a, b)},${Math.max(a, b)}`))) {
|
|
5838
|
+
throw new Error("Breakline was not preserved inside the valid terrain domain");
|
|
5839
|
+
}
|
|
5840
|
+
return { ...mesh, breaklineEdges: Uint32Array.from(breaklineEdges.flat()), overriddenSamples };
|
|
5841
|
+
}
|
|
5842
|
+
|
|
5843
|
+
// dist/terrain/continuous-mesh-error.js
|
|
5844
|
+
var exact = (x) => [x, x];
|
|
5845
|
+
function outward(lo, hi) {
|
|
5846
|
+
if (!Number.isFinite(lo) || !Number.isFinite(hi))
|
|
5847
|
+
throw new Error("Continuous error arithmetic overflow");
|
|
5848
|
+
const result = [
|
|
5849
|
+
lo - Math.max(Number.MIN_VALUE, Math.abs(lo) * Number.EPSILON),
|
|
5850
|
+
hi + Math.max(Number.MIN_VALUE, Math.abs(hi) * Number.EPSILON)
|
|
5851
|
+
];
|
|
5852
|
+
if (!result.every(Number.isFinite))
|
|
5853
|
+
throw new Error("Continuous error arithmetic overflow");
|
|
5854
|
+
return result;
|
|
5855
|
+
}
|
|
5856
|
+
var add = (a, b) => outward(a[0] + b[0], a[1] + b[1]);
|
|
5857
|
+
var sub = (a, b) => outward(a[0] - b[1], a[1] - b[0]);
|
|
5858
|
+
function mul(a, b) {
|
|
5859
|
+
const values = [a[0] * b[0], a[0] * b[1], a[1] * b[0], a[1] * b[1]];
|
|
5860
|
+
return outward(Math.min(...values), Math.max(...values));
|
|
5861
|
+
}
|
|
5862
|
+
function div(a, b) {
|
|
5863
|
+
if (b[0] <= 0 && b[1] >= 0)
|
|
5864
|
+
throw new Error("Degenerate or numerically unresolved mesh triangle");
|
|
5865
|
+
return mul(a, outward(1 / b[1], 1 / b[0]));
|
|
5866
|
+
}
|
|
5867
|
+
var magnitude = (a) => Math.max(-a[0], a[1]);
|
|
5868
|
+
var minimumMagnitude = (a) => Math.max(0, a[0], -a[1]);
|
|
5869
|
+
var evaluate = (p, x, y) => add(p[0], add(mul(p[1], x), mul(p[2], y)));
|
|
5870
|
+
function edge(a, b, column, row) {
|
|
5871
|
+
const dx = sub(exact(b[0]), exact(a[0]));
|
|
5872
|
+
const dy = sub(exact(b[1]), exact(a[1]));
|
|
5873
|
+
return [
|
|
5874
|
+
sub(mul(dx, sub(exact(row), exact(a[1]))), mul(dy, sub(exact(column), exact(a[0])))),
|
|
5875
|
+
[-dy[1], -dy[0]],
|
|
5876
|
+
dx
|
|
5877
|
+
];
|
|
5878
|
+
}
|
|
5879
|
+
function polygon(triangle, column, row) {
|
|
5880
|
+
const [a, b, c] = triangle;
|
|
5881
|
+
const first = edge(a, b, a[0], a[1]);
|
|
5882
|
+
const orientation2 = evaluate(first, sub(exact(c[0]), exact(a[0])), sub(exact(c[1]), exact(a[1])));
|
|
5883
|
+
if (orientation2[0] <= 0 && orientation2[1] >= 0)
|
|
5884
|
+
throw new Error("Degenerate or numerically unresolved mesh triangle");
|
|
5885
|
+
const sides = [edge(a, b, column, row), edge(b, c, column, row), edge(c, a, column, row)];
|
|
5886
|
+
return orientation2[0] > 0 ? sides : sides.map((p) => p.map(([lo, hi]) => [-hi, -lo]));
|
|
5887
|
+
}
|
|
5888
|
+
function boundTerrainMeshError(field, mesh, options = {}) {
|
|
5889
|
+
const { reference = "triangle", gap = 0.05, maxBoxes = 2e6, maxDepth = 12 } = options;
|
|
5890
|
+
const { gridCoordinates: xy, positions, indices, origin } = mesh;
|
|
5891
|
+
if (!["triangle", "bilinear"].includes(reference) || !Number.isFinite(gap) || gap < 0 || !Number.isSafeInteger(maxBoxes) || maxBoxes < 1 || !Number.isSafeInteger(maxDepth) || maxDepth < 0 || maxDepth > 24)
|
|
5892
|
+
throw new Error("Invalid continuous error options");
|
|
5893
|
+
if (mesh.heightReference !== field.heightReference || !Number.isFinite(origin[2]) || positions.length % 3 || xy.length !== positions.length / 3 * 2 || indices.length % 3)
|
|
5894
|
+
throw new Error("Invalid continuous error mesh buffers or height reference");
|
|
5895
|
+
let upperBound = null;
|
|
5896
|
+
let lowerBound = 0;
|
|
5897
|
+
let witness = null;
|
|
5898
|
+
let boxes = 0;
|
|
5899
|
+
for (let i = 0; i < indices.length; i += 3) {
|
|
5900
|
+
const ids = [indices[i], indices[i + 1], indices[i + 2]];
|
|
5901
|
+
if (ids.some((id) => !Number.isSafeInteger(id) || id < 0 || id >= xy.length / 2)) {
|
|
5902
|
+
throw new Error("Invalid continuous error index");
|
|
5903
|
+
}
|
|
5904
|
+
const triangle = [
|
|
5905
|
+
[xy[2 * ids[0]], xy[2 * ids[0] + 1]],
|
|
5906
|
+
[xy[2 * ids[1]], xy[2 * ids[1] + 1]],
|
|
5907
|
+
[xy[2 * ids[2]], xy[2 * ids[2] + 1]]
|
|
5908
|
+
];
|
|
5909
|
+
const [a, b, c] = triangle;
|
|
5910
|
+
const [za, zb, zc] = ids.map((id) => exact(positions[3 * id + 2]));
|
|
5911
|
+
if (triangle.some(([x, y]) => !Number.isFinite(x) || !Number.isFinite(y)) || [za, zb, zc].some((z) => !Number.isFinite(z[0])))
|
|
5912
|
+
throw new Error("Nonfinite continuous error vertex");
|
|
5913
|
+
if (reference === "triangle" && origin[2] === 0 && matchesReferenceHalf(field, triangle, [za[0], zb[0], zc[0]])) {
|
|
5914
|
+
if (++boxes > maxBoxes)
|
|
5915
|
+
throw new Error("Continuous error box limit exceeded");
|
|
5916
|
+
upperBound ?? (upperBound = 0);
|
|
5917
|
+
witness ?? (witness = a);
|
|
5918
|
+
continue;
|
|
5919
|
+
}
|
|
5920
|
+
const dx = sub(exact(b[0]), exact(a[0])), dy = sub(exact(b[1]), exact(a[1]));
|
|
5921
|
+
const ex = sub(exact(c[0]), exact(a[0])), ey = sub(exact(c[1]), exact(a[1]));
|
|
5922
|
+
const det = sub(mul(dx, ey), mul(dy, ex));
|
|
5923
|
+
const dz = sub(zb, za), ez = sub(zc, za);
|
|
5924
|
+
const sx = div(sub(mul(dz, ey), mul(ez, dy)), det);
|
|
5925
|
+
const sy = div(sub(mul(dx, ez), mul(ex, dz)), det);
|
|
5926
|
+
for (let row = Math.max(0, Math.ceil(Math.min(a[1], b[1], c[1])) - 1); row <= Math.min(field.height - 2, Math.floor(Math.max(a[1], b[1], c[1]))); row++) {
|
|
5927
|
+
for (let column = Math.max(0, Math.ceil(Math.min(a[0], b[0], c[0])) - 1); column <= Math.min(field.width - 2, Math.floor(Math.max(a[0], b[0], c[0]))); column++) {
|
|
5928
|
+
let visit = function(constraints, p, mixed, x, y, depth) {
|
|
5929
|
+
if (++boxes > maxBoxes)
|
|
5930
|
+
throw new Error("Continuous error box limit exceeded");
|
|
5931
|
+
if (constraints.some((side) => evaluate(side, x, y)[1] < 0))
|
|
5932
|
+
return;
|
|
5933
|
+
const error = (u2, v2) => add(evaluate(p, u2, v2), mul(mixed, mul(u2, v2)));
|
|
5934
|
+
const centerX = (x[0] + x[1]) / 2;
|
|
5935
|
+
const centerY = (y[0] + y[1]) / 2;
|
|
5936
|
+
const u = exact(centerX), v = exact(centerY);
|
|
5937
|
+
if (constraints.every((side) => evaluate(side, u, v)[0] >= 0)) {
|
|
5938
|
+
const lower = minimumMagnitude(error(u, v));
|
|
5939
|
+
if (!witness || lower > lowerBound) {
|
|
5940
|
+
lowerBound = lower;
|
|
5941
|
+
witness = [column + centerX, row + centerY];
|
|
5942
|
+
}
|
|
5943
|
+
}
|
|
5944
|
+
const upper = Math.max(...x.flatMap((u2) => y.map((v2) => magnitude(error(exact(u2), exact(v2))))));
|
|
5945
|
+
if (upper <= lowerBound + gap || depth === maxDepth) {
|
|
5946
|
+
upperBound = Math.max(upperBound ?? 0, upper);
|
|
5947
|
+
return;
|
|
5948
|
+
}
|
|
5949
|
+
if (x[1] - x[0] >= y[1] - y[0]) {
|
|
5950
|
+
visit(constraints, p, mixed, [x[0], centerX], y, depth + 1);
|
|
5951
|
+
visit(constraints, p, mixed, [centerX, x[1]], y, depth + 1);
|
|
5952
|
+
} else {
|
|
5953
|
+
visit(constraints, p, mixed, x, [y[0], centerY], depth + 1);
|
|
5954
|
+
visit(constraints, p, mixed, x, [centerY, y[1]], depth + 1);
|
|
5955
|
+
}
|
|
5956
|
+
};
|
|
5957
|
+
if (++boxes > maxBoxes)
|
|
5958
|
+
throw new Error("Continuous error box limit exceeded");
|
|
5959
|
+
const vertices = [
|
|
5960
|
+
[0, 0],
|
|
5961
|
+
[1, 0],
|
|
5962
|
+
[0, 1],
|
|
5963
|
+
[1, 1]
|
|
5964
|
+
];
|
|
5965
|
+
const h = vertices.map(([x, y]) => field.getHeight(column + x, row + y));
|
|
5966
|
+
const sides = polygon(triangle, column, row);
|
|
5967
|
+
const base = add(za, add(mul(sx, sub(exact(column), exact(a[0]))), mul(sy, sub(exact(row), exact(a[1])))));
|
|
5968
|
+
const compare = (constant, x, y, mixed, constraints) => visit(constraints, [sub(base, sub(constant, exact(origin[2]))), sub(sx, x), sub(sy, y)], [-mixed[1], -mixed[0]], [0, 1], [0, 1], 0);
|
|
5969
|
+
if (reference === "bilinear") {
|
|
5970
|
+
const [h00, h10, h01, h11] = h;
|
|
5971
|
+
if (h00 === void 0 || h10 === void 0 || h01 === void 0 || h11 === void 0)
|
|
5972
|
+
continue;
|
|
5973
|
+
const x = sub(exact(h10), exact(h00)), y = sub(exact(h01), exact(h00));
|
|
5974
|
+
compare(exact(h00), x, y, sub(sub(exact(h11), exact(h01)), x), sides);
|
|
5975
|
+
} else {
|
|
5976
|
+
const halves = field.diagonal === "00-11" ? [
|
|
5977
|
+
[0, 1, 3],
|
|
5978
|
+
[0, 3, 2]
|
|
5979
|
+
] : [
|
|
5980
|
+
[0, 1, 2],
|
|
5981
|
+
[1, 3, 2]
|
|
5982
|
+
];
|
|
5983
|
+
for (const [j, k, l] of halves) {
|
|
5984
|
+
const z0 = h[j], z1 = h[k], z2 = h[l];
|
|
5985
|
+
if (z0 === void 0 || z1 === void 0 || z2 === void 0)
|
|
5986
|
+
continue;
|
|
5987
|
+
const p = vertices[j], q = vertices[k], r = vertices[l];
|
|
5988
|
+
const x = sub(mul(sub(exact(z1), exact(z0)), exact(r[1] - p[1])), mul(sub(exact(z2), exact(z0)), exact(q[1] - p[1])));
|
|
5989
|
+
const y = sub(mul(exact(q[0] - p[0]), sub(exact(z2), exact(z0))), mul(exact(r[0] - p[0]), sub(exact(z1), exact(z0))));
|
|
5990
|
+
compare(sub(exact(z0), add(mul(x, exact(p[0])), mul(y, exact(p[1])))), x, y, exact(0), [
|
|
5991
|
+
...sides,
|
|
5992
|
+
...polygon([p, q, r], 0, 0)
|
|
5993
|
+
]);
|
|
5994
|
+
}
|
|
5995
|
+
}
|
|
5996
|
+
}
|
|
5997
|
+
}
|
|
5998
|
+
}
|
|
5999
|
+
return {
|
|
6000
|
+
upperBound,
|
|
6001
|
+
lowerBound,
|
|
6002
|
+
witness,
|
|
6003
|
+
boxes,
|
|
6004
|
+
converged: upperBound !== null && upperBound - lowerBound <= gap
|
|
6005
|
+
};
|
|
6006
|
+
}
|
|
6007
|
+
function matchesReferenceHalf(field, triangle, heights) {
|
|
6008
|
+
const column = Math.min(...triangle.map((p) => p[0]));
|
|
6009
|
+
const row = Math.min(...triangle.map((p) => p[1]));
|
|
6010
|
+
if (!Number.isInteger(column) || !Number.isInteger(row) || column < 0 || row < 0 || column >= field.width - 1 || row >= field.height - 1)
|
|
6011
|
+
return false;
|
|
6012
|
+
const corners = /* @__PURE__ */ new Set();
|
|
6013
|
+
for (let i = 0; i < 3; i++) {
|
|
6014
|
+
const [x, y] = triangle[i];
|
|
6015
|
+
const u = x - column, v = y - row;
|
|
6016
|
+
if (u !== 0 && u !== 1 || v !== 0 && v !== 1 || field.getHeight(x, y) !== heights[i])
|
|
6017
|
+
return false;
|
|
6018
|
+
corners.add(u + 2 * v);
|
|
6019
|
+
}
|
|
6020
|
+
return corners.size === 3 && (field.diagonal === "00-11" ? corners.has(0) && corners.has(3) : corners.has(1) && corners.has(2));
|
|
6021
|
+
}
|
|
6022
|
+
|
|
6023
|
+
// dist/terrain/geographic-seam.js
|
|
6024
|
+
function wrapTerrainLongitude(longitude, west, east) {
|
|
6025
|
+
if (![longitude, west, east].every(Number.isFinite) || east <= west || east - west > 360)
|
|
6026
|
+
throw new Error("Invalid terrain longitude interval or query");
|
|
6027
|
+
if (longitude >= west && longitude < east)
|
|
6028
|
+
return longitude;
|
|
6029
|
+
const delta = (longitude % 360 - west % 360) % 360;
|
|
6030
|
+
const offset = delta < 0 ? delta + 360 : delta;
|
|
6031
|
+
const mapped = west + offset;
|
|
6032
|
+
return mapped <= east ? mapped : void 0;
|
|
6033
|
+
}
|
|
6034
|
+
function measureGeographicTerrainSeam(a, b, probes, options = {}) {
|
|
6035
|
+
if (a && b && a.heightReference !== b.heightReference)
|
|
6036
|
+
throw new Error("Terrain seam height references differ");
|
|
6037
|
+
const sample = (field, longitude, latitude) => {
|
|
6038
|
+
if (!field || !Number.isFinite(longitude))
|
|
6039
|
+
return field == null ? void 0 : field.sample(longitude, latitude, options);
|
|
6040
|
+
const mapped = wrapTerrainLongitude(longitude, field.bounds[0], field.bounds[2]);
|
|
6041
|
+
return field.sample(mapped ?? longitude, latitude, options);
|
|
6042
|
+
};
|
|
6043
|
+
return probes.map(([longitude, latitude]) => {
|
|
6044
|
+
const left = sample(a, longitude, latitude);
|
|
6045
|
+
const right = sample(b, longitude, latitude);
|
|
6046
|
+
const valid = (left == null ? void 0 : left.status) === TerrainSampleStatus.VALID && (right == null ? void 0 : right.status) === TerrainSampleStatus.VALID;
|
|
6047
|
+
const derivatives = (left == null ? void 0 : left.gradientStatus) === TerrainSampleStatus.VALID && (right == null ? void 0 : right.gradientStatus) === TerrainSampleStatus.VALID;
|
|
6048
|
+
const normalAngle = derivatives ? Math.atan2(Math.hypot(left.normalY * right.normalZ - left.normalZ * right.normalY, left.normalZ * right.normalX - left.normalX * right.normalZ, left.normalX * right.normalY - left.normalY * right.normalX), left.normalX * right.normalX + left.normalY * right.normalY + left.normalZ * right.normalZ) : null;
|
|
6049
|
+
return {
|
|
6050
|
+
longitude,
|
|
6051
|
+
latitude,
|
|
6052
|
+
statusA: (left == null ? void 0 : left.status) ?? TerrainSampleStatus.NOT_RESIDENT,
|
|
6053
|
+
statusB: (right == null ? void 0 : right.status) ?? TerrainSampleStatus.NOT_RESIDENT,
|
|
6054
|
+
gradientStatusA: (left == null ? void 0 : left.gradientStatus) ?? TerrainSampleStatus.NOT_RESIDENT,
|
|
6055
|
+
gradientStatusB: (right == null ? void 0 : right.gradientStatus) ?? TerrainSampleStatus.NOT_RESIDENT,
|
|
6056
|
+
heightJump: valid ? Math.abs(left.height - right.height) : null,
|
|
6057
|
+
normalAngle
|
|
6058
|
+
};
|
|
6059
|
+
});
|
|
6060
|
+
}
|
|
6061
|
+
|
|
6062
|
+
// dist/terrain/lod-select.js
|
|
6063
|
+
function selectTerrainLod(roots, view) {
|
|
6064
|
+
var _a;
|
|
6065
|
+
const { position, verticalFov, viewportHeight, targetPixels, hysteresis = 0.2, previouslyRefined, maxVisited = 1e5 } = view;
|
|
6066
|
+
if (!position.every(Number.isFinite) || !Number.isFinite(verticalFov) || verticalFov <= 0 || verticalFov >= Math.PI || !Number.isFinite(viewportHeight) || viewportHeight <= 0 || !Number.isFinite(targetPixels) || targetPixels <= 0 || !(hysteresis >= 0 && hysteresis < 1) || !Number.isSafeInteger(maxVisited) || maxVisited < 1)
|
|
6067
|
+
throw new Error("Invalid terrain LOD view");
|
|
6068
|
+
const scale = viewportHeight / (2 * Math.tan(verticalFov / 2));
|
|
6069
|
+
if (!Number.isFinite(scale))
|
|
6070
|
+
throw new Error("Terrain LOD projection scale overflow");
|
|
6071
|
+
const selected = [];
|
|
6072
|
+
const refined = /* @__PURE__ */ new Set();
|
|
6073
|
+
const unavailable = [];
|
|
6074
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6075
|
+
const pending = [...roots].reverse();
|
|
6076
|
+
while (pending.length) {
|
|
6077
|
+
const tile = pending.pop();
|
|
6078
|
+
if (seen.size >= maxVisited)
|
|
6079
|
+
throw new Error("Terrain LOD visit limit exceeded");
|
|
6080
|
+
if (seen.has(tile.id))
|
|
6081
|
+
throw new Error("Duplicate terrain LOD tile or cycle");
|
|
6082
|
+
seen.add(tile.id);
|
|
6083
|
+
if (![...tile.min, ...tile.max, tile.geometricError].every(Number.isFinite) || tile.geometricError < 0 || tile.min.some((n, i) => n > tile.max[i]))
|
|
6084
|
+
throw new Error("Invalid terrain LOD tile bounds or error");
|
|
6085
|
+
if (!tile.resident) {
|
|
6086
|
+
unavailable.push(tile.id);
|
|
6087
|
+
continue;
|
|
6088
|
+
}
|
|
6089
|
+
const distance = Math.hypot(...position.map((n, i) => Math.max(tile.min[i] - n, n - tile.max[i], 0)));
|
|
6090
|
+
const pixels = tile.geometricError === 0 ? 0 : tile.geometricError / distance * scale;
|
|
6091
|
+
const threshold = targetPixels * ((previouslyRefined == null ? void 0 : previouslyRefined.has(tile.id)) ? 1 - hysteresis : 1);
|
|
6092
|
+
if (pixels > threshold && ((_a = tile.children) == null ? void 0 : _a.length) && tile.children.every((child) => child.resident)) {
|
|
6093
|
+
if (pending.length + seen.size + tile.children.length > maxVisited)
|
|
6094
|
+
throw new Error("Terrain LOD visit limit exceeded");
|
|
6095
|
+
refined.add(tile.id);
|
|
6096
|
+
for (let i = tile.children.length - 1; i >= 0; i--)
|
|
6097
|
+
pending.push(tile.children[i]);
|
|
6098
|
+
} else {
|
|
6099
|
+
selected.push({ tile, pixels });
|
|
6100
|
+
}
|
|
6101
|
+
}
|
|
6102
|
+
return { selected, refined, unavailable };
|
|
6103
|
+
}
|
|
6104
|
+
|
|
6105
|
+
// dist/terrain/lod-stitch.js
|
|
6106
|
+
function stitchTerrainLodCut(input, seams) {
|
|
6107
|
+
const meshes = input.slice();
|
|
6108
|
+
const paired = [];
|
|
6109
|
+
for (const { a, edgeA, b, edgeB, options, offsetBX = 0 } of seams) {
|
|
6110
|
+
if (a === b || !Number.isInteger(a) || !Number.isInteger(b) || !meshes[a] || !meshes[b])
|
|
6111
|
+
throw new Error("Invalid terrain LOD seam tile index");
|
|
6112
|
+
if (!Number.isFinite(offsetBX))
|
|
6113
|
+
throw new Error("Invalid terrain LOD seam offset");
|
|
6114
|
+
const meshB = meshes[b];
|
|
6115
|
+
const shiftedB = offsetBX === 0 ? meshB : {
|
|
6116
|
+
...meshB,
|
|
6117
|
+
origin: [meshB.origin[0] + offsetBX, meshB.origin[1], meshB.origin[2]]
|
|
6118
|
+
};
|
|
6119
|
+
const result = stitchTerrainMeshEdges(meshes[a], edgeA, shiftedB, edgeB, options);
|
|
6120
|
+
meshes[a] = result.a;
|
|
6121
|
+
meshes[b] = offsetBX === 0 ? result.b : {
|
|
6122
|
+
...result.b,
|
|
6123
|
+
origin: [result.b.origin[0] - offsetBX, result.b.origin[1], result.b.origin[2]]
|
|
6124
|
+
};
|
|
6125
|
+
paired.push({ a, b, idsA: result.seamA, idsB: result.seamB, offsetBX });
|
|
6126
|
+
}
|
|
6127
|
+
for (const { a, b, idsA, idsB, offsetBX } of paired) {
|
|
6128
|
+
const ma = meshes[a], mb = meshes[b];
|
|
6129
|
+
const path = (mesh, ids) => {
|
|
6130
|
+
const links = /* @__PURE__ */ new Set();
|
|
6131
|
+
for (let i = 1; i < ids.length; i++) {
|
|
6132
|
+
links.add(`${Math.min(ids[i - 1], ids[i])},${Math.max(ids[i - 1], ids[i])}`);
|
|
6133
|
+
}
|
|
6134
|
+
for (let i = 0; i < mesh.indices.length; i += 3) {
|
|
6135
|
+
for (let j = 0; j < 3; j++) {
|
|
6136
|
+
const p = mesh.indices[i + j], q = mesh.indices[i + (j + 1) % 3];
|
|
6137
|
+
links.delete(`${Math.min(p, q)},${Math.max(p, q)}`);
|
|
6138
|
+
}
|
|
6139
|
+
}
|
|
6140
|
+
return links.size === 0;
|
|
6141
|
+
};
|
|
6142
|
+
if (!path(ma, idsA) || !path(mb, idsB))
|
|
6143
|
+
throw new Error("Overlapping terrain LOD seam ranges require a common subdivision");
|
|
6144
|
+
for (let i = 0; i < idsA.length; i++) {
|
|
6145
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
6146
|
+
const offset = mb.origin[axis] + (axis === 0 ? offsetBX : 0) - ma.origin[axis];
|
|
6147
|
+
const av = ma.positions[3 * idsA[i] + axis], bv = mb.positions[3 * idsB[i] + axis];
|
|
6148
|
+
const residual = av - bv - offset;
|
|
6149
|
+
const roundoff = 8 * Number.EPSILON * (Math.abs(av) + Math.abs(bv) + Math.abs(offset));
|
|
6150
|
+
if (!Number.isFinite(residual) || Math.abs(residual) > roundoff)
|
|
6151
|
+
throw new Error("Incompatible terrain LOD seam heights or shared corners");
|
|
6152
|
+
}
|
|
6153
|
+
}
|
|
6154
|
+
}
|
|
6155
|
+
return meshes;
|
|
6156
|
+
}
|
|
6157
|
+
|
|
6158
|
+
// dist/terrain/breakline-preprocess.js
|
|
6159
|
+
function splitTerrainBreaklines(input, options = {}) {
|
|
6160
|
+
const { heightTolerance = 1e-8, maxPairTests = 21e5, maxSegments = 2048 } = options;
|
|
6161
|
+
if (!Number.isFinite(heightTolerance) || heightTolerance < 0 || ![maxPairTests, maxSegments].every((n) => Number.isSafeInteger(n) && n >= 0 && n <= 4294967295))
|
|
6162
|
+
throw new Error("Invalid breakline split limits");
|
|
6163
|
+
if (input.length > maxSegments || input.length * (input.length - 1) / 2 > maxPairTests)
|
|
6164
|
+
throw new Error("Breakline preprocessing work limit exceeded");
|
|
6165
|
+
const vertices = /* @__PURE__ */ new Map();
|
|
6166
|
+
const canonical = (p) => {
|
|
6167
|
+
if (!p.every(Number.isFinite))
|
|
6168
|
+
throw new Error("Invalid breakline vertex");
|
|
6169
|
+
const key2 = `${p[0]},${p[1]}`;
|
|
6170
|
+
const prior = vertices.get(key2);
|
|
6171
|
+
if (prior) {
|
|
6172
|
+
if (Math.abs(prior[2] - p[2]) > heightTolerance)
|
|
6173
|
+
throw new Error("Conflicting breakline heights");
|
|
6174
|
+
return prior;
|
|
6175
|
+
}
|
|
6176
|
+
const point = [...p];
|
|
6177
|
+
vertices.set(key2, point);
|
|
6178
|
+
return point;
|
|
6179
|
+
};
|
|
6180
|
+
const lines = input.map(([a, b]) => {
|
|
6181
|
+
const p = canonical(a), q = canonical(b);
|
|
6182
|
+
if (p === q)
|
|
6183
|
+
throw new Error("Zero-length breakline");
|
|
6184
|
+
const knots = [
|
|
6185
|
+
{ t: 0, point: p },
|
|
6186
|
+
{ t: 1, point: q }
|
|
6187
|
+
];
|
|
6188
|
+
return { p, q, dx: q[0] - p[0], dy: q[1] - p[1], knots };
|
|
6189
|
+
});
|
|
6190
|
+
let count = input.length;
|
|
6191
|
+
const add2 = (knots, t, point) => {
|
|
6192
|
+
if (knots.some((k) => k.point === point))
|
|
6193
|
+
return;
|
|
6194
|
+
if (knots.some((k) => k.t === t))
|
|
6195
|
+
throw new Error("Unresolved coincident breakline intersections");
|
|
6196
|
+
if (++count > maxSegments)
|
|
6197
|
+
throw new Error("Breakline output limit exceeded");
|
|
6198
|
+
knots.push({ t, point });
|
|
6199
|
+
};
|
|
6200
|
+
const cross3 = (ax, ay, bx, by) => ax * by - ay * bx;
|
|
6201
|
+
for (let i = 0; i < lines.length; i++) {
|
|
6202
|
+
const a = lines[i];
|
|
6203
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
6204
|
+
const b = lines[j];
|
|
6205
|
+
const x = b.p[0] - a.p[0], y = b.p[1] - a.p[1];
|
|
6206
|
+
const det = cross3(a.dx, a.dy, b.dx, b.dy);
|
|
6207
|
+
const u = cross3(x, y, a.dx, a.dy), t = cross3(x, y, b.dx, b.dy);
|
|
6208
|
+
if (![det, u, t].every(Number.isFinite))
|
|
6209
|
+
throw new Error("Breakline intersection overflow");
|
|
6210
|
+
if (det === 0) {
|
|
6211
|
+
if (u !== 0 || t !== 0)
|
|
6212
|
+
continue;
|
|
6213
|
+
const axis = Math.abs(a.dx) >= Math.abs(a.dy) ? 0 : 1;
|
|
6214
|
+
if (Math.max(Math.min(a.p[axis], a.q[axis]), Math.min(b.p[axis], b.q[axis])) < Math.min(Math.max(a.p[axis], a.q[axis]), Math.max(b.p[axis], b.q[axis])))
|
|
6215
|
+
throw new Error("Overlapping collinear breaklines");
|
|
6216
|
+
continue;
|
|
6217
|
+
}
|
|
6218
|
+
const fa = t / det, fb = u / det;
|
|
6219
|
+
if (fa < 0 || fa > 1 || fb < 0 || fb > 1)
|
|
6220
|
+
continue;
|
|
6221
|
+
const za = (1 - fa) * a.p[2] + fa * a.q[2], zb = (1 - fb) * b.p[2] + fb * b.q[2];
|
|
6222
|
+
if (!Number.isFinite(za) || !Number.isFinite(zb) || Math.abs(za - zb) > heightTolerance)
|
|
6223
|
+
throw new Error("Conflicting breakline heights at intersection");
|
|
6224
|
+
const point = canonical(fa === 0 ? a.p : fa === 1 ? a.q : fb === 0 ? b.p : fb === 1 ? b.q : [a.p[0] + fa * a.dx, a.p[1] + fa * a.dy, za]);
|
|
6225
|
+
add2(a.knots, fa, point);
|
|
6226
|
+
add2(b.knots, fb, point);
|
|
6227
|
+
}
|
|
6228
|
+
}
|
|
6229
|
+
const segments = [];
|
|
6230
|
+
const sourceSegments = new Uint32Array(count);
|
|
6231
|
+
for (let i = 0; i < lines.length; i++) {
|
|
6232
|
+
const knots = lines[i].knots.sort((a, b) => a.t - b.t);
|
|
6233
|
+
for (let j = 1; j < knots.length; j++) {
|
|
6234
|
+
sourceSegments[segments.length] = i;
|
|
6235
|
+
segments.push([knots[j - 1].point, knots[j].point]);
|
|
6236
|
+
}
|
|
6237
|
+
}
|
|
6238
|
+
return { segments, sourceSegments };
|
|
6239
|
+
}
|
|
6240
|
+
|
|
6241
|
+
// dist/terrain/valid-domain-regions.js
|
|
6242
|
+
function updateTerrainValidDomainMeshRegions(previous, field, dirty, options) {
|
|
6243
|
+
const { maxError, maxTrianglesPerRegion, maxSampleTestsPerRegion } = options;
|
|
6244
|
+
if (!Number.isFinite(maxError) || maxError < 0)
|
|
6245
|
+
throw new Error("Invalid regional mesh error");
|
|
6246
|
+
for (const limit of [maxTrianglesPerRegion, maxSampleTestsPerRegion]) {
|
|
6247
|
+
if (limit !== void 0 && (!Number.isSafeInteger(limit) || limit < 1))
|
|
6248
|
+
throw new Error("Invalid regional mesh work limit");
|
|
6249
|
+
}
|
|
6250
|
+
const configuration = `valid-domain:${maxError}:${maxTrianglesPerRegion ?? ""}:${maxSampleTestsPerRegion ?? ""}`;
|
|
6251
|
+
return updateMeshRegions(previous, field, dirty, options, configuration, (region) => createValidDomainTerrainMesh(region, {
|
|
6252
|
+
maxError,
|
|
6253
|
+
maxTriangles: maxTrianglesPerRegion,
|
|
6254
|
+
maxSampleTests: maxSampleTestsPerRegion
|
|
6255
|
+
}));
|
|
6256
|
+
}
|
|
6257
|
+
|
|
6258
|
+
// dist/terrain/mesh-coverage.js
|
|
6259
|
+
function gcd(a, b) {
|
|
6260
|
+
if (a < 0n)
|
|
6261
|
+
a = -a;
|
|
6262
|
+
if (b < 0n)
|
|
6263
|
+
b = -b;
|
|
6264
|
+
while (b !== 0n)
|
|
6265
|
+
[a, b] = [b, a % b];
|
|
6266
|
+
return a;
|
|
6267
|
+
}
|
|
6268
|
+
function certifyTerrainMeshCoverage(field, mesh, options = {}) {
|
|
6269
|
+
var _a, _b;
|
|
6270
|
+
const { reference = "triangle", maxTriangles = 2e6 } = options;
|
|
6271
|
+
const referenceMesh = typeof reference === "object" ? reference : null;
|
|
6272
|
+
const validShape = (input) => input.indices.length % 3 === 0 && input.gridCoordinates.length % 2 === 0;
|
|
6273
|
+
if (!Number.isSafeInteger(maxTriangles) || maxTriangles < 1 || !referenceMesh && reference !== "triangle" && reference !== "bilinear" || !validShape(mesh) || referenceMesh && !validShape(referenceMesh))
|
|
6274
|
+
throw new Error("Invalid terrain coverage input");
|
|
6275
|
+
const trianglesVisited = mesh.indices.length / 3 + (referenceMesh ? referenceMesh.indices.length / 3 : 2 * (field.width - 1) * (field.height - 1));
|
|
6276
|
+
if (trianglesVisited > maxTriangles) {
|
|
6277
|
+
return {
|
|
6278
|
+
status: "budget-exhausted",
|
|
6279
|
+
unmatchedSegments: 0,
|
|
6280
|
+
witness: null,
|
|
6281
|
+
trianglesVisited: 0,
|
|
6282
|
+
residualEdges: 0
|
|
6283
|
+
};
|
|
6284
|
+
}
|
|
6285
|
+
const bits2 = new DataView(new ArrayBuffer(8));
|
|
6286
|
+
function exact2(value) {
|
|
6287
|
+
bits2.setFloat64(0, value);
|
|
6288
|
+
const raw = bits2.getBigUint64(0);
|
|
6289
|
+
const exponent = Number(raw >> 52n & 2047n);
|
|
6290
|
+
const fraction = raw & (1n << 52n) - 1n;
|
|
6291
|
+
const integer2 = exponent === 0 ? fraction : (1n << 52n | fraction) << BigInt(exponent - 1);
|
|
6292
|
+
return value < 0 ? -integer2 : integer2;
|
|
6293
|
+
}
|
|
6294
|
+
const vertices = [];
|
|
6295
|
+
const vertexIds = /* @__PURE__ */ new Map();
|
|
6296
|
+
const edges2 = /* @__PURE__ */ new Map();
|
|
6297
|
+
function vertex(x, y) {
|
|
6298
|
+
if (!Number.isFinite(x) || !Number.isFinite(y))
|
|
6299
|
+
throw new Error("Nonfinite coverage coordinate");
|
|
6300
|
+
const key2 = `${x},${y}`;
|
|
6301
|
+
const previous = vertexIds.get(key2);
|
|
6302
|
+
if (previous !== void 0)
|
|
6303
|
+
return previous;
|
|
6304
|
+
const id = vertices.length;
|
|
6305
|
+
vertices.push([x, y]);
|
|
6306
|
+
vertexIds.set(key2, id);
|
|
6307
|
+
return id;
|
|
6308
|
+
}
|
|
6309
|
+
function edge2(a, b, weight) {
|
|
6310
|
+
var _a2;
|
|
6311
|
+
if (a > b) {
|
|
6312
|
+
[a, b] = [b, a];
|
|
6313
|
+
weight = -weight;
|
|
6314
|
+
}
|
|
6315
|
+
const key2 = b < 2 ** 26 ? a * 2 ** 26 + b : `${a},${b}`;
|
|
6316
|
+
const sum = (((_a2 = edges2.get(key2)) == null ? void 0 : _a2.weight) ?? 0) + weight;
|
|
6317
|
+
if (sum === 0)
|
|
6318
|
+
edges2.delete(key2);
|
|
6319
|
+
else
|
|
6320
|
+
edges2.set(key2, { a, b, weight: sum });
|
|
6321
|
+
}
|
|
6322
|
+
function triangle(a, b, c, weight) {
|
|
6323
|
+
edge2(a, b, weight);
|
|
6324
|
+
edge2(b, c, weight);
|
|
6325
|
+
edge2(c, a, weight);
|
|
6326
|
+
}
|
|
6327
|
+
function addMesh({ indices, gridCoordinates }, weight) {
|
|
6328
|
+
for (let i = 0; i < indices.length; i += 3) {
|
|
6329
|
+
const ids = [indices[i], indices[i + 1], indices[i + 2]].map((id) => {
|
|
6330
|
+
if (!Number.isSafeInteger(id) || id < 0 || id >= gridCoordinates.length / 2)
|
|
6331
|
+
throw new Error("Invalid coverage vertex index");
|
|
6332
|
+
return vertex(gridCoordinates[id * 2], gridCoordinates[id * 2 + 1]);
|
|
6333
|
+
});
|
|
6334
|
+
const [a, b, c] = ids.map((id) => vertices[id]);
|
|
6335
|
+
const left = (b[0] - a[0]) * (c[1] - a[1]);
|
|
6336
|
+
const right = (b[1] - a[1]) * (c[0] - a[0]);
|
|
6337
|
+
const det = left - right;
|
|
6338
|
+
const limit = 8 * Number.EPSILON * (Math.abs(left) + Math.abs(right)) + 8 * Number.MIN_VALUE;
|
|
6339
|
+
let sign2 = Math.sign(det);
|
|
6340
|
+
if (!Number.isFinite(det) || Math.abs(det) <= limit) {
|
|
6341
|
+
const [ax, ay] = a.map(exact2), [bx, by] = b.map(exact2), [cx, cy] = c.map(exact2);
|
|
6342
|
+
const determinant = (bx - ax) * (cy - ay) - (by - ay) * (cx - ax);
|
|
6343
|
+
sign2 = determinant > 0n ? 1 : determinant < 0n ? -1 : 0;
|
|
6344
|
+
}
|
|
6345
|
+
if (!sign2)
|
|
6346
|
+
throw new Error("Degenerate coverage triangle");
|
|
6347
|
+
triangle(ids[0], ids[1], ids[2], weight * sign2);
|
|
6348
|
+
}
|
|
6349
|
+
}
|
|
6350
|
+
addMesh(mesh, 1);
|
|
6351
|
+
if (referenceMesh)
|
|
6352
|
+
addMesh(referenceMesh, -1);
|
|
6353
|
+
else
|
|
6354
|
+
for (let y = 0; y < field.height - 1; y++) {
|
|
6355
|
+
for (let x = 0; x < field.width - 1; x++) {
|
|
6356
|
+
const valid = [
|
|
6357
|
+
field.getHeight(x, y),
|
|
6358
|
+
field.getHeight(x + 1, y),
|
|
6359
|
+
field.getHeight(x, y + 1),
|
|
6360
|
+
field.getHeight(x + 1, y + 1)
|
|
6361
|
+
].map((z) => z !== void 0);
|
|
6362
|
+
if (reference === "bilinear" && !valid.every(Boolean))
|
|
6363
|
+
continue;
|
|
6364
|
+
const corners = [
|
|
6365
|
+
[x, y],
|
|
6366
|
+
[x + 1, y],
|
|
6367
|
+
[x, y + 1],
|
|
6368
|
+
[x + 1, y + 1]
|
|
6369
|
+
];
|
|
6370
|
+
const faces = field.diagonal === "00-11" ? [
|
|
6371
|
+
[0, 1, 3],
|
|
6372
|
+
[0, 3, 2]
|
|
6373
|
+
] : [
|
|
6374
|
+
[0, 1, 2],
|
|
6375
|
+
[1, 3, 2]
|
|
6376
|
+
];
|
|
6377
|
+
for (const [a, b, c] of faces) {
|
|
6378
|
+
if (!valid[a] || !valid[b] || !valid[c])
|
|
6379
|
+
continue;
|
|
6380
|
+
triangle(vertex(...corners[a]), vertex(...corners[b]), vertex(...corners[c]), -1);
|
|
6381
|
+
}
|
|
6382
|
+
}
|
|
6383
|
+
}
|
|
6384
|
+
const lines = /* @__PURE__ */ new Map();
|
|
6385
|
+
for (const { a, b, weight } of edges2.values()) {
|
|
6386
|
+
const p = vertices[a], q = vertices[b];
|
|
6387
|
+
const [x, y] = p.map(exact2), [u, v] = q.map(exact2);
|
|
6388
|
+
const divisor = gcd(u - x, v - y);
|
|
6389
|
+
let dx = (u - x) / divisor, dy = (v - y) / divisor;
|
|
6390
|
+
if (dx < 0n || dx === 0n && dy < 0n)
|
|
6391
|
+
[dx, dy] = [-dx, -dy];
|
|
6392
|
+
const key2 = `${dx},${dy},${dx * y - dy * x}`;
|
|
6393
|
+
let events = lines.get(key2);
|
|
6394
|
+
if (!events) {
|
|
6395
|
+
events = /* @__PURE__ */ new Map();
|
|
6396
|
+
lines.set(key2, events);
|
|
6397
|
+
}
|
|
6398
|
+
const axis = dx === 0n ? 1 : 0;
|
|
6399
|
+
const delta = weight;
|
|
6400
|
+
events.set(p[axis], { point: p, delta: (((_a = events.get(p[axis])) == null ? void 0 : _a.delta) ?? 0) + delta });
|
|
6401
|
+
events.set(q[axis], { point: q, delta: (((_b = events.get(q[axis])) == null ? void 0 : _b.delta) ?? 0) - delta });
|
|
6402
|
+
}
|
|
6403
|
+
let unmatchedSegments = 0;
|
|
6404
|
+
let witness = null;
|
|
6405
|
+
for (const events of lines.values()) {
|
|
6406
|
+
const sorted = [...events].sort(([a], [b]) => a - b);
|
|
6407
|
+
let jump = 0;
|
|
6408
|
+
for (let i = 0; i + 1 < sorted.length; i++) {
|
|
6409
|
+
jump += sorted[i][1].delta;
|
|
6410
|
+
if (!jump)
|
|
6411
|
+
continue;
|
|
6412
|
+
unmatchedSegments++;
|
|
6413
|
+
witness ?? (witness = { start: sorted[i][1].point, end: sorted[i + 1][1].point, multiplicityJump: jump });
|
|
6414
|
+
}
|
|
6415
|
+
}
|
|
6416
|
+
return {
|
|
6417
|
+
status: unmatchedSegments ? "mismatch" : "certified",
|
|
6418
|
+
unmatchedSegments,
|
|
6419
|
+
witness,
|
|
6420
|
+
trianglesVisited,
|
|
6421
|
+
residualEdges: edges2.size
|
|
6422
|
+
};
|
|
6423
|
+
}
|
|
6424
|
+
|
|
6425
|
+
// dist/geographic-tiles.js
|
|
6426
|
+
function getGeographicTileBounds(tile) {
|
|
6427
|
+
const size = gridSize(tile.level);
|
|
6428
|
+
if (![tile.x, tile.y].every((v) => Number.isInteger(v) && v >= 0 && v < size))
|
|
6429
|
+
throw new RangeError("Tile coordinates must be integers inside the level grid");
|
|
6430
|
+
return [
|
|
6431
|
+
-180 + 360 * tile.x / size,
|
|
6432
|
+
90 - 180 * (tile.y + 1) / size,
|
|
6433
|
+
-180 + 360 * (tile.x + 1) / size,
|
|
6434
|
+
90 - 180 * tile.y / size
|
|
6435
|
+
];
|
|
6436
|
+
}
|
|
6437
|
+
function gridSize(level) {
|
|
6438
|
+
if (!Number.isInteger(level) || level < 0 || level > 30)
|
|
6439
|
+
throw new RangeError("Level must be an integer from 0 through 30");
|
|
6440
|
+
return 2 ** level;
|
|
6441
|
+
}
|
|
6442
|
+
|
|
6443
|
+
// dist/terrain/geographic-neighbor.js
|
|
6444
|
+
function getGeographicTerrainNeighbor(tile, edge2) {
|
|
6445
|
+
getGeographicTileBounds(tile);
|
|
6446
|
+
const { x, y, level } = tile;
|
|
6447
|
+
const size = 2 ** level;
|
|
6448
|
+
switch (edge2) {
|
|
6449
|
+
case "west":
|
|
6450
|
+
case "east": {
|
|
6451
|
+
const ownerX = edge2 === "west" ? x : (x + 1) % size;
|
|
6452
|
+
return {
|
|
6453
|
+
owner: { x: ownerX, y, level },
|
|
6454
|
+
ownerEdge: "west",
|
|
6455
|
+
other: { x: (ownerX + size - 1) % size, y, level },
|
|
6456
|
+
otherEdge: "east",
|
|
6457
|
+
crossesAntimeridian: ownerX === 0
|
|
6458
|
+
};
|
|
6459
|
+
}
|
|
6460
|
+
case "north":
|
|
6461
|
+
case "south": {
|
|
6462
|
+
const ownerY = edge2 === "north" ? y : y + 1;
|
|
6463
|
+
if (ownerY === 0 || ownerY === size)
|
|
6464
|
+
return null;
|
|
6465
|
+
return {
|
|
6466
|
+
owner: { x, y: ownerY, level },
|
|
6467
|
+
ownerEdge: "north",
|
|
6468
|
+
other: { x, y: ownerY - 1, level },
|
|
6469
|
+
otherEdge: "south",
|
|
6470
|
+
crossesAntimeridian: false
|
|
6471
|
+
};
|
|
6472
|
+
}
|
|
6473
|
+
default:
|
|
6474
|
+
throw new RangeError("Invalid geographic terrain edge");
|
|
6475
|
+
}
|
|
6476
|
+
}
|
|
6477
|
+
|
|
6478
|
+
// dist/terrain/sweep-sphere.js
|
|
6479
|
+
function sweepTerrainSphere(surface, start, end, radius, { fractionTolerance = 1e-6, maxWork = 1e5 } = {}) {
|
|
6480
|
+
if (!(fractionTolerance >= Number.EPSILON && fractionTolerance <= 1) || !Number.isSafeInteger(maxWork) || maxWork < 0)
|
|
6481
|
+
throw new RangeError("Invalid terrain sphere sweep limits");
|
|
6482
|
+
const delta = end.map((value, axis) => value - start[axis]);
|
|
6483
|
+
if (start.length !== 3 || end.length !== 3 || !start.every(Number.isFinite) || !end.every(Number.isFinite) || !delta.every(Number.isFinite) || !Number.isFinite(radius) || radius < 0)
|
|
6484
|
+
throw new RangeError("Invalid terrain sphere sweep motion or radius");
|
|
6485
|
+
let work = 0;
|
|
6486
|
+
let lower = 0;
|
|
6487
|
+
let upper = 1;
|
|
6488
|
+
const prefix = (fraction) => {
|
|
6489
|
+
const endPoint = fraction === 0 ? start : fraction === 1 ? end : [
|
|
6490
|
+
start[0] + delta[0] * fraction,
|
|
6491
|
+
start[1] + delta[1] * fraction,
|
|
6492
|
+
start[2] + delta[2] * fraction
|
|
6493
|
+
];
|
|
6494
|
+
const query = surface.intersectCapsule(start, endPoint, radius, {
|
|
6495
|
+
maxWork: maxWork - work,
|
|
6496
|
+
maxContacts: 1
|
|
6497
|
+
});
|
|
6498
|
+
work += query.work;
|
|
6499
|
+
return query;
|
|
6500
|
+
};
|
|
6501
|
+
const initial = prefix(0);
|
|
6502
|
+
if (initial.result[0])
|
|
6503
|
+
return { status: "hit", fraction: 0, lowerFraction: 0, contact: initial.result[0], work };
|
|
6504
|
+
if (!initial.complete)
|
|
6505
|
+
return { status: "incomplete", work };
|
|
6506
|
+
const full = prefix(1);
|
|
6507
|
+
let contact = full.result[0];
|
|
6508
|
+
if (!contact)
|
|
6509
|
+
return { status: full.complete ? "miss" : "incomplete", work };
|
|
6510
|
+
while (upper - lower > fractionTolerance) {
|
|
6511
|
+
const middle = (lower + upper) / 2;
|
|
6512
|
+
const query = prefix(middle);
|
|
6513
|
+
if (query.result[0]) {
|
|
6514
|
+
upper = middle;
|
|
6515
|
+
contact = query.result[0];
|
|
6516
|
+
} else if (query.complete) {
|
|
6517
|
+
lower = middle;
|
|
6518
|
+
} else {
|
|
6519
|
+
return { status: "incomplete", work };
|
|
6520
|
+
}
|
|
6521
|
+
}
|
|
6522
|
+
return { status: "hit", fraction: upper, lowerFraction: lower, contact, work };
|
|
6523
|
+
}
|
|
6524
|
+
|
|
6525
|
+
// dist/terrain/sweep-capsule.js
|
|
6526
|
+
function sweepTerrainCapsule(surface, start, end, translation, radius, { fractionTolerance = 1e-6, maxWork = 1e5 } = {}) {
|
|
6527
|
+
var _a;
|
|
6528
|
+
const speed = Math.hypot(...translation);
|
|
6529
|
+
if (![start, end, translation].every((point) => point.length === 3 && point.every(Number.isFinite)) || !Number.isFinite(speed) || !Number.isFinite(radius) || radius < 0 || !(fractionTolerance >= Number.EPSILON && fractionTolerance <= 1) || !Number.isSafeInteger(maxWork) || maxWork < 0)
|
|
6530
|
+
throw new RangeError("Invalid terrain capsule sweep");
|
|
6531
|
+
let work = 0;
|
|
6532
|
+
const probe = (fraction) => {
|
|
6533
|
+
if (work >= maxWork)
|
|
6534
|
+
return null;
|
|
6535
|
+
work++;
|
|
6536
|
+
const move = (point) => [
|
|
6537
|
+
point[0] + translation[0] * fraction,
|
|
6538
|
+
point[1] + translation[1] * fraction,
|
|
6539
|
+
point[2] + translation[2] * fraction
|
|
6540
|
+
];
|
|
6541
|
+
const query = surface.nearestSegmentQuery(move(start), move(end), { maxWork: maxWork - work });
|
|
6542
|
+
work += query.work;
|
|
6543
|
+
return query;
|
|
6544
|
+
};
|
|
6545
|
+
const initial = probe(0);
|
|
6546
|
+
if ((initial == null ? void 0 : initial.result) && initial.result.distance <= radius)
|
|
6547
|
+
return { status: "hit", work, fraction: 0, lowerFraction: 0, contact: initial.result };
|
|
6548
|
+
if (!(initial == null ? void 0 : initial.complete))
|
|
6549
|
+
return { status: "incomplete", work };
|
|
6550
|
+
if (!initial.result || speed === 0)
|
|
6551
|
+
return { status: "miss", work };
|
|
6552
|
+
let clearUntil = 0;
|
|
6553
|
+
let witness;
|
|
6554
|
+
const pending = [[0, 1]];
|
|
6555
|
+
while (pending.length) {
|
|
6556
|
+
const [lower, upper] = pending.pop();
|
|
6557
|
+
if (witness && witness.fraction - clearUntil <= fractionTolerance)
|
|
6558
|
+
return { status: "hit", work, lowerFraction: clearUntil, ...witness };
|
|
6559
|
+
const middle = lower + (upper - lower) / 2;
|
|
6560
|
+
const query = probe(middle);
|
|
6561
|
+
if (!query)
|
|
6562
|
+
return { status: "incomplete", work };
|
|
6563
|
+
const hit = query.result;
|
|
6564
|
+
if (hit && hit.distance <= radius) {
|
|
6565
|
+
witness = { fraction: middle, contact: hit };
|
|
6566
|
+
if (middle - clearUntil <= fractionTolerance)
|
|
6567
|
+
return { status: "hit", work, lowerFraction: clearUntil, ...witness };
|
|
6568
|
+
pending.push([lower, middle]);
|
|
6569
|
+
continue;
|
|
6570
|
+
}
|
|
6571
|
+
if (!query.complete)
|
|
6572
|
+
return { status: "incomplete", work };
|
|
6573
|
+
const travel = speed * Math.max(middle - lower, upper - middle);
|
|
6574
|
+
const allowance = 8 * Number.EPSILON * Math.max((hit == null ? void 0 : hit.distance) ?? 0, radius, travel);
|
|
6575
|
+
if (!hit || hit.distance - radius > travel + allowance) {
|
|
6576
|
+
clearUntil = upper;
|
|
6577
|
+
continue;
|
|
6578
|
+
}
|
|
6579
|
+
if (upper - lower <= fractionTolerance) {
|
|
6580
|
+
const final = (_a = probe(upper)) == null ? void 0 : _a.result;
|
|
6581
|
+
if (final && final.distance <= radius && upper - clearUntil <= fractionTolerance)
|
|
6582
|
+
return { status: "hit", work, fraction: upper, lowerFraction: clearUntil, contact: final };
|
|
6583
|
+
return { status: "incomplete", work };
|
|
6584
|
+
}
|
|
6585
|
+
pending.push([middle, upper], [lower, middle]);
|
|
6586
|
+
}
|
|
6587
|
+
return witness ? { status: "hit", work, lowerFraction: clearUntil, ...witness } : { status: "miss", work };
|
|
6588
|
+
}
|
|
6589
|
+
function sweepTerrainTaperedCapsule(surface, start, end, translation, radiusStart, radiusEnd, { maxWork = 1e5, fractionTolerance } = {}) {
|
|
6590
|
+
if (![radiusStart, radiusEnd].every((radius) => Number.isFinite(radius) && radius >= 0))
|
|
6591
|
+
throw new RangeError("Invalid terrain tapered capsule radii");
|
|
6592
|
+
const outer = sweepTerrainCapsule(surface, start, end, translation, Math.max(radiusStart, radiusEnd), {
|
|
6593
|
+
maxWork,
|
|
6594
|
+
fractionTolerance
|
|
6595
|
+
});
|
|
6596
|
+
if (outer.status !== "hit" || radiusStart === radiusEnd)
|
|
6597
|
+
return outer;
|
|
6598
|
+
const inner = sweepTerrainCapsule(surface, start, end, translation, Math.min(radiusStart, radiusEnd), {
|
|
6599
|
+
maxWork: maxWork - outer.work,
|
|
6600
|
+
fractionTolerance
|
|
6601
|
+
});
|
|
6602
|
+
const work = outer.work + inner.work;
|
|
6603
|
+
return inner.status === "hit" && outer.lowerFraction <= inner.fraction ? { ...inner, lowerFraction: outer.lowerFraction, work } : { status: "incomplete", work };
|
|
6604
|
+
}
|
|
6605
|
+
|
|
6606
|
+
// dist/terrain/sweep-polytope.js
|
|
6607
|
+
var sub2 = (a, b) => [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
|
|
6608
|
+
var cross2 = (a, b) => [
|
|
6609
|
+
a[1] * b[2] - a[2] * b[1],
|
|
6610
|
+
a[2] * b[0] - a[0] * b[2],
|
|
6611
|
+
a[0] * b[1] - a[1] * b[0]
|
|
6612
|
+
];
|
|
6613
|
+
var dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
6614
|
+
var edges = ([a, b, c]) => [sub2(b, a), sub2(c, b), sub2(a, c)];
|
|
6615
|
+
function sweepTerrainPolytope(surface, collider, translation, { maxWork = 1e5 } = {}) {
|
|
6616
|
+
if (!Number.isSafeInteger(maxWork) || maxWork < 0 || translation.length !== 3 || !translation.every(Number.isFinite) || collider.vertices.length < 4 || collider.faces.length < 4 || collider.vertices.some((point) => point.length !== 3 || !point.every(Number.isFinite)))
|
|
6617
|
+
throw new RangeError("Invalid terrain polytope sweep");
|
|
6618
|
+
const vertices = collider.vertices.map((point) => sub2(point, surface.origin));
|
|
6619
|
+
const normals = [];
|
|
6620
|
+
const directions = [];
|
|
6621
|
+
for (const face of collider.faces) {
|
|
6622
|
+
if (face.length !== 3 || face.some((i) => !Number.isSafeInteger(i) || !vertices[i]))
|
|
6623
|
+
throw new RangeError("Invalid terrain polytope face");
|
|
6624
|
+
const side = edges([vertices[face[0]], vertices[face[1]], vertices[face[2]]]);
|
|
6625
|
+
const normal = cross2(side[0], side[1]);
|
|
6626
|
+
if (!normal.every(Number.isFinite) || !normal.some(Boolean))
|
|
6627
|
+
throw new RangeError("Degenerate terrain polytope face");
|
|
6628
|
+
normals.push(normal);
|
|
6629
|
+
directions.push(...side);
|
|
6630
|
+
}
|
|
6631
|
+
return sweepTriangles(surface.copyData(), vertices, normals, directions, translation, maxWork);
|
|
6632
|
+
}
|
|
6633
|
+
function sweepTerrainTriangleMesh(surface, collider, translation, { maxWork = 1e5 } = {}) {
|
|
6634
|
+
if (!Number.isSafeInteger(maxWork) || maxWork < 0 || translation.length !== 3 || !translation.every(Number.isFinite))
|
|
6635
|
+
throw new RangeError("Invalid terrain triangle mesh sweep");
|
|
6636
|
+
const data = surface.copyData();
|
|
6637
|
+
let work = 0;
|
|
6638
|
+
let best;
|
|
6639
|
+
for (const face of collider.faces) {
|
|
6640
|
+
if (face.length !== 3)
|
|
6641
|
+
throw new RangeError("Invalid terrain sweep mesh face");
|
|
6642
|
+
const vertices = face.map((index) => {
|
|
6643
|
+
const point = collider.vertices[index];
|
|
6644
|
+
if (!Number.isSafeInteger(index) || !point || point.length !== 3 || !point.every(Number.isFinite))
|
|
6645
|
+
throw new RangeError("Invalid terrain sweep mesh vertex");
|
|
6646
|
+
return sub2(point, surface.origin);
|
|
6647
|
+
});
|
|
6648
|
+
const directions = edges(vertices);
|
|
6649
|
+
const normal = cross2(directions[0], directions[1]);
|
|
6650
|
+
if (!normal.every(Number.isFinite) || !normal.some(Boolean))
|
|
6651
|
+
throw new RangeError("Degenerate terrain sweep mesh face");
|
|
6652
|
+
const result = sweepTriangles(data, vertices, [normal], directions, translation, maxWork - work, normal);
|
|
6653
|
+
work += result.work;
|
|
6654
|
+
if (result.status === "incomplete")
|
|
6655
|
+
return { status: "incomplete", work };
|
|
6656
|
+
if (result.status === "hit" && (!best || result.fraction < best.fraction))
|
|
6657
|
+
best = result;
|
|
6658
|
+
}
|
|
6659
|
+
return best ? { ...best, work } : { status: "miss", work };
|
|
6660
|
+
}
|
|
6661
|
+
function sweepTriangles(data, vertices, normals, directions, translation, maxWork, movingTriangleNormal) {
|
|
6662
|
+
let work = 0;
|
|
6663
|
+
let best;
|
|
6664
|
+
const vertex = (index) => {
|
|
6665
|
+
const i = 3 * data.indices[index];
|
|
6666
|
+
return [data.positions[i], data.positions[i + 1], data.positions[i + 2]];
|
|
6667
|
+
};
|
|
6668
|
+
for (let i = 0; i < data.triangleValidity.length; i++) {
|
|
6669
|
+
if (!data.triangleValidity[i])
|
|
6670
|
+
continue;
|
|
6671
|
+
const triangle = [vertex(3 * i), vertex(3 * i + 1), vertex(3 * i + 2)];
|
|
6672
|
+
const sides = edges(triangle);
|
|
6673
|
+
let enter = 0;
|
|
6674
|
+
let exit = (best == null ? void 0 : best.fraction) ?? 1;
|
|
6675
|
+
let normal = null;
|
|
6676
|
+
function* axes() {
|
|
6677
|
+
const terrainNormal = cross2(sides[0], sides[1]);
|
|
6678
|
+
yield terrainNormal;
|
|
6679
|
+
if (movingTriangleNormal) {
|
|
6680
|
+
for (const side of sides)
|
|
6681
|
+
yield cross2(terrainNormal, side);
|
|
6682
|
+
for (const direction of directions)
|
|
6683
|
+
yield cross2(movingTriangleNormal, direction);
|
|
6684
|
+
}
|
|
6685
|
+
yield* normals;
|
|
6686
|
+
for (const side of sides)
|
|
6687
|
+
for (const direction of directions)
|
|
6688
|
+
yield cross2(side, direction);
|
|
6689
|
+
}
|
|
6690
|
+
for (const axis of axes()) {
|
|
6691
|
+
if (work >= maxWork)
|
|
6692
|
+
return { status: "incomplete", work };
|
|
6693
|
+
work++;
|
|
6694
|
+
const length = Math.hypot(...axis);
|
|
6695
|
+
if (length === 0)
|
|
6696
|
+
continue;
|
|
6697
|
+
const unit = [axis[0] / length, axis[1] / length, axis[2] / length];
|
|
6698
|
+
const low = Math.min(...triangle.map((point) => dot(point, unit)));
|
|
6699
|
+
const high = Math.max(...triangle.map((point) => dot(point, unit)));
|
|
6700
|
+
let min = Infinity;
|
|
6701
|
+
let max = -Infinity;
|
|
6702
|
+
for (const point of vertices) {
|
|
6703
|
+
const projection = dot(point, unit);
|
|
6704
|
+
min = Math.min(min, projection);
|
|
6705
|
+
max = Math.max(max, projection);
|
|
6706
|
+
}
|
|
6707
|
+
const speed = dot(translation, unit);
|
|
6708
|
+
if (![low, high, min, max, speed, length].every(Number.isFinite))
|
|
6709
|
+
throw new RangeError("Terrain polytope projection overflow");
|
|
6710
|
+
if (speed === 0) {
|
|
6711
|
+
if (min > high || max < low)
|
|
6712
|
+
exit = -1;
|
|
6713
|
+
} else {
|
|
6714
|
+
const first = (low - max) / speed;
|
|
6715
|
+
const last = (high - min) / speed;
|
|
6716
|
+
const entry = Math.min(first, last);
|
|
6717
|
+
if (entry > enter) {
|
|
6718
|
+
enter = entry;
|
|
6719
|
+
normal = speed < 0 ? unit : [-unit[0], -unit[1], -unit[2]];
|
|
6720
|
+
}
|
|
6721
|
+
exit = Math.min(exit, Math.max(first, last));
|
|
6722
|
+
}
|
|
6723
|
+
if (enter > exit)
|
|
6724
|
+
break;
|
|
6725
|
+
}
|
|
6726
|
+
if (enter <= exit && (!best || enter < best.fraction)) {
|
|
6727
|
+
best = { status: "hit", fraction: enter, triangleIndex: i, normal, work };
|
|
6728
|
+
if (enter === 0)
|
|
6729
|
+
break;
|
|
6730
|
+
}
|
|
6731
|
+
}
|
|
6732
|
+
return best ? { ...best, work } : { status: "miss", work };
|
|
6733
|
+
}
|
|
6734
|
+
function sweepTerrainBox(surface, center, halfExtents, translation, options) {
|
|
6735
|
+
if (halfExtents.length !== 3 || halfExtents.some((value) => !(value > 0)))
|
|
6736
|
+
throw new RangeError("Terrain box half extents must be positive");
|
|
6737
|
+
const vertices = Array.from({ length: 8 }, (_, i) => [
|
|
6738
|
+
center[0] + (i & 1 ? 1 : -1) * halfExtents[0],
|
|
6739
|
+
center[1] + (i & 2 ? 1 : -1) * halfExtents[1],
|
|
6740
|
+
center[2] + (i & 4 ? 1 : -1) * halfExtents[2]
|
|
6741
|
+
]);
|
|
6742
|
+
return sweepTerrainPolytope(surface, {
|
|
6743
|
+
vertices,
|
|
6744
|
+
faces: [
|
|
6745
|
+
[0, 1, 3],
|
|
6746
|
+
[0, 3, 2],
|
|
6747
|
+
[4, 6, 7],
|
|
6748
|
+
[4, 7, 5],
|
|
6749
|
+
[0, 4, 5],
|
|
6750
|
+
[0, 5, 1],
|
|
6751
|
+
[2, 3, 7],
|
|
6752
|
+
[2, 7, 6],
|
|
6753
|
+
[0, 2, 6],
|
|
6754
|
+
[0, 6, 4],
|
|
6755
|
+
[1, 5, 7],
|
|
6756
|
+
[1, 7, 3]
|
|
6757
|
+
]
|
|
6758
|
+
}, translation, options);
|
|
6759
|
+
}
|
|
6760
|
+
|
|
6761
|
+
// dist/terrain/sweep-cylinder.js
|
|
6762
|
+
function sweepTerrainCylinder(surface, center, height, radiusBottom, radiusTop, translation, { sides = 16, maxWork = 1e5 } = {}) {
|
|
6763
|
+
if (center.length !== 3 || !center.every(Number.isFinite) || ![height, radiusBottom, radiusTop].every((value) => Number.isFinite(value) && value > 0) || !Number.isInteger(sides) || sides < 3 || sides > 128)
|
|
6764
|
+
throw new RangeError("Invalid terrain cylinder sweep");
|
|
6765
|
+
const faces = [];
|
|
6766
|
+
for (let i = 0; i < sides; i++) {
|
|
6767
|
+
const next = (i + 1) % sides;
|
|
6768
|
+
faces.push([i, next, next + sides], [i, next + sides, i + sides]);
|
|
6769
|
+
if (i > 0 && i < sides - 1)
|
|
6770
|
+
faces.push([0, i + 1, i], [sides, sides + i, sides + i + 1]);
|
|
6771
|
+
}
|
|
6772
|
+
const hull = (scale) => ({
|
|
6773
|
+
faces,
|
|
6774
|
+
vertices: Array.from({ length: 2 * sides }, (_, i) => {
|
|
6775
|
+
const top = i >= sides;
|
|
6776
|
+
const angle = 2 * Math.PI * (i % sides) / sides;
|
|
6777
|
+
const radius = (top ? radiusTop : radiusBottom) * scale;
|
|
6778
|
+
return [
|
|
6779
|
+
center[0] + radius * Math.cos(angle),
|
|
6780
|
+
center[1] + radius * Math.sin(angle),
|
|
6781
|
+
center[2] + (top ? height : -height) / 2
|
|
6782
|
+
];
|
|
6783
|
+
})
|
|
6784
|
+
});
|
|
6785
|
+
const outer = sweepTerrainPolytope(surface, hull(1 / Math.cos(Math.PI / sides)), translation, {
|
|
6786
|
+
maxWork
|
|
6787
|
+
});
|
|
6788
|
+
if (outer.status !== "hit")
|
|
6789
|
+
return outer;
|
|
6790
|
+
const inner = sweepTerrainPolytope(surface, hull(1), translation, {
|
|
6791
|
+
maxWork: maxWork - outer.work
|
|
6792
|
+
});
|
|
6793
|
+
const work = outer.work + inner.work;
|
|
6794
|
+
if (inner.status !== "hit" || inner.fraction < outer.fraction)
|
|
6795
|
+
return { status: "incomplete", work };
|
|
6796
|
+
return { ...inner, normal: null, lowerFraction: outer.fraction, work };
|
|
6797
|
+
}
|
|
6798
|
+
|
|
6799
|
+
// dist/terrain/sweep-plane.js
|
|
6800
|
+
function sweepTerrainPlane(surface, point, normal, translation, { maxWork = 1e5 } = {}) {
|
|
6801
|
+
const length = Math.hypot(...normal);
|
|
6802
|
+
if (![point, normal, translation].every((v) => v.length === 3 && v.every(Number.isFinite)) || !(length > 0 && Number.isFinite(length)) || !Number.isSafeInteger(maxWork) || maxWork < 0)
|
|
6803
|
+
throw new RangeError("Invalid terrain plane sweep");
|
|
6804
|
+
const unit = [normal[0] / length, normal[1] / length, normal[2] / length];
|
|
6805
|
+
const velocity = translation[0] * unit[0] + translation[1] * unit[1] + translation[2] * unit[2];
|
|
6806
|
+
if (!Number.isFinite(velocity))
|
|
6807
|
+
throw new RangeError("Terrain plane velocity overflow");
|
|
6808
|
+
const { positions, indices, triangleValidity } = surface.copyData();
|
|
6809
|
+
const local = point.map((value, axis) => value - surface.origin[axis]);
|
|
6810
|
+
let work = 0;
|
|
6811
|
+
let fraction = Infinity;
|
|
6812
|
+
let triangleIndex = -1;
|
|
6813
|
+
for (let i = 0; i < triangleValidity.length; i++) {
|
|
6814
|
+
if (!triangleValidity[i])
|
|
6815
|
+
continue;
|
|
6816
|
+
if (work >= maxWork)
|
|
6817
|
+
return { status: "incomplete", work };
|
|
6818
|
+
work++;
|
|
6819
|
+
let min = Infinity;
|
|
6820
|
+
let max = -Infinity;
|
|
6821
|
+
for (let j = 0; j < 3; j++) {
|
|
6822
|
+
const k = indices[3 * i + j] * 3;
|
|
6823
|
+
const distance = (positions[k] - local[0]) * unit[0] + (positions[k + 1] - local[1]) * unit[1] + (positions[k + 2] - local[2]) * unit[2];
|
|
6824
|
+
if (!Number.isFinite(distance))
|
|
6825
|
+
throw new RangeError("Terrain plane projection overflow");
|
|
6826
|
+
min = Math.min(min, distance);
|
|
6827
|
+
max = Math.max(max, distance);
|
|
6828
|
+
}
|
|
6829
|
+
if (min <= 0 && max >= 0)
|
|
6830
|
+
return { status: "hit", fraction: 0, triangleIndex: i, normal: null, work };
|
|
6831
|
+
const entry = velocity > 0 ? min / velocity : max / velocity;
|
|
6832
|
+
if (velocity !== 0 && entry > 0 && entry <= 1 && entry < fraction) {
|
|
6833
|
+
triangleIndex = i;
|
|
6834
|
+
fraction = entry;
|
|
6835
|
+
}
|
|
6836
|
+
}
|
|
6837
|
+
if (triangleIndex < 0)
|
|
6838
|
+
return { status: "miss", work };
|
|
6839
|
+
const entryNormal = velocity < 0 ? unit : [-unit[0], -unit[1], -unit[2]];
|
|
6840
|
+
return { status: "hit", fraction, triangleIndex, normal: entryNormal, work };
|
|
6841
|
+
}
|
|
6842
|
+
|
|
6843
|
+
// dist/terrain/geographic-lod-seams.js
|
|
6844
|
+
function discoverGeographicTerrainLodSeams(cut) {
|
|
6845
|
+
const vertical = /* @__PURE__ */ new Map();
|
|
6846
|
+
const horizontal = /* @__PURE__ */ new Map();
|
|
6847
|
+
const world = 2 ** 30;
|
|
6848
|
+
const addresses = /* @__PURE__ */ new Set();
|
|
6849
|
+
const key2 = (level, x, y) => `${level}/${x}/${y}`;
|
|
6850
|
+
for (const tile of cut) {
|
|
6851
|
+
getGeographicTileBounds(tile);
|
|
6852
|
+
const address = key2(tile.level, tile.x, tile.y);
|
|
6853
|
+
if (addresses.has(address))
|
|
6854
|
+
throw new Error("Duplicate geographic terrain tile");
|
|
6855
|
+
addresses.add(address);
|
|
6856
|
+
}
|
|
6857
|
+
function add2(lines, line, side, span) {
|
|
6858
|
+
let group = lines.get(line);
|
|
6859
|
+
if (!group) {
|
|
6860
|
+
group = { before: [], after: [] };
|
|
6861
|
+
lines.set(line, group);
|
|
6862
|
+
}
|
|
6863
|
+
group[side].push(span);
|
|
6864
|
+
}
|
|
6865
|
+
cut.forEach(({ level, x, y }, tile) => {
|
|
6866
|
+
for (let parent = level - 1; parent >= 0; parent--) {
|
|
6867
|
+
const scale = 2 ** (level - parent);
|
|
6868
|
+
if (addresses.has(key2(parent, Math.floor(x / scale), Math.floor(y / scale))))
|
|
6869
|
+
throw new Error("Overlapping geographic terrain tiles");
|
|
6870
|
+
}
|
|
6871
|
+
const size = 2 ** (30 - level);
|
|
6872
|
+
const west = x * size;
|
|
6873
|
+
const north = y * size;
|
|
6874
|
+
const east = west + size;
|
|
6875
|
+
const south = north + size;
|
|
6876
|
+
add2(vertical, west, "after", { tile, start: north, end: south });
|
|
6877
|
+
add2(vertical, east % world, "before", { tile, start: north, end: south });
|
|
6878
|
+
if (north !== 0)
|
|
6879
|
+
add2(horizontal, north, "after", { tile, start: west, end: east });
|
|
6880
|
+
if (south !== world)
|
|
6881
|
+
add2(horizontal, south, "before", { tile, start: west, end: east });
|
|
6882
|
+
});
|
|
6883
|
+
const seams = [];
|
|
6884
|
+
function match(lines, column) {
|
|
6885
|
+
const beforeEdge = column ? "maxColumn" : "maxRow";
|
|
6886
|
+
const afterEdge = column ? "minColumn" : "minRow";
|
|
6887
|
+
const byStart = (a, b) => a.start - b.start;
|
|
6888
|
+
for (const [line, { before, after }] of lines) {
|
|
6889
|
+
before.sort(byStart);
|
|
6890
|
+
after.sort(byStart);
|
|
6891
|
+
let i = 0;
|
|
6892
|
+
let j = 0;
|
|
6893
|
+
while (i < before.length && j < after.length) {
|
|
6894
|
+
const left = before[i];
|
|
6895
|
+
const right = after[j];
|
|
6896
|
+
const start = Math.max(left.start, right.start);
|
|
6897
|
+
const end = Math.min(left.end, right.end);
|
|
6898
|
+
const leftLevel = cut[left.tile].level;
|
|
6899
|
+
const rightLevel = cut[right.tile].level;
|
|
6900
|
+
if (end > start && leftLevel !== rightLevel) {
|
|
6901
|
+
const leftOwns = leftLevel < rightLevel;
|
|
6902
|
+
const coarse = leftOwns ? left : right;
|
|
6903
|
+
seams.push({
|
|
6904
|
+
a: coarse.tile,
|
|
6905
|
+
edgeA: leftOwns ? beforeEdge : afterEdge,
|
|
6906
|
+
b: leftOwns ? right.tile : left.tile,
|
|
6907
|
+
edgeB: leftOwns ? afterEdge : beforeEdge,
|
|
6908
|
+
...column && line === 0 ? { offsetBX: leftOwns ? 360 : -360 } : {},
|
|
6909
|
+
options: {
|
|
6910
|
+
rangeA: [
|
|
6911
|
+
(start - coarse.start) / (coarse.end - coarse.start),
|
|
6912
|
+
(end - coarse.start) / (coarse.end - coarse.start)
|
|
6913
|
+
]
|
|
6914
|
+
}
|
|
6915
|
+
});
|
|
6916
|
+
}
|
|
6917
|
+
if (left.end <= right.end)
|
|
6918
|
+
i++;
|
|
6919
|
+
if (right.end <= left.end)
|
|
6920
|
+
j++;
|
|
6921
|
+
}
|
|
6922
|
+
}
|
|
6923
|
+
}
|
|
6924
|
+
match(vertical, true);
|
|
6925
|
+
match(horizontal, false);
|
|
6926
|
+
const edges2 = ["minColumn", "maxColumn", "minRow", "maxRow"];
|
|
6927
|
+
return seams.sort((a, b) => cut[a.a].level - cut[b.a].level || cut[a.a].y - cut[b.a].y || cut[a.a].x - cut[b.a].x || edges2.indexOf(a.edgeA) - edges2.indexOf(b.edgeA) || a.options.rangeA[0] - b.options.rangeA[0]);
|
|
6928
|
+
}
|
|
6929
|
+
|
|
6930
|
+
// dist/terrain/geographic-poles.js
|
|
6931
|
+
function discoverGeographicTerrainPoles(cut) {
|
|
6932
|
+
function collect(latitude, edge2) {
|
|
6933
|
+
const incident = [];
|
|
6934
|
+
for (let tile = 0; tile < cut.length; tile++) {
|
|
6935
|
+
const [west, south, east, north] = getGeographicTileBounds(cut[tile]);
|
|
6936
|
+
if ((edge2 === "north" ? north : south) === latitude)
|
|
6937
|
+
incident.push({ tile, edge: edge2, longitude: [west, east] });
|
|
6938
|
+
}
|
|
6939
|
+
incident.sort((a, b) => a.longitude[0] - b.longitude[0]);
|
|
6940
|
+
const gaps = [];
|
|
6941
|
+
let cursor = -180;
|
|
6942
|
+
for (const { longitude: [west, east] } of incident) {
|
|
6943
|
+
if (west < cursor)
|
|
6944
|
+
throw new Error("Overlapping geographic terrain pole sectors");
|
|
6945
|
+
if (west > cursor)
|
|
6946
|
+
gaps.push([cursor, west]);
|
|
6947
|
+
cursor = east;
|
|
6948
|
+
}
|
|
6949
|
+
if (cursor < 180)
|
|
6950
|
+
gaps.push([cursor, 180]);
|
|
6951
|
+
return { latitude, incident, gaps };
|
|
6952
|
+
}
|
|
6953
|
+
return { north: collect(90, "north"), south: collect(-90, "south") };
|
|
6954
|
+
}
|
|
3099
6955
|
//# sourceMappingURL=index.cjs.map
|