@deck.gl/extensions 9.0.40 → 9.1.0-beta.3

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 (160) hide show
  1. package/dist/brushing/brushing-extension.d.ts +1 -0
  2. package/dist/brushing/brushing-extension.d.ts.map +1 -1
  3. package/dist/brushing/brushing-extension.js +16 -19
  4. package/dist/brushing/brushing-extension.js.map +1 -0
  5. package/dist/brushing/shader-module.d.ts +8 -2
  6. package/dist/brushing/shader-module.d.ts.map +1 -1
  7. package/dist/brushing/shader-module.js +75 -50
  8. package/dist/brushing/shader-module.js.map +1 -0
  9. package/dist/clip/clip-extension.d.ts +5 -2
  10. package/dist/clip/clip-extension.d.ts.map +1 -1
  11. package/dist/clip/clip-extension.js +37 -42
  12. package/dist/clip/clip-extension.js.map +1 -0
  13. package/dist/collision-filter/collision-filter-effect.d.ts +4 -4
  14. package/dist/collision-filter/collision-filter-effect.d.ts.map +1 -1
  15. package/dist/collision-filter/collision-filter-effect.js +28 -13
  16. package/dist/collision-filter/collision-filter-effect.js.map +1 -0
  17. package/dist/collision-filter/collision-filter-extension.d.ts +1 -1
  18. package/dist/collision-filter/collision-filter-extension.d.ts.map +1 -1
  19. package/dist/collision-filter/collision-filter-extension.js +6 -6
  20. package/dist/collision-filter/collision-filter-extension.js.map +1 -0
  21. package/dist/collision-filter/collision-filter-pass.d.ts +9 -5
  22. package/dist/collision-filter/collision-filter-pass.d.ts.map +1 -1
  23. package/dist/collision-filter/collision-filter-pass.js +15 -4
  24. package/dist/collision-filter/collision-filter-pass.js.map +1 -0
  25. package/dist/collision-filter/shader-module.d.ts +3 -2
  26. package/dist/collision-filter/shader-module.d.ts.map +1 -1
  27. package/dist/collision-filter/shader-module.js +75 -52
  28. package/dist/collision-filter/shader-module.js.map +1 -0
  29. package/dist/data-filter/aggregator.d.ts +4 -10
  30. package/dist/data-filter/aggregator.d.ts.map +1 -1
  31. package/dist/data-filter/aggregator.js +15 -8
  32. package/dist/data-filter/aggregator.js.map +1 -0
  33. package/dist/data-filter/data-filter-extension.d.ts.map +1 -1
  34. package/dist/data-filter/data-filter-extension.js +49 -39
  35. package/dist/data-filter/data-filter-extension.js.map +1 -0
  36. package/dist/data-filter/shader-module.d.ts +12 -5
  37. package/dist/data-filter/shader-module.d.ts.map +1 -1
  38. package/dist/data-filter/shader-module.js +190 -131
  39. package/dist/data-filter/shader-module.js.map +1 -0
  40. package/dist/dist.dev.js +2720 -2037
  41. package/dist/fill-style/fill-style-extension.d.ts.map +1 -1
  42. package/dist/fill-style/fill-style-extension.js +12 -4
  43. package/dist/fill-style/fill-style-extension.js.map +1 -0
  44. package/dist/fill-style/shader-module.d.ts +64 -6
  45. package/dist/fill-style/shader-module.d.ts.map +1 -1
  46. package/dist/fill-style/shader-module.js +74 -51
  47. package/dist/fill-style/shader-module.js.map +1 -0
  48. package/dist/fp64/fp64-extension.d.ts +1 -0
  49. package/dist/fp64/fp64-extension.d.ts.map +1 -1
  50. package/dist/fp64/fp64-extension.js +8 -19
  51. package/dist/fp64/fp64-extension.js.map +1 -0
  52. package/dist/fp64/project64.d.ts +2 -2
  53. package/dist/fp64/project64.d.ts.map +1 -1
  54. package/dist/fp64/project64.glsl.d.ts +1 -1
  55. package/dist/fp64/project64.glsl.d.ts.map +1 -1
  56. package/dist/fp64/project64.glsl.js +19 -21
  57. package/dist/fp64/project64.glsl.js.map +1 -0
  58. package/dist/fp64/project64.js +25 -24
  59. package/dist/fp64/project64.js.map +1 -0
  60. package/dist/index.cjs +1034 -528
  61. package/dist/index.cjs.map +4 -4
  62. package/dist/index.d.ts +1 -0
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +4 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/mask/mask-effect.d.ts +5 -3
  67. package/dist/mask/mask-effect.d.ts.map +1 -1
  68. package/dist/mask/mask-effect.js +13 -5
  69. package/dist/mask/mask-effect.js.map +1 -0
  70. package/dist/mask/mask-extension.d.ts +1 -1
  71. package/dist/mask/mask-extension.d.ts.map +1 -1
  72. package/dist/mask/mask-extension.js +14 -8
  73. package/dist/mask/mask-extension.js.map +1 -0
  74. package/dist/mask/mask-pass.d.ts +2 -43
  75. package/dist/mask/mask-pass.d.ts.map +1 -1
  76. package/dist/mask/mask-pass.js +5 -1
  77. package/dist/mask/mask-pass.js.map +1 -0
  78. package/dist/mask/shader-module.d.ts +60 -3
  79. package/dist/mask/shader-module.d.ts.map +1 -1
  80. package/dist/mask/shader-module.js +74 -46
  81. package/dist/mask/shader-module.js.map +1 -0
  82. package/dist/path-style/path-style-extension.d.ts.map +1 -1
  83. package/dist/path-style/path-style-extension.js +21 -24
  84. package/dist/path-style/path-style-extension.js.map +1 -0
  85. package/dist/path-style/shaders.glsl.d.ts.map +1 -1
  86. package/dist/path-style/shaders.glsl.js +12 -7
  87. package/dist/path-style/shaders.glsl.js.map +1 -0
  88. package/dist/terrain/height-map-builder.d.ts.map +1 -1
  89. package/dist/terrain/height-map-builder.js +4 -0
  90. package/dist/terrain/height-map-builder.js.map +1 -0
  91. package/dist/terrain/shader-module.d.ts +60 -6
  92. package/dist/terrain/shader-module.d.ts.map +1 -1
  93. package/dist/terrain/shader-module.js +70 -61
  94. package/dist/terrain/shader-module.js.map +1 -0
  95. package/dist/terrain/terrain-cover.d.ts.map +1 -1
  96. package/dist/terrain/terrain-cover.js +4 -0
  97. package/dist/terrain/terrain-cover.js.map +1 -0
  98. package/dist/terrain/terrain-effect.d.ts +4 -2
  99. package/dist/terrain/terrain-effect.d.ts.map +1 -1
  100. package/dist/terrain/terrain-effect.js +32 -18
  101. package/dist/terrain/terrain-effect.js.map +1 -0
  102. package/dist/terrain/terrain-extension.d.ts.map +1 -1
  103. package/dist/terrain/terrain-extension.js +4 -0
  104. package/dist/terrain/terrain-extension.js.map +1 -0
  105. package/dist/terrain/terrain-pass.d.ts +6 -41
  106. package/dist/terrain/terrain-pass.d.ts.map +1 -1
  107. package/dist/terrain/terrain-pass.js +12 -1
  108. package/dist/terrain/terrain-pass.js.map +1 -0
  109. package/dist/terrain/terrain-picking-pass.d.ts +7 -1
  110. package/dist/terrain/terrain-picking-pass.d.ts.map +1 -1
  111. package/dist/terrain/terrain-picking-pass.js +12 -1
  112. package/dist/terrain/terrain-picking-pass.js.map +1 -0
  113. package/dist/terrain/utils.d.ts.map +1 -1
  114. package/dist/terrain/utils.js +4 -0
  115. package/dist/terrain/utils.js.map +1 -0
  116. package/dist/utils/debug.d.ts +2 -2
  117. package/dist/utils/debug.d.ts.map +1 -1
  118. package/dist/utils/debug.js +4 -1
  119. package/dist/utils/debug.js.map +1 -0
  120. package/dist/utils/projection-utils.d.ts.map +1 -1
  121. package/dist/utils/projection-utils.js +4 -0
  122. package/dist/utils/projection-utils.js.map +1 -0
  123. package/dist.min.js +1102 -817
  124. package/package.json +8 -8
  125. package/src/brushing/brushing-extension.ts +17 -20
  126. package/src/brushing/shader-module.ts +58 -47
  127. package/src/clip/clip-extension.ts +38 -40
  128. package/src/collision-filter/collision-filter-effect.ts +31 -20
  129. package/src/collision-filter/collision-filter-extension.ts +6 -7
  130. package/src/collision-filter/collision-filter-pass.ts +17 -6
  131. package/src/collision-filter/shader-module.ts +40 -22
  132. package/src/data-filter/aggregator.ts +23 -11
  133. package/src/data-filter/data-filter-extension.ts +76 -49
  134. package/src/data-filter/shader-module.ts +150 -90
  135. package/src/fill-style/fill-style-extension.ts +13 -5
  136. package/src/fill-style/shader-module.ts +84 -52
  137. package/src/fp64/fp64-extension.ts +8 -19
  138. package/src/fp64/project64.glsl.ts +18 -21
  139. package/src/fp64/project64.ts +27 -28
  140. package/src/index.ts +5 -0
  141. package/src/mask/mask-effect.ts +17 -7
  142. package/src/mask/mask-extension.ts +16 -9
  143. package/src/mask/mask-pass.ts +17 -3
  144. package/src/mask/shader-module.ts +63 -27
  145. package/src/path-style/path-style-extension.ts +27 -28
  146. package/src/path-style/shaders.glsl.ts +13 -7
  147. package/src/terrain/height-map-builder.ts +4 -0
  148. package/src/terrain/shader-module.ts +62 -44
  149. package/src/terrain/terrain-cover.ts +4 -0
  150. package/src/terrain/terrain-effect.ts +36 -19
  151. package/src/terrain/terrain-extension.ts +4 -0
  152. package/src/terrain/terrain-pass.ts +19 -3
  153. package/src/terrain/terrain-picking-pass.ts +15 -2
  154. package/src/terrain/utils.ts +4 -0
  155. package/src/utils/debug.ts +4 -0
  156. package/src/utils/projection-utils.ts +4 -0
  157. package/dist/utils/syntax-tags.d.ts +0 -6
  158. package/dist/utils/syntax-tags.d.ts.map +0 -1
  159. package/dist/utils/syntax-tags.js +0 -5
  160. package/src/utils/syntax-tags.ts +0 -5
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Plug-and-play functionalities for deck.gl layers",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
- "version": "9.0.40",
6
+ "version": "9.1.0-beta.3",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -38,14 +38,14 @@
38
38
  "prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env=dev"
39
39
  },
40
40
  "dependencies": {
41
- "@luma.gl/constants": "~9.0.27",
42
- "@luma.gl/shadertools": "~9.0.27",
43
- "@math.gl/core": "^4.0.0"
41
+ "@luma.gl/constants": "^9.1.0-beta.16",
42
+ "@luma.gl/shadertools": "^9.1.0-beta.16",
43
+ "@math.gl/core": "^4.1.0"
44
44
  },
45
45
  "peerDependencies": {
46
- "@deck.gl/core": "^9.0.0",
47
- "@luma.gl/core": "~9.0.0",
48
- "@luma.gl/engine": "~9.0.0"
46
+ "@deck.gl/core": "^9.1.0-beta",
47
+ "@luma.gl/core": "^9.1.0-beta",
48
+ "@luma.gl/engine": "^9.1.0-beta"
49
49
  },
50
- "gitHead": "fe6e4763b3dcd5b602291e7732e9d30b0a4eaec1"
50
+ "gitHead": "6625885881202cb753b64c6f2b8ee6f323092075"
51
51
  }
@@ -1,25 +1,9 @@
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.
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
20
4
 
21
5
  import {LayerExtension} from '@deck.gl/core';
22
- import shaderModule from './shader-module';
6
+ import shaderModule, {BrushingModuleProps} from './shader-module';
23
7
 
24
8
  import type {Layer, LayerContext, Accessor} from '@deck.gl/core';
25
9
 
@@ -101,4 +85,17 @@ export default class BrushingExtension extends LayerExtension {
101
85
  });
102
86
  }
103
87
  }
88
+
89
+ draw(this: Layer<BrushingExtensionProps>, params: any, extension: this) {
90
+ const {viewport, mousePosition} = params.context;
91
+ const {brushingEnabled, brushingRadius, brushingTarget} = this.props;
92
+ const brushingProps: BrushingModuleProps = {
93
+ viewport,
94
+ mousePosition,
95
+ brushingEnabled,
96
+ brushingRadius,
97
+ brushingTarget
98
+ };
99
+ this.setShaderModuleProps({brushing: brushingProps});
100
+ }
104
101
  }
@@ -1,55 +1,50 @@
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.
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
20
5
  /* eslint-disable camelcase */
21
6
  import type {ShaderModule} from '@luma.gl/shadertools';
22
7
  import {project} from '@deck.gl/core';
23
8
  import type {Viewport} from '@deck.gl/core';
24
9
 
25
10
  import type {BrushingExtensionProps} from './brushing-extension';
26
- import {glsl} from '../utils/syntax-tags';
27
11
 
28
- type BrushingModuleSettings = {
12
+ export type BrushingModuleProps = {
29
13
  // From layer context
30
14
  viewport: Viewport;
31
15
  mousePosition?: {x: number; y: number};
32
16
  } & BrushingExtensionProps;
33
17
 
34
- const vs = glsl`
35
- uniform bool brushing_enabled;
36
- uniform int brushing_target;
37
- uniform vec2 brushing_mousePos;
38
- uniform float brushing_radius;
18
+ type BrushingModuleUniforms = {
19
+ enabled?: boolean;
20
+ target?: number;
21
+ mousePos?: [number, number];
22
+ radius?: number;
23
+ };
24
+
25
+ const uniformBlock = /* glsl */ `\
26
+ uniform brushingUniforms {
27
+ bool enabled;
28
+ highp int target;
29
+ vec2 mousePos;
30
+ float radius;
31
+ } brushing;
32
+ `;
39
33
 
34
+ const vertex = /* glsl */ `
40
35
  in vec2 brushingTargets;
41
36
 
42
37
  out float brushing_isVisible;
43
38
 
44
39
  bool brushing_isPointInRange(vec2 position) {
45
- if (!brushing_enabled) {
40
+ if (!brushing.enabled) {
46
41
  return true;
47
42
  }
48
43
  vec2 source_commonspace = project_position(position);
49
- vec2 target_commonspace = project_position(brushing_mousePos);
50
- float distance = length((target_commonspace - source_commonspace) / project_uCommonUnitsPerMeter.xy);
44
+ vec2 target_commonspace = project_position(brushing.mousePos);
45
+ float distance = length((target_commonspace - source_commonspace) / project.commonUnitsPerMeter.xy);
51
46
 
52
- return distance <= brushing_radius;
47
+ return distance <= brushing.radius;
53
48
  }
54
49
 
55
50
  bool brushing_arePointsInRange(vec2 sourcePos, vec2 targetPos) {
@@ -61,11 +56,20 @@ const vs = glsl`
61
56
  }
62
57
  `;
63
58
 
64
- const fs = glsl`
65
- uniform bool brushing_enabled;
59
+ const vs = `
60
+ ${uniformBlock}
61
+ ${vertex}
62
+ `;
63
+
64
+ const fragment = /* glsl */ `
66
65
  in float brushing_isVisible;
67
66
  `;
68
67
 
68
+ const fs = `
69
+ ${uniformBlock}
70
+ ${fragment}
71
+ `;
72
+
69
73
  const TARGET = {
70
74
  source: 0,
71
75
  target: 1,
@@ -74,21 +78,21 @@ const TARGET = {
74
78
  };
75
79
 
76
80
  const inject = {
77
- 'vs:DECKGL_FILTER_GL_POSITION': glsl`
81
+ 'vs:DECKGL_FILTER_GL_POSITION': /* glsl */ `
78
82
  vec2 brushingTarget;
79
83
  vec2 brushingSource;
80
- if (brushing_target == 3) {
84
+ if (brushing.target == 3) {
81
85
  brushingTarget = geometry.worldPositionAlt.xy;
82
86
  brushingSource = geometry.worldPosition.xy;
83
- } else if (brushing_target == 0) {
87
+ } else if (brushing.target == 0) {
84
88
  brushingTarget = geometry.worldPosition.xy;
85
- } else if (brushing_target == 1) {
89
+ } else if (brushing.target == 1) {
86
90
  brushingTarget = geometry.worldPositionAlt.xy;
87
91
  } else {
88
92
  brushingTarget = brushingTargets;
89
93
  }
90
94
  bool visible;
91
- if (brushing_target == 3) {
95
+ if (brushing.target == 3) {
92
96
  visible = brushing_arePointsInRange(brushingSource, brushingTarget);
93
97
  } else {
94
98
  visible = brushing_isPointInRange(brushingTarget);
@@ -97,7 +101,7 @@ const inject = {
97
101
  `,
98
102
 
99
103
  'fs:DECKGL_FILTER_COLOR': `
100
- if (brushing_enabled && brushing_isVisible < 0.5) {
104
+ if (brushing.enabled && brushing_isVisible < 0.5) {
101
105
  discard;
102
106
  }
103
107
  `
@@ -109,7 +113,7 @@ export default {
109
113
  vs,
110
114
  fs,
111
115
  inject,
112
- getUniforms: (opts?: BrushingModuleSettings | {}): Record<string, any> => {
116
+ getUniforms: (opts?: BrushingModuleProps | {}): BrushingModuleUniforms => {
113
117
  if (!opts || !('viewport' in opts)) {
114
118
  return {};
115
119
  }
@@ -121,14 +125,21 @@ export default {
121
125
  viewport
122
126
  } = opts;
123
127
  return {
124
- brushing_enabled: Boolean(
125
- brushingEnabled && mousePosition && viewport.containsPixel(mousePosition)
126
- ),
127
- brushing_radius: brushingRadius,
128
- brushing_target: TARGET[brushingTarget] || 0,
129
- brushing_mousePos: mousePosition
130
- ? viewport.unproject([mousePosition.x - viewport.x, mousePosition.y - viewport.y])
128
+ enabled: Boolean(brushingEnabled && mousePosition && viewport.containsPixel(mousePosition)),
129
+ radius: brushingRadius,
130
+ target: TARGET[brushingTarget] || 0,
131
+ mousePos: mousePosition
132
+ ? (viewport.unproject([mousePosition.x - viewport.x, mousePosition.y - viewport.y]) as [
133
+ number,
134
+ number
135
+ ])
131
136
  : [0, 0]
132
137
  };
138
+ },
139
+ uniformTypes: {
140
+ enabled: 'i32',
141
+ target: 'i32',
142
+ mousePos: 'vec2<f32>',
143
+ radius: 'f32'
133
144
  }
134
- } as ShaderModule<BrushingModuleSettings>;
145
+ } as ShaderModule<BrushingModuleProps, BrushingModuleUniforms, {}>;
@@ -1,28 +1,11 @@
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.
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
20
4
 
21
5
  import type {ShaderModule} from '@luma.gl/shadertools';
22
6
  import {LayerExtension} from '@deck.gl/core';
23
7
 
24
8
  import type {Layer} from '@deck.gl/core';
25
- import {glsl} from '../utils/syntax-tags';
26
9
 
27
10
  const defaultProps = {
28
11
  clipBounds: [0, 0, 1, 1],
@@ -41,34 +24,43 @@ export type ClipExtensionProps = {
41
24
  clipByInstance?: boolean;
42
25
  };
43
26
 
44
- const shaderFunction = glsl`
45
- uniform vec4 clip_bounds;
27
+ const shaderFunction = /* glsl */ `
28
+ uniform clipUniforms {
29
+ vec4 bounds;
30
+ } clip;
46
31
 
47
32
  bool clip_isInBounds(vec2 position) {
48
- return position.x >= clip_bounds[0] && position.y >= clip_bounds[1] && position.x < clip_bounds[2] && position.y < clip_bounds[3];
33
+ return position.x >= clip.bounds[0] && position.y >= clip.bounds[1] && position.x < clip.bounds[2] && position.y < clip.bounds[3];
49
34
  }
50
35
  `;
51
36
 
37
+ export type ClipModuleProps = {
38
+ bounds: [number, number, number, number];
39
+ };
40
+
52
41
  /*
53
42
  * The vertex-shader version clips geometries by their anchor position
54
43
  * e.g. ScatterplotLayer - show if the center of a circle is within bounds
55
44
  */
56
- const shaderModuleVs: ShaderModule = {
57
- name: 'clip-vs',
58
- vs: shaderFunction
45
+ const shaderModuleVs: ShaderModule<ClipModuleProps> = {
46
+ name: 'clip',
47
+ vs: shaderFunction,
48
+ uniformTypes: {
49
+ bounds: 'vec4<f32>'
50
+ }
59
51
  };
60
52
 
61
53
  const injectionVs = {
62
- 'vs:#decl': glsl`
54
+ 'vs:#decl': /* glsl */ `
63
55
  out float clip_isVisible;
64
56
  `,
65
- 'vs:DECKGL_FILTER_GL_POSITION': glsl`
57
+ 'vs:DECKGL_FILTER_GL_POSITION': /* glsl */ `
66
58
  clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy));
67
59
  `,
68
- 'fs:#decl': glsl`
60
+ 'fs:#decl': /* glsl */ `
69
61
  in float clip_isVisible;
70
62
  `,
71
- 'fs:DECKGL_FILTER_COLOR': glsl`
63
+ 'fs:DECKGL_FILTER_COLOR': /* glsl */ `
72
64
  if (clip_isVisible < 0.5) discard;
73
65
  `
74
66
  };
@@ -77,22 +69,25 @@ in float clip_isVisible;
77
69
  * The fragment-shader version clips pixels at the bounds
78
70
  * e.g. PolygonLayer - show the part of the polygon that intersect with the bounds
79
71
  */
80
- const shaderModuleFs: ShaderModule = {
81
- name: 'clip-fs',
82
- fs: shaderFunction
72
+ const shaderModuleFs: ShaderModule<ClipModuleProps> = {
73
+ name: 'clip',
74
+ fs: shaderFunction,
75
+ uniformTypes: {
76
+ bounds: 'vec4<f32>'
77
+ }
83
78
  };
84
79
 
85
80
  const injectionFs = {
86
- 'vs:#decl': glsl`
81
+ 'vs:#decl': /* glsl */ `
87
82
  out vec2 clip_commonPosition;
88
83
  `,
89
- 'vs:DECKGL_FILTER_GL_POSITION': glsl`
84
+ 'vs:DECKGL_FILTER_GL_POSITION': /* glsl */ `
90
85
  clip_commonPosition = geometry.position.xy;
91
86
  `,
92
- 'fs:#decl': glsl`
87
+ 'fs:#decl': /* glsl */ `
93
88
  in vec2 clip_commonPosition;
94
89
  `,
95
- 'fs:DECKGL_FILTER_COLOR': glsl`
90
+ 'fs:DECKGL_FILTER_COLOR': /* glsl */ `
96
91
  if (!clip_isInBounds(clip_commonPosition)) discard;
97
92
  `
98
93
  };
@@ -126,20 +121,23 @@ export default class ClipExtension extends LayerExtension {
126
121
  }
127
122
 
128
123
  /* eslint-disable camelcase */
129
- draw(this: Layer<Required<ClipExtensionProps>>, {uniforms}: any): void {
124
+ draw(this: Layer<Required<ClipExtensionProps>>): void {
130
125
  const {clipBounds} = this.props;
126
+ const clipProps = {} as ClipModuleProps;
131
127
  if (this.state.clipByInstance) {
132
- uniforms.clip_bounds = clipBounds;
128
+ clipProps.bounds = clipBounds;
133
129
  } else {
134
130
  const corner0 = this.projectPosition([clipBounds[0], clipBounds[1], 0]);
135
131
  const corner1 = this.projectPosition([clipBounds[2], clipBounds[3], 0]);
136
132
 
137
- uniforms.clip_bounds = [
133
+ clipProps.bounds = [
138
134
  Math.min(corner0[0], corner1[0]),
139
135
  Math.min(corner0[1], corner1[1]),
140
136
  Math.max(corner0[0], corner1[0]),
141
137
  Math.max(corner0[1], corner1[1])
142
138
  ];
143
139
  }
140
+
141
+ this.setShaderModuleProps({clip: clipProps});
144
142
  }
145
143
  }
@@ -1,3 +1,7 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  import {Device, Framebuffer, Texture} from '@luma.gl/core';
2
6
  import {equals} from '@math.gl/core';
3
7
  import {_deepEqual as deepEqual} from '@deck.gl/core';
@@ -6,10 +10,8 @@ import CollisionFilterPass from './collision-filter-pass';
6
10
  import {MaskPreRenderStats} from '../mask/mask-effect';
7
11
  // import {debugFBO} from '../utils/debug';
8
12
 
9
- type CollisionFilterExtensionProps = {
10
- collisionTestProps?: {};
11
- collisionGroup: string;
12
- };
13
+ import type {CollisionFilterExtensionProps} from './collision-filter-extension';
14
+ import type {CollisionModuleProps} from './shader-module';
13
15
 
14
16
  // Factor by which to downscale Collision FBO relative to canvas
15
17
  const DOWNSCALE = 2;
@@ -155,11 +157,16 @@ export default class CollisionFilterEffect implements Effect {
155
157
  viewports: viewport ? [viewport] : [],
156
158
  onViewportActive,
157
159
  views,
158
- moduleParameters: {
159
- // To avoid feedback loop forming between Framebuffer and active Texture.
160
- dummyCollisionMap: this.dummyCollisionMap,
161
- // @ts-expect-error TODO - assuming WebGL context
162
- devicePixelRatio: collisionFBO.device.canvasContext.getDevicePixelRatio() / DOWNSCALE
160
+ shaderModuleProps: {
161
+ collision: {
162
+ enabled: true,
163
+ // To avoid feedback loop forming between Framebuffer and active Texture.
164
+ dummyCollisionMap: this.dummyCollisionMap
165
+ },
166
+ project: {
167
+ // @ts-expect-error TODO - assuming WebGL context
168
+ devicePixelRatio: collisionFBO.device.canvasContext.getDevicePixelRatio() / DOWNSCALE
169
+ }
163
170
  }
164
171
  });
165
172
  }
@@ -175,7 +182,7 @@ export default class CollisionFilterEffect implements Effect {
175
182
  ): Record<string, RenderInfo> {
176
183
  const channelMap = {};
177
184
  for (const layer of collisionLayers) {
178
- const {collisionGroup} = layer.props;
185
+ const collisionGroup = layer.props.collisionGroup!;
179
186
  let channelInfo = channelMap[collisionGroup];
180
187
  if (!channelInfo) {
181
188
  channelInfo = {collisionGroup, layers: [], layerBounds: [], allLayersLoaded: true};
@@ -206,13 +213,21 @@ export default class CollisionFilterEffect implements Effect {
206
213
  return channelMap;
207
214
  }
208
215
 
209
- getModuleParameters(layer: Layer): {
210
- collisionFBO: Framebuffer;
211
- dummyCollisionMap: Texture;
216
+ getShaderModuleProps(layer: Layer): {
217
+ collision: CollisionModuleProps;
212
218
  } {
213
- const {collisionGroup} = (layer as Layer<CollisionFilterExtensionProps>).props;
219
+ const {collisionGroup, collisionEnabled} = (layer as Layer<CollisionFilterExtensionProps>)
220
+ .props;
214
221
  const {collisionFBOs, dummyCollisionMap} = this;
215
- return {collisionFBO: collisionFBOs[collisionGroup], dummyCollisionMap: dummyCollisionMap!};
222
+ const collisionFBO = collisionFBOs[collisionGroup!];
223
+ const enabled = collisionEnabled && Boolean(collisionFBO);
224
+ return {
225
+ collision: {
226
+ enabled,
227
+ collisionFBO,
228
+ dummyCollisionMap: dummyCollisionMap!
229
+ }
230
+ };
216
231
  }
217
232
 
218
233
  cleanup(): void {
@@ -248,11 +263,7 @@ export default class CollisionFilterEffect implements Effect {
248
263
  format: 'depth16unorm',
249
264
  width,
250
265
  height,
251
- mipmaps: false,
252
-
253
- // TODO fix getWebGLTextureParameters() in luma to avoid passing deprecated parameters
254
- dataFormat: 6402, // gl.DEPTH_COMPONENT
255
- type: 5125 // gl.UNSIGNED_INT
266
+ mipmaps: false
256
267
  });
257
268
  this.collisionFBOs[collisionGroup] = device.createFramebuffer({
258
269
  id: `collision-${collisionGroup}`,
@@ -1,3 +1,7 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  import {Accessor, Layer, LayerContext, LayerExtension} from '@deck.gl/core';
2
6
  import collision from './shader-module';
3
7
  import CollisionFilterEffect from './collision-filter-effect';
@@ -42,13 +46,8 @@ export default class CollisionFilterExtension extends LayerExtension {
42
46
  }
43
47
 
44
48
  /* eslint-disable camelcase */
45
- draw(this: Layer<CollisionFilterExtensionProps>, {uniforms, context, moduleParameters}: any) {
46
- const {collisionEnabled} = this.props;
47
- const {collisionFBO, drawToCollisionMap} = moduleParameters;
48
- const enabled = collisionEnabled && Boolean(collisionFBO);
49
- uniforms.collision_enabled = enabled;
50
-
51
- if (drawToCollisionMap) {
49
+ draw(this: Layer<CollisionFilterExtensionProps>, {shaderModuleProps}: any) {
50
+ if (shaderModuleProps.collision?.drawToCollisionMap) {
52
51
  // Override any props with those defined in collisionTestProps
53
52
  // @ts-ignore
54
53
  this.props = this.clone(this.props.collisionTestProps).props;
@@ -1,4 +1,8 @@
1
- import {Framebuffer} from '@luma.gl/core';
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {Framebuffer, Parameters} from '@luma.gl/core';
2
6
  import {Layer, _LayersPass as LayersPass, LayersPassRenderOptions, Viewport} from '@deck.gl/core';
3
7
 
4
8
  type CollisionFilterPassRenderOptions = LayersPassRenderOptions & {};
@@ -12,19 +16,26 @@ export default class CollisionFilterPass extends LayersPass {
12
16
  this.render({...options, clearColor, scissorRect, target, pass: 'collision'});
13
17
  }
14
18
 
15
- protected getLayerParameters(layer: Layer, layerIndex: number, viewport: Viewport): any {
16
- return {...layer.props.parameters, blend: false, depthRange: [0, 1], depthTest: true};
19
+ protected getLayerParameters(layer: Layer, layerIndex: number, viewport: Viewport): Parameters {
20
+ return {
21
+ ...layer.props.parameters,
22
+ blend: false,
23
+ depthWriteEnabled: true,
24
+ depthCompare: 'less-equal'
25
+ };
17
26
  }
18
27
 
19
- getModuleParameters() {
28
+ getShaderModuleProps() {
20
29
  // Draw picking colors into collision FBO
21
30
  return {
22
- drawToCollisionMap: true,
31
+ collision: {
32
+ drawToCollisionMap: true
33
+ },
23
34
  picking: {
24
35
  isActive: 1,
25
36
  isAttribute: false
26
37
  },
27
- lightSources: {}
38
+ lighting: {enabled: false}
28
39
  };
29
40
  }
30
41
  }