tangram-core 0.3.0__cp310-cp310-manylinux_2_28_aarch64.whl
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.
- tangram_core/App.vue +441 -0
- tangram_core/CommandPalette.vue +200 -0
- tangram_core/HighlightText.vue +32 -0
- tangram_core/__Timeline.vue +300 -0
- tangram_core/__init__.py +5 -0
- tangram_core/__main__.py +331 -0
- tangram_core/_core.cpython-310-aarch64-linux-gnu.so +0 -0
- tangram_core/_core.pyi +38 -0
- tangram_core/api.ts +652 -0
- tangram_core/backend.py +458 -0
- tangram_core/components.ts +2 -0
- tangram_core/config.py +167 -0
- tangram_core/dist-frontend/aggregation-layers.js +521 -0
- tangram_core/dist-frontend/aggregation-layers.js.map +1 -0
- tangram_core/dist-frontend/assets/_commonjsHelpers-CqkleIqs.js +2 -0
- tangram_core/dist-frontend/assets/_commonjsHelpers-CqkleIqs.js.map +1 -0
- tangram_core/dist-frontend/assets/array-utils-flat-BBMak426.js +11 -0
- tangram_core/dist-frontend/assets/array-utils-flat-BBMak426.js.map +1 -0
- tangram_core/dist-frontend/assets/assert-cyW4mg7q.js +3 -0
- tangram_core/dist-frontend/assets/assert-cyW4mg7q.js.map +1 -0
- tangram_core/dist-frontend/assets/b612-latin-400-italic-DePNXA0a.woff +0 -0
- tangram_core/dist-frontend/assets/b612-latin-400-italic-a-4GLPtl.woff2 +0 -0
- tangram_core/dist-frontend/assets/b612-latin-400-normal-CC98FVm_.woff2 +0 -0
- tangram_core/dist-frontend/assets/b612-latin-400-normal-JbZ7xwUX.woff +0 -0
- tangram_core/dist-frontend/assets/b612-latin-700-normal-B_Snq1wd.woff +0 -0
- tangram_core/dist-frontend/assets/b612-latin-700-normal-BinQrnoB.woff2 +0 -0
- tangram_core/dist-frontend/assets/clip-extension-D-rbmFPj.js +26 -0
- tangram_core/dist-frontend/assets/clip-extension-D-rbmFPj.js.map +1 -0
- tangram_core/dist-frontend/assets/color-CUNNsFV-.js +17 -0
- tangram_core/dist-frontend/assets/color-CUNNsFV-.js.map +1 -0
- tangram_core/dist-frontend/assets/cube-geometry-v0HQ793i.js +2 -0
- tangram_core/dist-frontend/assets/cube-geometry-v0HQ793i.js.map +1 -0
- tangram_core/dist-frontend/assets/deep-equal-BTW2ZN6S.js +2 -0
- tangram_core/dist-frontend/assets/deep-equal-BTW2ZN6S.js.map +1 -0
- tangram_core/dist-frontend/assets/fly-to-interpolator-CIXGjOdo.js +2 -0
- tangram_core/dist-frontend/assets/fly-to-interpolator-CIXGjOdo.js.map +1 -0
- tangram_core/dist-frontend/assets/geojson-layer-DgMOQ4Qu.js +1010 -0
- tangram_core/dist-frontend/assets/geojson-layer-DgMOQ4Qu.js.map +1 -0
- tangram_core/dist-frontend/assets/globe-view-Day_n1iB.js +94 -0
- tangram_core/dist-frontend/assets/globe-view-Day_n1iB.js.map +1 -0
- tangram_core/dist-frontend/assets/globe-viewport-tqhQW7C4.js +2 -0
- tangram_core/dist-frontend/assets/globe-viewport-tqhQW7C4.js.map +1 -0
- tangram_core/dist-frontend/assets/image-loader-hHJsndO6.js +2 -0
- tangram_core/dist-frontend/assets/image-loader-hHJsndO6.js.map +1 -0
- tangram_core/dist-frontend/assets/inconsolata-latin-400-normal-DTZQ6lD6.woff2 +0 -0
- tangram_core/dist-frontend/assets/inconsolata-latin-400-normal-HYADljCo.woff +0 -0
- tangram_core/dist-frontend/assets/inconsolata-latin-700-normal-ByjKuJjN.woff2 +0 -0
- tangram_core/dist-frontend/assets/inconsolata-latin-700-normal-DzgUY3Rl.woff +0 -0
- tangram_core/dist-frontend/assets/inconsolata-latin-ext-400-normal-BaHVOdFB.woff2 +0 -0
- tangram_core/dist-frontend/assets/inconsolata-latin-ext-400-normal-yvPjCxxx.woff +0 -0
- tangram_core/dist-frontend/assets/inconsolata-latin-ext-700-normal-D0Kpgs_9.woff2 +0 -0
- tangram_core/dist-frontend/assets/inconsolata-latin-ext-700-normal-Dlt-daqV.woff +0 -0
- tangram_core/dist-frontend/assets/inconsolata-vietnamese-400-normal-ByiM2lek.woff +0 -0
- tangram_core/dist-frontend/assets/inconsolata-vietnamese-400-normal-DfC_iMic.woff2 +0 -0
- tangram_core/dist-frontend/assets/inconsolata-vietnamese-700-normal-DLCFFAUf.woff +0 -0
- tangram_core/dist-frontend/assets/inconsolata-vietnamese-700-normal-DuasYmn8.woff2 +0 -0
- tangram_core/dist-frontend/assets/index-CcogpxdD.js +824 -0
- tangram_core/dist-frontend/assets/index-CcogpxdD.js.map +1 -0
- tangram_core/dist-frontend/assets/index-SSLdizTv.css +1 -0
- tangram_core/dist-frontend/assets/layer-DPcO4AXQ.js +555 -0
- tangram_core/dist-frontend/assets/layer-DPcO4AXQ.js.map +1 -0
- tangram_core/dist-frontend/assets/layer-extension-CYwTXf73.js +2 -0
- tangram_core/dist-frontend/assets/layer-extension-CYwTXf73.js.map +1 -0
- tangram_core/dist-frontend/assets/mesh-layers-wiqredoy.js +1123 -0
- tangram_core/dist-frontend/assets/mesh-layers-wiqredoy.js.map +1 -0
- tangram_core/dist-frontend/assets/orthographic-viewport-B4nCj5tn.js +2 -0
- tangram_core/dist-frontend/assets/orthographic-viewport-B4nCj5tn.js.map +1 -0
- tangram_core/dist-frontend/assets/pick-layers-pass-C-3k0wbN.js +2 -0
- tangram_core/dist-frontend/assets/pick-layers-pass-C-3k0wbN.js.map +1 -0
- tangram_core/dist-frontend/assets/project-BTjD2Imj.js +760 -0
- tangram_core/dist-frontend/assets/project-BTjD2Imj.js.map +1 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-400-italic-4qS3_zkX.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-400-italic-CDK-EZBY.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-400-normal-Bgns473E.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-400-normal-_T2aQlWs.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-500-normal-CvEVpWxD.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-500-normal-s4PklZE0.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-700-normal-9RN-Z7cI.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-700-normal-BGMkBBYx.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-400-italic-C7erd-g8.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-400-italic-DR5R5TWx.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-400-normal-DGo1Ayjq.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-400-normal-WtM1l1qc.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-500-normal-C8FNIdXm.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-500-normal-TLDmfi3Q.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-700-normal-CTXjXnze.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-700-normal-CWPRiRXS.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-greek-400-italic-CR6qj4Z4.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-greek-400-italic-DHRaIs10.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-greek-400-normal-D5vBSIyg.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-greek-400-normal-FabMgVmk.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-greek-500-normal-BIN62cw9.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-greek-500-normal-Hsn-wDIp.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-greek-700-normal-89Up2Xly.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-greek-700-normal-DWMOA2VK.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-400-italic-D_BR-3LG.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-400-italic-om57GXsO.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-400-normal-BICmKrXV.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-400-normal-D2e7XwB1.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-500-normal-3p2daRJW.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-500-normal-Dc9bsamC.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-700-normal-BOl6B_hI.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-700-normal-DRbp0YnP.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-400-italic-BXrkWnoY.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-400-italic-Bhem1d5z.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-400-normal-DT8nEsYA.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-400-normal-OHaX69iP.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-500-normal-CcSTXKtO.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-500-normal-JgPl2bDS.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-700-normal-B004qtqu.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-700-normal-O6H_RRvN.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-400-italic-BwUYFJ2t.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-400-italic-DV8QogUk.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-400-normal-0o1laQ-g.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-400-normal-CPsdS8_S.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-500-normal-G9shSJ2z.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-500-normal-TFWhjk13.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-700-normal-BtNeb9D6.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-700-normal-D35V1G0s.woff2 +0 -0
- tangram_core/dist-frontend/assets/shader-Cbdysp2j.js +843 -0
- tangram_core/dist-frontend/assets/shader-Cbdysp2j.js.map +1 -0
- tangram_core/dist-frontend/assets/solid-polygon-layer-DJFl_7Ca.js +392 -0
- tangram_core/dist-frontend/assets/solid-polygon-layer-DJFl_7Ca.js.map +1 -0
- tangram_core/dist-frontend/assets/tesselator-CENyUZ2p.js +2 -0
- tangram_core/dist-frontend/assets/tesselator-CENyUZ2p.js.map +1 -0
- tangram_core/dist-frontend/assets/webgl-developer-tools-utTNOsNf.js +7 -0
- tangram_core/dist-frontend/assets/webgl-developer-tools-utTNOsNf.js.map +1 -0
- tangram_core/dist-frontend/assets/webgl-device-BYRB-GQX.js +3 -0
- tangram_core/dist-frontend/assets/webgl-device-BYRB-GQX.js.map +1 -0
- tangram_core/dist-frontend/assets/widget-BjgEeHAL.js +2 -0
- tangram_core/dist-frontend/assets/widget-BjgEeHAL.js.map +1 -0
- tangram_core/dist-frontend/core.js +60 -0
- tangram_core/dist-frontend/core.js.map +1 -0
- tangram_core/dist-frontend/extensions.js +609 -0
- tangram_core/dist-frontend/extensions.js.map +1 -0
- tangram_core/dist-frontend/favicon.ico +0 -0
- tangram_core/dist-frontend/favicon.png +0 -0
- tangram_core/dist-frontend/geo-layers.js +115 -0
- tangram_core/dist-frontend/geo-layers.js.map +1 -0
- tangram_core/dist-frontend/index.html +39 -0
- tangram_core/dist-frontend/json.js +3 -0
- tangram_core/dist-frontend/json.js.map +1 -0
- tangram_core/dist-frontend/layers.js +268 -0
- tangram_core/dist-frontend/layers.js.map +1 -0
- tangram_core/dist-frontend/mapbox.js +2 -0
- tangram_core/dist-frontend/mapbox.js.map +1 -0
- tangram_core/dist-frontend/mesh-layers.js +2 -0
- tangram_core/dist-frontend/mesh-layers.js.map +1 -0
- tangram_core/dist-frontend/widgets.js +3 -0
- tangram_core/dist-frontend/widgets.js.map +1 -0
- tangram_core/main.ts +28 -0
- tangram_core/package.json +62 -0
- tangram_core/plugin.py +109 -0
- tangram_core/plugin.ts +47 -0
- tangram_core/redis.py +89 -0
- tangram_core/user.css +114 -0
- tangram_core/utils.ts +143 -0
- tangram_core/vite-plugin-tangram.mjs +155 -0
- tangram_core-0.3.0.dist-info/METADATA +101 -0
- tangram_core-0.3.0.dist-info/RECORD +162 -0
- tangram_core-0.3.0.dist-info/WHEEL +4 -0
- tangram_core-0.3.0.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
import{p as _,m as le}from"./assets/project-BTjD2Imj.js";import{L as v}from"./assets/layer-extension-CYwTXf73.js";import{M as ce,f as G,m as I}from"./assets/shader-Cbdysp2j.js";import{i as U,x as P,O as b,a0 as de,X as j,A as H,W as fe}from"./assets/deep-equal-BTW2ZN6S.js";import{C as Gt}from"./assets/clip-extension-D-rbmFPj.js";import{L as w,a as ue}from"./assets/pick-layers-pass-C-3k0wbN.js";import{O as pe}from"./assets/orthographic-viewport-B4nCj5tn.js";import"./assets/array-utils-flat-BBMak426.js";const Y=`uniform brushingUniforms {
|
|
2
|
+
bool enabled;
|
|
3
|
+
highp int target;
|
|
4
|
+
vec2 mousePos;
|
|
5
|
+
float radius;
|
|
6
|
+
} brushing;
|
|
7
|
+
`,he=`
|
|
8
|
+
in vec2 brushingTargets;
|
|
9
|
+
|
|
10
|
+
out float brushing_isVisible;
|
|
11
|
+
|
|
12
|
+
bool brushing_isPointInRange(vec2 position) {
|
|
13
|
+
if (!brushing.enabled) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
vec2 source_commonspace = project_position(position);
|
|
17
|
+
vec2 target_commonspace = project_position(brushing.mousePos);
|
|
18
|
+
float distance = length((target_commonspace - source_commonspace) / project.commonUnitsPerMeter.xy);
|
|
19
|
+
|
|
20
|
+
return distance <= brushing.radius;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
bool brushing_arePointsInRange(vec2 sourcePos, vec2 targetPos) {
|
|
24
|
+
return brushing_isPointInRange(sourcePos) || brushing_isPointInRange(targetPos);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
void brushing_setVisible(bool visible) {
|
|
28
|
+
brushing_isVisible = float(visible);
|
|
29
|
+
}
|
|
30
|
+
`,me=`
|
|
31
|
+
${Y}
|
|
32
|
+
${he}
|
|
33
|
+
`,ge=`
|
|
34
|
+
in float brushing_isVisible;
|
|
35
|
+
`,_e=`
|
|
36
|
+
${Y}
|
|
37
|
+
${ge}
|
|
38
|
+
`,ve={source:0,target:1,custom:2,source_target:3},ye={"vs:DECKGL_FILTER_GL_POSITION":`
|
|
39
|
+
vec2 brushingTarget;
|
|
40
|
+
vec2 brushingSource;
|
|
41
|
+
if (brushing.target == 3) {
|
|
42
|
+
brushingTarget = geometry.worldPositionAlt.xy;
|
|
43
|
+
brushingSource = geometry.worldPosition.xy;
|
|
44
|
+
} else if (brushing.target == 0) {
|
|
45
|
+
brushingTarget = geometry.worldPosition.xy;
|
|
46
|
+
} else if (brushing.target == 1) {
|
|
47
|
+
brushingTarget = geometry.worldPositionAlt.xy;
|
|
48
|
+
} else {
|
|
49
|
+
brushingTarget = brushingTargets;
|
|
50
|
+
}
|
|
51
|
+
bool visible;
|
|
52
|
+
if (brushing.target == 3) {
|
|
53
|
+
visible = brushing_arePointsInRange(brushingSource, brushingTarget);
|
|
54
|
+
} else {
|
|
55
|
+
visible = brushing_isPointInRange(brushingTarget);
|
|
56
|
+
}
|
|
57
|
+
brushing_setVisible(visible);
|
|
58
|
+
`,"fs:DECKGL_FILTER_COLOR":`
|
|
59
|
+
if (brushing.enabled && brushing_isVisible < 0.5) {
|
|
60
|
+
discard;
|
|
61
|
+
}
|
|
62
|
+
`},be={name:"brushing",dependencies:[_],vs:me,fs:_e,inject:ye,getUniforms:a=>{if(!a||!("viewport"in a))return{};const{brushingEnabled:e=!0,brushingRadius:t=1e4,brushingTarget:i="source",mousePosition:s,viewport:o}=a;return{enabled:!!(e&&s&&o.containsPixel(s)),radius:t,target:ve[i]||0,mousePos:s?o.unproject([s.x-o.x,s.y-o.y]):[0,0]}},uniformTypes:{enabled:"i32",target:"i32",mousePos:"vec2<f32>",radius:"f32"}},Pe={getBrushingTarget:{type:"accessor",value:[0,0]},brushingTarget:"source",brushingEnabled:!0,brushingRadius:1e4};class $ extends v{getShaders(){return{modules:[be]}}initializeState(e,t){const i=this.getAttributeManager();i&&i.add({brushingTargets:{size:2,stepMode:"dynamic",accessor:"getBrushingTarget"}});const s=()=>{this.getCurrentLayer()?.setNeedsRedraw()};this.state.onMouseMove=s,e.deck&&e.deck.eventManager.on({pointermove:s,pointerleave:s})}finalizeState(e,t){if(e.deck){const i=this.state.onMouseMove;e.deck.eventManager.off({pointermove:i,pointerleave:i})}}draw(e,t){const{viewport:i,mousePosition:s}=e.context,{brushingEnabled:o,brushingRadius:r,brushingTarget:n}=this.props,l={viewport:i,mousePosition:s,brushingEnabled:o,brushingRadius:r,brushingTarget:n};this.setShaderModuleProps({brushing:l})}}$.defaultProps=Pe;$.extensionName="BrushingExtension";const W=`uniform dataFilterUniforms {
|
|
63
|
+
bool useSoftMargin;
|
|
64
|
+
bool enabled;
|
|
65
|
+
bool transformSize;
|
|
66
|
+
bool transformColor;
|
|
67
|
+
#ifdef DATAFILTER_TYPE
|
|
68
|
+
DATAFILTER_TYPE min;
|
|
69
|
+
DATAFILTER_TYPE softMin;
|
|
70
|
+
DATAFILTER_TYPE softMax;
|
|
71
|
+
DATAFILTER_TYPE max;
|
|
72
|
+
#ifdef DATAFILTER_DOUBLE
|
|
73
|
+
DATAFILTER_TYPE min64High;
|
|
74
|
+
DATAFILTER_TYPE max64High;
|
|
75
|
+
#endif
|
|
76
|
+
#endif
|
|
77
|
+
#ifdef DATACATEGORY_TYPE
|
|
78
|
+
highp uvec4 categoryBitMask;
|
|
79
|
+
#endif
|
|
80
|
+
} dataFilter;
|
|
81
|
+
`,xe=`
|
|
82
|
+
#ifdef DATAFILTER_TYPE
|
|
83
|
+
in DATAFILTER_TYPE filterValues;
|
|
84
|
+
#ifdef DATAFILTER_DOUBLE
|
|
85
|
+
in DATAFILTER_TYPE filterValues64Low;
|
|
86
|
+
#endif
|
|
87
|
+
#endif
|
|
88
|
+
|
|
89
|
+
#ifdef DATACATEGORY_TYPE
|
|
90
|
+
in DATACATEGORY_TYPE filterCategoryValues;
|
|
91
|
+
#endif
|
|
92
|
+
|
|
93
|
+
out float dataFilter_value;
|
|
94
|
+
|
|
95
|
+
float dataFilter_reduceValue(float value) {
|
|
96
|
+
return value;
|
|
97
|
+
}
|
|
98
|
+
float dataFilter_reduceValue(vec2 value) {
|
|
99
|
+
return min(value.x, value.y);
|
|
100
|
+
}
|
|
101
|
+
float dataFilter_reduceValue(vec3 value) {
|
|
102
|
+
return min(min(value.x, value.y), value.z);
|
|
103
|
+
}
|
|
104
|
+
float dataFilter_reduceValue(vec4 value) {
|
|
105
|
+
return min(min(value.x, value.y), min(value.z, value.w));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
#ifdef DATAFILTER_TYPE
|
|
109
|
+
void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax) {
|
|
110
|
+
if (dataFilter.useSoftMargin) {
|
|
111
|
+
// smoothstep results are undefined if edge0 ≥ edge1
|
|
112
|
+
// Fallback to ignore filterSoftRange if it is truncated by filterRange
|
|
113
|
+
DATAFILTER_TYPE leftInRange = mix(
|
|
114
|
+
smoothstep(dataFilter.min, dataFilter.softMin, valueFromMin),
|
|
115
|
+
step(dataFilter.min, valueFromMin),
|
|
116
|
+
step(dataFilter.softMin, dataFilter.min)
|
|
117
|
+
);
|
|
118
|
+
DATAFILTER_TYPE rightInRange = mix(
|
|
119
|
+
1.0 - smoothstep(dataFilter.softMax, dataFilter.max, valueFromMax),
|
|
120
|
+
step(valueFromMax, dataFilter.max),
|
|
121
|
+
step(dataFilter.max, dataFilter.softMax)
|
|
122
|
+
);
|
|
123
|
+
dataFilter_value = dataFilter_reduceValue(leftInRange * rightInRange);
|
|
124
|
+
} else {
|
|
125
|
+
dataFilter_value = dataFilter_reduceValue(
|
|
126
|
+
step(dataFilter.min, valueFromMin) * step(valueFromMax, dataFilter.max)
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
#endif
|
|
131
|
+
|
|
132
|
+
#ifdef DATACATEGORY_TYPE
|
|
133
|
+
void dataFilter_setCategoryValue(DATACATEGORY_TYPE category) {
|
|
134
|
+
#if DATACATEGORY_CHANNELS == 1 // One 128-bit mask
|
|
135
|
+
uint dataFilter_masks = dataFilter.categoryBitMask[category / 32u];
|
|
136
|
+
#elif DATACATEGORY_CHANNELS == 2 // Two 64-bit masks
|
|
137
|
+
uvec2 dataFilter_masks = uvec2(
|
|
138
|
+
dataFilter.categoryBitMask[category.x / 32u],
|
|
139
|
+
dataFilter.categoryBitMask[category.y / 32u + 2u]
|
|
140
|
+
);
|
|
141
|
+
#elif DATACATEGORY_CHANNELS == 3 // Three 32-bit masks
|
|
142
|
+
uvec3 dataFilter_masks = dataFilter.categoryBitMask.xyz;
|
|
143
|
+
#else // Four 32-bit masks
|
|
144
|
+
uvec4 dataFilter_masks = dataFilter.categoryBitMask;
|
|
145
|
+
#endif
|
|
146
|
+
|
|
147
|
+
// Shift mask and extract relevant bits
|
|
148
|
+
DATACATEGORY_TYPE dataFilter_bits = DATACATEGORY_TYPE(dataFilter_masks) >> (category & 31u);
|
|
149
|
+
dataFilter_bits &= 1u;
|
|
150
|
+
|
|
151
|
+
#if DATACATEGORY_CHANNELS == 1
|
|
152
|
+
if(dataFilter_bits == 0u) dataFilter_value = 0.0;
|
|
153
|
+
#else
|
|
154
|
+
if(any(equal(dataFilter_bits, DATACATEGORY_TYPE(0u)))) dataFilter_value = 0.0;
|
|
155
|
+
#endif
|
|
156
|
+
}
|
|
157
|
+
#endif
|
|
158
|
+
`,K=`
|
|
159
|
+
${W}
|
|
160
|
+
${xe}
|
|
161
|
+
`,Me=`
|
|
162
|
+
in float dataFilter_value;
|
|
163
|
+
`,Z=`
|
|
164
|
+
${W}
|
|
165
|
+
${Me}
|
|
166
|
+
`;function q(a){if(!a||!("extensions"in a))return{};const{filterRange:e=[-1,1],filterEnabled:t=!0,filterTransformSize:i=!0,filterTransformColor:s=!0,categoryBitMask:o}=a,r=a.filterSoftRange||e;return{...Number.isFinite(e[0])?{min:e[0],softMin:r[0],softMax:r[1],max:e[1]}:{min:e.map(n=>n[0]),softMin:r.map(n=>n[0]),softMax:r.map(n=>n[1]),max:e.map(n=>n[1])},enabled:t,useSoftMargin:!!a.filterSoftRange,transformSize:t&&i,transformColor:t&&s,...o&&{categoryBitMask:o}}}function Te(a){if(!a||!("extensions"in a))return{};const e=q(a);if(Number.isFinite(e.min)){const t=Math.fround(e.min);e.min-=t,e.softMin-=t,e.min64High=t;const i=Math.fround(e.max);e.max-=i,e.softMax-=i,e.max64High=i}else{const t=e.min.map(Math.fround);e.min=e.min.map((s,o)=>s-t[o]),e.softMin=e.softMin.map((s,o)=>s-t[o]),e.min64High=t;const i=e.max.map(Math.fround);e.max=e.max.map((s,o)=>s-i[o]),e.softMax=e.softMax.map((s,o)=>s-i[o]),e.max64High=i}return e}const X={"vs:#main-start":`
|
|
167
|
+
dataFilter_value = 1.0;
|
|
168
|
+
if (dataFilter.enabled) {
|
|
169
|
+
#ifdef DATAFILTER_TYPE
|
|
170
|
+
#ifdef DATAFILTER_DOUBLE
|
|
171
|
+
dataFilter_setValue(
|
|
172
|
+
filterValues - dataFilter.min64High + filterValues64Low,
|
|
173
|
+
filterValues - dataFilter.max64High + filterValues64Low
|
|
174
|
+
);
|
|
175
|
+
#else
|
|
176
|
+
dataFilter_setValue(filterValues, filterValues);
|
|
177
|
+
#endif
|
|
178
|
+
#endif
|
|
179
|
+
|
|
180
|
+
#ifdef DATACATEGORY_TYPE
|
|
181
|
+
dataFilter_setCategoryValue(filterCategoryValues);
|
|
182
|
+
#endif
|
|
183
|
+
}
|
|
184
|
+
`,"vs:#main-end":`
|
|
185
|
+
if (dataFilter_value == 0.0) {
|
|
186
|
+
gl_Position = vec4(0.);
|
|
187
|
+
}
|
|
188
|
+
`,"vs:DECKGL_FILTER_SIZE":`
|
|
189
|
+
if (dataFilter.transformSize) {
|
|
190
|
+
size = size * dataFilter_value;
|
|
191
|
+
}
|
|
192
|
+
`,"fs:DECKGL_FILTER_COLOR":`
|
|
193
|
+
if (dataFilter_value == 0.0) discard;
|
|
194
|
+
if (dataFilter.transformColor) {
|
|
195
|
+
color.a *= dataFilter_value;
|
|
196
|
+
}
|
|
197
|
+
`};function J(a){const{categorySize:e,filterSize:t,fp64:i}=a,s={useSoftMargin:"i32",enabled:"i32",transformSize:"i32",transformColor:"i32"};if(t){const o=t===1?"f32":`vec${t}<f32>`;s.min=o,s.softMin=o,s.softMax=o,s.max=o,i&&(s.min64High=o,s.max64High=o)}return e&&(s.categoryBitMask="vec4<i32>"),s}const Ce={name:"dataFilter",vs:K,fs:Z,inject:X,getUniforms:q,uniformTypesFromOptions:J},Ee={name:"dataFilter",vs:K,fs:Z,inject:X,getUniforms:Te,uniformTypesFromOptions:J},Fe=`#version 300 es
|
|
198
|
+
#define SHADER_NAME data-filter-vertex-shader
|
|
199
|
+
|
|
200
|
+
#ifdef FLOAT_TARGET
|
|
201
|
+
in float filterIndices;
|
|
202
|
+
in float filterPrevIndices;
|
|
203
|
+
#else
|
|
204
|
+
in vec2 filterIndices;
|
|
205
|
+
in vec2 filterPrevIndices;
|
|
206
|
+
#endif
|
|
207
|
+
|
|
208
|
+
out vec4 vColor;
|
|
209
|
+
const float component = 1.0 / 255.0;
|
|
210
|
+
|
|
211
|
+
void main() {
|
|
212
|
+
#ifdef FLOAT_TARGET
|
|
213
|
+
dataFilter_value *= float(filterIndices != filterPrevIndices);
|
|
214
|
+
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
|
|
215
|
+
vColor = vec4(0.0, 0.0, 0.0, 1.0);
|
|
216
|
+
#else
|
|
217
|
+
// Float texture is not supported: pack result into 4 channels x 256 px x 64px
|
|
218
|
+
dataFilter_value *= float(filterIndices.x != filterPrevIndices.x);
|
|
219
|
+
float col = filterIndices.x;
|
|
220
|
+
float row = filterIndices.y * 4.0;
|
|
221
|
+
float channel = floor(row);
|
|
222
|
+
row = fract(row);
|
|
223
|
+
vColor = component * vec4(bvec4(channel == 0.0, channel == 1.0, channel == 2.0, channel == 3.0));
|
|
224
|
+
gl_Position = vec4(col * 2.0 - 1.0, row * 2.0 - 1.0, 0.0, 1.0);
|
|
225
|
+
#endif
|
|
226
|
+
gl_PointSize = 1.0;
|
|
227
|
+
}
|
|
228
|
+
`,ke=`#version 300 es
|
|
229
|
+
#define SHADER_NAME data-filter-fragment-shader
|
|
230
|
+
precision highp float;
|
|
231
|
+
|
|
232
|
+
in vec4 vColor;
|
|
233
|
+
|
|
234
|
+
out vec4 fragColor;
|
|
235
|
+
|
|
236
|
+
void main() {
|
|
237
|
+
if (dataFilter_value < 0.5) {
|
|
238
|
+
discard;
|
|
239
|
+
}
|
|
240
|
+
fragColor = vColor;
|
|
241
|
+
}
|
|
242
|
+
`,Ae=["float32-renderable-webgl","texture-blend-float-webgl"];function we(a){return Ae.every(e=>a.features.has(e))}function Le(a,e){return e?a.createFramebuffer({width:1,height:1,colorAttachments:[a.createTexture({format:"rgba32float",dimension:"2d",width:1,height:1})]}):a.createFramebuffer({width:256,height:64,colorAttachments:[a.createTexture({format:"rgba8unorm",dimension:"2d",width:256,height:64})]})}function Se(a,e,t,i){return t.defines.NON_INSTANCED_MODEL=1,i&&(t.defines.FLOAT_TARGET=1),new ce(a,{id:"data-filter-aggregation-model",vertexCount:1,isInstanced:!1,topology:"point-list",disableWarnings:!0,vs:Fe,fs:ke,bufferLayout:e,...t})}const Re={blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendColorOperation:"add",blendAlphaOperation:"add",depthCompare:"never"},Oe={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},Be={categorySize:0,filterSize:1,fp64:!1,countItems:!1},De={1:"uint",2:"uvec2",3:"uvec3",4:"uvec4"},Ie={1:"float",2:"vec2",3:"vec3",4:"vec4"};class Q extends v{constructor(e={}){super({...Be,...e})}getShaders(e){const{categorySize:t,filterSize:i,fp64:s}=e.opts,o={};t&&(o.DATACATEGORY_TYPE=De[t],o.DATACATEGORY_CHANNELS=t),i&&(o.DATAFILTER_TYPE=Ie[i],o.DATAFILTER_DOUBLE=!!s);const r=s?Ee:Ce;return r.uniformTypes=r.uniformTypesFromOptions(e.opts),{modules:[r],defines:o}}initializeState(e,t){const i=this.getAttributeManager(),{categorySize:s,filterSize:o,fp64:r}=t.opts;i&&(o&&i.add({filterValues:{size:o,type:r?"float64":"float32",stepMode:"dynamic",accessor:"getFilterValue"}}),s&&i.add({filterCategoryValues:{size:s,stepMode:"dynamic",accessor:"getFilterCategory",type:"uint32",transform:s===1?l=>t._getCategoryKey.call(this,l,0):l=>l.map((d,f)=>t._getCategoryKey.call(this,d,f))}}));const{device:n}=this.context;if(i&&t.opts.countItems){const l=we(n);i.add({filterVertexIndices:{size:l?1:2,vertexOffset:1,type:"unorm8",accessor:(c,{index:u})=>{const p=c&&c.__source?c.__source.index:u;return l?(p+1)%255:[(p+1)%255,Math.floor(p/255)%255]},shaderAttributes:{filterPrevIndices:{vertexOffset:0},filterIndices:{vertexOffset:1}}}});const d=Le(n,l),f=Se(n,i.getBufferLayouts({isInstanced:!1}),t.getShaders.call(this,t),l);this.setState({filterFBO:d,filterModel:f})}}updateState({props:e,oldProps:t,changeFlags:i},s){const o=this.getAttributeManager(),{categorySize:r}=s.opts;if(this.state.filterModel){const n=o.attributes.filterValues?.needsUpdate()||o.attributes.filterCategoryValues?.needsUpdate()||e.filterEnabled!==t.filterEnabled||e.filterRange!==t.filterRange||e.filterSoftRange!==t.filterSoftRange||e.filterCategories!==t.filterCategories;n&&this.setState({filterNeedsUpdate:n})}o?.attributes.filterCategoryValues&&((o.attributes.filterCategoryValues.needsUpdate()||!U(e.filterCategories,t.filterCategories,2))&&this.setState({categoryBitMask:null}),i.dataChanged&&(this.setState({categoryMap:Array(r).fill(0).map(()=>({}))}),o.attributes.filterCategoryValues.setNeedsUpdate("categoryMap")))}draw(e,t){const i=this.state.filterFBO,s=this.state.filterModel,o=this.state.filterNeedsUpdate;this.state.categoryBitMask||t._updateCategoryBitMask.call(this,e,t);const{onFilteredItemsChange:r,extensions:n,filterEnabled:l,filterRange:d,filterSoftRange:f,filterTransformSize:c,filterTransformColor:u,filterCategories:p}=this.props,m={extensions:n,filterEnabled:l,filterRange:d,filterSoftRange:f,filterTransformSize:c,filterTransformColor:u,filterCategories:p};if(this.state.categoryBitMask&&(m.categoryBitMask=this.state.categoryBitMask),this.setShaderModuleProps({dataFilter:m}),o&&r&&s){const x=this.getAttributeManager(),{attributes:{filterValues:g,filterCategoryValues:y,filterVertexIndices:M}}=x;s.setVertexCount(this.getNumInstances());const T={...g?.getValue(),...y?.getValue(),...M?.getValue()};s.setAttributes(T),s.shaderInputs.setProps({dataFilter:m});const C=[0,0,i.width,i.height],O=s.device.beginRenderPass({id:"data-filter-aggregation",framebuffer:i,parameters:{viewport:C},clearColor:[0,0,0,0]});s.setParameters(Re),s.draw(O),O.end();const B=s.device.readPixelsToArrayWebGL(i);let D=0;for(let E=0;E<B.length;E++)D+=B[E];r({id:this.id,count:D}),this.state.filterNeedsUpdate=!1}}finalizeState(){const e=this.state.filterFBO,t=this.state.filterModel;e?.destroy(),t?.destroy()}_updateCategoryBitMask(e,t){const{categorySize:i}=t.opts;if(!i)return;const{filterCategories:s}=this.props,o=new Uint32Array([0,0,0,0]),r=i===1?[s]:s,n=i===1?128:i===2?64:32;for(let l=0;l<r.length;l++){const d=r[l];for(const f of d){const c=t._getCategoryKey.call(this,f,l);if(c<n){const u=l*(n/32)+Math.floor(c/32);o[u]+=Math.pow(2,c%32)}else P.warn(`Exceeded maximum number of categories (${n})`)()}}this.state.categoryBitMask=o}_getCategoryKey(e,t){const i=this.state.categoryMap[t];return e in i||(i[e]=Object.keys(i).length),i[e]}}Q.defaultProps=Oe;Q.extensionName="DataFilterExtension";const je=`const vec2 WORLD_SCALE_FP64 = vec2(81.4873275756836, 0.0000032873668232014097);
|
|
243
|
+
uniform project64Uniforms {
|
|
244
|
+
vec2 scale;
|
|
245
|
+
mat4 viewProjectionMatrix;
|
|
246
|
+
mat4 viewProjectionMatrix64Low;
|
|
247
|
+
} project64;
|
|
248
|
+
void mercatorProject_fp64(vec4 lnglat_fp64, out vec2 out_val[2]) {
|
|
249
|
+
#if defined(NVIDIA_FP64_WORKAROUND)
|
|
250
|
+
out_val[0] = sum_fp64(radians_fp64(lnglat_fp64.xy), PI_FP64 * ONE);
|
|
251
|
+
#else
|
|
252
|
+
out_val[0] = sum_fp64(radians_fp64(lnglat_fp64.xy), PI_FP64);
|
|
253
|
+
#endif
|
|
254
|
+
out_val[1] = sum_fp64(PI_FP64,
|
|
255
|
+
log_fp64(tan_fp64(sum_fp64(PI_4_FP64, radians_fp64(lnglat_fp64.zw) / 2.0))));
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
void project_position_fp64(vec4 position_fp64, out vec2 out_val[2]) {
|
|
259
|
+
vec2 pos_fp64[2];
|
|
260
|
+
mercatorProject_fp64(position_fp64, pos_fp64);
|
|
261
|
+
out_val[0] = mul_fp64(pos_fp64[0], WORLD_SCALE_FP64);
|
|
262
|
+
out_val[1] = mul_fp64(pos_fp64[1], WORLD_SCALE_FP64);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
void project_position_fp64(vec2 position, vec2 position64xyLow, out vec2 out_val[2]) {
|
|
266
|
+
vec4 position64xy = vec4(
|
|
267
|
+
position.x, position64xyLow.x,
|
|
268
|
+
position.y, position64xyLow.y);
|
|
269
|
+
project_position_fp64(position64xy, out_val);
|
|
270
|
+
}
|
|
271
|
+
vec4 project_common_position_to_clipspace_fp64(vec2 vertex_pos_modelspace[4]) {
|
|
272
|
+
vec2 vertex_pos_clipspace[4];
|
|
273
|
+
vec2 viewProjectionMatrixFP64[16];
|
|
274
|
+
for (int i = 0; i < 4; i++) {
|
|
275
|
+
for (int j = 0; j < 4; j++) {
|
|
276
|
+
viewProjectionMatrixFP64[4 * i + j] = vec2(
|
|
277
|
+
project64.viewProjectionMatrix[j][i],
|
|
278
|
+
project64.viewProjectionMatrix64Low[j][i]
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
mat4_vec4_mul_fp64(viewProjectionMatrixFP64, vertex_pos_modelspace,
|
|
283
|
+
vertex_pos_clipspace);
|
|
284
|
+
return vec4(
|
|
285
|
+
vertex_pos_clipspace[0].x,
|
|
286
|
+
vertex_pos_clipspace[1].x,
|
|
287
|
+
vertex_pos_clipspace[2].x,
|
|
288
|
+
vertex_pos_clipspace[3].x
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
vec4 project_position_to_clipspace(
|
|
292
|
+
vec3 position, vec3 position64xyLow, vec3 offset, out vec4 commonPosition
|
|
293
|
+
) {
|
|
294
|
+
vec2 offset64[4];
|
|
295
|
+
vec4_fp64(vec4(offset, 0.0), offset64);
|
|
296
|
+
float z = project_size(position.z);
|
|
297
|
+
vec2 projectedPosition64xy[2];
|
|
298
|
+
project_position_fp64(position.xy, position64xyLow.xy, projectedPosition64xy);
|
|
299
|
+
vec2 commonPosition64[4];
|
|
300
|
+
commonPosition64[0] = sum_fp64(offset64[0], projectedPosition64xy[0]);
|
|
301
|
+
commonPosition64[1] = sum_fp64(offset64[1], projectedPosition64xy[1]);
|
|
302
|
+
commonPosition64[2] = sum_fp64(offset64[2], vec2(z, 0.0));
|
|
303
|
+
commonPosition64[3] = vec2(1.0, 0.0);
|
|
304
|
+
commonPosition = vec4(projectedPosition64xy[0].x, projectedPosition64xy[1].x, z, 1.0);
|
|
305
|
+
return project_common_position_to_clipspace_fp64(commonPosition64);
|
|
306
|
+
}
|
|
307
|
+
vec4 project_position_to_clipspace(
|
|
308
|
+
vec3 position, vec3 position64xyLow, vec3 offset
|
|
309
|
+
) {
|
|
310
|
+
vec4 commonPosition;
|
|
311
|
+
return project_position_to_clipspace(
|
|
312
|
+
position, position64xyLow, offset, commonPosition
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
`,{fp64ify:Ve,fp64ifyMatrix4:ze}=G,Ne={name:"project64",dependencies:[_,G],vs:je,getUniforms:Ue,uniformTypes:{scale:"vec2<f32>",viewProjectionMatrix:"mat4x4<f32>",viewProjectionMatrix64Low:"mat4x4<f32>"}},Ge=le(He);function Ue(a){if(a&&"viewport"in a){const{viewProjectionMatrix:e,scale:t}=a.viewport;return Ge({viewProjectionMatrix:e,scale:t})}return{}}function He({viewProjectionMatrix:a,scale:e}){const t=ze(a),i=new Float32Array(16),s=new Float32Array(16);for(let o=0;o<4;o++)for(let r=0;r<4;r++){const n=4*o+r,l=4*r+o;i[l]=t[2*n],s[l]=t[2*n+1]}return{scale:Ve(e),viewProjectionMatrix:[...i],viewProjectionMatrix64Low:[...s]}}class Ye extends v{getShaders(){const{coordinateSystem:e}=this.props;if(e!==b.LNGLAT&&e!==b.DEFAULT)throw new Error("fp64: coordinateSystem must be LNGLAT");return{modules:[Ne]}}draw(e,t){const{viewport:i}=e.context;this.setShaderModuleProps({project64:{viewport:i}})}}Ye.extensionName="Fp64Extension";const $e={inject:{"vs:#decl":`
|
|
316
|
+
in vec2 instanceDashArrays;
|
|
317
|
+
in float instanceDashOffsets;
|
|
318
|
+
out vec2 vDashArray;
|
|
319
|
+
out float vDashOffset;
|
|
320
|
+
`,"vs:#main-end":`
|
|
321
|
+
vDashArray = instanceDashArrays;
|
|
322
|
+
vDashOffset = instanceDashOffsets / width.x;
|
|
323
|
+
`,"fs:#decl":`
|
|
324
|
+
uniform pathStyleUniforms {
|
|
325
|
+
float dashAlignMode;
|
|
326
|
+
bool dashGapPickable;
|
|
327
|
+
} pathStyle;
|
|
328
|
+
in vec2 vDashArray;
|
|
329
|
+
in float vDashOffset;
|
|
330
|
+
`,"fs:#main-start":`
|
|
331
|
+
float solidLength = vDashArray.x;
|
|
332
|
+
float gapLength = vDashArray.y;
|
|
333
|
+
float unitLength = solidLength + gapLength;
|
|
334
|
+
float offset;
|
|
335
|
+
if (unitLength > 0.0) {
|
|
336
|
+
if (pathStyle.dashAlignMode == 0.0) {
|
|
337
|
+
offset = vDashOffset;
|
|
338
|
+
} else {
|
|
339
|
+
unitLength = vPathLength / round(vPathLength / unitLength);
|
|
340
|
+
offset = solidLength / 2.0;
|
|
341
|
+
}
|
|
342
|
+
float unitOffset = mod(vPathPosition.y + offset, unitLength);
|
|
343
|
+
if (gapLength > 0.0 && unitOffset > solidLength) {
|
|
344
|
+
if (path.capType <= 0.5) {
|
|
345
|
+
if (!(pathStyle.dashGapPickable && bool(picking.isActive))) {
|
|
346
|
+
discard;
|
|
347
|
+
}
|
|
348
|
+
} else {
|
|
349
|
+
float distToEnd = length(vec2(
|
|
350
|
+
min(unitOffset - solidLength, unitLength - unitOffset),
|
|
351
|
+
vPathPosition.x
|
|
352
|
+
));
|
|
353
|
+
if (distToEnd > 1.0) {
|
|
354
|
+
if (!(pathStyle.dashGapPickable && bool(picking.isActive))) {
|
|
355
|
+
discard;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
`}},We={inject:{"vs:#decl":`
|
|
362
|
+
in float instanceOffsets;
|
|
363
|
+
`,"vs:DECKGL_FILTER_SIZE":`
|
|
364
|
+
float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;
|
|
365
|
+
size *= offsetWidth;
|
|
366
|
+
`,"vs:#main-end":`
|
|
367
|
+
float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;
|
|
368
|
+
float offsetDir = sign(instanceOffsets);
|
|
369
|
+
vPathPosition.x = (vPathPosition.x + offsetDir) * offsetWidth - offsetDir;
|
|
370
|
+
vPathPosition.y *= offsetWidth;
|
|
371
|
+
vPathLength *= offsetWidth;
|
|
372
|
+
`,"fs:#main-start":`
|
|
373
|
+
float isInside;
|
|
374
|
+
isInside = step(-1.0, vPathPosition.x) * step(vPathPosition.x, 1.0);
|
|
375
|
+
if (isInside == 0.0) {
|
|
376
|
+
discard;
|
|
377
|
+
}
|
|
378
|
+
`}},Ke={getDashArray:{type:"accessor",value:[0,0]},getOffset:{type:"accessor",value:0},dashJustified:!1,dashGapPickable:!1};class ee extends v{constructor({dash:e=!1,offset:t=!1,highPrecisionDash:i=!1}={}){super({dash:e||i,offset:t,highPrecisionDash:i})}isEnabled(e){return"pathTesselator"in e.state}getShaders(e){if(!e.isEnabled(this))return null;let t={};e.opts.dash&&(t=I(t,$e)),e.opts.offset&&(t=I(t,We));const{inject:i}=t;return{modules:[{name:"pathStyle",inject:i,uniformTypes:{dashAlignMode:"f32",dashGapPickable:"i32"}}]}}initializeState(e,t){const i=this.getAttributeManager();!i||!t.isEnabled(this)||(t.opts.dash&&i.addInstanced({instanceDashArrays:{size:2,accessor:"getDashArray"},instanceDashOffsets:t.opts.highPrecisionDash?{size:1,accessor:"getPath",transform:t.getDashOffsets.bind(this)}:{size:1,update:s=>{s.constant=!0,s.value=[0]}}}),t.opts.offset&&i.addInstanced({instanceOffsets:{size:1,accessor:"getOffset"}}))}updateState(e,t){if(t.isEnabled(this)&&t.opts.dash){const i={dashAlignMode:this.props.dashJustified?1:0,dashGapPickable:!!this.props.dashGapPickable};this.setShaderModuleProps({pathStyle:i})}}getDashOffsets(e){const t=[0],i=this.props.positionFormat==="XY"?2:3,s=Array.isArray(e[0]),o=s?e.length:e.length/i;let r,n;for(let l=0;l<o-1;l++)r=s?e[l]:e.slice(l*i,l*i+i),r=this.projectPosition(r),l>0&&(t[l]=t[l-1]+de(n,r)),n=r;return t[o-1]=0,t}}ee.defaultProps=Ke;ee.extensionName="PathStyleExtension";const te=`uniform fillUniforms {
|
|
379
|
+
vec2 patternTextureSize;
|
|
380
|
+
bool patternEnabled;
|
|
381
|
+
bool patternMask;
|
|
382
|
+
vec2 uvCoordinateOrigin;
|
|
383
|
+
vec2 uvCoordinateOrigin64Low;
|
|
384
|
+
} fill;
|
|
385
|
+
`,Ze=`
|
|
386
|
+
in vec4 fillPatternFrames;
|
|
387
|
+
in float fillPatternScales;
|
|
388
|
+
in vec2 fillPatternOffsets;
|
|
389
|
+
|
|
390
|
+
out vec2 fill_uv;
|
|
391
|
+
out vec4 fill_patternBounds;
|
|
392
|
+
out vec4 fill_patternPlacement;
|
|
393
|
+
`,qe=`
|
|
394
|
+
${te}
|
|
395
|
+
${Ze}
|
|
396
|
+
`,Xe=`
|
|
397
|
+
uniform sampler2D fill_patternTexture;
|
|
398
|
+
|
|
399
|
+
in vec4 fill_patternBounds;
|
|
400
|
+
in vec4 fill_patternPlacement;
|
|
401
|
+
in vec2 fill_uv;
|
|
402
|
+
|
|
403
|
+
const float FILL_UV_SCALE = 512.0 / 40000000.0;
|
|
404
|
+
`,Je=`
|
|
405
|
+
${te}
|
|
406
|
+
${Xe}
|
|
407
|
+
`,Qe={"vs:DECKGL_FILTER_GL_POSITION":`
|
|
408
|
+
fill_uv = geometry.position.xy;
|
|
409
|
+
`,"vs:DECKGL_FILTER_COLOR":`
|
|
410
|
+
if (fill.patternEnabled) {
|
|
411
|
+
fill_patternBounds = fillPatternFrames / vec4(fill.patternTextureSize, fill.patternTextureSize);
|
|
412
|
+
fill_patternPlacement.xy = fillPatternOffsets;
|
|
413
|
+
fill_patternPlacement.zw = fillPatternScales * fillPatternFrames.zw;
|
|
414
|
+
}
|
|
415
|
+
`,"fs:DECKGL_FILTER_COLOR":`
|
|
416
|
+
if (fill.patternEnabled) {
|
|
417
|
+
vec2 scale = FILL_UV_SCALE * fill_patternPlacement.zw;
|
|
418
|
+
vec2 patternUV = mod(mod(fill.uvCoordinateOrigin, scale) + fill.uvCoordinateOrigin64Low + fill_uv, scale) / scale;
|
|
419
|
+
patternUV = mod(fill_patternPlacement.xy + patternUV, 1.0);
|
|
420
|
+
|
|
421
|
+
vec2 texCoords = fill_patternBounds.xy + fill_patternBounds.zw * patternUV;
|
|
422
|
+
|
|
423
|
+
vec4 patternColor = texture(fill_patternTexture, texCoords);
|
|
424
|
+
color.a *= patternColor.a;
|
|
425
|
+
if (!fill.patternMask) {
|
|
426
|
+
color.rgb = patternColor.rgb;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
`};function et(a){if(!a)return{};const e={};if("fillPatternTexture"in a){const{fillPatternTexture:t}=a;e.fill_patternTexture=t,e.patternTextureSize=[t.width,t.height]}if("project"in a){const{fillPatternMask:t=!0,fillPatternEnabled:i=!0}=a,s=_.getUniforms(a.project),{commonOrigin:o}=s,r=[j(o[0]),j(o[1])];e.uvCoordinateOrigin=o.slice(0,2),e.uvCoordinateOrigin64Low=r,e.patternMask=t,e.patternEnabled=i}return e}const tt={name:"fill",vs:qe,fs:Je,inject:Qe,dependencies:[_],getUniforms:et,uniformTypes:{patternTextureSize:"vec2<f32>",patternEnabled:"i32",patternMask:"i32",uvCoordinateOrigin:"vec2<f32>",uvCoordinateOrigin64Low:"vec2<f32>"}},it={fillPatternEnabled:!0,fillPatternAtlas:{type:"image",value:null,async:!0,parameters:{lodMaxClamp:0}},fillPatternMapping:{type:"object",value:{},async:!0},fillPatternMask:!0,getFillPattern:{type:"accessor",value:a=>a.pattern},getFillPatternScale:{type:"accessor",value:1},getFillPatternOffset:{type:"accessor",value:[0,0]}};class ie extends v{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&&tt].filter(Boolean)}:null}initializeState(e,t){if(!t.isEnabled(this))return;const i=this.getAttributeManager();t.opts.pattern&&i.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},i){i.isEnabled(this)&&e.fillPatternMapping&&e.fillPatternMapping!==t.fillPatternMapping&&this.getAttributeManager().invalidate("getFillPattern")}draw(e,t){if(!t.isEnabled(this))return;const{fillPatternAtlas:i,fillPatternEnabled:s,fillPatternMask:o}=this.props,r={project:e.shaderModuleProps.project,fillPatternEnabled:s,fillPatternMask:o,fillPatternTexture:i||this.state.emptyTexture};this.setShaderModuleProps({fill:r})}finalizeState(){this.state.emptyTexture?.delete()}getPatternFrame(e){const{fillPatternMapping:t}=this.getCurrentLayer().props,i=t&&t[e];return i?[i.x,i.y,i.width,i.height]:[0,0,0,0]}}ie.defaultProps=it;ie.extensionName="FillStyleExtension";const st=`
|
|
430
|
+
in float collisionPriorities;
|
|
431
|
+
|
|
432
|
+
uniform sampler2D collision_texture;
|
|
433
|
+
|
|
434
|
+
uniform collisionUniforms {
|
|
435
|
+
bool sort;
|
|
436
|
+
bool enabled;
|
|
437
|
+
} collision;
|
|
438
|
+
|
|
439
|
+
vec2 collision_getCoords(vec4 position) {
|
|
440
|
+
vec4 collision_clipspace = project_common_position_to_clipspace(position);
|
|
441
|
+
return (1.0 + collision_clipspace.xy / collision_clipspace.w) / 2.0;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
float collision_match(vec2 tex, vec3 pickingColor) {
|
|
445
|
+
vec4 collision_pickingColor = texture(collision_texture, tex);
|
|
446
|
+
float delta = dot(abs(collision_pickingColor.rgb - pickingColor), vec3(1.0));
|
|
447
|
+
float e = 0.001;
|
|
448
|
+
return step(delta, e);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
|
|
452
|
+
if (!collision.enabled) {
|
|
453
|
+
return 1.0;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// Visibility test, sample area of 5x5 pixels in order to fade in/out.
|
|
457
|
+
// Due to the locality, the lookups will be cached
|
|
458
|
+
// This reduces the flicker present when objects are shown/hidden
|
|
459
|
+
const int N = 2;
|
|
460
|
+
float accumulator = 0.0;
|
|
461
|
+
vec2 step = vec2(1.0 / project.viewportSize);
|
|
462
|
+
|
|
463
|
+
const float floatN = float(N);
|
|
464
|
+
vec2 delta = -floatN * step;
|
|
465
|
+
for(int i = -N; i <= N; i++) {
|
|
466
|
+
delta.x = -step.x * floatN;
|
|
467
|
+
for(int j = -N; j <= N; j++) {
|
|
468
|
+
accumulator += collision_match(texCoords + delta, pickingColor);
|
|
469
|
+
delta.x += step.x;
|
|
470
|
+
}
|
|
471
|
+
delta.y += step.y;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
float W = 2.0 * floatN + 1.0;
|
|
475
|
+
return pow(accumulator / (W * W), 2.2);
|
|
476
|
+
}
|
|
477
|
+
`,ot={"vs:#decl":`
|
|
478
|
+
float collision_fade = 1.0;
|
|
479
|
+
`,"vs:DECKGL_FILTER_GL_POSITION":`
|
|
480
|
+
if (collision.sort) {
|
|
481
|
+
float collisionPriority = collisionPriorities;
|
|
482
|
+
position.z = -0.001 * collisionPriority * position.w; // Support range -1000 -> 1000
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
if (collision.enabled) {
|
|
486
|
+
vec4 collision_common_position = project_position(vec4(geometry.worldPosition, 1.0));
|
|
487
|
+
vec2 collision_texCoords = collision_getCoords(collision_common_position);
|
|
488
|
+
collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);
|
|
489
|
+
if (collision_fade < 0.0001) {
|
|
490
|
+
// Position outside clip space bounds to discard
|
|
491
|
+
position = vec4(0.0, 0.0, 2.0, 1.0);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
`,"vs:DECKGL_FILTER_COLOR":`
|
|
495
|
+
color.a *= collision_fade;
|
|
496
|
+
`},rt=a=>{if(!a||!("dummyCollisionMap"in a))return{};const{enabled:e,collisionFBO:t,drawToCollisionMap:i,dummyCollisionMap:s}=a;return{enabled:e&&!i,sort:!!i,collision_texture:!i&&t?t.colorAttachments[0]:s}},at={name:"collision",dependencies:[_],vs:st,inject:ot,getUniforms:rt,uniformTypes:{sort:"i32",enabled:"i32"}};class nt extends w{renderCollisionMap(e,t){const s=[0,0,0,0],o=[1,1,e.width-2,e.height-2];this.render({...t,clearColor:s,scissorRect:o,target:e,pass:"collision"})}getLayerParameters(e,t,i){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}getShaderModuleProps(){return{collision:{drawToCollisionMap:!0},picking:{isActive:1,isAttribute:!1},lighting:{enabled:!1}}}}const F=2;class lt{constructor(){this.id="collision-filter-effect",this.props=null,this.useInPicking=!0,this.order=1,this.channels={},this.collisionFBOs={}}setup(e){this.context=e;const{device:t}=e;this.dummyCollisionMap=t.createTexture({width:1,height:1}),this.collisionFilterPass=new nt(t,{id:"default-collision-filter"})}preRender({effects:e,layers:t,layerFilter:i,viewports:s,onViewportActive:o,views:r,isPicking:n,preRenderStats:l={}}){const{device:d}=this.context;if(n)return;const f=t.filter(({props:{visible:g,collisionEnabled:y}})=>g&&y);if(f.length===0){this.channels={};return}const c=e?.filter(g=>g.useInPicking&&l[g.id]),u=l["mask-effect"]?.didRender,p=this._groupByCollisionGroup(d,f),m=s[0],x=!this.lastViewport||!this.lastViewport.equals(m)||u;for(const g in p){const y=this.collisionFBOs[g],M=p[g],[T,C]=d.canvasContext.getPixelSize();y.resize({width:T/F,height:C/F}),this._render(M,{effects:c,layerFilter:i,onViewportActive:o,views:r,viewport:m,viewportChanged:x})}}_render(e,{effects:t,layerFilter:i,onViewportActive:s,views:o,viewport:r,viewportChanged:n}){const{collisionGroup:l}=e,d=this.channels[l];if(!d)return;const f=n||e===d||!U(d.layers,e.layers,1)||e.layerBounds.some((c,u)=>!H(c,d.layerBounds[u]))||e.allLayersLoaded!==d.allLayersLoaded||e.layers.some(c=>c.props.transitions);if(this.channels[l]=e,f){this.lastViewport=r;const c=this.collisionFBOs[l];this.collisionFilterPass.renderCollisionMap(c,{pass:"collision-filter",isPicking:!0,layers:e.layers,effects:t,layerFilter:i,viewports:r?[r]:[],onViewportActive:s,views:o,shaderModuleProps:{collision:{enabled:!0,dummyCollisionMap:this.dummyCollisionMap},project:{devicePixelRatio:c.device.canvasContext.getDevicePixelRatio()/F}}})}}_groupByCollisionGroup(e,t){const i={};for(const s of t){const o=s.props.collisionGroup;let r=i[o];r||(r={collisionGroup:o,layers:[],layerBounds:[],allLayersLoaded:!0},i[o]=r),r.layers.push(s),r.layerBounds.push(s.getBounds()),s.isLoaded||(r.allLayersLoaded=!1)}for(const s of Object.keys(i))this.collisionFBOs[s]||this.createFBO(e,s),this.channels[s]||(this.channels[s]=i[s]);for(const s of Object.keys(this.collisionFBOs))i[s]||this.destroyFBO(s);return i}getShaderModuleProps(e){const{collisionGroup:t,collisionEnabled:i}=e.props,{collisionFBOs:s,dummyCollisionMap:o}=this,r=s[t];return{collision:{enabled:i&&!!r,collisionFBO:r,dummyCollisionMap:o}}}cleanup(){this.dummyCollisionMap&&(this.dummyCollisionMap.delete(),this.dummyCollisionMap=void 0),this.channels={};for(const e of Object.keys(this.collisionFBOs))this.destroyFBO(e);this.collisionFBOs={},this.lastViewport=void 0}createFBO(e,t){const{width:i,height:s}=e.getDefaultCanvasContext().canvas,o=e.createTexture({format:"rgba8unorm",width:i,height:s,sampler:{minFilter:"nearest",magFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),r=e.createTexture({format:"depth16unorm",width:i,height:s});this.collisionFBOs[t]=e.createFramebuffer({id:`collision-${t}`,width:i,height:s,colorAttachments:[o],depthStencilAttachment:r})}destroyFBO(e){const t=this.collisionFBOs[e];t.colorAttachments[0]?.destroy(),t.depthStencilAttachment?.destroy(),t.destroy(),delete this.collisionFBOs[e]}}const ct={getCollisionPriority:{type:"accessor",value:0},collisionEnabled:!0,collisionGroup:{type:"string",value:"default"},collisionTestProps:{}};class se extends v{getShaders(){return{modules:[at]}}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 lt),this.getAttributeManager().add({collisionPriorities:{size:1,stepMode:"dynamic",accessor:"getCollisionPriority"}})}getNeedsPickingBuffer(){return this.props.collisionEnabled}}se.defaultProps=ct;se.extensionName="CollisionFilterExtension";const oe=`uniform maskUniforms {
|
|
497
|
+
vec4 bounds;
|
|
498
|
+
highp int channel;
|
|
499
|
+
bool enabled;
|
|
500
|
+
bool inverted;
|
|
501
|
+
bool maskByInstance;
|
|
502
|
+
} mask;
|
|
503
|
+
`,dt=`
|
|
504
|
+
vec2 mask_getCoords(vec4 position) {
|
|
505
|
+
return (position.xy - mask.bounds.xy) / (mask.bounds.zw - mask.bounds.xy);
|
|
506
|
+
}
|
|
507
|
+
`,ft=`
|
|
508
|
+
${oe}
|
|
509
|
+
${dt}
|
|
510
|
+
`,ut=`
|
|
511
|
+
uniform sampler2D mask_texture;
|
|
512
|
+
|
|
513
|
+
bool mask_isInBounds(vec2 texCoords) {
|
|
514
|
+
if (!mask.enabled) {
|
|
515
|
+
return true;
|
|
516
|
+
}
|
|
517
|
+
vec4 maskColor = texture(mask_texture, texCoords);
|
|
518
|
+
float maskValue = 1.0;
|
|
519
|
+
if (mask.channel == 0) {
|
|
520
|
+
maskValue = maskColor.r;
|
|
521
|
+
} else if (mask.channel == 1) {
|
|
522
|
+
maskValue = maskColor.g;
|
|
523
|
+
} else if (mask.channel == 2) {
|
|
524
|
+
maskValue = maskColor.b;
|
|
525
|
+
} else if (mask.channel == 3) {
|
|
526
|
+
maskValue = maskColor.a;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
if (mask.inverted) {
|
|
530
|
+
return maskValue >= 0.5;
|
|
531
|
+
} else {
|
|
532
|
+
return maskValue < 0.5;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
`,pt=`
|
|
536
|
+
${oe}
|
|
537
|
+
${ut}
|
|
538
|
+
`,ht={"vs:#decl":`
|
|
539
|
+
out vec2 mask_texCoords;
|
|
540
|
+
`,"vs:#main-end":`
|
|
541
|
+
vec4 mask_common_position;
|
|
542
|
+
if (mask.maskByInstance) {
|
|
543
|
+
mask_common_position = project_position(vec4(geometry.worldPosition, 1.0));
|
|
544
|
+
} else {
|
|
545
|
+
mask_common_position = geometry.position;
|
|
546
|
+
}
|
|
547
|
+
mask_texCoords = mask_getCoords(mask_common_position);
|
|
548
|
+
`,"fs:#decl":`
|
|
549
|
+
in vec2 mask_texCoords;
|
|
550
|
+
`,"fs:#main-start":`
|
|
551
|
+
if (mask.enabled) {
|
|
552
|
+
bool mask = mask_isInBounds(mask_texCoords);
|
|
553
|
+
|
|
554
|
+
// Debug: show extent of render target
|
|
555
|
+
// fragColor = vec4(mask_texCoords, 0.0, 1.0);
|
|
556
|
+
// fragColor = texture(mask_texture, mask_texCoords);
|
|
557
|
+
|
|
558
|
+
if (!mask) discard;
|
|
559
|
+
}
|
|
560
|
+
`},mt=a=>a&&"maskMap"in a?{mask_texture:a.maskMap}:a||{},gt={name:"mask",dependencies:[_],vs:ft,fs:pt,inject:ht,getUniforms:mt,uniformTypes:{bounds:"vec4<f32>",channel:"i32",enabled:"i32",inverted:"i32",maskByInstance:"i32"}},_t={blendColorOperation:"subtract",blendColorSrcFactor:"zero",blendColorDstFactor:"one",blendAlphaOperation:"subtract",blendAlphaSrcFactor:"zero",blendAlphaDstFactor:"one"};class vt extends w{constructor(e,t){super(e,t);const{mapSize:i=2048}=t;this.maskMap=e.createTexture({format:"rgba8unorm",width:i,height:i,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),this.fbo=e.createFramebuffer({id:"maskmap",width:i,height:i,colorAttachments:[this.maskMap]})}render(e){const t=2**e.channel,i=[255,255,255,255];super.render({...e,clearColor:i,colorMask:t,target:this.fbo,pass:"mask"})}getLayerParameters(e,t,i){return{...e.props.parameters,blend:!0,depthCompare:"always",..._t}}shouldDrawLayer(e){return e.props.operation.includes("mask")}delete(){this.fbo.delete(),this.maskMap.delete()}}function L(a,e){const t=[1/0,1/0,-1/0,-1/0];for(const i of a){const s=i.getBounds();if(s){const o=i.projectPosition(s[0],{viewport:e,autoOffset:!1}),r=i.projectPosition(s[1],{viewport:e,autoOffset:!1});t[0]=Math.min(t[0],o[0]),t[1]=Math.min(t[1],o[1]),t[2]=Math.max(t[2],r[0]),t[3]=Math.max(t[3],r[1])}}return Number.isFinite(t[0])?t:null}const yt=2048;function S(a){const{bounds:e,viewport:t,border:i=0}=a,{isGeospatial:s}=t;if(e[2]<=e[0]||e[3]<=e[1])return null;const o=t.unprojectPosition([(e[0]+e[2])/2,(e[1]+e[3])/2,0]);let{width:r,height:n,zoom:l}=a;if(l===void 0){r=r-i*2,n=n-i*2;const d=Math.min(r/(e[2]-e[0]),n/(e[3]-e[1]));l=Math.min(Math.log2(d),20)}else if(!r||!n){const d=2**l;r=Math.round(Math.abs(e[2]-e[0])*d),n=Math.round(Math.abs(e[3]-e[1])*d);const f=yt-i*2;if(r>f||n>f){const c=f/Math.max(r,n);r=Math.round(r*c),n=Math.round(n*c),l+=Math.log2(c)}}return s?new fe({id:t.id,x:i,y:i,width:r,height:n,longitude:o[0],latitude:o[1],zoom:l,orthographic:!0}):new pe({id:t.id,x:i,y:i,width:r,height:n,target:o,zoom:l,flipY:!1})}function bt(a,e){let t;t=a.getBounds();const i=a.projectPosition(t.slice(0,2)),s=a.projectPosition(t.slice(2,4));return[i[0],i[1],s[0],s[1]]}function R(a,e,t){if(!a)return[0,0,1,1];const i=bt(e),s=Pt(i);return a[2]-a[0]<=s[2]-s[0]&&a[3]-a[1]<=s[3]-s[1]?a:[Math.max(a[0],s[0]),Math.max(a[1],s[1]),Math.min(a[2],s[2]),Math.min(a[3],s[3])]}function Pt(a){const e=a[2]-a[0],t=a[3]-a[1],i=(a[0]+a[2])/2,s=(a[1]+a[3])/2;return[i-e,s-t,i+e,s+t]}class xt{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 vt(e,{id:"default-mask"}),this.maskMap=this.maskPass.maskMap}preRender({layers:e,layerFilter:t,viewports:i,onViewportActive:s,views:o,isPicking:r}){let n=!1;if(r)return{didRender:n};const l=e.filter(u=>u.props.visible&&u.props.operation.includes("mask"));if(l.length===0)return this.masks=null,this.channels.length=0,{didRender:n};this.masks={};const d=this._sortMaskChannels(l),f=i[0],c=!this.lastViewport||!this.lastViewport.equals(f);if(f.resolution!==void 0)return P.warn("MaskExtension is not supported in GlobeView")(),{didRender:n};for(const u in d){const p=this._renderChannel(d[u],{layerFilter:t,onViewportActive:s,views:o,viewport:f,viewportChanged:c});n||(n=p)}return{didRender:n}}_renderChannel(e,{layerFilter:t,onViewportActive:i,views:s,viewport:o,viewportChanged:r}){let n=!1;const l=this.channels[e.index];if(!l)return n;const d=e===l||e.layers.length!==l.layers.length||e.layers.some((f,c)=>f!==l.layers[c]||f.props.transitions)||e.layerBounds.some((f,c)=>f!==l.layerBounds[c]);if(e.bounds=l.bounds,e.maskBounds=l.maskBounds,this.channels[e.index]=e,d||r){this.lastViewport=o;const f=L(e.layers,o);if(e.bounds=f&&R(f,o),d||!H(e.bounds,l.bounds)){const{maskPass:c,maskMap:u}=this,p=f&&S({bounds:e.bounds,viewport:o,width:u.width,height:u.height,border:1});e.maskBounds=p?p.getBounds():[0,0,1,1],c.render({pass:"mask",channel:e.index,layers:e.layers,layerFilter:t,viewports:p?[p]:[],onViewportActive:i,views:s,shaderModuleProps:{project:{devicePixelRatio:1}}}),n=!0}}return this.masks[e.id]={index:e.index,bounds:e.maskBounds,coordinateOrigin:e.coordinateOrigin,coordinateSystem:e.coordinateSystem},n}_sortMaskChannels(e){const t={};let i=0;for(const s of e){const{id:o}=s.root;let r=t[o];if(!r){if(++i>4){P.warn("Too many mask layers. The max supported is 4")();continue}r={id:o,index:this.channels.findIndex(n=>n?.id===o),layers:[],layerBounds:[],coordinateOrigin:s.root.props.coordinateOrigin,coordinateSystem:s.root.props.coordinateSystem},t[o]=r}r.layers.push(s),r.layerBounds.push(s.getBounds())}for(let s=0;s<4;s++){const o=this.channels[s];(!o||!(o.id in t))&&(this.channels[s]=null)}for(const s in t){const o=t[s];o.index<0&&(o.index=this.channels.findIndex(r=>!r),this.channels[o.index]=o)}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}}const Mt={maskId:"",maskByInstance:void 0,maskInverted:!1};class re extends v{initializeState(){this.context.deck?._addDefaultEffect(new xt)}getShaders(){let e="instancePositions"in this.getAttributeManager().attributes;return this.props.maskByInstance!==void 0&&(e=!!this.props.maskByInstance),this.state.maskByInstance=e,{modules:[gt]}}draw({context:e,shaderModuleProps:t}){const i={};i.maskByInstance=!!this.state.maskByInstance;const{maskId:s,maskInverted:o}=this.props,{maskChannels:r}=t.mask||{},{viewport:n}=e;if(r&&r[s]){const{index:l,bounds:d,coordinateOrigin:f}=r[s];let{coordinateSystem:c}=r[s];i.enabled=!0,i.channel=l,i.inverted=o,c===b.DEFAULT&&(c=n.isGeospatial?b.LNGLAT:b.CARTESIAN);const u={modelMatrix:null,fromCoordinateOrigin:f,fromCoordinateSystem:c},p=this.projectPosition([d[0],d[1],0],u),m=this.projectPosition([d[2],d[3],0],u);i.bounds=[p[0],p[1],m[0],m[1]]}else s&&P.warn(`Could not find a mask layer with id: ${s}`)(),i.enabled=!1;this.setShaderModuleProps({mask:i})}}re.defaultProps=Mt;re.extensionName="MaskExtension";const h={NONE:0,WRITE_HEIGHT_MAP:1,USE_HEIGHT_MAP:2,USE_COVER:3,USE_COVER_ONLY:4,SKIP:5},Tt=Object.keys(h).map(a=>`const float TERRAIN_MODE_${a} = ${h[a]}.0;`).join(`
|
|
561
|
+
`),V=Tt+`
|
|
562
|
+
uniform terrainUniforms {
|
|
563
|
+
float mode;
|
|
564
|
+
vec4 bounds;
|
|
565
|
+
} terrain;
|
|
566
|
+
|
|
567
|
+
uniform sampler2D terrain_map;
|
|
568
|
+
`,k={name:"terrain",dependencies:[_],vs:V+"out vec3 commonPos;",fs:V+"in vec3 commonPos;",inject:{"vs:#main-start":`
|
|
569
|
+
if (terrain.mode == TERRAIN_MODE_SKIP) {
|
|
570
|
+
gl_Position = vec4(0.0);
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
`,"vs:DECKGL_FILTER_GL_POSITION":`
|
|
574
|
+
commonPos = geometry.position.xyz;
|
|
575
|
+
if (terrain.mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
|
|
576
|
+
vec2 texCoords = (commonPos.xy - terrain.bounds.xy) / terrain.bounds.zw;
|
|
577
|
+
position = vec4(texCoords * 2.0 - 1.0, 0.0, 1.0);
|
|
578
|
+
commonPos.z += project.commonOrigin.z;
|
|
579
|
+
}
|
|
580
|
+
if (terrain.mode == TERRAIN_MODE_USE_HEIGHT_MAP) {
|
|
581
|
+
vec3 anchor = geometry.worldPosition;
|
|
582
|
+
anchor.z = 0.0;
|
|
583
|
+
vec3 anchorCommon = project_position(anchor);
|
|
584
|
+
vec2 texCoords = (anchorCommon.xy - terrain.bounds.xy) / terrain.bounds.zw;
|
|
585
|
+
if (texCoords.x >= 0.0 && texCoords.y >= 0.0 && texCoords.x <= 1.0 && texCoords.y <= 1.0) {
|
|
586
|
+
float terrainZ = texture(terrain_map, texCoords).r;
|
|
587
|
+
geometry.position.z += terrainZ;
|
|
588
|
+
position = project_common_position_to_clipspace(geometry.position);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
`,"fs:#main-start":`
|
|
592
|
+
if (terrain.mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
|
|
593
|
+
fragColor = vec4(commonPos.z, 0.0, 0.0, 1.0);
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
`,"fs:DECKGL_FILTER_COLOR":`
|
|
597
|
+
if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_USE_COVER_ONLY)) {
|
|
598
|
+
vec2 texCoords = (commonPos.xy - terrain.bounds.xy) / terrain.bounds.zw;
|
|
599
|
+
vec4 pixel = texture(terrain_map, texCoords);
|
|
600
|
+
if (terrain.mode == TERRAIN_MODE_USE_COVER_ONLY) {
|
|
601
|
+
color = pixel;
|
|
602
|
+
} else {
|
|
603
|
+
// pixel is premultiplied
|
|
604
|
+
color = pixel + color * (1.0 - pixel.a);
|
|
605
|
+
}
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
`},getUniforms:(a={})=>{if("dummyHeightMap"in a){const{drawToTerrainHeightMap:e,heightMap:t,heightMapBounds:i,dummyHeightMap:s,terrainCover:o,useTerrainHeightMap:r,terrainSkipRender:n}=a,l=_.getUniforms(a.project),{commonOrigin:d}=l;let f=n?h.SKIP:h.NONE,c=s,u=null;return e?(f=h.WRITE_HEIGHT_MAP,u=i):r&&t?(f=h.USE_HEIGHT_MAP,c=t,u=i):o&&(c=(a.isPicking?o.getPickingFramebuffer():o.getRenderFramebuffer())?.colorAttachments[0].texture,a.isPicking&&(f=h.SKIP),c?(f=f===h.SKIP?h.USE_COVER_ONLY:h.USE_COVER,u=o.bounds):c=s),{mode:f,terrain_map:c,bounds:u?[u[0]-d[0],u[1]-d[1],u[2]-u[0],u[3]-u[1]]:[0,0,0,0]}}return{}},uniformTypes:{mode:"f32",bounds:"vec4<f32>"}};function A(a,e){return a.createFramebuffer({id:e.id,colorAttachments:[a.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"}})]})}class Ct{constructor(e){this.isDirty=!0,this.renderViewport=null,this.bounds=null,this.layers=[],this.targetBounds=null,this.targetBoundsCommon=null,this.targetLayer=e,this.tile=ae(e)}get id(){return this.targetLayer.id}get isActive(){return!!this.targetLayer.getCurrentLayer()}shouldUpdate({targetLayer:e,viewport:t,layers:i,layerNeedsRedraw:s}){e&&(this.targetLayer=e);const o=t?this._updateViewport(t):!1;let r=i?this._updateLayers(i):!1;if(s){for(const n of this.layers)if(s[n]){r=!0;break}}return r||o}_updateLayers(e){let t=!1;if(e=this.tile?Et(this.tile,e):e,e.length!==this.layers.length)t=!0;else for(let i=0;i<e.length;i++)if(e[i].id!==this.layers[i]){t=!0;break}return t&&(this.layers=e.map(i=>i.id)),t}_updateViewport(e){const t=this.targetLayer;let i=!1;if(this.tile&&"boundingBox"in this.tile){if(!this.targetBounds){i=!0,this.targetBounds=this.tile.boundingBox;const o=e.projectPosition(this.targetBounds[0]),r=e.projectPosition(this.targetBounds[1]);this.targetBoundsCommon=[o[0],o[1],r[0],r[1]]}}else this.targetBounds!==t.getBounds()&&(i=!0,this.targetBounds=t.getBounds(),this.targetBoundsCommon=L([t],e));if(!this.targetBoundsCommon)return!1;const s=Math.ceil(e.zoom+.5);if(this.tile)this.bounds=this.targetBoundsCommon;else{const o=this.renderViewport?.zoom;i=i||s!==o;const r=R(this.targetBoundsCommon,e),n=this.bounds;i=i||!n||r.some((l,d)=>l!==n[d]),this.bounds=r}return i&&(this.renderViewport=S({bounds:this.bounds,zoom:s,viewport:e})),i}getRenderFramebuffer(){return!this.renderViewport||this.layers.length===0?null:(this.fbo||(this.fbo=A(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=A(this.targetLayer.context.device,{id:`${this.id}-picking`,interpolate:!1})),this.pickingFbo)}filterLayers(e){return e.filter(({id:t})=>this.layers.includes(t))}delete(){const{fbo:e,pickingFbo:t}=this;e&&(e.colorAttachments[0].destroy(),e.destroy()),t&&(t.colorAttachments[0].destroy(),t.destroy())}}function Et(a,e){return e.filter(t=>{const i=ae(t);return i?Ft(a.boundingBox,i.boundingBox):!0})}function ae(a){for(;a;){const{tile:e}=a.props;if(e)return e;a=a.parent}return null}function Ft(a,e){return a&&e?a[0][0]<e[1][0]&&e[0][0]<a[1][0]&&a[0][1]<e[1][1]&&e[0][1]<a[1][1]:!1}const kt={blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"};class At extends w{getRenderableLayers(e,t){const{layers:i}=t,s=[],o=this._getDrawLayerParams(e,t,!0);for(let r=0;r<i.length;r++){const n=i[r];!n.isComposite&&o[r].shouldDrawLayer&&s.push(n)}return s}renderHeightMap(e,t){const i=e.getRenderFramebuffer(),s=e.renderViewport;!i||!s||(i.resize(s),this.render({...t,target:i,pass:"terrain-height-map",layers:t.layers,viewports:[s],effects:[],clearColor:[0,0,0,0]}))}renderTerrainCover(e,t){const i=e.getRenderFramebuffer(),s=e.renderViewport;if(!i||!s)return;const o=e.filterLayers(t.layers);i.resize(s),this.render({...t,target:i,pass:`terrain-cover-${e.id}`,layers:o,effects:[],viewports:[s],clearColor:[0,0,0,0]})}getLayerParameters(e,t,i){return{...e.props.parameters,blend:!0,depthCompare:"always",...e.props.operation.includes("terrain")&&kt}}getShaderModuleProps(e,t,i){return{terrain:{project:i.project}}}}class wt extends ue{constructor(){super(...arguments),this.drawParameters={}}getRenderableLayers(e,t){const{layers:i}=t,s=[];this.drawParameters={},this._resetColorEncoder(t.pickZ);const o=this._getDrawLayerParams(e,t);for(let r=0;r<i.length;r++){const n=i[r];!n.isComposite&&o[r].shouldDrawLayer&&(s.push(n),this.drawParameters[n.id]=o[r].layerParameters)}return s}renderTerrainCover(e,t){const i=e.getPickingFramebuffer(),s=e.renderViewport;if(!i||!s)return;const o=e.filterLayers(t.layers),r=e.targetLayer;r.props.pickable&&o.unshift(r),i.resize(s),this.render({...t,pickingFBO:i,pass:`terrain-cover-picking-${e.id}`,layers:o,effects:[],viewports:[s],cullRect:void 0,deviceRect:s,pickZ:!1})}getLayerParameters(e,t,i){let s;return this.drawParameters[e.id]?s=this.drawParameters[e.id]:(s=super.getLayerParameters(e,t,i),s.blend=!0),{...s,depthCompare:"always"}}getShaderModuleProps(e,t,i){return{...super.getShaderModuleProps(e,t,i),terrain:{project:i.project}}}}const z=2048;class N{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=A(this.device,{id:"height-map",float:!0})),this.fbo):null}shouldUpdate({layers:e,viewport:t}){const i=e.length!==this.layers.length||e.some((o,r)=>o!==this.layers[r]||o.props.transitions||o.getBounds()!==this.layersBounds[r]);i&&(this.layers=e,this.layersBounds=e.map(o=>o.getBounds()),this.layersBoundsCommon=L(e,t));const s=!this.lastViewport||!t.equals(this.lastViewport);if(!this.layersBoundsCommon)this.renderViewport=null;else if(i||s){const o=R(this.layersBoundsCommon,t);if(o[2]<=o[0]||o[3]<=o[1])return this.renderViewport=null,!1;this.bounds=o,this.lastViewport=t;const r=t.scale,n=(o[2]-o[0])*r,l=(o[3]-o[1])*r;return this.renderViewport=n>0||l>0?S({bounds:[t.center[0]-1,t.center[1]-1,t.center[0]+1,t.center[1]+1],zoom:t.zoom,width:Math.min(n,z),height:Math.min(l,z),viewport:t}):null,!0}return!1}delete(){this.fbo&&(this.fbo.colorAttachments[0].delete(),this.fbo.delete())}}class Lt{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 At(e,{id:"terrain"}),this.terrainPickingPass=new wt(e,{id:"terrain-picking"}),N.isSupported(e)?this.heightMap=new N(e):P.warn("Terrain offset mode is not supported by this browser")(),t._addDefaultShaderModule(k)}preRender(e){if(e.pickZ){this.isDrapingEnabled=!1;return}const{viewports:t}=e,i=e.pass.startsWith("picking");this.isPicking=i,this.isDrapingEnabled=!0;const s=t[0],o=(i?this.terrainPickingPass:this.terrainPass).getRenderableLayers(s,e),r=o.filter(l=>l.props.operation.includes("terrain"));if(r.length===0)return;i||o.filter(d=>d.state.terrainDrawMode==="offset").length>0&&this._updateHeightMap(r,s,e);const n=o.filter(l=>l.state.terrainDrawMode==="drape");this._updateTerrainCovers(r,n,s,e)}getShaderModuleProps(e,t){const{terrainDrawMode:i}=e.state;return{terrain:{project:t.project,isPicking:this.isPicking,heightMap:this.heightMap?.getRenderFramebuffer()?.colorAttachments[0].texture||null,heightMapBounds:this.heightMap?.bounds,dummyHeightMap:this.dummyHeightMap,terrainCover:this.isDrapingEnabled?this.terrainCovers.get(e.id):null,useTerrainHeightMap:i==="offset",terrainSkipRender:i==="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(const t of this.terrainCovers.values())t.delete();this.terrainCovers.clear(),e._removeDefaultShaderModule(k)}_updateHeightMap(e,t,i){!this.heightMap||!this.heightMap.shouldUpdate({layers:e,viewport:t})||this.terrainPass.renderHeightMap(this.heightMap,{...i,layers:e,shaderModuleProps:{terrain:{heightMapBounds:this.heightMap.bounds,dummyHeightMap:this.dummyHeightMap,drawToTerrainHeightMap:!0},project:{devicePixelRatio:1}}})}_updateTerrainCovers(e,t,i,s){const o={};for(const r of t)r.state.terrainCoverNeedsRedraw&&(o[r.id]=!0,r.state.terrainCoverNeedsRedraw=!1);for(const r of this.terrainCovers.values())r.isDirty=r.isDirty||r.shouldUpdate({layerNeedsRedraw:o});for(const r of e)this._updateTerrainCover(r,t,i,s);this.isPicking||this._pruneTerrainCovers()}_updateTerrainCover(e,t,i,s){const o=this.isPicking?this.terrainPickingPass:this.terrainPass;let r=this.terrainCovers.get(e.id);r||(r=new Ct(e),this.terrainCovers.set(e.id,r));try{const n=r.shouldUpdate({targetLayer:e,viewport:i,layers:t});(this.isPicking||r.isDirty||n)&&(o.renderTerrainCover(r,{...s,layers:t,shaderModuleProps:{terrain:{dummyHeightMap:this.dummyHeightMap,terrainSkipRender:!1},project:{devicePixelRatio:1}}}),this.isPicking||(r.isDirty=!1))}catch(n){e.raiseError(n,`Error rendering terrain cover ${r.id}`)}}_pruneTerrainCovers(){const e=[];for(const[t,i]of this.terrainCovers)i.isActive||e.push(t);for(const t of e)this.terrainCovers.delete(t)}}const St={terrainDrawMode:void 0};class ne extends v{getShaders(){return{modules:[k]}}initializeState(){this.context.deck?._addDefaultEffect(new Lt)}updateState(e){const{props:t,oldProps:i}=e;if(this.state.terrainDrawMode&&t.terrainDrawMode===i.terrainDrawMode&&t.extruded===i.extruded)return;let{terrainDrawMode:s}=t;if(!s){const o=this.props.extruded,r=this.getAttributeManager()?.attributes,n=r&&"instancePositions"in r;s=o||n?"offset":"drape"}this.setState({terrainDrawMode:s})}onNeedsRedraw(){const e=this.state;e.terrainDrawMode==="drape"&&(e.terrainCoverNeedsRedraw=!0)}}ne.defaultProps=St;ne.extensionName="TerrainExtension";export{$ as BrushingExtension,Gt as ClipExtension,se as CollisionFilterExtension,Q as DataFilterExtension,ie as FillStyleExtension,Ye as Fp64Extension,re as MaskExtension,ee as PathStyleExtension,ne as _TerrainExtension,Ne as project64};
|
|
609
|
+
//# sourceMappingURL=extensions.js.map
|