@deck.gl/extensions 8.10.0-alpha.4 → 8.10.0-alpha.5

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.
Files changed (91) hide show
  1. package/dist/dist.dev.js +38 -660
  2. package/dist/es5/brushing/brushing-extension.js +48 -54
  3. package/dist/es5/brushing/brushing-extension.js.map +1 -1
  4. package/dist/es5/clip/clip-extension.js +32 -37
  5. package/dist/es5/clip/clip-extension.js.map +1 -1
  6. package/dist/es5/collision-filter/collision-filter-effect.js +217 -225
  7. package/dist/es5/collision-filter/collision-filter-effect.js.map +1 -1
  8. package/dist/es5/collision-filter/collision-filter-extension.js +49 -56
  9. package/dist/es5/collision-filter/collision-filter-extension.js.map +1 -1
  10. package/dist/es5/collision-filter/collision-filter-pass.js +31 -34
  11. package/dist/es5/collision-filter/collision-filter-pass.js.map +1 -1
  12. package/dist/es5/data-filter/data-filter-extension.js +126 -132
  13. package/dist/es5/data-filter/data-filter-extension.js.map +1 -1
  14. package/dist/es5/fill-style/fill-style-extension.js +101 -109
  15. package/dist/es5/fill-style/fill-style-extension.js.map +1 -1
  16. package/dist/es5/fp64/fp64-extension.js +12 -16
  17. package/dist/es5/fp64/fp64-extension.js.map +1 -1
  18. package/dist/es5/mask/mask-effect.js +208 -216
  19. package/dist/es5/mask/mask-effect.js.map +1 -1
  20. package/dist/es5/mask/mask-extension.js +57 -63
  21. package/dist/es5/mask/mask-extension.js.map +1 -1
  22. package/dist/es5/mask/mask-pass.js +36 -42
  23. package/dist/es5/mask/mask-pass.js.map +1 -1
  24. package/dist/es5/path-style/path-style-extension.js +81 -89
  25. package/dist/es5/path-style/path-style-extension.js.map +1 -1
  26. package/dist/es5/terrain/height-map-builder.js +73 -80
  27. package/dist/es5/terrain/height-map-builder.js.map +1 -1
  28. package/dist/es5/terrain/terrain-cover.js +155 -162
  29. package/dist/es5/terrain/terrain-cover.js.map +1 -1
  30. package/dist/es5/terrain/terrain-effect.js +233 -242
  31. package/dist/es5/terrain/terrain-effect.js.map +1 -1
  32. package/dist/es5/terrain/terrain-extension.js +44 -51
  33. package/dist/es5/terrain/terrain-extension.js.map +1 -1
  34. package/dist/es5/terrain/terrain-pass.js +61 -65
  35. package/dist/es5/terrain/terrain-pass.js.map +1 -1
  36. package/dist/es5/terrain/terrain-picking-pass.js +56 -62
  37. package/dist/es5/terrain/terrain-picking-pass.js.map +1 -1
  38. package/dist/esm/brushing/brushing-extension.js +2 -5
  39. package/dist/esm/brushing/brushing-extension.js.map +1 -1
  40. package/dist/esm/brushing/shader-module.js +67 -4
  41. package/dist/esm/brushing/shader-module.js.map +1 -1
  42. package/dist/esm/clip/clip-extension.js +33 -14
  43. package/dist/esm/clip/clip-extension.js.map +1 -1
  44. package/dist/esm/collision-filter/collision-filter-effect.js +10 -19
  45. package/dist/esm/collision-filter/collision-filter-effect.js.map +1 -1
  46. package/dist/esm/collision-filter/collision-filter-extension.js +2 -5
  47. package/dist/esm/collision-filter/collision-filter-extension.js.map +1 -1
  48. package/dist/esm/collision-filter/shader-module.js +76 -4
  49. package/dist/esm/collision-filter/shader-module.js.map +1 -1
  50. package/dist/esm/data-filter/aggregator.js +45 -2
  51. package/dist/esm/data-filter/aggregator.js.map +1 -1
  52. package/dist/esm/data-filter/data-filter-extension.js +2 -5
  53. package/dist/esm/data-filter/data-filter-extension.js.map +1 -1
  54. package/dist/esm/data-filter/shader-module.js +86 -6
  55. package/dist/esm/data-filter/shader-module.js.map +1 -1
  56. package/dist/esm/fill-style/fill-style-extension.js +2 -5
  57. package/dist/esm/fill-style/fill-style-extension.js.map +1 -1
  58. package/dist/esm/fill-style/shaders.glsl.js +60 -5
  59. package/dist/esm/fill-style/shaders.glsl.js.map +1 -1
  60. package/dist/esm/fp64/fp64-extension.js +1 -3
  61. package/dist/esm/fp64/fp64-extension.js.map +1 -1
  62. package/dist/esm/fp64/project64.glsl.js +81 -1
  63. package/dist/esm/fp64/project64.glsl.js.map +1 -1
  64. package/dist/esm/mask/mask-effect.js +10 -20
  65. package/dist/esm/mask/mask-effect.js.map +1 -1
  66. package/dist/esm/mask/mask-extension.js +3 -6
  67. package/dist/esm/mask/mask-extension.js.map +1 -1
  68. package/dist/esm/mask/mask-pass.js +2 -6
  69. package/dist/esm/mask/mask-pass.js.map +1 -1
  70. package/dist/esm/mask/shader-module.js +61 -6
  71. package/dist/esm/mask/shader-module.js.map +1 -1
  72. package/dist/esm/path-style/path-style-extension.js +2 -5
  73. package/dist/esm/path-style/path-style-extension.js.map +1 -1
  74. package/dist/esm/path-style/shaders.glsl.js +79 -8
  75. package/dist/esm/path-style/shaders.glsl.js.map +1 -1
  76. package/dist/esm/terrain/height-map-builder.js +8 -17
  77. package/dist/esm/terrain/height-map-builder.js.map +1 -1
  78. package/dist/esm/terrain/shader-module.js +59 -7
  79. package/dist/esm/terrain/shader-module.js.map +1 -1
  80. package/dist/esm/terrain/terrain-cover.js +11 -22
  81. package/dist/esm/terrain/terrain-cover.js.map +1 -1
  82. package/dist/esm/terrain/terrain-effect.js +11 -21
  83. package/dist/esm/terrain/terrain-effect.js.map +1 -1
  84. package/dist/esm/terrain/terrain-extension.js +2 -5
  85. package/dist/esm/terrain/terrain-extension.js.map +1 -1
  86. package/dist/esm/terrain/terrain-pass.js +1 -1
  87. package/dist/esm/terrain/terrain-pass.js.map +1 -1
  88. package/dist/esm/terrain/terrain-picking-pass.js +2 -4
  89. package/dist/esm/terrain/terrain-picking-pass.js.map +1 -1
  90. package/dist.min.js +36 -35
  91. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/brushing/brushing-extension.ts"],"names":["LayerExtension","shaderModule","defaultProps","getBrushingTarget","type","value","brushingTarget","brushingEnabled","brushingRadius","BrushingExtension","getShaders","modules","initializeState","context","extension","attributeManager","getAttributeManager","add","brushingTargets","size","accessor","shaderAttributes","divisor","instanceBrushingTargets","state","onMouseMove","getCurrentLayer","setNeedsRedraw","deck","eventManager","on","pointermove","pointerleave","finalizeState","off"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KAAL,CAAWC;AAFE,OAA7B;AAID;AACF;;AAEDQ,EAAAA,aAAa,CAAsCpB,OAAtC,EAA6DC,SAA7D,EAA8E;AAEzF,QAAID,OAAO,CAACe,IAAZ,EAAkB;AAEhBf,MAAAA,OAAO,CAACe,IAAR,CAAaC,YAAb,CAA0BK,GAA1B,CAA8B;AAC5BH,QAAAA,WAAW,EAAE,KAAKP,KAAL,CAAWC,WADI;AAE5BO,QAAAA,YAAY,EAAE,KAAKR,KAAL,CAAWC;AAFG,OAA9B;AAID;AACF;;AApD2D;;gBAAzChB,iB,kBACGP,Y;;gBADHO,iB,mBAEI,mB","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 {LayerExtension} from '@deck.gl/core';\nimport shaderModule from './shader-module';\n\nimport type {Layer, LayerContext, Accessor} from '@deck.gl/core';\n\nconst defaultProps = {\n getBrushingTarget: {type: 'accessor', value: [0, 0]},\n\n brushingTarget: 'source',\n brushingEnabled: true,\n brushingRadius: 10000\n};\n\nexport type BrushingExtensionProps<DataT = any> = {\n /**\n * Called to retrieve an arbitrary position for each object that it will be filtered by.\n * Only effective if `brushingTarget` is set to `custom`.\n */\n getBrushingTarget?: Accessor<DataT, [number, number]>;\n /**\n * Enable/disable brushing. If brushing is disabled, all objects are rendered.\n * @default true\n */\n brushingEnabled?: boolean;\n /**\n * The position used to filter each object by.\n */\n brushingTarget?: 'source' | 'target' | 'source_target' | 'custom';\n /** The brushing radius centered at the pointer, in meters. If a data object is within this circle, it is rendered; otherwise it is hidden.\n * @default 10000\n */\n brushingRadius?: number;\n};\n\n/** Adds GPU-based data brushing functionalities to layers. It allows the layer to show/hide objects based on the current pointer position. */\nexport default class BrushingExtension extends LayerExtension {\n static defaultProps = defaultProps;\n static extensionName = 'BrushingExtension';\n\n getShaders(): any {\n return {\n modules: [shaderModule]\n };\n }\n\n initializeState(this: Layer<BrushingExtensionProps>, context: LayerContext, extension: this) {\n const attributeManager = this.getAttributeManager();\n if (attributeManager) {\n attributeManager.add({\n brushingTargets: {\n size: 2,\n accessor: 'getBrushingTarget',\n shaderAttributes: {\n brushingTargets: {\n divisor: 0\n },\n instanceBrushingTargets: {\n divisor: 1\n }\n }\n }\n });\n }\n\n // Trigger redraw when mouse moves\n // TODO - expose this in a better way\n this.state.onMouseMove = () => {\n this.getCurrentLayer()?.setNeedsRedraw();\n };\n if (context.deck) {\n // @ts-expect-error (2446) accessing protected property\n context.deck.eventManager.on({\n pointermove: this.state.onMouseMove,\n pointerleave: this.state.onMouseMove\n });\n }\n }\n\n finalizeState(this: Layer<BrushingExtensionProps>, context: LayerContext, extension: this) {\n // Remove event listeners\n if (context.deck) {\n // @ts-expect-error (2446) accessing protected property\n context.deck.eventManager.off({\n pointermove: this.state.onMouseMove,\n pointerleave: this.state.onMouseMove\n });\n }\n }\n}\n"],"file":"brushing-extension.js"}
1
+ {"version":3,"sources":["../../../src/brushing/brushing-extension.ts"],"names":["LayerExtension","shaderModule","defaultProps","getBrushingTarget","type","value","brushingTarget","brushingEnabled","brushingRadius","BrushingExtension","getShaders","modules","initializeState","context","extension","attributeManager","getAttributeManager","add","brushingTargets","size","accessor","shaderAttributes","divisor","instanceBrushingTargets","state","onMouseMove","getCurrentLayer","setNeedsRedraw","deck","eventManager","on","pointermove","pointerleave","finalizeState","off","extensionName"],"mappings":"AAoBA,SAAQA,cAAR,QAA6B,eAA7B;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AAIA,MAAMC,YAAY,GAAG;AACnBC,EAAAA,iBAAiB,EAAE;AAACC,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE,CAAC,CAAD,EAAI,CAAJ;AAA1B,GADA;AAGnBC,EAAAA,cAAc,EAAE,QAHG;AAInBC,EAAAA,eAAe,EAAE,IAJE;AAKnBC,EAAAA,cAAc,EAAE;AALG,CAArB;AA8BA,eAAe,MAAMC,iBAAN,SAAgCT,cAAhC,CAA+C;AAI5DU,EAAAA,UAAU,GAAQ;AAChB,WAAO;AACLC,MAAAA,OAAO,EAAE,CAACV,YAAD;AADJ,KAAP;AAGD;;AAEDW,EAAAA,eAAe,CAAsCC,OAAtC,EAA6DC,SAA7D,EAA8E;AAC3F,UAAMC,gBAAgB,GAAG,KAAKC,mBAAL,EAAzB;;AACA,QAAID,gBAAJ,EAAsB;AACpBA,MAAAA,gBAAgB,CAACE,GAAjB,CAAqB;AACnBC,QAAAA,eAAe,EAAE;AACfC,UAAAA,IAAI,EAAE,CADS;AAEfC,UAAAA,QAAQ,EAAE,mBAFK;AAGfC,UAAAA,gBAAgB,EAAE;AAChBH,YAAAA,eAAe,EAAE;AACfI,cAAAA,OAAO,EAAE;AADM,aADD;AAIhBC,YAAAA,uBAAuB,EAAE;AACvBD,cAAAA,OAAO,EAAE;AADc;AAJT;AAHH;AADE,OAArB;AAcD;;AAID,SAAKE,KAAL,CAAWC,WAAX,GAAyB,MAAM;AAAA;;AAC7B,oCAAKC,eAAL,kFAAwBC,cAAxB;AACD,KAFD;;AAGA,QAAId,OAAO,CAACe,IAAZ,EAAkB;AAEhBf,MAAAA,OAAO,CAACe,IAAR,CAAaC,YAAb,CAA0BC,EAA1B,CAA6B;AAC3BC,QAAAA,WAAW,EAAE,KAAKP,KAAL,CAAWC,WADG;AAE3BO,QAAAA,YAAY,EAAE,KAAKR,KAAL,CAAWC;AAFE,OAA7B;AAID;AACF;;AAEDQ,EAAAA,aAAa,CAAsCpB,OAAtC,EAA6DC,SAA7D,EAA8E;AAEzF,QAAID,OAAO,CAACe,IAAZ,EAAkB;AAEhBf,MAAAA,OAAO,CAACe,IAAR,CAAaC,YAAb,CAA0BK,GAA1B,CAA8B;AAC5BH,QAAAA,WAAW,EAAE,KAAKP,KAAL,CAAWC,WADI;AAE5BO,QAAAA,YAAY,EAAE,KAAKR,KAAL,CAAWC;AAFG,OAA9B;AAID;AACF;;AApD2D;AAAzChB,iB,CACZP,Y,GAAeA,Y;AADHO,iB,CAEZ0B,a,GAAgB,mB","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 {LayerExtension} from '@deck.gl/core';\nimport shaderModule from './shader-module';\n\nimport type {Layer, LayerContext, Accessor} from '@deck.gl/core';\n\nconst defaultProps = {\n getBrushingTarget: {type: 'accessor', value: [0, 0]},\n\n brushingTarget: 'source',\n brushingEnabled: true,\n brushingRadius: 10000\n};\n\nexport type BrushingExtensionProps<DataT = any> = {\n /**\n * Called to retrieve an arbitrary position for each object that it will be filtered by.\n * Only effective if `brushingTarget` is set to `custom`.\n */\n getBrushingTarget?: Accessor<DataT, [number, number]>;\n /**\n * Enable/disable brushing. If brushing is disabled, all objects are rendered.\n * @default true\n */\n brushingEnabled?: boolean;\n /**\n * The position used to filter each object by.\n */\n brushingTarget?: 'source' | 'target' | 'source_target' | 'custom';\n /** The brushing radius centered at the pointer, in meters. If a data object is within this circle, it is rendered; otherwise it is hidden.\n * @default 10000\n */\n brushingRadius?: number;\n};\n\n/** Adds GPU-based data brushing functionalities to layers. It allows the layer to show/hide objects based on the current pointer position. */\nexport default class BrushingExtension extends LayerExtension {\n static defaultProps = defaultProps;\n static extensionName = 'BrushingExtension';\n\n getShaders(): any {\n return {\n modules: [shaderModule]\n };\n }\n\n initializeState(this: Layer<BrushingExtensionProps>, context: LayerContext, extension: this) {\n const attributeManager = this.getAttributeManager();\n if (attributeManager) {\n attributeManager.add({\n brushingTargets: {\n size: 2,\n accessor: 'getBrushingTarget',\n shaderAttributes: {\n brushingTargets: {\n divisor: 0\n },\n instanceBrushingTargets: {\n divisor: 1\n }\n }\n }\n });\n }\n\n // Trigger redraw when mouse moves\n // TODO - expose this in a better way\n this.state.onMouseMove = () => {\n this.getCurrentLayer()?.setNeedsRedraw();\n };\n if (context.deck) {\n // @ts-expect-error (2446) accessing protected property\n context.deck.eventManager.on({\n pointermove: this.state.onMouseMove,\n pointerleave: this.state.onMouseMove\n });\n }\n }\n\n finalizeState(this: Layer<BrushingExtensionProps>, context: LayerContext, extension: this) {\n // Remove event listeners\n if (context.deck) {\n // @ts-expect-error (2446) accessing protected property\n context.deck.eventManager.off({\n pointermove: this.state.onMouseMove,\n pointerleave: this.state.onMouseMove\n });\n }\n }\n}\n"],"file":"brushing-extension.js"}
@@ -1,6 +1,41 @@
1
1
  import { project } from '@deck.gl/core';
2
- const 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 attribute vec2 brushingTargets;\n #else\n attribute vec2 instanceBrushingTargets;\n #endif\n\n varying 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";
3
- const fs = "\n uniform bool brushing_enabled;\n varying float brushing_isVisible;\n";
2
+ const vs = `
3
+ uniform bool brushing_enabled;
4
+ uniform int brushing_target;
5
+ uniform vec2 brushing_mousePos;
6
+ uniform float brushing_radius;
7
+
8
+ #ifdef NON_INSTANCED_MODEL
9
+ attribute vec2 brushingTargets;
10
+ #else
11
+ attribute vec2 instanceBrushingTargets;
12
+ #endif
13
+
14
+ varying float brushing_isVisible;
15
+
16
+ bool brushing_isPointInRange(vec2 position) {
17
+ if (!brushing_enabled) {
18
+ return true;
19
+ }
20
+ vec2 source_commonspace = project_position(position);
21
+ vec2 target_commonspace = project_position(brushing_mousePos);
22
+ float distance = length((target_commonspace - source_commonspace) / project_uCommonUnitsPerMeter.xy);
23
+
24
+ return distance <= brushing_radius;
25
+ }
26
+
27
+ bool brushing_arePointsInRange(vec2 sourcePos, vec2 targetPos) {
28
+ return brushing_isPointInRange(sourcePos) || brushing_isPointInRange(targetPos);
29
+ }
30
+
31
+ void brushing_setVisible(bool visible) {
32
+ brushing_isVisible = float(visible);
33
+ }
34
+ `;
35
+ const fs = `
36
+ uniform bool brushing_enabled;
37
+ varying float brushing_isVisible;
38
+ `;
4
39
  const TARGET = {
5
40
  source: 0,
6
41
  target: 1,
@@ -8,8 +43,36 @@ const TARGET = {
8
43
  source_target: 3
9
44
  };
10
45
  const inject = {
11
- '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 ",
12
- 'fs:DECKGL_FILTER_COLOR': "\n if (brushing_enabled && brushing_isVisible < 0.5) {\n discard;\n }\n "
46
+ 'vs:DECKGL_FILTER_GL_POSITION': `
47
+ vec2 brushingTarget;
48
+ vec2 brushingSource;
49
+ if (brushing_target == 3) {
50
+ brushingTarget = geometry.worldPositionAlt.xy;
51
+ brushingSource = geometry.worldPosition.xy;
52
+ } else if (brushing_target == 0) {
53
+ brushingTarget = geometry.worldPosition.xy;
54
+ } else if (brushing_target == 1) {
55
+ brushingTarget = geometry.worldPositionAlt.xy;
56
+ } else {
57
+ #ifdef NON_INSTANCED_MODEL
58
+ brushingTarget = brushingTargets;
59
+ #else
60
+ brushingTarget = instanceBrushingTargets;
61
+ #endif
62
+ }
63
+ bool visible;
64
+ if (brushing_target == 3) {
65
+ visible = brushing_arePointsInRange(brushingSource, brushingTarget);
66
+ } else {
67
+ visible = brushing_isPointInRange(brushingTarget);
68
+ }
69
+ brushing_setVisible(visible);
70
+ `,
71
+ 'fs:DECKGL_FILTER_COLOR': `
72
+ if (brushing_enabled && brushing_isVisible < 0.5) {
73
+ discard;
74
+ }
75
+ `
13
76
  };
14
77
  export default {
15
78
  name: 'brushing',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/brushing/shader-module.ts"],"names":["project","vs","fs","TARGET","source","target","custom","source_target","inject","name","dependencies","getUniforms","opts","brushingEnabled","brushingRadius","brushingTarget","mousePosition","viewport","brushing_enabled","Boolean","containsPixel","brushing_radius","brushing_target","brushing_mousePos","unproject","x","y"],"mappings":"AAoBA,SAAQA,OAAR,QAAsB,eAAtB;AAWA,MAAMC,EAAE,07BAAR;AAkCA,MAAMC,EAAE,8EAAR;AAKA,MAAMC,MAAM,GAAG;AACbC,EAAAA,MAAM,EAAE,CADK;AAEbC,EAAAA,MAAM,EAAE,CAFK;AAGbC,EAAAA,MAAM,EAAE,CAHK;AAIbC,EAAAA,aAAa,EAAE;AAJF,CAAf;AAOA,MAAMC,MAAM,GAAG;AACb,6zBADa;AA2Bb;AA3Ba,CAAf;AAkCA,eAAe;AACbC,EAAAA,IAAI,EAAE,UADO;AAEbC,EAAAA,YAAY,EAAE,CAACV,OAAD,CAFD;AAGbC,EAAAA,EAHa;AAIbC,EAAAA,EAJa;AAKbM,EAAAA,MALa;AAMbG,EAAAA,WAAW,EAAGC,IAAD,IAA6D;AACxE,QAAI,CAACA,IAAD,IAAS,EAAE,cAAcA,IAAhB,CAAb,EAAoC;AAClC,aAAO,EAAP;AACD;;AACD,UAAM;AACJC,MAAAA,eAAe,GAAG,IADd;AAEJC,MAAAA,cAAc,GAAG,KAFb;AAGJC,MAAAA,cAAc,GAAG,QAHb;AAIJC,MAAAA,aAJI;AAKJC,MAAAA;AALI,QAMFL,IANJ;AAOA,WAAO;AACLM,MAAAA,gBAAgB,EAAEC,OAAO,CACvBN,eAAe,IAAIG,aAAnB,IAAoCC,QAAQ,CAACG,aAAT,CAAuBJ,aAAvB,CADb,CADpB;AAILK,MAAAA,eAAe,EAAEP,cAJZ;AAKLQ,MAAAA,eAAe,EAAEnB,MAAM,CAACY,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,CAAf","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 {project} from '@deck.gl/core';\nimport type {Viewport, _ShaderModule as ShaderModule} 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 attribute vec2 brushingTargets;\n #else\n attribute vec2 instanceBrushingTargets;\n #endif\n\n varying 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 varying 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"}
1
+ {"version":3,"sources":["../../../src/brushing/shader-module.ts"],"names":["project","vs","fs","TARGET","source","target","custom","source_target","inject","name","dependencies","getUniforms","opts","brushingEnabled","brushingRadius","brushingTarget","mousePosition","viewport","brushing_enabled","Boolean","containsPixel","brushing_radius","brushing_target","brushing_mousePos","unproject","x","y"],"mappings":"AAoBA,SAAQA,OAAR,QAAsB,eAAtB;AAWA,MAAMC,EAAE,GAAI;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAhCA;AAkCA,MAAMC,EAAE,GAAI;AACZ;AACA;AACA,CAHA;AAKA,MAAMC,MAAM,GAAG;AACbC,EAAAA,MAAM,EAAE,CADK;AAEbC,EAAAA,MAAM,EAAE,CAFK;AAGbC,EAAAA,MAAM,EAAE,CAHK;AAIbC,EAAAA,aAAa,EAAE;AAJF,CAAf;AAOA,MAAMC,MAAM,GAAG;AACb,kCAAiC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAzBe;AA2Bb,4BAA2B;AAC7B;AACA;AACA;AACA;AA/Be,CAAf;AAkCA,eAAe;AACbC,EAAAA,IAAI,EAAE,UADO;AAEbC,EAAAA,YAAY,EAAE,CAACV,OAAD,CAFD;AAGbC,EAAAA,EAHa;AAIbC,EAAAA,EAJa;AAKbM,EAAAA,MALa;AAMbG,EAAAA,WAAW,EAAGC,IAAD,IAA6D;AACxE,QAAI,CAACA,IAAD,IAAS,EAAE,cAAcA,IAAhB,CAAb,EAAoC;AAClC,aAAO,EAAP;AACD;;AACD,UAAM;AACJC,MAAAA,eAAe,GAAG,IADd;AAEJC,MAAAA,cAAc,GAAG,KAFb;AAGJC,MAAAA,cAAc,GAAG,QAHb;AAIJC,MAAAA,aAJI;AAKJC,MAAAA;AALI,QAMFL,IANJ;AAOA,WAAO;AACLM,MAAAA,gBAAgB,EAAEC,OAAO,CACvBN,eAAe,IAAIG,aAAnB,IAAoCC,QAAQ,CAACG,aAAT,CAAuBJ,aAAvB,CADb,CADpB;AAILK,MAAAA,eAAe,EAAEP,cAJZ;AAKLQ,MAAAA,eAAe,EAAEnB,MAAM,CAACY,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,CAAf","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 {project} from '@deck.gl/core';\nimport type {Viewport, _ShaderModule as ShaderModule} 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 attribute vec2 brushingTargets;\n #else\n attribute vec2 instanceBrushingTargets;\n #endif\n\n varying 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 varying 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"}
@@ -1,29 +1,50 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import { LayerExtension } from '@deck.gl/core';
3
2
  const defaultProps = {
4
3
  clipBounds: [0, 0, 1, 1],
5
4
  clipByInstance: undefined
6
5
  };
7
- const 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";
6
+ const shaderFunction = `
7
+ uniform vec4 clip_bounds;
8
+
9
+ bool clip_isInBounds(vec2 position) {
10
+ return position.x >= clip_bounds[0] && position.y >= clip_bounds[1] && position.x < clip_bounds[2] && position.y < clip_bounds[3];
11
+ }
12
+ `;
8
13
  const shaderModuleVs = {
9
14
  name: 'clip-vs',
10
15
  vs: shaderFunction
11
16
  };
12
17
  const injectionVs = {
13
- 'vs:#decl': "\nvarying float clip_isVisible;\n",
14
- 'vs:DECKGL_FILTER_GL_POSITION': "\n clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy));\n",
15
- 'fs:#decl': "\nvarying float clip_isVisible;\n",
16
- 'fs:DECKGL_FILTER_COLOR': "\n if (clip_isVisible < 0.5) discard;\n"
18
+ 'vs:#decl': `
19
+ varying float clip_isVisible;
20
+ `,
21
+ 'vs:DECKGL_FILTER_GL_POSITION': `
22
+ clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy));
23
+ `,
24
+ 'fs:#decl': `
25
+ varying float clip_isVisible;
26
+ `,
27
+ 'fs:DECKGL_FILTER_COLOR': `
28
+ if (clip_isVisible < 0.5) discard;
29
+ `
17
30
  };
18
31
  const shaderModuleFs = {
19
32
  name: 'clip-fs',
20
33
  fs: shaderFunction
21
34
  };
22
35
  const injectionFs = {
23
- 'vs:#decl': "\nvarying vec2 clip_commonPosition;\n",
24
- 'vs:DECKGL_FILTER_GL_POSITION': "\n clip_commonPosition = geometry.position.xy;\n",
25
- 'fs:#decl': "\nvarying vec2 clip_commonPosition;\n",
26
- 'fs:DECKGL_FILTER_COLOR': "\n if (!clip_isInBounds(clip_commonPosition)) discard;\n"
36
+ 'vs:#decl': `
37
+ varying vec2 clip_commonPosition;
38
+ `,
39
+ 'vs:DECKGL_FILTER_GL_POSITION': `
40
+ clip_commonPosition = geometry.position.xy;
41
+ `,
42
+ 'fs:#decl': `
43
+ varying vec2 clip_commonPosition;
44
+ `,
45
+ 'fs:DECKGL_FILTER_COLOR': `
46
+ if (!clip_isInBounds(clip_commonPosition)) discard;
47
+ `
27
48
  };
28
49
  export default class ClipExtension extends LayerExtension {
29
50
  getShaders() {
@@ -60,8 +81,6 @@ export default class ClipExtension extends LayerExtension {
60
81
  }
61
82
 
62
83
  }
63
-
64
- _defineProperty(ClipExtension, "defaultProps", defaultProps);
65
-
66
- _defineProperty(ClipExtension, "extensionName", 'ClipExtension');
84
+ ClipExtension.defaultProps = defaultProps;
85
+ ClipExtension.extensionName = 'ClipExtension';
67
86
  //# sourceMappingURL=clip-extension.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/clip/clip-extension.ts"],"names":["LayerExtension","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"],"mappings":";AAoBA,SAAQA,cAAR,QAA4D,eAA5D;AAIA,MAAMC,YAAY,GAAG;AACnBC,EAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CADO;AAEnBC,EAAAA,cAAc,EAAEC;AAFG,CAArB;AAiBA,MAAMC,cAAc,oNAApB;AAYA,MAAMC,cAA4B,GAAG;AACnCC,EAAAA,IAAI,EAAE,SAD6B;AAEnCC,EAAAA,EAAE,EAAEH;AAF+B,CAArC;AAKA,MAAMI,WAAW,GAAG;AAClB,iDADkB;AAIlB,6GAJkB;AAOlB,iDAPkB;AAUlB;AAVkB,CAApB;AAmBA,MAAMC,cAA4B,GAAG;AACnCH,EAAAA,IAAI,EAAE,SAD6B;AAEnCI,EAAAA,EAAE,EAAEN;AAF+B,CAArC;AAKA,MAAMO,WAAW,GA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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;;AA5CuD;;gBAArCd,a,kBACGZ,Y;;gBADHY,a,mBAEI,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 {LayerExtension, _ShaderModule as ShaderModule} 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': `\nvarying float clip_isVisible;\n`,\n 'vs:DECKGL_FILTER_GL_POSITION': `\n clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy));\n`,\n 'fs:#decl': `\nvarying 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': `\nvarying vec2 clip_commonPosition;\n`,\n 'vs:DECKGL_FILTER_GL_POSITION': `\n clip_commonPosition = geometry.position.xy;\n`,\n 'fs:#decl': `\nvarying 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 // @ts-expect-error attributeManager is always defined for primitive layers\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"}
1
+ {"version":3,"sources":["../../../src/clip/clip-extension.ts"],"names":["LayerExtension","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","extensionName"],"mappings":"AAoBA,SAAQA,cAAR,QAA4D,eAA5D;AAIA,MAAMC,YAAY,GAAG;AACnBC,EAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CADO;AAEnBC,EAAAA,cAAc,EAAEC;AAFG,CAArB;AAiBA,MAAMC,cAAc,GAAI;AACxB;AACA;AACA;AACA;AACA;AACA,CANA;AAYA,MAAMC,c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AQ,CAACC,WAAT,GAAuBtB,UAAvB;AACD,KAFD,MAEO;AACL,YAAMuB,OAAO,GAAG,KAAKC,eAAL,CAAqB,CAACxB,UAAU,CAAC,CAAD,CAAX,EAAgBA,UAAU,CAAC,CAAD,CAA1B,EAA+B,CAA/B,CAArB,CAAhB;AACA,YAAMyB,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;;AA5CuD;AAArCd,a,CACZZ,Y,GAAeA,Y;AADHY,a,CAEZkB,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 {LayerExtension, _ShaderModule as ShaderModule} 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': `\nvarying float clip_isVisible;\n`,\n 'vs:DECKGL_FILTER_GL_POSITION': `\n clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy));\n`,\n 'fs:#decl': `\nvarying 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': `\nvarying vec2 clip_commonPosition;\n`,\n 'vs:DECKGL_FILTER_GL_POSITION': `\n clip_commonPosition = geometry.position.xy;\n`,\n 'fs:#decl': `\nvarying 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 // @ts-expect-error attributeManager is always defined for primitive layers\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"}
@@ -1,4 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import { Framebuffer, Renderbuffer, Texture2D, cssToDeviceRatio } from '@luma.gl/core';
3
2
  import { equals } from '@math.gl/core';
4
3
  import { _deepEqual as deepEqual } from '@deck.gl/core';
@@ -7,23 +6,15 @@ import MaskEffect from '../mask/mask-effect';
7
6
  const DOWNSCALE = 2;
8
7
  export default class CollisionFilterEffect {
9
8
  constructor() {
10
- _defineProperty(this, "id", 'collision-filter-effect');
11
-
12
- _defineProperty(this, "props", null);
13
-
14
- _defineProperty(this, "useInPicking", true);
15
-
16
- _defineProperty(this, "order", 1);
17
-
18
- _defineProperty(this, "channels", {});
19
-
20
- _defineProperty(this, "collisionFilterPass", void 0);
21
-
22
- _defineProperty(this, "collisionFBOs", {});
23
-
24
- _defineProperty(this, "dummyCollisionMap", void 0);
25
-
26
- _defineProperty(this, "lastViewport", void 0);
9
+ this.id = 'collision-filter-effect';
10
+ this.props = null;
11
+ this.useInPicking = true;
12
+ this.order = 1;
13
+ this.channels = {};
14
+ this.collisionFilterPass = void 0;
15
+ this.collisionFBOs = {};
16
+ this.dummyCollisionMap = void 0;
17
+ this.lastViewport = void 0;
27
18
  }
28
19
 
29
20
  preRender(gl, {
@@ -231,7 +222,7 @@ export default class CollisionFilterEffect {
231
222
  height
232
223
  });
233
224
  this.collisionFBOs[collisionGroup] = new Framebuffer(gl, {
234
- id: "Collision-".concat(collisionGroup),
225
+ id: `Collision-${collisionGroup}`,
235
226
  width,
236
227
  height,
237
228
  attachments: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collision-filter/collision-filter-effect.ts"],"names":["Framebuffer","Renderbuffer","Texture2D","cssToDeviceRatio","equals","_deepEqual","deepEqual","CollisionFilterPass","MaskEffect","DOWNSCALE","CollisionFilterEffect","preRender","gl","effects","allEffects","layers","layerFilter","viewports","onViewportActive","views","isPicking","preRenderStats","dummyCollisionMap","width","height","collisionLayers","filter","props","visible","collisionEnabled","length","channels","collisionFilterPass","id","e","constructor","maskEffectRendered","didRender","_groupByCollisionGroup","viewport","viewportChanged","lastViewport","collisionGroup","collisionFBO","collisionFBOs","renderInfo","resize","canvas","_render","oldRenderInfo","needsRender","layerBounds","some","b","i","allLayersLoaded","layer","transitions","renderCollisionMap","pass","moduleParameters","devicePixelRatio","channelMap","channelInfo","push","getBounds","isLoaded","Object","keys","createFBO","destroyFBO","getModuleParameters","cleanup","delete","undefined","collisionMap","parameters","depthBuffer","format","attachments","fbo","attachment","values"],"mappings":";AAAA,SAAQA,WAAR,EAAqBC,YAArB,EAAmCC,SAAnC,EAA8CC,gBAA9C,QAAqE,eAArE;AACA,SAAQC,MAAR,QAAqB,eAArB;AACA,SAAQC,UAAU,IAAIC,SAAtB,QAAsC,eAAtC;AAEA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,OAAOC,UAAP,MAA6C,qBAA7C;AASA,MAAMC,SAAS,GAAG,CAAlB;AASA,eAAe,MAAMC,qBAAN,CAA8C;AAAA;AAAA,gCACtD,yBADsD;;AAAA,mCAEnD,IAFmD;;AAAA,0CAG5C,IAH4C;;AAAA,mCAInD,CAJmD;;AAAA,sCAMZ,EANY;;AAAA;;AAAA,2CAQN,EARM;;AAAA;;AAAA;AAAA;;AAY3DC,EAAAA,SAAS,CACPC,EADO,EAEP;AACEC,IAAAA,OAAO,EAAEC,UADX;AAEEC,IAAAA,MAFF;AAGEC,IAAAA,WAHF;AAIEC,IAAAA,SAJF;AAKEC,IAAAA,gBALF;AAMEC,IAAAA,KANF;AAOEC,IAAAA,SAPF;AAQEC,IAAAA,cAAc,GAAG;AARnB,GAFO,EAYD;AAAA;;AACN,QAAI,CAAC,KAAKC,iBAAV,EAA6B;AAC3B,WAAKA,iBAAL,GAAyB,IAAIpB,SAAJ,CAAcU,EAAd,EAAkB;AAACW,QAAAA,KAAK,EAAE,CAAR;AAAWC,QAAAA,MAAM,EAAE;AAAnB,OAAlB,CAAzB;AACD;;AAED,QAAIJ,SAAJ,EAAe;AAEb;AACD;;AAED,UAAMK,eAAe,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AAL,GAAoBiC,SAApB;AACD;;AAEDL,EAAAA,SAAS,CAACzD,EAAD,EAA4B8B,cAA5B,EAAoD;AAC3D,UAAM;AAACnB,MAAAA,KAAD;AAAQC,MAAAA;AAAR,QAAkBZ,EAAE,CAACmC,MAA3B;AACA,UAAM4B,YAAY,GAAG,IAAIzE,SAAJ,CAAcU,EAAd,EAAkB;AACrCW,MAAAA,KADqC;AAErCC,MAAAA,MAFqC;AAGrCoD,MAAAA,UAAU,EAAE;AACV,qBADU;AAEV,qBAFU;AAGV,sBAHU;AAIV;AAJU;AAHyB,KAAlB,CAArB;AAWA,UAAMC,WAAW,GAAG,IAAI5E,YAAJ,CAAiBW,EAAjB,EAAqB;AAACkE,MAAAA,MAAM,OAAP;AAA+BvD,MAAAA,KAA/B;AAAsCC,MAAAA;AAAtC,KAArB,CAApB;AACA,SAAKoB,aAAL,CAAmBF,cAAnB,IAAqC,IAAI1C,WAAJ,CAAgBY,EAAhB,EAAoB;AACvDqB,MAAAA,EAAE,sBAAeS,cAAf,CADqD;AAEvDnB,MAAAA,KAFuD;AAGvDC,MAAAA,MAHuD;AAIvDuD,MAAAA,WAAW,EAAE;AACX,iBAAwBJ,YADb;AAEX,iBAAuBE;AAFZ;AAJ0C,KAApB,CAArC;AASD;;AAEDP,EAAAA,UAAU,CAAC5B,cAAD,EAAyB;AACjC,UAAMsC,GAAG,GAAG,KAAKpC,aAAL,CAAmBF,cAAnB,CAAZ;;AACA,SAAK,MAAMuC,UAAX,IAAyBd,MAAM,CAACe,MAAP,CAAcF,GAAG,CAACD,WAAlB,CAAzB,EAAwE;AACtEE,MAAAA,UAAU,CAACR,MAAX;AACD;;AACDO,IAAAA,GAAG,CAACP,MAAJ;AACA,WAAO,KAAK7B,aAAL,CAAmBF,cAAnB,CAAP;AACD;;AA5O0D","sourcesContent":["import {Framebuffer, Renderbuffer, Texture2D, cssToDeviceRatio} from '@luma.gl/core';\nimport {equals} from '@math.gl/core';\nimport {_deepEqual as deepEqual} from '@deck.gl/core';\nimport type {Effect, Layer, PreRenderOptions, Viewport} from '@deck.gl/core';\nimport CollisionFilterPass from './collision-filter-pass';\nimport MaskEffect, {MaskPreRenderStats} from '../mask/mask-effect';\n// import {debugFBO} from '../utils/debug';\n\ntype CollisionFilterExtensionProps = {\n collisionTestProps?: {};\n collisionGroup: string;\n};\n\n// Factor by which to downscale Collision FBO relative to canvas\nconst DOWNSCALE = 2;\n\ntype RenderInfo = {\n collisionGroup: string;\n layers: Layer<CollisionFilterExtensionProps>[];\n layerBounds: ([number[], number[]] | null)[];\n allLayersLoaded: boolean;\n};\n\nexport default class CollisionFilterEffect implements Effect {\n id = 'collision-filter-effect';\n props = null;\n useInPicking = true;\n order = 1;\n\n private channels: Record<string, RenderInfo> = {};\n private collisionFilterPass?: CollisionFilterPass;\n private collisionFBOs: Record<string, Framebuffer> = {};\n private dummyCollisionMap?: Texture2D;\n private lastViewport?: Viewport;\n\n preRender(\n gl: WebGLRenderingContext,\n {\n effects: allEffects,\n layers,\n layerFilter,\n viewports,\n onViewportActive,\n views,\n isPicking,\n preRenderStats = {}\n }: PreRenderOptions\n ): void {\n if (!this.dummyCollisionMap) {\n this.dummyCollisionMap = new Texture2D(gl, {width: 1, height: 1});\n }\n\n if (isPicking) {\n // Do not update on picking pass\n return;\n }\n\n const collisionLayers = layers.filter(\n // @ts-ignore\n ({props: {visible, collisionEnabled}}) => visible && collisionEnabled\n ) as Layer<CollisionFilterExtensionProps>[];\n if (collisionLayers.length === 0) {\n this.channels = {};\n return;\n }\n\n if (!this.collisionFilterPass) {\n this.collisionFilterPass = new CollisionFilterPass(gl, {id: 'default-collision-filter'});\n }\n\n // Detect if mask has rendered. TODO: better dependency system for Effects\n const effects = allEffects?.filter(e => e.constructor === MaskEffect);\n const maskEffectRendered = (preRenderStats['mask-effect'] as MaskPreRenderStats)?.didRender;\n\n // Collect layers to render\n const channels = this._groupByCollisionGroup(gl, collisionLayers);\n\n const viewport = viewports[0];\n const viewportChanged =\n !this.lastViewport || !this.lastViewport.equals(viewport) || maskEffectRendered;\n\n // Resize framebuffers to match canvas\n for (const collisionGroup in channels) {\n const collisionFBO = this.collisionFBOs[collisionGroup];\n const renderInfo = channels[collisionGroup];\n collisionFBO.resize({\n width: gl.canvas.width / DOWNSCALE,\n height: gl.canvas.height / DOWNSCALE\n });\n this._render(renderInfo, {\n effects,\n layerFilter,\n onViewportActive,\n views,\n viewport,\n viewportChanged\n });\n }\n\n // debugFBO(this.collisionFBOs[Object.keys(channels)[0]], {minimap: true});\n }\n\n private _render(\n renderInfo: RenderInfo,\n {\n effects,\n layerFilter,\n onViewportActive,\n views,\n viewport,\n viewportChanged\n }: {\n effects: PreRenderOptions['effects'];\n layerFilter: PreRenderOptions['layerFilter'];\n onViewportActive: PreRenderOptions['onViewportActive'];\n views: PreRenderOptions['views'];\n viewport: Viewport;\n viewportChanged: boolean;\n }\n ) {\n const {collisionGroup} = renderInfo;\n const oldRenderInfo = this.channels[collisionGroup];\n if (!oldRenderInfo) {\n return;\n }\n\n const needsRender =\n viewportChanged ||\n // If render info is new\n renderInfo === oldRenderInfo ||\n // If sublayers have changed\n !deepEqual(oldRenderInfo.layers, renderInfo.layers, 1) ||\n // If a sublayer's bounds have been updated\n renderInfo.layerBounds.some((b, i) => !equals(b, oldRenderInfo.layerBounds[i])) ||\n // If a sublayer's isLoaded state has been updated\n renderInfo.allLayersLoaded !== oldRenderInfo.allLayersLoaded ||\n // Some prop is in transition\n renderInfo.layers.some(layer => layer.props.transitions);\n\n this.channels[collisionGroup] = renderInfo;\n\n if (needsRender) {\n this.lastViewport = viewport;\n const collisionFBO = this.collisionFBOs[collisionGroup];\n\n // Rerender collision FBO\n this.collisionFilterPass!.renderCollisionMap(collisionFBO, {\n pass: 'collision-filter',\n isPicking: true,\n layers: renderInfo.layers,\n effects,\n layerFilter,\n viewports: viewport ? [viewport] : [],\n onViewportActive,\n views,\n moduleParameters: {\n // To avoid feedback loop forming between Framebuffer and active Texture.\n dummyCollisionMap: this.dummyCollisionMap,\n devicePixelRatio: cssToDeviceRatio(collisionFBO.gl) / DOWNSCALE\n }\n });\n }\n }\n\n /**\n * Group layers by collisionGroup\n * Returns a map from collisionGroup to render info\n */\n private _groupByCollisionGroup(\n gl: WebGLRenderingContext,\n collisionLayers: Layer<CollisionFilterExtensionProps>[]\n ): Record<string, RenderInfo> {\n const channelMap = {};\n for (const layer of collisionLayers) {\n const {collisionGroup} = layer.props;\n let channelInfo = channelMap[collisionGroup];\n if (!channelInfo) {\n channelInfo = {collisionGroup, layers: [], layerBounds: [], allLayersLoaded: true};\n channelMap[collisionGroup] = channelInfo;\n }\n channelInfo.layers.push(layer);\n channelInfo.layerBounds.push(layer.getBounds());\n if (!layer.isLoaded) {\n channelInfo.allLayersLoaded = false;\n }\n }\n\n // Create any new passes and remove any old ones\n for (const collisionGroup of Object.keys(channelMap)) {\n if (!this.collisionFBOs[collisionGroup]) {\n this.createFBO(gl, collisionGroup);\n }\n if (!this.channels[collisionGroup]) {\n this.channels[collisionGroup] = channelMap[collisionGroup];\n }\n }\n for (const collisionGroup of Object.keys(this.collisionFBOs)) {\n if (!channelMap[collisionGroup]) {\n this.destroyFBO(collisionGroup);\n }\n }\n\n return channelMap;\n }\n\n getModuleParameters(layer: Layer): {\n collisionFBO: Framebuffer;\n dummyCollisionMap: Texture2D;\n } {\n const {collisionGroup} = (layer as Layer<CollisionFilterExtensionProps>).props;\n const {collisionFBOs, dummyCollisionMap} = this;\n return {collisionFBO: collisionFBOs[collisionGroup], dummyCollisionMap};\n }\n\n cleanup(): void {\n if (this.dummyCollisionMap) {\n this.dummyCollisionMap.delete();\n this.dummyCollisionMap = undefined;\n }\n this.channels = {};\n for (const collisionGroup of Object.keys(this.collisionFBOs)) {\n this.destroyFBO(collisionGroup);\n }\n this.collisionFBOs = {};\n this.lastViewport = undefined;\n }\n\n createFBO(gl: WebGLRenderingContext, collisionGroup: string) {\n const {width, height} = gl.canvas;\n const collisionMap = new Texture2D(gl, {\n width,\n height,\n parameters: {\n [gl.TEXTURE_MIN_FILTER]: gl.NEAREST,\n [gl.TEXTURE_MAG_FILTER]: gl.NEAREST,\n [gl.TEXTURE_WRAP_S]: gl.CLAMP_TO_EDGE,\n [gl.TEXTURE_WRAP_T]: gl.CLAMP_TO_EDGE\n }\n });\n\n const depthBuffer = new Renderbuffer(gl, {format: gl.DEPTH_COMPONENT16, width, height});\n this.collisionFBOs[collisionGroup] = new Framebuffer(gl, {\n id: `Collision-${collisionGroup}`,\n width,\n height,\n attachments: {\n [gl.COLOR_ATTACHMENT0]: collisionMap,\n [gl.DEPTH_ATTACHMENT]: depthBuffer\n }\n });\n }\n\n destroyFBO(collisionGroup: string) {\n const fbo = this.collisionFBOs[collisionGroup];\n for (const attachment of Object.values(fbo.attachments as Texture2D[])) {\n attachment.delete();\n }\n fbo.delete();\n delete this.collisionFBOs[collisionGroup];\n }\n}\n"],"file":"collision-filter-effect.js"}
1
+ {"version":3,"sources":["../../../src/collision-filter/collision-filter-effect.ts"],"names":["Framebuffer","Renderbuffer","Texture2D","cssToDeviceRatio","equals","_deepEqual","deepEqual","CollisionFilterPass","MaskEffect","DOWNSCALE","CollisionFilterEffect","id","props","useInPicking","order","channels","collisionFilterPass","collisionFBOs","dummyCollisionMap","lastViewport","preRender","gl","effects","allEffects","layers","layerFilter","viewports","onViewportActive","views","isPicking","preRenderStats","width","height","collisionLayers","filter","visible","collisionEnabled","length","e","constructor","maskEffectRendered","didRender","_groupByCollisionGroup","viewport","viewportChanged","collisionGroup","collisionFBO","renderInfo","resize","canvas","_render","oldRenderInfo","needsRender","layerBounds","some","b","i","allLayersLoaded","layer","transitions","renderCollisionMap","pass","moduleParameters","devicePixelRatio","channelMap","channelInfo","push","getBounds","isLoaded","Object","keys","createFBO","destroyFBO","getModuleParameters","cleanup","delete","undefined","collisionMap","parameters","depthBuffer","format","attachments","fbo","attachment","values"],"mappings":"AAAA,SAAQA,WAAR,EAAqBC,YAArB,EAAmCC,SAAnC,EAA8CC,gBAA9C,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AcmB,EAAd,EAAkB;AACrCU,MAAAA,KADqC;AAErCC,MAAAA,MAFqC;AAGrC8C,MAAAA,UAAU,EAAE;AACV,qBADU;AAEV,qBAFU;AAGV,sBAHU;AAIV;AAJU;AAHyB,KAAlB,CAArB;AAWA,UAAMC,WAAW,GAAG,IAAI9E,YAAJ,CAAiBoB,EAAjB,EAAqB;AAAC2D,MAAAA,MAAM,OAAP;AAA+BjD,MAAAA,KAA/B;AAAsCC,MAAAA;AAAtC,KAArB,CAApB;AACA,SAAKf,aAAL,CAAmB4B,cAAnB,IAAqC,IAAI7C,WAAJ,CAAgBqB,EAAhB,EAAoB;AACvDV,MAAAA,EAAE,EAAG,aAAYkC,cAAe,EADuB;AAEvDd,MAAAA,KAFuD;AAGvDC,MAAAA,MAHuD;AAIvDiD,MAAAA,WAAW,EAAE;AACX,iBAAwBJ,YADb;AAEX,iBAAuBE;AAFZ;AAJ0C,KAApB,CAArC;AASD;;AAEDP,EAAAA,UAAU,CAAC3B,cAAD,EAAyB;AACjC,UAAMqC,GAAG,GAAG,KAAKjE,aAAL,CAAmB4B,cAAnB,CAAZ;;AACA,SAAK,MAAMsC,UAAX,IAAyBd,MAAM,CAACe,MAAP,CAAcF,GAAG,CAACD,WAAlB,CAAzB,EAAwE;AACtEE,MAAAA,UAAU,CAACR,MAAX;AACD;;AACDO,IAAAA,GAAG,CAACP,MAAJ;AACA,WAAO,KAAK1D,aAAL,CAAmB4B,cAAnB,CAAP;AACD;;AA5O0D","sourcesContent":["import {Framebuffer, Renderbuffer, Texture2D, cssToDeviceRatio} from '@luma.gl/core';\nimport {equals} from '@math.gl/core';\nimport {_deepEqual as deepEqual} from '@deck.gl/core';\nimport type {Effect, Layer, PreRenderOptions, Viewport} from '@deck.gl/core';\nimport CollisionFilterPass from './collision-filter-pass';\nimport MaskEffect, {MaskPreRenderStats} from '../mask/mask-effect';\n// import {debugFBO} from '../utils/debug';\n\ntype CollisionFilterExtensionProps = {\n collisionTestProps?: {};\n collisionGroup: string;\n};\n\n// Factor by which to downscale Collision FBO relative to canvas\nconst DOWNSCALE = 2;\n\ntype RenderInfo = {\n collisionGroup: string;\n layers: Layer<CollisionFilterExtensionProps>[];\n layerBounds: ([number[], number[]] | null)[];\n allLayersLoaded: boolean;\n};\n\nexport default class CollisionFilterEffect implements Effect {\n id = 'collision-filter-effect';\n props = null;\n useInPicking = true;\n order = 1;\n\n private channels: Record<string, RenderInfo> = {};\n private collisionFilterPass?: CollisionFilterPass;\n private collisionFBOs: Record<string, Framebuffer> = {};\n private dummyCollisionMap?: Texture2D;\n private lastViewport?: Viewport;\n\n preRender(\n gl: WebGLRenderingContext,\n {\n effects: allEffects,\n layers,\n layerFilter,\n viewports,\n onViewportActive,\n views,\n isPicking,\n preRenderStats = {}\n }: PreRenderOptions\n ): void {\n if (!this.dummyCollisionMap) {\n this.dummyCollisionMap = new Texture2D(gl, {width: 1, height: 1});\n }\n\n if (isPicking) {\n // Do not update on picking pass\n return;\n }\n\n const collisionLayers = layers.filter(\n // @ts-ignore\n ({props: {visible, collisionEnabled}}) => visible && collisionEnabled\n ) as Layer<CollisionFilterExtensionProps>[];\n if (collisionLayers.length === 0) {\n this.channels = {};\n return;\n }\n\n if (!this.collisionFilterPass) {\n this.collisionFilterPass = new CollisionFilterPass(gl, {id: 'default-collision-filter'});\n }\n\n // Detect if mask has rendered. TODO: better dependency system for Effects\n const effects = allEffects?.filter(e => e.constructor === MaskEffect);\n const maskEffectRendered = (preRenderStats['mask-effect'] as MaskPreRenderStats)?.didRender;\n\n // Collect layers to render\n const channels = this._groupByCollisionGroup(gl, collisionLayers);\n\n const viewport = viewports[0];\n const viewportChanged =\n !this.lastViewport || !this.lastViewport.equals(viewport) || maskEffectRendered;\n\n // Resize framebuffers to match canvas\n for (const collisionGroup in channels) {\n const collisionFBO = this.collisionFBOs[collisionGroup];\n const renderInfo = channels[collisionGroup];\n collisionFBO.resize({\n width: gl.canvas.width / DOWNSCALE,\n height: gl.canvas.height / DOWNSCALE\n });\n this._render(renderInfo, {\n effects,\n layerFilter,\n onViewportActive,\n views,\n viewport,\n viewportChanged\n });\n }\n\n // debugFBO(this.collisionFBOs[Object.keys(channels)[0]], {minimap: true});\n }\n\n private _render(\n renderInfo: RenderInfo,\n {\n effects,\n layerFilter,\n onViewportActive,\n views,\n viewport,\n viewportChanged\n }: {\n effects: PreRenderOptions['effects'];\n layerFilter: PreRenderOptions['layerFilter'];\n onViewportActive: PreRenderOptions['onViewportActive'];\n views: PreRenderOptions['views'];\n viewport: Viewport;\n viewportChanged: boolean;\n }\n ) {\n const {collisionGroup} = renderInfo;\n const oldRenderInfo = this.channels[collisionGroup];\n if (!oldRenderInfo) {\n return;\n }\n\n const needsRender =\n viewportChanged ||\n // If render info is new\n renderInfo === oldRenderInfo ||\n // If sublayers have changed\n !deepEqual(oldRenderInfo.layers, renderInfo.layers, 1) ||\n // If a sublayer's bounds have been updated\n renderInfo.layerBounds.some((b, i) => !equals(b, oldRenderInfo.layerBounds[i])) ||\n // If a sublayer's isLoaded state has been updated\n renderInfo.allLayersLoaded !== oldRenderInfo.allLayersLoaded ||\n // Some prop is in transition\n renderInfo.layers.some(layer => layer.props.transitions);\n\n this.channels[collisionGroup] = renderInfo;\n\n if (needsRender) {\n this.lastViewport = viewport;\n const collisionFBO = this.collisionFBOs[collisionGroup];\n\n // Rerender collision FBO\n this.collisionFilterPass!.renderCollisionMap(collisionFBO, {\n pass: 'collision-filter',\n isPicking: true,\n layers: renderInfo.layers,\n effects,\n layerFilter,\n viewports: viewport ? [viewport] : [],\n onViewportActive,\n views,\n moduleParameters: {\n // To avoid feedback loop forming between Framebuffer and active Texture.\n dummyCollisionMap: this.dummyCollisionMap,\n devicePixelRatio: cssToDeviceRatio(collisionFBO.gl) / DOWNSCALE\n }\n });\n }\n }\n\n /**\n * Group layers by collisionGroup\n * Returns a map from collisionGroup to render info\n */\n private _groupByCollisionGroup(\n gl: WebGLRenderingContext,\n collisionLayers: Layer<CollisionFilterExtensionProps>[]\n ): Record<string, RenderInfo> {\n const channelMap = {};\n for (const layer of collisionLayers) {\n const {collisionGroup} = layer.props;\n let channelInfo = channelMap[collisionGroup];\n if (!channelInfo) {\n channelInfo = {collisionGroup, layers: [], layerBounds: [], allLayersLoaded: true};\n channelMap[collisionGroup] = channelInfo;\n }\n channelInfo.layers.push(layer);\n channelInfo.layerBounds.push(layer.getBounds());\n if (!layer.isLoaded) {\n channelInfo.allLayersLoaded = false;\n }\n }\n\n // Create any new passes and remove any old ones\n for (const collisionGroup of Object.keys(channelMap)) {\n if (!this.collisionFBOs[collisionGroup]) {\n this.createFBO(gl, collisionGroup);\n }\n if (!this.channels[collisionGroup]) {\n this.channels[collisionGroup] = channelMap[collisionGroup];\n }\n }\n for (const collisionGroup of Object.keys(this.collisionFBOs)) {\n if (!channelMap[collisionGroup]) {\n this.destroyFBO(collisionGroup);\n }\n }\n\n return channelMap;\n }\n\n getModuleParameters(layer: Layer): {\n collisionFBO: Framebuffer;\n dummyCollisionMap: Texture2D;\n } {\n const {collisionGroup} = (layer as Layer<CollisionFilterExtensionProps>).props;\n const {collisionFBOs, dummyCollisionMap} = this;\n return {collisionFBO: collisionFBOs[collisionGroup], dummyCollisionMap};\n }\n\n cleanup(): void {\n if (this.dummyCollisionMap) {\n this.dummyCollisionMap.delete();\n this.dummyCollisionMap = undefined;\n }\n this.channels = {};\n for (const collisionGroup of Object.keys(this.collisionFBOs)) {\n this.destroyFBO(collisionGroup);\n }\n this.collisionFBOs = {};\n this.lastViewport = undefined;\n }\n\n createFBO(gl: WebGLRenderingContext, collisionGroup: string) {\n const {width, height} = gl.canvas;\n const collisionMap = new Texture2D(gl, {\n width,\n height,\n parameters: {\n [gl.TEXTURE_MIN_FILTER]: gl.NEAREST,\n [gl.TEXTURE_MAG_FILTER]: gl.NEAREST,\n [gl.TEXTURE_WRAP_S]: gl.CLAMP_TO_EDGE,\n [gl.TEXTURE_WRAP_T]: gl.CLAMP_TO_EDGE\n }\n });\n\n const depthBuffer = new Renderbuffer(gl, {format: gl.DEPTH_COMPONENT16, width, height});\n this.collisionFBOs[collisionGroup] = new Framebuffer(gl, {\n id: `Collision-${collisionGroup}`,\n width,\n height,\n attachments: {\n [gl.COLOR_ATTACHMENT0]: collisionMap,\n [gl.DEPTH_ATTACHMENT]: depthBuffer\n }\n });\n }\n\n destroyFBO(collisionGroup: string) {\n const fbo = this.collisionFBOs[collisionGroup];\n for (const attachment of Object.values(fbo.attachments as Texture2D[])) {\n attachment.delete();\n }\n fbo.delete();\n delete this.collisionFBOs[collisionGroup];\n }\n}\n"],"file":"collision-filter-effect.js"}
@@ -1,4 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import { LayerExtension } from '@deck.gl/core';
3
2
  import collision from './shader-module';
4
3
  import CollisionFilterEffect from './collision-filter-effect';
@@ -71,8 +70,6 @@ export default class CollisionFilterExtension extends LayerExtension {
71
70
  }
72
71
 
73
72
  }
74
-
75
- _defineProperty(CollisionFilterExtension, "defaultProps", defaultProps);
76
-
77
- _defineProperty(CollisionFilterExtension, "extensionName", 'CollisionFilterExtension');
73
+ CollisionFilterExtension.defaultProps = defaultProps;
74
+ CollisionFilterExtension.extensionName = 'CollisionFilterExtension';
78
75
  //# sourceMappingURL=collision-filter-extension.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collision-filter/collision-filter-extension.ts"],"names":["LayerExtension","collision","CollisionFilterEffect","defaultProps","getCollisionPriority","type","value","collisionEnabled","collisionGroup","collisionTestProps","CollisionFilterExtension","getShaders","modules","draw","uniforms","context","moduleParameters","props","collisionFBO","drawToCollisionMap","enabled","Boolean","collision_enabled","clone","initializeState","extension","getAttributeManager","deck","_addDefaultEffect","attributeManager","add","collisionPriorities","size","accessor","shaderAttributes","divisor","instanceCollisionPriorities","getNeedsPickingBuffer"],"mappings":";AAAA,SAAuCA,cAAvC,QAA4D,eAA5D;AACA,OAAOC,SAAP,MAAsB,iBAAtB;AACA,OAAOC,qBAAP,MAAk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,MAAAA,mBAAmB,EAAE;AACnBC,QAAAA,IAAI,EAAE,CADa;AAEnBC,QAAAA,QAAQ,EAAE,sBAFS;AAGnBC,QAAAA,gBAAgB,EAAE;AAChBH,UAAAA,mBAAmB,EAAE;AAACI,YAAAA,OAAO,EAAE;AAAV,WADL;AAEhBC,UAAAA,2BAA2B,EAAE;AAACD,YAAAA,OAAO,EAAE;AAAV;AAFb;AAHC;AADD,KAAtB;AAUD;;AAEDE,EAAAA,qBAAqB,GAAsD;AACzE,WAAO,KAAKpB,KAAL,CAAWV,gBAAlB;AACD;;AA9CkE;;gBAAhDG,wB,kBACGP,Y;;gBADHO,wB,mBAEI,0B","sourcesContent":["import {Accessor, Layer, LayerContext, LayerExtension} from '@deck.gl/core';\nimport collision from './shader-module';\nimport CollisionFilterEffect from './collision-filter-effect';\n\nconst defaultProps = {\n getCollisionPriority: {type: 'accessor', value: 0},\n collisionEnabled: true,\n collisionGroup: {type: 'string', value: 'default'},\n collisionTestProps: {}\n};\n\nexport type CollisionFilterExtensionProps<DataT = any> = {\n /**\n * Accessor for collision priority. Must return a number in the range -1000 -> 1000. Features with higher values are shown preferentially.\n */\n getCollisionPriority?: Accessor<DataT, number>;\n\n /**\n * Enable/disable collisions. If collisions are disabled, all objects are rendered.\n * @default true\n */\n collisionEnabled: boolean;\n\n /**\n * Collision group this layer belongs to. If it is not set, the 'default' collision group is used\n */\n collisionGroup?: string;\n\n /**\n * Props to override when rendering collision map\n */\n collisionTestProps?: {};\n};\n\n/** Allows layers to hide overlapping objects. */\nexport default class CollisionFilterExtension extends LayerExtension {\n static defaultProps = defaultProps;\n static extensionName = 'CollisionFilterExtension';\n\n getShaders(this: Layer<CollisionFilterExtensionProps>): any {\n return {modules: [collision]};\n }\n\n /* eslint-disable camelcase */\n draw(this: Layer<CollisionFilterExtensionProps>, {uniforms, context, moduleParameters}: any) {\n const {collisionEnabled} = this.props;\n const {collisionFBO, drawToCollisionMap} = moduleParameters;\n const enabled = collisionEnabled && Boolean(collisionFBO);\n uniforms.collision_enabled = enabled;\n\n if (drawToCollisionMap) {\n // Override any props with those defined in collisionTestProps\n // @ts-ignore\n this.props = this.clone(this.props.collisionTestProps).props;\n }\n }\n\n initializeState(\n this: Layer<CollisionFilterExtensionProps>,\n context: LayerContext,\n extension: this\n ) {\n if (this.getAttributeManager() === null) {\n return;\n }\n this.context.deck?._addDefaultEffect(new CollisionFilterEffect());\n const attributeManager = this.getAttributeManager();\n attributeManager!.add({\n collisionPriorities: {\n size: 1,\n accessor: 'getCollisionPriority',\n shaderAttributes: {\n collisionPriorities: {divisor: 0},\n instanceCollisionPriorities: {divisor: 1}\n }\n }\n });\n }\n\n getNeedsPickingBuffer(this: Layer<CollisionFilterExtensionProps>): boolean {\n return this.props.collisionEnabled;\n }\n}\n"],"file":"collision-filter-extension.js"}
1
+ {"version":3,"sources":["../../../src/collision-filter/collision-filter-extension.ts"],"names":["LayerExtension","collision","CollisionFilterEffect","defaultProps","getCollisionPriority","type","value","collisionEnabled","collisionGroup","collisionTestProps","CollisionFilterExtension","getShaders","modules","draw","uniforms","context","moduleParameters","props","collisionFBO","drawToCollisionMap","enabled","Boolean","collision_enabled","clone","initializeState","extension","getAttributeManager","deck","_addDefaultEffect","attributeManager","add","collisionPriorities","size","accessor","shaderAttributes","divisor","instanceCollisionPriorities","getNeedsPickingBuffer","extensionName"],"mappings":"AAAA,SAAuCA,cAAvC,QAA4D,eAA5D;AACA,OAAOC,SAAP,MAAsB,iBAAtB;AACA,OAAOC,qBAAP,MAAkC,2BAAlC;AAEA,MAAMC,YAAY,GAAG;AACnBC,EAAAA,oBAAoB,EAAE;AAACC,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GADH;AAEnBC,EAAAA,gBAAgB,EAAE,IAFC;AAGnBC,EAAAA,cAAc,EAAE;AAACH,IAAAA,IAAI,EAAE,QAAP;AAAiBC,IAAAA,KAAK,EAAE;AAAxB,GAHG;AAInBG,EAAAA,kBAA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,qBAAqB,GAAsD;AACzE,WAAO,KAAKpB,KAAL,CAAWV,gBAAlB;AACD;;AA9CkE;AAAhDG,wB,CACZP,Y,GAAeA,Y;AADHO,wB,CAEZ4B,a,GAAgB,0B","sourcesContent":["import {Accessor, Layer, LayerContext, LayerExtension} from '@deck.gl/core';\nimport collision from './shader-module';\nimport CollisionFilterEffect from './collision-filter-effect';\n\nconst defaultProps = {\n getCollisionPriority: {type: 'accessor', value: 0},\n collisionEnabled: true,\n collisionGroup: {type: 'string', value: 'default'},\n collisionTestProps: {}\n};\n\nexport type CollisionFilterExtensionProps<DataT = any> = {\n /**\n * Accessor for collision priority. Must return a number in the range -1000 -> 1000. Features with higher values are shown preferentially.\n */\n getCollisionPriority?: Accessor<DataT, number>;\n\n /**\n * Enable/disable collisions. If collisions are disabled, all objects are rendered.\n * @default true\n */\n collisionEnabled: boolean;\n\n /**\n * Collision group this layer belongs to. If it is not set, the 'default' collision group is used\n */\n collisionGroup?: string;\n\n /**\n * Props to override when rendering collision map\n */\n collisionTestProps?: {};\n};\n\n/** Allows layers to hide overlapping objects. */\nexport default class CollisionFilterExtension extends LayerExtension {\n static defaultProps = defaultProps;\n static extensionName = 'CollisionFilterExtension';\n\n getShaders(this: Layer<CollisionFilterExtensionProps>): any {\n return {modules: [collision]};\n }\n\n /* eslint-disable camelcase */\n draw(this: Layer<CollisionFilterExtensionProps>, {uniforms, context, moduleParameters}: any) {\n const {collisionEnabled} = this.props;\n const {collisionFBO, drawToCollisionMap} = moduleParameters;\n const enabled = collisionEnabled && Boolean(collisionFBO);\n uniforms.collision_enabled = enabled;\n\n if (drawToCollisionMap) {\n // Override any props with those defined in collisionTestProps\n // @ts-ignore\n this.props = this.clone(this.props.collisionTestProps).props;\n }\n }\n\n initializeState(\n this: Layer<CollisionFilterExtensionProps>,\n context: LayerContext,\n extension: this\n ) {\n if (this.getAttributeManager() === null) {\n return;\n }\n this.context.deck?._addDefaultEffect(new CollisionFilterEffect());\n const attributeManager = this.getAttributeManager();\n attributeManager!.add({\n collisionPriorities: {\n size: 1,\n accessor: 'getCollisionPriority',\n shaderAttributes: {\n collisionPriorities: {divisor: 0},\n instanceCollisionPriorities: {divisor: 1}\n }\n }\n });\n }\n\n getNeedsPickingBuffer(this: Layer<CollisionFilterExtensionProps>): boolean {\n return this.props.collisionEnabled;\n }\n}\n"],"file":"collision-filter-extension.js"}
@@ -1,9 +1,81 @@
1
1
  import { project } from '@deck.gl/core';
2
- const vs = "\n#ifdef NON_INSTANCED_MODEL\nattribute float collisionPriorities;\n#else\nattribute 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 = texture2D(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";
2
+ const vs = `
3
+ #ifdef NON_INSTANCED_MODEL
4
+ attribute float collisionPriorities;
5
+ #else
6
+ attribute float instanceCollisionPriorities;
7
+ #endif
8
+
9
+ uniform sampler2D collision_texture;
10
+ uniform bool collision_sort;
11
+ uniform bool collision_enabled;
12
+
13
+ vec2 collision_getCoords(vec4 position) {
14
+ vec4 collision_clipspace = project_common_position_to_clipspace(position);
15
+ return (1.0 + collision_clipspace.xy / collision_clipspace.w) / 2.0;
16
+ }
17
+
18
+ float collision_match(vec2 tex, vec3 pickingColor) {
19
+ vec4 collision_pickingColor = texture2D(collision_texture, tex);
20
+ float delta = dot(abs(collision_pickingColor.rgb - pickingColor), vec3(1.0));
21
+ float e = 0.001;
22
+ return step(delta, e);
23
+ }
24
+
25
+ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
26
+ if (!collision_enabled) {
27
+ return 1.0;
28
+ }
29
+
30
+ // Visibility test, sample area of 5x5 pixels in order to fade in/out.
31
+ // Due to the locality, the lookups will be cached
32
+ // This reduces the flicker present when objects are shown/hidden
33
+ const int N = 2;
34
+ float accumulator = 0.0;
35
+ vec2 step = vec2(1.0 / project_uViewportSize);
36
+
37
+ const float floatN = float(N);
38
+ vec2 delta = -floatN * step;
39
+ for(int i = -N; i <= N; i++) {
40
+ delta.x = -step.x * floatN;
41
+ for(int j = -N; j <= N; j++) {
42
+ accumulator += collision_match(texCoords + delta, pickingColor);
43
+ delta.x += step.x;
44
+ }
45
+ delta.y += step.y;
46
+ }
47
+
48
+ float W = 2.0 * floatN + 1.0;
49
+ return pow(accumulator / (W * W), 2.2);
50
+ }
51
+ `;
3
52
  const inject = {
4
- 'vs:#decl': "\n float collision_fade = 1.0;\n",
5
- '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 ",
6
- 'vs:DECKGL_FILTER_COLOR': "\n color.a *= collision_fade;\n "
53
+ 'vs:#decl': `
54
+ float collision_fade = 1.0;
55
+ `,
56
+ 'vs:DECKGL_FILTER_GL_POSITION': `
57
+ if (collision_sort) {
58
+ #ifdef NON_INSTANCED_MODEL
59
+ float collisionPriority = collisionPriorities;
60
+ #else
61
+ float collisionPriority = instanceCollisionPriorities;
62
+ #endif
63
+ position.z = -0.001 * collisionPriority * position.w; // Support range -1000 -> 1000
64
+ }
65
+
66
+ if (collision_enabled) {
67
+ vec4 collision_common_position = project_position(vec4(geometry.worldPosition, 1.0));
68
+ vec2 collision_texCoords = collision_getCoords(collision_common_position);
69
+ collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);
70
+ if (collision_fade < 0.0001) {
71
+ // Position outside clip space bounds to discard
72
+ position = vec4(0.0, 0.0, 2.0, 1.0);
73
+ }
74
+ }
75
+ `,
76
+ 'vs:DECKGL_FILTER_COLOR': `
77
+ color.a *= collision_fade;
78
+ `
7
79
  };
8
80
 
9
81
  const getCollisionUniforms = (opts, uniforms) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collision-filter/shader-module.ts"],"names":["project","vs","inject","getCollisionUniforms","opts","uniforms","collisionFBO","drawToCollisionMap","dummyCollisionMap","collision_sort","Boolean","collision_texture","name","dependencies","getUniforms"],"mappings":"AACA,SAAQA,OAAR,QAAsB,eAAtB;AAGA,MAAMC,EAAE,i9CAAR;AAmDA,MAAMC,MAAM,GAAG;AACb,iDADa;AAIb,mwBAJa;AAwBb;AAxBa,CAAf;;AAsCA,MAAMC,oBAAoB,GAAG,CAC3BC,IAD2B,EAE3BC,QAF2B,KAGL;AACtB,MAAI,CAACD,IAAD,IAAS,EAAE,uBAAuBA,IAAzB,CAAb,EAA6C;AAC3C,WAAO,EAAP;AACD;;AACD,QAAM;AAACE,IAAAA,YAAD;AAAeC,IAAAA,kBAAf;AAAmCC,IAAAA;AAAnC,MAAwDJ,IAA9D;AACA,SAAO;AACLK,IAAAA,cAAc,EAAEC,OAAO,CAACH,kBAAD,CADlB;AAELI,IAAAA,iBAAiB,EAAE,CAACJ,kBAAD,IAAuBD,YAAvB,GAAsCA,YAAtC,GAAqDE;AAFnE,GAAP;AAID,CAZD;;AAcA,eAAe;AACbI,EAAAA,IAAI,EAAE,WADO;AAEbC,EAAAA,YAAY,EAAE,CAACb,OAAD,CAFD;AAGbC,EAAAA,EAHa;AAIbC,EAAAA,MAJa;AAKbY,EAAAA,WAAW,EAAEX;AALA,CAAf","sourcesContent":["import {Framebuffer, Texture2D} from '@luma.gl/core';\nimport {project} from '@deck.gl/core';\nimport type {_ShaderModule as ShaderModule} from '@deck.gl/core';\n\nconst vs = `\n#ifdef NON_INSTANCED_MODEL\nattribute float collisionPriorities;\n#else\nattribute 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 = texture2D(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?: Texture2D;\n};\n\n/* eslint-disable camelcase */\ntype CollisionUniforms = {collision_sort?: boolean; collision_texture?: Framebuffer | Texture2D};\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: !drawToCollisionMap && collisionFBO ? collisionFBO : dummyCollisionMap\n };\n};\n\nexport default {\n name: 'collision',\n dependencies: [project],\n vs,\n inject,\n getUniforms: getCollisionUniforms\n} as ShaderModule;\n"],"file":"shader-module.js"}
1
+ {"version":3,"sources":["../../../src/collision-filter/shader-module.ts"],"names":["project","vs","inject","getCollisionUniforms","opts","uniforms","collisionFBO","drawToCollisionMap","dummyCollisionMap","collision_sort","Boolean","collision_texture","name","dependencies","getUniforms"],"mappings":"AACA,SAAQA,OAAR,QAAsB,eAAtB;AAGA,MAAMC,EAAE,GAAI;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAjDA;AAmDA,MAAMC,MAAM,GAAG;AACb,cAAa;AACf;AACA,CAHe;AAIb,kCAAiC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAvBe;AAwBb,4BAA2B;AAC7B;AACA;AA1Be,CAAf;;AAsCA,MAAMC,oBAAoB,GAAG,CAC3BC,IAD2B,EAE3BC,QAF2B,KAGL;AACtB,MAAI,CAACD,IAAD,IAAS,EAAE,uBAAuBA,IAAzB,CAAb,EAA6C;AAC3C,WAAO,EAAP;AACD;;AACD,QAAM;AAACE,IAAAA,YAAD;AAAeC,IAAAA,kBAAf;AAAmCC,IAAAA;AAAnC,MAAwDJ,IAA9D;AACA,SAAO;AACLK,IAAAA,cAAc,EAAEC,OAAO,CAACH,kBAAD,CADlB;AAELI,IAAAA,iBAAiB,EAAE,CAACJ,kBAAD,IAAuBD,YAAvB,GAAsCA,YAAtC,GAAqDE;AAFnE,GAAP;AAID,CAZD;;AAcA,eAAe;AACbI,EAAAA,IAAI,EAAE,WADO;AAEbC,EAAAA,YAAY,EAAE,CAACb,OAAD,CAFD;AAGbC,EAAAA,EAHa;AAIbC,EAAAA,MAJa;AAKbY,EAAAA,WAAW,EAAEX;AALA,CAAf","sourcesContent":["import {Framebuffer, Texture2D} from '@luma.gl/core';\nimport {project} from '@deck.gl/core';\nimport type {_ShaderModule as ShaderModule} from '@deck.gl/core';\n\nconst vs = `\n#ifdef NON_INSTANCED_MODEL\nattribute float collisionPriorities;\n#else\nattribute 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 = texture2D(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?: Texture2D;\n};\n\n/* eslint-disable camelcase */\ntype CollisionUniforms = {collision_sort?: boolean; collision_texture?: Framebuffer | Texture2D};\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: !drawToCollisionMap && collisionFBO ? collisionFBO : dummyCollisionMap\n };\n};\n\nexport default {\n name: 'collision',\n dependencies: [project],\n vs,\n inject,\n getUniforms: getCollisionUniforms\n} as ShaderModule;\n"],"file":"shader-module.js"}
@@ -1,6 +1,49 @@
1
1
  import { Model, Texture2D, Framebuffer, isWebGL2 } from '@luma.gl/core';
2
- const AGGREGATE_VS = "#define SHADER_NAME data-filter-vertex-shader\n\n#ifdef FLOAT_TARGET\n attribute float filterIndices;\n attribute float filterPrevIndices;\n#else\n attribute vec2 filterIndices;\n attribute vec2 filterPrevIndices;\n#endif\n\nvarying 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";
3
- const AGGREGATE_FS = "#define SHADER_NAME data-filter-fragment-shader\nprecision highp float;\n\nvarying vec4 vColor;\n\nvoid main() {\n if (dataFilter_value < 0.5) {\n discard;\n }\n gl_FragColor = vColor;\n}\n";
2
+ const AGGREGATE_VS = `\
3
+ #define SHADER_NAME data-filter-vertex-shader
4
+
5
+ #ifdef FLOAT_TARGET
6
+ attribute float filterIndices;
7
+ attribute float filterPrevIndices;
8
+ #else
9
+ attribute vec2 filterIndices;
10
+ attribute vec2 filterPrevIndices;
11
+ #endif
12
+
13
+ varying vec4 vColor;
14
+ const float component = 1.0 / 255.0;
15
+
16
+ void main() {
17
+ #ifdef FLOAT_TARGET
18
+ dataFilter_value *= float(filterIndices != filterPrevIndices);
19
+ gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
20
+ vColor = vec4(0.0, 0.0, 0.0, 1.0);
21
+ #else
22
+ // Float texture is not supported: pack result into 4 channels x 256 px x 64px
23
+ dataFilter_value *= float(filterIndices.x != filterPrevIndices.x);
24
+ float col = filterIndices.x;
25
+ float row = filterIndices.y * 4.0;
26
+ float channel = floor(row);
27
+ row = fract(row);
28
+ vColor = component * vec4(bvec4(channel == 0.0, channel == 1.0, channel == 2.0, channel == 3.0));
29
+ gl_Position = vec4(col * 2.0 - 1.0, row * 2.0 - 1.0, 0.0, 1.0);
30
+ #endif
31
+ gl_PointSize = 1.0;
32
+ }
33
+ `;
34
+ const AGGREGATE_FS = `\
35
+ #define SHADER_NAME data-filter-fragment-shader
36
+ precision highp float;
37
+
38
+ varying vec4 vColor;
39
+
40
+ void main() {
41
+ if (dataFilter_value < 0.5) {
42
+ discard;
43
+ }
44
+ gl_FragColor = vColor;
45
+ }
46
+ `;
4
47
  export function supportsFloatTarget(gl) {
5
48
  return Boolean(gl.getExtension('EXT_float_blend') && (gl.getExtension('EXT_color_buffer_float') || gl.getExtension('WEBGL_color_buffer_float')));
6
49
  }