@deck.gl/extensions 8.6.0 → 8.6.4

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.
@@ -7,25 +7,11 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
-
16
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
17
-
18
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
19
-
20
10
  var _core = require("@deck.gl/core");
21
11
 
22
12
  var _shaderModule = _interopRequireDefault(require("./shader-module"));
23
13
 
24
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
25
-
26
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
27
-
28
- var defaultProps = {
14
+ const defaultProps = {
29
15
  getBrushingTarget: {
30
16
  type: 'accessor',
31
17
  value: [0, 0]
@@ -35,79 +21,62 @@ var defaultProps = {
35
21
  brushingRadius: 10000
36
22
  };
37
23
 
38
- var BrushingExtension = function (_LayerExtension) {
39
- (0, _inherits2.default)(BrushingExtension, _LayerExtension);
40
-
41
- var _super = _createSuper(BrushingExtension);
42
-
43
- function BrushingExtension() {
44
- (0, _classCallCheck2.default)(this, BrushingExtension);
45
- return _super.apply(this, arguments);
24
+ class BrushingExtension extends _core.LayerExtension {
25
+ getShaders(extension) {
26
+ return {
27
+ modules: [_shaderModule.default]
28
+ };
46
29
  }
47
30
 
48
- (0, _createClass2.default)(BrushingExtension, [{
49
- key: "getShaders",
50
- value: function getShaders(extension) {
51
- return {
52
- modules: [_shaderModule.default]
53
- };
54
- }
55
- }, {
56
- key: "initializeState",
57
- value: function initializeState(context, extension) {
58
- var _this = this;
59
-
60
- var attributeManager = this.getAttributeManager();
61
-
62
- if (attributeManager) {
63
- attributeManager.add({
64
- brushingTargets: {
65
- size: 2,
66
- accessor: 'getBrushingTarget',
67
- update: !this.props.getBrushingTarget && extension.useConstantTargetPositions,
68
- shaderAttributes: {
69
- brushingTargets: {
70
- divisor: 0
71
- },
72
- instanceBrushingTargets: {
73
- divisor: 1
74
- }
31
+ initializeState(context, extension) {
32
+ const attributeManager = this.getAttributeManager();
33
+
34
+ if (attributeManager) {
35
+ attributeManager.add({
36
+ brushingTargets: {
37
+ size: 2,
38
+ accessor: 'getBrushingTarget',
39
+ update: !this.props.getBrushingTarget && extension.useConstantTargetPositions,
40
+ shaderAttributes: {
41
+ brushingTargets: {
42
+ divisor: 0
43
+ },
44
+ instanceBrushingTargets: {
45
+ divisor: 1
75
46
  }
76
47
  }
77
- });
78
- }
48
+ }
49
+ });
50
+ }
79
51
 
80
- extension.onMouseMove = function () {
81
- _this.getCurrentLayer().setNeedsRedraw();
82
- };
52
+ extension.onMouseMove = () => {
53
+ this.getCurrentLayer().setNeedsRedraw();
54
+ };
83
55
 
84
- if (this.context.deck) {
85
- this.context.deck.eventManager.on({
86
- pointermove: extension.onMouseMove,
87
- pointerleave: extension.onMouseMove
88
- });
89
- }
56
+ if (this.context.deck) {
57
+ this.context.deck.eventManager.on({
58
+ pointermove: extension.onMouseMove,
59
+ pointerleave: extension.onMouseMove
60
+ });
90
61
  }
91
- }, {
92
- key: "finalizeState",
93
- value: function finalizeState(extension) {
94
- if (this.context.deck) {
95
- this.context.deck.eventManager.off({
96
- pointermove: extension.onMouseMove,
97
- pointerleave: extension.onMouseMove
98
- });
99
- }
100
- }
101
- }, {
102
- key: "useConstantTargetPositions",
103
- value: function useConstantTargetPositions(attribute) {
104
- attribute.constant = true;
105
- attribute.value = new Float32Array(2);
106
- return;
62
+ }
63
+
64
+ finalizeState(extension) {
65
+ if (this.context.deck) {
66
+ this.context.deck.eventManager.off({
67
+ pointermove: extension.onMouseMove,
68
+ pointerleave: extension.onMouseMove
69
+ });
107
70
  }
108
- }]);
109
- return BrushingExtension;
110
- }(_core.LayerExtension);
71
+ }
72
+
73
+ useConstantTargetPositions(attribute) {
74
+ attribute.constant = true;
75
+ attribute.value = new Float32Array(2);
76
+ return;
77
+ }
78
+
79
+ }
111
80
 
112
81
  exports.default = BrushingExtension;
113
82
  BrushingExtension.extensionName = 'BrushingExtension';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/brushing/brushing.js"],"names":["defaultProps","getBrushingTarget","type","value","brushingTarget","brushingEnabled","brushingRadius","BrushingExtension","extension","modules","shaderModule","context","attributeManager","getAttributeManager","add","brushingTargets","size","accessor","update","props","useConstantTargetPositions","shaderAttributes","divisor","instanceBrushingTargets","onMouseMove","getCurrentLayer","setNeedsRedraw","deck","eventManager","on","pointermove","pointerleave","off","attribute","constant","Float32Array","LayerExtension","extensionName"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA;;AACA;;;;;;AAEA,IAAMA,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;;IAQqBC,iB;;;;;;;;;;;;+BACRC,S,EAAW;AACp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AAqB,IAArB;AACAD,MAAAA,SAAS,CAAC9B,KAAV,GAAkB,IAAIgC,YAAJ,CAAiB,CAAjB,CAAlB;AACA;AACD;;;EAxD4CC,oB;;;AA2D/C7B,iBAAiB,CAAC8B,aAAlB,GAAkC,mBAAlC;AACA9B,iBAAiB,CAACP,YAAlB,GAAiCA,YAAjC","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\nconst defaultProps = {\n getBrushingTarget: {type: 'accessor', value: [0, 0]},\n\n brushingTarget: 'source',\n brushingEnabled: true,\n brushingRadius: 10000\n};\n\nexport default class BrushingExtension extends LayerExtension {\n getShaders(extension) {\n return {\n modules: [shaderModule]\n };\n }\n\n initializeState(context, extension) {\n const attributeManager = this.getAttributeManager();\n if (attributeManager) {\n attributeManager.add({\n brushingTargets: {\n size: 2,\n accessor: 'getBrushingTarget',\n // Hack: extension's defaultProps is not merged with the layer's defaultProps,\n // So we can't use the standard accessor when the prop is undefined\n update: !this.props.getBrushingTarget && extension.useConstantTargetPositions,\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 extension.onMouseMove = () => {\n this.getCurrentLayer().setNeedsRedraw();\n };\n if (this.context.deck) {\n this.context.deck.eventManager.on({\n pointermove: extension.onMouseMove,\n pointerleave: extension.onMouseMove\n });\n }\n }\n\n finalizeState(extension) {\n // Remove event listeners\n if (this.context.deck) {\n this.context.deck.eventManager.off({\n pointermove: extension.onMouseMove,\n pointerleave: extension.onMouseMove\n });\n }\n }\n\n useConstantTargetPositions(attribute) {\n attribute.constant = true;\n attribute.value = new Float32Array(2);\n return;\n }\n}\n\nBrushingExtension.extensionName = 'BrushingExtension';\nBrushingExtension.defaultProps = defaultProps;\n"],"file":"brushing.js"}
1
+ {"version":3,"sources":["../../../src/brushing/brushing.js"],"names":["defaultProps","getBrushingTarget","type","value","brushingTarget","brushingEnabled","brushingRadius","BrushingExtension","LayerExtension","getShaders","extension","modules","shaderModule","initializeState","context","attributeManager","getAttributeManager","add","brushingTargets","size","accessor","update","props","useConstantTargetPositions","shaderAttributes","divisor","instanceBrushingTargets","onMouseMove","getCurrentLayer","setNeedsRedraw","deck","eventManager","on","pointermove","pointerleave","finalizeState","off","attribute","constant","Float32Array","extensionName"],"mappings":";;;;;;;;;AAoBA;;AACA;;AAEA,MAAMA,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;;AAQe,MAAMC,iBAAN,SAAgCC,oB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CAACiB;AAFS,OAAnC;AAID;AACF;;AAEDJ,EAAAA,0BAA0B,CAACc,SAAD,EAAY;AACpCA,IAAAA,SAAS,CAACC,QAAV,GAAqB,IAArB;AACAD,IAAAA,SAAS,CAAClC,KAAV,GAAkB,IAAIoC,YAAJ,CAAiB,CAAjB,CAAlB;AACA;AACD;;AAxD2D;;;AA2D9DhC,iBAAiB,CAACiC,aAAlB,GAAkC,mBAAlC;AACAjC,iBAAiB,CAACP,YAAlB,GAAiCA,YAAjC","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\nconst defaultProps = {\n getBrushingTarget: {type: 'accessor', value: [0, 0]},\n\n brushingTarget: 'source',\n brushingEnabled: true,\n brushingRadius: 10000\n};\n\nexport default class BrushingExtension extends LayerExtension {\n getShaders(extension) {\n return {\n modules: [shaderModule]\n };\n }\n\n initializeState(context, extension) {\n const attributeManager = this.getAttributeManager();\n if (attributeManager) {\n attributeManager.add({\n brushingTargets: {\n size: 2,\n accessor: 'getBrushingTarget',\n // Hack: extension's defaultProps is not merged with the layer's defaultProps,\n // So we can't use the standard accessor when the prop is undefined\n update: !this.props.getBrushingTarget && extension.useConstantTargetPositions,\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 extension.onMouseMove = () => {\n this.getCurrentLayer().setNeedsRedraw();\n };\n if (this.context.deck) {\n this.context.deck.eventManager.on({\n pointermove: extension.onMouseMove,\n pointerleave: extension.onMouseMove\n });\n }\n }\n\n finalizeState(extension) {\n // Remove event listeners\n if (this.context.deck) {\n this.context.deck.eventManager.off({\n pointermove: extension.onMouseMove,\n pointerleave: extension.onMouseMove\n });\n }\n }\n\n useConstantTargetPositions(attribute) {\n attribute.constant = true;\n attribute.value = new Float32Array(2);\n return;\n }\n}\n\nBrushingExtension.extensionName = 'BrushingExtension';\nBrushingExtension.defaultProps = defaultProps;\n"],"file":"brushing.js"}
@@ -7,37 +7,36 @@ exports.default = void 0;
7
7
 
8
8
  var _core = require("@deck.gl/core");
9
9
 
10
- var vs = "\n uniform bool brushing_enabled;\n uniform int brushing_target;\n uniform vec2 brushing_mousePos;\n uniform float brushing_radius;\n\n #ifdef NON_INSTANCED_MODEL\n 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";
11
- var fs = "\n uniform bool brushing_enabled;\n varying float brushing_isVisible;\n";
12
- var TARGET = {
10
+ 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";
11
+ const fs = "\n uniform bool brushing_enabled;\n varying float brushing_isVisible;\n";
12
+ const TARGET = {
13
13
  source: 0,
14
14
  target: 1,
15
15
  custom: 2,
16
16
  source_target: 3
17
17
  };
18
- var inject = {
18
+ const inject = {
19
19
  '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 ",
20
20
  'fs:DECKGL_FILTER_COLOR': "\n if (brushing_enabled && brushing_isVisible < 0.5) {\n discard;\n }\n "
21
21
  };
22
22
  var _default = {
23
23
  name: 'brushing',
24
24
  dependencies: [_core.project],
25
- vs: vs,
26
- fs: fs,
27
- inject: inject,
28
- getUniforms: function getUniforms(opts) {
25
+ vs,
26
+ fs,
27
+ inject,
28
+ getUniforms: opts => {
29
29
  if (!opts || !opts.viewport) {
30
30
  return {};
31
31
  }
32
32
 
33
- var _opts$brushingEnabled = opts.brushingEnabled,
34
- brushingEnabled = _opts$brushingEnabled === void 0 ? true : _opts$brushingEnabled,
35
- _opts$brushingRadius = opts.brushingRadius,
36
- brushingRadius = _opts$brushingRadius === void 0 ? 10000 : _opts$brushingRadius,
37
- _opts$brushingTarget = opts.brushingTarget,
38
- brushingTarget = _opts$brushingTarget === void 0 ? 'source' : _opts$brushingTarget,
39
- mousePosition = opts.mousePosition,
40
- viewport = opts.viewport;
33
+ const {
34
+ brushingEnabled = true,
35
+ brushingRadius = 10000,
36
+ brushingTarget = 'source',
37
+ mousePosition,
38
+ viewport
39
+ } = opts;
41
40
  return {
42
41
  brushing_enabled: Boolean(brushingEnabled && mousePosition && viewport.containsPixel(mousePosition)),
43
42
  brushing_radius: brushingRadius,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/brushing/shader-module.js"],"names":["vs","fs","TARGET","source","target","custom","source_target","inject","name","dependencies","project","getUniforms","opts","viewport","brushingEnabled","brushingRadius","brushingTarget","mousePosition","brushing_enabled","Boolean","containsPixel","brushing_radius","brushing_target","brushing_mousePos","unproject","x","y"],"mappings":";;;;;;;AAmBA;;AAEA,IAAMA,EAAE,07BAAR;AAkCA,IAAMC,EAAE,8EAAR;AAKA,IAAMC,MAAM,GAAG;AACbC,EAAAA,MAAM,EAAE,CADK;AAEbC,EAAAA,MAAM,EAAE,CAFK;AAGbC,EAAAA,MAAM,EAAE,CAHK;AAIbC,EAAAA,aAAa,EAAE;AAJF,CAAf;AAOA,IAAMC,MAAM,GAAG;AACb,6zBADa;AA2Bb;AA3Ba,CAAf;eAkCe;AACbC,EAAAA,IAAI,EAAE,UADO;AAEbC,EAAAA,YAAY,EAAE,CAACC,aAAD,CAFD;AAGbV,EAAAA,EAAE,EAAFA,EAHa;AAIbC,EAAAA,EAAE,EAAFA,EAJa;AAKbM,EAAAA,MAAM,EAANA,MALa;AAMbI,EAAAA,WAAW,EAAE,qBAAAC,IAAI,EAAI;AACnB,QAAI,CAACA,IAAD,IAAS,CAACA,IAAI,CAACC,QAAnB,EAA6B;AAC3B,aAAO,EAAP;AACD;;AAHkB,gCAUfD,IAVe,CAKjBE,eALiB;AAAA,QAKjBA,eALiB,sCAKC,IALD;AAAA,+BAUfF,IAVe,CAMjBG,cANiB;AAAA,QAMjBA,cANiB,qCAMA,KANA;AAAA,+BAUfH,IAVe,CAOjBI,cAPiB;AAAA,QAOjBA,cAPiB,qCAOA,QAPA;AAAA,QAQjBC,aARiB,GAUfL,IAVe,CAQjBK,aARiB;AAAA,QASjBJ,QATiB,GAUfD,IAVe,CASjBC,QATiB;AAWnB,WAAO;AACLK,MAAAA,gBAAgB,EAAEC,OAAO,CACvBL,eAAe,IAAIG,aAAnB,IAAoCJ,QAAQ,CAACO,aAAT,CAAuBH,aAAvB,CADb,CADpB;AAILI,MAAAA,eAAe,EAAEN,cAJZ;AAKLO,MAAAA,eAAe,EAAEpB,MAAM,CAACc,cAAD,CAAN,IAA0B,CALtC;AAMLO,MAAAA,iBAAiB,EAAEN,aAAa,GAC5BJ,QAAQ,CAACW,SAAT,CAAmB,CAACP,aAAa,CAACQ,CAAd,GAAkBZ,QAAQ,CAACY,CAA5B,EAA+BR,aAAa,CAACS,CAAd,GAAkBb,QAAQ,CAACa,CAA1D,CAAnB,CAD4B,GAE5B,CAAC,CAAD,EAAI,CAAJ;AARC,KAAP;AAUD;AA3BY,C","sourcesContent":["// Copyright (c) 2015-2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\nimport {project} from '@deck.gl/core';\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 => {\n if (!opts || !opts.viewport) {\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};\n"],"file":"shader-module.js"}
1
+ {"version":3,"sources":["../../../src/brushing/shader-module.js"],"names":["vs","fs","TARGET","source","target","custom","source_target","inject","name","dependencies","project","getUniforms","opts","viewport","brushingEnabled","brushingRadius","brushingTarget","mousePosition","brushing_enabled","Boolean","containsPixel","brushing_radius","brushing_target","brushing_mousePos","unproject","x","y"],"mappings":";;;;;;;AAmBA;;AAEA,MAAMA,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;eAkCe;AACbC,EAAAA,IAAI,EAAE,UADO;AAEbC,EAAAA,YAAY,EAAE,CAACC,aAAD,CAFD;AAGbV,EAAAA,EAHa;AAIbC,EAAAA,EAJa;AAKbM,EAAAA,MALa;AAMbI,EAAAA,WAAW,EAAEC,IAAI,IAAI;AACnB,QAAI,CAACA,IAAD,IAAS,CAACA,IAAI,CAACC,QAAnB,EAA6B;AAC3B,aAAO,EAAP;AACD;;AACD,UAAM;AACJC,MAAAA,eAAe,GAAG,IADd;AAEJC,MAAAA,cAAc,GAAG,KAFb;AAGJC,MAAAA,cAAc,GAAG,QAHb;AAIJC,MAAAA,aAJI;AAKJJ,MAAAA;AALI,QAMFD,IANJ;AAOA,WAAO;AACLM,MAAAA,gBAAgB,EAAEC,OAAO,CACvBL,eAAe,IAAIG,aAAnB,IAAoCJ,QAAQ,CAACO,aAAT,CAAuBH,aAAvB,CADb,CADpB;AAILI,MAAAA,eAAe,EAAEN,cAJZ;AAKLO,MAAAA,eAAe,EAAEpB,MAAM,CAACc,cAAD,CAAN,IAA0B,CALtC;AAMLO,MAAAA,iBAAiB,EAAEN,aAAa,GAC5BJ,QAAQ,CAACW,SAAT,CAAmB,CAACP,aAAa,CAACQ,CAAd,GAAkBZ,QAAQ,CAACY,CAA5B,EAA+BR,aAAa,CAACS,CAAd,GAAkBb,QAAQ,CAACa,CAA1D,CAAnB,CAD4B,GAE5B,CAAC,CAAD,EAAI,CAAJ;AARC,KAAP;AAUD;AA3BY,C","sourcesContent":["// Copyright (c) 2015-2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\nimport {project} from '@deck.gl/core';\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 => {\n if (!opts || !opts.viewport) {\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};\n"],"file":"shader-module.js"}
@@ -1,99 +1,72 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.default = void 0;
9
7
 
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
-
16
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
17
-
18
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
19
-
20
8
  var _core = require("@deck.gl/core");
21
9
 
22
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
23
-
24
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
25
-
26
- var defaultProps = {
10
+ const defaultProps = {
27
11
  clipBounds: [0, 0, 1, 1]
28
12
  };
29
- var 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";
30
- var shaderModuleVs = {
13
+ 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";
14
+ const shaderModuleVs = {
31
15
  name: 'clip-vs',
32
16
  vs: shaderFunction
33
17
  };
34
- var injectionVs = {
18
+ const injectionVs = {
35
19
  'vs:#decl': "\nvarying float clip_isVisible;\n",
36
20
  'vs:DECKGL_FILTER_GL_POSITION': "\n clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy));\n",
37
21
  'fs:#decl': "\nvarying float clip_isVisible;\n",
38
22
  'fs:DECKGL_FILTER_COLOR': "\n if (clip_isVisible < 0.5) discard;\n"
39
23
  };
40
- var shaderModuleFs = {
24
+ const shaderModuleFs = {
41
25
  name: 'clip-fs',
42
26
  fs: shaderFunction
43
27
  };
44
- var injectionFs = {
28
+ const injectionFs = {
45
29
  'vs:#decl': "\nvarying vec2 clip_commonPosition;\n",
46
30
  'vs:DECKGL_FILTER_GL_POSITION': "\n clip_commonPosition = geometry.position.xy;\n",
47
31
  'fs:#decl': "\nvarying vec2 clip_commonPosition;\n",
48
32
  'fs:DECKGL_FILTER_COLOR': "\n if (!clip_isInBounds(clip_commonPosition)) discard;\n"
49
33
  };
50
34
 
51
- var ClipExtension = function (_LayerExtension) {
52
- (0, _inherits2.default)(ClipExtension, _LayerExtension);
35
+ class ClipExtension extends _core.LayerExtension {
36
+ getShaders() {
37
+ let clipByInstance = ('instancePositions' in this.getAttributeManager().attributes);
53
38
 
54
- var _super = _createSuper(ClipExtension);
39
+ if ('clipByInstance' in this.props) {
40
+ clipByInstance = this.props.clipByInstance;
41
+ }
55
42
 
56
- function ClipExtension() {
57
- (0, _classCallCheck2.default)(this, ClipExtension);
58
- return _super.apply(this, arguments);
43
+ this.state.clipByInstance = clipByInstance;
44
+ return clipByInstance ? {
45
+ modules: [shaderModuleVs],
46
+ inject: injectionVs
47
+ } : {
48
+ modules: [shaderModuleFs],
49
+ inject: injectionFs
50
+ };
59
51
  }
60
52
 
61
- (0, _createClass2.default)(ClipExtension, [{
62
- key: "getShaders",
63
- value: function getShaders() {
64
- var clipByInstance = ('instancePositions' in this.getAttributeManager().attributes);
65
-
66
- if ('clipByInstance' in this.props) {
67
- clipByInstance = this.props.clipByInstance;
68
- }
69
-
70
- this.state.clipByInstance = clipByInstance;
71
- return clipByInstance ? {
72
- modules: [shaderModuleVs],
73
- inject: injectionVs
74
- } : {
75
- modules: [shaderModuleFs],
76
- inject: injectionFs
77
- };
53
+ draw({
54
+ uniforms
55
+ }) {
56
+ const {
57
+ clipBounds = defaultProps.clipBounds
58
+ } = this.props;
59
+
60
+ if (this.state.clipByInstance) {
61
+ uniforms.clip_bounds = clipBounds;
62
+ } else {
63
+ const corner0 = this.projectPosition([clipBounds[0], clipBounds[1], 0]);
64
+ const corner1 = this.projectPosition([clipBounds[2], clipBounds[3], 0]);
65
+ uniforms.clip_bounds = [Math.min(corner0[0], corner1[0]), Math.min(corner0[1], corner1[1]), Math.max(corner0[0], corner1[0]), Math.max(corner0[1], corner1[1])];
78
66
  }
79
- }, {
80
- key: "draw",
81
- value: function draw(_ref) {
82
- var uniforms = _ref.uniforms;
83
- var _this$props$clipBound = this.props.clipBounds,
84
- clipBounds = _this$props$clipBound === void 0 ? defaultProps.clipBounds : _this$props$clipBound;
67
+ }
85
68
 
86
- if (this.state.clipByInstance) {
87
- uniforms.clip_bounds = clipBounds;
88
- } else {
89
- var corner0 = this.projectPosition([clipBounds[0], clipBounds[1], 0]);
90
- var corner1 = this.projectPosition([clipBounds[2], clipBounds[3], 0]);
91
- uniforms.clip_bounds = [Math.min(corner0[0], corner1[0]), Math.min(corner0[1], corner1[1]), Math.max(corner0[0], corner1[0]), Math.max(corner0[1], corner1[1])];
92
- }
93
- }
94
- }]);
95
- return ClipExtension;
96
- }(_core.LayerExtension);
69
+ }
97
70
 
98
71
  exports.default = ClipExtension;
99
72
  ClipExtension.extensionName = 'ClipExtension';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/clip/clip.js"],"names":["defaultProps","clipBounds","shaderFunction","shaderModuleVs","name","vs","injectionVs","shaderModuleFs","fs","injectionFs","ClipExtension","clipByInstance","getAttributeManager","attributes","props","state","modules","inject","uniforms","clip_bounds","corner0","projectPosition","corner1","Math","min","max","LayerExtension","extensionName"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA;;;;;;AAEA,IAAMA,YAAY,GAAG;AACnBC,EAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV;AADO,CAArB;AAIA,IAAMC,cAAc,oNAApB;AAYA,IAAMC,cAAc,GAAG;AACrBC,EAAAA,IAAI,EAA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D,CAAX,EAAgBA,UAAU,CAAC,CAAD,CAA1B,EAA+B,CAA/B,CAArB,CAAhB;AAEAiB,QAAAA,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;;;EAvCwCI,oB;;;AA0C3ChB,aAAa,CAACiB,aAAd,GAA8B,eAA9B;AACAjB,aAAa,CAACV,YAAd,GAA6BA,YAA7B","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';\n\nconst defaultProps = {\n clipBounds: [0, 0, 1, 1]\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 = {\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 = {\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\nexport default class ClipExtension extends LayerExtension {\n getShaders() {\n // If `clipByInstance: true`, the entire object is shown/hidden based on its anchor position (done by vertex shader)\n // Otherwise, the object is trimmed by the clip bounds (done by fragment shader)\n\n // Default behavior: consider a layer instanced if it has attribute `instancePositions`\n let clipByInstance = 'instancePositions' in this.getAttributeManager().attributes;\n // Users can override by setting the `clipByInstance` prop\n if ('clipByInstance' in this.props) {\n clipByInstance = 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 draw({uniforms}) {\n const {clipBounds = defaultProps.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\nClipExtension.extensionName = 'ClipExtension';\nClipExtension.defaultProps = defaultProps;\n"],"file":"clip.js"}
1
+ {"version":3,"sources":["../../../src/clip/clip.js"],"names":["defaultProps","clipBounds","shaderFunction","shaderModuleVs","name","vs","injectionVs","shaderModuleFs","fs","injectionFs","ClipExtension","LayerExtension","getShaders","clipByInstance","getAttributeManager","attributes","props","state","modules","inject","draw","uniforms","clip_bounds","corner0","projectPosition","corner1","Math","min","max","extensionName"],"mappings":";;;;;;;AAoBA;;AAEA,MAAMA,YAAY,GAAG;AACnBC,EAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV;AADO,CAArB;AAIA,MAAMC,cAAc,oNAApB;AAYA,MAAMC,cAAc,GAAG;AACrBC,EAAAA,IAAI,EAAE,SADe;AAErBC,EAAAA,EAAE,EAAEH;AAFiB,CAAvB;AAKA,MAAMI,WAAW,GAAG;AAClB,iDADkB;AAIlB,6GAJkB;AAOlB,iDAPkB;AAUlB;AAVkB,CAApB;AAmBA,MAAMC,cAAc,GAAG;AACrBH,EAAAA,IAAI,EAAE,SADe;AAErBI,EAAAA,EAAE,EAAEN;AAFiB,CAAvB;AAKA,MAAMO,WAAW,GAAG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ErBC,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;;AAvCuD;;;AA0C1Df,aAAa,CAACmB,aAAd,GAA8B,eAA9B;AACAnB,aAAa,CAACV,YAAd,GAA6BA,YAA7B","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';\n\nconst defaultProps = {\n clipBounds: [0, 0, 1, 1]\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 = {\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 = {\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\nexport default class ClipExtension extends LayerExtension {\n getShaders() {\n // If `clipByInstance: true`, the entire object is shown/hidden based on its anchor position (done by vertex shader)\n // Otherwise, the object is trimmed by the clip bounds (done by fragment shader)\n\n // Default behavior: consider a layer instanced if it has attribute `instancePositions`\n let clipByInstance = 'instancePositions' in this.getAttributeManager().attributes;\n // Users can override by setting the `clipByInstance` prop\n if ('clipByInstance' in this.props) {\n clipByInstance = 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 draw({uniforms}) {\n const {clipBounds = defaultProps.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\nClipExtension.extensionName = 'ClipExtension';\nClipExtension.defaultProps = defaultProps;\n"],"file":"clip.js"}
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -10,16 +8,10 @@ exports.getFramebuffer = getFramebuffer;
10
8
  exports.getModel = getModel;
11
9
  exports.parameters = void 0;
12
10
 
13
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
-
15
11
  var _core = require("@luma.gl/core");
16
12
 
17
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
18
-
19
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
20
-
21
- var 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";
22
- var 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";
13
+ 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";
14
+ 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";
23
15
 
24
16
  function supportsFloatTarget(gl) {
25
17
  return gl.getExtension('EXT_float_blend') && (gl.getExtension('EXT_color_buffer_float') || gl.getExtension('WEBGL_color_buffer_float'));
@@ -30,11 +22,13 @@ function getFramebuffer(gl, useFloatTarget) {
30
22
  return new _core.Framebuffer(gl, {
31
23
  width: 1,
32
24
  height: 1,
33
- attachments: (0, _defineProperty2.default)({}, 36064, new _core.Texture2D(gl, {
34
- format: (0, _core.isWebGL2)(gl) ? 34836 : 6408,
35
- type: 5126,
36
- mipmaps: false
37
- }))
25
+ attachments: {
26
+ [36064]: new _core.Texture2D(gl, {
27
+ format: (0, _core.isWebGL2)(gl) ? 34836 : 6408,
28
+ type: 5126,
29
+ mipmaps: false
30
+ })
31
+ }
38
32
  });
39
33
  }
40
34
 
@@ -52,17 +46,18 @@ function getModel(gl, shaderOptions, useFloatTarget) {
52
46
  shaderOptions.defines.FLOAT_TARGET = 1;
53
47
  }
54
48
 
55
- return new _core.Model(gl, _objectSpread({
49
+ return new _core.Model(gl, {
56
50
  id: 'data-filter-aggregation-model',
57
51
  vertexCount: 1,
58
52
  isInstanced: false,
59
53
  drawMode: 0,
60
54
  vs: AGGREGATE_VS,
61
- fs: AGGREGATE_FS
62
- }, shaderOptions));
55
+ fs: AGGREGATE_FS,
56
+ ...shaderOptions
57
+ });
63
58
  }
64
59
 
65
- var parameters = {
60
+ const parameters = {
66
61
  blend: true,
67
62
  blendFunc: [1, 1, 1, 1],
68
63
  blendEquation: [32774, 32774],
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/data-filter/aggregator.js"],"names":["AGGREGATE_VS","AGGREGATE_FS","supportsFloatTarget","gl","getExtension","getFramebuffer","useFloatTarget","Framebuffer","width","height","attachments","Texture2D","format","type","mipmaps","depth","getModel","shaderOptions","defines","NON_INSTANCED_MODEL","FLOAT_TARGET","Model","id","vertexCount","isInstanced","drawMode","vs","fs","parameters","blend","blendFunc","blendEquation","depthTest"],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;AAGA,IAAMA,YAAY,89BAAlB;AAiCA,IAAMC,YAAY,wMAAlB;;AAcO,SAASC,mBAAT,CAA6BC,EAA7B,EAAiC;AAEtC,SACEA,EAAE,CAACC,YAAH,CAAgB,iBAAhB,MAECD,EAAE,CAACC,YAAH,CAAgB,wBAAhB,KAECD,EAAE,CAACC,YAAH,CAAgB,0BAAhB,CAJF,CADF;AAOD;;AAGM,SAASC,cAAT,CAAwBF,EAAxB,EAA4BG,cAA5B,EAA4C;AACjD,MAAIA,cAAJ,EAAoB;AAClB,WAAO,IAAIC,iBAAJ,CAAgBJ,EAAhB,EAAoB;AACzBK,MAAAA,KAAK,EAAE,CADkB;AAEzBC,MAAAA,MAAM,EAAE,CAFiB;AAGzBC,MAAAA,WAAW,2CACe,IAAIC,eAAJ,CAAcR,EAAd,EAAkB;AACxCS,QAAAA,MAAM,EAAE,oBAAST,EAAT,gBADgC;AAExCU,QAAAA,IAAI,MAFoC;AAGxCC,QAAAA,OAAO,EAAE;AAH+B,OAAlB,CADf;AAHc,KAApB,CAAP;AAWD;;AACD,SAAO,IAAIP,iBAAJ,CAAgBJ,EAAhB,EAAoB;AACzBK,IAAAA,KAAK,EAAE,GADkB;AAEzBC,IAAAA,MAAM,EAAE,EAFiB;AAGzBM,IAAAA,KAAK,EAAE;AAHkB,GAApB,CAAP;AAKD;;AAGM,SAASC,QAAT,CAAkBb,EAAlB,EAAsBc,aAAtB,EAAqCX,cAArC,EAAqD;AAC1DW,EAAAA,aAAa,CAACC,OAAd,CAAsBC,mBAAtB,GAA4C,CAA5C;;AACA,MAAIb,cAAJ,EAAoB;AAClBW,IAAAA,aAAa,CAACC,OAAd,CAAsBE,YAAtB,GAAqC,CAArC;AACD;;AAED,SAAO,IAAIC,WAAJ,CAAUlB,EAAV;AACLmB,IAAAA,EAAE,EAAE,+BADC;AAELC,IAAAA,WAAW,EAAE,CAFR;AAGLC,IAAAA,WAAW,EAAE,KAHR;AAILC,IAAAA,QAAQ,GAJH;AAKLC,IAAAA,EAAE,EAAE1B,YALC;AAML2B,IAAAA,EAAE,EAAE1B;AANC,KAOFgB,aAPE,EAAP;AASD;;AAEM,IAAMW,UAAU,GAAG;AACxBC,EAAAA,KAAK,EAAE,IADiB;AAExBC,EAAAA,SAAS,EAAE,YAFa;AAGxBC,EAAAA,aAAa,EAAE,cAHS;AAIxBC,EAAAA,SAAS,EAAE;AAJa,CAAnB","sourcesContent":["import {Model, Texture2D, Framebuffer, isWebGL2} from '@luma.gl/core';\r\nimport GL from '@luma.gl/constants';\r\n\r\nconst AGGREGATE_VS = `\\\r\n#define SHADER_NAME data-filter-vertex-shader\r\n\r\n#ifdef FLOAT_TARGET\r\n attribute float filterIndices;\r\n attribute float filterPrevIndices;\r\n#else\r\n attribute vec2 filterIndices;\r\n attribute vec2 filterPrevIndices;\r\n#endif\r\n\r\nvarying vec4 vColor;\r\nconst float component = 1.0 / 255.0;\r\n\r\nvoid main() {\r\n #ifdef FLOAT_TARGET\r\n dataFilter_value *= float(filterIndices != filterPrevIndices);\r\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\r\n vColor = vec4(0.0, 0.0, 0.0, 1.0);\r\n #else\r\n // Float texture is not supported: pack result into 4 channels x 256 px x 64px\r\n dataFilter_value *= float(filterIndices.x != filterPrevIndices.x);\r\n float col = filterIndices.x;\r\n float row = filterIndices.y * 4.0;\r\n float channel = floor(row);\r\n row = fract(row);\r\n vColor = component * vec4(bvec4(channel == 0.0, channel == 1.0, channel == 2.0, channel == 3.0));\r\n gl_Position = vec4(col * 2.0 - 1.0, row * 2.0 - 1.0, 0.0, 1.0);\r\n #endif\r\n gl_PointSize = 1.0;\r\n}\r\n`;\r\n\r\nconst AGGREGATE_FS = `\\\r\n#define SHADER_NAME data-filter-fragment-shader\r\nprecision highp float;\r\n\r\nvarying vec4 vColor;\r\n\r\nvoid main() {\r\n if (dataFilter_value < 0.5) {\r\n discard;\r\n }\r\n gl_FragColor = vColor;\r\n}\r\n`;\r\n\r\nexport function supportsFloatTarget(gl) {\r\n // https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices#Support_for_float_textures_doesnt_mean_you_can_render_into_them!\r\n return (\r\n gl.getExtension('EXT_float_blend') &&\r\n // WebGL 2\r\n (gl.getExtension('EXT_color_buffer_float') ||\r\n // WebGL 1\r\n gl.getExtension('WEBGL_color_buffer_float'))\r\n );\r\n}\r\n\r\n// A 1x1 framebuffer object that encodes the total count of filtered items\r\nexport function getFramebuffer(gl, useFloatTarget) {\r\n if (useFloatTarget) {\r\n return new Framebuffer(gl, {\r\n width: 1,\r\n height: 1,\r\n attachments: {\r\n [GL.COLOR_ATTACHMENT0]: new Texture2D(gl, {\r\n format: isWebGL2(gl) ? GL.RGBA32F : GL.RGBA,\r\n type: GL.FLOAT,\r\n mipmaps: false\r\n })\r\n }\r\n });\r\n }\r\n return new Framebuffer(gl, {\r\n width: 256,\r\n height: 64,\r\n depth: false\r\n });\r\n}\r\n\r\n// Increments the counter based on dataFilter_value\r\nexport function getModel(gl, shaderOptions, useFloatTarget) {\r\n shaderOptions.defines.NON_INSTANCED_MODEL = 1;\r\n if (useFloatTarget) {\r\n shaderOptions.defines.FLOAT_TARGET = 1;\r\n }\r\n\r\n return new Model(gl, {\r\n id: 'data-filter-aggregation-model',\r\n vertexCount: 1,\r\n isInstanced: false,\r\n drawMode: GL.POINTS,\r\n vs: AGGREGATE_VS,\r\n fs: AGGREGATE_FS,\r\n ...shaderOptions\r\n });\r\n}\r\n\r\nexport const parameters = {\r\n blend: true,\r\n blendFunc: [GL.ONE, GL.ONE, GL.ONE, GL.ONE],\r\n blendEquation: [GL.FUNC_ADD, GL.FUNC_ADD],\r\n depthTest: false\r\n};\r\n"],"file":"aggregator.js"}
1
+ {"version":3,"sources":["../../../src/data-filter/aggregator.js"],"names":["AGGREGATE_VS","AGGREGATE_FS","supportsFloatTarget","gl","getExtension","getFramebuffer","useFloatTarget","Framebuffer","width","height","attachments","Texture2D","format","type","mipmaps","depth","getModel","shaderOptions","defines","NON_INSTANCED_MODEL","FLOAT_TARGET","Model","id","vertexCount","isInstanced","drawMode","vs","fs","parameters","blend","blendFunc","blendEquation","depthTest"],"mappings":";;;;;;;;;;AAAA;;AAGA,MAAMA,YAAY,89BAAlB;AAiCA,MAAMC,YAAY,wMAAlB;;AAcO,SAASC,mBAAT,CAA6BC,EAA7B,EAAiC;AAEtC,SACEA,EAAE,CAACC,YAAH,CAAgB,iBAAhB,MAECD,EAAE,CAACC,YAAH,CAAgB,wBAAhB,KAECD,EAAE,CAACC,YAAH,CAAgB,0BAAhB,CAJF,CADF;AAOD;;AAGM,SAASC,cAAT,CAAwBF,EAAxB,EAA4BG,cAA5B,EAA4C;AACjD,MAAIA,cAAJ,EAAoB;AAClB,WAAO,IAAIC,iBAAJ,CAAgBJ,EAAhB,EAAoB;AACzBK,MAAAA,KAAK,EAAE,CADkB;AAEzBC,MAAAA,MAAM,EAAE,CAFiB;AAGzBC,MAAAA,WAAW,EAAE;AACX,iBAAwB,IAAIC,eAAJ,CAAcR,EAAd,EAAkB;AACxCS,UAAAA,MAAM,EAAE,oBAAST,EAAT,gBADgC;AAExCU,UAAAA,IAAI,MAFoC;AAGxCC,UAAAA,OAAO,EAAE;AAH+B,SAAlB;AADb;AAHY,KAApB,CAAP;AAWD;;AACD,SAAO,IAAIP,iBAAJ,CAAgBJ,EAAhB,EAAoB;AACzBK,IAAAA,KAAK,EAAE,GADkB;AAEzBC,IAAAA,MAAM,EAAE,EAFiB;AAGzBM,IAAAA,KAAK,EAAE;AAHkB,GAApB,CAAP;AAKD;;AAGM,SAASC,QAAT,CAAkBb,EAAlB,EAAsBc,aAAtB,EAAqCX,cAArC,EAAqD;AAC1DW,EAAAA,aAAa,CAACC,OAAd,CAAsBC,mBAAtB,GAA4C,CAA5C;;AACA,MAAIb,cAAJ,EAAoB;AAClBW,IAAAA,aAAa,CAACC,OAAd,CAAsBE,YAAtB,GAAqC,CAArC;AACD;;AAED,SAAO,IAAIC,WAAJ,CAAUlB,EAAV,EAAc;AACnBmB,IAAAA,EAAE,EAAE,+BADe;AAEnBC,IAAAA,WAAW,EAAE,CAFM;AAGnBC,IAAAA,WAAW,EAAE,KAHM;AAInBC,IAAAA,QAAQ,GAJW;AAKnBC,IAAAA,EAAE,EAAE1B,YALe;AAMnB2B,IAAAA,EAAE,EAAE1B,YANe;AAOnB,OAAGgB;AAPgB,GAAd,CAAP;AASD;;AAEM,MAAMW,UAAU,GAAG;AACxBC,EAAAA,KAAK,EAAE,IADiB;AAExBC,EAAAA,SAAS,EAAE,YAFa;AAGxBC,EAAAA,aAAa,EAAE,cAHS;AAIxBC,EAAAA,SAAS,EAAE;AAJa,CAAnB","sourcesContent":["import {Model, Texture2D, Framebuffer, isWebGL2} from '@luma.gl/core';\r\nimport GL from '@luma.gl/constants';\r\n\r\nconst AGGREGATE_VS = `\\\r\n#define SHADER_NAME data-filter-vertex-shader\r\n\r\n#ifdef FLOAT_TARGET\r\n attribute float filterIndices;\r\n attribute float filterPrevIndices;\r\n#else\r\n attribute vec2 filterIndices;\r\n attribute vec2 filterPrevIndices;\r\n#endif\r\n\r\nvarying vec4 vColor;\r\nconst float component = 1.0 / 255.0;\r\n\r\nvoid main() {\r\n #ifdef FLOAT_TARGET\r\n dataFilter_value *= float(filterIndices != filterPrevIndices);\r\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\r\n vColor = vec4(0.0, 0.0, 0.0, 1.0);\r\n #else\r\n // Float texture is not supported: pack result into 4 channels x 256 px x 64px\r\n dataFilter_value *= float(filterIndices.x != filterPrevIndices.x);\r\n float col = filterIndices.x;\r\n float row = filterIndices.y * 4.0;\r\n float channel = floor(row);\r\n row = fract(row);\r\n vColor = component * vec4(bvec4(channel == 0.0, channel == 1.0, channel == 2.0, channel == 3.0));\r\n gl_Position = vec4(col * 2.0 - 1.0, row * 2.0 - 1.0, 0.0, 1.0);\r\n #endif\r\n gl_PointSize = 1.0;\r\n}\r\n`;\r\n\r\nconst AGGREGATE_FS = `\\\r\n#define SHADER_NAME data-filter-fragment-shader\r\nprecision highp float;\r\n\r\nvarying vec4 vColor;\r\n\r\nvoid main() {\r\n if (dataFilter_value < 0.5) {\r\n discard;\r\n }\r\n gl_FragColor = vColor;\r\n}\r\n`;\r\n\r\nexport function supportsFloatTarget(gl) {\r\n // https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices#Support_for_float_textures_doesnt_mean_you_can_render_into_them!\r\n return (\r\n gl.getExtension('EXT_float_blend') &&\r\n // WebGL 2\r\n (gl.getExtension('EXT_color_buffer_float') ||\r\n // WebGL 1\r\n gl.getExtension('WEBGL_color_buffer_float'))\r\n );\r\n}\r\n\r\n// A 1x1 framebuffer object that encodes the total count of filtered items\r\nexport function getFramebuffer(gl, useFloatTarget) {\r\n if (useFloatTarget) {\r\n return new Framebuffer(gl, {\r\n width: 1,\r\n height: 1,\r\n attachments: {\r\n [GL.COLOR_ATTACHMENT0]: new Texture2D(gl, {\r\n format: isWebGL2(gl) ? GL.RGBA32F : GL.RGBA,\r\n type: GL.FLOAT,\r\n mipmaps: false\r\n })\r\n }\r\n });\r\n }\r\n return new Framebuffer(gl, {\r\n width: 256,\r\n height: 64,\r\n depth: false\r\n });\r\n}\r\n\r\n// Increments the counter based on dataFilter_value\r\nexport function getModel(gl, shaderOptions, useFloatTarget) {\r\n shaderOptions.defines.NON_INSTANCED_MODEL = 1;\r\n if (useFloatTarget) {\r\n shaderOptions.defines.FLOAT_TARGET = 1;\r\n }\r\n\r\n return new Model(gl, {\r\n id: 'data-filter-aggregation-model',\r\n vertexCount: 1,\r\n isInstanced: false,\r\n drawMode: GL.POINTS,\r\n vs: AGGREGATE_VS,\r\n fs: AGGREGATE_FS,\r\n ...shaderOptions\r\n });\r\n}\r\n\r\nexport const parameters = {\r\n blend: true,\r\n blendFunc: [GL.ONE, GL.ONE, GL.ONE, GL.ONE],\r\n blendEquation: [GL.FUNC_ADD, GL.FUNC_ADD],\r\n depthTest: false\r\n};\r\n"],"file":"aggregator.js"}