@deck.gl/extensions 9.0.0-beta.1 → 9.0.0-beta.10

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 (265) hide show
  1. package/dist/brushing/brushing-extension.js +80 -0
  2. package/{typed → dist}/brushing/shader-module.d.ts +1 -1
  3. package/{typed → dist}/brushing/shader-module.d.ts.map +1 -1
  4. package/dist/brushing/shader-module.js +92 -0
  5. package/{typed → dist}/clip/clip-extension.d.ts.map +1 -1
  6. package/dist/clip/clip-extension.js +117 -0
  7. package/{typed → dist}/collision-filter/collision-filter-effect.d.ts.map +1 -1
  8. package/dist/collision-filter/collision-filter-effect.js +193 -0
  9. package/dist/collision-filter/collision-filter-extension.js +49 -0
  10. package/{typed → dist}/collision-filter/collision-filter-pass.d.ts.map +1 -1
  11. package/dist/collision-filter/collision-filter-pass.js +25 -0
  12. package/{typed → dist}/collision-filter/shader-module.d.ts.map +1 -1
  13. package/dist/collision-filter/shader-module.js +87 -0
  14. package/dist/data-filter/aggregator.d.ts.map +1 -0
  15. package/dist/{esm/data-filter → data-filter}/aggregator.js +40 -41
  16. package/{typed → dist}/data-filter/data-filter-extension.d.ts +38 -6
  17. package/dist/data-filter/data-filter-extension.d.ts.map +1 -0
  18. package/dist/data-filter/data-filter-extension.js +249 -0
  19. package/{typed → dist}/data-filter/shader-module.d.ts +1 -1
  20. package/dist/data-filter/shader-module.d.ts.map +1 -0
  21. package/dist/data-filter/shader-module.js +179 -0
  22. package/dist/dist.dev.js +2203 -10630
  23. package/{typed → dist}/fill-style/fill-style-extension.d.ts +2 -30
  24. package/dist/fill-style/fill-style-extension.d.ts.map +1 -0
  25. package/dist/fill-style/fill-style-extension.js +116 -0
  26. package/{typed/fill-style/shaders.glsl.d.ts → dist/fill-style/shader-module.d.ts} +1 -1
  27. package/dist/fill-style/shader-module.d.ts.map +1 -0
  28. package/dist/fill-style/shader-module.js +96 -0
  29. package/dist/fp64/fp64-extension.js +35 -0
  30. package/dist/fp64/project64.glsl.js +81 -0
  31. package/dist/fp64/project64.js +50 -0
  32. package/dist/index.cjs +2756 -0
  33. package/dist/index.cjs.map +7 -0
  34. package/dist/index.d.ts +19 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +11 -0
  37. package/{typed → dist}/mask/mask-effect.d.ts +1 -1
  38. package/dist/mask/mask-effect.d.ts.map +1 -0
  39. package/dist/mask/mask-effect.js +194 -0
  40. package/dist/mask/mask-extension.js +57 -0
  41. package/{typed → dist}/mask/mask-pass.d.ts.map +1 -1
  42. package/dist/mask/mask-pass.js +44 -0
  43. package/{typed → dist}/mask/shader-module.d.ts.map +1 -1
  44. package/dist/mask/shader-module.js +77 -0
  45. package/dist/path-style/path-style-extension.js +111 -0
  46. package/dist/path-style/shaders.glsl.js +86 -0
  47. package/{typed → dist}/terrain/height-map-builder.d.ts +1 -1
  48. package/dist/terrain/height-map-builder.d.ts.map +1 -0
  49. package/dist/terrain/height-map-builder.js +104 -0
  50. package/{typed → dist}/terrain/shader-module.d.ts +2 -2
  51. package/dist/terrain/shader-module.d.ts.map +1 -0
  52. package/dist/terrain/shader-module.js +137 -0
  53. package/{typed → dist}/terrain/terrain-cover.d.ts +1 -1
  54. package/dist/terrain/terrain-cover.d.ts.map +1 -0
  55. package/dist/terrain/terrain-cover.js +187 -0
  56. package/{typed → dist}/terrain/terrain-effect.d.ts +2 -2
  57. package/dist/terrain/terrain-effect.d.ts.map +1 -0
  58. package/dist/terrain/terrain-effect.js +184 -0
  59. package/dist/terrain/terrain-extension.js +44 -0
  60. package/{typed → dist}/terrain/terrain-pass.d.ts +2 -2
  61. package/dist/terrain/terrain-pass.d.ts.map +1 -0
  62. package/dist/terrain/terrain-pass.js +61 -0
  63. package/{typed → dist}/terrain/terrain-picking-pass.d.ts +1 -1
  64. package/dist/terrain/terrain-picking-pass.d.ts.map +1 -0
  65. package/dist/terrain/terrain-picking-pass.js +66 -0
  66. package/dist/terrain/utils.js +21 -0
  67. package/{typed → dist}/utils/debug.d.ts.map +1 -1
  68. package/dist/utils/debug.js +50 -0
  69. package/dist/utils/projection-utils.js +153 -0
  70. package/dist/utils/syntax-tags.d.ts +6 -0
  71. package/dist/utils/syntax-tags.d.ts.map +1 -0
  72. package/dist/utils/syntax-tags.js +5 -0
  73. package/dist.min.js +898 -1257
  74. package/package.json +19 -16
  75. package/src/brushing/shader-module.ts +4 -3
  76. package/src/clip/clip-extension.ts +10 -9
  77. package/src/collision-filter/collision-filter-effect.ts +12 -8
  78. package/src/collision-filter/collision-filter-pass.ts +1 -3
  79. package/src/collision-filter/shader-module.ts +6 -4
  80. package/src/data-filter/aggregator.ts +8 -13
  81. package/src/data-filter/data-filter-extension.ts +147 -30
  82. package/src/data-filter/shader-module.ts +38 -9
  83. package/src/fill-style/fill-style-extension.ts +4 -5
  84. package/src/fill-style/{shaders.glsl.ts → shader-module.ts} +6 -5
  85. package/src/mask/mask-effect.ts +0 -1
  86. package/src/mask/mask-pass.ts +1 -3
  87. package/src/mask/shader-module.ts +7 -6
  88. package/src/terrain/shader-module.ts +14 -13
  89. package/src/terrain/terrain-effect.ts +12 -5
  90. package/src/terrain/terrain-pass.ts +2 -5
  91. package/src/terrain/terrain-picking-pass.ts +1 -3
  92. package/src/terrain/utils.ts +1 -1
  93. package/src/utils/debug.ts +1 -2
  94. package/src/utils/syntax-tags.ts +5 -0
  95. package/dist/es5/brushing/brushing-extension.js +0 -108
  96. package/dist/es5/brushing/brushing-extension.js.map +0 -1
  97. package/dist/es5/brushing/shader-module.js +0 -50
  98. package/dist/es5/brushing/shader-module.js.map +0 -1
  99. package/dist/es5/clip/clip-extension.js +0 -98
  100. package/dist/es5/clip/clip-extension.js.map +0 -1
  101. package/dist/es5/collision-filter/collision-filter-effect.js +0 -294
  102. package/dist/es5/collision-filter/collision-filter-effect.js.map +0 -1
  103. package/dist/es5/collision-filter/collision-filter-extension.js +0 -109
  104. package/dist/es5/collision-filter/collision-filter-extension.js.map +0 -1
  105. package/dist/es5/collision-filter/collision-filter-pass.js +0 -79
  106. package/dist/es5/collision-filter/collision-filter-pass.js.map +0 -1
  107. package/dist/es5/collision-filter/shader-module.js +0 -39
  108. package/dist/es5/collision-filter/shader-module.js.map +0 -1
  109. package/dist/es5/data-filter/aggregator.js +0 -79
  110. package/dist/es5/data-filter/aggregator.js.map +0 -1
  111. package/dist/es5/data-filter/data-filter-extension.js +0 -236
  112. package/dist/es5/data-filter/data-filter-extension.js.map +0 -1
  113. package/dist/es5/data-filter/shader-module.js +0 -122
  114. package/dist/es5/data-filter/shader-module.js.map +0 -1
  115. package/dist/es5/fill-style/fill-style-extension.js +0 -190
  116. package/dist/es5/fill-style/fill-style-extension.js.map +0 -1
  117. package/dist/es5/fill-style/shaders.glsl.js +0 -59
  118. package/dist/es5/fill-style/shaders.glsl.js.map +0 -1
  119. package/dist/es5/fp64/fp64-extension.js +0 -55
  120. package/dist/es5/fp64/fp64-extension.js.map +0 -1
  121. package/dist/es5/fp64/project64.glsl.js +0 -9
  122. package/dist/es5/fp64/project64.glsl.js.map +0 -1
  123. package/dist/es5/fp64/project64.js +0 -52
  124. package/dist/es5/fp64/project64.js.map +0 -1
  125. package/dist/es5/index.js +0 -88
  126. package/dist/es5/index.js.map +0 -1
  127. package/dist/es5/mask/mask-effect.js +0 -279
  128. package/dist/es5/mask/mask-effect.js.map +0 -1
  129. package/dist/es5/mask/mask-extension.js +0 -113
  130. package/dist/es5/mask/mask-extension.js.map +0 -1
  131. package/dist/es5/mask/mask-pass.js +0 -106
  132. package/dist/es5/mask/mask-pass.js.map +0 -1
  133. package/dist/es5/mask/shader-module.js +0 -38
  134. package/dist/es5/mask/shader-module.js.map +0 -1
  135. package/dist/es5/path-style/path-style-extension.js +0 -169
  136. package/dist/es5/path-style/path-style-extension.js.map +0 -1
  137. package/dist/es5/path-style/shaders.glsl.js +0 -25
  138. package/dist/es5/path-style/shaders.glsl.js.map +0 -1
  139. package/dist/es5/terrain/height-map-builder.js +0 -111
  140. package/dist/es5/terrain/height-map-builder.js.map +0 -1
  141. package/dist/es5/terrain/shader-module.js +0 -86
  142. package/dist/es5/terrain/shader-module.js.map +0 -1
  143. package/dist/es5/terrain/terrain-cover.js +0 -256
  144. package/dist/es5/terrain/terrain-cover.js.map +0 -1
  145. package/dist/es5/terrain/terrain-effect.js +0 -326
  146. package/dist/es5/terrain/terrain-effect.js.map +0 -1
  147. package/dist/es5/terrain/terrain-extension.js +0 -94
  148. package/dist/es5/terrain/terrain-extension.js.map +0 -1
  149. package/dist/es5/terrain/terrain-pass.js +0 -121
  150. package/dist/es5/terrain/terrain-pass.js.map +0 -1
  151. package/dist/es5/terrain/terrain-picking-pass.js +0 -124
  152. package/dist/es5/terrain/terrain-picking-pass.js.map +0 -1
  153. package/dist/es5/terrain/utils.js +0 -35
  154. package/dist/es5/terrain/utils.js.map +0 -1
  155. package/dist/es5/utils/debug.js +0 -71
  156. package/dist/es5/utils/debug.js.map +0 -1
  157. package/dist/es5/utils/projection-utils.js +0 -168
  158. package/dist/es5/utils/projection-utils.js.map +0 -1
  159. package/dist/esm/brushing/brushing-extension.js +0 -68
  160. package/dist/esm/brushing/brushing-extension.js.map +0 -1
  161. package/dist/esm/brushing/shader-module.js +0 -103
  162. package/dist/esm/brushing/shader-module.js.map +0 -1
  163. package/dist/esm/clip/clip-extension.js +0 -86
  164. package/dist/esm/clip/clip-extension.js.map +0 -1
  165. package/dist/esm/collision-filter/collision-filter-effect.js +0 -246
  166. package/dist/esm/collision-filter/collision-filter-effect.js.map +0 -1
  167. package/dist/esm/collision-filter/collision-filter-extension.js +0 -75
  168. package/dist/esm/collision-filter/collision-filter-extension.js.map +0 -1
  169. package/dist/esm/collision-filter/collision-filter-pass.js +0 -32
  170. package/dist/esm/collision-filter/collision-filter-pass.js.map +0 -1
  171. package/dist/esm/collision-filter/shader-module.js +0 -104
  172. package/dist/esm/collision-filter/shader-module.js.map +0 -1
  173. package/dist/esm/data-filter/aggregator.js.map +0 -1
  174. package/dist/esm/data-filter/data-filter-extension.js +0 -189
  175. package/dist/esm/data-filter/data-filter-extension.js.map +0 -1
  176. package/dist/esm/data-filter/shader-module.js +0 -164
  177. package/dist/esm/data-filter/shader-module.js.map +0 -1
  178. package/dist/esm/fill-style/fill-style-extension.js +0 -156
  179. package/dist/esm/fill-style/fill-style-extension.js.map +0 -1
  180. package/dist/esm/fill-style/shaders.glsl.js +0 -108
  181. package/dist/esm/fill-style/shaders.glsl.js.map +0 -1
  182. package/dist/esm/fp64/fp64-extension.js +0 -20
  183. package/dist/esm/fp64/fp64-extension.js.map +0 -1
  184. package/dist/esm/fp64/project64.glsl.js +0 -82
  185. package/dist/esm/fp64/project64.glsl.js.map +0 -1
  186. package/dist/esm/fp64/project64.js +0 -43
  187. package/dist/esm/fp64/project64.js.map +0 -1
  188. package/dist/esm/index.js +0 -11
  189. package/dist/esm/index.js.map +0 -1
  190. package/dist/esm/mask/mask-effect.js +0 -228
  191. package/dist/esm/mask/mask-effect.js.map +0 -1
  192. package/dist/esm/mask/mask-extension.js +0 -83
  193. package/dist/esm/mask/mask-extension.js.map +0 -1
  194. package/dist/esm/mask/mask-pass.js +0 -58
  195. package/dist/esm/mask/mask-pass.js.map +0 -1
  196. package/dist/esm/mask/shader-module.js +0 -84
  197. package/dist/esm/mask/shader-module.js.map +0 -1
  198. package/dist/esm/path-style/path-style-extension.js +0 -130
  199. package/dist/esm/path-style/path-style-extension.js.map +0 -1
  200. package/dist/esm/path-style/shaders.glsl.js +0 -84
  201. package/dist/esm/path-style/shaders.glsl.js.map +0 -1
  202. package/dist/esm/terrain/height-map-builder.js +0 -86
  203. package/dist/esm/terrain/height-map-builder.js.map +0 -1
  204. package/dist/esm/terrain/shader-module.js +0 -127
  205. package/dist/esm/terrain/shader-module.js.map +0 -1
  206. package/dist/esm/terrain/terrain-cover.js +0 -212
  207. package/dist/esm/terrain/terrain-cover.js.map +0 -1
  208. package/dist/esm/terrain/terrain-effect.js +0 -219
  209. package/dist/esm/terrain/terrain-effect.js.map +0 -1
  210. package/dist/esm/terrain/terrain-extension.js +0 -59
  211. package/dist/esm/terrain/terrain-extension.js.map +0 -1
  212. package/dist/esm/terrain/terrain-pass.js +0 -71
  213. package/dist/esm/terrain/terrain-pass.js.map +0 -1
  214. package/dist/esm/terrain/terrain-picking-pass.js +0 -73
  215. package/dist/esm/terrain/terrain-picking-pass.js.map +0 -1
  216. package/dist/esm/terrain/utils.js +0 -19
  217. package/dist/esm/terrain/utils.js.map +0 -1
  218. package/dist/esm/utils/debug.js +0 -61
  219. package/dist/esm/utils/debug.js.map +0 -1
  220. package/dist/esm/utils/projection-utils.js +0 -134
  221. package/dist/esm/utils/projection-utils.js.map +0 -1
  222. package/typed/data-filter/aggregator.d.ts.map +0 -1
  223. package/typed/data-filter/data-filter-extension.d.ts.map +0 -1
  224. package/typed/data-filter/shader-module.d.ts.map +0 -1
  225. package/typed/fill-style/fill-style-extension.d.ts.map +0 -1
  226. package/typed/fill-style/shaders.glsl.d.ts.map +0 -1
  227. package/typed/index.d.ts +0 -19
  228. package/typed/index.d.ts.map +0 -1
  229. package/typed/mask/mask-effect.d.ts.map +0 -1
  230. package/typed/terrain/height-map-builder.d.ts.map +0 -1
  231. package/typed/terrain/shader-module.d.ts.map +0 -1
  232. package/typed/terrain/terrain-cover.d.ts.map +0 -1
  233. package/typed/terrain/terrain-effect.d.ts.map +0 -1
  234. package/typed/terrain/terrain-pass.d.ts.map +0 -1
  235. package/typed/terrain/terrain-picking-pass.d.ts.map +0 -1
  236. /package/{typed → dist}/brushing/brushing-extension.d.ts +0 -0
  237. /package/{typed → dist}/brushing/brushing-extension.d.ts.map +0 -0
  238. /package/{typed → dist}/clip/clip-extension.d.ts +0 -0
  239. /package/{typed → dist}/collision-filter/collision-filter-effect.d.ts +0 -0
  240. /package/{typed → dist}/collision-filter/collision-filter-extension.d.ts +0 -0
  241. /package/{typed → dist}/collision-filter/collision-filter-extension.d.ts.map +0 -0
  242. /package/{typed → dist}/collision-filter/collision-filter-pass.d.ts +0 -0
  243. /package/{typed → dist}/collision-filter/shader-module.d.ts +0 -0
  244. /package/{typed → dist}/data-filter/aggregator.d.ts +0 -0
  245. /package/{typed → dist}/fp64/fp64-extension.d.ts +0 -0
  246. /package/{typed → dist}/fp64/fp64-extension.d.ts.map +0 -0
  247. /package/{typed → dist}/fp64/project64.d.ts +0 -0
  248. /package/{typed → dist}/fp64/project64.d.ts.map +0 -0
  249. /package/{typed → dist}/fp64/project64.glsl.d.ts +0 -0
  250. /package/{typed → dist}/fp64/project64.glsl.d.ts.map +0 -0
  251. /package/{typed → dist}/mask/mask-extension.d.ts +0 -0
  252. /package/{typed → dist}/mask/mask-extension.d.ts.map +0 -0
  253. /package/{typed → dist}/mask/mask-pass.d.ts +0 -0
  254. /package/{typed → dist}/mask/shader-module.d.ts +0 -0
  255. /package/{typed → dist}/path-style/path-style-extension.d.ts +0 -0
  256. /package/{typed → dist}/path-style/path-style-extension.d.ts.map +0 -0
  257. /package/{typed → dist}/path-style/shaders.glsl.d.ts +0 -0
  258. /package/{typed → dist}/path-style/shaders.glsl.d.ts.map +0 -0
  259. /package/{typed → dist}/terrain/terrain-extension.d.ts +0 -0
  260. /package/{typed → dist}/terrain/terrain-extension.d.ts.map +0 -0
  261. /package/{typed → dist}/terrain/utils.d.ts +0 -0
  262. /package/{typed → dist}/terrain/utils.d.ts.map +0 -0
  263. /package/{typed → dist}/utils/debug.d.ts +0 -0
  264. /package/{typed → dist}/utils/projection-utils.d.ts +0 -0
  265. /package/{typed → dist}/utils/projection-utils.d.ts.map +0 -0
package/package.json CHANGED
@@ -2,7 +2,8 @@
2
2
  "name": "@deck.gl/extensions",
3
3
  "description": "Plug-and-play functionalities for deck.gl layers",
4
4
  "license": "MIT",
5
- "version": "9.0.0-beta.1",
5
+ "type": "module",
6
+ "version": "9.0.0-beta.10",
6
7
  "publishConfig": {
7
8
  "access": "public"
8
9
  },
@@ -16,13 +17,19 @@
16
17
  "type": "git",
17
18
  "url": "https://github.com/visgl/deck.gl.git"
18
19
  },
19
- "main": "dist/es5/index.js",
20
- "module": "dist/esm/index.js",
21
- "types": "typed/index.d.ts",
20
+ "types": "dist/index.d.ts",
21
+ "main": "dist/index.cjs",
22
+ "module": "dist/index.js",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js",
27
+ "require": "./dist/index.cjs"
28
+ }
29
+ },
22
30
  "files": [
23
31
  "dist",
24
32
  "src",
25
- "typed",
26
33
  "dist.min.js"
27
34
  ],
28
35
  "sideEffects": false,
@@ -31,18 +38,14 @@
31
38
  "prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env=dev"
32
39
  },
33
40
  "dependencies": {
34
- "@babel/runtime": "^7.0.0",
35
- "@luma.gl/shadertools": "9.0.0-alpha.54"
41
+ "@luma.gl/constants": "^9.0.4",
42
+ "@luma.gl/shadertools": "^9.0.4",
43
+ "@math.gl/core": "^4.0.0"
36
44
  },
37
45
  "peerDependencies": {
38
- "@deck.gl/core": "^9.0.0-alpha",
39
- "@luma.gl/constants": "9.0.0-alpha.54",
40
- "@luma.gl/core": "9.0.0-alpha.54",
41
- "@luma.gl/engine": "9.0.0-alpha.54",
42
- "@luma.gl/shadertools": "9.0.0-alpha.54",
43
- "@luma.gl/webgl": "9.0.0-alpha.54",
44
- "@math.gl/core": "^4.0.0",
45
- "@math.gl/web-mercator": "^4.0.0"
46
+ "@deck.gl/core": "^9.0.0-beta",
47
+ "@luma.gl/core": "^9.0.4",
48
+ "@luma.gl/engine": "^9.0.4"
46
49
  },
47
- "gitHead": "9628417918bec5cc73c1345bfcd2f2be575741f1"
50
+ "gitHead": "6c44f602069374cd21268ff279c5bf818c905ff7"
48
51
  }
@@ -23,6 +23,7 @@ import {project} from '@deck.gl/core';
23
23
  import type {Viewport} from '@deck.gl/core';
24
24
 
25
25
  import type {BrushingExtensionProps} from './brushing-extension';
26
+ import {glsl} from '../utils/syntax-tags';
26
27
 
27
28
  type BrushingModuleSettings = {
28
29
  // From layer context
@@ -30,7 +31,7 @@ type BrushingModuleSettings = {
30
31
  mousePosition?: {x: number; y: number};
31
32
  } & BrushingExtensionProps;
32
33
 
33
- const vs = `
34
+ const vs = glsl`
34
35
  uniform bool brushing_enabled;
35
36
  uniform int brushing_target;
36
37
  uniform vec2 brushing_mousePos;
@@ -64,7 +65,7 @@ const vs = `
64
65
  }
65
66
  `;
66
67
 
67
- const fs = `
68
+ const fs = glsl`
68
69
  uniform bool brushing_enabled;
69
70
  in float brushing_isVisible;
70
71
  `;
@@ -77,7 +78,7 @@ const TARGET = {
77
78
  };
78
79
 
79
80
  const inject = {
80
- 'vs:DECKGL_FILTER_GL_POSITION': `
81
+ 'vs:DECKGL_FILTER_GL_POSITION': glsl`
81
82
  vec2 brushingTarget;
82
83
  vec2 brushingSource;
83
84
  if (brushing_target == 3) {
@@ -22,6 +22,7 @@ import type {ShaderModule} from '@luma.gl/shadertools';
22
22
  import {LayerExtension} from '@deck.gl/core';
23
23
 
24
24
  import type {Layer} from '@deck.gl/core';
25
+ import {glsl} from '../utils/syntax-tags';
25
26
 
26
27
  const defaultProps = {
27
28
  clipBounds: [0, 0, 1, 1],
@@ -40,7 +41,7 @@ export type ClipExtensionProps = {
40
41
  clipByInstance?: boolean;
41
42
  };
42
43
 
43
- const shaderFunction = `
44
+ const shaderFunction = glsl`
44
45
  uniform vec4 clip_bounds;
45
46
 
46
47
  bool clip_isInBounds(vec2 position) {
@@ -58,16 +59,16 @@ const shaderModuleVs: ShaderModule = {
58
59
  };
59
60
 
60
61
  const injectionVs = {
61
- 'vs:#decl': `
62
+ 'vs:#decl': glsl`
62
63
  out float clip_isVisible;
63
64
  `,
64
- 'vs:DECKGL_FILTER_GL_POSITION': `
65
+ 'vs:DECKGL_FILTER_GL_POSITION': glsl`
65
66
  clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy));
66
67
  `,
67
- 'fs:#decl': `
68
+ 'fs:#decl': glsl`
68
69
  in float clip_isVisible;
69
70
  `,
70
- 'fs:DECKGL_FILTER_COLOR': `
71
+ 'fs:DECKGL_FILTER_COLOR': glsl`
71
72
  if (clip_isVisible < 0.5) discard;
72
73
  `
73
74
  };
@@ -82,16 +83,16 @@ const shaderModuleFs: ShaderModule = {
82
83
  };
83
84
 
84
85
  const injectionFs = {
85
- 'vs:#decl': `
86
+ 'vs:#decl': glsl`
86
87
  out vec2 clip_commonPosition;
87
88
  `,
88
- 'vs:DECKGL_FILTER_GL_POSITION': `
89
+ 'vs:DECKGL_FILTER_GL_POSITION': glsl`
89
90
  clip_commonPosition = geometry.position.xy;
90
91
  `,
91
- 'fs:#decl': `
92
+ 'fs:#decl': glsl`
92
93
  in vec2 clip_commonPosition;
93
94
  `,
94
- 'fs:DECKGL_FILTER_COLOR': `
95
+ 'fs:DECKGL_FILTER_COLOR': glsl`
95
96
  if (!clip_isInBounds(clip_commonPosition)) discard;
96
97
  `
97
98
  };
@@ -1,5 +1,4 @@
1
1
  import {Device, Framebuffer, Texture} from '@luma.gl/core';
2
- import {WEBGLRenderbuffer} from '@luma.gl/webgl';
3
2
  import {equals} from '@math.gl/core';
4
3
  import {_deepEqual as deepEqual} from '@deck.gl/core';
5
4
  import type {Effect, Layer, PreRenderOptions, Viewport} from '@deck.gl/core';
@@ -244,18 +243,23 @@ export default class CollisionFilterEffect implements Effect {
244
243
  }
245
244
  });
246
245
 
247
- const depthBuffer = new WEBGLRenderbuffer(
248
- // @ts-expect-error TODO v9 needs to be WebGLDevice
249
- device,
250
- {format: 'depth16unorm', width, height}
251
- );
246
+ // @ts-ignore
247
+ const depthStencilAttachment = device.createTexture({
248
+ format: 'depth16unorm',
249
+ width,
250
+ 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
256
+ });
252
257
  this.collisionFBOs[collisionGroup] = device.createFramebuffer({
253
258
  id: `collision-${collisionGroup}`,
254
259
  width,
255
260
  height,
256
261
  colorAttachments: [collisionMap],
257
- // @ts-expect-error TODO v9 doesn't handle renderbuffers well
258
- depthStencilAttachment: depthBuffer
262
+ depthStencilAttachment
259
263
  });
260
264
  }
261
265
 
@@ -1,5 +1,4 @@
1
1
  import {Framebuffer} from '@luma.gl/core';
2
- import {withGLParameters} from '@luma.gl/webgl';
3
2
  import {_LayersPass as LayersPass, LayersPassRenderOptions} from '@deck.gl/core';
4
3
 
5
4
  type CollisionFilterPassRenderOptions = LayersPassRenderOptions & {};
@@ -9,8 +8,7 @@ export default class CollisionFilterPass extends LayersPass {
9
8
  const padding = 1;
10
9
  const clearColor = [0, 0, 0, 0];
11
10
 
12
- return withGLParameters(
13
- this.device,
11
+ return this.device.withParametersWebGL(
14
12
  {
15
13
  scissorTest: true,
16
14
  scissor: [padding, padding, target.width - 2 * padding, target.height - 2 * padding],
@@ -1,8 +1,9 @@
1
1
  import {Framebuffer, Texture} from '@luma.gl/core';
2
2
  import type {ShaderModule} from '@luma.gl/shadertools';
3
3
  import {project} from '@deck.gl/core';
4
+ import {glsl} from '../utils/syntax-tags';
4
5
 
5
- const vs = `
6
+ const vs = glsl`
6
7
  #ifdef NON_INSTANCED_MODEL
7
8
  in float collisionPriorities;
8
9
  #else
@@ -54,10 +55,10 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
54
55
  `;
55
56
 
56
57
  const inject = {
57
- 'vs:#decl': `
58
+ 'vs:#decl': glsl`
58
59
  float collision_fade = 1.0;
59
60
  `,
60
- 'vs:DECKGL_FILTER_GL_POSITION': `
61
+ 'vs:DECKGL_FILTER_GL_POSITION': glsl`
61
62
  if (collision_sort) {
62
63
  #ifdef NON_INSTANCED_MODEL
63
64
  float collisionPriority = collisionPriorities;
@@ -77,7 +78,7 @@ const inject = {
77
78
  }
78
79
  }
79
80
  `,
80
- 'vs:DECKGL_FILTER_COLOR': `
81
+ 'vs:DECKGL_FILTER_COLOR': glsl`
81
82
  color.a *= collision_fade;
82
83
  `
83
84
  };
@@ -101,6 +102,7 @@ const getCollisionUniforms = (
101
102
  const {collisionFBO, drawToCollisionMap, dummyCollisionMap} = opts;
102
103
  return {
103
104
  collision_sort: Boolean(drawToCollisionMap),
105
+ // @ts-ignore (v9 not sure why this isn't allowed now)
104
106
  collision_texture:
105
107
  !drawToCollisionMap && collisionFBO ? collisionFBO.colorAttachments[0] : dummyCollisionMap
106
108
  };
@@ -1,4 +1,4 @@
1
- import {Device, Framebuffer} from '@luma.gl/core';
1
+ import {Device, DeviceFeature, Framebuffer} from '@luma.gl/core';
2
2
  import {Model} from '@luma.gl/engine';
3
3
  import {GL} from '@luma.gl/constants';
4
4
 
@@ -53,18 +53,13 @@ void main() {
53
53
  }
54
54
  `;
55
55
 
56
- export function supportsFloatTarget(device: Device): boolean {
57
- // @ts-expect-error
58
- const gl = device.gl;
56
+ const FLOAT_TARGET_FEATURES: DeviceFeature[] = [
57
+ 'float32-renderable-webgl', // ability to render to float texture
58
+ 'texture-blend-float-webgl' // ability to blend when rendering to float texture
59
+ ];
59
60
 
60
- // 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!
61
- return Boolean(
62
- gl.getExtension('EXT_float_blend') &&
63
- // WebGL 2
64
- (gl.getExtension('EXT_color_buffer_float') ||
65
- // WebGL 1
66
- gl.getExtension('WEBGL_color_buffer_float'))
67
- );
61
+ export function supportsFloatTarget(device: Device): boolean {
62
+ return FLOAT_TARGET_FEATURES.every(feature => device.features.has(feature));
68
63
  }
69
64
 
70
65
  // A 1x1 framebuffer object that encodes the total count of filtered items
@@ -75,7 +70,7 @@ export function getFramebuffer(device: Device, useFloatTarget: boolean): Framebu
75
70
  height: 1,
76
71
  colorAttachments: [
77
72
  device.createTexture({
78
- format: device.info.type === 'webgl2' ? 'rgba32float' : 'rgba8unorm',
73
+ format: 'rgba32float',
79
74
  type: GL.FLOAT,
80
75
  mipmaps: false
81
76
  })
@@ -18,32 +18,39 @@
18
18
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  // THE SOFTWARE.
20
20
 
21
- import {readPixelsToArray, clear, withGLParameters} from '@luma.gl/webgl';
22
- import {GL} from '@luma.gl/constants';
23
21
  import type {Framebuffer} from '@luma.gl/core';
24
22
  import type {Model} from '@luma.gl/engine';
25
23
  import type {Layer, LayerContext, Accessor, UpdateParameters} from '@deck.gl/core';
26
- import {LayerExtension} from '@deck.gl/core';
24
+ import {_deepEqual as deepEqual, LayerExtension, log} from '@deck.gl/core';
27
25
  import {shaderModule, shaderModule64} from './shader-module';
28
26
  import * as aggregator from './aggregator';
29
27
 
30
28
  const defaultProps = {
31
29
  getFilterValue: {type: 'accessor', value: 0},
30
+ getFilterCategory: {type: 'accessor', value: 0},
32
31
  onFilteredItemsChange: {type: 'function', value: null, optional: true},
33
32
 
34
33
  filterEnabled: true,
35
34
  filterRange: [-1, 1],
36
35
  filterSoftRange: null,
36
+ filterCategories: [0],
37
37
  filterTransformSize: true,
38
38
  filterTransformColor: true
39
39
  };
40
40
 
41
+ type FilterCategory = number | string;
42
+
41
43
  export type DataFilterExtensionProps<DataT = any> = {
42
44
  /**
43
45
  * Accessor to retrieve the value for each object that it will be filtered by.
44
46
  * Returns either a number (if `filterSize: 1`) or an array of numbers.
45
47
  */
46
48
  getFilterValue?: Accessor<DataT, number | number[]>;
49
+ /**
50
+ * Accessor to retrieve the category (`number | string`) for each object that it will be filtered by.
51
+ * Returns either a single category (if `filterSize: 1`) or an array of categories.
52
+ */
53
+ getFilterCategory?: Accessor<DataT, FilterCategory | FilterCategory[]>;
47
54
  /**
48
55
  * Enable/disable the data filter. If the data filter is disabled, all objects are rendered.
49
56
  * @default true
@@ -71,6 +78,11 @@ export type DataFilterExtensionProps<DataT = any> = {
71
78
  * @default true
72
79
  */
73
80
  filterTransformColor?: boolean;
81
+ /**
82
+ * The categories which define whether an object should be rendered.
83
+ * @default []
84
+ */
85
+ filterCategories: FilterCategory[] | FilterCategory[][];
74
86
  /**
75
87
  * Only called if the `countItems` option is enabled.
76
88
  */
@@ -83,21 +95,33 @@ export type DataFilterExtensionProps<DataT = any> = {
83
95
  };
84
96
 
85
97
  type DataFilterExtensionOptions = {
98
+ /**
99
+ * The size of the category filter (number of columns to filter by). The category filter can show/hide data based on 1-4 properties of each object.
100
+ * @default 1
101
+ */
102
+ categorySize?: 1 | 2 | 3 | 4;
86
103
  /**
87
104
  * The size of the filter (number of columns to filter by). The data filter can show/hide data based on 1-4 numeric properties of each object.
88
105
  * @default 1
89
106
  */
90
- filterSize: number;
107
+ filterSize?: 1 | 2 | 3 | 4;
91
108
  /**
92
109
  * Use 64-bit precision instead of 32-bit.
93
110
  * @default false
94
111
  */
95
- fp64: boolean;
112
+ fp64?: boolean;
96
113
  /**
97
114
  * If `true`, reports the number of filtered objects with the `onFilteredItemsChange` callback.
98
115
  * @default `false`.
99
116
  */
100
- countItems: boolean;
117
+ countItems?: boolean;
118
+ };
119
+
120
+ const defaultOptions: Required<DataFilterExtensionOptions> = {
121
+ categorySize: 1,
122
+ filterSize: 1,
123
+ fp64: false,
124
+ countItems: false
101
125
  };
102
126
 
103
127
  const DATA_TYPE_FROM_SIZE = {
@@ -108,28 +132,24 @@ const DATA_TYPE_FROM_SIZE = {
108
132
  };
109
133
 
110
134
  /** Adds GPU-based data filtering functionalities to layers. It allows the layer to show/hide objects based on user-defined properties. */
111
- export default class DataFilterExtension extends LayerExtension<DataFilterExtensionOptions> {
135
+ export default class DataFilterExtension extends LayerExtension<
136
+ Required<DataFilterExtensionOptions>
137
+ > {
112
138
  static defaultProps = defaultProps;
113
139
  static extensionName = 'DataFilterExtension';
114
140
 
115
- constructor({
116
- filterSize = 1,
117
- fp64 = false,
118
- countItems = false
119
- }: Partial<DataFilterExtensionOptions> = {}) {
120
- if (!DATA_TYPE_FROM_SIZE[filterSize]) {
121
- throw new Error('filterSize out of range');
122
- }
123
-
124
- super({filterSize, fp64, countItems});
141
+ constructor(opts: DataFilterExtensionOptions = {}) {
142
+ super({...defaultOptions, ...opts});
125
143
  }
126
144
 
127
145
  getShaders(this: Layer<DataFilterExtensionProps>, extension: this): any {
128
- const {filterSize, fp64} = extension.opts;
146
+ const {categorySize, filterSize, fp64} = extension.opts;
129
147
 
130
148
  return {
131
149
  modules: [fp64 ? shaderModule64 : shaderModule],
132
150
  defines: {
151
+ DATACATEGORY_TYPE: DATA_TYPE_FROM_SIZE[categorySize],
152
+ DATACATEGORY_CHANNELS: categorySize,
133
153
  DATAFILTER_TYPE: DATA_TYPE_FROM_SIZE[filterSize],
134
154
  DATAFILTER_DOUBLE: Boolean(fp64)
135
155
  }
@@ -138,11 +158,13 @@ export default class DataFilterExtension extends LayerExtension<DataFilterExtens
138
158
 
139
159
  initializeState(this: Layer<DataFilterExtensionProps>, context: LayerContext, extension: this) {
140
160
  const attributeManager = this.getAttributeManager();
161
+ const {categorySize, filterSize, fp64} = extension.opts;
162
+
141
163
  if (attributeManager) {
142
164
  attributeManager.add({
143
165
  filterValues: {
144
- size: extension.opts.filterSize,
145
- type: extension.opts.fp64 ? GL.DOUBLE : GL.FLOAT,
166
+ size: filterSize,
167
+ type: fp64 ? 'float64' : 'float32',
146
168
  accessor: 'getFilterValue',
147
169
  shaderAttributes: {
148
170
  filterValues: {
@@ -152,6 +174,22 @@ export default class DataFilterExtension extends LayerExtension<DataFilterExtens
152
174
  divisor: 1
153
175
  }
154
176
  }
177
+ },
178
+ filterCategoryValues: {
179
+ size: categorySize,
180
+ accessor: 'getFilterCategory',
181
+ transform:
182
+ categorySize === 1
183
+ ? d => extension._getCategoryKey.call(this, d, 0)
184
+ : d => d.map((x, i) => extension._getCategoryKey.call(this, x, i)),
185
+ shaderAttributes: {
186
+ filterCategoryValues: {
187
+ divisor: 0
188
+ },
189
+ instanceFilterCategoryValues: {
190
+ divisor: 1
191
+ }
192
+ }
155
193
  }
156
194
  });
157
195
  }
@@ -166,8 +204,7 @@ export default class DataFilterExtension extends LayerExtension<DataFilterExtens
166
204
  filterIndices: {
167
205
  size: useFloatTarget ? 1 : 2,
168
206
  vertexOffset: 1,
169
- type: GL.UNSIGNED_BYTE,
170
- normalized: true,
207
+ type: 'unorm8',
171
208
  accessor: (object, {index}) => {
172
209
  const i = object && object.__source ? object.__source.index : index;
173
210
  return useFloatTarget ? (i + 1) % 255 : [(i + 1) % 255, Math.floor(i / 255) % 255];
@@ -195,44 +232,74 @@ export default class DataFilterExtension extends LayerExtension<DataFilterExtens
195
232
 
196
233
  updateState(
197
234
  this: Layer<DataFilterExtensionProps>,
198
- {props, oldProps}: UpdateParameters<Layer<DataFilterExtensionProps>>
235
+ {props, oldProps, changeFlags}: UpdateParameters<Layer<DataFilterExtensionProps>>,
236
+ extension: this
199
237
  ) {
238
+ const attributeManager = this.getAttributeManager();
239
+ const {categorySize} = extension.opts;
200
240
  if (this.state.filterModel) {
201
- const attributeManager = this.getAttributeManager();
202
241
  const filterNeedsUpdate =
203
242
  // attributeManager must be defined for filterModel to be set
204
243
  attributeManager!.attributes.filterValues.needsUpdate() ||
244
+ attributeManager!.attributes.filterCategoryValues?.needsUpdate() ||
205
245
  props.filterEnabled !== oldProps.filterEnabled ||
206
246
  props.filterRange !== oldProps.filterRange ||
207
- props.filterSoftRange !== oldProps.filterSoftRange;
247
+ props.filterSoftRange !== oldProps.filterSoftRange ||
248
+ props.filterCategories !== oldProps.filterCategories;
208
249
  if (filterNeedsUpdate) {
209
250
  this.setState({filterNeedsUpdate});
210
251
  }
211
252
  }
253
+ if (attributeManager?.attributes.filterCategoryValues) {
254
+ // Update bitmask if accessor or selected categories has changed
255
+ const categoryBitMaskNeedsUpdate =
256
+ attributeManager.attributes.filterCategoryValues.needsUpdate() ||
257
+ !deepEqual(props.filterCategories, oldProps.filterCategories, 2);
258
+ if (categoryBitMaskNeedsUpdate) {
259
+ this.setState({categoryBitMaskNeedsUpdate});
260
+ }
261
+
262
+ // Need to recreate category map if categorySize has changed
263
+ const resetCategories = changeFlags.dataChanged;
264
+ if (resetCategories) {
265
+ this.setState({
266
+ categoryMap: Array(categorySize)
267
+ .fill(0)
268
+ .map(() => ({}))
269
+ });
270
+ attributeManager.attributes.filterCategoryValues.setNeedsUpdate('categoryMap');
271
+ }
272
+ }
212
273
  }
213
274
 
214
275
  draw(this: Layer<DataFilterExtensionProps>, params: any, extension: this) {
215
276
  const filterFBO = this.state.filterFBO as Framebuffer;
216
277
  const filterModel = this.state.filterModel as Model;
217
278
  const filterNeedsUpdate = this.state.filterNeedsUpdate as boolean;
279
+ const categoryBitMaskNeedsUpdate = this.state.categoryBitMaskNeedsUpdate as boolean;
218
280
 
219
281
  const {onFilteredItemsChange} = this.props;
282
+
283
+ if (categoryBitMaskNeedsUpdate) {
284
+ extension._updateCategoryBitMask.call(this, params, extension);
285
+ }
220
286
  if (filterNeedsUpdate && onFilteredItemsChange && filterModel) {
221
287
  const {
222
- attributes: {filterValues, filterIndices}
288
+ attributes: {filterValues, filterCategoryValues, filterIndices}
223
289
  } = this.getAttributeManager()!;
224
290
  filterModel.setVertexCount(this.getNumInstances());
225
291
 
226
- clear(this.context.device, {framebuffer: filterFBO, color: [0, 0, 0, 0]});
292
+ this.context.device.clearWebGL({framebuffer: filterFBO, color: [0, 0, 0, 0]});
227
293
 
228
294
  filterModel.updateModuleSettings(params.moduleParameters);
229
295
  // @ts-expect-error filterValue and filterIndices should always have buffer value
230
296
  filterModel.setAttributes({
231
297
  ...filterValues.getValue(),
298
+ ...filterCategoryValues?.getValue(),
232
299
  ...filterIndices?.getValue()
233
300
  });
234
- withGLParameters(
235
- filterModel.device,
301
+ filterModel.setUniforms(params.uniforms);
302
+ filterModel.device.withParametersWebGL(
236
303
  {
237
304
  framebuffer: filterFBO,
238
305
  // ts-ignore 'readonly' cannot be assigned to the mutable type '[GLBlendEquation, GLBlendEquation]'
@@ -243,7 +310,7 @@ export default class DataFilterExtension extends LayerExtension<DataFilterExtens
243
310
  filterModel.draw(this.context.renderPass);
244
311
  }
245
312
  );
246
- const color = readPixelsToArray(filterFBO);
313
+ const color = filterModel.device.readPixelsToArrayWebGL(filterFBO);
247
314
  let count = 0;
248
315
  for (let i = 0; i < color.length; i++) {
249
316
  count += color[i];
@@ -262,4 +329,54 @@ export default class DataFilterExtension extends LayerExtension<DataFilterExtens
262
329
  filterFBO?.destroy();
263
330
  filterModel?.destroy();
264
331
  }
332
+
333
+ /**
334
+ * Updates the bitmask used on the GPU to perform the filter based on the
335
+ * `filterCategories` prop. The mapping between categories and bit in the bitmask
336
+ * is performed by `_getCategoryKey()`
337
+ */
338
+ _updateCategoryBitMask(
339
+ this: Layer<DataFilterExtensionProps>,
340
+ params: any,
341
+ extension: this
342
+ ): void {
343
+ const {categorySize} = extension.opts;
344
+ const {filterCategories} = this.props;
345
+ const categoryBitMask = new Uint32Array([0, 0, 0, 0]);
346
+ const categoryFilters = (
347
+ categorySize === 1 ? [filterCategories] : filterCategories
348
+ ) as FilterCategory[][];
349
+ const maxCategories = categorySize === 1 ? 128 : categorySize === 2 ? 64 : 32;
350
+ for (let c = 0; c < categoryFilters.length; c++) {
351
+ const categoryFilter = categoryFilters[c];
352
+ for (const category of categoryFilter) {
353
+ const key = extension._getCategoryKey.call(this, category, c);
354
+ if (key < maxCategories) {
355
+ const channel = c * (maxCategories / 32) + Math.floor(key / 32);
356
+ categoryBitMask[channel] += Math.pow(2, key % 32); // 1 << key fails for key > 30
357
+ } else {
358
+ log.warn(`Exceeded maximum number of categories (${maxCategories})`)();
359
+ }
360
+ }
361
+ }
362
+ /* eslint-disable-next-line camelcase */
363
+ params.uniforms.filter_categoryBitMask = categoryBitMask;
364
+ this.state.categoryBitMaskNeedsUpdate = false;
365
+ }
366
+
367
+ /**
368
+ * Returns an index of bit in the bitmask for a given category. If the category has
369
+ * not yet been assigned a bit, a new one is assigned.
370
+ */
371
+ _getCategoryKey(
372
+ this: Layer<DataFilterExtensionProps>,
373
+ category: FilterCategory,
374
+ channel: number
375
+ ) {
376
+ const categoryMap = (this.state.categoryMap as Record<FilterCategory, number>[])[channel];
377
+ if (!(category in categoryMap)) {
378
+ categoryMap[category] = Object.keys(categoryMap).length;
379
+ }
380
+ return categoryMap[category];
381
+ }
265
382
  }