@deck.gl/extensions 9.3.7 → 9.4.0-alpha.2
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/dist/dist.dev.js +348 -35
- package/dist/fill-style/shader-module.d.ts +1 -1
- package/dist/index.cjs +78 -35
- package/dist/index.cjs.map +4 -4
- package/dist/mask/shader-module.d.ts +1 -1
- package/dist/terrain/height-map-builder.d.ts.map +1 -1
- package/dist/terrain/height-map-builder.js +16 -10
- package/dist/terrain/height-map-builder.js.map +1 -1
- package/dist/terrain/shader-module.d.ts +6 -6
- package/dist/terrain/shader-module.d.ts.map +1 -1
- package/dist/terrain/shader-module.js +38 -11
- package/dist/terrain/shader-module.js.map +1 -1
- package/dist/terrain/terrain-cover.d.ts.map +1 -1
- package/dist/terrain/terrain-cover.js +10 -5
- package/dist/terrain/terrain-cover.js.map +1 -1
- package/dist/utils/projection-utils.d.ts +4 -0
- package/dist/utils/projection-utils.d.ts.map +1 -1
- package/dist/utils/projection-utils.js +25 -5
- package/dist/utils/projection-utils.js.map +1 -1
- package/dist.min.js +362 -65
- package/package.json +11 -7
- package/src/terrain/height-map-builder.ts +25 -10
- package/src/terrain/shader-module.ts +38 -11
- package/src/terrain/terrain-cover.ts +21 -5
- package/src/utils/projection-utils.ts +28 -5
package/dist/dist.dev.js
CHANGED
|
@@ -1683,11 +1683,278 @@ vec2 sqrt_fp64(vec2 a) {
|
|
|
1683
1683
|
|
|
1684
1684
|
@group(0) @binding(auto) var<uniform> fp64arithmetic : Fp64ArithmeticUniforms;
|
|
1685
1685
|
|
|
1686
|
+
struct Fp64Bits {
|
|
1687
|
+
sign: u32,
|
|
1688
|
+
exponent: i32,
|
|
1689
|
+
significand: vec2u,
|
|
1690
|
+
isZero: bool,
|
|
1691
|
+
isInf: bool,
|
|
1692
|
+
isNan: bool,
|
|
1693
|
+
};
|
|
1694
|
+
|
|
1686
1695
|
fn fp64_nan(seed: f32) -> f32 {
|
|
1687
1696
|
let nanBits = 0x7fc00000u | select(0u, 1u, seed < 0.0);
|
|
1688
1697
|
return bitcast<f32>(nanBits);
|
|
1689
1698
|
}
|
|
1690
1699
|
|
|
1700
|
+
fn fp64_u64_is_zero(value: vec2u) -> bool {
|
|
1701
|
+
return value.x == 0u && value.y == 0u;
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
fn fp64_u64_compare(a: vec2u, b: vec2u) -> i32 {
|
|
1705
|
+
if (a.x != b.x) {
|
|
1706
|
+
return select(-1, 1, a.x > b.x);
|
|
1707
|
+
}
|
|
1708
|
+
if (a.y != b.y) {
|
|
1709
|
+
return select(-1, 1, a.y > b.y);
|
|
1710
|
+
}
|
|
1711
|
+
return 0;
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
fn fp64_u64_add(a: vec2u, b: vec2u) -> vec2u {
|
|
1715
|
+
let low = a.y + b.y;
|
|
1716
|
+
let carry = select(0u, 1u, low < a.y);
|
|
1717
|
+
return vec2u(a.x + b.x + carry, low);
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
fn fp64_u64_sub(a: vec2u, b: vec2u) -> vec2u {
|
|
1721
|
+
let borrow = select(0u, 1u, a.y < b.y);
|
|
1722
|
+
return vec2u(a.x - b.x - borrow, a.y - b.y);
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
fn fp64_u64_shift_left(value: vec2u, shift: u32) -> vec2u {
|
|
1726
|
+
if (shift == 0u) {
|
|
1727
|
+
return value;
|
|
1728
|
+
}
|
|
1729
|
+
if (shift < 32u) {
|
|
1730
|
+
return vec2u((value.x << shift) | (value.y >> (32u - shift)), value.y << shift);
|
|
1731
|
+
}
|
|
1732
|
+
if (shift == 32u) {
|
|
1733
|
+
return vec2u(value.y, 0u);
|
|
1734
|
+
}
|
|
1735
|
+
if (shift < 64u) {
|
|
1736
|
+
return vec2u(value.y << (shift - 32u), 0u);
|
|
1737
|
+
}
|
|
1738
|
+
return vec2u(0u);
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
fn fp64_u64_shift_right(value: vec2u, shift: u32) -> vec2u {
|
|
1742
|
+
if (shift == 0u) {
|
|
1743
|
+
return value;
|
|
1744
|
+
}
|
|
1745
|
+
if (shift < 32u) {
|
|
1746
|
+
return vec2u(value.x >> shift, (value.y >> shift) | (value.x << (32u - shift)));
|
|
1747
|
+
}
|
|
1748
|
+
if (shift == 32u) {
|
|
1749
|
+
return vec2u(0u, value.x);
|
|
1750
|
+
}
|
|
1751
|
+
if (shift < 64u) {
|
|
1752
|
+
return vec2u(0u, value.x >> (shift - 32u));
|
|
1753
|
+
}
|
|
1754
|
+
return vec2u(0u);
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
fn fp64_u64_get_bit(value: vec2u, bitIndex: u32) -> bool {
|
|
1758
|
+
if (bitIndex >= 64u) {
|
|
1759
|
+
return false;
|
|
1760
|
+
}
|
|
1761
|
+
if (bitIndex >= 32u) {
|
|
1762
|
+
return ((value.x >> (bitIndex - 32u)) & 1u) != 0u;
|
|
1763
|
+
}
|
|
1764
|
+
return ((value.y >> bitIndex) & 1u) != 0u;
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
fn fp64_u64_has_bits_below(value: vec2u, bitCount: u32) -> bool {
|
|
1768
|
+
if (bitCount == 0u) {
|
|
1769
|
+
return false;
|
|
1770
|
+
}
|
|
1771
|
+
if (bitCount >= 64u) {
|
|
1772
|
+
return !fp64_u64_is_zero(value);
|
|
1773
|
+
}
|
|
1774
|
+
if (bitCount > 32u) {
|
|
1775
|
+
let highBitCount = bitCount - 32u;
|
|
1776
|
+
let highMask = (1u << highBitCount) - 1u;
|
|
1777
|
+
return value.y != 0u || (value.x & highMask) != 0u;
|
|
1778
|
+
}
|
|
1779
|
+
if (bitCount == 32u) {
|
|
1780
|
+
return value.y != 0u;
|
|
1781
|
+
}
|
|
1782
|
+
let lowMask = (1u << bitCount) - 1u;
|
|
1783
|
+
return (value.y & lowMask) != 0u;
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
fn fp64_u64_shift_right_sticky(value: vec2u, shift: u32) -> vec2u {
|
|
1787
|
+
var shifted = fp64_u64_shift_right(value, shift);
|
|
1788
|
+
if (fp64_u64_has_bits_below(value, shift)) {
|
|
1789
|
+
shifted.y = shifted.y | 1u;
|
|
1790
|
+
}
|
|
1791
|
+
return shifted;
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
fn fp64_u64_count_leading_zeros(value: vec2u) -> u32 {
|
|
1795
|
+
if (value.x != 0u) {
|
|
1796
|
+
return countLeadingZeros(value.x);
|
|
1797
|
+
}
|
|
1798
|
+
return 32u + countLeadingZeros(value.y);
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
fn fp64_round_shift_right_to_u32(value: vec2u, shift: u32) -> u32 {
|
|
1802
|
+
if (shift == 0u) {
|
|
1803
|
+
return value.y;
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
let truncated = fp64_u64_shift_right(value, shift);
|
|
1807
|
+
var rounded = truncated.y;
|
|
1808
|
+
let guard = fp64_u64_get_bit(value, shift - 1u);
|
|
1809
|
+
let hasTrailingBits = fp64_u64_has_bits_below(value, shift - 1u);
|
|
1810
|
+
if (guard && (hasTrailingBits || (rounded & 1u) == 1u)) {
|
|
1811
|
+
rounded = rounded + 1u;
|
|
1812
|
+
}
|
|
1813
|
+
return rounded;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
fn fp64_make_f32_bits_from_u64(sign: u32, significand: vec2u, baseExponent: i32) -> u32 {
|
|
1817
|
+
if (fp64_u64_is_zero(significand)) {
|
|
1818
|
+
return sign << 31u;
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
let leadingZeros = fp64_u64_count_leading_zeros(significand);
|
|
1822
|
+
let mostSignificantBit = 63u - leadingZeros;
|
|
1823
|
+
var exponent = baseExponent + i32(mostSignificantBit);
|
|
1824
|
+
|
|
1825
|
+
if (exponent > 127) {
|
|
1826
|
+
return (sign << 31u) | 0x7f800000u;
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
if (exponent >= -126) {
|
|
1830
|
+
let shift = i32(mostSignificantBit) - 23;
|
|
1831
|
+
var significand24: u32;
|
|
1832
|
+
if (shift > 0) {
|
|
1833
|
+
significand24 = fp64_round_shift_right_to_u32(significand, u32(shift));
|
|
1834
|
+
} else {
|
|
1835
|
+
significand24 = fp64_u64_shift_left(significand, u32(-shift)).y;
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
if (significand24 >= 0x1000000u) {
|
|
1839
|
+
significand24 = significand24 >> 1u;
|
|
1840
|
+
exponent = exponent + 1;
|
|
1841
|
+
if (exponent > 127) {
|
|
1842
|
+
return (sign << 31u) | 0x7f800000u;
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
return (sign << 31u) | (u32(exponent + 127) << 23u) | (significand24 & 0x7fffffu);
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
let scaleExponent = baseExponent + 149;
|
|
1850
|
+
var mantissa: u32;
|
|
1851
|
+
if (scaleExponent >= 0) {
|
|
1852
|
+
mantissa = fp64_u64_shift_left(significand, u32(scaleExponent)).y;
|
|
1853
|
+
} else {
|
|
1854
|
+
mantissa = fp64_round_shift_right_to_u32(significand, u32(-scaleExponent));
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
if (mantissa >= 0x800000u) {
|
|
1858
|
+
return (sign << 31u) | 0x00800000u;
|
|
1859
|
+
}
|
|
1860
|
+
return (sign << 31u) | mantissa;
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
fn fp64_decode_bits(bits: vec2u) -> Fp64Bits {
|
|
1864
|
+
let sign = bits.x >> 31u;
|
|
1865
|
+
let exponentBits = (bits.x >> 20u) & 0x7ffu;
|
|
1866
|
+
let fractionHigh = bits.x & 0xfffffu;
|
|
1867
|
+
let fractionLow = bits.y;
|
|
1868
|
+
let fraction = vec2u(fractionHigh, fractionLow);
|
|
1869
|
+
|
|
1870
|
+
if (exponentBits == 0x7ffu) {
|
|
1871
|
+
let isInf = fp64_u64_is_zero(fraction);
|
|
1872
|
+
return Fp64Bits(sign, 0, vec2u(0u), false, isInf, !isInf);
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
if (exponentBits == 0u) {
|
|
1876
|
+
let isZero = fp64_u64_is_zero(fraction);
|
|
1877
|
+
return Fp64Bits(sign, -1022, fraction, isZero, false, false);
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
return Fp64Bits(sign, i32(exponentBits) - 1023, vec2u((1u << 20u) | fractionHigh, fractionLow), false, false, false);
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
fn fp64_finite_magnitude_compare(a: Fp64Bits, b: Fp64Bits) -> i32 {
|
|
1884
|
+
if (a.exponent != b.exponent) {
|
|
1885
|
+
return select(-1, 1, a.exponent > b.exponent);
|
|
1886
|
+
}
|
|
1887
|
+
return fp64_u64_compare(a.significand, b.significand);
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
fn fp64_add_aligned_magnitudes_to_f32_bits(sign: u32, larger: Fp64Bits, smaller: Fp64Bits) -> u32 {
|
|
1891
|
+
let largeSignificand = fp64_u64_shift_left(larger.significand, 3u);
|
|
1892
|
+
let smallSignificand = fp64_u64_shift_right_sticky(
|
|
1893
|
+
fp64_u64_shift_left(smaller.significand, 3u),
|
|
1894
|
+
u32(larger.exponent - smaller.exponent)
|
|
1895
|
+
);
|
|
1896
|
+
let resultSignificand = fp64_u64_add(largeSignificand, smallSignificand);
|
|
1897
|
+
return fp64_make_f32_bits_from_u64(sign, resultSignificand, larger.exponent - 55);
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
fn fp64_sub_aligned_magnitudes_to_f32_bits(sign: u32, larger: Fp64Bits, smaller: Fp64Bits) -> u32 {
|
|
1901
|
+
let largeSignificand = fp64_u64_shift_left(larger.significand, 3u);
|
|
1902
|
+
let smallSignificand = fp64_u64_shift_right_sticky(
|
|
1903
|
+
fp64_u64_shift_left(smaller.significand, 3u),
|
|
1904
|
+
u32(larger.exponent - smaller.exponent)
|
|
1905
|
+
);
|
|
1906
|
+
let resultSignificand = fp64_u64_sub(largeSignificand, smallSignificand);
|
|
1907
|
+
return fp64_make_f32_bits_from_u64(sign, resultSignificand, larger.exponent - 55);
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1910
|
+
// Subtract two raw binary64 values and round the exact result once to f32.
|
|
1911
|
+
// The input words are canonical high/low words: .x contains sign/exponent/high
|
|
1912
|
+
// fraction bits, and .y contains the low 32 fraction bits.
|
|
1913
|
+
fn sub_fp64u32_to_f32_bits(aBits: vec2u, bBits: vec2u) -> u32 {
|
|
1914
|
+
let a = fp64_decode_bits(aBits);
|
|
1915
|
+
let b = fp64_decode_bits(bBits);
|
|
1916
|
+
let bSubtractionSign = b.sign ^ 1u;
|
|
1917
|
+
|
|
1918
|
+
if (a.isNan || b.isNan) {
|
|
1919
|
+
return 0x7fc00000u;
|
|
1920
|
+
}
|
|
1921
|
+
if (a.isInf && b.isInf) {
|
|
1922
|
+
if (a.sign == bSubtractionSign) {
|
|
1923
|
+
return (a.sign << 31u) | 0x7f800000u;
|
|
1924
|
+
}
|
|
1925
|
+
return 0x7fc00000u;
|
|
1926
|
+
}
|
|
1927
|
+
if (a.isInf) {
|
|
1928
|
+
return (a.sign << 31u) | 0x7f800000u;
|
|
1929
|
+
}
|
|
1930
|
+
if (b.isInf) {
|
|
1931
|
+
return (bSubtractionSign << 31u) | 0x7f800000u;
|
|
1932
|
+
}
|
|
1933
|
+
if (a.isZero && b.isZero) {
|
|
1934
|
+
return select(0u, 0x80000000u, a.sign == 1u && b.sign == 0u);
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
let magnitudeComparison = fp64_finite_magnitude_compare(a, b);
|
|
1938
|
+
if (a.sign == bSubtractionSign) {
|
|
1939
|
+
if (magnitudeComparison >= 0) {
|
|
1940
|
+
return fp64_add_aligned_magnitudes_to_f32_bits(a.sign, a, b);
|
|
1941
|
+
}
|
|
1942
|
+
return fp64_add_aligned_magnitudes_to_f32_bits(a.sign, b, a);
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
if (magnitudeComparison == 0) {
|
|
1946
|
+
return 0u;
|
|
1947
|
+
}
|
|
1948
|
+
if (magnitudeComparison > 0) {
|
|
1949
|
+
return fp64_sub_aligned_magnitudes_to_f32_bits(a.sign, a, b);
|
|
1950
|
+
}
|
|
1951
|
+
return fp64_sub_aligned_magnitudes_to_f32_bits(bSubtractionSign, b, a);
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
fn sub_fp64u32_to_f32(aBits: vec2u, bBits: vec2u) -> f32 {
|
|
1955
|
+
return bitcast<f32>(sub_fp64u32_to_f32_bits(aBits, bBits));
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1691
1958
|
fn fp64_runtime_zero() -> f32 {
|
|
1692
1959
|
return fp64arithmetic.ONE * 0.0;
|
|
1693
1960
|
}
|
|
@@ -4113,6 +4380,20 @@ in vec2 mask_texCoords;
|
|
|
4113
4380
|
|
|
4114
4381
|
// src/utils/projection-utils.ts
|
|
4115
4382
|
var import_core19 = __toESM(require_core(), 1);
|
|
4383
|
+
var MERCATOR_REFERENCE_VIEWPORT = new import_core19.WebMercatorViewport({
|
|
4384
|
+
width: 1,
|
|
4385
|
+
height: 1,
|
|
4386
|
+
longitude: 0,
|
|
4387
|
+
latitude: 0,
|
|
4388
|
+
zoom: 0
|
|
4389
|
+
});
|
|
4390
|
+
function lngLatToMercatorCommon(lngLat) {
|
|
4391
|
+
const [x, y] = MERCATOR_REFERENCE_VIEWPORT.projectPosition(lngLat);
|
|
4392
|
+
return [x, y];
|
|
4393
|
+
}
|
|
4394
|
+
function getMercatorReferenceViewport(viewport) {
|
|
4395
|
+
return viewport.isGeospatial ? MERCATOR_REFERENCE_VIEWPORT : viewport;
|
|
4396
|
+
}
|
|
4116
4397
|
function joinLayerBounds(layers, viewport) {
|
|
4117
4398
|
const bounds = [Infinity, Infinity, -Infinity, -Infinity];
|
|
4118
4399
|
for (const layer of layers) {
|
|
@@ -4138,11 +4419,11 @@ in vec2 mask_texCoords;
|
|
|
4138
4419
|
if (bounds[2] <= bounds[0] || bounds[3] <= bounds[1]) {
|
|
4139
4420
|
return null;
|
|
4140
4421
|
}
|
|
4141
|
-
const centerWorld =
|
|
4422
|
+
const centerWorld = isGeospatial ? MERCATOR_REFERENCE_VIEWPORT.unprojectPosition([
|
|
4142
4423
|
(bounds[0] + bounds[2]) / 2,
|
|
4143
4424
|
(bounds[1] + bounds[3]) / 2,
|
|
4144
4425
|
0
|
|
4145
|
-
]);
|
|
4426
|
+
]) : viewport.unprojectPosition([(bounds[0] + bounds[2]) / 2, (bounds[1] + bounds[3]) / 2, 0]);
|
|
4146
4427
|
let { width, height, zoom } = opts;
|
|
4147
4428
|
if (zoom === void 0) {
|
|
4148
4429
|
width = width - border * 2;
|
|
@@ -4483,10 +4764,10 @@ in vec2 mask_texCoords;
|
|
|
4483
4764
|
MaskExtension.extensionName = "MaskExtension";
|
|
4484
4765
|
|
|
4485
4766
|
// src/terrain/terrain-extension.ts
|
|
4486
|
-
var
|
|
4767
|
+
var import_core29 = __toESM(require_core(), 1);
|
|
4487
4768
|
|
|
4488
4769
|
// src/terrain/terrain-effect.ts
|
|
4489
|
-
var
|
|
4770
|
+
var import_core28 = __toESM(require_core(), 1);
|
|
4490
4771
|
|
|
4491
4772
|
// src/terrain/shader-module.ts
|
|
4492
4773
|
var import_core23 = __toESM(require_core(), 1);
|
|
@@ -4519,12 +4800,22 @@ uniform sampler2D terrain_map;
|
|
|
4519
4800
|
var terrainModule = {
|
|
4520
4801
|
name: "terrain",
|
|
4521
4802
|
dependencies: [import_core23.project],
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4803
|
+
vs: `${uniformBlock5}
|
|
4804
|
+
out vec3 commonPos;
|
|
4805
|
+
// In globe mode, absolute Mercator position for terrain FBO UV lookups
|
|
4806
|
+
out vec2 terrainMercPos;
|
|
4807
|
+
out float terrainHeight;
|
|
4808
|
+
|
|
4809
|
+
vec2 terrain_globe_to_mercator(vec3 globePosition) {
|
|
4810
|
+
float D = length(globePosition);
|
|
4811
|
+
float sinLat = clamp(globePosition.z / D, -0.999998, 0.999998);
|
|
4812
|
+
float x = atan(globePosition.x, -globePosition.y);
|
|
4813
|
+
float y = atanh(sinLat);
|
|
4814
|
+
return (vec2(x, y) + PI) * WORLD_SCALE;
|
|
4815
|
+
}
|
|
4816
|
+
`,
|
|
4817
|
+
fs: `${uniformBlock5}in vec2 terrainMercPos;
|
|
4818
|
+
in float terrainHeight;`,
|
|
4528
4819
|
inject: {
|
|
4529
4820
|
"vs:#main-start": (
|
|
4530
4821
|
/* glsl */
|
|
@@ -4539,19 +4830,35 @@ if (terrain.mode == TERRAIN_MODE_SKIP) {
|
|
|
4539
4830
|
/* glsl */
|
|
4540
4831
|
`
|
|
4541
4832
|
commonPos = geometry.position.xyz;
|
|
4833
|
+
terrainHeight = commonPos.z + project.commonOrigin.z;
|
|
4834
|
+
if (project.projectionMode == PROJECTION_MODE_GLOBE) {
|
|
4835
|
+
terrainMercPos = terrain_globe_to_mercator(commonPos);
|
|
4836
|
+
terrainHeight = length(commonPos) - GLOBE_RADIUS;
|
|
4837
|
+
} else {
|
|
4838
|
+
terrainMercPos = commonPos.xy;
|
|
4839
|
+
}
|
|
4542
4840
|
if (terrain.mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
|
|
4543
|
-
vec2 texCoords = (
|
|
4841
|
+
vec2 texCoords = (terrainMercPos - terrain.bounds.xy) / terrain.bounds.zw;
|
|
4544
4842
|
position = vec4(texCoords * 2.0 - 1.0, 0.0, 1.0);
|
|
4545
|
-
commonPos.z += project.commonOrigin.z;
|
|
4546
4843
|
}
|
|
4547
4844
|
if (terrain.mode == TERRAIN_MODE_USE_HEIGHT_MAP) {
|
|
4548
4845
|
vec3 anchor = geometry.worldPosition;
|
|
4549
4846
|
anchor.z = 0.0;
|
|
4550
4847
|
vec3 anchorCommon = project_position(anchor);
|
|
4551
|
-
vec2
|
|
4848
|
+
vec2 anchorMercPos = project.projectionMode == PROJECTION_MODE_GLOBE
|
|
4849
|
+
? terrain_globe_to_mercator(anchorCommon)
|
|
4850
|
+
: anchorCommon.xy;
|
|
4851
|
+
vec2 texCoords = (anchorMercPos - terrain.bounds.xy) / terrain.bounds.zw;
|
|
4552
4852
|
if (texCoords.x >= 0.0 && texCoords.y >= 0.0 && texCoords.x <= 1.0 && texCoords.y <= 1.0) {
|
|
4553
4853
|
float terrainZ = texture(terrain_map, texCoords).r;
|
|
4554
|
-
|
|
4854
|
+
if (project.projectionMode == PROJECTION_MODE_GLOBE) {
|
|
4855
|
+
// Height map is written in Mercator common space (units = TILE_SIZE / EARTH_CIRCUMFERENCE / cos(lat))
|
|
4856
|
+
// Convert to globe radial units (units = GLOBE_RADIUS / EARTH_RADIUS)
|
|
4857
|
+
terrainZ *= cos(radians(geometry.worldPosition.y)) * PI;
|
|
4858
|
+
geometry.position.xyz += normalize(geometry.position.xyz) * terrainZ;
|
|
4859
|
+
} else {
|
|
4860
|
+
geometry.position.z += terrainZ;
|
|
4861
|
+
}
|
|
4555
4862
|
position = project_common_position_to_clipspace(geometry.position);
|
|
4556
4863
|
}
|
|
4557
4864
|
}
|
|
@@ -4561,7 +4868,7 @@ if (terrain.mode == TERRAIN_MODE_USE_HEIGHT_MAP) {
|
|
|
4561
4868
|
/* glsl */
|
|
4562
4869
|
`
|
|
4563
4870
|
if (terrain.mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
|
|
4564
|
-
fragColor = vec4(
|
|
4871
|
+
fragColor = vec4(terrainHeight, 0.0, 0.0, 1.0);
|
|
4565
4872
|
return;
|
|
4566
4873
|
}
|
|
4567
4874
|
`
|
|
@@ -4570,7 +4877,7 @@ if (terrain.mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
|
|
|
4570
4877
|
/* glsl */
|
|
4571
4878
|
`
|
|
4572
4879
|
if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_USE_COVER_ONLY)) {
|
|
4573
|
-
vec2 texCoords = (
|
|
4880
|
+
vec2 texCoords = (terrainMercPos - terrain.bounds.xy) / terrain.bounds.zw;
|
|
4574
4881
|
vec4 pixel = texture(terrain_map, texCoords);
|
|
4575
4882
|
if (terrain.mode == TERRAIN_MODE_USE_COVER_ONLY) {
|
|
4576
4883
|
color = pixel;
|
|
@@ -4627,7 +4934,7 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
4627
4934
|
return {
|
|
4628
4935
|
mode,
|
|
4629
4936
|
terrain_map: sampler,
|
|
4630
|
-
// Convert bounds to
|
|
4937
|
+
// Convert bounds to common space, as [minX, minY, width, height]
|
|
4631
4938
|
bounds: bounds ? [
|
|
4632
4939
|
bounds[0] - commonOrigin[0],
|
|
4633
4940
|
bounds[1] - commonOrigin[1],
|
|
@@ -4648,6 +4955,9 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
4648
4955
|
}
|
|
4649
4956
|
};
|
|
4650
4957
|
|
|
4958
|
+
// src/terrain/terrain-cover.ts
|
|
4959
|
+
var import_core24 = __toESM(require_core(), 1);
|
|
4960
|
+
|
|
4651
4961
|
// ../../node_modules/@luma.gl/webgl/dist/constants/webgl-constants.js
|
|
4652
4962
|
var GLEnum;
|
|
4653
4963
|
(function(GLEnum2) {
|
|
@@ -5398,8 +5708,8 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
5398
5708
|
if (!this.targetBounds) {
|
|
5399
5709
|
shouldRedraw = true;
|
|
5400
5710
|
this.targetBounds = this.tile.boundingBox;
|
|
5401
|
-
const bottomLeftCommon =
|
|
5402
|
-
const topRightCommon =
|
|
5711
|
+
const bottomLeftCommon = lngLatToMercatorCommon(this.targetBounds[0]);
|
|
5712
|
+
const topRightCommon = lngLatToMercatorCommon(this.targetBounds[1]);
|
|
5403
5713
|
this.targetBoundsCommon = [
|
|
5404
5714
|
bottomLeftCommon[0],
|
|
5405
5715
|
bottomLeftCommon[1],
|
|
@@ -5410,7 +5720,10 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
5410
5720
|
} else if (this.targetBounds !== targetLayer.getBounds()) {
|
|
5411
5721
|
shouldRedraw = true;
|
|
5412
5722
|
this.targetBounds = targetLayer.getBounds();
|
|
5413
|
-
this.targetBoundsCommon = joinLayerBounds(
|
|
5723
|
+
this.targetBoundsCommon = joinLayerBounds(
|
|
5724
|
+
[targetLayer],
|
|
5725
|
+
getMercatorReferenceViewport(viewport)
|
|
5726
|
+
);
|
|
5414
5727
|
}
|
|
5415
5728
|
if (!this.targetBoundsCommon) {
|
|
5416
5729
|
return false;
|
|
@@ -5421,7 +5734,7 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
5421
5734
|
} else {
|
|
5422
5735
|
const oldZoom = this.renderViewport?.zoom;
|
|
5423
5736
|
shouldRedraw = shouldRedraw || newZoom !== oldZoom;
|
|
5424
|
-
const newBounds = getRenderBounds(this.targetBoundsCommon, viewport);
|
|
5737
|
+
const newBounds = viewport instanceof import_core24._GlobeViewport ? this.targetBoundsCommon : getRenderBounds(this.targetBoundsCommon, viewport);
|
|
5425
5738
|
const oldBounds = this.bounds;
|
|
5426
5739
|
shouldRedraw = shouldRedraw || !oldBounds || newBounds.some((x, i) => x !== oldBounds[i]);
|
|
5427
5740
|
this.bounds = newBounds;
|
|
@@ -5498,7 +5811,7 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
5498
5811
|
}
|
|
5499
5812
|
|
|
5500
5813
|
// src/terrain/terrain-pass.ts
|
|
5501
|
-
var
|
|
5814
|
+
var import_core25 = __toESM(require_core(), 1);
|
|
5502
5815
|
var TERRAIN_BLENDING = {
|
|
5503
5816
|
blendColorOperation: "max",
|
|
5504
5817
|
blendColorSrcFactor: "one",
|
|
@@ -5507,7 +5820,7 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
5507
5820
|
blendAlphaSrcFactor: "one",
|
|
5508
5821
|
blendAlphaDstFactor: "one"
|
|
5509
5822
|
};
|
|
5510
|
-
var TerrainPass = class extends
|
|
5823
|
+
var TerrainPass = class extends import_core25._LayersPass {
|
|
5511
5824
|
getRenderableLayers(viewport, opts) {
|
|
5512
5825
|
const { layers } = opts;
|
|
5513
5826
|
const result = [];
|
|
@@ -5572,8 +5885,8 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
5572
5885
|
};
|
|
5573
5886
|
|
|
5574
5887
|
// src/terrain/terrain-picking-pass.ts
|
|
5575
|
-
var
|
|
5576
|
-
var TerrainPickingPass = class extends
|
|
5888
|
+
var import_core26 = __toESM(require_core(), 1);
|
|
5889
|
+
var TerrainPickingPass = class extends import_core26._PickLayersPass {
|
|
5577
5890
|
constructor() {
|
|
5578
5891
|
super(...arguments);
|
|
5579
5892
|
/** Save layer index for use when drawing to terrain cover.
|
|
@@ -5649,6 +5962,7 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
5649
5962
|
};
|
|
5650
5963
|
|
|
5651
5964
|
// src/terrain/height-map-builder.ts
|
|
5965
|
+
var import_core27 = __toESM(require_core(), 1);
|
|
5652
5966
|
var MAP_MAX_SIZE = 2048;
|
|
5653
5967
|
var HeightMapBuilder = class {
|
|
5654
5968
|
constructor(device) {
|
|
@@ -5696,13 +6010,13 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
5696
6010
|
if (layersChanged) {
|
|
5697
6011
|
this.layers = layers;
|
|
5698
6012
|
this.layersBounds = layers.map((layer) => layer.getBounds());
|
|
5699
|
-
this.layersBoundsCommon = joinLayerBounds(layers, viewport);
|
|
6013
|
+
this.layersBoundsCommon = joinLayerBounds(layers, getMercatorReferenceViewport(viewport));
|
|
5700
6014
|
}
|
|
5701
6015
|
const viewportChanged = !this.lastViewport || !viewport.equals(this.lastViewport);
|
|
5702
6016
|
if (!this.layersBoundsCommon) {
|
|
5703
6017
|
this.renderViewport = null;
|
|
5704
6018
|
} else if (layersChanged || viewportChanged) {
|
|
5705
|
-
const bounds = getRenderBounds(this.layersBoundsCommon, viewport);
|
|
6019
|
+
const bounds = viewport instanceof import_core27._GlobeViewport ? this.layersBoundsCommon : getRenderBounds(this.layersBoundsCommon, viewport);
|
|
5706
6020
|
if (bounds[2] <= bounds[0] || bounds[3] <= bounds[1]) {
|
|
5707
6021
|
this.renderViewport = null;
|
|
5708
6022
|
return false;
|
|
@@ -5712,17 +6026,16 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
5712
6026
|
const scale2 = viewport.scale;
|
|
5713
6027
|
const pixelWidth = (bounds[2] - bounds[0]) * scale2;
|
|
5714
6028
|
const pixelHeight = (bounds[3] - bounds[1]) * scale2;
|
|
6029
|
+
const centerMerc = viewport.isGeospatial ? lngLatToMercatorCommon([
|
|
6030
|
+
viewport.longitude ?? 0,
|
|
6031
|
+
viewport.latitude ?? 0
|
|
6032
|
+
]) : [viewport.center[0], viewport.center[1]];
|
|
5715
6033
|
this.renderViewport = pixelWidth > 0 || pixelHeight > 0 ? makeViewport({
|
|
5716
6034
|
// It's not important whether the geometry is visible in this viewport, because
|
|
5717
6035
|
// vertices will not use the standard project_to_clipspace in the DRAW_TO_HEIGHT_MAP shader
|
|
5718
6036
|
// However the viewport must have the same center and zoom as the screen viewport
|
|
5719
6037
|
// So that projection uniforms used for calculating z are the same
|
|
5720
|
-
bounds: [
|
|
5721
|
-
viewport.center[0] - 1,
|
|
5722
|
-
viewport.center[1] - 1,
|
|
5723
|
-
viewport.center[0] + 1,
|
|
5724
|
-
viewport.center[1] + 1
|
|
5725
|
-
],
|
|
6038
|
+
bounds: [centerMerc[0] - 1, centerMerc[1] - 1, centerMerc[0] + 1, centerMerc[1] + 1],
|
|
5726
6039
|
zoom: viewport.zoom,
|
|
5727
6040
|
width: Math.min(pixelWidth, MAP_MAX_SIZE),
|
|
5728
6041
|
height: Math.min(pixelHeight, MAP_MAX_SIZE),
|
|
@@ -5764,7 +6077,7 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
5764
6077
|
if (HeightMapBuilder.isSupported(device)) {
|
|
5765
6078
|
this.heightMap = new HeightMapBuilder(device);
|
|
5766
6079
|
} else {
|
|
5767
|
-
|
|
6080
|
+
import_core28.log.warn("Terrain offset mode is not supported by this browser")();
|
|
5768
6081
|
}
|
|
5769
6082
|
deck._addDefaultShaderModule(terrainModule);
|
|
5770
6083
|
}
|
|
@@ -5933,7 +6246,7 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
5933
6246
|
var defaultProps8 = {
|
|
5934
6247
|
terrainDrawMode: void 0
|
|
5935
6248
|
};
|
|
5936
|
-
var TerrainExtension = class extends
|
|
6249
|
+
var TerrainExtension = class extends import_core29.LayerExtension {
|
|
5937
6250
|
getShaders() {
|
|
5938
6251
|
return {
|
|
5939
6252
|
modules: [terrainModule]
|
|
@@ -35,7 +35,7 @@ export declare const patternShaders: {
|
|
|
35
35
|
readonly name: "geometry";
|
|
36
36
|
readonly source: "const SMOOTH_EDGE_RADIUS: f32 = 0.5;\n\nstruct VertexGeometry {\n position: vec4<f32>,\n worldPosition: vec3<f32>,\n worldPositionAlt: vec3<f32>,\n normal: vec3<f32>,\n uv: vec2<f32>,\n pickingColor: vec3<f32>,\n};\n\nvar<private> geometry_: VertexGeometry = VertexGeometry(\n vec4<f32>(0.0, 0.0, 1.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0),\n vec2<f32>(0.0, 0.0),\n vec3<f32>(0.0, 0.0, 0.0)\n);\n\nstruct FragmentGeometry {\n uv: vec2<f32>,\n};\n\nvar<private> fragmentGeometry: FragmentGeometry;\n\nfn smoothedge(edge: f32, x: f32) -> f32 {\n return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n";
|
|
37
37
|
readonly vs: "#define SMOOTH_EDGE_RADIUS 0.5\n\nstruct VertexGeometry {\n vec4 position;\n vec3 worldPosition;\n vec3 worldPositionAlt;\n vec3 normal;\n vec2 uv;\n vec3 pickingColor;\n} geometry = VertexGeometry(\n vec4(0.0, 0.0, 1.0, 0.0),\n vec3(0.0),\n vec3(0.0),\n vec3(0.0),\n vec2(0.0),\n vec3(0.0)\n);\n";
|
|
38
|
-
readonly fs: "#define SMOOTH_EDGE_RADIUS 0.5\n\nstruct FragmentGeometry {\n vec2 uv;\n} geometry;\n\nfloat smoothedge(float edge, float x) {\n return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n";
|
|
38
|
+
readonly fs: "#define SMOOTH_EDGE_RADIUS 0.5\n\nstruct FragmentGeometry {\n vec2 uv;\n};\nFragmentGeometry geometry;\n\nfloat smoothedge(float edge, float x) {\n return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n";
|
|
39
39
|
}];
|
|
40
40
|
readonly source: string;
|
|
41
41
|
readonly vs: string;
|