@deck.gl/extensions 9.4.0-alpha.1 → 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 +267 -0
- package/dist.min.js +312 -45
- package/package.json +10 -6
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
|
}
|
package/dist.min.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['deck'] = factory();
|
|
6
6
|
else root['deck'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var
|
|
7
|
+
"use strict";var __exports__=(()=>{var Yt=Object.create;var Q=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var $t=Object.getOwnPropertyNames;var Zt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var Ae=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Se=(i,e)=>{for(var t in e)Q(i,t,{get:e[t],enumerable:!0})},X=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of $t(e))!Jt.call(i,o)&&o!==t&&Q(i,o,{get:()=>e[o],enumerable:!(r=Kt(e,o))||r.enumerable});return i},y=(i,e,t)=>(X(i,e,"default"),t&&X(t,e,"default")),d=(i,e,t)=>(t=i!=null?Yt(Zt(i)):{},X(e||!i||!i.__esModule?Q(t,"default",{value:i,enumerable:!0}):t,i)),Xt=i=>X(Q({},"__esModule",{value:!0}),i);var _=Ae((qr,Ie)=>{Ie.exports=globalThis.deck});var Ye=Ae((Jr,We)=>{We.exports=globalThis.luma});var J={};Se(J,{BrushingExtension:()=>Be,ClipExtension:()=>Ft,CollisionFilterExtension:()=>It,DataFilterExtension:()=>Qe,FillStyleExtension:()=>Pt,Fp64Extension:()=>dt,MaskExtension:()=>Nt,PathStyleExtension:()=>gt,_TerrainExtension:()=>Wt,project64:()=>oe});var x={},Ce=d(_(),1);y(x,d(_(),1));if(!Ce.Layer)throw new Error("@deck.gl/core is not found");y(J,x);var Ne=d(_(),1);var Re=d(_(),1),ke=`layout(std140) uniform brushingUniforms {
|
|
8
8
|
bool enabled;
|
|
9
9
|
highp int target;
|
|
10
10
|
vec2 mousePos;
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
void brushing_setVisible(bool visible) {
|
|
34
34
|
brushing_isVisible = float(visible);
|
|
35
35
|
}
|
|
36
|
-
`,
|
|
36
|
+
`,ei=`
|
|
37
37
|
${ke}
|
|
38
38
|
${Qt}
|
|
39
|
-
`,
|
|
39
|
+
`,ti=`
|
|
40
40
|
in float brushing_isVisible;
|
|
41
|
-
`,
|
|
41
|
+
`,ii=`
|
|
42
42
|
${ke}
|
|
43
|
-
${
|
|
44
|
-
`,
|
|
43
|
+
${ti}
|
|
44
|
+
`,ri={source:0,target:1,custom:2,source_target:3},oi={"vs:DECKGL_FILTER_GL_POSITION":`
|
|
45
45
|
vec2 brushingTarget;
|
|
46
46
|
vec2 brushingSource;
|
|
47
47
|
if (brushing.target == 3) {
|
|
@@ -65,7 +65,7 @@ ${tr}
|
|
|
65
65
|
if (brushing.enabled && brushing_isVisible < 0.5) {
|
|
66
66
|
discard;
|
|
67
67
|
}
|
|
68
|
-
`},we={name:"brushing",dependencies:[
|
|
68
|
+
`},we={name:"brushing",dependencies:[Re.project],vs:ei,fs:ii,inject:oi,getUniforms:i=>{if(!i||!("viewport"in i))return{};let{brushingEnabled:e=!0,brushingRadius:t=1e4,brushingTarget:r="source",mousePosition:o,viewport:s}=i;return{enabled:Boolean(e&&o&&s.containsPixel(o)),radius:t,target:ri[r]||0,mousePos:o?s.unproject([o.x-s.x,o.y-s.y]):[0,0]}},uniformTypes:{enabled:"i32",target:"i32",mousePos:"vec2<f32>",radius:"f32"}};var si={getBrushingTarget:{type:"accessor",value:[0,0]},brushingTarget:"source",brushingEnabled:!0,brushingRadius:1e4},S=class extends Ne.LayerExtension{getShaders(){return{modules:[we]}}initializeState(e,t){let r=this.getAttributeManager();r&&r.add({brushingTargets:{size:2,stepMode:"dynamic",accessor:"getBrushingTarget"}});let o=()=>{this.getCurrentLayer()?.setNeedsRedraw()};this.state.onMouseMove=o,e.deck&&e.deck.eventManager.on({pointermove:o,pointerleave:o})}finalizeState(e,t){if(e.deck){let r=this.state.onMouseMove;e.deck.eventManager.off({pointermove:r,pointerleave:r})}}draw(e,t){let{viewport:r,mousePosition:o}=e.context,{brushingEnabled:s,brushingRadius:n,brushingTarget:a}=this.props,l={viewport:r,mousePosition:o,brushingEnabled:s,brushingRadius:n,brushingTarget:a};this.setShaderModuleProps({brushing:l})}};S.defaultProps=si;S.extensionName="BrushingExtension";var Be=S;var E=d(_(),1);var De=`layout(std140) uniform dataFilterUniforms {
|
|
69
69
|
bool useSoftMargin;
|
|
70
70
|
bool enabled;
|
|
71
71
|
bool transformSize;
|
|
@@ -78,7 +78,7 @@ ${tr}
|
|
|
78
78
|
vec4 max64High;
|
|
79
79
|
highp uvec4 categoryBitMask;
|
|
80
80
|
} dataFilter;
|
|
81
|
-
`,
|
|
81
|
+
`,ni=`
|
|
82
82
|
#ifdef DATAFILTER_TYPE
|
|
83
83
|
in DATAFILTER_TYPE filterValues;
|
|
84
84
|
#ifdef DATAFILTER_DOUBLE
|
|
@@ -241,13 +241,13 @@ float dataFilter_reduceValue(vec4 value) {
|
|
|
241
241
|
#endif
|
|
242
242
|
`,ze=`
|
|
243
243
|
${De}
|
|
244
|
-
${
|
|
245
|
-
`,
|
|
244
|
+
${ni}
|
|
245
|
+
`,ai=`
|
|
246
246
|
in float dataFilter_value;
|
|
247
247
|
`,Ve=`
|
|
248
248
|
${De}
|
|
249
|
-
${
|
|
250
|
-
`;function je(
|
|
249
|
+
${ai}
|
|
250
|
+
`;function je(i){if(!i||!("extensions"in i))return{};let{filterRange:e=[-1,1],filterEnabled:t=!0,filterTransformSize:r=!0,filterTransformColor:o=!0,categoryBitMask:s}=i,n=i.filterSoftRange||e,a=l=>Array.isArray(l)?[l[0]||0,l[1]||0,l[2]||0,l[3]||0]:[l,0,0,0];return{...Number.isFinite(e[0])?{min:a(e[0]),softMin:a(n[0]),softMax:a(n[1]),max:a(e[1])}:{min:a(e.map(l=>l[0])),softMin:a(n.map(l=>l[0])),softMax:a(n.map(l=>l[1])),max:a(e.map(l=>l[1]))},enabled:t,useSoftMargin:Boolean(i.filterSoftRange),transformSize:t&&r,transformColor:t&&o,...s&&{categoryBitMask:s}}}function li(i){if(!i||!("extensions"in i))return{};let e=je(i),t=e.min.map(Math.fround);e.min=e.min.map((o,s)=>o-t[s]),e.softMin=e.softMin.map((o,s)=>o-t[s]),e.min64High=t;let r=e.max.map(Math.fround);return e.max=e.max.map((o,s)=>o-r[s]),e.softMax=e.softMax.map((o,s)=>o-r[s]),e.max64High=r,e}var Ue={"vs:#main-start":`
|
|
251
251
|
dataFilter_value = 1.0;
|
|
252
252
|
if (dataFilter.enabled) {
|
|
253
253
|
#ifdef DATAFILTER_TYPE
|
|
@@ -278,7 +278,7 @@ ${nr}
|
|
|
278
278
|
if (dataFilter.transformColor) {
|
|
279
279
|
color.a *= dataFilter_value;
|
|
280
280
|
}
|
|
281
|
-
`};function Ge(
|
|
281
|
+
`};function Ge(i){return{useSoftMargin:"i32",enabled:"i32",transformSize:"i32",transformColor:"i32",min:"vec4<f32>",softMin:"vec4<f32>",softMax:"vec4<f32>",max:"vec4<f32>",min64High:"vec4<f32>",max64High:"vec4<f32>",categoryBitMask:"vec4<u32>"}}var He={name:"dataFilter",vs:ze,fs:Ve,inject:Ue,getUniforms:je,uniformTypesFromOptions:Ge},qe={name:"dataFilter",vs:ze,fs:Ve,inject:Ue,getUniforms:li,uniformTypesFromOptions:Ge};var Ke=d(Ye(),1),fi=`#version 300 es
|
|
282
282
|
#define SHADER_NAME data-filter-vertex-shader
|
|
283
283
|
|
|
284
284
|
#ifdef FLOAT_TARGET
|
|
@@ -309,7 +309,7 @@ void main() {
|
|
|
309
309
|
#endif
|
|
310
310
|
gl_PointSize = 1.0;
|
|
311
311
|
}
|
|
312
|
-
`,
|
|
312
|
+
`,ci=`#version 300 es
|
|
313
313
|
#define SHADER_NAME data-filter-fragment-shader
|
|
314
314
|
precision highp float;
|
|
315
315
|
|
|
@@ -323,7 +323,7 @@ void main() {
|
|
|
323
323
|
}
|
|
324
324
|
fragColor = vColor;
|
|
325
325
|
}
|
|
326
|
-
`,pr=["float32-renderable-webgl","texture-blend-float-webgl"];function $e(r){return pr.every(e=>r.features.has(e))}function Ze(r,e){return e?r.createFramebuffer({width:1,height:1,colorAttachments:[r.createTexture({format:"rgba32float",dimension:"2d",width:1,height:1})]}):r.createFramebuffer({width:256,height:64,colorAttachments:[r.createTexture({format:"rgba8unorm",dimension:"2d",width:256,height:64})]})}function Je(r,e,t,o){return t.defines.NON_INSTANCED_MODEL=1,o&&(t.defines.FLOAT_TARGET=1),new Ye.Model(r,{id:"data-filter-aggregation-model",vertexCount:1,isInstanced:!1,topology:"point-list",disableWarnings:!0,vs:cr,fs:fr,bufferLayout:e,...t})}var Xe={blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendColorOperation:"add",blendAlphaOperation:"add",depthCompare:"never"};var dr={getFilterValue:{type:"accessor",value:0},getFilterCategory:{type:"accessor",value:0},onFilteredItemsChange:{type:"function",value:null,optional:!0},filterEnabled:!0,filterRange:[-1,1],filterSoftRange:null,filterCategories:[0],filterTransformSize:!0,filterTransformColor:!0},_r={categorySize:0,filterSize:1,fp64:!1,countItems:!1},mr={1:"uint",2:"uvec2",3:"uvec3",4:"uvec4"},hr={1:"float",2:"vec2",3:"vec3",4:"vec4"},I=class extends M.LayerExtension{constructor(e={}){super({..._r,...e})}getShaders(e){let{categorySize:t,filterSize:o,fp64:i}=e.opts,s={};t&&(s.DATACATEGORY_TYPE=mr[t],s.DATACATEGORY_CHANNELS=t),o&&(s.DATAFILTER_TYPE=hr[o],s.DATAFILTER_DOUBLE=Boolean(i));let a=i?qe:He;return a.uniformTypes=a.uniformTypesFromOptions(e.opts),{modules:[a],defines:s}}initializeState(e,t){let o=this.getAttributeManager(),{categorySize:i,filterSize:s,fp64:a}=t.opts;o&&(s&&o.add({filterValues:{size:s,type:a?"float64":"float32",stepMode:"dynamic",accessor:"getFilterValue"}}),i&&o.add({filterCategoryValues:{size:i,stepMode:"dynamic",accessor:"getFilterCategory",type:"uint32",transform:i===1?l=>t._getCategoryKey.call(this,l,0):l=>l.map((c,p)=>t._getCategoryKey.call(this,c,p))}}));let{device:n}=this.context;if(o&&t.opts.countItems){let l=$e(n);o.add({filterVertexIndices:{size:l?1:2,vertexOffset:1,type:"unorm8",accessor:(f,{index:u})=>{let m=f&&f.__source?f.__source.index:u;return l?(m+1)%255:[(m+1)%255,Math.floor(m/255)%255]},shaderAttributes:{filterPrevIndices:{vertexOffset:0},filterIndices:{vertexOffset:1}}}});let c=Ze(n,l),p=Je(n,o.getBufferLayouts({isInstanced:!1}),t.getShaders.call(this,t),l);this.setState({filterFBO:c,filterModel:p})}}updateState({props:e,oldProps:t,changeFlags:o},i){let s=this.getAttributeManager(),{categorySize:a}=i.opts;if(this.state.filterModel){let n=s.attributes.filterValues?.needsUpdate()||s.attributes.filterCategoryValues?.needsUpdate()||e.filterEnabled!==t.filterEnabled||e.filterRange!==t.filterRange||e.filterSoftRange!==t.filterSoftRange||e.filterCategories!==t.filterCategories;n&&this.setState({filterNeedsUpdate:n})}s?.attributes.filterCategoryValues&&((s.attributes.filterCategoryValues.needsUpdate()||!(0,M._deepEqual)(e.filterCategories,t.filterCategories,2))&&this.setState({categoryBitMask:null}),o.dataChanged&&(this.setState({categoryMap:Array(a).fill(0).map(()=>({}))}),s.attributes.filterCategoryValues.setNeedsUpdate("categoryMap")))}draw(e,t){let o=this.state.filterFBO,i=this.state.filterModel,s=this.state.filterNeedsUpdate;this.state.categoryBitMask||t._updateCategoryBitMask.call(this,e,t);let{onFilteredItemsChange:a,extensions:n,filterEnabled:l,filterRange:c,filterSoftRange:p,filterTransformSize:f,filterTransformColor:u,filterCategories:m}=this.props,h={extensions:n,filterEnabled:l,filterRange:c,filterSoftRange:p,filterTransformSize:f,filterTransformColor:u,filterCategories:m};if(this.state.categoryBitMask&&(h.categoryBitMask=this.state.categoryBitMask),this.setShaderModuleProps({dataFilter:h}),s&&a&&i){let b=this.getAttributeManager(),{attributes:{filterValues:v,filterCategoryValues:L,filterVertexIndices:pe}}=b;i.setVertexCount(this.getNumInstances());let ue={...v?.getValue(),...L?.getValue(),...pe?.getValue()};i.setAttributes(ue),i.shaderInputs.setProps({dataFilter:h});let de=[0,0,o.width,o.height],Te=i.device.beginRenderPass({id:"data-filter-aggregation",framebuffer:o,parameters:{viewport:de},clearColor:[0,0,0,0]});i.setParameters(Xe),i.draw(Te),Te.end();let Oe=i.device.readPixelsToArrayWebGL(o),Ae=0;for(let _e=0;_e<Oe.length;_e++)Ae+=Oe[_e];a({id:this.id,count:Ae}),this.state.filterNeedsUpdate=!1}}finalizeState(){let e=this.state.filterFBO,t=this.state.filterModel;e?.destroy(),t?.destroy()}_updateCategoryBitMask(e,t){let{categorySize:o}=t.opts;if(!o)return;let{filterCategories:i}=this.props,s=new Uint32Array([0,0,0,0]),a=o===1?[i]:i,n=o===1?128:o===2?64:32;for(let l=0;l<a.length;l++){let c=a[l];for(let p of c){let f=t._getCategoryKey.call(this,p,l);if(f<n){let u=l*(n/32)+Math.floor(f/32);s[u]+=Math.pow(2,f%32)}else M.log.warn(`Exceeded maximum number of categories (${n})`)()}}this.state.categoryBitMask=s}_getCategoryKey(e,t){let o=this.state.categoryMap[t];return e in o||(o[e]=Object.keys(o).length),o[e]}};I.defaultProps=dr;I.extensionName="DataFilterExtension";var Qe=I;var ut=d(_(),1);var ti=1/Math.PI*180,ri=1/180*Math.PI,vr={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...vr}};var R=globalThis.mathgl.config;function me(r){return Array.isArray(r)||ArrayBuffer.isView(r)&&!(r instanceof DataView)}function E(r,e,t){let o=R.EPSILON;t&&(R.EPSILON=t);try{if(r===e)return!0;if(me(r)&&me(e)){if(r.length!==e.length)return!1;for(let i=0;i<r.length;++i)if(!E(r[i],e[i]))return!1;return!0}return r&&r.equals?r.equals(e):e&&e.equals?e.equals(r):typeof r=="number"&&typeof e=="number"?Math.abs(r-e)<=R.EPSILON*Math.max(1,Math.abs(r),Math.abs(e)):!1}finally{R.EPSILON=o}}var C=typeof Float32Array<"u"?Float32Array:Array,he=Math.random;function ee(r){return r>=0?Math.round(r):r%.5===0?Math.floor(r):Math.round(r)}var ii=Math.PI/180;var k={};Se(k,{add:()=>Mr,angle:()=>Wr,bezier:()=>Dr,ceil:()=>Er,clone:()=>xr,copy:()=>Pr,create:()=>et,cross:()=>kr,dist:()=>eo,distance:()=>st,div:()=>Qr,divide:()=>it,dot:()=>ge,equals:()=>Zr,exactEquals:()=>$r,floor:()=>Fr,forEach:()=>io,fromValues:()=>yr,hermite:()=>Br,inverse:()=>Rr,len:()=>ro,length:()=>tt,lerp:()=>wr,max:()=>Or,min:()=>Tr,mul:()=>Xr,multiply:()=>ot,negate:()=>Ir,normalize:()=>Cr,random:()=>zr,rotateX:()=>Gr,rotateY:()=>Hr,rotateZ:()=>qr,round:()=>Ar,scale:()=>Lr,scaleAndAdd:()=>Sr,set:()=>br,slerp:()=>Nr,sqrDist:()=>to,sqrLen:()=>oo,squaredDistance:()=>at,squaredLength:()=>nt,str:()=>Yr,sub:()=>Jr,subtract:()=>rt,transformMat3:()=>jr,transformMat4:()=>Vr,transformQuat:()=>Ur,zero:()=>Kr});function et(){let r=new C(3);return C!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r}function xr(r){let e=new C(3);return e[0]=r[0],e[1]=r[1],e[2]=r[2],e}function tt(r){let e=r[0],t=r[1],o=r[2];return Math.sqrt(e*e+t*t+o*o)}function yr(r,e,t){let o=new C(3);return o[0]=r,o[1]=e,o[2]=t,o}function Pr(r,e){return r[0]=e[0],r[1]=e[1],r[2]=e[2],r}function br(r,e,t,o){return r[0]=e,r[1]=t,r[2]=o,r}function Mr(r,e,t){return r[0]=e[0]+t[0],r[1]=e[1]+t[1],r[2]=e[2]+t[2],r}function rt(r,e,t){return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],r}function ot(r,e,t){return r[0]=e[0]*t[0],r[1]=e[1]*t[1],r[2]=e[2]*t[2],r}function it(r,e,t){return r[0]=e[0]/t[0],r[1]=e[1]/t[1],r[2]=e[2]/t[2],r}function Er(r,e){return r[0]=Math.ceil(e[0]),r[1]=Math.ceil(e[1]),r[2]=Math.ceil(e[2]),r}function Fr(r,e){return r[0]=Math.floor(e[0]),r[1]=Math.floor(e[1]),r[2]=Math.floor(e[2]),r}function Tr(r,e,t){return r[0]=Math.min(e[0],t[0]),r[1]=Math.min(e[1],t[1]),r[2]=Math.min(e[2],t[2]),r}function Or(r,e,t){return r[0]=Math.max(e[0],t[0]),r[1]=Math.max(e[1],t[1]),r[2]=Math.max(e[2],t[2]),r}function Ar(r,e){return r[0]=ee(e[0]),r[1]=ee(e[1]),r[2]=ee(e[2]),r}function Lr(r,e,t){return r[0]=e[0]*t,r[1]=e[1]*t,r[2]=e[2]*t,r}function Sr(r,e,t,o){return r[0]=e[0]+t[0]*o,r[1]=e[1]+t[1]*o,r[2]=e[2]+t[2]*o,r}function st(r,e){let t=e[0]-r[0],o=e[1]-r[1],i=e[2]-r[2];return Math.sqrt(t*t+o*o+i*i)}function at(r,e){let t=e[0]-r[0],o=e[1]-r[1],i=e[2]-r[2];return t*t+o*o+i*i}function nt(r){let e=r[0],t=r[1],o=r[2];return e*e+t*t+o*o}function Ir(r,e){return r[0]=-e[0],r[1]=-e[1],r[2]=-e[2],r}function Rr(r,e){return r[0]=1/e[0],r[1]=1/e[1],r[2]=1/e[2],r}function Cr(r,e){let t=e[0],o=e[1],i=e[2],s=t*t+o*o+i*i;return s>0&&(s=1/Math.sqrt(s)),r[0]=e[0]*s,r[1]=e[1]*s,r[2]=e[2]*s,r}function ge(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]}function kr(r,e,t){let o=e[0],i=e[1],s=e[2],a=t[0],n=t[1],l=t[2];return r[0]=i*l-s*n,r[1]=s*a-o*l,r[2]=o*n-i*a,r}function wr(r,e,t,o){let i=e[0],s=e[1],a=e[2];return r[0]=i+o*(t[0]-i),r[1]=s+o*(t[1]-s),r[2]=a+o*(t[2]-a),r}function Nr(r,e,t,o){let i=Math.acos(Math.min(Math.max(ge(e,t),-1),1)),s=Math.sin(i),a=Math.sin((1-o)*i)/s,n=Math.sin(o*i)/s;return r[0]=a*e[0]+n*t[0],r[1]=a*e[1]+n*t[1],r[2]=a*e[2]+n*t[2],r}function Br(r,e,t,o,i,s){let a=s*s,n=a*(2*s-3)+1,l=a*(s-2)+s,c=a*(s-1),p=a*(3-2*s);return r[0]=e[0]*n+t[0]*l+o[0]*c+i[0]*p,r[1]=e[1]*n+t[1]*l+o[1]*c+i[1]*p,r[2]=e[2]*n+t[2]*l+o[2]*c+i[2]*p,r}function Dr(r,e,t,o,i,s){let a=1-s,n=a*a,l=s*s,c=n*a,p=3*s*n,f=3*l*a,u=l*s;return r[0]=e[0]*c+t[0]*p+o[0]*f+i[0]*u,r[1]=e[1]*c+t[1]*p+o[1]*f+i[1]*u,r[2]=e[2]*c+t[2]*p+o[2]*f+i[2]*u,r}function zr(r,e){e=e===void 0?1:e;let t=he()*2*Math.PI,o=he()*2-1,i=Math.sqrt(1-o*o)*e;return r[0]=Math.cos(t)*i,r[1]=Math.sin(t)*i,r[2]=o*e,r}function Vr(r,e,t){let o=e[0],i=e[1],s=e[2],a=t[3]*o+t[7]*i+t[11]*s+t[15];return a=a||1,r[0]=(t[0]*o+t[4]*i+t[8]*s+t[12])/a,r[1]=(t[1]*o+t[5]*i+t[9]*s+t[13])/a,r[2]=(t[2]*o+t[6]*i+t[10]*s+t[14])/a,r}function jr(r,e,t){let o=e[0],i=e[1],s=e[2];return r[0]=o*t[0]+i*t[3]+s*t[6],r[1]=o*t[1]+i*t[4]+s*t[7],r[2]=o*t[2]+i*t[5]+s*t[8],r}function Ur(r,e,t){let o=t[0],i=t[1],s=t[2],a=t[3],n=e[0],l=e[1],c=e[2],p=i*c-s*l,f=s*n-o*c,u=o*l-i*n,m=i*u-s*f,h=s*p-o*u,b=o*f-i*p,v=a*2;return p*=v,f*=v,u*=v,m*=2,h*=2,b*=2,r[0]=n+p+m,r[1]=l+f+h,r[2]=c+u+b,r}function Gr(r,e,t,o){let i=[],s=[];return i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],s[0]=i[0],s[1]=i[1]*Math.cos(o)-i[2]*Math.sin(o),s[2]=i[1]*Math.sin(o)+i[2]*Math.cos(o),r[0]=s[0]+t[0],r[1]=s[1]+t[1],r[2]=s[2]+t[2],r}function Hr(r,e,t,o){let i=[],s=[];return i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],s[0]=i[2]*Math.sin(o)+i[0]*Math.cos(o),s[1]=i[1],s[2]=i[2]*Math.cos(o)-i[0]*Math.sin(o),r[0]=s[0]+t[0],r[1]=s[1]+t[1],r[2]=s[2]+t[2],r}function qr(r,e,t,o){let i=[],s=[];return i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],s[0]=i[0]*Math.cos(o)-i[1]*Math.sin(o),s[1]=i[0]*Math.sin(o)+i[1]*Math.cos(o),s[2]=i[2],r[0]=s[0]+t[0],r[1]=s[1]+t[1],r[2]=s[2]+t[2],r}function Wr(r,e){let t=r[0],o=r[1],i=r[2],s=e[0],a=e[1],n=e[2],l=Math.sqrt((t*t+o*o+i*i)*(s*s+a*a+n*n)),c=l&&ge(r,e)/l;return Math.acos(Math.min(Math.max(c,-1),1))}function Kr(r){return r[0]=0,r[1]=0,r[2]=0,r}function Yr(r){return`vec3(${r[0]}, ${r[1]}, ${r[2]})`}function $r(r,e){return r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]}function Zr(r,e){let t=r[0],o=r[1],i=r[2],s=e[0],a=e[1],n=e[2];return Math.abs(t-s)<=1e-6*Math.max(1,Math.abs(t),Math.abs(s))&&Math.abs(o-a)<=1e-6*Math.max(1,Math.abs(o),Math.abs(a))&&Math.abs(i-n)<=1e-6*Math.max(1,Math.abs(i),Math.abs(n))}var Jr=rt,Xr=ot,Qr=it,eo=st,to=at,ro=tt,oo=nt,io=function(){let r=et();return function(e,t,o,i,s,a){let n,l;for(t||(t=3),o||(o=0),i?l=Math.min(i*t+o,e.length):l=e.length,n=o;n<l;n+=t)r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],s(r,r,a),e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2];return e}}();function te(r,e=[],t=0){let o=Math.fround(r),i=r-o;return e[t]=o,e[t+1]=i,e}function xe(r){return r-Math.fround(r)}function ye(r){let e=new Float32Array(32);for(let t=0;t<4;++t)for(let o=0;o<4;++o){let i=t*4+o;te(r[o*4+t],e,i*2)}return e}var Pe=`
|
|
326
|
+
`,ui=["float32-renderable-webgl","texture-blend-float-webgl"];function $e(i){return ui.every(e=>i.features.has(e))}function Ze(i,e){return e?i.createFramebuffer({width:1,height:1,colorAttachments:[i.createTexture({format:"rgba32float",dimension:"2d",width:1,height:1})]}):i.createFramebuffer({width:256,height:64,colorAttachments:[i.createTexture({format:"rgba8unorm",dimension:"2d",width:256,height:64})]})}function Je(i,e,t,r){return t.defines.NON_INSTANCED_MODEL=1,r&&(t.defines.FLOAT_TARGET=1),new Ke.Model(i,{id:"data-filter-aggregation-model",vertexCount:1,isInstanced:!1,topology:"point-list",disableWarnings:!0,vs:fi,fs:ci,bufferLayout:e,...t})}var Xe={blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendColorOperation:"add",blendAlphaOperation:"add",depthCompare:"never"};var di={getFilterValue:{type:"accessor",value:0},getFilterCategory:{type:"accessor",value:0},onFilteredItemsChange:{type:"function",value:null,optional:!0},filterEnabled:!0,filterRange:[-1,1],filterSoftRange:null,filterCategories:[0],filterTransformSize:!0,filterTransformColor:!0},_i={categorySize:0,filterSize:1,fp64:!1,countItems:!1},mi={1:"uint",2:"uvec2",3:"uvec3",4:"uvec4"},hi={1:"float",2:"vec2",3:"vec3",4:"vec4"},I=class extends E.LayerExtension{constructor(e={}){super({..._i,...e})}getShaders(e){let{categorySize:t,filterSize:r,fp64:o}=e.opts,s={};t&&(s.DATACATEGORY_TYPE=mi[t],s.DATACATEGORY_CHANNELS=t),r&&(s.DATAFILTER_TYPE=hi[r],s.DATAFILTER_DOUBLE=Boolean(o));let n=o?qe:He;return n.uniformTypes=n.uniformTypesFromOptions(e.opts),{modules:[n],defines:s}}initializeState(e,t){let r=this.getAttributeManager(),{categorySize:o,filterSize:s,fp64:n}=t.opts;r&&(s&&r.add({filterValues:{size:s,type:n?"float64":"float32",stepMode:"dynamic",accessor:"getFilterValue"}}),o&&r.add({filterCategoryValues:{size:o,stepMode:"dynamic",accessor:"getFilterCategory",type:"uint32",transform:o===1?l=>t._getCategoryKey.call(this,l,0):l=>l.map((f,u)=>t._getCategoryKey.call(this,f,u))}}));let{device:a}=this.context;if(r&&t.opts.countItems){let l=$e(a);r.add({filterVertexIndices:{size:l?1:2,vertexOffset:1,type:"unorm8",accessor:(c,{index:p})=>{let m=c&&c.__source?c.__source.index:p;return l?(m+1)%255:[(m+1)%255,Math.floor(m/255)%255]},shaderAttributes:{filterPrevIndices:{vertexOffset:0},filterIndices:{vertexOffset:1}}}});let f=Ze(a,l),u=Je(a,r.getBufferLayouts({isInstanced:!1}),t.getShaders.call(this,t),l);this.setState({filterFBO:f,filterModel:u})}}updateState({props:e,oldProps:t,changeFlags:r},o){let s=this.getAttributeManager(),{categorySize:n}=o.opts;if(this.state.filterModel){let a=s.attributes.filterValues?.needsUpdate()||s.attributes.filterCategoryValues?.needsUpdate()||e.filterEnabled!==t.filterEnabled||e.filterRange!==t.filterRange||e.filterSoftRange!==t.filterSoftRange||e.filterCategories!==t.filterCategories;a&&this.setState({filterNeedsUpdate:a})}s?.attributes.filterCategoryValues&&((s.attributes.filterCategoryValues.needsUpdate()||!(0,E._deepEqual)(e.filterCategories,t.filterCategories,2))&&this.setState({categoryBitMask:null}),r.dataChanged&&(this.setState({categoryMap:Array(n).fill(0).map(()=>({}))}),s.attributes.filterCategoryValues.setNeedsUpdate("categoryMap")))}draw(e,t){let r=this.state.filterFBO,o=this.state.filterModel,s=this.state.filterNeedsUpdate;this.state.categoryBitMask||t._updateCategoryBitMask.call(this,e,t);let{onFilteredItemsChange:n,extensions:a,filterEnabled:l,filterRange:f,filterSoftRange:u,filterTransformSize:c,filterTransformColor:p,filterCategories:m}=this.props,h={extensions:a,filterEnabled:l,filterRange:f,filterSoftRange:u,filterTransformSize:c,filterTransformColor:p,filterCategories:m};if(this.state.categoryBitMask&&(h.categoryBitMask=this.state.categoryBitMask),this.setShaderModuleProps({dataFilter:h}),s&&n&&o){let P=this.getAttributeManager(),{attributes:{filterValues:v,filterCategoryValues:A,filterVertexIndices:ue}}=P;o.setVertexCount(this.getNumInstances());let pe={...v?.getValue(),...A?.getValue(),...ue?.getValue()};o.setAttributes(pe),o.shaderInputs.setProps({dataFilter:h});let de=[0,0,r.width,r.height],Te=o.device.beginRenderPass({id:"data-filter-aggregation",framebuffer:r,parameters:{viewport:de},clearColor:[0,0,0,0]});o.setParameters(Xe),o.draw(Te),Te.end();let Oe=o.device.readPixelsToArrayWebGL(r),Le=0;for(let _e=0;_e<Oe.length;_e++)Le+=Oe[_e];n({id:this.id,count:Le}),this.state.filterNeedsUpdate=!1}}finalizeState(){let e=this.state.filterFBO,t=this.state.filterModel;e?.destroy(),t?.destroy()}_updateCategoryBitMask(e,t){let{categorySize:r}=t.opts;if(!r)return;let{filterCategories:o}=this.props,s=new Uint32Array([0,0,0,0]),n=r===1?[o]:o,a=r===1?128:r===2?64:32;for(let l=0;l<n.length;l++){let f=n[l];for(let u of f){let c=t._getCategoryKey.call(this,u,l);if(c<a){let p=l*(a/32)+Math.floor(c/32);s[p]+=Math.pow(2,c%32)}else E.log.warn(`Exceeded maximum number of categories (${a})`)()}}this.state.categoryBitMask=s}_getCategoryKey(e,t){let r=this.state.categoryMap[t];return e in r||(r[e]=Object.keys(r).length),r[e]}};I.defaultProps=di;I.extensionName="DataFilterExtension";var Qe=I;var pt=d(_(),1);var eo=1/Math.PI*180,to=1/180*Math.PI,vi={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...vi}};var C=globalThis.mathgl.config;function me(i){return Array.isArray(i)||ArrayBuffer.isView(i)&&!(i instanceof DataView)}function M(i,e,t){let r=C.EPSILON;t&&(C.EPSILON=t);try{if(i===e)return!0;if(me(i)&&me(e)){if(i.length!==e.length)return!1;for(let o=0;o<i.length;++o)if(!M(i[o],e[o]))return!1;return!0}return i&&i.equals?i.equals(e):e&&e.equals?e.equals(i):typeof i=="number"&&typeof e=="number"?Math.abs(i-e)<=C.EPSILON*Math.max(1,Math.abs(i),Math.abs(e)):!1}finally{C.EPSILON=r}}var R=typeof Float32Array<"u"?Float32Array:Array,he=Math.random;function ee(i){return i>=0?Math.round(i):i%.5===0?Math.floor(i):Math.round(i)}var ro=Math.PI/180;var k={};Se(k,{add:()=>Ei,angle:()=>Wi,bezier:()=>Di,ceil:()=>Mi,clone:()=>xi,copy:()=>bi,create:()=>et,cross:()=>ki,dist:()=>er,distance:()=>st,div:()=>Qi,divide:()=>ot,dot:()=>ge,equals:()=>Zi,exactEquals:()=>$i,floor:()=>Fi,forEach:()=>or,fromValues:()=>yi,hermite:()=>Bi,inverse:()=>Ci,len:()=>ir,length:()=>tt,lerp:()=>wi,max:()=>Oi,min:()=>Ti,mul:()=>Xi,multiply:()=>rt,negate:()=>Ii,normalize:()=>Ri,random:()=>zi,rotateX:()=>Gi,rotateY:()=>Hi,rotateZ:()=>qi,round:()=>Li,scale:()=>Ai,scaleAndAdd:()=>Si,set:()=>Pi,slerp:()=>Ni,sqrDist:()=>tr,sqrLen:()=>rr,squaredDistance:()=>nt,squaredLength:()=>at,str:()=>Ki,sub:()=>Ji,subtract:()=>it,transformMat3:()=>ji,transformMat4:()=>Vi,transformQuat:()=>Ui,zero:()=>Yi});function et(){let i=new R(3);return R!=Float32Array&&(i[0]=0,i[1]=0,i[2]=0),i}function xi(i){let e=new R(3);return e[0]=i[0],e[1]=i[1],e[2]=i[2],e}function tt(i){let e=i[0],t=i[1],r=i[2];return Math.sqrt(e*e+t*t+r*r)}function yi(i,e,t){let r=new R(3);return r[0]=i,r[1]=e,r[2]=t,r}function bi(i,e){return i[0]=e[0],i[1]=e[1],i[2]=e[2],i}function Pi(i,e,t,r){return i[0]=e,i[1]=t,i[2]=r,i}function Ei(i,e,t){return i[0]=e[0]+t[0],i[1]=e[1]+t[1],i[2]=e[2]+t[2],i}function it(i,e,t){return i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],i}function rt(i,e,t){return i[0]=e[0]*t[0],i[1]=e[1]*t[1],i[2]=e[2]*t[2],i}function ot(i,e,t){return i[0]=e[0]/t[0],i[1]=e[1]/t[1],i[2]=e[2]/t[2],i}function Mi(i,e){return i[0]=Math.ceil(e[0]),i[1]=Math.ceil(e[1]),i[2]=Math.ceil(e[2]),i}function Fi(i,e){return i[0]=Math.floor(e[0]),i[1]=Math.floor(e[1]),i[2]=Math.floor(e[2]),i}function Ti(i,e,t){return i[0]=Math.min(e[0],t[0]),i[1]=Math.min(e[1],t[1]),i[2]=Math.min(e[2],t[2]),i}function Oi(i,e,t){return i[0]=Math.max(e[0],t[0]),i[1]=Math.max(e[1],t[1]),i[2]=Math.max(e[2],t[2]),i}function Li(i,e){return i[0]=ee(e[0]),i[1]=ee(e[1]),i[2]=ee(e[2]),i}function Ai(i,e,t){return i[0]=e[0]*t,i[1]=e[1]*t,i[2]=e[2]*t,i}function Si(i,e,t,r){return i[0]=e[0]+t[0]*r,i[1]=e[1]+t[1]*r,i[2]=e[2]+t[2]*r,i}function st(i,e){let t=e[0]-i[0],r=e[1]-i[1],o=e[2]-i[2];return Math.sqrt(t*t+r*r+o*o)}function nt(i,e){let t=e[0]-i[0],r=e[1]-i[1],o=e[2]-i[2];return t*t+r*r+o*o}function at(i){let e=i[0],t=i[1],r=i[2];return e*e+t*t+r*r}function Ii(i,e){return i[0]=-e[0],i[1]=-e[1],i[2]=-e[2],i}function Ci(i,e){return i[0]=1/e[0],i[1]=1/e[1],i[2]=1/e[2],i}function Ri(i,e){let t=e[0],r=e[1],o=e[2],s=t*t+r*r+o*o;return s>0&&(s=1/Math.sqrt(s)),i[0]=e[0]*s,i[1]=e[1]*s,i[2]=e[2]*s,i}function ge(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]}function ki(i,e,t){let r=e[0],o=e[1],s=e[2],n=t[0],a=t[1],l=t[2];return i[0]=o*l-s*a,i[1]=s*n-r*l,i[2]=r*a-o*n,i}function wi(i,e,t,r){let o=e[0],s=e[1],n=e[2];return i[0]=o+r*(t[0]-o),i[1]=s+r*(t[1]-s),i[2]=n+r*(t[2]-n),i}function Ni(i,e,t,r){let o=Math.acos(Math.min(Math.max(ge(e,t),-1),1)),s=Math.sin(o),n=Math.sin((1-r)*o)/s,a=Math.sin(r*o)/s;return i[0]=n*e[0]+a*t[0],i[1]=n*e[1]+a*t[1],i[2]=n*e[2]+a*t[2],i}function Bi(i,e,t,r,o,s){let n=s*s,a=n*(2*s-3)+1,l=n*(s-2)+s,f=n*(s-1),u=n*(3-2*s);return i[0]=e[0]*a+t[0]*l+r[0]*f+o[0]*u,i[1]=e[1]*a+t[1]*l+r[1]*f+o[1]*u,i[2]=e[2]*a+t[2]*l+r[2]*f+o[2]*u,i}function Di(i,e,t,r,o,s){let n=1-s,a=n*n,l=s*s,f=a*n,u=3*s*a,c=3*l*n,p=l*s;return i[0]=e[0]*f+t[0]*u+r[0]*c+o[0]*p,i[1]=e[1]*f+t[1]*u+r[1]*c+o[1]*p,i[2]=e[2]*f+t[2]*u+r[2]*c+o[2]*p,i}function zi(i,e){e=e===void 0?1:e;let t=he()*2*Math.PI,r=he()*2-1,o=Math.sqrt(1-r*r)*e;return i[0]=Math.cos(t)*o,i[1]=Math.sin(t)*o,i[2]=r*e,i}function Vi(i,e,t){let r=e[0],o=e[1],s=e[2],n=t[3]*r+t[7]*o+t[11]*s+t[15];return n=n||1,i[0]=(t[0]*r+t[4]*o+t[8]*s+t[12])/n,i[1]=(t[1]*r+t[5]*o+t[9]*s+t[13])/n,i[2]=(t[2]*r+t[6]*o+t[10]*s+t[14])/n,i}function ji(i,e,t){let r=e[0],o=e[1],s=e[2];return i[0]=r*t[0]+o*t[3]+s*t[6],i[1]=r*t[1]+o*t[4]+s*t[7],i[2]=r*t[2]+o*t[5]+s*t[8],i}function Ui(i,e,t){let r=t[0],o=t[1],s=t[2],n=t[3],a=e[0],l=e[1],f=e[2],u=o*f-s*l,c=s*a-r*f,p=r*l-o*a,m=o*p-s*c,h=s*u-r*p,P=r*c-o*u,v=n*2;return u*=v,c*=v,p*=v,m*=2,h*=2,P*=2,i[0]=a+u+m,i[1]=l+c+h,i[2]=f+p+P,i}function Gi(i,e,t,r){let o=[],s=[];return o[0]=e[0]-t[0],o[1]=e[1]-t[1],o[2]=e[2]-t[2],s[0]=o[0],s[1]=o[1]*Math.cos(r)-o[2]*Math.sin(r),s[2]=o[1]*Math.sin(r)+o[2]*Math.cos(r),i[0]=s[0]+t[0],i[1]=s[1]+t[1],i[2]=s[2]+t[2],i}function Hi(i,e,t,r){let o=[],s=[];return o[0]=e[0]-t[0],o[1]=e[1]-t[1],o[2]=e[2]-t[2],s[0]=o[2]*Math.sin(r)+o[0]*Math.cos(r),s[1]=o[1],s[2]=o[2]*Math.cos(r)-o[0]*Math.sin(r),i[0]=s[0]+t[0],i[1]=s[1]+t[1],i[2]=s[2]+t[2],i}function qi(i,e,t,r){let o=[],s=[];return o[0]=e[0]-t[0],o[1]=e[1]-t[1],o[2]=e[2]-t[2],s[0]=o[0]*Math.cos(r)-o[1]*Math.sin(r),s[1]=o[0]*Math.sin(r)+o[1]*Math.cos(r),s[2]=o[2],i[0]=s[0]+t[0],i[1]=s[1]+t[1],i[2]=s[2]+t[2],i}function Wi(i,e){let t=i[0],r=i[1],o=i[2],s=e[0],n=e[1],a=e[2],l=Math.sqrt((t*t+r*r+o*o)*(s*s+n*n+a*a)),f=l&&ge(i,e)/l;return Math.acos(Math.min(Math.max(f,-1),1))}function Yi(i){return i[0]=0,i[1]=0,i[2]=0,i}function Ki(i){return`vec3(${i[0]}, ${i[1]}, ${i[2]})`}function $i(i,e){return i[0]===e[0]&&i[1]===e[1]&&i[2]===e[2]}function Zi(i,e){let t=i[0],r=i[1],o=i[2],s=e[0],n=e[1],a=e[2];return Math.abs(t-s)<=1e-6*Math.max(1,Math.abs(t),Math.abs(s))&&Math.abs(r-n)<=1e-6*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(o-a)<=1e-6*Math.max(1,Math.abs(o),Math.abs(a))}var Ji=it,Xi=rt,Qi=ot,er=st,tr=nt,ir=tt,rr=at,or=function(){let i=et();return function(e,t,r,o,s,n){let a,l;for(t||(t=3),r||(r=0),o?l=Math.min(o*t+r,e.length):l=e.length,a=r;a<l;a+=t)i[0]=e[a],i[1]=e[a+1],i[2]=e[a+2],s(i,i,n),e[a]=i[0],e[a+1]=i[1],e[a+2]=i[2];return e}}();function te(i,e=[],t=0){let r=Math.fround(i),o=i-r;return e[t]=r,e[t+1]=o,e}function xe(i){return i-Math.fround(i)}function ye(i){let e=new Float32Array(32);for(let t=0;t<4;++t)for(let r=0;r<4;++r){let o=t*4+r;te(i[r*4+t],e,o*2)}return e}var be=`
|
|
327
327
|
layout(std140) uniform fp64arithmeticUniforms {
|
|
328
328
|
uniform float ONE;
|
|
329
329
|
uniform float SPLIT;
|
|
@@ -529,11 +529,278 @@ vec2 sqrt_fp64(vec2 a) {
|
|
|
529
529
|
|
|
530
530
|
@group(0) @binding(auto) var<uniform> fp64arithmetic : Fp64ArithmeticUniforms;
|
|
531
531
|
|
|
532
|
+
struct Fp64Bits {
|
|
533
|
+
sign: u32,
|
|
534
|
+
exponent: i32,
|
|
535
|
+
significand: vec2u,
|
|
536
|
+
isZero: bool,
|
|
537
|
+
isInf: bool,
|
|
538
|
+
isNan: bool,
|
|
539
|
+
};
|
|
540
|
+
|
|
532
541
|
fn fp64_nan(seed: f32) -> f32 {
|
|
533
542
|
let nanBits = 0x7fc00000u | select(0u, 1u, seed < 0.0);
|
|
534
543
|
return bitcast<f32>(nanBits);
|
|
535
544
|
}
|
|
536
545
|
|
|
546
|
+
fn fp64_u64_is_zero(value: vec2u) -> bool {
|
|
547
|
+
return value.x == 0u && value.y == 0u;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
fn fp64_u64_compare(a: vec2u, b: vec2u) -> i32 {
|
|
551
|
+
if (a.x != b.x) {
|
|
552
|
+
return select(-1, 1, a.x > b.x);
|
|
553
|
+
}
|
|
554
|
+
if (a.y != b.y) {
|
|
555
|
+
return select(-1, 1, a.y > b.y);
|
|
556
|
+
}
|
|
557
|
+
return 0;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
fn fp64_u64_add(a: vec2u, b: vec2u) -> vec2u {
|
|
561
|
+
let low = a.y + b.y;
|
|
562
|
+
let carry = select(0u, 1u, low < a.y);
|
|
563
|
+
return vec2u(a.x + b.x + carry, low);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
fn fp64_u64_sub(a: vec2u, b: vec2u) -> vec2u {
|
|
567
|
+
let borrow = select(0u, 1u, a.y < b.y);
|
|
568
|
+
return vec2u(a.x - b.x - borrow, a.y - b.y);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
fn fp64_u64_shift_left(value: vec2u, shift: u32) -> vec2u {
|
|
572
|
+
if (shift == 0u) {
|
|
573
|
+
return value;
|
|
574
|
+
}
|
|
575
|
+
if (shift < 32u) {
|
|
576
|
+
return vec2u((value.x << shift) | (value.y >> (32u - shift)), value.y << shift);
|
|
577
|
+
}
|
|
578
|
+
if (shift == 32u) {
|
|
579
|
+
return vec2u(value.y, 0u);
|
|
580
|
+
}
|
|
581
|
+
if (shift < 64u) {
|
|
582
|
+
return vec2u(value.y << (shift - 32u), 0u);
|
|
583
|
+
}
|
|
584
|
+
return vec2u(0u);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
fn fp64_u64_shift_right(value: vec2u, shift: u32) -> vec2u {
|
|
588
|
+
if (shift == 0u) {
|
|
589
|
+
return value;
|
|
590
|
+
}
|
|
591
|
+
if (shift < 32u) {
|
|
592
|
+
return vec2u(value.x >> shift, (value.y >> shift) | (value.x << (32u - shift)));
|
|
593
|
+
}
|
|
594
|
+
if (shift == 32u) {
|
|
595
|
+
return vec2u(0u, value.x);
|
|
596
|
+
}
|
|
597
|
+
if (shift < 64u) {
|
|
598
|
+
return vec2u(0u, value.x >> (shift - 32u));
|
|
599
|
+
}
|
|
600
|
+
return vec2u(0u);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
fn fp64_u64_get_bit(value: vec2u, bitIndex: u32) -> bool {
|
|
604
|
+
if (bitIndex >= 64u) {
|
|
605
|
+
return false;
|
|
606
|
+
}
|
|
607
|
+
if (bitIndex >= 32u) {
|
|
608
|
+
return ((value.x >> (bitIndex - 32u)) & 1u) != 0u;
|
|
609
|
+
}
|
|
610
|
+
return ((value.y >> bitIndex) & 1u) != 0u;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
fn fp64_u64_has_bits_below(value: vec2u, bitCount: u32) -> bool {
|
|
614
|
+
if (bitCount == 0u) {
|
|
615
|
+
return false;
|
|
616
|
+
}
|
|
617
|
+
if (bitCount >= 64u) {
|
|
618
|
+
return !fp64_u64_is_zero(value);
|
|
619
|
+
}
|
|
620
|
+
if (bitCount > 32u) {
|
|
621
|
+
let highBitCount = bitCount - 32u;
|
|
622
|
+
let highMask = (1u << highBitCount) - 1u;
|
|
623
|
+
return value.y != 0u || (value.x & highMask) != 0u;
|
|
624
|
+
}
|
|
625
|
+
if (bitCount == 32u) {
|
|
626
|
+
return value.y != 0u;
|
|
627
|
+
}
|
|
628
|
+
let lowMask = (1u << bitCount) - 1u;
|
|
629
|
+
return (value.y & lowMask) != 0u;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
fn fp64_u64_shift_right_sticky(value: vec2u, shift: u32) -> vec2u {
|
|
633
|
+
var shifted = fp64_u64_shift_right(value, shift);
|
|
634
|
+
if (fp64_u64_has_bits_below(value, shift)) {
|
|
635
|
+
shifted.y = shifted.y | 1u;
|
|
636
|
+
}
|
|
637
|
+
return shifted;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
fn fp64_u64_count_leading_zeros(value: vec2u) -> u32 {
|
|
641
|
+
if (value.x != 0u) {
|
|
642
|
+
return countLeadingZeros(value.x);
|
|
643
|
+
}
|
|
644
|
+
return 32u + countLeadingZeros(value.y);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
fn fp64_round_shift_right_to_u32(value: vec2u, shift: u32) -> u32 {
|
|
648
|
+
if (shift == 0u) {
|
|
649
|
+
return value.y;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
let truncated = fp64_u64_shift_right(value, shift);
|
|
653
|
+
var rounded = truncated.y;
|
|
654
|
+
let guard = fp64_u64_get_bit(value, shift - 1u);
|
|
655
|
+
let hasTrailingBits = fp64_u64_has_bits_below(value, shift - 1u);
|
|
656
|
+
if (guard && (hasTrailingBits || (rounded & 1u) == 1u)) {
|
|
657
|
+
rounded = rounded + 1u;
|
|
658
|
+
}
|
|
659
|
+
return rounded;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
fn fp64_make_f32_bits_from_u64(sign: u32, significand: vec2u, baseExponent: i32) -> u32 {
|
|
663
|
+
if (fp64_u64_is_zero(significand)) {
|
|
664
|
+
return sign << 31u;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
let leadingZeros = fp64_u64_count_leading_zeros(significand);
|
|
668
|
+
let mostSignificantBit = 63u - leadingZeros;
|
|
669
|
+
var exponent = baseExponent + i32(mostSignificantBit);
|
|
670
|
+
|
|
671
|
+
if (exponent > 127) {
|
|
672
|
+
return (sign << 31u) | 0x7f800000u;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
if (exponent >= -126) {
|
|
676
|
+
let shift = i32(mostSignificantBit) - 23;
|
|
677
|
+
var significand24: u32;
|
|
678
|
+
if (shift > 0) {
|
|
679
|
+
significand24 = fp64_round_shift_right_to_u32(significand, u32(shift));
|
|
680
|
+
} else {
|
|
681
|
+
significand24 = fp64_u64_shift_left(significand, u32(-shift)).y;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
if (significand24 >= 0x1000000u) {
|
|
685
|
+
significand24 = significand24 >> 1u;
|
|
686
|
+
exponent = exponent + 1;
|
|
687
|
+
if (exponent > 127) {
|
|
688
|
+
return (sign << 31u) | 0x7f800000u;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
return (sign << 31u) | (u32(exponent + 127) << 23u) | (significand24 & 0x7fffffu);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
let scaleExponent = baseExponent + 149;
|
|
696
|
+
var mantissa: u32;
|
|
697
|
+
if (scaleExponent >= 0) {
|
|
698
|
+
mantissa = fp64_u64_shift_left(significand, u32(scaleExponent)).y;
|
|
699
|
+
} else {
|
|
700
|
+
mantissa = fp64_round_shift_right_to_u32(significand, u32(-scaleExponent));
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
if (mantissa >= 0x800000u) {
|
|
704
|
+
return (sign << 31u) | 0x00800000u;
|
|
705
|
+
}
|
|
706
|
+
return (sign << 31u) | mantissa;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
fn fp64_decode_bits(bits: vec2u) -> Fp64Bits {
|
|
710
|
+
let sign = bits.x >> 31u;
|
|
711
|
+
let exponentBits = (bits.x >> 20u) & 0x7ffu;
|
|
712
|
+
let fractionHigh = bits.x & 0xfffffu;
|
|
713
|
+
let fractionLow = bits.y;
|
|
714
|
+
let fraction = vec2u(fractionHigh, fractionLow);
|
|
715
|
+
|
|
716
|
+
if (exponentBits == 0x7ffu) {
|
|
717
|
+
let isInf = fp64_u64_is_zero(fraction);
|
|
718
|
+
return Fp64Bits(sign, 0, vec2u(0u), false, isInf, !isInf);
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
if (exponentBits == 0u) {
|
|
722
|
+
let isZero = fp64_u64_is_zero(fraction);
|
|
723
|
+
return Fp64Bits(sign, -1022, fraction, isZero, false, false);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
return Fp64Bits(sign, i32(exponentBits) - 1023, vec2u((1u << 20u) | fractionHigh, fractionLow), false, false, false);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
fn fp64_finite_magnitude_compare(a: Fp64Bits, b: Fp64Bits) -> i32 {
|
|
730
|
+
if (a.exponent != b.exponent) {
|
|
731
|
+
return select(-1, 1, a.exponent > b.exponent);
|
|
732
|
+
}
|
|
733
|
+
return fp64_u64_compare(a.significand, b.significand);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
fn fp64_add_aligned_magnitudes_to_f32_bits(sign: u32, larger: Fp64Bits, smaller: Fp64Bits) -> u32 {
|
|
737
|
+
let largeSignificand = fp64_u64_shift_left(larger.significand, 3u);
|
|
738
|
+
let smallSignificand = fp64_u64_shift_right_sticky(
|
|
739
|
+
fp64_u64_shift_left(smaller.significand, 3u),
|
|
740
|
+
u32(larger.exponent - smaller.exponent)
|
|
741
|
+
);
|
|
742
|
+
let resultSignificand = fp64_u64_add(largeSignificand, smallSignificand);
|
|
743
|
+
return fp64_make_f32_bits_from_u64(sign, resultSignificand, larger.exponent - 55);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
fn fp64_sub_aligned_magnitudes_to_f32_bits(sign: u32, larger: Fp64Bits, smaller: Fp64Bits) -> u32 {
|
|
747
|
+
let largeSignificand = fp64_u64_shift_left(larger.significand, 3u);
|
|
748
|
+
let smallSignificand = fp64_u64_shift_right_sticky(
|
|
749
|
+
fp64_u64_shift_left(smaller.significand, 3u),
|
|
750
|
+
u32(larger.exponent - smaller.exponent)
|
|
751
|
+
);
|
|
752
|
+
let resultSignificand = fp64_u64_sub(largeSignificand, smallSignificand);
|
|
753
|
+
return fp64_make_f32_bits_from_u64(sign, resultSignificand, larger.exponent - 55);
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
// Subtract two raw binary64 values and round the exact result once to f32.
|
|
757
|
+
// The input words are canonical high/low words: .x contains sign/exponent/high
|
|
758
|
+
// fraction bits, and .y contains the low 32 fraction bits.
|
|
759
|
+
fn sub_fp64u32_to_f32_bits(aBits: vec2u, bBits: vec2u) -> u32 {
|
|
760
|
+
let a = fp64_decode_bits(aBits);
|
|
761
|
+
let b = fp64_decode_bits(bBits);
|
|
762
|
+
let bSubtractionSign = b.sign ^ 1u;
|
|
763
|
+
|
|
764
|
+
if (a.isNan || b.isNan) {
|
|
765
|
+
return 0x7fc00000u;
|
|
766
|
+
}
|
|
767
|
+
if (a.isInf && b.isInf) {
|
|
768
|
+
if (a.sign == bSubtractionSign) {
|
|
769
|
+
return (a.sign << 31u) | 0x7f800000u;
|
|
770
|
+
}
|
|
771
|
+
return 0x7fc00000u;
|
|
772
|
+
}
|
|
773
|
+
if (a.isInf) {
|
|
774
|
+
return (a.sign << 31u) | 0x7f800000u;
|
|
775
|
+
}
|
|
776
|
+
if (b.isInf) {
|
|
777
|
+
return (bSubtractionSign << 31u) | 0x7f800000u;
|
|
778
|
+
}
|
|
779
|
+
if (a.isZero && b.isZero) {
|
|
780
|
+
return select(0u, 0x80000000u, a.sign == 1u && b.sign == 0u);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
let magnitudeComparison = fp64_finite_magnitude_compare(a, b);
|
|
784
|
+
if (a.sign == bSubtractionSign) {
|
|
785
|
+
if (magnitudeComparison >= 0) {
|
|
786
|
+
return fp64_add_aligned_magnitudes_to_f32_bits(a.sign, a, b);
|
|
787
|
+
}
|
|
788
|
+
return fp64_add_aligned_magnitudes_to_f32_bits(a.sign, b, a);
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
if (magnitudeComparison == 0) {
|
|
792
|
+
return 0u;
|
|
793
|
+
}
|
|
794
|
+
if (magnitudeComparison > 0) {
|
|
795
|
+
return fp64_sub_aligned_magnitudes_to_f32_bits(a.sign, a, b);
|
|
796
|
+
}
|
|
797
|
+
return fp64_sub_aligned_magnitudes_to_f32_bits(bSubtractionSign, b, a);
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
fn sub_fp64u32_to_f32(aBits: vec2u, bBits: vec2u) -> f32 {
|
|
801
|
+
return bitcast<f32>(sub_fp64u32_to_f32_bits(aBits, bBits));
|
|
802
|
+
}
|
|
803
|
+
|
|
537
804
|
fn fp64_runtime_zero() -> f32 {
|
|
538
805
|
return fp64arithmetic.ONE * 0.0;
|
|
539
806
|
}
|
|
@@ -728,7 +995,7 @@ fn sqrt_fp64(a: vec2f) -> vec2f {
|
|
|
728
995
|
return sum_fp64(vec2f(yn, 0.0), prod);
|
|
729
996
|
#endif
|
|
730
997
|
}
|
|
731
|
-
`;var
|
|
998
|
+
`;var ft=`const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
|
|
732
999
|
const vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09);
|
|
733
1000
|
const vec2 PI_FP64 = vec2(3.1415927410125732, -8.742278012618954e-8);
|
|
734
1001
|
const vec2 TWO_PI_FP64 = vec2(6.2831854820251465, -1.7484556025237907e-7);
|
|
@@ -1397,7 +1664,7 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
|
|
|
1397
1664
|
vec4_dot_fp64(a, tmp, out_val[i]);
|
|
1398
1665
|
}
|
|
1399
1666
|
}
|
|
1400
|
-
`;var
|
|
1667
|
+
`;var sr={ONE:1,SPLIT:4097},ct={name:"fp64arithmetic",source:lt,fs:be,vs:be,defaultUniforms:sr,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:te,fp64LowPart:xe,fp64ifyMatrix4:ye},ie={name:"fp64",vs:ft,dependencies:[ct],fp64ify:te,fp64LowPart:xe,fp64ifyMatrix4:ye};var re=d(_(),1);var ut=`const vec2 WORLD_SCALE_FP64 = vec2(81.4873275756836, 0.0000032873668232014097);
|
|
1401
1668
|
layout(std140) uniform project64Uniforms {
|
|
1402
1669
|
vec2 scale;
|
|
1403
1670
|
mat4 viewProjectionMatrix;
|
|
@@ -1470,7 +1737,7 @@ return project_position_to_clipspace(
|
|
|
1470
1737
|
position, position64xyLow, offset, commonPosition
|
|
1471
1738
|
);
|
|
1472
1739
|
}
|
|
1473
|
-
`;var{fp64ify:
|
|
1740
|
+
`;var{fp64ify:nr,fp64ifyMatrix4:ar}=ie,oe={name:"project64",dependencies:[re.project,ie],vs:ut,getUniforms:fr,uniformTypes:{scale:"vec2<f32>",viewProjectionMatrix:"mat4x4<f32>",viewProjectionMatrix64Low:"mat4x4<f32>"}},lr=(0,re._memoize)(cr);function fr(i){if(i&&"viewport"in i){let{viewProjectionMatrix:e,scale:t}=i.viewport;return lr({viewProjectionMatrix:e,scale:t})}return{}}function cr({viewProjectionMatrix:i,scale:e}){let t=ar(i),r=new Float32Array(16),o=new Float32Array(16);for(let s=0;s<4;s++)for(let n=0;n<4;n++){let a=4*s+n,l=4*n+s;r[l]=t[2*a],o[l]=t[2*a+1]}return{scale:nr(e),viewProjectionMatrix:[...r],viewProjectionMatrix64Low:[...o]}}var se=class extends pt.LayerExtension{getShaders(){let{coordinateSystem:e}=this.props;if(e!=="lnglat"&&e!=="default")throw new Error("fp64: coordinateSystem must be LNGLAT");return{modules:[oe]}}draw(e,t){let{viewport:r}=e.context;this.setShaderModuleProps({project64:{viewport:r}})}};se.extensionName="Fp64Extension";var dt=se;var w=d(_(),1);var _t={inject:{"vs:#decl":`
|
|
1474
1741
|
in vec2 instanceDashArrays;
|
|
1475
1742
|
#ifdef HIGH_PRECISION_DASH
|
|
1476
1743
|
in float instanceDashOffsets;
|
|
@@ -1703,14 +1970,14 @@ isInside = step(-1.0, vPathPosition.x) * step(vPathPosition.x, 1.0);
|
|
|
1703
1970
|
if (isInside == 0.0) {
|
|
1704
1971
|
discard;
|
|
1705
1972
|
}
|
|
1706
|
-
`}};var
|
|
1973
|
+
`}};var ur={getDashArray:{type:"accessor",value:[0,0]},getOffset:{type:"accessor",value:0},dashJustified:!1,dashGapPickable:!1},N=class extends w.LayerExtension{constructor({dash:e=!1,offset:t=!1,highPrecisionDash:r=!1}={}){super({dash:e||r,offset:t,highPrecisionDash:r})}getLayerType(e){if("pathTesselator"in e.state)return"path";let t=e.constructor.layerName;return t==="ScatterplotLayer"?"scatterplot":t==="TextBackgroundLayer"?"textBackground":null}isEnabled(e){return this.getLayerType(e)!==null}getShaders(e){let t=e.getLayerType(this);if(!t)return null;if(t==="scatterplot"||t==="textBackground")return e.opts.dash?{modules:[{name:"pathStyle",inject:t==="scatterplot"?mt.inject:ht.inject,uniformTypes:{dashGapPickable:"i32"}}]}:null;let r={},o={};e.opts.dash&&(r=(0,w._mergeShaders)(r,_t),e.opts.highPrecisionDash&&(o.HIGH_PRECISION_DASH=!0)),e.opts.offset&&(r=(0,w._mergeShaders)(r,vt));let{inject:s}=r;return{modules:[{name:"pathStyle",inject:s,uniformTypes:{dashAlignMode:"f32",dashGapPickable:"i32"}}],defines:o}}initializeState(e,t){let r=this.getAttributeManager(),o=t.getLayerType(this);!r||!o||(t.opts.dash&&r.addInstanced({instanceDashArrays:{size:2,accessor:"getDashArray"},...o==="path"&&t.opts.highPrecisionDash?{instanceDashOffsets:{size:1,accessor:"getPath",transform:t.getDashOffsets.bind(this)}}:{}}),o==="path"&&t.opts.offset&&r.addInstanced({instanceOffsets:{size:1,accessor:"getOffset"}}))}updateState(e,t){if(t.isEnabled(this)&&t.opts.dash){let r=t.getLayerType(this);if(r==="scatterplot"||r==="textBackground"){let o={dashGapPickable:Boolean(this.props.dashGapPickable)};this.setShaderModuleProps({pathStyle:o})}else{let o={dashAlignMode:this.props.dashJustified?1:0,dashGapPickable:Boolean(this.props.dashGapPickable)};this.setShaderModuleProps({pathStyle:o})}}}getDashOffsets(e){let t=[0],r=this.props.positionFormat==="XY"?2:3,o=Array.isArray(e[0]),s=o?e.length:e.length/r,n,a;for(let l=0;l<s-1;l++)n=o?e[l]:e.slice(l*r,l*r+r),n=this.projectPosition(n),l>0&&(t[l]=t[l-1]+k.dist(a,n)),a=n;return t[s-1]=0,t}};N.defaultProps=ur;N.extensionName="PathStyleExtension";var gt=N;var bt=d(_(),1);var F=d(_(),1),xt=`layout(std140) uniform fillUniforms {
|
|
1707
1974
|
vec2 patternTextureSize;
|
|
1708
1975
|
bool patternEnabled;
|
|
1709
1976
|
bool patternMask;
|
|
1710
1977
|
vec2 uvCoordinateOrigin;
|
|
1711
1978
|
vec2 uvCoordinateOrigin64Low;
|
|
1712
1979
|
} fill;
|
|
1713
|
-
`,
|
|
1980
|
+
`,pr=`
|
|
1714
1981
|
in vec4 fillPatternFrames;
|
|
1715
1982
|
in float fillPatternScales;
|
|
1716
1983
|
in vec2 fillPatternOffsets;
|
|
@@ -1718,10 +1985,10 @@ in vec2 fillPatternOffsets;
|
|
|
1718
1985
|
out vec2 fill_uv;
|
|
1719
1986
|
out vec4 fill_patternBounds;
|
|
1720
1987
|
out vec4 fill_patternPlacement;
|
|
1721
|
-
`,
|
|
1988
|
+
`,dr=`
|
|
1722
1989
|
${xt}
|
|
1723
|
-
${
|
|
1724
|
-
`,
|
|
1990
|
+
${pr}
|
|
1991
|
+
`,_r=`
|
|
1725
1992
|
uniform sampler2D fill_patternTexture;
|
|
1726
1993
|
|
|
1727
1994
|
in vec4 fill_patternBounds;
|
|
@@ -1729,10 +1996,10 @@ in vec4 fill_patternPlacement;
|
|
|
1729
1996
|
in vec2 fill_uv;
|
|
1730
1997
|
|
|
1731
1998
|
const float FILL_UV_SCALE = 512.0 / 40000000.0;
|
|
1732
|
-
`,
|
|
1999
|
+
`,mr=`
|
|
1733
2000
|
${xt}
|
|
1734
|
-
${
|
|
1735
|
-
`,
|
|
2001
|
+
${_r}
|
|
2002
|
+
`,hr={"vs:DECKGL_FILTER_GL_POSITION":`
|
|
1736
2003
|
fill_uv = geometry.position.xy;
|
|
1737
2004
|
`,"vs:DECKGL_FILTER_COLOR":`
|
|
1738
2005
|
if (fill.patternEnabled) {
|
|
@@ -1754,7 +2021,7 @@ ${mo}
|
|
|
1754
2021
|
color.rgb = patternColor.rgb;
|
|
1755
2022
|
}
|
|
1756
2023
|
}
|
|
1757
|
-
`};function
|
|
2024
|
+
`};function vr(i){if(!i)return{};let e={};if("fillPatternTexture"in i){let{fillPatternTexture:t}=i;e.fill_patternTexture=t,e.patternTextureSize=[t.width,t.height]}if("project"in i){let{fillPatternMask:t=!0,fillPatternEnabled:r=!0}=i,o=F.project.getUniforms(i.project),{commonOrigin:s}=o,n=[(0,F.fp64LowPart)(s[0]),(0,F.fp64LowPart)(s[1])];e.uvCoordinateOrigin=s.slice(0,2),e.uvCoordinateOrigin64Low=n,e.patternMask=t,e.patternEnabled=r}return e}var yt={name:"fill",vs:dr,fs:mr,inject:hr,dependencies:[F.project],getUniforms:vr,uniformTypes:{patternTextureSize:"vec2<f32>",patternEnabled:"i32",patternMask:"i32",uvCoordinateOrigin:"vec2<f32>",uvCoordinateOrigin64Low:"vec2<f32>"}};var gr={fillPatternEnabled:!0,fillPatternAtlas:{type:"image",value:null,async:!0,parameters:{lodMaxClamp:0}},fillPatternMapping:{type:"object",value:{},async:!0},fillPatternMask:!0,getFillPattern:{type:"accessor",value:i=>i.pattern},getFillPatternScale:{type:"accessor",value:1},getFillPatternOffset:{type:"accessor",value:[0,0]}},B=class extends bt.LayerExtension{constructor({pattern:e=!1}={}){super({pattern:e})}isEnabled(e){return e.getAttributeManager()!==null&&!("pathTesselator"in e.state)}getShaders(e){return e.isEnabled(this)?{modules:[e.opts.pattern&&yt].filter(Boolean)}:null}initializeState(e,t){if(!t.isEnabled(this))return;let r=this.getAttributeManager();t.opts.pattern&&r.add({fillPatternFrames:{size:4,stepMode:"dynamic",accessor:"getFillPattern",transform:t.getPatternFrame.bind(this)},fillPatternScales:{size:1,stepMode:"dynamic",accessor:"getFillPatternScale",defaultValue:1},fillPatternOffsets:{size:2,stepMode:"dynamic",accessor:"getFillPatternOffset"}}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState({props:e,oldProps:t},r){r.isEnabled(this)&&e.fillPatternMapping&&e.fillPatternMapping!==t.fillPatternMapping&&this.getAttributeManager().invalidate("getFillPattern")}draw(e,t){if(!t.isEnabled(this))return;let{fillPatternAtlas:r,fillPatternEnabled:o,fillPatternMask:s}=this.props,n={project:e.shaderModuleProps.project,fillPatternEnabled:o,fillPatternMask:s,fillPatternTexture:r||this.state.emptyTexture};this.setShaderModuleProps({fill:n})}finalizeState(){this.state.emptyTexture?.delete()}getPatternFrame(e){let{fillPatternMapping:t}=this.getCurrentLayer().props,r=t&&t[e];return r?[r.x,r.y,r.width,r.height]:[0,0,0,0]}};B.defaultProps=gr;B.extensionName="FillStyleExtension";var Pt=B;var Et=d(_(),1),xr={clipBounds:[0,0,1,1],clipByInstance:void 0},Mt=`
|
|
1758
2025
|
layout(std140) uniform clipUniforms {
|
|
1759
2026
|
vec4 bounds;
|
|
1760
2027
|
} clip;
|
|
@@ -1762,7 +2029,7 @@ layout(std140) uniform clipUniforms {
|
|
|
1762
2029
|
bool clip_isInBounds(vec2 position) {
|
|
1763
2030
|
return position.x >= clip.bounds[0] && position.y >= clip.bounds[1] && position.x < clip.bounds[2] && position.y < clip.bounds[3];
|
|
1764
2031
|
}
|
|
1765
|
-
`,
|
|
2032
|
+
`,yr={name:"clip",vs:Mt,uniformTypes:{bounds:"vec4<f32>"}},br={"vs:#decl":`
|
|
1766
2033
|
out float clip_isVisible;
|
|
1767
2034
|
`,"vs:DECKGL_FILTER_GL_POSITION":`
|
|
1768
2035
|
clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy));
|
|
@@ -1770,7 +2037,7 @@ out float clip_isVisible;
|
|
|
1770
2037
|
in float clip_isVisible;
|
|
1771
2038
|
`,"fs:DECKGL_FILTER_COLOR":`
|
|
1772
2039
|
if (clip_isVisible < 0.5) discard;
|
|
1773
|
-
`},
|
|
2040
|
+
`},Pr={name:"clip",fs:Mt,uniformTypes:{bounds:"vec4<f32>"}},Er={"vs:#decl":`
|
|
1774
2041
|
out vec2 clip_commonPosition;
|
|
1775
2042
|
`,"vs:DECKGL_FILTER_GL_POSITION":`
|
|
1776
2043
|
clip_commonPosition = geometry.position.xy;
|
|
@@ -1778,7 +2045,7 @@ out vec2 clip_commonPosition;
|
|
|
1778
2045
|
in vec2 clip_commonPosition;
|
|
1779
2046
|
`,"fs:DECKGL_FILTER_COLOR":`
|
|
1780
2047
|
if (!clip_isInBounds(clip_commonPosition)) discard;
|
|
1781
|
-
`},D=class extends
|
|
2048
|
+
`},D=class extends Et.LayerExtension{getShaders(){let e="instancePositions"in this.getAttributeManager().attributes;return this.props.clipByInstance!==void 0&&(e=Boolean(this.props.clipByInstance)),this.state.clipByInstance=e,e?{modules:[yr],inject:br}:{modules:[Pr],inject:Er}}draw(){let{clipBounds:e}=this.props,t={};if(this.state.clipByInstance)t.bounds=e;else{let r=this.projectPosition([e[0],e[1],0]),o=this.projectPosition([e[2],e[3],0]);t.bounds=[Math.min(r[0],o[0]),Math.min(r[1],o[1]),Math.max(r[0],o[0]),Math.max(r[1],o[1])]}this.setShaderModuleProps({clip:t})}};D.defaultProps=xr;D.extensionName="ClipExtension";var Ft=D;var St=d(_(),1);var Tt=d(_(),1),Mr=`
|
|
1782
2049
|
in float collisionPriorities;
|
|
1783
2050
|
|
|
1784
2051
|
uniform sampler2D collision_texture;
|
|
@@ -1826,7 +2093,7 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
|
|
|
1826
2093
|
float W = 2.0 * floatN + 1.0;
|
|
1827
2094
|
return pow(accumulator / (W * W), 2.2);
|
|
1828
2095
|
}
|
|
1829
|
-
`,
|
|
2096
|
+
`,Fr={"vs:#decl":`
|
|
1830
2097
|
float collision_fade = 1.0;
|
|
1831
2098
|
`,"vs:DECKGL_FILTER_GL_POSITION":`
|
|
1832
2099
|
if (collision.sort) {
|
|
@@ -1845,21 +2112,21 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
|
|
|
1845
2112
|
}
|
|
1846
2113
|
`,"vs:DECKGL_FILTER_COLOR":`
|
|
1847
2114
|
color.a *= collision_fade;
|
|
1848
|
-
`},
|
|
2115
|
+
`},Tr=i=>{if(!i||!("dummyCollisionMap"in i))return{};let{enabled:e,collisionFBO:t,drawToCollisionMap:r,dummyCollisionMap:o}=i;return{enabled:e&&!r,sort:Boolean(r),collision_texture:!r&&t?t.colorAttachments[0]:o}},Ot={name:"collision",dependencies:[Tt.project],vs:Mr,inject:Fr,getUniforms:Tr,uniformTypes:{sort:"i32",enabled:"i32"}};var At=d(_(),1);var Lt=d(_(),1),z=class extends Lt._LayersPass{renderCollisionMap(e,t){let o=[0,0,0,0],s=[1,1,e.width-2*1,e.height-2*1];this.render({...t,clearColor:o,scissorRect:s,target:e,pass:"collision"})}getLayerParameters(e,t,r){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}getShaderModuleProps(){return{collision:{drawToCollisionMap:!0},picking:{isActive:1,isAttribute:!1},lighting:{enabled:!1}}}};var Pe=2,V=class{constructor(){this.id="collision-filter-effect",this.props=null,this.useInPicking=!0,this.order=1,this.channels={},this.collisionFBOs={}}setup(e){this.context=e;let{device:t}=e;this.dummyCollisionMap=t.createTexture({width:1,height:1}),this.collisionFilterPass=new z(t,{id:"default-collision-filter"})}preRender({effects:e,layers:t,layerFilter:r,viewports:o,onViewportActive:s,views:n,isPicking:a,preRenderStats:l={}}){let{device:f}=this.context;if(a)return;let u=t.filter(({props:{visible:v,collisionEnabled:A}})=>v&&A);if(u.length===0){this.channels={};return}let c=e?.filter(v=>v.useInPicking&&l[v.id]),p=l["mask-effect"]?.didRender,m=this._groupByCollisionGroup(f,u),h=o[0],P=!this.lastViewport||!this.lastViewport.equals(h)||p;for(let v in m){let A=this.collisionFBOs[v],ue=m[v],[pe,de]=f.canvasContext.getPixelSize();A.resize({width:pe/Pe,height:de/Pe}),this._render(ue,{effects:c,layerFilter:r,onViewportActive:s,views:n,viewport:h,viewportChanged:P})}}_render(e,{effects:t,layerFilter:r,onViewportActive:o,views:s,viewport:n,viewportChanged:a}){let{collisionGroup:l}=e,f=this.channels[l];if(!f)return;let u=a||e===f||!(0,At._deepEqual)(f.layers,e.layers,1)||e.layerBounds.some((c,p)=>!M(c,f.layerBounds[p]))||e.allLayersLoaded!==f.allLayersLoaded||e.layers.some(c=>c.props.transitions);if(this.channels[l]=e,u){this.lastViewport=n;let c=this.collisionFBOs[l];this.collisionFilterPass.renderCollisionMap(c,{pass:"collision-filter",isPicking:!0,layers:e.layers,effects:t,layerFilter:r,viewports:n?[n]:[],onViewportActive:o,views:s,shaderModuleProps:{collision:{enabled:!0,dummyCollisionMap:this.dummyCollisionMap},project:{devicePixelRatio:c.device.canvasContext.getDevicePixelRatio()/Pe}}})}}_groupByCollisionGroup(e,t){let r={};for(let o of t){let s=o.props.collisionGroup,n=r[s];n||(n={collisionGroup:s,layers:[],layerBounds:[],allLayersLoaded:!0},r[s]=n),n.layers.push(o),n.layerBounds.push(o.getBounds()),o.isLoaded||(n.allLayersLoaded=!1)}for(let o of Object.keys(r))this.collisionFBOs[o]||this.createFBO(e,o),this.channels[o]||(this.channels[o]=r[o]);for(let o of Object.keys(this.collisionFBOs))r[o]||this.destroyFBO(o);return r}getShaderModuleProps(e){let{collisionGroup:t,collisionEnabled:r}=e.props,{collisionFBOs:o,dummyCollisionMap:s}=this,n=o[t];return{collision:{enabled:r&&Boolean(n),collisionFBO:n,dummyCollisionMap:s}}}cleanup(){this.dummyCollisionMap&&(this.dummyCollisionMap.delete(),this.dummyCollisionMap=void 0),this.channels={};for(let e of Object.keys(this.collisionFBOs))this.destroyFBO(e);this.collisionFBOs={},this.lastViewport=void 0}createFBO(e,t){let{width:r,height:o}=e.getDefaultCanvasContext().canvas,s=e.createTexture({format:"rgba8unorm",width:r,height:o,sampler:{minFilter:"nearest",magFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),n=e.createTexture({format:"depth16unorm",width:r,height:o});this.collisionFBOs[t]=e.createFramebuffer({id:`collision-${t}`,width:r,height:o,colorAttachments:[s],depthStencilAttachment:n})}destroyFBO(e){let t=this.collisionFBOs[e];t.colorAttachments[0]?.destroy(),t.depthStencilAttachment?.destroy(),t.destroy(),delete this.collisionFBOs[e]}};var Or={getCollisionPriority:{type:"accessor",value:0},collisionEnabled:!0,collisionGroup:{type:"string",value:"default"},collisionTestProps:{}},j=class extends St.LayerExtension{getShaders(){return{modules:[Ot]}}draw({shaderModuleProps:e}){e.collision?.drawToCollisionMap&&(this.props=this.clone(this.props.collisionTestProps).props)}initializeState(e,t){if(this.getAttributeManager()===null)return;this.context.deck?._addDefaultEffect(new V),this.getAttributeManager().add({collisionPriorities:{size:1,stepMode:"dynamic",accessor:"getCollisionPriority"}})}getNeedsPickingBuffer(){return this.props.collisionEnabled}};j.defaultProps=Or;j.extensionName="CollisionFilterExtension";var It=j;var b=d(_(),1);var Ct=d(_(),1),Rt=`layout(std140) uniform maskUniforms {
|
|
1849
2116
|
vec4 bounds;
|
|
1850
2117
|
highp int channel;
|
|
1851
2118
|
bool enabled;
|
|
1852
2119
|
bool inverted;
|
|
1853
2120
|
bool maskByInstance;
|
|
1854
2121
|
} mask;
|
|
1855
|
-
`,
|
|
2122
|
+
`,Lr=`
|
|
1856
2123
|
vec2 mask_getCoords(vec4 position) {
|
|
1857
2124
|
return (position.xy - mask.bounds.xy) / (mask.bounds.zw - mask.bounds.xy);
|
|
1858
2125
|
}
|
|
1859
|
-
`,
|
|
1860
|
-
${
|
|
1861
|
-
${
|
|
1862
|
-
`,
|
|
2126
|
+
`,Ar=`
|
|
2127
|
+
${Rt}
|
|
2128
|
+
${Lr}
|
|
2129
|
+
`,Sr=`
|
|
1863
2130
|
uniform sampler2D mask_texture;
|
|
1864
2131
|
|
|
1865
2132
|
bool mask_isInBounds(vec2 texCoords) {
|
|
@@ -1884,10 +2151,10 @@ bool mask_isInBounds(vec2 texCoords) {
|
|
|
1884
2151
|
return maskValue < 0.5;
|
|
1885
2152
|
}
|
|
1886
2153
|
}
|
|
1887
|
-
`,
|
|
1888
|
-
${
|
|
1889
|
-
${
|
|
1890
|
-
`,
|
|
2154
|
+
`,Ir=`
|
|
2155
|
+
${Rt}
|
|
2156
|
+
${Sr}
|
|
2157
|
+
`,Cr={"vs:#decl":`
|
|
1891
2158
|
out vec2 mask_texCoords;
|
|
1892
2159
|
`,"vs:#main-end":`
|
|
1893
2160
|
vec4 mask_common_position;
|
|
@@ -1909,15 +2176,15 @@ in vec2 mask_texCoords;
|
|
|
1909
2176
|
|
|
1910
2177
|
if (!mask) discard;
|
|
1911
2178
|
}
|
|
1912
|
-
`},
|
|
1913
|
-
`),Bt=
|
|
2179
|
+
`},Rr=i=>i&&"maskMap"in i?{mask_texture:i.maskMap}:i||{},kt={name:"mask",dependencies:[Ct.project],vs:Ar,fs:Ir,inject:Cr,getUniforms:Rr,uniformTypes:{bounds:"vec4<f32>",channel:"i32",enabled:"i32",inverted:"i32",maskByInstance:"i32"}};var Me=d(_(),1);var wt=d(_(),1),kr={blendColorOperation:"subtract",blendColorSrcFactor:"zero",blendColorDstFactor:"one",blendAlphaOperation:"subtract",blendAlphaSrcFactor:"zero",blendAlphaDstFactor:"one"},U=class extends wt._LayersPass{constructor(e,t){super(e,t);let{mapSize:r=2048}=t;this.maskMap=e.createTexture({format:"rgba8unorm",width:r,height:r,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),this.fbo=e.createFramebuffer({id:"maskmap",width:r,height:r,colorAttachments:[this.maskMap]})}render(e){let t=2**e.channel,r=[255,255,255,255];super.render({...e,clearColor:r,colorMask:t,target:this.fbo,pass:"mask"})}getLayerParameters(e,t,r){return{...e.props.parameters,blend:!0,depthCompare:"always",...kr}}shouldDrawLayer(e){return e.props.operation.includes("mask")}delete(){this.fbo.delete(),this.maskMap.delete()}};var G=d(_(),1),Ee=new G.WebMercatorViewport({width:1,height:1,longitude:0,latitude:0,zoom:0});function H(i){let[e,t]=Ee.projectPosition(i);return[e,t]}function ne(i){return i.isGeospatial?Ee:i}function T(i,e){let t=[1/0,1/0,-1/0,-1/0];for(let r of i){let o=r.getBounds();if(o){let s=r.projectPosition(o[0],{viewport:e,autoOffset:!1}),n=r.projectPosition(o[1],{viewport:e,autoOffset:!1});t[0]=Math.min(t[0],s[0]),t[1]=Math.min(t[1],s[1]),t[2]=Math.max(t[2],n[0]),t[3]=Math.max(t[3],n[1])}}return Number.isFinite(t[0])?t:null}var wr=2048;function O(i){let{bounds:e,viewport:t,border:r=0}=i,{isGeospatial:o}=t;if(e[2]<=e[0]||e[3]<=e[1])return null;let s=o?Ee.unprojectPosition([(e[0]+e[2])/2,(e[1]+e[3])/2,0]):t.unprojectPosition([(e[0]+e[2])/2,(e[1]+e[3])/2,0]),{width:n,height:a,zoom:l}=i;if(l===void 0){n=n-r*2,a=a-r*2;let f=Math.min(n/(e[2]-e[0]),a/(e[3]-e[1]));l=Math.min(Math.log2(f),20)}else if(!n||!a){let f=2**l;n=Math.round(Math.abs(e[2]-e[0])*f),a=Math.round(Math.abs(e[3]-e[1])*f);let u=wr-r*2;if(n>u||a>u){let c=u/Math.max(n,a);n=Math.round(n*c),a=Math.round(a*c),l+=Math.log2(c)}}return o?new G.WebMercatorViewport({id:t.id,x:r,y:r,width:n,height:a,longitude:s[0],latitude:s[1],zoom:l,orthographic:!0}):new G.OrthographicViewport({id:t.id,x:r,y:r,width:n,height:a,target:s,zoom:l,flipY:!1})}function Nr(i,e){let t;if(e&&e.length===2){let[s,n]=e,a=i.getBounds({z:s}),l=i.getBounds({z:n});t=[Math.min(a[0],l[0]),Math.min(a[1],l[1]),Math.max(a[2],l[2]),Math.max(a[3],l[3])]}else t=i.getBounds();let r=i.projectPosition(t.slice(0,2)),o=i.projectPosition(t.slice(2,4));return[r[0],r[1],o[0],o[1]]}function L(i,e,t){if(!i)return[0,0,1,1];let r=Nr(e,t),o=Br(r);return i[2]-i[0]<=o[2]-o[0]&&i[3]-i[1]<=o[3]-o[1]?i:[Math.max(i[0],o[0]),Math.max(i[1],o[1]),Math.min(i[2],o[2]),Math.min(i[3],o[3])]}function Br(i){let e=i[2]-i[0],t=i[3]-i[1],r=(i[0]+i[2])/2,o=(i[1]+i[3])/2;return[r-e,o-t,r+e,o+t]}var q=class{constructor(){this.id="mask-effect",this.props=null,this.useInPicking=!0,this.order=0,this.channels=[],this.masks=null}setup({device:e}){this.dummyMaskMap=e.createTexture({width:1,height:1}),this.maskPass=new U(e,{id:"default-mask"}),this.maskMap=this.maskPass.maskMap}preRender({layers:e,layerFilter:t,viewports:r,onViewportActive:o,views:s,effects:n,isPicking:a}){let l=!1;if(a)return{didRender:l};let f=e.filter(m=>m.props.visible&&m.props.operation.includes("mask"));if(f.length===0)return this.masks=null,this.channels.length=0,{didRender:l};this.masks={};let u=this._sortMaskChannels(f),c=r[0],p=!this.lastViewport||!this.lastViewport.equals(c);if(c.resolution!==void 0)return Me.log.warn("MaskExtension is not supported in GlobeView")(),{didRender:l};for(let m in u){let h=this._renderChannel(u[m],{layerFilter:t,onViewportActive:o,views:s,effects:n,viewport:c,viewportChanged:p});l||(l=h)}return{didRender:l}}_renderChannel(e,{layerFilter:t,onViewportActive:r,views:o,effects:s,viewport:n,viewportChanged:a}){let l=!1,f=this.channels[e.index];if(!f)return l;let u=e===f||e.layers.length!==f.layers.length||e.layers.some((c,p)=>c!==f.layers[p]||c.props.transitions)||e.layerBounds.some((c,p)=>c!==f.layerBounds[p]);if(e.bounds=f.bounds,e.maskBounds=f.maskBounds,this.channels[e.index]=e,u||a){this.lastViewport=n;let c=T(e.layers,n);if(e.bounds=c&&L(c,n),u||!M(e.bounds,f.bounds)){let{maskPass:p,maskMap:m}=this,h=c&&O({bounds:e.bounds,viewport:n,width:m.width,height:m.height,border:1});e.maskBounds=h?h.getBounds():[0,0,1,1],p.render({pass:"mask",channel:e.index,layers:e.layers,layerFilter:t,viewports:h?[h]:[],onViewportActive:r,views:o,effects:s,shaderModuleProps:{project:{devicePixelRatio:1}}}),l=!0}}return this.masks[e.id]={index:e.index,bounds:e.maskBounds,coordinateOrigin:e.coordinateOrigin,coordinateSystem:e.coordinateSystem},l}_sortMaskChannels(e){let t={},r=0;for(let o of e){let{id:s}=o.root,n=t[s];if(!n){if(++r>4){Me.log.warn("Too many mask layers. The max supported is 4")();continue}n={id:s,index:this.channels.findIndex(a=>a?.id===s),layers:[],layerBounds:[],coordinateOrigin:o.root.props.coordinateOrigin,coordinateSystem:o.root.props.coordinateSystem},t[s]=n}n.layers.push(o),n.layerBounds.push(o.getBounds())}for(let o=0;o<4;o++){let s=this.channels[o];(!s||!(s.id in t))&&(this.channels[o]=null)}for(let o in t){let s=t[o];s.index<0&&(s.index=this.channels.findIndex(n=>!n),this.channels[s.index]=s)}return t}getShaderModuleProps(){return{mask:{maskMap:this.masks?this.maskMap:this.dummyMaskMap,maskChannels:this.masks}}}cleanup(){this.dummyMaskMap&&(this.dummyMaskMap.delete(),this.dummyMaskMap=void 0),this.maskPass&&(this.maskPass.delete(),this.maskPass=void 0,this.maskMap=void 0),this.lastViewport=void 0,this.masks=null,this.channels.length=0}};var Dr={maskId:"",maskByInstance:void 0,maskInverted:!1},W=class extends b.LayerExtension{initializeState(){this.context.deck?._addDefaultEffect(new q)}getShaders(){let e="instancePositions"in this.getAttributeManager().attributes;return this.props.maskByInstance!==void 0&&(e=Boolean(this.props.maskByInstance)),this.state.maskByInstance=e,{modules:[kt]}}draw({context:e,shaderModuleProps:t}){let r={};r.maskByInstance=Boolean(this.state.maskByInstance);let{maskId:o,maskInverted:s}=this.props,{maskChannels:n}=t.mask||{},{viewport:a}=e;if(n&&n[o]){let{index:l,bounds:f,coordinateOrigin:u}=n[o],{coordinateSystem:c}=n[o];r.enabled=!0,r.channel=l,r.inverted=s,c===b.COORDINATE_SYSTEM.DEFAULT&&(c=a.isGeospatial?b.COORDINATE_SYSTEM.LNGLAT:b.COORDINATE_SYSTEM.CARTESIAN);let p={modelMatrix:null,fromCoordinateOrigin:u,fromCoordinateSystem:c},m=this.projectPosition([f[0],f[1],0],p),h=this.projectPosition([f[2],f[3],0],p);r.bounds=[m[0],m[1],h[0],h[1]]}else o&&b.log.warn(`Could not find a mask layer with id: ${o}`)(),r.enabled=!1;this.setShaderModuleProps({mask:r})}};W.defaultProps=Dr;W.extensionName="MaskExtension";var Nt=W;var qt=d(_(),1);var Ht=d(_(),1);var Fe=d(_(),1),g={NONE:0,WRITE_HEIGHT_MAP:1,USE_HEIGHT_MAP:2,USE_COVER:3,USE_COVER_ONLY:4,SKIP:5},zr=Object.keys(g).map(i=>`const float TERRAIN_MODE_${i} = ${g[i]}.0;`).join(`
|
|
2180
|
+
`),Bt=zr+`
|
|
1914
2181
|
layout(std140) uniform terrainUniforms {
|
|
1915
2182
|
float mode;
|
|
1916
2183
|
vec4 bounds;
|
|
1917
2184
|
} terrain;
|
|
1918
2185
|
|
|
1919
2186
|
uniform sampler2D terrain_map;
|
|
1920
|
-
`,
|
|
2187
|
+
`,Y={name:"terrain",dependencies:[Fe.project],vs:`${Bt}
|
|
1921
2188
|
out vec3 commonPos;
|
|
1922
2189
|
// In globe mode, absolute Mercator position for terrain FBO UV lookups
|
|
1923
2190
|
out vec2 terrainMercPos;
|
|
@@ -1987,6 +2254,6 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
1987
2254
|
}
|
|
1988
2255
|
return;
|
|
1989
2256
|
}
|
|
1990
|
-
`},getUniforms:(r={})=>{if(!r.dummyHeightMap)return{};if("terrainSkipRender"in r||"drawToTerrainHeightMap"in r){let{drawToTerrainHeightMap:e,heightMap:t,heightMapBounds:o,dummyHeightMap:i,terrainCover:s,useTerrainHeightMap:a,terrainSkipRender:n}=r,l=Fe.project.getUniforms(r.project),{commonOrigin:c}=l,p=n?g.SKIP:g.NONE,f=i,u=null;if(e)p=g.WRITE_HEIGHT_MAP,u=o;else if(a&&t)p=g.USE_HEIGHT_MAP,f=t,u=o;else if(s){let h=(r.isPicking?s.getPickingFramebuffer():s.getRenderFramebuffer())?.colorAttachments[0].texture;r.isPicking&&(p=g.SKIP),h?(f=h,p=p===g.SKIP?g.USE_COVER_ONLY:g.USE_COVER,u=s.bounds):r.isPicking&&!n&&(p=g.NONE)}return{mode:p,terrain_map:f,bounds:u?[u[0]-c[0],u[1]-c[1],u[2]-u[0],u[3]-u[1]]:[0,0,0,0]}}return{mode:g.NONE,terrain_map:r.dummyHeightMap,bounds:[0,0,0,0]}},uniformTypes:{mode:"f32",bounds:"vec4<f32>"}};var Dt=d(_(),1);function Y(r,e){return r.createFramebuffer({id:e.id,colorAttachments:[r.createTexture({id:e.id,...e.float&&{format:"rgba32float",type:5126},dimension:"2d",width:1,height:1,sampler:e.interpolate===!1?{minFilter:"nearest",magFilter:"nearest"}:{minFilter:"linear",magFilter:"linear"}})]})}var ne=class{constructor(e){this.isDirty=!0,this.renderViewport=null,this.bounds=null,this.layers=[],this.targetBounds=null,this.targetBoundsCommon=null,this.targetLayer=e,this.tile=zt(e)}get id(){return this.targetLayer.id}get isActive(){return Boolean(this.targetLayer.getCurrentLayer())}shouldUpdate({targetLayer:e,viewport:t,layers:o,layerNeedsRedraw:i}){e&&(this.targetLayer=e);let s=t?this._updateViewport(t):!1,a=o?this._updateLayers(o):!1;if(i){for(let n of this.layers)if(i[n]){a=!0;break}}return a||s}_updateLayers(e){let t=!1;if(e=this.tile?jo(this.tile,e):e,e.length!==this.layers.length)t=!0;else for(let o=0;o<e.length;o++)if(e[o].id!==this.layers[o]){t=!0;break}return t&&(this.layers=e.map(o=>o.id)),t}_updateViewport(e){let t=this.targetLayer,o=!1;if(this.tile&&"boundingBox"in this.tile){if(!this.targetBounds){o=!0,this.targetBounds=this.tile.boundingBox;let s=H(this.targetBounds[0]),a=H(this.targetBounds[1]);this.targetBoundsCommon=[s[0],s[1],a[0],a[1]]}}else this.targetBounds!==t.getBounds()&&(o=!0,this.targetBounds=t.getBounds(),this.targetBoundsCommon=T([t],ae(e)));if(!this.targetBoundsCommon)return!1;let i=Math.ceil(e.zoom+.5);if(this.tile)this.bounds=this.targetBoundsCommon;else{let s=this.renderViewport?.zoom;o=o||i!==s;let a=e instanceof Dt._GlobeViewport?this.targetBoundsCommon:A(this.targetBoundsCommon,e),n=this.bounds;o=o||!n||a.some((l,c)=>l!==n[c]),this.bounds=a}return o&&(this.renderViewport=O({bounds:this.bounds,zoom:i,viewport:e})),o}getRenderFramebuffer(){return!this.renderViewport||this.layers.length===0?null:(this.fbo||(this.fbo=Y(this.targetLayer.context.device,{id:this.id})),this.fbo)}getPickingFramebuffer(){return!this.renderViewport||this.layers.length===0&&!this.targetLayer.props.pickable?null:(this.pickingFbo||(this.pickingFbo=Y(this.targetLayer.context.device,{id:`${this.id}-picking`,interpolate:!1})),this.pickingFbo)}filterLayers(e){return e.filter(({id:t})=>this.layers.includes(t))}delete(){let{fbo:e,pickingFbo:t}=this;e&&(e.colorAttachments[0].destroy(),e.destroy()),t&&(t.colorAttachments[0].destroy(),t.destroy())}};function jo(r,e){return e.filter(t=>{let o=zt(t);return o?Uo(r.boundingBox,o.boundingBox):!0})}function zt(r){for(;r;){let{tile:e}=r.props;if(e)return e;r=r.parent}return null}function Uo(r,e){return r&&e?r[0][0]<e[1][0]&&e[0][0]<r[1][0]&&r[0][1]<e[1][1]&&e[0][1]<r[1][1]:!1}var Vt=d(_(),1),Go={blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},le=class extends Vt._LayersPass{getRenderableLayers(e,t){let{layers:o}=t,i=[],s=this._getDrawLayerParams(e,t,!0);for(let a=0;a<o.length;a++){let n=o[a];!n.isComposite&&s[a].shouldDrawLayer&&i.push(n)}return i}renderHeightMap(e,t){let o=e.getRenderFramebuffer(),i=e.renderViewport;!o||!i||(o.resize(i),this.render({...t,target:o,pass:"terrain-height-map",layers:t.layers,viewports:[i],effects:[],clearColor:[0,0,0,0]}))}renderTerrainCover(e,t){let o=e.getRenderFramebuffer(),i=e.renderViewport;if(!o||!i)return;let s=e.filterLayers(t.layers);o.resize(i),this.render({...t,target:o,pass:`terrain-cover-${e.id}`,layers:s,viewports:[i],clearColor:[0,0,0,0]})}getLayerParameters(e,t,o){return{...e.props.parameters,blend:!0,depthCompare:"always",...e.props.operation.includes("terrain")&&Go}}getShaderModuleProps(e,t,o){return{terrain:{project:o.project}}}};var jt=d(_(),1),ce=class extends jt._PickLayersPass{constructor(){super(...arguments),this.drawParameters={}}getRenderableLayers(e,t){let{layers:o}=t,i=[];this.drawParameters={},this._resetColorEncoder(t.pickZ);let s=this._getDrawLayerParams(e,t);for(let a=0;a<o.length;a++){let n=o[a];!n.isComposite&&s[a].shouldDrawLayer&&(i.push(n),this.drawParameters[n.id]=s[a].layerParameters)}return i}renderTerrainCover(e,t){let o=e.getPickingFramebuffer(),i=e.renderViewport;if(!o||!i)return;let s=e.filterLayers(t.layers),a=e.targetLayer;a.props.pickable&&s.unshift(a),o.resize(i);let l=this.drawParameters[a.id]?.blendColor?.[3]??0;this.render({...t,pickingFBO:o,pass:`terrain-cover-picking-${e.id}`,layers:s,viewports:[i],cullRect:void 0,deviceRect:i,pickZ:!1,clearColor:[0,0,0,l]})}getLayerParameters(e,t,o){let i;return this.drawParameters[e.id]?i=this.drawParameters[e.id]:(i=super.getLayerParameters(e,t,o),i.blend=!0),{...i,depthCompare:"always",blendAlphaSrcFactor:"constant"}}getShaderModuleProps(e,t,o){return{...super.getShaderModuleProps(e,t,o),terrain:{project:o.project}}}};var Gt=d(_(),1),Ut=2048,$=class{static isSupported(e){return e.isTextureFormatRenderable("rgba32float")}constructor(e){this.renderViewport=null,this.bounds=null,this.layers=[],this.layersBounds=[],this.layersBoundsCommon=null,this.lastViewport=null,this.device=e}getRenderFramebuffer(){return this.renderViewport?(this.fbo||(this.fbo=Y(this.device,{id:"height-map",float:!0})),this.fbo):null}shouldUpdate({layers:e,viewport:t}){let o=e.length!==this.layers.length||e.some((s,a)=>s!==this.layers[a]||s.props.transitions||s.getBounds()!==this.layersBounds[a]);o&&(this.layers=e,this.layersBounds=e.map(s=>s.getBounds()),this.layersBoundsCommon=T(e,ae(t)));let i=!this.lastViewport||!t.equals(this.lastViewport);if(!this.layersBoundsCommon)this.renderViewport=null;else if(o||i){let s=t instanceof Gt._GlobeViewport?this.layersBoundsCommon:A(this.layersBoundsCommon,t);if(s[2]<=s[0]||s[3]<=s[1])return this.renderViewport=null,!1;this.bounds=s,this.lastViewport=t;let a=t.scale,n=(s[2]-s[0])*a,l=(s[3]-s[1])*a,c=t.isGeospatial?H([t.longitude??0,t.latitude??0]):[t.center[0],t.center[1]];return this.renderViewport=n>0||l>0?O({bounds:[c[0]-1,c[1]-1,c[0]+1,c[1]+1],zoom:t.zoom,width:Math.min(n,Ut),height:Math.min(l,Ut),viewport:t}):null,!0}return!1}delete(){this.fbo&&(this.fbo.colorAttachments[0].delete(),this.fbo.delete())}};var fe=class{constructor(){this.id="terrain-effect",this.props=null,this.useInPicking=!0,this.isPicking=!1,this.isDrapingEnabled=!1,this.terrainCovers=new Map}setup({device:e,deck:t}){this.dummyHeightMap=e.createTexture({width:1,height:1,data:new Uint8Array([0,0,0,0])}),this.terrainPass=new le(e,{id:"terrain"}),this.terrainPickingPass=new ce(e,{id:"terrain-picking"}),$.isSupported(e)?this.heightMap=new $(e):Ht.log.warn("Terrain offset mode is not supported by this browser")(),t._addDefaultShaderModule(K)}preRender(e){if(e.pickZ){this.isDrapingEnabled=!1;return}let{viewports:t}=e,o=e.pass.startsWith("picking");this.isPicking=o,this.isDrapingEnabled=!0;let i=t[0],s=(o?this.terrainPickingPass:this.terrainPass).getRenderableLayers(i,e),a=s.filter(c=>c.props.operation.includes("terrain"));if(a.length===0)return;o||s.filter(p=>p.state.terrainDrawMode==="offset").length>0&&this._updateHeightMap(a,i,e);let n=s.filter(c=>c.state.terrainDrawMode==="drape"),l=e.effects?.filter(c=>c!==this);this._updateTerrainCovers(a,n,i,{...e,effects:l})}getShaderModuleProps(e,t){if(e.props.operation.includes("mask"))return{terrain:{dummyHeightMap:this.dummyHeightMap}};let{terrainDrawMode:o}=e.state,i=this.isDrapingEnabled?this.terrainCovers.get(e.id)??null:null;return this.isPicking&&e.props.operation.includes("terrain")&&(e.state._hasPickingCover=Boolean(i?.getPickingFramebuffer())),{terrain:{project:t.project,isPicking:this.isPicking,heightMap:this.heightMap?.getRenderFramebuffer()?.colorAttachments[0].texture||null,heightMapBounds:this.heightMap?.bounds,dummyHeightMap:this.dummyHeightMap,terrainCover:i,useTerrainHeightMap:o==="offset",terrainSkipRender:o==="drape"||!e.props.operation.includes("draw")}}}cleanup({deck:e}){this.dummyHeightMap&&(this.dummyHeightMap.delete(),this.dummyHeightMap=void 0),this.heightMap&&(this.heightMap.delete(),this.heightMap=void 0);for(let t of this.terrainCovers.values())t.delete();this.terrainCovers.clear(),e._removeDefaultShaderModule(K)}_updateHeightMap(e,t,o){!this.heightMap||!this.heightMap.shouldUpdate({layers:e,viewport:t})||this.terrainPass.renderHeightMap(this.heightMap,{...o,layers:e,shaderModuleProps:{terrain:{heightMapBounds:this.heightMap.bounds,dummyHeightMap:this.dummyHeightMap,drawToTerrainHeightMap:!0},project:{devicePixelRatio:1}}})}_updateTerrainCovers(e,t,o,i){let s={};for(let a of t)a.state.terrainCoverNeedsRedraw&&(s[a.id]=!0,a.state.terrainCoverNeedsRedraw=!1);for(let a of this.terrainCovers.values())a.isDirty=a.isDirty||a.shouldUpdate({layerNeedsRedraw:s});for(let a of e)this._updateTerrainCover(a,t,o,i);this.isPicking||this._pruneTerrainCovers()}_updateTerrainCover(e,t,o,i){let s=this.isPicking?this.terrainPickingPass:this.terrainPass,a=this.terrainCovers.get(e.id);a||(a=new ne(e),this.terrainCovers.set(e.id,a));try{let n=a.shouldUpdate({targetLayer:e,viewport:o,layers:t});(this.isPicking||a.isDirty||n)&&(s.renderTerrainCover(a,{...i,layers:t,shaderModuleProps:{terrain:{dummyHeightMap:this.dummyHeightMap,terrainSkipRender:!1},project:{devicePixelRatio:1}}}),this.isPicking||(a.isDirty=!1))}catch(n){e.raiseError(n,`Error rendering terrain cover ${a.id}`)}}_pruneTerrainCovers(){let e=[];for(let[t,o]of this.terrainCovers)o.isActive||e.push(t);for(let t of e)this.terrainCovers.delete(t)}};var Ho={terrainDrawMode:void 0},Z=class extends qt.LayerExtension{getShaders(){return{modules:[K]}}initializeState(){this.context.deck?._addDefaultEffect(new fe)}updateState(e){let{props:t,oldProps:o}=e;if(this.state.terrainDrawMode&&t.terrainDrawMode===o.terrainDrawMode&&t.extruded===o.extruded)return;let{terrainDrawMode:i}=t;if(!i){let s=this.props.extruded,a=this.getAttributeManager()?.attributes,n=a&&"instancePositions"in a;i=s||n?"offset":"drape"}this.setState({terrainDrawMode:i})}onNeedsRedraw(){let e=this.state;e.terrainDrawMode==="drape"&&(e.terrainCoverNeedsRedraw=!0)}};Z.defaultProps=Ho;Z.extensionName="TerrainExtension";var Wt=Z;return Xt(J);})();
|
|
2257
|
+
`},getUniforms:(i={})=>{if(!i.dummyHeightMap)return{};if("terrainSkipRender"in i||"drawToTerrainHeightMap"in i){let{drawToTerrainHeightMap:e,heightMap:t,heightMapBounds:r,dummyHeightMap:o,terrainCover:s,useTerrainHeightMap:n,terrainSkipRender:a}=i,l=Fe.project.getUniforms(i.project),{commonOrigin:f}=l,u=a?g.SKIP:g.NONE,c=o,p=null;if(e)u=g.WRITE_HEIGHT_MAP,p=r;else if(n&&t)u=g.USE_HEIGHT_MAP,c=t,p=r;else if(s){let h=(i.isPicking?s.getPickingFramebuffer():s.getRenderFramebuffer())?.colorAttachments[0].texture;i.isPicking&&(u=g.SKIP),h?(c=h,u=u===g.SKIP?g.USE_COVER_ONLY:g.USE_COVER,p=s.bounds):i.isPicking&&!a&&(u=g.NONE)}return{mode:u,terrain_map:c,bounds:p?[p[0]-f[0],p[1]-f[1],p[2]-p[0],p[3]-p[1]]:[0,0,0,0]}}return{mode:g.NONE,terrain_map:i.dummyHeightMap,bounds:[0,0,0,0]}},uniformTypes:{mode:"f32",bounds:"vec4<f32>"}};var Dt=d(_(),1);function K(i,e){return i.createFramebuffer({id:e.id,colorAttachments:[i.createTexture({id:e.id,...e.float&&{format:"rgba32float",type:5126},dimension:"2d",width:1,height:1,sampler:e.interpolate===!1?{minFilter:"nearest",magFilter:"nearest"}:{minFilter:"linear",magFilter:"linear"}})]})}var ae=class{constructor(e){this.isDirty=!0,this.renderViewport=null,this.bounds=null,this.layers=[],this.targetBounds=null,this.targetBoundsCommon=null,this.targetLayer=e,this.tile=zt(e)}get id(){return this.targetLayer.id}get isActive(){return Boolean(this.targetLayer.getCurrentLayer())}shouldUpdate({targetLayer:e,viewport:t,layers:r,layerNeedsRedraw:o}){e&&(this.targetLayer=e);let s=t?this._updateViewport(t):!1,n=r?this._updateLayers(r):!1;if(o){for(let a of this.layers)if(o[a]){n=!0;break}}return n||s}_updateLayers(e){let t=!1;if(e=this.tile?Vr(this.tile,e):e,e.length!==this.layers.length)t=!0;else for(let r=0;r<e.length;r++)if(e[r].id!==this.layers[r]){t=!0;break}return t&&(this.layers=e.map(r=>r.id)),t}_updateViewport(e){let t=this.targetLayer,r=!1;if(this.tile&&"boundingBox"in this.tile){if(!this.targetBounds){r=!0,this.targetBounds=this.tile.boundingBox;let s=H(this.targetBounds[0]),n=H(this.targetBounds[1]);this.targetBoundsCommon=[s[0],s[1],n[0],n[1]]}}else this.targetBounds!==t.getBounds()&&(r=!0,this.targetBounds=t.getBounds(),this.targetBoundsCommon=T([t],ne(e)));if(!this.targetBoundsCommon)return!1;let o=Math.ceil(e.zoom+.5);if(this.tile)this.bounds=this.targetBoundsCommon;else{let s=this.renderViewport?.zoom;r=r||o!==s;let n=e instanceof Dt._GlobeViewport?this.targetBoundsCommon:L(this.targetBoundsCommon,e),a=this.bounds;r=r||!a||n.some((l,f)=>l!==a[f]),this.bounds=n}return r&&(this.renderViewport=O({bounds:this.bounds,zoom:o,viewport:e})),r}getRenderFramebuffer(){return!this.renderViewport||this.layers.length===0?null:(this.fbo||(this.fbo=K(this.targetLayer.context.device,{id:this.id})),this.fbo)}getPickingFramebuffer(){return!this.renderViewport||this.layers.length===0&&!this.targetLayer.props.pickable?null:(this.pickingFbo||(this.pickingFbo=K(this.targetLayer.context.device,{id:`${this.id}-picking`,interpolate:!1})),this.pickingFbo)}filterLayers(e){return e.filter(({id:t})=>this.layers.includes(t))}delete(){let{fbo:e,pickingFbo:t}=this;e&&(e.colorAttachments[0].destroy(),e.destroy()),t&&(t.colorAttachments[0].destroy(),t.destroy())}};function Vr(i,e){return e.filter(t=>{let r=zt(t);return r?jr(i.boundingBox,r.boundingBox):!0})}function zt(i){for(;i;){let{tile:e}=i.props;if(e)return e;i=i.parent}return null}function jr(i,e){return i&&e?i[0][0]<e[1][0]&&e[0][0]<i[1][0]&&i[0][1]<e[1][1]&&e[0][1]<i[1][1]:!1}var Vt=d(_(),1),Ur={blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},le=class extends Vt._LayersPass{getRenderableLayers(e,t){let{layers:r}=t,o=[],s=this._getDrawLayerParams(e,t,!0);for(let n=0;n<r.length;n++){let a=r[n];!a.isComposite&&s[n].shouldDrawLayer&&o.push(a)}return o}renderHeightMap(e,t){let r=e.getRenderFramebuffer(),o=e.renderViewport;!r||!o||(r.resize(o),this.render({...t,target:r,pass:"terrain-height-map",layers:t.layers,viewports:[o],effects:[],clearColor:[0,0,0,0]}))}renderTerrainCover(e,t){let r=e.getRenderFramebuffer(),o=e.renderViewport;if(!r||!o)return;let s=e.filterLayers(t.layers);r.resize(o),this.render({...t,target:r,pass:`terrain-cover-${e.id}`,layers:s,viewports:[o],clearColor:[0,0,0,0]})}getLayerParameters(e,t,r){return{...e.props.parameters,blend:!0,depthCompare:"always",...e.props.operation.includes("terrain")&&Ur}}getShaderModuleProps(e,t,r){return{terrain:{project:r.project}}}};var jt=d(_(),1),fe=class extends jt._PickLayersPass{constructor(){super(...arguments),this.drawParameters={}}getRenderableLayers(e,t){let{layers:r}=t,o=[];this.drawParameters={},this._resetColorEncoder(t.pickZ);let s=this._getDrawLayerParams(e,t);for(let n=0;n<r.length;n++){let a=r[n];!a.isComposite&&s[n].shouldDrawLayer&&(o.push(a),this.drawParameters[a.id]=s[n].layerParameters)}return o}renderTerrainCover(e,t){let r=e.getPickingFramebuffer(),o=e.renderViewport;if(!r||!o)return;let s=e.filterLayers(t.layers),n=e.targetLayer;n.props.pickable&&s.unshift(n),r.resize(o);let l=this.drawParameters[n.id]?.blendColor?.[3]??0;this.render({...t,pickingFBO:r,pass:`terrain-cover-picking-${e.id}`,layers:s,viewports:[o],cullRect:void 0,deviceRect:o,pickZ:!1,clearColor:[0,0,0,l]})}getLayerParameters(e,t,r){let o;return this.drawParameters[e.id]?o=this.drawParameters[e.id]:(o=super.getLayerParameters(e,t,r),o.blend=!0),{...o,depthCompare:"always",blendAlphaSrcFactor:"constant"}}getShaderModuleProps(e,t,r){return{...super.getShaderModuleProps(e,t,r),terrain:{project:r.project}}}};var Gt=d(_(),1),Ut=2048,$=class{static isSupported(e){return e.isTextureFormatRenderable("rgba32float")}constructor(e){this.renderViewport=null,this.bounds=null,this.layers=[],this.layersBounds=[],this.layersBoundsCommon=null,this.lastViewport=null,this.device=e}getRenderFramebuffer(){return this.renderViewport?(this.fbo||(this.fbo=K(this.device,{id:"height-map",float:!0})),this.fbo):null}shouldUpdate({layers:e,viewport:t}){let r=e.length!==this.layers.length||e.some((s,n)=>s!==this.layers[n]||s.props.transitions||s.getBounds()!==this.layersBounds[n]);r&&(this.layers=e,this.layersBounds=e.map(s=>s.getBounds()),this.layersBoundsCommon=T(e,ne(t)));let o=!this.lastViewport||!t.equals(this.lastViewport);if(!this.layersBoundsCommon)this.renderViewport=null;else if(r||o){let s=t instanceof Gt._GlobeViewport?this.layersBoundsCommon:L(this.layersBoundsCommon,t);if(s[2]<=s[0]||s[3]<=s[1])return this.renderViewport=null,!1;this.bounds=s,this.lastViewport=t;let n=t.scale,a=(s[2]-s[0])*n,l=(s[3]-s[1])*n,f=t.isGeospatial?H([t.longitude??0,t.latitude??0]):[t.center[0],t.center[1]];return this.renderViewport=a>0||l>0?O({bounds:[f[0]-1,f[1]-1,f[0]+1,f[1]+1],zoom:t.zoom,width:Math.min(a,Ut),height:Math.min(l,Ut),viewport:t}):null,!0}return!1}delete(){this.fbo&&(this.fbo.colorAttachments[0].delete(),this.fbo.delete())}};var ce=class{constructor(){this.id="terrain-effect",this.props=null,this.useInPicking=!0,this.isPicking=!1,this.isDrapingEnabled=!1,this.terrainCovers=new Map}setup({device:e,deck:t}){this.dummyHeightMap=e.createTexture({width:1,height:1,data:new Uint8Array([0,0,0,0])}),this.terrainPass=new le(e,{id:"terrain"}),this.terrainPickingPass=new fe(e,{id:"terrain-picking"}),$.isSupported(e)?this.heightMap=new $(e):Ht.log.warn("Terrain offset mode is not supported by this browser")(),t._addDefaultShaderModule(Y)}preRender(e){if(e.pickZ){this.isDrapingEnabled=!1;return}let{viewports:t}=e,r=e.pass.startsWith("picking");this.isPicking=r,this.isDrapingEnabled=!0;let o=t[0],s=(r?this.terrainPickingPass:this.terrainPass).getRenderableLayers(o,e),n=s.filter(f=>f.props.operation.includes("terrain"));if(n.length===0)return;r||s.filter(u=>u.state.terrainDrawMode==="offset").length>0&&this._updateHeightMap(n,o,e);let a=s.filter(f=>f.state.terrainDrawMode==="drape"),l=e.effects?.filter(f=>f!==this);this._updateTerrainCovers(n,a,o,{...e,effects:l})}getShaderModuleProps(e,t){if(e.props.operation.includes("mask"))return{terrain:{dummyHeightMap:this.dummyHeightMap}};let{terrainDrawMode:r}=e.state,o=this.isDrapingEnabled?this.terrainCovers.get(e.id)??null:null;return this.isPicking&&e.props.operation.includes("terrain")&&(e.state._hasPickingCover=Boolean(o?.getPickingFramebuffer())),{terrain:{project:t.project,isPicking:this.isPicking,heightMap:this.heightMap?.getRenderFramebuffer()?.colorAttachments[0].texture||null,heightMapBounds:this.heightMap?.bounds,dummyHeightMap:this.dummyHeightMap,terrainCover:o,useTerrainHeightMap:r==="offset",terrainSkipRender:r==="drape"||!e.props.operation.includes("draw")}}}cleanup({deck:e}){this.dummyHeightMap&&(this.dummyHeightMap.delete(),this.dummyHeightMap=void 0),this.heightMap&&(this.heightMap.delete(),this.heightMap=void 0);for(let t of this.terrainCovers.values())t.delete();this.terrainCovers.clear(),e._removeDefaultShaderModule(Y)}_updateHeightMap(e,t,r){!this.heightMap||!this.heightMap.shouldUpdate({layers:e,viewport:t})||this.terrainPass.renderHeightMap(this.heightMap,{...r,layers:e,shaderModuleProps:{terrain:{heightMapBounds:this.heightMap.bounds,dummyHeightMap:this.dummyHeightMap,drawToTerrainHeightMap:!0},project:{devicePixelRatio:1}}})}_updateTerrainCovers(e,t,r,o){let s={};for(let n of t)n.state.terrainCoverNeedsRedraw&&(s[n.id]=!0,n.state.terrainCoverNeedsRedraw=!1);for(let n of this.terrainCovers.values())n.isDirty=n.isDirty||n.shouldUpdate({layerNeedsRedraw:s});for(let n of e)this._updateTerrainCover(n,t,r,o);this.isPicking||this._pruneTerrainCovers()}_updateTerrainCover(e,t,r,o){let s=this.isPicking?this.terrainPickingPass:this.terrainPass,n=this.terrainCovers.get(e.id);n||(n=new ae(e),this.terrainCovers.set(e.id,n));try{let a=n.shouldUpdate({targetLayer:e,viewport:r,layers:t});(this.isPicking||n.isDirty||a)&&(s.renderTerrainCover(n,{...o,layers:t,shaderModuleProps:{terrain:{dummyHeightMap:this.dummyHeightMap,terrainSkipRender:!1},project:{devicePixelRatio:1}}}),this.isPicking||(n.isDirty=!1))}catch(a){e.raiseError(a,`Error rendering terrain cover ${n.id}`)}}_pruneTerrainCovers(){let e=[];for(let[t,r]of this.terrainCovers)r.isActive||e.push(t);for(let t of e)this.terrainCovers.delete(t)}};var Gr={terrainDrawMode:void 0},Z=class extends qt.LayerExtension{getShaders(){return{modules:[Y]}}initializeState(){this.context.deck?._addDefaultEffect(new ce)}updateState(e){let{props:t,oldProps:r}=e;if(this.state.terrainDrawMode&&t.terrainDrawMode===r.terrainDrawMode&&t.extruded===r.extruded)return;let{terrainDrawMode:o}=t;if(!o){let s=this.props.extruded,n=this.getAttributeManager()?.attributes,a=n&&"instancePositions"in n;o=s||a?"offset":"drape"}this.setState({terrainDrawMode:o})}onNeedsRedraw(){let e=this.state;e.terrainDrawMode==="drape"&&(e.terrainCoverNeedsRedraw=!0)}};Z.defaultProps=Gr;Z.extensionName="TerrainExtension";var Wt=Z;return Xt(J);})();
|
|
1991
2258
|
return __exports__;
|
|
1992
2259
|
});
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Plug-and-play functionalities for deck.gl layers",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "9.4.0-alpha.
|
|
6
|
+
"version": "9.4.0-alpha.2",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
"type": "git",
|
|
18
18
|
"url": "https://github.com/visgl/deck.gl.git"
|
|
19
19
|
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/visgl/deck.gl/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://deck.gl",
|
|
20
24
|
"types": "dist/index.d.ts",
|
|
21
25
|
"main": "dist/index.cjs",
|
|
22
26
|
"module": "dist/index.js",
|
|
@@ -38,14 +42,14 @@
|
|
|
38
42
|
"prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env=dev"
|
|
39
43
|
},
|
|
40
44
|
"dependencies": {
|
|
41
|
-
"@luma.gl/shadertools": "^9.
|
|
42
|
-
"@luma.gl/webgl": "^9.
|
|
45
|
+
"@luma.gl/shadertools": "^9.4.0-alpha.1",
|
|
46
|
+
"@luma.gl/webgl": "^9.4.0-alpha.1",
|
|
43
47
|
"@math.gl/core": "^4.1.0"
|
|
44
48
|
},
|
|
45
49
|
"peerDependencies": {
|
|
46
50
|
"@deck.gl/core": "~9.3.0-beta.2",
|
|
47
|
-
"@luma.gl/core": "~9.
|
|
48
|
-
"@luma.gl/engine": "~9.
|
|
51
|
+
"@luma.gl/core": "~9.4.0-alpha.1",
|
|
52
|
+
"@luma.gl/engine": "~9.4.0-alpha.1"
|
|
49
53
|
},
|
|
50
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "546e2e8284b00949ab26e744ffd05b9aa017c802"
|
|
51
55
|
}
|