@deck.gl/aggregation-layers 9.0.34 → 9.1.0-beta.1

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 (318) hide show
  1. package/dist/common/aggregation-layer.d.ts +30 -0
  2. package/dist/common/aggregation-layer.d.ts.map +1 -0
  3. package/dist/common/aggregation-layer.js +69 -0
  4. package/dist/common/aggregator/aggregator.d.ts +76 -0
  5. package/dist/common/aggregator/aggregator.d.ts.map +1 -0
  6. package/dist/common/aggregator/aggregator.js +4 -0
  7. package/dist/common/aggregator/cpu-aggregator/aggregate.d.ts +27 -0
  8. package/dist/common/aggregator/cpu-aggregator/aggregate.d.ts.map +1 -0
  9. package/dist/common/aggregator/cpu-aggregator/aggregate.js +66 -0
  10. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.d.ts +70 -0
  11. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.d.ts.map +1 -0
  12. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.js +139 -0
  13. package/dist/common/aggregator/cpu-aggregator/sort-bins.d.ts +15 -0
  14. package/dist/common/aggregator/cpu-aggregator/sort-bins.d.ts.map +1 -0
  15. package/dist/common/aggregator/cpu-aggregator/sort-bins.js +43 -0
  16. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.d.ts +21 -0
  17. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.d.ts.map +1 -0
  18. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.js +55 -0
  19. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.d.ts +18 -0
  20. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.d.ts.map +1 -0
  21. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.js +20 -0
  22. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.d.ts +14 -0
  23. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.d.ts.map +1 -0
  24. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.js +17 -0
  25. package/dist/common/aggregator/gpu-aggregator/utils.d.ts +6 -0
  26. package/dist/common/aggregator/gpu-aggregator/utils.d.ts.map +1 -0
  27. package/dist/common/aggregator/gpu-aggregator/utils.js +24 -0
  28. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts +24 -0
  29. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts.map +1 -0
  30. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js +215 -0
  31. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.d.ts +81 -0
  32. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.d.ts.map +1 -0
  33. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.js +201 -0
  34. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.d.ts +38 -0
  35. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.d.ts.map +1 -0
  36. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js +223 -0
  37. package/dist/common/aggregator/index.d.ts +6 -0
  38. package/dist/common/aggregator/index.d.ts.map +1 -0
  39. package/dist/common/aggregator/index.js +5 -0
  40. package/dist/common/types.d.ts +11 -0
  41. package/dist/common/types.d.ts.map +1 -0
  42. package/dist/common/types.js +4 -0
  43. package/dist/common/utils/bounds-utils.d.ts +10 -0
  44. package/dist/common/utils/bounds-utils.d.ts.map +1 -0
  45. package/dist/common/utils/bounds-utils.js +20 -0
  46. package/dist/common/utils/color-utils.d.ts +10 -0
  47. package/dist/common/utils/color-utils.d.ts.map +1 -0
  48. package/dist/common/utils/color-utils.js +65 -0
  49. package/dist/common/utils/prop-utils.d.ts.map +1 -0
  50. package/dist/common/utils/prop-utils.js +12 -0
  51. package/dist/common/utils/scale-utils.d.ts +46 -0
  52. package/dist/common/utils/scale-utils.d.ts.map +1 -0
  53. package/dist/common/utils/scale-utils.js +180 -0
  54. package/dist/contour-layer/bin-options-uniforms.d.ts +13 -0
  55. package/dist/contour-layer/bin-options-uniforms.d.ts.map +1 -0
  56. package/dist/contour-layer/bin-options-uniforms.js +17 -0
  57. package/dist/contour-layer/contour-layer.d.ts +42 -50
  58. package/dist/contour-layer/contour-layer.d.ts.map +1 -1
  59. package/dist/contour-layer/contour-layer.js +232 -192
  60. package/dist/contour-layer/contour-utils.d.ts +36 -15
  61. package/dist/contour-layer/contour-utils.d.ts.map +1 -1
  62. package/dist/contour-layer/contour-utils.js +24 -29
  63. package/dist/contour-layer/marching-squares-codes.d.ts.map +1 -1
  64. package/dist/contour-layer/marching-squares-codes.js +3 -0
  65. package/dist/contour-layer/marching-squares.d.ts +22 -6
  66. package/dist/contour-layer/marching-squares.d.ts.map +1 -1
  67. package/dist/contour-layer/marching-squares.js +71 -68
  68. package/dist/contour-layer/value-reader.d.ts +10 -0
  69. package/dist/contour-layer/value-reader.d.ts.map +1 -0
  70. package/dist/contour-layer/value-reader.js +46 -0
  71. package/dist/dist.dev.js +4842 -4081
  72. package/dist/grid-layer/bin-options-uniforms.d.ts +13 -0
  73. package/dist/grid-layer/bin-options-uniforms.d.ts.map +1 -0
  74. package/dist/grid-layer/bin-options-uniforms.js +17 -0
  75. package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts +3 -0
  76. package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts.map +1 -0
  77. package/dist/grid-layer/grid-cell-layer-vertex.glsl.js +51 -0
  78. package/dist/grid-layer/grid-cell-layer.d.ts +32 -0
  79. package/dist/grid-layer/grid-cell-layer.d.ts.map +1 -0
  80. package/dist/grid-layer/grid-cell-layer.js +93 -0
  81. package/dist/grid-layer/grid-layer-uniforms.d.ts +21 -0
  82. package/dist/grid-layer/grid-layer-uniforms.d.ts.map +1 -0
  83. package/dist/grid-layer/grid-layer-uniforms.js +23 -0
  84. package/dist/grid-layer/grid-layer.d.ts +175 -13
  85. package/dist/grid-layer/grid-layer.d.ts.map +1 -1
  86. package/dist/grid-layer/grid-layer.js +342 -46
  87. package/dist/{aggregation-layer.d.ts → heatmap-layer/aggregation-layer.d.ts} +1 -0
  88. package/dist/heatmap-layer/aggregation-layer.d.ts.map +1 -0
  89. package/dist/{aggregation-layer.js → heatmap-layer/aggregation-layer.js} +6 -21
  90. package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts +30 -0
  91. package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts.map +1 -0
  92. package/dist/heatmap-layer/heatmap-layer-uniforms.js +32 -0
  93. package/dist/heatmap-layer/heatmap-layer-utils.d.ts +1 -1
  94. package/dist/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -1
  95. package/dist/heatmap-layer/heatmap-layer-utils.js +3 -0
  96. package/dist/heatmap-layer/heatmap-layer.d.ts +6 -4
  97. package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -1
  98. package/dist/heatmap-layer/heatmap-layer.js +43 -33
  99. package/dist/heatmap-layer/max-fs.glsl.d.ts.map +1 -1
  100. package/dist/heatmap-layer/max-fs.glsl.js +3 -0
  101. package/dist/heatmap-layer/max-vs.glsl.d.ts +1 -1
  102. package/dist/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
  103. package/dist/heatmap-layer/max-vs.glsl.js +6 -4
  104. package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts +1 -1
  105. package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +1 -1
  106. package/dist/heatmap-layer/triangle-layer-fragment.glsl.js +5 -23
  107. package/dist/heatmap-layer/triangle-layer-uniforms.d.ts +22 -0
  108. package/dist/heatmap-layer/triangle-layer-uniforms.d.ts.map +1 -0
  109. package/dist/heatmap-layer/triangle-layer-uniforms.js +22 -0
  110. package/dist/heatmap-layer/triangle-layer-vertex.glsl.d.ts +1 -1
  111. package/dist/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +1 -1
  112. package/dist/heatmap-layer/triangle-layer-vertex.glsl.js +10 -30
  113. package/dist/heatmap-layer/triangle-layer.d.ts +4 -10
  114. package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -1
  115. package/dist/heatmap-layer/triangle-layer.js +17 -30
  116. package/dist/heatmap-layer/weights-fs.glsl.d.ts.map +1 -1
  117. package/dist/heatmap-layer/weights-fs.glsl.js +3 -0
  118. package/dist/heatmap-layer/weights-vs.glsl.d.ts +1 -1
  119. package/dist/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
  120. package/dist/heatmap-layer/weights-vs.glsl.js +6 -7
  121. package/dist/hexagon-layer/bin-options-uniforms.d.ts +14 -0
  122. package/dist/hexagon-layer/bin-options-uniforms.d.ts.map +1 -0
  123. package/dist/hexagon-layer/bin-options-uniforms.js +17 -0
  124. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts +3 -0
  125. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts.map +1 -0
  126. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.js +55 -0
  127. package/dist/hexagon-layer/hexagon-cell-layer.d.ts +29 -0
  128. package/dist/hexagon-layer/hexagon-cell-layer.d.ts.map +1 -0
  129. package/dist/hexagon-layer/hexagon-cell-layer.js +94 -0
  130. package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts +19 -0
  131. package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts.map +1 -0
  132. package/dist/hexagon-layer/hexagon-layer-uniforms.js +21 -0
  133. package/dist/hexagon-layer/hexagon-layer.d.ts +84 -54
  134. package/dist/hexagon-layer/hexagon-layer.d.ts.map +1 -1
  135. package/dist/hexagon-layer/hexagon-layer.js +307 -123
  136. package/dist/hexagon-layer/hexbin.d.ts +17 -0
  137. package/dist/hexagon-layer/hexbin.d.ts.map +1 -0
  138. package/dist/hexagon-layer/hexbin.js +69 -0
  139. package/dist/index.cjs +3025 -2946
  140. package/dist/index.cjs.map +4 -4
  141. package/dist/index.d.ts +7 -13
  142. package/dist/index.d.ts.map +1 -1
  143. package/dist/index.js +5 -27
  144. package/dist/screen-grid-layer/bin-options-uniforms.d.ts +11 -0
  145. package/dist/screen-grid-layer/bin-options-uniforms.d.ts.map +1 -0
  146. package/dist/screen-grid-layer/bin-options-uniforms.js +15 -0
  147. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts +11 -16
  148. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
  149. package/dist/screen-grid-layer/screen-grid-cell-layer.js +52 -134
  150. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +1 -1
  151. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +1 -1
  152. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js +4 -24
  153. package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts +17 -0
  154. package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts.map +1 -0
  155. package/dist/screen-grid-layer/screen-grid-layer-uniforms.js +19 -0
  156. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +1 -1
  157. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +1 -1
  158. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js +21 -62
  159. package/dist/screen-grid-layer/screen-grid-layer.d.ts +33 -40
  160. package/dist/screen-grid-layer/screen-grid-layer.d.ts.map +1 -1
  161. package/dist/screen-grid-layer/screen-grid-layer.js +157 -174
  162. package/dist.min.js +401 -382
  163. package/package.json +10 -9
  164. package/src/common/aggregation-layer.ts +107 -0
  165. package/src/common/aggregator/aggregator.ts +88 -0
  166. package/src/common/aggregator/cpu-aggregator/aggregate.ts +101 -0
  167. package/src/common/aggregator/cpu-aggregator/cpu-aggregator.ts +203 -0
  168. package/src/common/aggregator/cpu-aggregator/sort-bins.ts +63 -0
  169. package/src/common/aggregator/cpu-aggregator/vertex-accessor.ts +86 -0
  170. package/src/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.ts +33 -0
  171. package/src/common/aggregator/gpu-aggregator/bin-sorter-uniforms.ts +27 -0
  172. package/src/common/aggregator/gpu-aggregator/utils.ts +27 -0
  173. package/src/common/aggregator/gpu-aggregator/webgl-aggregation-transform.ts +247 -0
  174. package/src/common/aggregator/gpu-aggregator/webgl-aggregator.ts +274 -0
  175. package/src/common/aggregator/gpu-aggregator/webgl-bin-sorter.ts +258 -0
  176. package/src/common/aggregator/index.ts +10 -0
  177. package/src/{types.ts → common/types.ts} +10 -4
  178. package/src/common/utils/bounds-utils.ts +34 -0
  179. package/src/common/utils/color-utils.ts +86 -0
  180. package/src/common/utils/prop-utils.ts +13 -0
  181. package/src/common/utils/scale-utils.ts +236 -0
  182. package/src/contour-layer/bin-options-uniforms.ts +26 -0
  183. package/src/contour-layer/contour-layer.ts +300 -265
  184. package/src/contour-layer/contour-utils.ts +68 -39
  185. package/src/contour-layer/marching-squares-codes.ts +4 -0
  186. package/src/contour-layer/marching-squares.ts +93 -82
  187. package/src/contour-layer/value-reader.ts +65 -0
  188. package/src/grid-layer/bin-options-uniforms.ts +26 -0
  189. package/src/grid-layer/grid-cell-layer-vertex.glsl.ts +68 -0
  190. package/src/grid-layer/grid-cell-layer.ts +141 -0
  191. package/src/grid-layer/grid-layer-uniforms.ts +37 -0
  192. package/src/grid-layer/grid-layer.ts +614 -73
  193. package/src/{aggregation-layer.ts → heatmap-layer/aggregation-layer.ts} +6 -21
  194. package/src/heatmap-layer/heatmap-layer-uniforms.ts +50 -0
  195. package/src/heatmap-layer/heatmap-layer-utils.ts +9 -1
  196. package/src/heatmap-layer/heatmap-layer.ts +59 -36
  197. package/src/heatmap-layer/max-fs.glsl.ts +4 -0
  198. package/src/heatmap-layer/max-vs.glsl.ts +7 -4
  199. package/src/heatmap-layer/triangle-layer-fragment.glsl.ts +5 -23
  200. package/src/heatmap-layer/triangle-layer-uniforms.ts +37 -0
  201. package/src/heatmap-layer/triangle-layer-vertex.glsl.ts +10 -30
  202. package/src/heatmap-layer/triangle-layer.ts +26 -31
  203. package/src/heatmap-layer/weights-fs.glsl.ts +4 -0
  204. package/src/heatmap-layer/weights-vs.glsl.ts +7 -7
  205. package/src/hexagon-layer/bin-options-uniforms.ts +27 -0
  206. package/src/hexagon-layer/hexagon-cell-layer-vertex.glsl.ts +73 -0
  207. package/src/hexagon-layer/hexagon-cell-layer.ts +141 -0
  208. package/src/hexagon-layer/hexagon-layer-uniforms.ts +34 -0
  209. package/src/hexagon-layer/hexagon-layer.ts +454 -186
  210. package/src/hexagon-layer/hexbin.ts +79 -0
  211. package/src/index.ts +21 -34
  212. package/src/screen-grid-layer/bin-options-uniforms.ts +23 -0
  213. package/src/screen-grid-layer/screen-grid-cell-layer.ts +71 -156
  214. package/src/screen-grid-layer/screen-grid-layer-fragment.glsl.ts +4 -24
  215. package/src/screen-grid-layer/screen-grid-layer-uniforms.ts +31 -0
  216. package/src/screen-grid-layer/screen-grid-layer-vertex.glsl.ts +21 -64
  217. package/src/screen-grid-layer/screen-grid-layer.ts +194 -222
  218. package/dist/aggregation-layer.d.ts.map +0 -1
  219. package/dist/cpu-grid-layer/cpu-grid-layer.d.ts +0 -158
  220. package/dist/cpu-grid-layer/cpu-grid-layer.d.ts.map +0 -1
  221. package/dist/cpu-grid-layer/cpu-grid-layer.js +0 -130
  222. package/dist/cpu-grid-layer/grid-aggregator.d.ts +0 -35
  223. package/dist/cpu-grid-layer/grid-aggregator.d.ts.map +0 -1
  224. package/dist/cpu-grid-layer/grid-aggregator.js +0 -141
  225. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +0 -3
  226. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +0 -1
  227. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -30
  228. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +0 -3
  229. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +0 -1
  230. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -112
  231. package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts +0 -48
  232. package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +0 -1
  233. package/dist/gpu-grid-layer/gpu-grid-cell-layer.js +0 -146
  234. package/dist/gpu-grid-layer/gpu-grid-layer.d.ts +0 -99
  235. package/dist/gpu-grid-layer/gpu-grid-layer.d.ts.map +0 -1
  236. package/dist/gpu-grid-layer/gpu-grid-layer.js +0 -289
  237. package/dist/grid-aggregation-layer.d.ts +0 -67
  238. package/dist/grid-aggregation-layer.d.ts.map +0 -1
  239. package/dist/grid-aggregation-layer.js +0 -173
  240. package/dist/hexagon-layer/hexagon-aggregator.d.ts +0 -27
  241. package/dist/hexagon-layer/hexagon-aggregator.d.ts.map +0 -1
  242. package/dist/hexagon-layer/hexagon-aggregator.js +0 -112
  243. package/dist/types.d.ts +0 -12
  244. package/dist/types.d.ts.map +0 -1
  245. package/dist/types.js +0 -1
  246. package/dist/utils/aggregation-operation-utils.d.ts +0 -19
  247. package/dist/utils/aggregation-operation-utils.d.ts.map +0 -1
  248. package/dist/utils/aggregation-operation-utils.js +0 -94
  249. package/dist/utils/bin-sorter.d.ts +0 -52
  250. package/dist/utils/bin-sorter.d.ts.map +0 -1
  251. package/dist/utils/bin-sorter.js +0 -167
  252. package/dist/utils/color-utils.d.ts +0 -3
  253. package/dist/utils/color-utils.d.ts.map +0 -1
  254. package/dist/utils/color-utils.js +0 -53
  255. package/dist/utils/cpu-aggregator.d.ts +0 -169
  256. package/dist/utils/cpu-aggregator.d.ts.map +0 -1
  257. package/dist/utils/cpu-aggregator.js +0 -421
  258. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +0 -3
  259. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +0 -1
  260. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -36
  261. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +0 -3
  262. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +0 -1
  263. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -42
  264. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +0 -3
  265. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +0 -1
  266. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -30
  267. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +0 -3
  268. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +0 -1
  269. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -61
  270. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +0 -38
  271. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +0 -1
  272. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -41
  273. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts +0 -1
  274. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +0 -1
  275. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -1
  276. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +0 -76
  277. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +0 -1
  278. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -555
  279. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +0 -3
  280. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +0 -1
  281. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -32
  282. package/dist/utils/grid-aggregation-utils.d.ts +0 -30
  283. package/dist/utils/grid-aggregation-utils.d.ts.map +0 -1
  284. package/dist/utils/grid-aggregation-utils.js +0 -114
  285. package/dist/utils/prop-utils.d.ts.map +0 -1
  286. package/dist/utils/prop-utils.js +0 -28
  287. package/dist/utils/resource-utils.d.ts +0 -14
  288. package/dist/utils/resource-utils.d.ts.map +0 -1
  289. package/dist/utils/resource-utils.js +0 -38
  290. package/dist/utils/scale-utils.d.ts +0 -15
  291. package/dist/utils/scale-utils.d.ts.map +0 -1
  292. package/dist/utils/scale-utils.js +0 -184
  293. package/src/cpu-grid-layer/cpu-grid-layer.ts +0 -329
  294. package/src/cpu-grid-layer/grid-aggregator.ts +0 -184
  295. package/src/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.ts +0 -35
  296. package/src/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.ts +0 -143
  297. package/src/gpu-grid-layer/gpu-grid-cell-layer.ts +0 -201
  298. package/src/gpu-grid-layer/gpu-grid-layer.ts +0 -455
  299. package/src/grid-aggregation-layer.ts +0 -243
  300. package/src/hexagon-layer/hexagon-aggregator.ts +0 -127
  301. package/src/utils/aggregation-operation-utils.ts +0 -118
  302. package/src/utils/bin-sorter.ts +0 -218
  303. package/src/utils/color-utils.ts +0 -57
  304. package/src/utils/cpu-aggregator.ts +0 -503
  305. package/src/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.ts +0 -40
  306. package/src/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.ts +0 -54
  307. package/src/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.ts +0 -35
  308. package/src/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.ts +0 -79
  309. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.ts +0 -46
  310. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.ts +0 -0
  311. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
  312. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.ts +0 -690
  313. package/src/utils/gpu-grid-aggregation/transform-mean-vs.glsl.ts +0 -38
  314. package/src/utils/grid-aggregation-utils.ts +0 -147
  315. package/src/utils/prop-utils.ts +0 -29
  316. package/src/utils/resource-utils.ts +0 -53
  317. package/src/utils/scale-utils.js +0 -219
  318. /package/dist/{utils → common/utils}/prop-utils.d.ts +0 -0
@@ -0,0 +1,79 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ const THIRD_PI = Math.PI / 3;
6
+ const DIST_X = 2 * Math.sin(THIRD_PI);
7
+ const DIST_Y = 1.5;
8
+
9
+ type HexBin = [i: number, j: number];
10
+ type Point = [x: number, y: number];
11
+
12
+ export const HexbinVertices = Array.from({length: 6}, (_, i) => {
13
+ const angle = i * THIRD_PI;
14
+ return [Math.sin(angle), -Math.cos(angle)];
15
+ });
16
+
17
+ /**
18
+ * Adapted from d3-hexbin
19
+ * Copyright Mike Bostock, 2012-2016
20
+ All rights reserved.
21
+ * https://github.com/d3/d3-hexbin/blob/master/src/hexbin.js
22
+ *
23
+ * Returns the hexbin that a point (x,y) falls into
24
+ */
25
+ export function pointToHexbin([px, py]: Point, radius: number): HexBin {
26
+ let pj = Math.round((py = py / radius / DIST_Y));
27
+ let pi = Math.round((px = px / radius / DIST_X - (pj & 1) / 2));
28
+ const py1 = py - pj;
29
+
30
+ if (Math.abs(py1) * 3 > 1) {
31
+ const px1 = px - pi;
32
+ const pi2 = pi + (px < pi ? -1 : 1) / 2;
33
+ const pj2 = pj + (py < pj ? -1 : 1);
34
+ const px2 = px - pi2;
35
+ const py2 = py - pj2;
36
+ if (px1 * px1 + py1 * py1 > px2 * px2 + py2 * py2) {
37
+ pi = pi2 + (pj & 1 ? 1 : -1) / 2;
38
+ pj = pj2;
39
+ }
40
+ }
41
+ return [pi, pj];
42
+ }
43
+
44
+ export const pointToHexbinGLSL = /* glsl */ `
45
+ const vec2 DIST = vec2(${DIST_X}, ${DIST_Y});
46
+
47
+ ivec2 pointToHexbin(vec2 p, float radius) {
48
+ p /= radius * DIST;
49
+ float pj = round(p.y);
50
+ float pjm2 = mod(pj, 2.0);
51
+ p.x -= pjm2 * 0.5;
52
+ float pi = round(p.x);
53
+ vec2 d1 = p - vec2(pi, pj);
54
+
55
+ if (abs(d1.y) * 3. > 1.) {
56
+ vec2 v2 = step(0.0, d1) - 0.5;
57
+ v2.y *= 2.0;
58
+ vec2 d2 = d1 - v2;
59
+ if (dot(d1, d1) > dot(d2, d2)) {
60
+ pi += v2.x + pjm2 - 0.5;
61
+ pj += v2.y;
62
+ }
63
+ }
64
+ return ivec2(pi, pj);
65
+ }
66
+ `;
67
+
68
+ export function getHexbinCentroid([i, j]: HexBin, radius: number): Point {
69
+ return [(i + (j & 1) / 2) * radius * DIST_X, j * radius * DIST_Y];
70
+ }
71
+
72
+ export const getHexbinCentroidGLSL = `
73
+ const vec2 DIST = vec2(${DIST_X}, ${DIST_Y});
74
+
75
+ vec2 hexbinCentroid(vec2 binId, float radius) {
76
+ binId.x += fract(binId.y * 0.5);
77
+ return binId * DIST * radius;
78
+ }
79
+ `;
package/src/index.ts CHANGED
@@ -1,43 +1,30 @@
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
  export {default as ScreenGridLayer} from './screen-grid-layer/screen-grid-layer';
22
- export {default as CPUGridLayer} from './cpu-grid-layer/cpu-grid-layer';
23
6
  export {default as HexagonLayer} from './hexagon-layer/hexagon-layer';
24
7
  export {default as ContourLayer} from './contour-layer/contour-layer';
25
8
  export {default as GridLayer} from './grid-layer/grid-layer';
26
- export {default as GPUGridLayer} from './gpu-grid-layer/gpu-grid-layer';
27
- export {AGGREGATION_OPERATION} from './utils/aggregation-operation-utils';
28
-
29
- // experimental export
30
9
  export {default as HeatmapLayer} from './heatmap-layer/heatmap-layer';
31
- export {default as _GPUGridAggregator} from './utils/gpu-grid-aggregation/gpu-grid-aggregator';
32
- export {default as _CPUAggregator} from './utils/cpu-aggregator';
33
- export {default as _AggregationLayer} from './aggregation-layer';
34
- export {default as _BinSorter} from './utils/bin-sorter';
10
+
11
+ export {default as _AggregationLayer} from './common/aggregation-layer';
12
+ export {WebGLAggregator, CPUAggregator} from './common/aggregator/index';
35
13
 
36
14
  // types
37
- export type {ContourLayerProps} from './contour-layer/contour-layer';
15
+ export type {ContourLayerProps, ContourLayerPickingInfo} from './contour-layer/contour-layer';
38
16
  export type {HeatmapLayerProps} from './heatmap-layer/heatmap-layer';
39
- export type {HexagonLayerProps} from './hexagon-layer/hexagon-layer';
40
- export type {CPUGridLayerProps} from './cpu-grid-layer/cpu-grid-layer';
41
- export type {GridLayerProps} from './grid-layer/grid-layer';
42
- export type {GPUGridLayerProps} from './gpu-grid-layer/gpu-grid-layer';
43
- export type {ScreenGridLayerProps} from './screen-grid-layer/screen-grid-layer';
17
+ export type {HexagonLayerProps, HexagonLayerPickingInfo} from './hexagon-layer/hexagon-layer';
18
+ export type {GridLayerProps, GridLayerPickingInfo} from './grid-layer/grid-layer';
19
+ export type {
20
+ ScreenGridLayerProps,
21
+ ScreenGridLayerPickingInfo
22
+ } from './screen-grid-layer/screen-grid-layer';
23
+
24
+ export type {
25
+ Aggregator,
26
+ AggregationOperation,
27
+ AggregationProps,
28
+ WebGLAggregatorProps,
29
+ CPUAggregatorProps
30
+ } from './common/aggregator/index';
@@ -0,0 +1,23 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import type {ShaderModule} from '@luma.gl/shadertools';
6
+
7
+ const uniformBlock = /* glsl */ `\
8
+ uniform binOptionsUniforms {
9
+ float cellSizePixels;
10
+ } binOptions;
11
+ `;
12
+
13
+ export type BinOptions = {
14
+ cellSizePixels: number;
15
+ };
16
+
17
+ export const binOptionsUniforms = {
18
+ name: 'binOptions',
19
+ vs: uniformBlock,
20
+ uniformTypes: {
21
+ cellSizePixels: 'f32'
22
+ }
23
+ } as const satisfies ShaderModule<BinOptions>;
@@ -1,142 +1,106 @@
1
- // Copyright (c) 2015 - 2019 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 {Texture} from '@luma.gl/core';
22
6
  import {Model, Geometry} from '@luma.gl/engine';
23
- import {Layer, LayerProps, log, picking, UpdateParameters, DefaultProps} from '@deck.gl/core';
24
- import {defaultColorRange, colorRangeToFlatArray} from '../utils/color-utils';
7
+ import {Layer, picking, UpdateParameters, DefaultProps, Color} from '@deck.gl/core';
8
+ import {createColorRangeTexture, updateColorRangeTexture} from '../common/utils/color-utils';
25
9
  import vs from './screen-grid-layer-vertex.glsl';
26
10
  import fs from './screen-grid-layer-fragment.glsl';
27
- import type {_ScreenGridLayerProps} from './screen-grid-layer';
11
+ import {ScreenGridProps, screenGridUniforms} from './screen-grid-layer-uniforms';
28
12
  import {ShaderModule} from '@luma.gl/shadertools';
29
-
30
- const DEFAULT_MINCOLOR = [0, 0, 0, 0];
31
- const DEFAULT_MAXCOLOR = [0, 255, 0, 255];
32
- const COLOR_PROPS = ['minColor', 'maxColor', 'colorRange', 'colorDomain'];
33
-
34
- const defaultProps: DefaultProps<ScreenGridCellLayerProps> = {
35
- cellSizePixels: {type: 'number', value: 100, min: 1},
36
- cellMarginPixels: {type: 'number', value: 2, min: 0, max: 5},
37
-
38
- colorDomain: null,
39
- colorRange: defaultColorRange
40
- };
41
-
42
- /** All properties supported by ScreenGridCellLayer. */
43
- export type ScreenGridCellLayerProps<DataT = unknown> = _ScreenGridCellLayerProps<DataT> &
44
- LayerProps;
13
+ import type {ScaleType} from '../common/types';
45
14
 
46
15
  /** Proprties added by ScreenGridCellLayer. */
47
- export type _ScreenGridCellLayerProps<DataT> = _ScreenGridLayerProps<DataT> & {
48
- maxTexture: Texture;
16
+ export type _ScreenGridCellLayerProps = {
17
+ cellSizePixels: number;
18
+ cellMarginPixels: number;
19
+ colorScaleType: ScaleType;
20
+ colorDomain: () => [number, number];
21
+ colorRange?: Color[];
49
22
  };
50
23
 
51
- export default class ScreenGridCellLayer<DataT = any, ExtraPropsT extends {} = {}> extends Layer<
52
- ExtraPropsT & Required<_ScreenGridCellLayerProps<DataT>>
24
+ export default class ScreenGridCellLayer<ExtraPropsT extends {} = {}> extends Layer<
25
+ ExtraPropsT & Required<_ScreenGridCellLayerProps>
53
26
  > {
54
27
  static layerName = 'ScreenGridCellLayer';
55
- static defaultProps = defaultProps;
56
28
 
57
29
  state!: {
58
30
  model?: Model;
31
+ colorTexture: Texture;
59
32
  };
60
33
 
61
34
  getShaders(): {vs: string; fs: string; modules: ShaderModule[]} {
62
- return {vs, fs, modules: [picking as ShaderModule]};
35
+ return super.getShaders({vs, fs, modules: [picking, screenGridUniforms]});
63
36
  }
64
37
 
65
38
  initializeState() {
66
- const attributeManager = this.getAttributeManager()!;
67
- attributeManager.addInstanced({
68
- // eslint-disable-next-line @typescript-eslint/unbound-method
69
- instancePositions: {size: 3, update: this.calculateInstancePositions},
70
- instanceCounts: {size: 4, noAlloc: true}
71
- });
72
- this.setState({
73
- model: this._getModel()
39
+ this.getAttributeManager()!.addInstanced({
40
+ instancePositions: {
41
+ size: 2,
42
+ type: 'float32',
43
+ accessor: 'getBin'
44
+ },
45
+ instanceWeights: {
46
+ size: 1,
47
+ type: 'float32',
48
+ accessor: 'getWeight'
49
+ }
74
50
  });
75
- }
76
51
 
77
- shouldUpdateState({changeFlags}) {
78
- // 'instanceCounts' buffer contetns change on viewport change.
79
- return changeFlags.somethingChanged;
52
+ this.state.model = this._getModel();
80
53
  }
81
54
 
82
55
  updateState(params: UpdateParameters<this>) {
83
56
  super.updateState(params);
84
57
 
85
- const {oldProps, props, changeFlags} = params;
58
+ const {props, oldProps, changeFlags} = params;
59
+ const model = this.state.model!;
86
60
 
87
- const attributeManager = this.getAttributeManager()!;
88
- if (props.numInstances !== oldProps.numInstances) {
89
- attributeManager.invalidateAll();
90
- } else if (oldProps.cellSizePixels !== props.cellSizePixels) {
91
- attributeManager.invalidate('instancePositions');
61
+ if (oldProps.colorRange !== props.colorRange) {
62
+ this.state.colorTexture?.destroy();
63
+ this.state.colorTexture = createColorRangeTexture(
64
+ this.context.device,
65
+ props.colorRange,
66
+ props.colorScaleType
67
+ );
68
+ const screenGridProps: Partial<ScreenGridProps> = {colorRange: this.state.colorTexture};
69
+ model.shaderInputs.setProps({screenGrid: screenGridProps});
70
+ } else if (oldProps.colorScaleType !== props.colorScaleType) {
71
+ updateColorRangeTexture(this.state.colorTexture, props.colorScaleType);
92
72
  }
93
73
 
94
- this._updateUniforms(oldProps, props, changeFlags);
74
+ if (
75
+ oldProps.cellMarginPixels !== props.cellMarginPixels ||
76
+ oldProps.cellSizePixels !== props.cellSizePixels ||
77
+ changeFlags.viewportChanged
78
+ ) {
79
+ const {width, height} = this.context.viewport;
80
+ const {cellSizePixels: gridSize, cellMarginPixels} = this.props;
81
+ const cellSize = Math.max(gridSize - cellMarginPixels, 0);
82
+
83
+ const screenGridProps: Partial<ScreenGridProps> = {
84
+ gridSizeClipspace: [(gridSize / width) * 2, (gridSize / height) * 2],
85
+ cellSizeClipspace: [(cellSize / width) * 2, (cellSize / height) * 2]
86
+ };
87
+ model.shaderInputs.setProps({screenGrid: screenGridProps});
88
+ }
95
89
  }
96
90
 
97
- draw({uniforms}) {
98
- const {parameters, maxTexture} = this.props;
99
- const minColor = this.props.minColor || DEFAULT_MINCOLOR;
100
- const maxColor = this.props.maxColor || DEFAULT_MAXCOLOR;
91
+ finalizeState(context) {
92
+ super.finalizeState(context);
101
93
 
102
- // If colorDomain not specified we use default domain [1, maxCount]
103
- // maxCount value will be sampled form maxTexture in vertex shader.
104
- const colorDomain = this.props.colorDomain || [1, 0];
105
- const model = this.state.model!;
106
- model.setUniforms(uniforms);
107
- model.setBindings({
108
- maxTexture
109
- });
110
- model.setUniforms({
111
- // @ts-expect-error stricter luma gl types
112
- minColor,
113
- // @ts-expect-error stricter luma gl types
114
- maxColor,
115
- colorDomain
116
- });
117
- model.setParameters({
118
- depthWriteEnabled: false,
119
- // How to specify depth mask in WebGPU?
120
- // depthMask: false,
121
- ...parameters
122
- });
123
- model.draw(this.context.renderPass);
94
+ this.state.colorTexture?.destroy();
124
95
  }
125
96
 
126
- calculateInstancePositions(attribute, {numInstances}) {
127
- const {width, height} = this.context.viewport;
128
- const {cellSizePixels} = this.props;
129
- const numCol = Math.ceil(width / cellSizePixels);
130
-
131
- const {value, size} = attribute;
97
+ draw({uniforms}) {
98
+ const colorDomain = this.props.colorDomain();
99
+ const model = this.state.model!;
132
100
 
133
- for (let i = 0; i < numInstances; i++) {
134
- const x = i % numCol;
135
- const y = Math.floor(i / numCol);
136
- value[i * size + 0] = ((x * cellSizePixels) / width) * 2 - 1;
137
- value[i * size + 1] = 1 - ((y * cellSizePixels) / height) * 2;
138
- value[i * size + 2] = 0;
139
- }
101
+ const screenGridProps: Partial<ScreenGridProps> = {colorDomain};
102
+ model.shaderInputs.setProps({screenGrid: screenGridProps});
103
+ model.draw(this.context.renderPass);
140
104
  }
141
105
 
142
106
  // Private Methods
@@ -147,64 +111,15 @@ export default class ScreenGridCellLayer<DataT = any, ExtraPropsT extends {} = {
147
111
  id: this.props.id,
148
112
  bufferLayout: this.getAttributeManager()!.getBufferLayouts(),
149
113
  geometry: new Geometry({
150
- topology: 'triangle-list',
114
+ topology: 'triangle-strip',
151
115
  attributes: {
152
- // prettier-ignore
153
- positions: new Float32Array([
154
- 0, 0, 0,
155
- 1, 0, 0,
156
- 1, 1, 0,
157
- 0, 0, 0,
158
- 1, 1, 0,
159
- 0, 1, 0,
160
- ])
116
+ positions: {
117
+ value: new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]),
118
+ size: 2
119
+ }
161
120
  }
162
121
  }),
163
122
  isInstanced: true
164
123
  });
165
124
  }
166
-
167
- _shouldUseMinMax(): boolean {
168
- const {minColor, maxColor, colorDomain, colorRange} = this.props;
169
- if (minColor || maxColor) {
170
- log.deprecated('ScreenGridLayer props: minColor and maxColor', 'colorRange, colorDomain')();
171
- return true;
172
- }
173
- // minColor and maxColor not supplied, check if colorRange or colorDomain supplied.
174
- // NOTE: colorDomain and colorRange are experimental features, use them only when supplied.
175
- if (colorDomain || colorRange) {
176
- return false;
177
- }
178
- // None specified, use default minColor and maxColor
179
- return true;
180
- }
181
-
182
- _updateUniforms(oldProps, props, changeFlags): void {
183
- const model = this.state.model!;
184
- if (COLOR_PROPS.some(key => oldProps[key] !== props[key])) {
185
- model.setUniforms({shouldUseMinMax: this._shouldUseMinMax()});
186
- }
187
-
188
- if (oldProps.colorRange !== props.colorRange) {
189
- model.setUniforms({colorRange: colorRangeToFlatArray(props.colorRange)});
190
- }
191
-
192
- if (
193
- oldProps.cellMarginPixels !== props.cellMarginPixels ||
194
- oldProps.cellSizePixels !== props.cellSizePixels ||
195
- changeFlags.viewportChanged
196
- ) {
197
- const {width, height} = this.context.viewport;
198
- const {cellSizePixels, cellMarginPixels} = this.props;
199
- const margin = cellSizePixels > cellMarginPixels ? cellMarginPixels : 0;
200
-
201
- const cellScale = new Float32Array([
202
- ((cellSizePixels - margin) / width) * 2,
203
- (-(cellSizePixels - margin) / height) * 2,
204
- 1
205
- ]);
206
- // @ts-expect-error stricter luma gl types
207
- model.setUniforms({cellScale});
208
- }
209
- }
210
125
  }
@@ -1,39 +1,19 @@
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
  /* fragment shader for the grid-layer */
22
- export default `\
6
+ export default /* glsl */ `\
23
7
  #version 300 es
24
8
  #define SHADER_NAME screen-grid-layer-fragment-shader
25
9
 
26
10
  precision highp float;
27
11
 
28
12
  in vec4 vColor;
29
- in float vSampleCount;
30
13
 
31
14
  out vec4 fragColor;
32
15
 
33
16
  void main(void) {
34
- if (vSampleCount <= 0.0) {
35
- discard;
36
- }
37
17
  fragColor = vColor;
38
18
 
39
19
  DECKGL_FILTER_COLOR(fragColor, geometry);
@@ -0,0 +1,31 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {Texture} from '@luma.gl/core';
6
+ import type {ShaderModule} from '@luma.gl/shadertools';
7
+
8
+ const uniformBlock = /* glsl */ `\
9
+ uniform screenGridUniforms {
10
+ vec2 cellSizeClipspace;
11
+ vec2 gridSizeClipspace;
12
+ vec2 colorDomain;
13
+ } screenGrid;
14
+ `;
15
+
16
+ export type ScreenGridProps = {
17
+ cellSizeClipspace: [number, number];
18
+ gridSizeClipspace: [number, number];
19
+ colorDomain: [number, number];
20
+ colorRange: Texture;
21
+ };
22
+
23
+ export const screenGridUniforms = {
24
+ name: 'screenGrid',
25
+ vs: uniformBlock,
26
+ uniformTypes: {
27
+ cellSizeClipspace: 'vec2<f32>',
28
+ gridSizeClipspace: 'vec2<f32>',
29
+ colorDomain: 'vec2<f32>'
30
+ }
31
+ } as const satisfies ShaderModule<ScreenGridProps>;
@@ -1,85 +1,42 @@
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
- export default `\
5
+ export default /* glsl */ `\
22
6
  #version 300 es
23
7
  #define SHADER_NAME screen-grid-layer-vertex-shader
24
8
  #define RANGE_COUNT 6
25
9
 
26
- in vec3 positions;
27
- in vec3 instancePositions;
28
- in vec4 instanceCounts;
10
+ in vec2 positions;
11
+ in vec2 instancePositions;
12
+ in float instanceWeights;
29
13
  in vec3 instancePickingColors;
30
14
 
31
- uniform float opacity;
32
- uniform vec3 cellScale;
33
- uniform vec4 minColor;
34
- uniform vec4 maxColor;
35
- uniform vec4 colorRange[RANGE_COUNT];
36
- uniform vec2 colorDomain;
37
- uniform bool shouldUseMinMax;
38
- uniform sampler2D maxTexture;
15
+ uniform sampler2D colorRange;
39
16
 
40
17
  out vec4 vColor;
41
- out float vSampleCount;
42
18
 
43
- vec4 quantizeScale(vec2 domain, vec4 range[RANGE_COUNT], float value) {
44
- vec4 outColor = vec4(0., 0., 0., 0.);
45
- if (value >= domain.x && value <= domain.y) {
46
- float domainRange = domain.y - domain.x;
47
- if (domainRange <= 0.) {
48
- outColor = colorRange[0];
49
- } else {
50
- float rangeCount = float(RANGE_COUNT);
51
- float rangeStep = domainRange / rangeCount;
52
- float idx = floor((value - domain.x) / rangeStep);
53
- idx = clamp(idx, 0., rangeCount - 1.);
54
- int intIdx = int(idx);
55
- outColor = colorRange[intIdx];
56
- }
57
- }
58
- outColor = outColor / 255.;
59
- return outColor;
19
+ vec4 interp(float value, vec2 domain, sampler2D range) {
20
+ float r = (value - domain.x) / (domain.y - domain.x);
21
+ return texture(range, vec2(r, 0.5));
60
22
  }
61
23
 
62
24
  void main(void) {
63
- vSampleCount = instanceCounts.a;
64
-
65
- float weight = instanceCounts.r;
66
- float maxWeight = texture(maxTexture, vec2(0.5)).r;
25
+ if (isnan(instanceWeights)) {
26
+ gl_Position = vec4(0.);
27
+ return;
28
+ }
67
29
 
68
- float step = weight / maxWeight;
69
- vec4 minMaxColor = mix(minColor, maxColor, step) / 255.;
30
+ vec2 pos = instancePositions * screenGrid.gridSizeClipspace + positions * screenGrid.cellSizeClipspace;
31
+ pos.x = pos.x - 1.0;
32
+ pos.y = 1.0 - pos.y;
70
33
 
71
- vec2 domain = colorDomain;
72
- float domainMaxValid = float(colorDomain.y != 0.);
73
- domain.y = mix(maxWeight, colorDomain.y, domainMaxValid);
74
- vec4 rangeColor = quantizeScale(domain, colorRange, weight);
34
+ gl_Position = vec4(pos, 0., 1.);
75
35
 
76
- float rangeMinMax = float(shouldUseMinMax);
77
- vec4 color = mix(rangeColor, minMaxColor, rangeMinMax);
78
- vColor = vec4(color.rgb, color.a * opacity);
36
+ vColor = interp(instanceWeights, screenGrid.colorDomain, colorRange);
37
+ vColor.a *= layer.opacity;
79
38
 
80
39
  // Set color to be rendered to picking fbo (also used to check for selection highlight).
81
40
  picking_setPickingColor(instancePickingColors);
82
-
83
- gl_Position = vec4(instancePositions + positions * cellScale, 1.);
84
41
  }
85
42
  `;