@deck.gl/extensions 9.0.0-alpha.6 → 9.0.0-beta.1
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 +2680 -2548
- package/dist/es5/brushing/shader-module.js +2 -2
- package/dist/es5/brushing/shader-module.js.map +1 -1
- package/dist/es5/clip/clip-extension.js +4 -4
- package/dist/es5/clip/clip-extension.js.map +1 -1
- package/dist/es5/collision-filter/collision-filter-pass.js +4 -2
- package/dist/es5/collision-filter/collision-filter-pass.js.map +1 -1
- package/dist/es5/collision-filter/shader-module.js +1 -1
- package/dist/es5/collision-filter/shader-module.js.map +1 -1
- package/dist/es5/data-filter/aggregator.js +2 -2
- package/dist/es5/data-filter/aggregator.js.map +1 -1
- package/dist/es5/data-filter/shader-module.js +2 -2
- package/dist/es5/data-filter/shader-module.js.map +1 -1
- package/dist/es5/fill-style/shaders.glsl.js +3 -3
- package/dist/es5/fill-style/shaders.glsl.js.map +1 -1
- package/dist/es5/fp64/project64.js.map +1 -1
- package/dist/es5/mask/shader-module.js +4 -4
- package/dist/es5/mask/shader-module.js.map +1 -1
- package/dist/es5/path-style/shaders.glsl.js +4 -4
- package/dist/es5/path-style/shaders.glsl.js.map +1 -1
- package/dist/es5/terrain/shader-module.js +8 -6
- package/dist/es5/terrain/shader-module.js.map +1 -1
- package/dist/esm/brushing/shader-module.js +4 -4
- package/dist/esm/brushing/shader-module.js.map +1 -1
- package/dist/esm/clip/clip-extension.js +4 -4
- package/dist/esm/clip/clip-extension.js.map +1 -1
- package/dist/esm/collision-filter/collision-filter-pass.js +4 -2
- package/dist/esm/collision-filter/collision-filter-pass.js.map +1 -1
- package/dist/esm/collision-filter/shader-module.js +3 -3
- package/dist/esm/collision-filter/shader-module.js.map +1 -1
- package/dist/esm/data-filter/aggregator.js +11 -7
- package/dist/esm/data-filter/aggregator.js.map +1 -1
- package/dist/esm/data-filter/shader-module.js +4 -4
- package/dist/esm/data-filter/shader-module.js.map +1 -1
- package/dist/esm/fill-style/shaders.glsl.js +10 -10
- package/dist/esm/fill-style/shaders.glsl.js.map +1 -1
- package/dist/esm/fp64/project64.js.map +1 -1
- package/dist/esm/mask/shader-module.js +5 -5
- package/dist/esm/mask/shader-module.js.map +1 -1
- package/dist/esm/path-style/shaders.glsl.js +9 -13
- package/dist/esm/path-style/shaders.glsl.js.map +1 -1
- package/dist/esm/terrain/shader-module.js +8 -6
- package/dist/esm/terrain/shader-module.js.map +1 -1
- package/dist.min.js +140 -143
- package/package.json +8 -8
- package/src/brushing/shader-module.ts +6 -5
- package/src/clip/clip-extension.ts +6 -5
- package/src/collision-filter/collision-filter-pass.ts +4 -2
- package/src/collision-filter/shader-module.ts +4 -4
- package/src/data-filter/aggregator.ts +11 -7
- package/src/data-filter/shader-module.ts +5 -6
- package/src/fill-style/shaders.glsl.ts +12 -11
- package/src/fp64/project64.ts +2 -1
- package/src/mask/shader-module.ts +6 -6
- package/src/path-style/shaders.glsl.ts +9 -13
- package/src/terrain/shader-module.ts +8 -8
- package/typed/brushing/brushing-extension.d.ts +1 -1
- package/typed/brushing/brushing-extension.d.ts.map +1 -1
- package/typed/brushing/shader-module.d.ts +3 -2
- package/typed/brushing/shader-module.d.ts.map +1 -1
- package/typed/clip/clip-extension.d.ts +4 -3
- package/typed/clip/clip-extension.d.ts.map +1 -1
- package/typed/collision-filter/collision-filter-extension.d.ts +1 -1
- package/typed/collision-filter/collision-filter-extension.d.ts.map +1 -1
- package/typed/collision-filter/collision-filter-pass.d.ts +5 -3
- package/typed/collision-filter/collision-filter-pass.d.ts.map +1 -1
- package/typed/collision-filter/shader-module.d.ts +2 -2
- package/typed/collision-filter/shader-module.d.ts.map +1 -1
- package/typed/data-filter/aggregator.d.ts.map +1 -1
- package/typed/data-filter/data-filter-extension.d.ts +2 -2
- package/typed/data-filter/data-filter-extension.d.ts.map +1 -1
- package/typed/data-filter/shader-module.d.ts +2 -2
- package/typed/data-filter/shader-module.d.ts.map +1 -1
- package/typed/fill-style/fill-style-extension.d.ts +2 -2
- package/typed/fill-style/fill-style-extension.d.ts.map +1 -1
- package/typed/fill-style/shaders.glsl.d.ts +3 -2
- package/typed/fill-style/shaders.glsl.d.ts.map +1 -1
- package/typed/fp64/project64.d.ts +3 -2
- package/typed/fp64/project64.d.ts.map +1 -1
- package/typed/mask/mask-effect.d.ts +2 -2
- package/typed/mask/mask-effect.d.ts.map +1 -1
- package/typed/mask/mask-extension.d.ts +1 -1
- package/typed/mask/mask-extension.d.ts.map +1 -1
- package/typed/mask/mask-pass.d.ts +1 -1
- package/typed/mask/mask-pass.d.ts.map +1 -1
- package/typed/mask/shader-module.d.ts +2 -2
- package/typed/mask/shader-module.d.ts.map +1 -1
- package/typed/path-style/path-style-extension.d.ts +2 -2
- package/typed/path-style/path-style-extension.d.ts.map +1 -1
- package/typed/path-style/shaders.glsl.d.ts.map +1 -1
- package/typed/terrain/shader-module.d.ts +5 -3
- package/typed/terrain/shader-module.d.ts.map +1 -1
- package/typed/terrain/terrain-extension.d.ts +1 -1
- package/typed/terrain/terrain-extension.d.ts.map +1 -1
- package/typed/terrain/terrain-pass.d.ts +1 -1
- package/typed/terrain/terrain-pass.d.ts.map +1 -1
- package/typed/terrain/terrain-picking-pass.d.ts +1 -1
- package/typed/terrain/terrain-picking-pass.d.ts.map +1 -1
- package/typed/utils/projection-utils.d.ts +1 -1
- package/typed/utils/projection-utils.d.ts.map +1 -1
|
@@ -7,8 +7,8 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _core = require("@deck.gl/core");
|
|
9
9
|
|
|
10
|
-
var vs = "\n uniform bool brushing_enabled;\n uniform int brushing_target;\n uniform vec2 brushing_mousePos;\n uniform float brushing_radius;\n\n #ifdef NON_INSTANCED_MODEL\n
|
|
11
|
-
var fs = "\n uniform bool brushing_enabled;\n
|
|
10
|
+
var vs = "\n uniform bool brushing_enabled;\n uniform int brushing_target;\n uniform vec2 brushing_mousePos;\n uniform float brushing_radius;\n\n #ifdef NON_INSTANCED_MODEL\n in vec2 brushingTargets;\n #else\n in vec2 instanceBrushingTargets;\n #endif\n\n out float brushing_isVisible;\n\n bool brushing_isPointInRange(vec2 position) {\n if (!brushing_enabled) {\n return true;\n }\n vec2 source_commonspace = project_position(position);\n vec2 target_commonspace = project_position(brushing_mousePos);\n float distance = length((target_commonspace - source_commonspace) / project_uCommonUnitsPerMeter.xy);\n\n return distance <= brushing_radius;\n }\n\n bool brushing_arePointsInRange(vec2 sourcePos, vec2 targetPos) {\n return brushing_isPointInRange(sourcePos) || brushing_isPointInRange(targetPos);\n }\n\n void brushing_setVisible(bool visible) {\n brushing_isVisible = float(visible);\n }\n";
|
|
11
|
+
var fs = "\n uniform bool brushing_enabled;\n in float brushing_isVisible;\n";
|
|
12
12
|
var TARGET = {
|
|
13
13
|
source: 0,
|
|
14
14
|
target: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/brushing/shader-module.ts"],"names":["vs","fs","TARGET","source","target","custom","source_target","inject","name","dependencies","project","getUniforms","opts","brushingEnabled","brushingRadius","brushingTarget","mousePosition","viewport","brushing_enabled","Boolean","containsPixel","brushing_radius","brushing_target","brushing_mousePos","unproject","x","y"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/brushing/shader-module.ts"],"names":["vs","fs","TARGET","source","target","custom","source_target","inject","name","dependencies","project","getUniforms","opts","brushingEnabled","brushingRadius","brushingTarget","mousePosition","viewport","brushing_enabled","Boolean","containsPixel","brushing_radius","brushing_target","brushing_mousePos","unproject","x","y"],"mappings":";;;;;;;AAqBA;;AAWA,IAAMA,EAAE,w6BAAR;AAkCA,IAAMC,EAAE,yEAAR;AAKA,IAAMC,MAAM,GAAG;AACbC,EAAAA,MAAM,EAAE,CADK;AAEbC,EAAAA,MAAM,EAAE,CAFK;AAGbC,EAAAA,MAAM,EAAE,CAHK;AAIbC,EAAAA,aAAa,EAAE;AAJF,CAAf;AAOA,IAAMC,MAAM,GAAG;AACb,6zBADa;AA2Bb;AA3Ba,CAAf;eAkCe;AACbC,EAAAA,IAAI,EAAE,UADO;AAEbC,EAAAA,YAAY,EAAE,CAACC,aAAD,CAFD;AAGbV,EAAAA,EAAE,EAAFA,EAHa;AAIbC,EAAAA,EAAE,EAAFA,EAJa;AAKbM,EAAAA,MAAM,EAANA,MALa;AAMbI,EAAAA,WAAW,EAAE,qBAACC,IAAD,EAA6D;AACxE,QAAI,CAACA,IAAD,IAAS,EAAE,cAAcA,IAAhB,CAAb,EAAoC;AAClC,aAAO,EAAP;AACD;;AACD,gCAMIA,IANJ,CACEC,eADF;AAAA,QACEA,eADF,sCACoB,IADpB;AAAA,+BAMID,IANJ,CAEEE,cAFF;AAAA,QAEEA,cAFF,qCAEmB,KAFnB;AAAA,+BAMIF,IANJ,CAGEG,cAHF;AAAA,QAGEA,cAHF,qCAGmB,QAHnB;AAAA,QAIEC,aAJF,GAMIJ,IANJ,CAIEI,aAJF;AAAA,QAKEC,QALF,GAMIL,IANJ,CAKEK,QALF;AAOA,WAAO;AACLC,MAAAA,gBAAgB,EAAEC,OAAO,CACvBN,eAAe,IAAIG,aAAnB,IAAoCC,QAAQ,CAACG,aAAT,CAAuBJ,aAAvB,CADb,CADpB;AAILK,MAAAA,eAAe,EAAEP,cAJZ;AAKLQ,MAAAA,eAAe,EAAEpB,MAAM,CAACa,cAAD,CAAN,IAA0B,CALtC;AAMLQ,MAAAA,iBAAiB,EAAEP,aAAa,GAC5BC,QAAQ,CAACO,SAAT,CAAmB,CAACR,aAAa,CAACS,CAAd,GAAkBR,QAAQ,CAACQ,CAA5B,EAA+BT,aAAa,CAACU,CAAd,GAAkBT,QAAQ,CAACS,CAA1D,CAAnB,CAD4B,GAE5B,CAAC,CAAD,EAAI,CAAJ;AARC,KAAP;AAUD;AA3BY,C","sourcesContent":["// Copyright (c) 2015-2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n/* eslint-disable camelcase */\nimport type {ShaderModule} from '@luma.gl/shadertools';\nimport {project} from '@deck.gl/core';\nimport type {Viewport} from '@deck.gl/core';\n\nimport type {BrushingExtensionProps} from './brushing-extension';\n\ntype BrushingModuleSettings = {\n // From layer context\n viewport: Viewport;\n mousePosition?: {x: number; y: number};\n} & BrushingExtensionProps;\n\nconst vs = `\n uniform bool brushing_enabled;\n uniform int brushing_target;\n uniform vec2 brushing_mousePos;\n uniform float brushing_radius;\n\n #ifdef NON_INSTANCED_MODEL\n in vec2 brushingTargets;\n #else\n in vec2 instanceBrushingTargets;\n #endif\n\n out float brushing_isVisible;\n\n bool brushing_isPointInRange(vec2 position) {\n if (!brushing_enabled) {\n return true;\n }\n vec2 source_commonspace = project_position(position);\n vec2 target_commonspace = project_position(brushing_mousePos);\n float distance = length((target_commonspace - source_commonspace) / project_uCommonUnitsPerMeter.xy);\n\n return distance <= brushing_radius;\n }\n\n bool brushing_arePointsInRange(vec2 sourcePos, vec2 targetPos) {\n return brushing_isPointInRange(sourcePos) || brushing_isPointInRange(targetPos);\n }\n\n void brushing_setVisible(bool visible) {\n brushing_isVisible = float(visible);\n }\n`;\n\nconst fs = `\n uniform bool brushing_enabled;\n in float brushing_isVisible;\n`;\n\nconst TARGET = {\n source: 0,\n target: 1,\n custom: 2,\n source_target: 3\n};\n\nconst inject = {\n 'vs:DECKGL_FILTER_GL_POSITION': `\n vec2 brushingTarget;\n vec2 brushingSource;\n if (brushing_target == 3) {\n brushingTarget = geometry.worldPositionAlt.xy;\n brushingSource = geometry.worldPosition.xy;\n } else if (brushing_target == 0) {\n brushingTarget = geometry.worldPosition.xy;\n } else if (brushing_target == 1) {\n brushingTarget = geometry.worldPositionAlt.xy;\n } else {\n #ifdef NON_INSTANCED_MODEL\n brushingTarget = brushingTargets;\n #else\n brushingTarget = instanceBrushingTargets;\n #endif\n }\n bool visible;\n if (brushing_target == 3) {\n visible = brushing_arePointsInRange(brushingSource, brushingTarget);\n } else {\n visible = brushing_isPointInRange(brushingTarget);\n }\n brushing_setVisible(visible);\n `,\n\n 'fs:DECKGL_FILTER_COLOR': `\n if (brushing_enabled && brushing_isVisible < 0.5) {\n discard;\n }\n `\n};\n\nexport default {\n name: 'brushing',\n dependencies: [project],\n vs,\n fs,\n inject,\n getUniforms: (opts?: BrushingModuleSettings | {}): Record<string, any> => {\n if (!opts || !('viewport' in opts)) {\n return {};\n }\n const {\n brushingEnabled = true,\n brushingRadius = 10000,\n brushingTarget = 'source',\n mousePosition,\n viewport\n } = opts;\n return {\n brushing_enabled: Boolean(\n brushingEnabled && mousePosition && viewport.containsPixel(mousePosition)\n ),\n brushing_radius: brushingRadius,\n brushing_target: TARGET[brushingTarget] || 0,\n brushing_mousePos: mousePosition\n ? viewport.unproject([mousePosition.x - viewport.x, mousePosition.y - viewport.y])\n : [0, 0]\n };\n }\n} as ShaderModule<BrushingModuleSettings>;\n"],"file":"shader-module.js"}
|
|
@@ -31,9 +31,9 @@ var shaderModuleVs = {
|
|
|
31
31
|
vs: shaderFunction
|
|
32
32
|
};
|
|
33
33
|
var injectionVs = {
|
|
34
|
-
'vs:#decl': "\
|
|
34
|
+
'vs:#decl': "\nout float clip_isVisible;\n",
|
|
35
35
|
'vs:DECKGL_FILTER_GL_POSITION': "\n clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy));\n",
|
|
36
|
-
'fs:#decl': "\
|
|
36
|
+
'fs:#decl': "\nin float clip_isVisible;\n",
|
|
37
37
|
'fs:DECKGL_FILTER_COLOR': "\n if (clip_isVisible < 0.5) discard;\n"
|
|
38
38
|
};
|
|
39
39
|
var shaderModuleFs = {
|
|
@@ -41,9 +41,9 @@ var shaderModuleFs = {
|
|
|
41
41
|
fs: shaderFunction
|
|
42
42
|
};
|
|
43
43
|
var injectionFs = {
|
|
44
|
-
'vs:#decl': "\
|
|
44
|
+
'vs:#decl': "\nout vec2 clip_commonPosition;\n",
|
|
45
45
|
'vs:DECKGL_FILTER_GL_POSITION': "\n clip_commonPosition = geometry.position.xy;\n",
|
|
46
|
-
'fs:#decl': "\
|
|
46
|
+
'fs:#decl': "\nin vec2 clip_commonPosition;\n",
|
|
47
47
|
'fs:DECKGL_FILTER_COLOR': "\n if (!clip_isInBounds(clip_commonPosition)) discard;\n"
|
|
48
48
|
};
|
|
49
49
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/clip/clip-extension.ts"],"names":["defaultProps","clipBounds","clipByInstance","undefined","shaderFunction","shaderModuleVs","name","vs","injectionVs","shaderModuleFs","fs","injectionFs","ClipExtension","getShaders","getAttributeManager","attributes","props","Boolean","state","modules","inject","draw","uniforms","clip_bounds","corner0","projectPosition","corner1","Math","min","max","LayerExtension","extensionName"],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/clip/clip-extension.ts"],"names":["defaultProps","clipBounds","clipByInstance","undefined","shaderFunction","shaderModuleVs","name","vs","injectionVs","shaderModuleFs","fs","injectionFs","ClipExtension","getShaders","getAttributeManager","attributes","props","Boolean","state","modules","inject","draw","uniforms","clip_bounds","corner0","projectPosition","corner1","Math","min","max","LayerExtension","extensionName"],"mappings":";;;;;;;;;;;;;;;;;AAqBA;;;;;;AAIA,IAAMA,YAAY,GAAG;AACnBC,EAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CADO;AAEnBC,EAAAA,cAAc,EAAEC;AAFG,CAArB;AAiBA,IAAMC,cAAc,oNAApB;AAYA,IAAMC,cAA4B,GAAG;AACnCC,EAAAA,IAAI,EAAE,SAD6B;AAEnCC,EAAAA,EAAE,EAAEH;AAF+B,CAArC;AAKA,IAAMI,WAAW,GAAG;AAClB,6CADkB;AAIlB,6GAJkB;AAOlB,4CAPkB;AAUlB;AAVkB,CAApB;AAmBA,IAAMC,cAA4B,GAAG;AACnCH,EAAAA,IAAI,EAAE,SAD6B;AAEnCI,EAAAA,EAAE,EAAEN;AAF+B,CAArC;AAKA,IAAMO,WAAW,GAAG;AAClB,iDADkB;AAIlB,qFAJkB;AAOlB,gDAPkB;AAUlB;AAVkB,CAApB;;IAgBqBC,a;;;;;;;;;;;;SAInBC,U,GAAA,sBAA4C;AAK1C,QAAIX,cAAc,IAAG,uBAAuB,KAAKY,mBAAL,GAA4BC,UAAtD,CAAlB;;AAEA,QAAI,KAAKC,KAAL,CAAWd,cAAX,KAA8BC,SAAlC,EAA6C;AAC3CD,MAAAA,cAAc,GAAGe,OAAO,CAAC,KAAKD,KAAL,CAAWd,cAAZ,CAAxB;AACD;;AACD,SAAKgB,KAAL,CAAWhB,cAAX,GAA4BA,cAA5B;AAEA,WAAOA,cAAc,GACjB;AACEiB,MAAAA,OAAO,EAAE,CAACd,cAAD,CADX;AAEEe,MAAAA,MAAM,EAAEZ;AAFV,KADiB,GAKjB;AACEW,MAAAA,OAAO,EAAE,CAACV,cAAD,CADX;AAEEW,MAAAA,MAAM,EAAET;AAFV,KALJ;AASD,G;;SAGDU,I,GAAA,oBAAuE;AAAA,QAAtBC,QAAsB,QAAtBA,QAAsB;AACrE,QAAOrB,UAAP,GAAqB,KAAKe,KAA1B,CAAOf,UAAP;;AACA,QAAI,KAAKiB,KAAL,CAAWhB,cAAf,EAA+B;AAC7BoB,MAAAA,QAAQ,CAACC,WAAT,GAAuBtB,UAAvB;AACD,KAFD,MAEO;AACL,UAAMuB,OAAO,GAAG,KAAKC,eAAL,CAAqB,CAACxB,UAAU,CAAC,CAAD,CAAX,EAAgBA,UAAU,CAAC,CAAD,CAA1B,EAA+B,CAA/B,CAArB,CAAhB;AACA,UAAMyB,OAAO,GAAG,KAAKD,eAAL,CAAqB,CAACxB,UAAU,CAAC,CAAD,CAAX,EAAgBA,UAAU,CAAC,CAAD,CAA1B,EAA+B,CAA/B,CAArB,CAAhB;AAEAqB,MAAAA,QAAQ,CAACC,WAAT,GAAuB,CACrBI,IAAI,CAACC,GAAL,CAASJ,OAAO,CAAC,CAAD,CAAhB,EAAqBE,OAAO,CAAC,CAAD,CAA5B,CADqB,EAErBC,IAAI,CAACC,GAAL,CAASJ,OAAO,CAAC,CAAD,CAAhB,EAAqBE,OAAO,CAAC,CAAD,CAA5B,CAFqB,EAGrBC,IAAI,CAACE,GAAL,CAASL,OAAO,CAAC,CAAD,CAAhB,EAAqBE,OAAO,CAAC,CAAD,CAA5B,CAHqB,EAIrBC,IAAI,CAACE,GAAL,CAASL,OAAO,CAAC,CAAD,CAAhB,EAAqBE,OAAO,CAAC,CAAD,CAA5B,CAJqB,CAAvB;AAMD;AACF,G;;;EA3CwCI,oB;;;AAAtBlB,a,CACZZ,Y,GAAeA,Y;AADHY,a,CAEZmB,a,GAAgB,e","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport type {ShaderModule} from '@luma.gl/shadertools';\nimport {LayerExtension} from '@deck.gl/core';\n\nimport type {Layer} from '@deck.gl/core';\n\nconst defaultProps = {\n clipBounds: [0, 0, 1, 1],\n clipByInstance: undefined\n};\n\nexport type ClipExtensionProps = {\n /** Rectangular bounds to be used for clipping the rendered region, in `[left, bottom, right, top]`.\n * @default [0, 0, 1, 1]\n */\n clipBounds?: [number, number, number, number];\n /**\n * Controls whether an object is clipped by its anchor (e.g. icon, point) or by its geometry (e.g. path, polygon).\n * If not specified, it is automatically deduced from the layer.\n */\n clipByInstance?: boolean;\n};\n\nconst shaderFunction = `\nuniform vec4 clip_bounds;\n\nbool clip_isInBounds(vec2 position) {\n return position.x >= clip_bounds[0] && position.y >= clip_bounds[1] && position.x < clip_bounds[2] && position.y < clip_bounds[3];\n}\n`;\n\n/*\n * The vertex-shader version clips geometries by their anchor position\n * e.g. ScatterplotLayer - show if the center of a circle is within bounds\n */\nconst shaderModuleVs: ShaderModule = {\n name: 'clip-vs',\n vs: shaderFunction\n};\n\nconst injectionVs = {\n 'vs:#decl': `\nout float clip_isVisible;\n`,\n 'vs:DECKGL_FILTER_GL_POSITION': `\n clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy));\n`,\n 'fs:#decl': `\nin float clip_isVisible;\n`,\n 'fs:DECKGL_FILTER_COLOR': `\n if (clip_isVisible < 0.5) discard;\n`\n};\n\n/*\n * The fragment-shader version clips pixels at the bounds\n * e.g. PolygonLayer - show the part of the polygon that intersect with the bounds\n */\nconst shaderModuleFs: ShaderModule = {\n name: 'clip-fs',\n fs: shaderFunction\n};\n\nconst injectionFs = {\n 'vs:#decl': `\nout vec2 clip_commonPosition;\n`,\n 'vs:DECKGL_FILTER_GL_POSITION': `\n clip_commonPosition = geometry.position.xy;\n`,\n 'fs:#decl': `\nin vec2 clip_commonPosition;\n`,\n 'fs:DECKGL_FILTER_COLOR': `\n if (!clip_isInBounds(clip_commonPosition)) discard;\n`\n};\n\n/** Adds support for clipping rendered layers by rectangular bounds. */\nexport default class ClipExtension extends LayerExtension {\n static defaultProps = defaultProps;\n static extensionName = 'ClipExtension';\n\n getShaders(this: Layer<ClipExtensionProps>) {\n // If `clipByInstance: true`, the entire object is shown/hidden based on its anchor position (done by vertex shader)\n // Otherwise, the object is trimmed by the clip bounds (done by fragment shader)\n\n // Default behavior: consider a layer instanced if it has attribute `instancePositions`\n let clipByInstance = 'instancePositions' in this.getAttributeManager()!.attributes;\n // Users can override by setting the `clipByInstance` prop\n if (this.props.clipByInstance !== undefined) {\n clipByInstance = Boolean(this.props.clipByInstance);\n }\n this.state.clipByInstance = clipByInstance;\n\n return clipByInstance\n ? {\n modules: [shaderModuleVs],\n inject: injectionVs\n }\n : {\n modules: [shaderModuleFs],\n inject: injectionFs\n };\n }\n\n /* eslint-disable camelcase */\n draw(this: Layer<Required<ClipExtensionProps>>, {uniforms}: any): void {\n const {clipBounds} = this.props;\n if (this.state.clipByInstance) {\n uniforms.clip_bounds = clipBounds;\n } else {\n const corner0 = this.projectPosition([clipBounds[0], clipBounds[1], 0]);\n const corner1 = this.projectPosition([clipBounds[2], clipBounds[3], 0]);\n\n uniforms.clip_bounds = [\n Math.min(corner0[0], corner1[0]),\n Math.min(corner0[1], corner1[1]),\n Math.max(corner0[0], corner1[0]),\n Math.max(corner0[1], corner1[1])\n ];\n }\n }\n}\n"],"file":"clip-extension.js"}
|
|
@@ -64,8 +64,10 @@ var CollisionFilterPass = function (_LayersPass) {
|
|
|
64
64
|
_proto.getModuleParameters = function getModuleParameters() {
|
|
65
65
|
return {
|
|
66
66
|
drawToCollisionMap: true,
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
picking: {
|
|
68
|
+
isActive: 1,
|
|
69
|
+
isAttribute: false
|
|
70
|
+
},
|
|
69
71
|
lightSources: {}
|
|
70
72
|
};
|
|
71
73
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collision-filter/collision-filter-pass.ts"],"names":["CollisionFilterPass","renderCollisionMap","target","options","padding","clearColor","device","scissorTest","scissor","width","height","blend","depthTest","depthRange","render","pass","getModuleParameters","drawToCollisionMap","
|
|
1
|
+
{"version":3,"sources":["../../../src/collision-filter/collision-filter-pass.ts"],"names":["CollisionFilterPass","renderCollisionMap","target","options","padding","clearColor","device","scissorTest","scissor","width","height","blend","depthTest","depthRange","render","pass","getModuleParameters","drawToCollisionMap","picking","isActive","isAttribute","lightSources","LayersPass"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;;AACA;;;;;;;;;;IAIqBA,mB;;;;;;;;;;;;SACnBC,kB,GAAA,4BAAmBC,MAAnB,EAAwCC,OAAxC,EAAmF;AAAA;;AACjF,QAAMC,OAAO,GAAG,CAAhB;AACA,QAAMC,UAAU,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAnB;AAEA,WAAO,6BACL,KAAKC,MADA,EAEL;AACEC,MAAAA,WAAW,EAAE,IADf;AAEEC,MAAAA,OAAO,EAAE,CAACJ,OAAD,EAAUA,OAAV,EAAmBF,MAAM,CAACO,KAAP,GAAe,IAAIL,OAAtC,EAA+CF,MAAM,CAACQ,MAAP,GAAgB,IAAIN,OAAnE,CAFX;AAGEO,MAAAA,KAAK,EAAE,KAHT;AAIEC,MAAAA,SAAS,EAAE,IAJb;AAKEC,MAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ;AALd,KAFK,EASL;AAAA,aAAM,KAAI,CAACC,MAAL,iCAAgBX,OAAhB;AAAyBE,QAAAA,UAAU,EAAVA,UAAzB;AAAqCH,QAAAA,MAAM,EAANA,MAArC;AAA6Ca,QAAAA,IAAI,EAAE;AAAnD,SAAN;AAAA,KATK,CAAP;AAWD,G;;SAEDC,mB,GAAA,+BAAsB;AAEpB,WAAO;AACLC,MAAAA,kBAAkB,EAAE,IADf;AAELC,MAAAA,OAAO,EAAE;AACPC,QAAAA,QAAQ,EAAE,CADH;AAEPC,QAAAA,WAAW,EAAE;AAFN,OAFJ;AAMLC,MAAAA,YAAY,EAAE;AANT,KAAP;AAQD,G;;;EA5B8CC,iB","sourcesContent":["import {Framebuffer} from '@luma.gl/core';\nimport {withGLParameters} from '@luma.gl/webgl';\nimport {_LayersPass as LayersPass, LayersPassRenderOptions} from '@deck.gl/core';\n\ntype CollisionFilterPassRenderOptions = LayersPassRenderOptions & {};\n\nexport default class CollisionFilterPass extends LayersPass {\n renderCollisionMap(target: Framebuffer, options: CollisionFilterPassRenderOptions) {\n const padding = 1;\n const clearColor = [0, 0, 0, 0];\n\n return withGLParameters(\n this.device,\n {\n scissorTest: true,\n scissor: [padding, padding, target.width - 2 * padding, target.height - 2 * padding],\n blend: false,\n depthTest: true,\n depthRange: [0, 1]\n },\n () => this.render({...options, clearColor, target, pass: 'collision'})\n );\n }\n\n getModuleParameters() {\n // Draw picking colors into collision FBO\n return {\n drawToCollisionMap: true,\n picking: {\n isActive: 1,\n isAttribute: false\n },\n lightSources: {}\n };\n }\n}\n"],"file":"collision-filter-pass.js"}
|
|
@@ -7,7 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _core = require("@deck.gl/core");
|
|
9
9
|
|
|
10
|
-
var vs = "\n#ifdef NON_INSTANCED_MODEL\
|
|
10
|
+
var vs = "\n#ifdef NON_INSTANCED_MODEL\nin float collisionPriorities;\n#else\nin float instanceCollisionPriorities;\n#endif\n\nuniform sampler2D collision_texture;\nuniform bool collision_sort;\nuniform bool collision_enabled;\n\nvec2 collision_getCoords(vec4 position) {\n vec4 collision_clipspace = project_common_position_to_clipspace(position);\n return (1.0 + collision_clipspace.xy / collision_clipspace.w) / 2.0;\n}\n\nfloat collision_match(vec2 tex, vec3 pickingColor) {\n vec4 collision_pickingColor = texture(collision_texture, tex);\n float delta = dot(abs(collision_pickingColor.rgb - pickingColor), vec3(1.0));\n float e = 0.001;\n return step(delta, e);\n}\n\nfloat collision_isVisible(vec2 texCoords, vec3 pickingColor) {\n if (!collision_enabled) {\n return 1.0;\n }\n\n // Visibility test, sample area of 5x5 pixels in order to fade in/out.\n // Due to the locality, the lookups will be cached\n // This reduces the flicker present when objects are shown/hidden\n const int N = 2;\n float accumulator = 0.0;\n vec2 step = vec2(1.0 / project_uViewportSize);\n\n const float floatN = float(N);\n vec2 delta = -floatN * step;\n for(int i = -N; i <= N; i++) {\n delta.x = -step.x * floatN;\n for(int j = -N; j <= N; j++) {\n accumulator += collision_match(texCoords + delta, pickingColor);\n delta.x += step.x;\n }\n delta.y += step.y;\n }\n\n float W = 2.0 * floatN + 1.0;\n return pow(accumulator / (W * W), 2.2);\n}\n";
|
|
11
11
|
var inject = {
|
|
12
12
|
'vs:#decl': "\n float collision_fade = 1.0;\n",
|
|
13
13
|
'vs:DECKGL_FILTER_GL_POSITION': "\n if (collision_sort) {\n #ifdef NON_INSTANCED_MODEL\n float collisionPriority = collisionPriorities;\n #else\n float collisionPriority = instanceCollisionPriorities;\n #endif\n position.z = -0.001 * collisionPriority * position.w; // Support range -1000 -> 1000\n }\n\n if (collision_enabled) {\n vec4 collision_common_position = project_position(vec4(geometry.worldPosition, 1.0));\n vec2 collision_texCoords = collision_getCoords(collision_common_position);\n collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);\n if (collision_fade < 0.0001) {\n // Position outside clip space bounds to discard\n position = vec4(0.0, 0.0, 2.0, 1.0);\n }\n }\n ",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collision-filter/shader-module.ts"],"names":["vs","inject","getCollisionUniforms","opts","uniforms","collisionFBO","drawToCollisionMap","dummyCollisionMap","collision_sort","Boolean","collision_texture","colorAttachments","name","dependencies","project","getUniforms"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/collision-filter/shader-module.ts"],"names":["vs","inject","getCollisionUniforms","opts","uniforms","collisionFBO","drawToCollisionMap","dummyCollisionMap","collision_sort","Boolean","collision_texture","colorAttachments","name","dependencies","project","getUniforms"],"mappings":";;;;;;;AAEA;;AAEA,IAAMA,EAAE,i8CAAR;AAmDA,IAAMC,MAAM,GAAG;AACb,iDADa;AAIb,mwBAJa;AAwBb;AAxBa,CAAf;;AAsCA,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAuB,CAC3BC,IAD2B,EAE3BC,QAF2B,EAGL;AACtB,MAAI,CAACD,IAAD,IAAS,EAAE,uBAAuBA,IAAzB,CAAb,EAA6C;AAC3C,WAAO,EAAP;AACD;;AACD,MAAOE,YAAP,GAA8DF,IAA9D,CAAOE,YAAP;AAAA,MAAqBC,kBAArB,GAA8DH,IAA9D,CAAqBG,kBAArB;AAAA,MAAyCC,iBAAzC,GAA8DJ,IAA9D,CAAyCI,iBAAzC;AACA,SAAO;AACLC,IAAAA,cAAc,EAAEC,OAAO,CAACH,kBAAD,CADlB;AAELI,IAAAA,iBAAiB,EACf,CAACJ,kBAAD,IAAuBD,YAAvB,GAAsCA,YAAY,CAACM,gBAAb,CAA8B,CAA9B,CAAtC,GAAyEJ;AAHtE,GAAP;AAKD,CAbD;;eAgBe;AACbK,EAAAA,IAAI,EAAE,WADO;AAEbC,EAAAA,YAAY,EAAE,CAACC,aAAD,CAFD;AAGbd,EAAAA,EAAE,EAAFA,EAHa;AAIbC,EAAAA,MAAM,EAANA,MAJa;AAKbc,EAAAA,WAAW,EAAEb;AALA,C","sourcesContent":["import {Framebuffer, Texture} from '@luma.gl/core';\nimport type {ShaderModule} from '@luma.gl/shadertools';\nimport {project} from '@deck.gl/core';\n\nconst vs = `\n#ifdef NON_INSTANCED_MODEL\nin float collisionPriorities;\n#else\nin float instanceCollisionPriorities;\n#endif\n\nuniform sampler2D collision_texture;\nuniform bool collision_sort;\nuniform bool collision_enabled;\n\nvec2 collision_getCoords(vec4 position) {\n vec4 collision_clipspace = project_common_position_to_clipspace(position);\n return (1.0 + collision_clipspace.xy / collision_clipspace.w) / 2.0;\n}\n\nfloat collision_match(vec2 tex, vec3 pickingColor) {\n vec4 collision_pickingColor = texture(collision_texture, tex);\n float delta = dot(abs(collision_pickingColor.rgb - pickingColor), vec3(1.0));\n float e = 0.001;\n return step(delta, e);\n}\n\nfloat collision_isVisible(vec2 texCoords, vec3 pickingColor) {\n if (!collision_enabled) {\n return 1.0;\n }\n\n // Visibility test, sample area of 5x5 pixels in order to fade in/out.\n // Due to the locality, the lookups will be cached\n // This reduces the flicker present when objects are shown/hidden\n const int N = 2;\n float accumulator = 0.0;\n vec2 step = vec2(1.0 / project_uViewportSize);\n\n const float floatN = float(N);\n vec2 delta = -floatN * step;\n for(int i = -N; i <= N; i++) {\n delta.x = -step.x * floatN;\n for(int j = -N; j <= N; j++) {\n accumulator += collision_match(texCoords + delta, pickingColor);\n delta.x += step.x;\n }\n delta.y += step.y;\n }\n\n float W = 2.0 * floatN + 1.0;\n return pow(accumulator / (W * W), 2.2);\n}\n`;\n\nconst inject = {\n 'vs:#decl': `\n float collision_fade = 1.0;\n`,\n 'vs:DECKGL_FILTER_GL_POSITION': `\n if (collision_sort) {\n #ifdef NON_INSTANCED_MODEL\n float collisionPriority = collisionPriorities;\n #else\n float collisionPriority = instanceCollisionPriorities;\n #endif\n position.z = -0.001 * collisionPriority * position.w; // Support range -1000 -> 1000\n }\n\n if (collision_enabled) {\n vec4 collision_common_position = project_position(vec4(geometry.worldPosition, 1.0));\n vec2 collision_texCoords = collision_getCoords(collision_common_position);\n collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);\n if (collision_fade < 0.0001) {\n // Position outside clip space bounds to discard\n position = vec4(0.0, 0.0, 2.0, 1.0);\n }\n }\n `,\n 'vs:DECKGL_FILTER_COLOR': `\n color.a *= collision_fade;\n `\n};\n\ntype CollisionModuleSettings = {\n collisionFBO?: Framebuffer;\n drawToCollisionMap?: boolean;\n dummyCollisionMap?: Texture;\n};\n\n/* eslint-disable camelcase */\ntype CollisionUniforms = {collision_sort?: boolean; collision_texture?: Texture};\n\nconst getCollisionUniforms = (\n opts: CollisionModuleSettings | {},\n uniforms: Record<string, any>\n): CollisionUniforms => {\n if (!opts || !('dummyCollisionMap' in opts)) {\n return {};\n }\n const {collisionFBO, drawToCollisionMap, dummyCollisionMap} = opts;\n return {\n collision_sort: Boolean(drawToCollisionMap),\n collision_texture:\n !drawToCollisionMap && collisionFBO ? collisionFBO.colorAttachments[0] : dummyCollisionMap\n };\n};\n\n// @ts-expect-error\nexport default {\n name: 'collision',\n dependencies: [project],\n vs,\n inject,\n getUniforms: getCollisionUniforms\n} as ShaderModule<CollisionModuleSettings>;\n"],"file":"shader-module.js"}
|
|
@@ -20,8 +20,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
20
20
|
|
|
21
21
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
22
22
|
|
|
23
|
-
var AGGREGATE_VS = "#define SHADER_NAME data-filter-vertex-shader\n\n#ifdef FLOAT_TARGET\n
|
|
24
|
-
var AGGREGATE_FS = "#define SHADER_NAME data-filter-fragment-shader\nprecision highp float;\n\
|
|
23
|
+
var AGGREGATE_VS = "#version 300 es\n#define SHADER_NAME data-filter-vertex-shader\n\n#ifdef FLOAT_TARGET\n in float filterIndices;\n in float filterPrevIndices;\n#else\n in vec2 filterIndices;\n in vec2 filterPrevIndices;\n#endif\n\nout vec4 vColor;\nconst float component = 1.0 / 255.0;\n\nvoid main() {\n #ifdef FLOAT_TARGET\n dataFilter_value *= float(filterIndices != filterPrevIndices);\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n vColor = vec4(0.0, 0.0, 0.0, 1.0);\n #else\n // Float texture is not supported: pack result into 4 channels x 256 px x 64px\n dataFilter_value *= float(filterIndices.x != filterPrevIndices.x);\n float col = filterIndices.x;\n float row = filterIndices.y * 4.0;\n float channel = floor(row);\n row = fract(row);\n vColor = component * vec4(bvec4(channel == 0.0, channel == 1.0, channel == 2.0, channel == 3.0));\n gl_Position = vec4(col * 2.0 - 1.0, row * 2.0 - 1.0, 0.0, 1.0);\n #endif\n gl_PointSize = 1.0;\n}\n";
|
|
24
|
+
var AGGREGATE_FS = "#version 300 es\n#define SHADER_NAME data-filter-fragment-shader\nprecision highp float;\n\nin vec4 vColor;\n\nout vec4 fragColor;\n\nvoid main() {\n if (dataFilter_value < 0.5) {\n discard;\n }\n fragColor = vColor;\n}\n";
|
|
25
25
|
|
|
26
26
|
function supportsFloatTarget(device) {
|
|
27
27
|
var gl = device.gl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/data-filter/aggregator.ts"],"names":["AGGREGATE_VS","AGGREGATE_FS","supportsFloatTarget","device","gl","Boolean","getExtension","getFramebuffer","useFloatTarget","createFramebuffer","width","height","colorAttachments","createTexture","format","info","type","mipmaps","getModel","shaderOptions","defines","NON_INSTANCED_MODEL","FLOAT_TARGET","Model","id","vertexCount","isInstanced","drawMode","vs","fs","parameters","blend","blendFunc","blendEquation","depthTest"],"mappings":";;;;;;;;;;;;;;AACA;;AACA;;;;;;AAEA,IAAMA,YAAY
|
|
1
|
+
{"version":3,"sources":["../../../src/data-filter/aggregator.ts"],"names":["AGGREGATE_VS","AGGREGATE_FS","supportsFloatTarget","device","gl","Boolean","getExtension","getFramebuffer","useFloatTarget","createFramebuffer","width","height","colorAttachments","createTexture","format","info","type","mipmaps","getModel","shaderOptions","defines","NON_INSTANCED_MODEL","FLOAT_TARGET","Model","id","vertexCount","isInstanced","drawMode","vs","fs","parameters","blend","blendFunc","blendEquation","depthTest"],"mappings":";;;;;;;;;;;;;;AACA;;AACA;;;;;;AAEA,IAAMA,YAAY,+8BAAlB;AAkCA,IAAMC,YAAY,wOAAlB;;AAiBO,SAASC,mBAAT,CAA6BC,MAA7B,EAAsD;AAE3D,MAAMC,EAAE,GAAGD,MAAM,CAACC,EAAlB;AAGA,SAAOC,OAAO,CACZD,EAAE,CAACE,YAAH,CAAgB,iBAAhB,MAEGF,EAAE,CAACE,YAAH,CAAgB,wBAAhB,KAECF,EAAE,CAACE,YAAH,CAAgB,0BAAhB,CAJJ,CADY,CAAd;AAOD;;AAGM,SAASC,cAAT,CAAwBJ,MAAxB,EAAwCK,cAAxC,EAA8E;AACnF,MAAIA,cAAJ,EAAoB;AAClB,WAAOL,MAAM,CAACM,iBAAP,CAAyB;AAC9BC,MAAAA,KAAK,EAAE,CADuB;AAE9BC,MAAAA,MAAM,EAAE,CAFsB;AAG9BC,MAAAA,gBAAgB,EAAE,CAChBT,MAAM,CAACU,aAAP,CAAqB;AACnBC,QAAAA,MAAM,EAAEX,MAAM,CAACY,IAAP,CAAYC,IAAZ,KAAqB,QAArB,GAAgC,aAAhC,GAAgD,YADrC;AAEnBA,QAAAA,IAAI,MAFe;AAGnBC,QAAAA,OAAO,EAAE;AAHU,OAArB,CADgB;AAHY,KAAzB,CAAP;AAWD;;AACD,SAAOd,MAAM,CAACM,iBAAP,CAAyB;AAC9BC,IAAAA,KAAK,EAAE,GADuB;AAE9BC,IAAAA,MAAM,EAAE,EAFsB;AAG9BC,IAAAA,gBAAgB,EAAE,CAACT,MAAM,CAACU,aAAP,CAAqB;AAACC,MAAAA,MAAM,EAAE,YAAT;AAAuBE,MAAAA,IAAI,MAA3B;AAAuCC,MAAAA,OAAO,EAAE;AAAhD,KAArB,CAAD;AAHY,GAAzB,CAAP;AAKD;;AAGM,SAASC,QAAT,CAAkBf,MAAlB,EAAkCgB,aAAlC,EAAsDX,cAAtD,EAAsF;AAC3FW,EAAAA,aAAa,CAACC,OAAd,CAAsBC,mBAAtB,GAA4C,CAA5C;;AACA,MAAIb,cAAJ,EAAoB;AAClBW,IAAAA,aAAa,CAACC,OAAd,CAAsBE,YAAtB,GAAqC,CAArC;AACD;;AAED,SAAO,IAAIC,aAAJ,CAAUpB,MAAV;AACLqB,IAAAA,EAAE,EAAE,+BADC;AAELC,IAAAA,WAAW,EAAE,CAFR;AAGLC,IAAAA,WAAW,EAAE,KAHR;AAILC,IAAAA,QAAQ,GAJH;AAKLC,IAAAA,EAAE,EAAE5B,YALC;AAML6B,IAAAA,EAAE,EAAE5B;AANC,KAOFkB,aAPE,EAAP;AASD;;AAEM,IAAMW,UAAU,GAAG;AACxBC,EAAAA,KAAK,EAAE,IADiB;AAExBC,EAAAA,SAAS,EAAE,YAFa;AAGxBC,EAAAA,aAAa,EAAE,cAHS;AAIxBC,EAAAA,SAAS,EAAE;AAJa,CAAnB","sourcesContent":["import {Device, Framebuffer} from '@luma.gl/core';\nimport {Model} from '@luma.gl/engine';\nimport {GL} from '@luma.gl/constants';\n\nconst AGGREGATE_VS = `\\\n#version 300 es\n#define SHADER_NAME data-filter-vertex-shader\n\n#ifdef FLOAT_TARGET\n in float filterIndices;\n in float filterPrevIndices;\n#else\n in vec2 filterIndices;\n in vec2 filterPrevIndices;\n#endif\n\nout vec4 vColor;\nconst float component = 1.0 / 255.0;\n\nvoid main() {\n #ifdef FLOAT_TARGET\n dataFilter_value *= float(filterIndices != filterPrevIndices);\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n vColor = vec4(0.0, 0.0, 0.0, 1.0);\n #else\n // Float texture is not supported: pack result into 4 channels x 256 px x 64px\n dataFilter_value *= float(filterIndices.x != filterPrevIndices.x);\n float col = filterIndices.x;\n float row = filterIndices.y * 4.0;\n float channel = floor(row);\n row = fract(row);\n vColor = component * vec4(bvec4(channel == 0.0, channel == 1.0, channel == 2.0, channel == 3.0));\n gl_Position = vec4(col * 2.0 - 1.0, row * 2.0 - 1.0, 0.0, 1.0);\n #endif\n gl_PointSize = 1.0;\n}\n`;\n\nconst AGGREGATE_FS = `\\\n#version 300 es\n#define SHADER_NAME data-filter-fragment-shader\nprecision highp float;\n\nin vec4 vColor;\n\nout vec4 fragColor;\n\nvoid main() {\n if (dataFilter_value < 0.5) {\n discard;\n }\n fragColor = vColor;\n}\n`;\n\nexport function supportsFloatTarget(device: Device): boolean {\n // @ts-expect-error\n const gl = device.gl;\n\n // https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices#Support_for_float_textures_doesnt_mean_you_can_render_into_them!\n return Boolean(\n gl.getExtension('EXT_float_blend') &&\n // WebGL 2\n (gl.getExtension('EXT_color_buffer_float') ||\n // WebGL 1\n gl.getExtension('WEBGL_color_buffer_float'))\n );\n}\n\n// A 1x1 framebuffer object that encodes the total count of filtered items\nexport function getFramebuffer(device: Device, useFloatTarget: boolean): Framebuffer {\n if (useFloatTarget) {\n return device.createFramebuffer({\n width: 1,\n height: 1,\n colorAttachments: [\n device.createTexture({\n format: device.info.type === 'webgl2' ? 'rgba32float' : 'rgba8unorm',\n type: GL.FLOAT,\n mipmaps: false\n })\n ]\n });\n }\n return device.createFramebuffer({\n width: 256,\n height: 64,\n colorAttachments: [device.createTexture({format: 'rgba8unorm', type: GL.FLOAT, mipmaps: false})]\n });\n}\n\n// Increments the counter based on dataFilter_value\nexport function getModel(device: Device, shaderOptions: any, useFloatTarget: boolean): Model {\n shaderOptions.defines.NON_INSTANCED_MODEL = 1;\n if (useFloatTarget) {\n shaderOptions.defines.FLOAT_TARGET = 1;\n }\n\n return new Model(device, {\n id: 'data-filter-aggregation-model',\n vertexCount: 1,\n isInstanced: false,\n drawMode: GL.POINTS,\n vs: AGGREGATE_VS,\n fs: AGGREGATE_FS,\n ...shaderOptions\n });\n}\n\nexport const parameters = {\n blend: true,\n blendFunc: [GL.ONE, GL.ONE, GL.ONE, GL.ONE],\n blendEquation: [GL.FUNC_ADD, GL.FUNC_ADD],\n depthTest: false\n} as const;\n"],"file":"aggregator.js"}
|
|
@@ -13,8 +13,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
13
13
|
|
|
14
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
15
15
|
|
|
16
|
-
var vs = "\nuniform DATAFILTER_TYPE filter_min;\nuniform DATAFILTER_TYPE filter_softMin;\nuniform DATAFILTER_TYPE filter_softMax;\nuniform DATAFILTER_TYPE filter_max;\nuniform bool filter_useSoftMargin;\nuniform bool filter_enabled;\nuniform bool filter_transformSize;\n\n#ifdef NON_INSTANCED_MODEL\n #define DATAFILTER_ATTRIB filterValues\n #define DATAFILTER_ATTRIB_64LOW filterValues64Low\n#else\n #define DATAFILTER_ATTRIB instanceFilterValues\n #define DATAFILTER_ATTRIB_64LOW instanceFilterValues64Low\n#endif\n\
|
|
17
|
-
var fs = "\nuniform bool filter_transformColor;\
|
|
16
|
+
var vs = "\nuniform DATAFILTER_TYPE filter_min;\nuniform DATAFILTER_TYPE filter_softMin;\nuniform DATAFILTER_TYPE filter_softMax;\nuniform DATAFILTER_TYPE filter_max;\nuniform bool filter_useSoftMargin;\nuniform bool filter_enabled;\nuniform bool filter_transformSize;\n\n#ifdef NON_INSTANCED_MODEL\n #define DATAFILTER_ATTRIB filterValues\n #define DATAFILTER_ATTRIB_64LOW filterValues64Low\n#else\n #define DATAFILTER_ATTRIB instanceFilterValues\n #define DATAFILTER_ATTRIB_64LOW instanceFilterValues64Low\n#endif\n\nin DATAFILTER_TYPE DATAFILTER_ATTRIB;\n#ifdef DATAFILTER_DOUBLE\n in DATAFILTER_TYPE DATAFILTER_ATTRIB_64LOW;\n\n uniform DATAFILTER_TYPE filter_min64High;\n uniform DATAFILTER_TYPE filter_max64High;\n#endif\n\nout float dataFilter_value;\n\nfloat dataFilter_reduceValue(float value) {\n return value;\n}\nfloat dataFilter_reduceValue(vec2 value) {\n return min(value.x, value.y);\n}\nfloat dataFilter_reduceValue(vec3 value) {\n return min(min(value.x, value.y), value.z);\n}\nfloat dataFilter_reduceValue(vec4 value) {\n return min(min(value.x, value.y), min(value.z, value.w));\n}\nvoid dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax) {\n if (filter_enabled) {\n if (filter_useSoftMargin) {\n dataFilter_value = dataFilter_reduceValue(\n smoothstep(filter_min, filter_softMin, valueFromMin) *\n (1.0 - smoothstep(filter_softMax, filter_max, valueFromMax))\n );\n } else {\n dataFilter_value = dataFilter_reduceValue(\n step(filter_min, valueFromMin) * step(valueFromMax, filter_max)\n );\n }\n } else {\n dataFilter_value = 1.0;\n }\n}\n";
|
|
17
|
+
var fs = "\nuniform bool filter_transformColor;\nin float dataFilter_value;\n";
|
|
18
18
|
|
|
19
19
|
function getUniforms(opts) {
|
|
20
20
|
if (!opts || !('extensions' in opts)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/data-filter/shader-module.ts"],"names":["vs","fs","getUniforms","opts","filterRange","filterEnabled","filterTransformSize","filterTransformColor","filterSoftRange","Number","isFinite","filter_min","filter_softMin","filter_softMax","filter_max","map","r","filter_enabled","filter_useSoftMargin","Boolean","filter_transformSize","filter_transformColor","getUniforms64","uniforms","min64High","Math","fround","filter_min64High","max64High","filter_max64High","x","i","inject","shaderModule","name","shaderModule64"],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/data-filter/shader-module.ts"],"names":["vs","fs","getUniforms","opts","filterRange","filterEnabled","filterTransformSize","filterTransformColor","filterSoftRange","Number","isFinite","filter_min","filter_softMin","filter_softMax","filter_max","map","r","filter_enabled","filter_useSoftMargin","Boolean","filter_transformSize","filter_transformColor","getUniforms64","uniforms","min64High","Math","fround","filter_min64High","max64High","filter_max64High","x","i","inject","shaderModule","name","shaderModule64"],"mappings":"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","sourcesContent":["import type {ShaderModule} from '@luma.gl/shadertools';\nimport type {DataFilterExtensionProps} from './data-filter-extension';\n\n/*\n * data filter shader module\n */\nconst vs = `\nuniform DATAFILTER_TYPE filter_min;\nuniform DATAFILTER_TYPE filter_softMin;\nuniform DATAFILTER_TYPE filter_softMax;\nuniform DATAFILTER_TYPE filter_max;\nuniform bool filter_useSoftMargin;\nuniform bool filter_enabled;\nuniform bool filter_transformSize;\n\n#ifdef NON_INSTANCED_MODEL\n #define DATAFILTER_ATTRIB filterValues\n #define DATAFILTER_ATTRIB_64LOW filterValues64Low\n#else\n #define DATAFILTER_ATTRIB instanceFilterValues\n #define DATAFILTER_ATTRIB_64LOW instanceFilterValues64Low\n#endif\n\nin DATAFILTER_TYPE DATAFILTER_ATTRIB;\n#ifdef DATAFILTER_DOUBLE\n in DATAFILTER_TYPE DATAFILTER_ATTRIB_64LOW;\n\n uniform DATAFILTER_TYPE filter_min64High;\n uniform DATAFILTER_TYPE filter_max64High;\n#endif\n\nout float dataFilter_value;\n\nfloat dataFilter_reduceValue(float value) {\n return value;\n}\nfloat dataFilter_reduceValue(vec2 value) {\n return min(value.x, value.y);\n}\nfloat dataFilter_reduceValue(vec3 value) {\n return min(min(value.x, value.y), value.z);\n}\nfloat dataFilter_reduceValue(vec4 value) {\n return min(min(value.x, value.y), min(value.z, value.w));\n}\nvoid dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax) {\n if (filter_enabled) {\n if (filter_useSoftMargin) {\n dataFilter_value = dataFilter_reduceValue(\n smoothstep(filter_min, filter_softMin, valueFromMin) *\n (1.0 - smoothstep(filter_softMax, filter_max, valueFromMax))\n );\n } else {\n dataFilter_value = dataFilter_reduceValue(\n step(filter_min, valueFromMin) * step(valueFromMax, filter_max)\n );\n }\n } else {\n dataFilter_value = 1.0;\n }\n}\n`;\n\nconst fs = `\nuniform bool filter_transformColor;\nin float dataFilter_value;\n`;\n\ntype DataFilterModuleSettings = {\n extensions: any[]; // used to detect if layer props are present\n} & DataFilterExtensionProps;\n\n/* eslint-disable camelcase */\nfunction getUniforms(opts?: DataFilterModuleSettings | {}): Record<string, any> {\n if (!opts || !('extensions' in opts)) {\n return {};\n }\n const {\n filterRange = [-1, 1],\n filterEnabled = true,\n filterTransformSize = true,\n filterTransformColor = true\n } = opts;\n const filterSoftRange = opts.filterSoftRange || filterRange;\n\n return {\n ...(Number.isFinite(filterRange[0])\n ? {\n filter_min: filterRange[0],\n filter_softMin: filterSoftRange[0],\n filter_softMax: filterSoftRange[1],\n filter_max: filterRange[1]\n }\n : {\n filter_min: filterRange.map(r => r[0]),\n filter_softMin: filterSoftRange.map(r => r[0]),\n filter_softMax: filterSoftRange.map(r => r[1]),\n filter_max: filterRange.map(r => r[1])\n }),\n filter_enabled: filterEnabled,\n filter_useSoftMargin: Boolean(opts.filterSoftRange),\n filter_transformSize: filterEnabled && filterTransformSize,\n filter_transformColor: filterEnabled && filterTransformColor\n };\n}\n\nfunction getUniforms64(opts?: DataFilterModuleSettings | {}): Record<string, any> {\n if (!opts || !('extensions' in opts)) {\n return {};\n }\n const uniforms = getUniforms(opts);\n if (Number.isFinite(uniforms.filter_min)) {\n const min64High = Math.fround(uniforms.filter_min);\n uniforms.filter_min -= min64High;\n uniforms.filter_softMin -= min64High;\n uniforms.filter_min64High = min64High;\n\n const max64High = Math.fround(uniforms.filter_max);\n uniforms.filter_max -= max64High;\n uniforms.filter_softMax -= max64High;\n uniforms.filter_max64High = max64High;\n } else {\n const min64High = uniforms.filter_min.map(Math.fround);\n uniforms.filter_min = uniforms.filter_min.map((x, i) => x - min64High[i]);\n uniforms.filter_softMin = uniforms.filter_softMin.map((x, i) => x - min64High[i]);\n uniforms.filter_min64High = min64High;\n\n const max64High = uniforms.filter_max.map(Math.fround);\n uniforms.filter_max = uniforms.filter_max.map((x, i) => x - max64High[i]);\n uniforms.filter_softMax = uniforms.filter_softMax.map((x, i) => x - max64High[i]);\n uniforms.filter_max64High = max64High;\n }\n return uniforms;\n}\n\nconst inject = {\n 'vs:#main-start': `\n #ifdef DATAFILTER_DOUBLE\n dataFilter_setValue(\n DATAFILTER_ATTRIB - filter_min64High + DATAFILTER_ATTRIB_64LOW,\n DATAFILTER_ATTRIB - filter_max64High + DATAFILTER_ATTRIB_64LOW\n );\n #else\n dataFilter_setValue(DATAFILTER_ATTRIB, DATAFILTER_ATTRIB);\n #endif\n `,\n\n 'vs:#main-end': `\n if (dataFilter_value == 0.0) {\n gl_Position = vec4(0.);\n }\n `,\n\n 'vs:DECKGL_FILTER_SIZE': `\n if (filter_transformSize) {\n size = size * dataFilter_value;\n }\n `,\n\n 'fs:DECKGL_FILTER_COLOR': `\n if (dataFilter_value == 0.0) discard;\n if (filter_transformColor) {\n color.a *= dataFilter_value;\n }\n `\n};\n\nexport const shaderModule: ShaderModule<DataFilterModuleSettings> = {\n name: 'data-filter',\n vs,\n fs,\n inject,\n getUniforms\n};\n\nexport const shaderModule64: ShaderModule<DataFilterModuleSettings> = {\n name: 'data-filter-fp64',\n vs,\n fs,\n inject,\n getUniforms: getUniforms64\n};\n"],"file":"shader-module.js"}
|
|
@@ -7,12 +7,12 @@ exports.patternShaders = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _core = require("@deck.gl/core");
|
|
9
9
|
|
|
10
|
-
var patternVs = "\n#ifdef NON_INSTANCED_MODEL\n #define FILL_PATTERN_FRAME_ATTRIB fillPatternFrames\n #define FILL_PATTERN_SCALE_ATTRIB fillPatternScales\n #define FILL_PATTERN_OFFSET_ATTRIB fillPatternOffsets\n#else\n #define FILL_PATTERN_FRAME_ATTRIB instanceFillPatternFrames\n #define FILL_PATTERN_SCALE_ATTRIB instanceFillPatternScales\n #define FILL_PATTERN_OFFSET_ATTRIB instanceFillPatternOffsets\n#endif\n\
|
|
11
|
-
var patternFs = "\nuniform bool fill_patternEnabled;\nuniform bool fill_patternMask;\nuniform sampler2D fill_patternTexture;\nuniform vec2 fill_uvCoordinateOrigin;\nuniform vec2 fill_uvCoordinateOrigin64Low;\n\
|
|
10
|
+
var patternVs = "\n#ifdef NON_INSTANCED_MODEL\n #define FILL_PATTERN_FRAME_ATTRIB fillPatternFrames\n #define FILL_PATTERN_SCALE_ATTRIB fillPatternScales\n #define FILL_PATTERN_OFFSET_ATTRIB fillPatternOffsets\n#else\n #define FILL_PATTERN_FRAME_ATTRIB instanceFillPatternFrames\n #define FILL_PATTERN_SCALE_ATTRIB instanceFillPatternScales\n #define FILL_PATTERN_OFFSET_ATTRIB instanceFillPatternOffsets\n#endif\n\nin vec4 FILL_PATTERN_FRAME_ATTRIB;\nin float FILL_PATTERN_SCALE_ATTRIB;\nin vec2 FILL_PATTERN_OFFSET_ATTRIB;\n\nuniform bool fill_patternEnabled;\nuniform vec2 fill_patternTextureSize;\n\nout vec2 fill_uv;\nout vec4 fill_patternBounds;\nout vec4 fill_patternPlacement;\n";
|
|
11
|
+
var patternFs = "\nuniform bool fill_patternEnabled;\nuniform bool fill_patternMask;\nuniform sampler2D fill_patternTexture;\nuniform vec2 fill_uvCoordinateOrigin;\nuniform vec2 fill_uvCoordinateOrigin64Low;\n\nin vec4 fill_patternBounds;\nin vec4 fill_patternPlacement;\nin vec2 fill_uv;\n\nconst float FILL_UV_SCALE = 512.0 / 40000000.0;\n";
|
|
12
12
|
var inject = {
|
|
13
13
|
'vs:DECKGL_FILTER_GL_POSITION': "\n fill_uv = geometry.position.xy;\n ",
|
|
14
14
|
'vs:DECKGL_FILTER_COLOR': "\n if (fill_patternEnabled) {\n fill_patternBounds = FILL_PATTERN_FRAME_ATTRIB / vec4(fill_patternTextureSize, fill_patternTextureSize);\n fill_patternPlacement.xy = FILL_PATTERN_OFFSET_ATTRIB;\n fill_patternPlacement.zw = FILL_PATTERN_SCALE_ATTRIB * FILL_PATTERN_FRAME_ATTRIB.zw;\n }\n ",
|
|
15
|
-
'fs:DECKGL_FILTER_COLOR': "\n if (fill_patternEnabled) {\n vec2 scale = FILL_UV_SCALE * fill_patternPlacement.zw;\n vec2 patternUV = mod(mod(fill_uvCoordinateOrigin, scale) + fill_uvCoordinateOrigin64Low + fill_uv, scale) / scale;\n patternUV = mod(fill_patternPlacement.xy + patternUV, 1.0);\n\n vec2 texCoords = fill_patternBounds.xy + fill_patternBounds.zw * patternUV;\n\n vec4 patternColor =
|
|
15
|
+
'fs:DECKGL_FILTER_COLOR': "\n if (fill_patternEnabled) {\n vec2 scale = FILL_UV_SCALE * fill_patternPlacement.zw;\n vec2 patternUV = mod(mod(fill_uvCoordinateOrigin, scale) + fill_uvCoordinateOrigin64Low + fill_uv, scale) / scale;\n patternUV = mod(fill_patternPlacement.xy + patternUV, 1.0);\n\n vec2 texCoords = fill_patternBounds.xy + fill_patternBounds.zw * patternUV;\n\n vec4 patternColor = texture(fill_patternTexture, texCoords);\n color.a *= patternColor.a;\n if (!fill_patternMask) {\n color.rgb = patternColor.rgb;\n }\n }\n "
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
function getPatternUniforms(opts, uniforms) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fill-style/shaders.glsl.ts"],"names":["patternVs","patternFs","inject","getPatternUniforms","opts","uniforms","fillPatternTexture","fill_patternTexture","fill_patternTextureSize","width","height","fillPatternMask","fillPatternEnabled","coordinateOriginCommon","project_uCommonOrigin","coordinateOriginCommon64Low","fill_uvCoordinateOrigin","slice","fill_uvCoordinateOrigin64Low","fill_patternMask","fill_patternEnabled","patternShaders","name","vs","fs","dependencies","project","getUniforms"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/fill-style/shaders.glsl.ts"],"names":["patternVs","patternFs","inject","getPatternUniforms","opts","uniforms","fillPatternTexture","fill_patternTexture","fill_patternTextureSize","width","height","fillPatternMask","fillPatternEnabled","coordinateOriginCommon","project_uCommonOrigin","coordinateOriginCommon64Low","fill_uvCoordinateOrigin","slice","fill_uvCoordinateOrigin64Low","fill_patternMask","fill_patternEnabled","patternShaders","name","vs","fs","dependencies","project","getUniforms"],"mappings":";;;;;;;AACA;;AAQA,IAAMA,SAAS,wqBAAf;AAuBA,IAAMC,SAAS,yUAAf;AAcA,IAAMC,MAAM,GAAG;AACb,6EADa;AAKb,mVALa;AAab;AAba,CAAf;;AAyCA,SAASC,kBAAT,CACEC,IADF,EAEEC,QAFF,EAGuB;AACrB,MAAI,CAACD,IAAL,EAAW;AACT,WAAO,EAAP;AACD;;AACD,MAAI,wBAAwBA,IAA5B,EAAkC;AAChC,QAAOE,kBAAP,GAA6BF,IAA7B,CAAOE,kBAAP;AACA,WAAO;AACLC,MAAAA,mBAAmB,EAAED,kBADhB;AAELE,MAAAA,uBAAuB,EAAE,CAACF,kBAAkB,CAACG,KAApB,EAA2BH,kBAAkB,CAACI,MAA9C;AAFpB,KAAP;AAID;;AACD,MAAI,cAAcN,IAAlB,EAAwB;AACtB,gCAA4DA,IAA5D,CAAOO,eAAP;AAAA,QAAOA,eAAP,sCAAyB,IAAzB;AAAA,gCAA4DP,IAA5D,CAA+BQ,kBAA/B;AAAA,QAA+BA,kBAA/B,sCAAoD,IAApD;AACA,eAAwDP,QAAxD;AAAA,QAA8BQ,sBAA9B,QAAOC,qBAAP;AAEA,QAAMC,2BAA2B,GAAG,CAClC,uBAAYF,sBAAsB,CAAC,CAAD,CAAlC,CADkC,EAElC,uBAAYA,sBAAsB,CAAC,CAAD,CAAlC,CAFkC,CAApC;AAKA,WAAO;AACLG,MAAAA,uBAAuB,EAAEH,sBAAsB,CAACI,KAAvB,CAA6B,CAA7B,EAAgC,CAAhC,CADpB;AAELC,MAAAA,4BAA4B,EAAEH,2BAFzB;AAGLI,MAAAA,gBAAgB,EAAER,eAHb;AAILS,MAAAA,mBAAmB,EAAER;AAJhB,KAAP;AAMD;;AACD,SAAO,EAAP;AACD;;AAEM,IAAMS,cAAqD,GAAG;AACnEC,EAAAA,IAAI,EAAE,cAD6D;AAEnEC,EAAAA,EAAE,EAAEvB,SAF+D;AAGnEwB,EAAAA,EAAE,EAAEvB,SAH+D;AAInEC,EAAAA,MAAM,EAANA,MAJmE;AAKnEuB,EAAAA,YAAY,EAAE,CAACC,aAAD,CALqD;AAMnEC,EAAAA,WAAW,EAAExB;AANsD,CAA9D","sourcesContent":["import type {ShaderModule} from '@luma.gl/shadertools';\nimport {project, fp64LowPart} from '@deck.gl/core';\nimport type {Viewport, ProjectUniforms} from '@deck.gl/core';\n\nimport type {Texture} from '@luma.gl/core';\n\n/*\n * fill pattern shader module\n */\nconst patternVs = `\n#ifdef NON_INSTANCED_MODEL\n #define FILL_PATTERN_FRAME_ATTRIB fillPatternFrames\n #define FILL_PATTERN_SCALE_ATTRIB fillPatternScales\n #define FILL_PATTERN_OFFSET_ATTRIB fillPatternOffsets\n#else\n #define FILL_PATTERN_FRAME_ATTRIB instanceFillPatternFrames\n #define FILL_PATTERN_SCALE_ATTRIB instanceFillPatternScales\n #define FILL_PATTERN_OFFSET_ATTRIB instanceFillPatternOffsets\n#endif\n\nin vec4 FILL_PATTERN_FRAME_ATTRIB;\nin float FILL_PATTERN_SCALE_ATTRIB;\nin vec2 FILL_PATTERN_OFFSET_ATTRIB;\n\nuniform bool fill_patternEnabled;\nuniform vec2 fill_patternTextureSize;\n\nout vec2 fill_uv;\nout vec4 fill_patternBounds;\nout vec4 fill_patternPlacement;\n`;\n\nconst patternFs = `\nuniform bool fill_patternEnabled;\nuniform bool fill_patternMask;\nuniform sampler2D fill_patternTexture;\nuniform vec2 fill_uvCoordinateOrigin;\nuniform vec2 fill_uvCoordinateOrigin64Low;\n\nin vec4 fill_patternBounds;\nin vec4 fill_patternPlacement;\nin vec2 fill_uv;\n\nconst float FILL_UV_SCALE = 512.0 / 40000000.0;\n`;\n\nconst inject = {\n 'vs:DECKGL_FILTER_GL_POSITION': `\n fill_uv = geometry.position.xy;\n `,\n\n 'vs:DECKGL_FILTER_COLOR': `\n if (fill_patternEnabled) {\n fill_patternBounds = FILL_PATTERN_FRAME_ATTRIB / vec4(fill_patternTextureSize, fill_patternTextureSize);\n fill_patternPlacement.xy = FILL_PATTERN_OFFSET_ATTRIB;\n fill_patternPlacement.zw = FILL_PATTERN_SCALE_ATTRIB * FILL_PATTERN_FRAME_ATTRIB.zw;\n }\n `,\n\n 'fs:DECKGL_FILTER_COLOR': `\n if (fill_patternEnabled) {\n vec2 scale = FILL_UV_SCALE * fill_patternPlacement.zw;\n vec2 patternUV = mod(mod(fill_uvCoordinateOrigin, scale) + fill_uvCoordinateOrigin64Low + fill_uv, scale) / scale;\n patternUV = mod(fill_patternPlacement.xy + patternUV, 1.0);\n\n vec2 texCoords = fill_patternBounds.xy + fill_patternBounds.zw * patternUV;\n\n vec4 patternColor = texture(fill_patternTexture, texCoords);\n color.a *= patternColor.a;\n if (!fill_patternMask) {\n color.rgb = patternColor.rgb;\n }\n }\n `\n};\n\ntype FillStyleModuleSettings =\n | {\n viewport: Viewport;\n fillPatternEnabled?: boolean;\n fillPatternMask?: boolean;\n }\n | {\n fillPatternTexture: Texture;\n };\n\n/* eslint-disable camelcase */\nfunction getPatternUniforms(\n opts: FillStyleModuleSettings | {},\n uniforms: Record<string, any>\n): Record<string, any> {\n if (!opts) {\n return {};\n }\n if ('fillPatternTexture' in opts) {\n const {fillPatternTexture} = opts;\n return {\n fill_patternTexture: fillPatternTexture,\n fill_patternTextureSize: [fillPatternTexture.width, fillPatternTexture.height]\n };\n }\n if ('viewport' in opts) {\n const {fillPatternMask = true, fillPatternEnabled = true} = opts;\n const {project_uCommonOrigin: coordinateOriginCommon} = uniforms as ProjectUniforms;\n\n const coordinateOriginCommon64Low = [\n fp64LowPart(coordinateOriginCommon[0]),\n fp64LowPart(coordinateOriginCommon[1])\n ];\n\n return {\n fill_uvCoordinateOrigin: coordinateOriginCommon.slice(0, 2),\n fill_uvCoordinateOrigin64Low: coordinateOriginCommon64Low,\n fill_patternMask: fillPatternMask,\n fill_patternEnabled: fillPatternEnabled\n };\n }\n return {};\n}\n\nexport const patternShaders: ShaderModule<FillStyleModuleSettings> = {\n name: 'fill-pattern',\n vs: patternVs,\n fs: patternFs,\n inject,\n dependencies: [project],\n getUniforms: getPatternUniforms\n};\n"],"file":"shaders.glsl.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fp64/project64.ts"],"names":["fp64ify","fp64","fp64ifyMatrix4","name","dependencies","project","vs","project64Shader","getUniforms","getMemoizedUniforms","calculateUniforms","opts","viewport","viewProjectionMatrix","scale","glViewProjectionMatrixFP64","scaleFP64","project_uViewProjectionMatrixFP64","project64_uViewProjectionMatrix","project64_uScale"],"mappings":";;;;;;;;;AAqBA;;
|
|
1
|
+
{"version":3,"sources":["../../../src/fp64/project64.ts"],"names":["fp64ify","fp64","fp64ifyMatrix4","name","dependencies","project","vs","project64Shader","getUniforms","getMemoizedUniforms","calculateUniforms","opts","viewport","viewProjectionMatrix","scale","glViewProjectionMatrixFP64","scaleFP64","project_uViewProjectionMatrixFP64","project64_uViewProjectionMatrix","project64_uScale"],"mappings":";;;;;;;;;AAqBA;;AAGA;;AAGA;;AAJA,IAAOA,OAAP,GAAkCC,iBAAlC,CAAOD,OAAP;AAAA,IAAgBE,cAAhB,GAAkCD,iBAAlC,CAAgBC,cAAhB;eAUe;AACbC,EAAAA,IAAI,EAAE,WADO;AAEbC,EAAAA,YAAY,EAAE,CAACC,aAAD,EAAUJ,iBAAV,CAFD;AAGbK,EAAAA,EAAE,EAAEC,gBAHS;AAIbC,EAAAA,WAAW,EAAXA;AAJa,C;;AAUf,IAAMC,mBAAmB,GAAG,oBAAQC,iBAAR,CAA5B;;AAEA,SAASF,WAAT,CAAqBG,IAArB,EAA+E;AAC7E,MAAIA,IAAI,IAAI,cAAcA,IAA1B,EAAgC;AAC9B,yBAAsCA,IAAI,CAACC,QAA3C;AAAA,QAAOC,oBAAP,kBAAOA,oBAAP;AAAA,QAA6BC,KAA7B,kBAA6BA,KAA7B;AAEA,WAAOL,mBAAmB,CAAC;AAACI,MAAAA,oBAAoB,EAApBA,oBAAD;AAAuBC,MAAAA,KAAK,EAALA;AAAvB,KAAD,CAA1B;AACD;;AACD,SAAO,EAAP;AACD;;AAED,SAASJ,iBAAT,OAMG;AAAA,MALDG,oBAKC,QALDA,oBAKC;AAAA,MAJDC,KAIC,QAJDA,KAIC;AACD,MAAMC,0BAA0B,GAAGb,cAAc,CAACW,oBAAD,CAAjD;AACA,MAAMG,SAAS,GAAGhB,OAAO,CAACc,KAAD,CAAzB;AAEA,SAAO;AACLG,IAAAA,iCAAiC,EAAEF,0BAD9B;AAELG,IAAAA,+BAA+B,EAAEH,0BAF5B;AAGLI,IAAAA,gBAAgB,EAAEH;AAHb,GAAP;AAKD","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\n/* eslint-disable camelcase */\nimport {fp64} from '@luma.gl/shadertools';\nimport type {ShaderModule} from '@luma.gl/shadertools';\nconst {fp64ify, fp64ifyMatrix4} = fp64;\nimport {project, _memoize as memoize} from '@deck.gl/core';\n\nimport type {Viewport} from '@deck.gl/core';\nimport project64Shader from './project64.glsl';\n\ntype Project64ModuleSettings = {\n viewport: Viewport;\n};\n\nexport default {\n name: 'project64',\n dependencies: [project, fp64],\n vs: project64Shader,\n getUniforms\n} as ShaderModule<Project64ModuleSettings>;\n\n// TODO - this module should calculate the 64 bit uniforms\n// It is currently done by project to minimize duplicated work\n\nconst getMemoizedUniforms = memoize(calculateUniforms);\n\nfunction getUniforms(opts?: Project64ModuleSettings | {}): Record<string, any> {\n if (opts && 'viewport' in opts) {\n const {viewProjectionMatrix, scale} = opts.viewport;\n // We only need to update fp64 uniforms if fp32 projection is being updated\n return getMemoizedUniforms({viewProjectionMatrix, scale});\n }\n return {};\n}\n\nfunction calculateUniforms({\n viewProjectionMatrix,\n scale\n}: {\n viewProjectionMatrix: number[];\n scale: number;\n}) {\n const glViewProjectionMatrixFP64 = fp64ifyMatrix4(viewProjectionMatrix);\n const scaleFP64 = fp64ify(scale);\n\n return {\n project_uViewProjectionMatrixFP64: glViewProjectionMatrixFP64,\n project64_uViewProjectionMatrix: glViewProjectionMatrixFP64,\n project64_uScale: scaleFP64\n };\n}\n"],"file":"project64.js"}
|
|
@@ -8,12 +8,12 @@ exports.default = void 0;
|
|
|
8
8
|
var _core = require("@deck.gl/core");
|
|
9
9
|
|
|
10
10
|
var vs = "\nuniform vec4 mask_bounds;\nuniform bool mask_maskByInstance;\nvec2 mask_getCoords(vec4 position) {\n return (position.xy - mask_bounds.xy) / (mask_bounds.zw - mask_bounds.xy);\n}\n";
|
|
11
|
-
var fs = "\nuniform sampler2D mask_texture;\nuniform int mask_channel;\nuniform bool mask_enabled;\nuniform bool mask_inverted;\nbool mask_isInBounds(vec2 texCoords) {\n if (!mask_enabled) {\n return true;\n }\n vec4 maskColor =
|
|
11
|
+
var fs = "\nuniform sampler2D mask_texture;\nuniform int mask_channel;\nuniform bool mask_enabled;\nuniform bool mask_inverted;\nbool mask_isInBounds(vec2 texCoords) {\n if (!mask_enabled) {\n return true;\n }\n vec4 maskColor = texture(mask_texture, texCoords);\n float maskValue = 1.0;\n if (mask_channel == 0) {\n maskValue = maskColor.r;\n } else if (mask_channel == 1) {\n maskValue = maskColor.g;\n } else if (mask_channel == 2) {\n maskValue = maskColor.b;\n } else if (mask_channel == 3) {\n maskValue = maskColor.a;\n }\n\n if (mask_inverted) {\n return maskValue >= 0.5;\n } else {\n return maskValue < 0.5;\n }\n}\n";
|
|
12
12
|
var inject = {
|
|
13
|
-
'vs:#decl': "\
|
|
13
|
+
'vs:#decl': "\nout vec2 mask_texCoords;\n",
|
|
14
14
|
'vs:#main-end': "\n vec4 mask_common_position;\n if (mask_maskByInstance) {\n mask_common_position = project_position(vec4(geometry.worldPosition, 1.0));\n } else {\n mask_common_position = geometry.position;\n }\n mask_texCoords = mask_getCoords(mask_common_position);\n",
|
|
15
|
-
'fs:#decl': "\
|
|
16
|
-
'fs:#main-start': "\n if (mask_enabled) {\n bool mask = mask_isInBounds(mask_texCoords);\n\n // Debug: show extent of render target\n //
|
|
15
|
+
'fs:#decl': "\nin vec2 mask_texCoords;\n",
|
|
16
|
+
'fs:#main-start': "\n if (mask_enabled) {\n bool mask = mask_isInBounds(mask_texCoords);\n\n // Debug: show extent of render target\n // fragColor = vec4(mask_texCoords, 0.0, 1.0);\n fragColor = texture(mask_texture, mask_texCoords);\n\n if (!mask) discard;\n }\n"
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
var getMaskUniforms = function getMaskUniforms(opts) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mask/shader-module.ts"],"names":["vs","fs","inject","getMaskUniforms","opts","mask_texture","maskMap","name","dependencies","project","getUniforms"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/mask/shader-module.ts"],"names":["vs","fs","inject","getMaskUniforms","opts","mask_texture","maskMap","name","dependencies","project","getUniforms"],"mappings":";;;;;;;AACA;;AAGA,IAAMA,EAAE,4LAAR;AAQA,IAAMC,EAAE,8oBAAR;AA6BA,IAAMC,MAAM,GAAG;AACb,4CADa;AAIb,oSAJa;AAab,2CAba;AAgBb;AAhBa,CAAf;;AAkCA,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAACC,IAAD,EAAyD;AAC/E,MAAIA,IAAI,IAAI,aAAaA,IAAzB,EAA+B;AAC7B,WAAO;AACLC,MAAAA,YAAY,EAAED,IAAI,CAACE;AADd,KAAP;AAGD;;AACD,SAAO,EAAP;AACD,CAPD;;eASe;AACbC,EAAAA,IAAI,EAAE,MADO;AAEbC,EAAAA,YAAY,EAAE,CAACC,aAAD,CAFD;AAGbT,EAAAA,EAAE,EAAFA,EAHa;AAIbC,EAAAA,EAAE,EAAFA,EAJa;AAKbC,EAAAA,MAAM,EAANA,MALa;AAMbQ,EAAAA,WAAW,EAAEP;AANA,C","sourcesContent":["import type {ShaderModule} from '@luma.gl/shadertools';\nimport {project} from '@deck.gl/core';\nimport type {Texture} from '@luma.gl/core';\n\nconst vs = `\nuniform vec4 mask_bounds;\nuniform bool mask_maskByInstance;\nvec2 mask_getCoords(vec4 position) {\n return (position.xy - mask_bounds.xy) / (mask_bounds.zw - mask_bounds.xy);\n}\n`;\n\nconst fs = `\nuniform sampler2D mask_texture;\nuniform int mask_channel;\nuniform bool mask_enabled;\nuniform bool mask_inverted;\nbool mask_isInBounds(vec2 texCoords) {\n if (!mask_enabled) {\n return true;\n }\n vec4 maskColor = texture(mask_texture, texCoords);\n float maskValue = 1.0;\n if (mask_channel == 0) {\n maskValue = maskColor.r;\n } else if (mask_channel == 1) {\n maskValue = maskColor.g;\n } else if (mask_channel == 2) {\n maskValue = maskColor.b;\n } else if (mask_channel == 3) {\n maskValue = maskColor.a;\n }\n\n if (mask_inverted) {\n return maskValue >= 0.5;\n } else {\n return maskValue < 0.5;\n }\n}\n`;\n\nconst inject = {\n 'vs:#decl': `\nout vec2 mask_texCoords;\n`,\n 'vs:#main-end': `\n vec4 mask_common_position;\n if (mask_maskByInstance) {\n mask_common_position = project_position(vec4(geometry.worldPosition, 1.0));\n } else {\n mask_common_position = geometry.position;\n }\n mask_texCoords = mask_getCoords(mask_common_position);\n`,\n 'fs:#decl': `\nin vec2 mask_texCoords;\n`,\n 'fs:#main-start': `\n if (mask_enabled) {\n bool mask = mask_isInBounds(mask_texCoords);\n\n // Debug: show extent of render target\n // fragColor = vec4(mask_texCoords, 0.0, 1.0);\n fragColor = texture(mask_texture, mask_texCoords);\n\n if (!mask) discard;\n }\n`\n};\n\ntype MaskModuleSettings = {\n maskMap?: Texture;\n};\n\n/* eslint-disable camelcase */\nconst getMaskUniforms = (opts?: MaskModuleSettings | {}): Record<string, any> => {\n if (opts && 'maskMap' in opts) {\n return {\n mask_texture: opts.maskMap\n };\n }\n return {};\n};\n\nexport default {\n name: 'mask',\n dependencies: [project],\n vs,\n fs,\n inject,\n getUniforms: getMaskUniforms\n} as ShaderModule<MaskModuleSettings>;\n"],"file":"shader-module.js"}
|
|
@@ -6,16 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.offsetShaders = exports.dashShaders = void 0;
|
|
7
7
|
var dashShaders = {
|
|
8
8
|
inject: {
|
|
9
|
-
'vs:#decl': "\
|
|
9
|
+
'vs:#decl': "\nin vec2 instanceDashArrays;\nin float instanceDashOffsets;\nout vec2 vDashArray;\nout float vDashOffset;\n",
|
|
10
10
|
'vs:#main-end': "\nvDashArray = instanceDashArrays;\nvDashOffset = instanceDashOffsets / width.x;\n",
|
|
11
|
-
'fs:#decl': "\nuniform float dashAlignMode;\nuniform float capType;\nuniform bool dashGapPickable;\
|
|
12
|
-
'fs:#main-start': "\n float solidLength = vDashArray.x;\n float gapLength = vDashArray.y;\n float unitLength = solidLength + gapLength;\n\n float offset;\n\n if (unitLength > 0.0) {\n if (dashAlignMode == 0.0) {\n offset = vDashOffset;\n } else {\n unitLength = vPathLength / round(vPathLength / unitLength);\n offset = solidLength / 2.0;\n }\n\n float unitOffset = mod(vPathPosition.y + offset, unitLength);\n\n if (gapLength > 0.0 && unitOffset > solidLength) {\n if (capType <= 0.5) {\n if (!(dashGapPickable &&
|
|
11
|
+
'fs:#decl': "\nuniform float dashAlignMode;\nuniform float capType;\nuniform bool dashGapPickable;\nin vec2 vDashArray;\nin float vDashOffset;\n",
|
|
12
|
+
'fs:#main-start': "\n float solidLength = vDashArray.x;\n float gapLength = vDashArray.y;\n float unitLength = solidLength + gapLength;\n\n float offset;\n\n if (unitLength > 0.0) {\n if (dashAlignMode == 0.0) {\n offset = vDashOffset;\n } else {\n unitLength = vPathLength / round(vPathLength / unitLength);\n offset = solidLength / 2.0;\n }\n\n float unitOffset = mod(vPathPosition.y + offset, unitLength);\n\n if (gapLength > 0.0 && unitOffset > solidLength) {\n if (capType <= 0.5) {\n if (!(dashGapPickable && bool(picking.isActive))) {\n discard;\n }\n } else {\n float distToEnd = length(vec2(\n min(unitOffset - solidLength, unitLength - unitOffset),\n vPathPosition.x\n ));\n if (distToEnd > 1.0) {\n if (!(dashGapPickable && bool(picking.isActive))) {\n discard;\n }\n }\n }\n }\n }\n"
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
exports.dashShaders = dashShaders;
|
|
16
16
|
var offsetShaders = {
|
|
17
17
|
inject: {
|
|
18
|
-
'vs:#decl': "\
|
|
18
|
+
'vs:#decl': "\nin float instanceOffsets;\n",
|
|
19
19
|
'vs:DECKGL_FILTER_SIZE': "\n float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;\n size *= offsetWidth;\n",
|
|
20
20
|
'vs:#main-end': "\n float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;\n float offsetDir = sign(instanceOffsets);\n vPathPosition.x = (vPathPosition.x + offsetDir) * offsetWidth - offsetDir;\n vPathPosition.y *= offsetWidth;\n vPathLength *= offsetWidth;\n",
|
|
21
21
|
'fs:#main-start': "\n float isInside;\n isInside = step(-1.0, vPathPosition.x) * step(vPathPosition.x, 1.0);\n if (isInside == 0.0) {\n discard;\n }\n"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/path-style/shaders.glsl.ts"],"names":["dashShaders","inject","offsetShaders"],"mappings":";;;;;;AAAO,IAAMA,WAAW,GAAG;AACzBC,EAAAA,MAAM,EAAE;AACN,
|
|
1
|
+
{"version":3,"sources":["../../../src/path-style/shaders.glsl.ts"],"names":["dashShaders","inject","offsetShaders"],"mappings":";;;;;;AAAO,IAAMA,WAAW,GAAG;AACzBC,EAAAA,MAAM,EAAE;AACN,8HADM;AAQN,wGARM;AAaN,qJAbM;AA6BN;AA7BM;AADiB,CAApB;;AAsEA,IAAMC,aAAa,GAAG;AAC3BD,EAAAA,MAAM,EAAE;AACN,+CADM;AAIN,kHAJM;AAQN,6QARM;AAeN;AAfM;AADmB,CAAtB","sourcesContent":["export const dashShaders = {\n inject: {\n 'vs:#decl': `\nin vec2 instanceDashArrays;\nin float instanceDashOffsets;\nout vec2 vDashArray;\nout float vDashOffset;\n`,\n\n 'vs:#main-end': `\nvDashArray = instanceDashArrays;\nvDashOffset = instanceDashOffsets / width.x;\n`,\n\n 'fs:#decl': `\nuniform float dashAlignMode;\nuniform float capType;\nuniform bool dashGapPickable;\nin vec2 vDashArray;\nin float vDashOffset;\n`,\n\n // if given position is in the gap part of the dashed line\n // dashArray.x: solid stroke length, relative to width\n // dashArray.y: gap length, relative to width\n // alignMode:\n // 0 - no adjustment\n // o---- ---- ---- ---- o---- -o---- ---- o\n // 1 - stretch to fit, draw half dash at each end for nicer joints\n // o-- ---- ---- ---- --o-- --o-- ---- --o\n 'fs:#main-start': `\n float solidLength = vDashArray.x;\n float gapLength = vDashArray.y;\n float unitLength = solidLength + gapLength;\n\n float offset;\n\n if (unitLength > 0.0) {\n if (dashAlignMode == 0.0) {\n offset = vDashOffset;\n } else {\n unitLength = vPathLength / round(vPathLength / unitLength);\n offset = solidLength / 2.0;\n }\n\n float unitOffset = mod(vPathPosition.y + offset, unitLength);\n\n if (gapLength > 0.0 && unitOffset > solidLength) {\n if (capType <= 0.5) {\n if (!(dashGapPickable && bool(picking.isActive))) {\n discard;\n }\n } else {\n // caps are rounded, test the distance to solid ends\n float distToEnd = length(vec2(\n min(unitOffset - solidLength, unitLength - unitOffset),\n vPathPosition.x\n ));\n if (distToEnd > 1.0) {\n if (!(dashGapPickable && bool(picking.isActive))) {\n discard;\n }\n }\n }\n }\n }\n`\n }\n};\n\nexport const offsetShaders = {\n inject: {\n 'vs:#decl': `\nin float instanceOffsets;\n`,\n 'vs:DECKGL_FILTER_SIZE': `\n float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;\n size *= offsetWidth;\n`,\n 'vs:#main-end': `\n float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;\n float offsetDir = sign(instanceOffsets);\n vPathPosition.x = (vPathPosition.x + offsetDir) * offsetWidth - offsetDir;\n vPathPosition.y *= offsetWidth;\n vPathLength *= offsetWidth;\n`,\n 'fs:#main-start': `\n float isInside;\n isInside = step(-1.0, vPathPosition.x) * step(vPathPosition.x, 1.0);\n if (isInside == 0.0) {\n discard;\n }\n`\n }\n};\n"],"file":"shaders.glsl.js"}
|
|
@@ -23,12 +23,12 @@ var terrainModule = {
|
|
|
23
23
|
name: 'terrain',
|
|
24
24
|
dependencies: [_core.project],
|
|
25
25
|
inject: {
|
|
26
|
-
'vs:#decl': "\nuniform float terrain_mode;\nuniform sampler2D terrain_map;\nuniform vec4 terrain_bounds;\
|
|
26
|
+
'vs:#decl': "\nuniform float terrain_mode;\nuniform sampler2D terrain_map;\nuniform vec4 terrain_bounds;\nout vec3 commonPos;\n".concat(TERRAIN_MODE_CONSTANTS, "\n "),
|
|
27
27
|
'vs:#main-start': "\nif (terrain_mode == TERRAIN_MODE_SKIP) {\n gl_Position = vec4(0.0);\n return;\n}\n",
|
|
28
|
-
'vs:DECKGL_FILTER_GL_POSITION': "\ncommonPos = geometry.position.xyz;\nif (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {\n vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;\n position = vec4(texCoords * 2.0 - 1.0, 0.0, 1.0);\n commonPos.z += project_uCommonOrigin.z;\n}\nif (terrain_mode == TERRAIN_MODE_USE_HEIGHT_MAP) {\n vec3 anchor = geometry.worldPosition;\n anchor.z = 0.0;\n vec3 anchorCommon = project_position(anchor);\n vec2 texCoords = (anchorCommon.xy - terrain_bounds.xy) / terrain_bounds.zw;\n if (texCoords.x >= 0.0 && texCoords.y >= 0.0 && texCoords.x <= 1.0 && texCoords.y <= 1.0) {\n float terrainZ =
|
|
29
|
-
'fs:#decl': "\nuniform float terrain_mode;\nuniform sampler2D terrain_map;\nuniform vec4 terrain_bounds;\
|
|
30
|
-
'fs:#main-start': "\nif (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {\n
|
|
31
|
-
'fs:DECKGL_FILTER_COLOR': "\nif ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY)) {\n vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;\n vec4 pixel =
|
|
28
|
+
'vs:DECKGL_FILTER_GL_POSITION': "\ncommonPos = geometry.position.xyz;\nif (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {\n vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;\n position = vec4(texCoords * 2.0 - 1.0, 0.0, 1.0);\n commonPos.z += project_uCommonOrigin.z;\n}\nif (terrain_mode == TERRAIN_MODE_USE_HEIGHT_MAP) {\n vec3 anchor = geometry.worldPosition;\n anchor.z = 0.0;\n vec3 anchorCommon = project_position(anchor);\n vec2 texCoords = (anchorCommon.xy - terrain_bounds.xy) / terrain_bounds.zw;\n if (texCoords.x >= 0.0 && texCoords.y >= 0.0 && texCoords.x <= 1.0 && texCoords.y <= 1.0) {\n float terrainZ = texture(terrain_map, texCoords).r;\n geometry.position.z += terrainZ;\n position = project_common_position_to_clipspace(geometry.position);\n }\n}\n ",
|
|
29
|
+
'fs:#decl': "\nuniform float terrain_mode;\nuniform sampler2D terrain_map;\nuniform vec4 terrain_bounds;\nin vec3 commonPos;\n".concat(TERRAIN_MODE_CONSTANTS, "\n "),
|
|
30
|
+
'fs:#main-start': "\nif (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {\n fragColor = vec4(commonPos.z, 0.0, 0.0, 1.0);\n return;\n}\n ",
|
|
31
|
+
'fs:DECKGL_FILTER_COLOR': "\nif ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY)) {\n vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;\n vec4 pixel = texture(terrain_map, texCoords);\n if (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY) {\n color = pixel;\n } else {\n // pixel is premultiplied\n color = pixel + color * (1.0 - pixel.a);\n }\n return;\n}\n "
|
|
32
32
|
},
|
|
33
33
|
getUniforms: function getUniforms() {
|
|
34
34
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -55,7 +55,9 @@ var terrainModule = {
|
|
|
55
55
|
sampler = heightMap;
|
|
56
56
|
bounds = heightMapBounds;
|
|
57
57
|
} else if (terrainCover) {
|
|
58
|
-
var
|
|
58
|
+
var _opts$picking;
|
|
59
|
+
|
|
60
|
+
var isPicking = (_opts$picking = opts.picking) === null || _opts$picking === void 0 ? void 0 : _opts$picking.isActive;
|
|
59
61
|
sampler = isPicking ? terrainCover.getPickingFramebuffer() : terrainCover.getRenderFramebuffer();
|
|
60
62
|
|
|
61
63
|
if (isPicking) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/terrain/shader-module.ts"],"names":["TERRAIN_MODE","NONE","WRITE_HEIGHT_MAP","USE_HEIGHT_MAP","USE_COVER","USE_COVER_ONLY","SKIP","TERRAIN_MODE_CONSTANTS","Object","keys","map","key","join","terrainModule","name","dependencies","project","inject","getUniforms","opts","uniforms","drawToTerrainHeightMap","heightMap","heightMapBounds","dummyHeightMap","terrainCover","useTerrainHeightMap","terrainSkipRender","project_uCommonOrigin","mode","sampler","bounds","isPicking","
|
|
1
|
+
{"version":3,"sources":["../../../src/terrain/shader-module.ts"],"names":["TERRAIN_MODE","NONE","WRITE_HEIGHT_MAP","USE_HEIGHT_MAP","USE_COVER","USE_COVER_ONLY","SKIP","TERRAIN_MODE_CONSTANTS","Object","keys","map","key","join","terrainModule","name","dependencies","project","inject","getUniforms","opts","uniforms","drawToTerrainHeightMap","heightMap","heightMapBounds","dummyHeightMap","terrainCover","useTerrainHeightMap","terrainSkipRender","project_uCommonOrigin","mode","sampler","bounds","isPicking","picking","isActive","getPickingFramebuffer","getRenderFramebuffer","terrain_mode","terrain_map","terrain_bounds"],"mappings":"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","sourcesContent":["/* eslint-disable camelcase */\n\nimport type {ShaderModule} from '@luma.gl/shadertools';\nimport {project} from '@deck.gl/core';\n\nimport type {Texture} from '@luma.gl/core';\nimport type {Bounds} from '../utils/projection-utils';\nimport type {TerrainCover} from './terrain-cover';\n\n/** Module parameters expected by the terrain shader module */\nexport type TerrainModuleSettings = {\n picking: {isActive?: boolean};\n heightMap: Texture | null;\n heightMapBounds?: Bounds | null;\n dummyHeightMap: Texture;\n terrainCover?: TerrainCover | null;\n drawToTerrainHeightMap?: boolean;\n useTerrainHeightMap?: boolean;\n terrainSkipRender?: boolean;\n};\n\n/** A model can have one of the following modes */\nexport const TERRAIN_MODE = {\n NONE: 0,\n /** A terrain layer rendering encoded ground elevation into the height map */\n WRITE_HEIGHT_MAP: 1,\n /** An offset layer reading encoded ground elevation from the height map */\n USE_HEIGHT_MAP: 2,\n /** A terrain layer rendering to screen, using the cover fbo overlaid with its own texture */\n USE_COVER: 3,\n /** A terrain layer rendering to screen, using the cover fbo as texture */\n USE_COVER_ONLY: 4,\n /** Draped layer is rendered into a texture, and never to screen */\n SKIP: 5\n};\n\nconst TERRAIN_MODE_CONSTANTS = Object.keys(TERRAIN_MODE)\n .map(key => `const float TERRAIN_MODE_${key} = ${TERRAIN_MODE[key]}.0;`)\n .join('\\n');\n\n// @ts-expect-error\nexport const terrainModule = {\n name: 'terrain',\n dependencies: [project],\n inject: {\n 'vs:#decl': `\nuniform float terrain_mode;\nuniform sampler2D terrain_map;\nuniform vec4 terrain_bounds;\nout vec3 commonPos;\n${TERRAIN_MODE_CONSTANTS}\n `,\n 'vs:#main-start': `\nif (terrain_mode == TERRAIN_MODE_SKIP) {\n gl_Position = vec4(0.0);\n return;\n}\n`,\n 'vs:DECKGL_FILTER_GL_POSITION': `\ncommonPos = geometry.position.xyz;\nif (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {\n vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;\n position = vec4(texCoords * 2.0 - 1.0, 0.0, 1.0);\n commonPos.z += project_uCommonOrigin.z;\n}\nif (terrain_mode == TERRAIN_MODE_USE_HEIGHT_MAP) {\n vec3 anchor = geometry.worldPosition;\n anchor.z = 0.0;\n vec3 anchorCommon = project_position(anchor);\n vec2 texCoords = (anchorCommon.xy - terrain_bounds.xy) / terrain_bounds.zw;\n if (texCoords.x >= 0.0 && texCoords.y >= 0.0 && texCoords.x <= 1.0 && texCoords.y <= 1.0) {\n float terrainZ = texture(terrain_map, texCoords).r;\n geometry.position.z += terrainZ;\n position = project_common_position_to_clipspace(geometry.position);\n }\n}\n `,\n 'fs:#decl': `\nuniform float terrain_mode;\nuniform sampler2D terrain_map;\nuniform vec4 terrain_bounds;\nin vec3 commonPos;\n${TERRAIN_MODE_CONSTANTS}\n `,\n 'fs:#main-start': `\nif (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {\n fragColor = vec4(commonPos.z, 0.0, 0.0, 1.0);\n return;\n}\n `,\n 'fs:DECKGL_FILTER_COLOR': `\nif ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY)) {\n vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;\n vec4 pixel = texture(terrain_map, texCoords);\n if (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY) {\n color = pixel;\n } else {\n // pixel is premultiplied\n color = pixel + color * (1.0 - pixel.a);\n }\n return;\n}\n `\n },\n // eslint-disable-next-line complexity\n getUniforms: (opts: Partial<TerrainModuleSettings> = {}, uniforms) => {\n if ('dummyHeightMap' in opts) {\n const {\n drawToTerrainHeightMap,\n heightMap,\n heightMapBounds,\n dummyHeightMap,\n terrainCover,\n useTerrainHeightMap,\n terrainSkipRender\n } = opts;\n const {project_uCommonOrigin} = uniforms;\n\n let mode: number = terrainSkipRender ? TERRAIN_MODE.SKIP : TERRAIN_MODE.NONE;\n // height map if case USE_HEIGHT_MAP, terrain cover if USE_COVER, otherwise empty\n let sampler = dummyHeightMap as Texture;\n // height map bounds if case USE_HEIGHT_MAP, terrain cover bounds if USE_COVER, otherwise null\n let bounds: number[] | null = null;\n if (drawToTerrainHeightMap) {\n mode = TERRAIN_MODE.WRITE_HEIGHT_MAP;\n bounds = heightMapBounds!;\n } else if (useTerrainHeightMap && heightMap) {\n mode = TERRAIN_MODE.USE_HEIGHT_MAP;\n sampler = heightMap;\n bounds = heightMapBounds!;\n } else if (terrainCover) {\n // This is a terrain layer\n const isPicking = opts.picking?.isActive;\n // @ts-expect-error\n sampler = isPicking\n ? terrainCover.getPickingFramebuffer()\n : terrainCover.getRenderFramebuffer();\n if (isPicking) {\n // Never render the layer itself in picking pass\n mode = TERRAIN_MODE.SKIP;\n }\n if (sampler) {\n mode = mode === TERRAIN_MODE.SKIP ? TERRAIN_MODE.USE_COVER_ONLY : TERRAIN_MODE.USE_COVER;\n bounds = terrainCover.bounds;\n } else {\n sampler = dummyHeightMap!;\n }\n }\n\n /* eslint-disable camelcase */\n return {\n terrain_mode: mode,\n terrain_map: sampler,\n // Convert bounds to the common space, as [minX, minY, width, height]\n terrain_bounds: bounds\n ? [\n bounds[0] - project_uCommonOrigin[0],\n bounds[1] - project_uCommonOrigin[1],\n bounds[2] - bounds[0],\n bounds[3] - bounds[1]\n ]\n : [0, 0, 0, 0]\n };\n }\n return null;\n }\n} as ShaderModule<TerrainModuleSettings>;\n"],"file":"shader-module.js"}
|
|
@@ -6,12 +6,12 @@ const vs = `
|
|
|
6
6
|
uniform float brushing_radius;
|
|
7
7
|
|
|
8
8
|
#ifdef NON_INSTANCED_MODEL
|
|
9
|
-
|
|
9
|
+
in vec2 brushingTargets;
|
|
10
10
|
#else
|
|
11
|
-
|
|
11
|
+
in vec2 instanceBrushingTargets;
|
|
12
12
|
#endif
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
out float brushing_isVisible;
|
|
15
15
|
|
|
16
16
|
bool brushing_isPointInRange(vec2 position) {
|
|
17
17
|
if (!brushing_enabled) {
|
|
@@ -34,7 +34,7 @@ const vs = `
|
|
|
34
34
|
`;
|
|
35
35
|
const fs = `
|
|
36
36
|
uniform bool brushing_enabled;
|
|
37
|
-
|
|
37
|
+
in float brushing_isVisible;
|
|
38
38
|
`;
|
|
39
39
|
const TARGET = {
|
|
40
40
|
source: 0,
|