@deck.gl/extensions 8.9.10 → 8.9.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@deck.gl/extensions",
3
3
  "description": "Plug-and-play functionalities for deck.gl layers",
4
4
  "license": "MIT",
5
- "version": "8.9.10",
5
+ "version": "8.9.11",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
@@ -40,5 +40,5 @@
40
40
  "@math.gl/web-mercator": "^3.6.2",
41
41
  "gl-matrix": "^3.0.0"
42
42
  },
43
- "gitHead": "95b67b17698635f96c9e26562f2d5bac28f96cbf"
43
+ "gitHead": "ec059b9b2bde01fecc8017ed39b9898d85794561"
44
44
  }
@@ -10,7 +10,7 @@ export default class CollideEffect implements Effect {
10
10
  private collideFBOs;
11
11
  private dummyCollideMap?;
12
12
  private lastViewport?;
13
- preRender(gl: WebGLRenderingContext, { effects: allEffects, layers, layerFilter, viewports, onViewportActive, views, isPicking, preRenderStats }: PreRenderOptions): void;
13
+ preRender(gl: WebGLRenderingContext, { effects: allEffects, layers, layerFilter, viewports, onViewportActive, views, pass, preRenderStats }: PreRenderOptions): void;
14
14
  private _render;
15
15
  /**
16
16
  * Group layers by collideGroup
@@ -1 +1 @@
1
- {"version":3,"file":"collide-effect.d.ts","sourceRoot":"","sources":["../../src/collide/collide-effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAgB,SAAS,EAAmB,MAAM,eAAe,CAAC;AAGrF,OAAO,KAAK,EAAC,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAW,MAAM,eAAe,CAAC;AAoB7E,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,MAAM;IAClD,EAAE,SAAoB;IACtB,KAAK,OAAQ;IACb,YAAY,UAAQ;IACpB,KAAK,SAAK;IAEV,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,WAAW,CAAC,CAA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AAgB,EAChB,KAAK,EACL,IAAI,EACJ,cAAmB,EACpB,EAAE,gBAAgB,GAClB,IAAI;IAuDP,OAAO,CAAC,OAAO;IAyDf;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAsC5B,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG;QACjC,UAAU,EAAE,WAAW,CAAC;QACxB,eAAe,EAAE,SAAS,CAAC;KAC5B;IAMD,OAAO,IAAI,IAAI;IAaf,SAAS,CAAC,EAAE,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM;IAyBzD,UAAU,CAAC,YAAY,EAAE,MAAM;CAQhC"}
@@ -3,6 +3,7 @@ import { _LayersPass as LayersPass, LayersPassRenderOptions } from '@deck.gl/cor
3
3
  declare type CollidePassRenderOptions = LayersPassRenderOptions & {};
4
4
  export default class CollidePass extends LayersPass {
5
5
  renderCollideMap(target: Framebuffer, options: CollidePassRenderOptions): any;
6
+ shouldDrawLayer(layer: any): any;
6
7
  getModuleParameters(): {
7
8
  drawToCollideMap: boolean;
8
9
  pickingActive: number;
@@ -1 +1 @@
1
- {"version":3,"file":"collide-pass.d.ts","sourceRoot":"","sources":["../../src/collide/collide-pass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAiB,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAC,WAAW,IAAI,UAAU,EAAE,uBAAuB,EAAC,MAAM,eAAe,CAAC;AAEjF,aAAK,wBAAwB,GAAG,uBAAuB,GAAG,EAAE,CAAC;AAE7D,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,UAAU;IACjD,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,wBAAwB;IAmBvE,mBAAmB;;;;;;CASpB"}
1
+ {"version":3,"file":"collide-pass.d.ts","sourceRoot":"","sources":["../../src/collide/collide-pass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAiB,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAC,WAAW,IAAI,UAAU,EAAE,uBAAuB,EAAC,MAAM,eAAe,CAAC;AAEjF,aAAK,wBAAwB,GAAG,uBAAuB,GAAG,EAAE,CAAC;AAE7D,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,UAAU;IACjD,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,wBAAwB;IAqBvE,eAAe,CAAC,KAAK,KAAA;IAQrB,mBAAmB;;;;;;CASpB"}
@@ -33,6 +33,7 @@ export default class CollideExtension extends LayerExtension {
33
33
  collideTestProps: {};
34
34
  };
35
35
  static extensionName: string;
36
+ isEnabled(layer: Layer<CollideExtensionProps>): boolean;
36
37
  getShaders(this: Layer<CollideExtensionProps>): any;
37
38
  draw(this: Layer<CollideExtensionProps>, { uniforms, context, moduleParameters }: any): void;
38
39
  initializeState(this: Layer<CollideExtensionProps>, context: LayerContext, extension: this): void;
@@ -1 +1 @@
1
- {"version":3,"file":"collide.d.ts","sourceRoot":"","sources":["../../src/collide/collide.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AAW5E,oBAAY,qBAAqB,CAAC,KAAK,GAAG,GAAG,IAAI;IAC/C;;OAEG;IACH,kBAAkB,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAE7C;;;OAGG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,gBAAgB,CAAC,EAAE,EAAE,CAAC;CACvB,CAAC;AAEF,iDAAiD;AACjD,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,cAAc;IAC1D,MAAM,CAAC,YAAY;;;;;;;;;;;MAAgB;IACnC,MAAM,CAAC,aAAa,SAAsB;IAE1C,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,qBAAqB,CAAC,GAAG,GAAG;IAKnD,I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Y,EAAE,SAAS,EAAE,IAAI;IAkB1F,qBAAqB,CAAC,IAAI,EAAE,KAAK,CAAC,qBAAqB,CAAC,GAAG,OAAO;CAGnE"}
@@ -1 +1 @@
1
- {"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/collide/shader-module.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,aAAa,IAAI,YAAY,EAAC,MAAM,eAAe,CAAC;;AAwGjE,wBAMkB"}
1
+ {"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/collide/shader-module.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,aAAa,IAAI,YAAY,EAAC,MAAM,eAAe,CAAC;;AAuGjE,wBAMkB"}
@@ -0,0 +1,6 @@
1
+ declare const EffectOrder: {
2
+ MaskEffect: number;
3
+ CollideEffect: number;
4
+ };
5
+ export default EffectOrder;
6
+ //# sourceMappingURL=effect-order.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effect-order.d.ts","sourceRoot":"","sources":["../src/effect-order.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,WAAW;;;CAGhB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,83 +0,0 @@
1
- // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
20
- import { LayerExtension } from '@deck.gl/core';
21
- import shaderModule from './shader-module';
22
- const defaultProps = {
23
- getBrushingTarget: { type: 'accessor', value: [0, 0] },
24
- brushingTarget: 'source',
25
- brushingEnabled: true,
26
- brushingRadius: 10000
27
- };
28
- export default class BrushingExtension extends LayerExtension {
29
- getShaders(extension) {
30
- return {
31
- modules: [shaderModule]
32
- };
33
- }
34
- initializeState(context, extension) {
35
- const attributeManager = this.getAttributeManager();
36
- if (attributeManager) {
37
- attributeManager.add({
38
- brushingTargets: {
39
- size: 2,
40
- accessor: 'getBrushingTarget',
41
- // Hack: extension's defaultProps is not merged with the layer's defaultProps,
42
- // So we can't use the standard accessor when the prop is undefined
43
- update: !this.props.getBrushingTarget && extension.useConstantTargetPositions,
44
- shaderAttributes: {
45
- brushingTargets: {
46
- divisor: 0
47
- },
48
- instanceBrushingTargets: {
49
- divisor: 1
50
- }
51
- }
52
- }
53
- });
54
- }
55
- // Trigger redraw when mouse moves
56
- // TODO - expose this in a better way
57
- extension.onMouseMove = () => {
58
- this.getCurrentLayer().setNeedsRedraw();
59
- };
60
- if (this.context.deck) {
61
- this.context.deck.eventManager.on({
62
- pointermove: extension.onMouseMove,
63
- pointerleave: extension.onMouseMove
64
- });
65
- }
66
- }
67
- finalizeState(extension) {
68
- // Remove event listeners
69
- if (this.context.deck) {
70
- this.context.deck.eventManager.off({
71
- pointermove: extension.onMouseMove,
72
- pointerleave: extension.onMouseMove
73
- });
74
- }
75
- }
76
- useConstantTargetPositions(attribute) {
77
- attribute.constant = true;
78
- attribute.value = new Float32Array(2);
79
- return;
80
- }
81
- }
82
- BrushingExtension.extensionName = 'BrushingExtension';
83
- BrushingExtension.defaultProps = defaultProps;
@@ -1,116 +0,0 @@
1
- // Copyright (c) 2015-2017 Uber Technologies, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
20
- import { project } from '@deck.gl/core';
21
- const vs = `
22
- uniform bool brushing_enabled;
23
- uniform int brushing_target;
24
- uniform vec2 brushing_mousePos;
25
- uniform float brushing_radius;
26
-
27
- #ifdef NON_INSTANCED_MODEL
28
- attribute vec2 brushingTargets;
29
- #else
30
- attribute vec2 instanceBrushingTargets;
31
- #endif
32
-
33
- varying float brushing_isVisible;
34
-
35
- bool brushing_isPointInRange(vec2 position) {
36
- if (!brushing_enabled) {
37
- return true;
38
- }
39
- vec2 source_commonspace = project_position(position);
40
- vec2 target_commonspace = project_position(brushing_mousePos);
41
- float distance = length((target_commonspace - source_commonspace) / project_uCommonUnitsPerMeter.xy);
42
-
43
- return distance <= brushing_radius;
44
- }
45
-
46
- bool brushing_arePointsInRange(vec2 sourcePos, vec2 targetPos) {
47
- return brushing_isPointInRange(sourcePos) || brushing_isPointInRange(targetPos);
48
- }
49
-
50
- void brushing_setVisible(bool visible) {
51
- brushing_isVisible = float(visible);
52
- }
53
- `;
54
- const fs = `
55
- uniform bool brushing_enabled;
56
- varying float brushing_isVisible;
57
- `;
58
- const TARGET = {
59
- source: 0,
60
- target: 1,
61
- custom: 2,
62
- source_target: 3
63
- };
64
- const inject = {
65
- 'vs:DECKGL_FILTER_GL_POSITION': `
66
- vec2 brushingTarget;
67
- vec2 brushingSource;
68
- if (brushing_target == 3) {
69
- brushingTarget = geometry.worldPositionAlt.xy;
70
- brushingSource = geometry.worldPosition.xy;
71
- } else if (brushing_target == 0) {
72
- brushingTarget = geometry.worldPosition.xy;
73
- } else if (brushing_target == 1) {
74
- brushingTarget = geometry.worldPositionAlt.xy;
75
- } else {
76
- #ifdef NON_INSTANCED_MODEL
77
- brushingTarget = brushingTargets;
78
- #else
79
- brushingTarget = instanceBrushingTargets;
80
- #endif
81
- }
82
- bool visible;
83
- if (brushing_target == 3) {
84
- visible = brushing_arePointsInRange(brushingSource, brushingTarget);
85
- } else {
86
- visible = brushing_isPointInRange(brushingTarget);
87
- }
88
- brushing_setVisible(visible);
89
- `,
90
- 'fs:DECKGL_FILTER_COLOR': `
91
- if (brushing_enabled && brushing_isVisible < 0.5) {
92
- discard;
93
- }
94
- `
95
- };
96
- export default {
97
- name: 'brushing',
98
- dependencies: [project],
99
- vs,
100
- fs,
101
- inject,
102
- getUniforms: opts => {
103
- if (!opts || !opts.viewport) {
104
- return {};
105
- }
106
- const { brushingEnabled = true, brushingRadius = 10000, brushingTarget = 'source', mousePosition, viewport } = opts;
107
- return {
108
- brushing_enabled: Boolean(brushingEnabled && mousePosition && viewport.containsPixel(mousePosition)),
109
- brushing_radius: brushingRadius,
110
- brushing_target: TARGET[brushingTarget] || 0,
111
- brushing_mousePos: mousePosition
112
- ? viewport.unproject([mousePosition.x - viewport.x, mousePosition.y - viewport.y])
113
- : [0, 0]
114
- };
115
- }
116
- };
@@ -1,114 +0,0 @@
1
- // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
20
- import { LayerExtension } from '@deck.gl/core';
21
- const defaultProps = {
22
- clipBounds: [0, 0, 1, 1]
23
- };
24
- const shaderFunction = `
25
- uniform vec4 clip_bounds;
26
-
27
- bool clip_isInBounds(vec2 position) {
28
- return position.x >= clip_bounds[0] && position.y >= clip_bounds[1] && position.x < clip_bounds[2] && position.y < clip_bounds[3];
29
- }
30
- `;
31
- /*
32
- * The vertex-shader version clips geometries by their anchor position
33
- * e.g. ScatterplotLayer - show if the center of a circle is within bounds
34
- */
35
- const shaderModuleVs = {
36
- name: 'clip-vs',
37
- vs: shaderFunction
38
- };
39
- const injectionVs = {
40
- 'vs:#decl': `
41
- varying float clip_isVisible;
42
- `,
43
- 'vs:DECKGL_FILTER_GL_POSITION': `
44
- clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy));
45
- `,
46
- 'fs:#decl': `
47
- varying float clip_isVisible;
48
- `,
49
- 'fs:DECKGL_FILTER_COLOR': `
50
- if (clip_isVisible < 0.5) discard;
51
- `
52
- };
53
- /*
54
- * The fragment-shader version clips pixels at the bounds
55
- * e.g. PolygonLayer - show the part of the polygon that intersect with the bounds
56
- */
57
- const shaderModuleFs = {
58
- name: 'clip-fs',
59
- fs: shaderFunction
60
- };
61
- const injectionFs = {
62
- 'vs:#decl': `
63
- varying vec2 clip_commonPosition;
64
- `,
65
- 'vs:DECKGL_FILTER_GL_POSITION': `
66
- clip_commonPosition = geometry.position.xy;
67
- `,
68
- 'fs:#decl': `
69
- varying vec2 clip_commonPosition;
70
- `,
71
- 'fs:DECKGL_FILTER_COLOR': `
72
- if (!clip_isInBounds(clip_commonPosition)) discard;
73
- `
74
- };
75
- export default class ClipExtension extends LayerExtension {
76
- getShaders() {
77
- // If `clipByInstance: true`, the entire object is shown/hidden based on its anchor position (done by vertex shader)
78
- // Otherwise, the object is trimmed by the clip bounds (done by fragment shader)
79
- // Default behavior: consider a layer instanced if it has attribute `instancePositions`
80
- let clipByInstance = 'instancePositions' in this.getAttributeManager().attributes;
81
- // Users can override by setting the `clipByInstance` prop
82
- if ('clipByInstance' in this.props) {
83
- clipByInstance = this.props.clipByInstance;
84
- }
85
- this.state.clipByInstance = clipByInstance;
86
- return clipByInstance
87
- ? {
88
- modules: [shaderModuleVs],
89
- inject: injectionVs
90
- }
91
- : {
92
- modules: [shaderModuleFs],
93
- inject: injectionFs
94
- };
95
- }
96
- draw({ uniforms }) {
97
- const { clipBounds = defaultProps.clipBounds } = this.props;
98
- if (this.state.clipByInstance) {
99
- uniforms.clip_bounds = clipBounds;
100
- }
101
- else {
102
- const corner0 = this.projectPosition([clipBounds[0], clipBounds[1], 0]);
103
- const corner1 = this.projectPosition([clipBounds[2], clipBounds[3], 0]);
104
- uniforms.clip_bounds = [
105
- Math.min(corner0[0], corner1[0]),
106
- Math.min(corner0[1], corner1[1]),
107
- Math.max(corner0[0], corner1[0]),
108
- Math.max(corner0[1], corner1[1])
109
- ];
110
- }
111
- }
112
- }
113
- ClipExtension.extensionName = 'ClipExtension';
114
- ClipExtension.defaultProps = defaultProps;
@@ -1,98 +0,0 @@
1
- import { Model, Texture2D, Framebuffer, isWebGL2 } from '@luma.gl/core';
2
- import GL from '@luma.gl/constants';
3
- const AGGREGATE_VS = `\
4
- #define SHADER_NAME data-filter-vertex-shader
5
-
6
- #ifdef FLOAT_TARGET
7
- attribute float filterIndices;
8
- attribute float filterPrevIndices;
9
- #else
10
- attribute vec2 filterIndices;
11
- attribute vec2 filterPrevIndices;
12
- #endif
13
-
14
- varying vec4 vColor;
15
- const float component = 1.0 / 255.0;
16
-
17
- void main() {
18
- #ifdef FLOAT_TARGET
19
- dataFilter_value *= float(filterIndices != filterPrevIndices);
20
- gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
21
- vColor = vec4(0.0, 0.0, 0.0, 1.0);
22
- #else
23
- // Float texture is not supported: pack result into 4 channels x 256 px x 64px
24
- dataFilter_value *= float(filterIndices.x != filterPrevIndices.x);
25
- float col = filterIndices.x;
26
- float row = filterIndices.y * 4.0;
27
- float channel = floor(row);
28
- row = fract(row);
29
- vColor = component * vec4(bvec4(channel == 0.0, channel == 1.0, channel == 2.0, channel == 3.0));
30
- gl_Position = vec4(col * 2.0 - 1.0, row * 2.0 - 1.0, 0.0, 1.0);
31
- #endif
32
- gl_PointSize = 1.0;
33
- }
34
- `;
35
- const AGGREGATE_FS = `\
36
- #define SHADER_NAME data-filter-fragment-shader
37
- precision highp float;
38
-
39
- varying vec4 vColor;
40
-
41
- void main() {
42
- if (dataFilter_value < 0.5) {
43
- discard;
44
- }
45
- gl_FragColor = vColor;
46
- }
47
- `;
48
- export function supportsFloatTarget(gl) {
49
- // 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!
50
- return (gl.getExtension('EXT_float_blend') &&
51
- // WebGL 2
52
- (gl.getExtension('EXT_color_buffer_float') ||
53
- // WebGL 1
54
- gl.getExtension('WEBGL_color_buffer_float')));
55
- }
56
- // A 1x1 framebuffer object that encodes the total count of filtered items
57
- export function getFramebuffer(gl, useFloatTarget) {
58
- if (useFloatTarget) {
59
- return new Framebuffer(gl, {
60
- width: 1,
61
- height: 1,
62
- attachments: {
63
- [GL.COLOR_ATTACHMENT0]: new Texture2D(gl, {
64
- format: isWebGL2(gl) ? GL.RGBA32F : GL.RGBA,
65
- type: GL.FLOAT,
66
- mipmaps: false
67
- })
68
- }
69
- });
70
- }
71
- return new Framebuffer(gl, {
72
- width: 256,
73
- height: 64,
74
- depth: false
75
- });
76
- }
77
- // Increments the counter based on dataFilter_value
78
- export function getModel(gl, shaderOptions, useFloatTarget) {
79
- shaderOptions.defines.NON_INSTANCED_MODEL = 1;
80
- if (useFloatTarget) {
81
- shaderOptions.defines.FLOAT_TARGET = 1;
82
- }
83
- return new Model(gl, {
84
- id: 'data-filter-aggregation-model',
85
- vertexCount: 1,
86
- isInstanced: false,
87
- drawMode: GL.POINTS,
88
- vs: AGGREGATE_VS,
89
- fs: AGGREGATE_FS,
90
- ...shaderOptions
91
- });
92
- }
93
- export const parameters = {
94
- blend: true,
95
- blendFunc: [GL.ONE, GL.ONE, GL.ONE, GL.ONE],
96
- blendEquation: [GL.FUNC_ADD, GL.FUNC_ADD],
97
- depthTest: false
98
- };
@@ -1,159 +0,0 @@
1
- // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
20
- import { LayerExtension } from '@deck.gl/core';
21
- import { shaderModule, shaderModule64 } from './shader-module';
22
- import * as aggregator from './aggregator';
23
- import { readPixelsToArray, clear } from '@luma.gl/core';
24
- import GL from '@luma.gl/constants';
25
- const defaultProps = {
26
- getFilterValue: { type: 'accessor', value: 0 },
27
- onFilteredItemsChange: { type: 'function', value: null, compare: false },
28
- filterEnabled: true,
29
- filterRange: [-1, 1],
30
- filterSoftRange: null,
31
- filterTransformSize: true,
32
- filterTransformColor: true
33
- };
34
- const DATA_TYPE_FROM_SIZE = {
35
- 1: 'float',
36
- 2: 'vec2',
37
- 3: 'vec3',
38
- 4: 'vec4'
39
- };
40
- export default class DataFilterExtension extends LayerExtension {
41
- constructor({ filterSize = 1, fp64 = false, countItems = false } = {}) {
42
- if (!DATA_TYPE_FROM_SIZE[filterSize]) {
43
- throw new Error('filterSize out of range');
44
- }
45
- super({ filterSize, fp64, countItems });
46
- }
47
- getShaders(extension) {
48
- const { filterSize, fp64 } = extension.opts;
49
- return {
50
- modules: [fp64 ? shaderModule64 : shaderModule],
51
- defines: {
52
- DATAFILTER_TYPE: DATA_TYPE_FROM_SIZE[filterSize],
53
- DATAFILTER_DOUBLE: Boolean(fp64)
54
- }
55
- };
56
- }
57
- initializeState(context, extension) {
58
- const attributeManager = this.getAttributeManager();
59
- if (attributeManager) {
60
- attributeManager.add({
61
- filterValues: {
62
- size: extension.opts.filterSize,
63
- type: extension.opts.fp64 ? GL.DOUBLE : GL.FLOAT,
64
- accessor: 'getFilterValue',
65
- shaderAttributes: {
66
- filterValues: {
67
- divisor: 0
68
- },
69
- instanceFilterValues: {
70
- divisor: 1
71
- }
72
- }
73
- }
74
- });
75
- }
76
- const { gl } = this.context;
77
- if (attributeManager && extension.opts.countItems) {
78
- const useFloatTarget = aggregator.supportsFloatTarget(gl);
79
- // This attribute is needed for variable-width data, e.g. Path, SolidPolygon, Text
80
- // The vertex shader checks if a vertex has the same "index" as the previous vertex
81
- // so that we only write one count cross multiple vertices of the same object
82
- attributeManager.add({
83
- filterIndices: {
84
- size: useFloatTarget ? 1 : 2,
85
- vertexOffset: 1,
86
- type: GL.UNSIGNED_BYTE,
87
- normalized: true,
88
- accessor: (object, { index }) => {
89
- const i = object && object.__source ? object.__source.index : index;
90
- return useFloatTarget ? (i + 1) % 255 : [(i + 1) % 255, Math.floor(i / 255) % 255];
91
- },
92
- shaderAttributes: {
93
- filterPrevIndices: {
94
- vertexOffset: 0
95
- },
96
- filterIndices: {
97
- vertexOffset: 1
98
- }
99
- }
100
- }
101
- });
102
- const filterFBO = aggregator.getFramebuffer(gl, useFloatTarget);
103
- const filterModel = aggregator.getModel(gl, extension.getShaders(extension), useFloatTarget);
104
- this.setState({ filterFBO, filterModel });
105
- }
106
- }
107
- updateState({ props, oldProps }) {
108
- if (this.state.filterModel) {
109
- const attributeManager = this.getAttributeManager();
110
- const filterNeedsUpdate = attributeManager.attributes.filterValues.needsUpdate() ||
111
- props.filterEnabled !== oldProps.filterEnabled ||
112
- props.filterRange !== oldProps.filterRange ||
113
- props.filterSoftRange !== oldProps.filterSoftRange;
114
- if (filterNeedsUpdate) {
115
- this.setState({ filterNeedsUpdate });
116
- }
117
- }
118
- }
119
- draw(params, extension) {
120
- const { filterFBO, filterModel, filterNeedsUpdate } = this.state;
121
- const { onFilteredItemsChange } = this.props;
122
- if (filterNeedsUpdate && onFilteredItemsChange && filterModel) {
123
- const { attributes: { filterValues, filterIndices } } = this.getAttributeManager();
124
- filterModel.setVertexCount(this.getNumInstances());
125
- const { gl } = this.context;
126
- clear(gl, { framebuffer: filterFBO, color: [0, 0, 0, 0] });
127
- filterModel
128
- .updateModuleSettings(params.moduleParameters)
129
- .setAttributes({
130
- ...filterValues.getShaderAttributes(),
131
- ...(filterIndices && filterIndices.getShaderAttributes())
132
- })
133
- .draw({
134
- framebuffer: filterFBO,
135
- parameters: {
136
- ...aggregator.parameters,
137
- viewport: [0, 0, filterFBO.width, filterFBO.height]
138
- }
139
- });
140
- const color = readPixelsToArray(filterFBO);
141
- let count = 0;
142
- for (let i = 0; i < color.length; i++) {
143
- count += color[i];
144
- }
145
- onFilteredItemsChange({ id: this.id, count });
146
- this.state.filterNeedsUpdate = false;
147
- }
148
- }
149
- finalizeState() {
150
- const { filterFBO, filterModel } = this.state;
151
- if (filterFBO) {
152
- filterFBO.color.delete();
153
- filterFBO.delete();
154
- filterModel.delete();
155
- }
156
- }
157
- }
158
- DataFilterExtension.extensionName = 'DataFilterExtension';
159
- DataFilterExtension.defaultProps = defaultProps;