@deck.gl/aggregation-layers 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 (372) 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 +70 -0
  4. package/dist/common/aggregation-layer.js.map +1 -0
  5. package/dist/common/aggregator/aggregator.d.ts +76 -0
  6. package/dist/common/aggregator/aggregator.d.ts.map +1 -0
  7. package/dist/common/aggregator/aggregator.js +5 -0
  8. package/dist/common/aggregator/aggregator.js.map +1 -0
  9. package/dist/common/aggregator/cpu-aggregator/aggregate.d.ts +27 -0
  10. package/dist/common/aggregator/cpu-aggregator/aggregate.d.ts.map +1 -0
  11. package/dist/common/aggregator/cpu-aggregator/aggregate.js +67 -0
  12. package/dist/common/aggregator/cpu-aggregator/aggregate.js.map +1 -0
  13. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.d.ts +70 -0
  14. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.d.ts.map +1 -0
  15. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.js +140 -0
  16. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.js.map +1 -0
  17. package/dist/common/aggregator/cpu-aggregator/sort-bins.d.ts +15 -0
  18. package/dist/common/aggregator/cpu-aggregator/sort-bins.d.ts.map +1 -0
  19. package/dist/common/aggregator/cpu-aggregator/sort-bins.js +44 -0
  20. package/dist/common/aggregator/cpu-aggregator/sort-bins.js.map +1 -0
  21. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.d.ts +21 -0
  22. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.d.ts.map +1 -0
  23. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.js +56 -0
  24. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.js.map +1 -0
  25. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.d.ts +18 -0
  26. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.d.ts.map +1 -0
  27. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.js +21 -0
  28. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.js.map +1 -0
  29. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.d.ts +14 -0
  30. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.d.ts.map +1 -0
  31. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.js +18 -0
  32. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.js.map +1 -0
  33. package/dist/common/aggregator/gpu-aggregator/utils.d.ts +6 -0
  34. package/dist/common/aggregator/gpu-aggregator/utils.d.ts.map +1 -0
  35. package/dist/common/aggregator/gpu-aggregator/utils.js +25 -0
  36. package/dist/common/aggregator/gpu-aggregator/utils.js.map +1 -0
  37. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts +24 -0
  38. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts.map +1 -0
  39. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js +216 -0
  40. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js.map +1 -0
  41. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.d.ts +81 -0
  42. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.d.ts.map +1 -0
  43. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.js +202 -0
  44. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.js.map +1 -0
  45. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.d.ts +38 -0
  46. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.d.ts.map +1 -0
  47. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js +224 -0
  48. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js.map +1 -0
  49. package/dist/common/aggregator/index.d.ts +6 -0
  50. package/dist/common/aggregator/index.d.ts.map +1 -0
  51. package/dist/common/aggregator/index.js +6 -0
  52. package/dist/common/aggregator/index.js.map +1 -0
  53. package/dist/common/types.d.ts +11 -0
  54. package/dist/common/types.d.ts.map +1 -0
  55. package/dist/common/types.js +5 -0
  56. package/dist/common/types.js.map +1 -0
  57. package/dist/common/utils/bounds-utils.d.ts +10 -0
  58. package/dist/common/utils/bounds-utils.d.ts.map +1 -0
  59. package/dist/common/utils/bounds-utils.js +21 -0
  60. package/dist/common/utils/bounds-utils.js.map +1 -0
  61. package/dist/common/utils/color-utils.d.ts +10 -0
  62. package/dist/common/utils/color-utils.d.ts.map +1 -0
  63. package/dist/common/utils/color-utils.js +66 -0
  64. package/dist/common/utils/color-utils.js.map +1 -0
  65. package/dist/common/utils/prop-utils.d.ts.map +1 -0
  66. package/dist/common/utils/prop-utils.js +13 -0
  67. package/dist/common/utils/prop-utils.js.map +1 -0
  68. package/dist/common/utils/scale-utils.d.ts +46 -0
  69. package/dist/common/utils/scale-utils.d.ts.map +1 -0
  70. package/dist/common/utils/scale-utils.js +181 -0
  71. package/dist/common/utils/scale-utils.js.map +1 -0
  72. package/dist/contour-layer/bin-options-uniforms.d.ts +13 -0
  73. package/dist/contour-layer/bin-options-uniforms.d.ts.map +1 -0
  74. package/dist/contour-layer/bin-options-uniforms.js +18 -0
  75. package/dist/contour-layer/bin-options-uniforms.js.map +1 -0
  76. package/dist/contour-layer/contour-layer.d.ts +42 -50
  77. package/dist/contour-layer/contour-layer.d.ts.map +1 -1
  78. package/dist/contour-layer/contour-layer.js +233 -192
  79. package/dist/contour-layer/contour-layer.js.map +1 -0
  80. package/dist/contour-layer/contour-utils.d.ts +36 -15
  81. package/dist/contour-layer/contour-utils.d.ts.map +1 -1
  82. package/dist/contour-layer/contour-utils.js +25 -29
  83. package/dist/contour-layer/contour-utils.js.map +1 -0
  84. package/dist/contour-layer/marching-squares-codes.d.ts.map +1 -1
  85. package/dist/contour-layer/marching-squares-codes.js +4 -0
  86. package/dist/contour-layer/marching-squares-codes.js.map +1 -0
  87. package/dist/contour-layer/marching-squares.d.ts +22 -6
  88. package/dist/contour-layer/marching-squares.d.ts.map +1 -1
  89. package/dist/contour-layer/marching-squares.js +72 -68
  90. package/dist/contour-layer/marching-squares.js.map +1 -0
  91. package/dist/contour-layer/value-reader.d.ts +10 -0
  92. package/dist/contour-layer/value-reader.d.ts.map +1 -0
  93. package/dist/contour-layer/value-reader.js +47 -0
  94. package/dist/contour-layer/value-reader.js.map +1 -0
  95. package/dist/dist.dev.js +4844 -4083
  96. package/dist/grid-layer/bin-options-uniforms.d.ts +13 -0
  97. package/dist/grid-layer/bin-options-uniforms.d.ts.map +1 -0
  98. package/dist/grid-layer/bin-options-uniforms.js +18 -0
  99. package/dist/grid-layer/bin-options-uniforms.js.map +1 -0
  100. package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts +3 -0
  101. package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts.map +1 -0
  102. package/dist/grid-layer/grid-cell-layer-vertex.glsl.js +52 -0
  103. package/dist/grid-layer/grid-cell-layer-vertex.glsl.js.map +1 -0
  104. package/dist/grid-layer/grid-cell-layer.d.ts +32 -0
  105. package/dist/grid-layer/grid-cell-layer.d.ts.map +1 -0
  106. package/dist/grid-layer/grid-cell-layer.js +94 -0
  107. package/dist/grid-layer/grid-cell-layer.js.map +1 -0
  108. package/dist/grid-layer/grid-layer-uniforms.d.ts +21 -0
  109. package/dist/grid-layer/grid-layer-uniforms.d.ts.map +1 -0
  110. package/dist/grid-layer/grid-layer-uniforms.js +24 -0
  111. package/dist/grid-layer/grid-layer-uniforms.js.map +1 -0
  112. package/dist/grid-layer/grid-layer.d.ts +176 -14
  113. package/dist/grid-layer/grid-layer.d.ts.map +1 -1
  114. package/dist/grid-layer/grid-layer.js +343 -46
  115. package/dist/grid-layer/grid-layer.js.map +1 -0
  116. package/dist/{aggregation-layer.d.ts → heatmap-layer/aggregation-layer.d.ts} +1 -0
  117. package/dist/heatmap-layer/aggregation-layer.d.ts.map +1 -0
  118. package/dist/{aggregation-layer.js → heatmap-layer/aggregation-layer.js} +7 -21
  119. package/dist/heatmap-layer/aggregation-layer.js.map +1 -0
  120. package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts +30 -0
  121. package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts.map +1 -0
  122. package/dist/heatmap-layer/heatmap-layer-uniforms.js +33 -0
  123. package/dist/heatmap-layer/heatmap-layer-uniforms.js.map +1 -0
  124. package/dist/heatmap-layer/heatmap-layer-utils.d.ts +1 -1
  125. package/dist/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -1
  126. package/dist/heatmap-layer/heatmap-layer-utils.js +4 -0
  127. package/dist/heatmap-layer/heatmap-layer-utils.js.map +1 -0
  128. package/dist/heatmap-layer/heatmap-layer.d.ts +6 -4
  129. package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -1
  130. package/dist/heatmap-layer/heatmap-layer.js +44 -33
  131. package/dist/heatmap-layer/heatmap-layer.js.map +1 -0
  132. package/dist/heatmap-layer/max-fs.glsl.d.ts.map +1 -1
  133. package/dist/heatmap-layer/max-fs.glsl.js +4 -0
  134. package/dist/heatmap-layer/max-fs.glsl.js.map +1 -0
  135. package/dist/heatmap-layer/max-vs.glsl.d.ts +1 -1
  136. package/dist/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
  137. package/dist/heatmap-layer/max-vs.glsl.js +7 -4
  138. package/dist/heatmap-layer/max-vs.glsl.js.map +1 -0
  139. package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts +1 -1
  140. package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +1 -1
  141. package/dist/heatmap-layer/triangle-layer-fragment.glsl.js +6 -23
  142. package/dist/heatmap-layer/triangle-layer-fragment.glsl.js.map +1 -0
  143. package/dist/heatmap-layer/triangle-layer-uniforms.d.ts +22 -0
  144. package/dist/heatmap-layer/triangle-layer-uniforms.d.ts.map +1 -0
  145. package/dist/heatmap-layer/triangle-layer-uniforms.js +23 -0
  146. package/dist/heatmap-layer/triangle-layer-uniforms.js.map +1 -0
  147. package/dist/heatmap-layer/triangle-layer-vertex.glsl.d.ts +1 -1
  148. package/dist/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +1 -1
  149. package/dist/heatmap-layer/triangle-layer-vertex.glsl.js +11 -30
  150. package/dist/heatmap-layer/triangle-layer-vertex.glsl.js.map +1 -0
  151. package/dist/heatmap-layer/triangle-layer.d.ts +4 -10
  152. package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -1
  153. package/dist/heatmap-layer/triangle-layer.js +18 -30
  154. package/dist/heatmap-layer/triangle-layer.js.map +1 -0
  155. package/dist/heatmap-layer/weights-fs.glsl.d.ts.map +1 -1
  156. package/dist/heatmap-layer/weights-fs.glsl.js +4 -0
  157. package/dist/heatmap-layer/weights-fs.glsl.js.map +1 -0
  158. package/dist/heatmap-layer/weights-vs.glsl.d.ts +1 -1
  159. package/dist/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
  160. package/dist/heatmap-layer/weights-vs.glsl.js +7 -7
  161. package/dist/heatmap-layer/weights-vs.glsl.js.map +1 -0
  162. package/dist/hexagon-layer/bin-options-uniforms.d.ts +14 -0
  163. package/dist/hexagon-layer/bin-options-uniforms.d.ts.map +1 -0
  164. package/dist/hexagon-layer/bin-options-uniforms.js +18 -0
  165. package/dist/hexagon-layer/bin-options-uniforms.js.map +1 -0
  166. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts +3 -0
  167. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts.map +1 -0
  168. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.js +56 -0
  169. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.js.map +1 -0
  170. package/dist/hexagon-layer/hexagon-cell-layer.d.ts +29 -0
  171. package/dist/hexagon-layer/hexagon-cell-layer.d.ts.map +1 -0
  172. package/dist/hexagon-layer/hexagon-cell-layer.js +95 -0
  173. package/dist/hexagon-layer/hexagon-cell-layer.js.map +1 -0
  174. package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts +19 -0
  175. package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts.map +1 -0
  176. package/dist/hexagon-layer/hexagon-layer-uniforms.js +22 -0
  177. package/dist/hexagon-layer/hexagon-layer-uniforms.js.map +1 -0
  178. package/dist/hexagon-layer/hexagon-layer.d.ts +84 -54
  179. package/dist/hexagon-layer/hexagon-layer.d.ts.map +1 -1
  180. package/dist/hexagon-layer/hexagon-layer.js +308 -123
  181. package/dist/hexagon-layer/hexagon-layer.js.map +1 -0
  182. package/dist/hexagon-layer/hexbin.d.ts +17 -0
  183. package/dist/hexagon-layer/hexbin.d.ts.map +1 -0
  184. package/dist/hexagon-layer/hexbin.js +70 -0
  185. package/dist/hexagon-layer/hexbin.js.map +1 -0
  186. package/dist/index.cjs +3026 -2947
  187. package/dist/index.cjs.map +4 -4
  188. package/dist/index.d.ts +7 -13
  189. package/dist/index.d.ts.map +1 -1
  190. package/dist/index.js +6 -27
  191. package/dist/index.js.map +1 -0
  192. package/dist/screen-grid-layer/bin-options-uniforms.d.ts +11 -0
  193. package/dist/screen-grid-layer/bin-options-uniforms.d.ts.map +1 -0
  194. package/dist/screen-grid-layer/bin-options-uniforms.js +16 -0
  195. package/dist/screen-grid-layer/bin-options-uniforms.js.map +1 -0
  196. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts +11 -16
  197. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
  198. package/dist/screen-grid-layer/screen-grid-cell-layer.js +53 -134
  199. package/dist/screen-grid-layer/screen-grid-cell-layer.js.map +1 -0
  200. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +1 -1
  201. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +1 -1
  202. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js +5 -24
  203. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +1 -0
  204. package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts +17 -0
  205. package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts.map +1 -0
  206. package/dist/screen-grid-layer/screen-grid-layer-uniforms.js +20 -0
  207. package/dist/screen-grid-layer/screen-grid-layer-uniforms.js.map +1 -0
  208. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +1 -1
  209. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +1 -1
  210. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js +22 -62
  211. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +1 -0
  212. package/dist/screen-grid-layer/screen-grid-layer.d.ts +33 -40
  213. package/dist/screen-grid-layer/screen-grid-layer.d.ts.map +1 -1
  214. package/dist/screen-grid-layer/screen-grid-layer.js +158 -174
  215. package/dist/screen-grid-layer/screen-grid-layer.js.map +1 -0
  216. package/dist.min.js +401 -382
  217. package/package.json +10 -9
  218. package/src/common/aggregation-layer.ts +107 -0
  219. package/src/common/aggregator/aggregator.ts +88 -0
  220. package/src/common/aggregator/cpu-aggregator/aggregate.ts +101 -0
  221. package/src/common/aggregator/cpu-aggregator/cpu-aggregator.ts +203 -0
  222. package/src/common/aggregator/cpu-aggregator/sort-bins.ts +63 -0
  223. package/src/common/aggregator/cpu-aggregator/vertex-accessor.ts +86 -0
  224. package/src/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.ts +33 -0
  225. package/src/common/aggregator/gpu-aggregator/bin-sorter-uniforms.ts +27 -0
  226. package/src/common/aggregator/gpu-aggregator/utils.ts +27 -0
  227. package/src/common/aggregator/gpu-aggregator/webgl-aggregation-transform.ts +247 -0
  228. package/src/common/aggregator/gpu-aggregator/webgl-aggregator.ts +274 -0
  229. package/src/common/aggregator/gpu-aggregator/webgl-bin-sorter.ts +258 -0
  230. package/src/common/aggregator/index.ts +10 -0
  231. package/src/{types.ts → common/types.ts} +10 -4
  232. package/src/common/utils/bounds-utils.ts +34 -0
  233. package/src/common/utils/color-utils.ts +86 -0
  234. package/src/common/utils/prop-utils.ts +13 -0
  235. package/src/common/utils/scale-utils.ts +236 -0
  236. package/src/contour-layer/bin-options-uniforms.ts +26 -0
  237. package/src/contour-layer/contour-layer.ts +300 -265
  238. package/src/contour-layer/contour-utils.ts +68 -39
  239. package/src/contour-layer/marching-squares-codes.ts +4 -0
  240. package/src/contour-layer/marching-squares.ts +93 -82
  241. package/src/contour-layer/value-reader.ts +65 -0
  242. package/src/grid-layer/bin-options-uniforms.ts +26 -0
  243. package/src/grid-layer/grid-cell-layer-vertex.glsl.ts +68 -0
  244. package/src/grid-layer/grid-cell-layer.ts +141 -0
  245. package/src/grid-layer/grid-layer-uniforms.ts +37 -0
  246. package/src/grid-layer/grid-layer.ts +614 -73
  247. package/src/{aggregation-layer.ts → heatmap-layer/aggregation-layer.ts} +6 -21
  248. package/src/heatmap-layer/heatmap-layer-uniforms.ts +50 -0
  249. package/src/heatmap-layer/heatmap-layer-utils.ts +9 -1
  250. package/src/heatmap-layer/heatmap-layer.ts +59 -36
  251. package/src/heatmap-layer/max-fs.glsl.ts +4 -0
  252. package/src/heatmap-layer/max-vs.glsl.ts +7 -4
  253. package/src/heatmap-layer/triangle-layer-fragment.glsl.ts +5 -23
  254. package/src/heatmap-layer/triangle-layer-uniforms.ts +37 -0
  255. package/src/heatmap-layer/triangle-layer-vertex.glsl.ts +10 -30
  256. package/src/heatmap-layer/triangle-layer.ts +26 -31
  257. package/src/heatmap-layer/weights-fs.glsl.ts +4 -0
  258. package/src/heatmap-layer/weights-vs.glsl.ts +7 -7
  259. package/src/hexagon-layer/bin-options-uniforms.ts +27 -0
  260. package/src/hexagon-layer/hexagon-cell-layer-vertex.glsl.ts +73 -0
  261. package/src/hexagon-layer/hexagon-cell-layer.ts +141 -0
  262. package/src/hexagon-layer/hexagon-layer-uniforms.ts +34 -0
  263. package/src/hexagon-layer/hexagon-layer.ts +454 -186
  264. package/src/hexagon-layer/hexbin.ts +79 -0
  265. package/src/index.ts +21 -34
  266. package/src/screen-grid-layer/bin-options-uniforms.ts +23 -0
  267. package/src/screen-grid-layer/screen-grid-cell-layer.ts +71 -156
  268. package/src/screen-grid-layer/screen-grid-layer-fragment.glsl.ts +4 -24
  269. package/src/screen-grid-layer/screen-grid-layer-uniforms.ts +31 -0
  270. package/src/screen-grid-layer/screen-grid-layer-vertex.glsl.ts +21 -64
  271. package/src/screen-grid-layer/screen-grid-layer.ts +194 -222
  272. package/dist/aggregation-layer.d.ts.map +0 -1
  273. package/dist/cpu-grid-layer/cpu-grid-layer.d.ts +0 -158
  274. package/dist/cpu-grid-layer/cpu-grid-layer.d.ts.map +0 -1
  275. package/dist/cpu-grid-layer/cpu-grid-layer.js +0 -130
  276. package/dist/cpu-grid-layer/grid-aggregator.d.ts +0 -35
  277. package/dist/cpu-grid-layer/grid-aggregator.d.ts.map +0 -1
  278. package/dist/cpu-grid-layer/grid-aggregator.js +0 -141
  279. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +0 -3
  280. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +0 -1
  281. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -30
  282. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +0 -3
  283. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +0 -1
  284. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -112
  285. package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts +0 -48
  286. package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +0 -1
  287. package/dist/gpu-grid-layer/gpu-grid-cell-layer.js +0 -146
  288. package/dist/gpu-grid-layer/gpu-grid-layer.d.ts +0 -99
  289. package/dist/gpu-grid-layer/gpu-grid-layer.d.ts.map +0 -1
  290. package/dist/gpu-grid-layer/gpu-grid-layer.js +0 -289
  291. package/dist/grid-aggregation-layer.d.ts +0 -67
  292. package/dist/grid-aggregation-layer.d.ts.map +0 -1
  293. package/dist/grid-aggregation-layer.js +0 -173
  294. package/dist/hexagon-layer/hexagon-aggregator.d.ts +0 -27
  295. package/dist/hexagon-layer/hexagon-aggregator.d.ts.map +0 -1
  296. package/dist/hexagon-layer/hexagon-aggregator.js +0 -112
  297. package/dist/types.d.ts +0 -12
  298. package/dist/types.d.ts.map +0 -1
  299. package/dist/types.js +0 -1
  300. package/dist/utils/aggregation-operation-utils.d.ts +0 -19
  301. package/dist/utils/aggregation-operation-utils.d.ts.map +0 -1
  302. package/dist/utils/aggregation-operation-utils.js +0 -94
  303. package/dist/utils/bin-sorter.d.ts +0 -52
  304. package/dist/utils/bin-sorter.d.ts.map +0 -1
  305. package/dist/utils/bin-sorter.js +0 -167
  306. package/dist/utils/color-utils.d.ts +0 -3
  307. package/dist/utils/color-utils.d.ts.map +0 -1
  308. package/dist/utils/color-utils.js +0 -53
  309. package/dist/utils/cpu-aggregator.d.ts +0 -169
  310. package/dist/utils/cpu-aggregator.d.ts.map +0 -1
  311. package/dist/utils/cpu-aggregator.js +0 -421
  312. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +0 -3
  313. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +0 -1
  314. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -36
  315. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +0 -3
  316. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +0 -1
  317. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -42
  318. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +0 -3
  319. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +0 -1
  320. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -30
  321. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +0 -3
  322. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +0 -1
  323. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -61
  324. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +0 -38
  325. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +0 -1
  326. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -41
  327. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts +0 -1
  328. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +0 -1
  329. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -1
  330. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +0 -76
  331. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +0 -1
  332. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -555
  333. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +0 -3
  334. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +0 -1
  335. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -32
  336. package/dist/utils/grid-aggregation-utils.d.ts +0 -30
  337. package/dist/utils/grid-aggregation-utils.d.ts.map +0 -1
  338. package/dist/utils/grid-aggregation-utils.js +0 -114
  339. package/dist/utils/prop-utils.d.ts.map +0 -1
  340. package/dist/utils/prop-utils.js +0 -28
  341. package/dist/utils/resource-utils.d.ts +0 -14
  342. package/dist/utils/resource-utils.d.ts.map +0 -1
  343. package/dist/utils/resource-utils.js +0 -38
  344. package/dist/utils/scale-utils.d.ts +0 -15
  345. package/dist/utils/scale-utils.d.ts.map +0 -1
  346. package/dist/utils/scale-utils.js +0 -184
  347. package/src/cpu-grid-layer/cpu-grid-layer.ts +0 -329
  348. package/src/cpu-grid-layer/grid-aggregator.ts +0 -184
  349. package/src/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.ts +0 -35
  350. package/src/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.ts +0 -143
  351. package/src/gpu-grid-layer/gpu-grid-cell-layer.ts +0 -201
  352. package/src/gpu-grid-layer/gpu-grid-layer.ts +0 -455
  353. package/src/grid-aggregation-layer.ts +0 -243
  354. package/src/hexagon-layer/hexagon-aggregator.ts +0 -127
  355. package/src/utils/aggregation-operation-utils.ts +0 -118
  356. package/src/utils/bin-sorter.ts +0 -218
  357. package/src/utils/color-utils.ts +0 -57
  358. package/src/utils/cpu-aggregator.ts +0 -503
  359. package/src/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.ts +0 -40
  360. package/src/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.ts +0 -54
  361. package/src/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.ts +0 -35
  362. package/src/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.ts +0 -79
  363. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.ts +0 -46
  364. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.ts +0 -0
  365. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
  366. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.ts +0 -690
  367. package/src/utils/gpu-grid-aggregation/transform-mean-vs.glsl.ts +0 -38
  368. package/src/utils/grid-aggregation-utils.ts +0 -147
  369. package/src/utils/prop-utils.ts +0 -29
  370. package/src/utils/resource-utils.ts +0 -53
  371. package/src/utils/scale-utils.js +0 -219
  372. /package/dist/{utils → common/utils}/prop-utils.d.ts +0 -0
@@ -0,0 +1,33 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {NumberArray3, NumberArray4} from '@math.gl/core';
6
+ import {ShaderModule} from '@luma.gl/shadertools';
7
+ import {Texture} from '@luma.gl/core';
8
+
9
+ const uniformBlock = /* glsl */ `\
10
+ uniform aggregatorTransformUniforms {
11
+ ivec4 binIdRange;
12
+ bvec3 isCount;
13
+ bvec3 isMean;
14
+ float naN;
15
+ } aggregatorTransform;
16
+ `;
17
+
18
+ export type AggregatorTransformProps = {
19
+ binIdRange: NumberArray4;
20
+ isCount: NumberArray3;
21
+ isMean: NumberArray3;
22
+ bins: Texture;
23
+ };
24
+
25
+ export const aggregatorTransformUniforms = {
26
+ name: 'aggregatorTransform',
27
+ vs: uniformBlock,
28
+ uniformTypes: {
29
+ binIdRange: 'vec4<i32>',
30
+ isCount: 'vec3<f32>',
31
+ isMean: 'vec3<f32>'
32
+ }
33
+ } as const satisfies ShaderModule<AggregatorTransformProps>;
@@ -0,0 +1,27 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {NumberArray2, NumberArray4} from '@math.gl/core';
6
+ import {ShaderModule} from '@luma.gl/shadertools';
7
+
8
+ const uniformBlock = /* glsl */ `\
9
+ uniform binSorterUniforms {
10
+ ivec4 binIdRange;
11
+ ivec2 targetSize;
12
+ } binSorter;
13
+ `;
14
+
15
+ export type BinSorterProps = {
16
+ binIdRange: NumberArray4;
17
+ targetSize: NumberArray2;
18
+ };
19
+
20
+ export const binSorterUniforms = {
21
+ name: 'binSorter',
22
+ vs: uniformBlock,
23
+ uniformTypes: {
24
+ binIdRange: 'vec4<i32>',
25
+ targetSize: 'vec2<i32>'
26
+ }
27
+ } as const satisfies ShaderModule<BinSorterProps>;
@@ -0,0 +1,27 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import type {Device, Framebuffer} from '@luma.gl/core';
6
+
7
+ /**
8
+ * Create a float texture to store aggregation result
9
+ */
10
+ export function createRenderTarget(device: Device, width: number, height: number): Framebuffer {
11
+ return device.createFramebuffer({
12
+ width,
13
+ height,
14
+ colorAttachments: [
15
+ device.createTexture({
16
+ width,
17
+ height,
18
+ format: 'rgba32float',
19
+ mipmaps: false,
20
+ sampler: {
21
+ minFilter: 'nearest',
22
+ magFilter: 'nearest'
23
+ }
24
+ })
25
+ ]
26
+ });
27
+ }
@@ -0,0 +1,247 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {BufferTransform} from '@luma.gl/engine';
6
+ import {createRenderTarget} from './utils';
7
+
8
+ import type {Device, Framebuffer, Buffer, Texture} from '@luma.gl/core';
9
+ import type {WebGLAggregatorProps} from './webgl-aggregator';
10
+ import type {AggregationOperation} from '../aggregator';
11
+
12
+ import {TEXTURE_WIDTH} from './webgl-bin-sorter';
13
+ import {
14
+ AggregatorTransformProps,
15
+ aggregatorTransformUniforms
16
+ } from './aggregation-transform-uniforms';
17
+ import {NumberArray3} from '@math.gl/core';
18
+
19
+ const MAX_FLOAT32 = 3e38;
20
+
21
+ export class WebGLAggregationTransform {
22
+ device: Device;
23
+ channelCount: number;
24
+
25
+ /** Packed from bin ids */
26
+ binBuffer: Buffer | null = null;
27
+ /** Packed values from each channel of each bin
28
+ * Stride is number of channels * 4 bytes (float32)
29
+ */
30
+ valueBuffer: Buffer | null = null;
31
+
32
+ private transform: BufferTransform;
33
+ /** Render target for calculating domain */
34
+ private domainFBO: Framebuffer;
35
+ /** Aggregated [min, max] for each channel */
36
+ private _domains: [min: number, max: number][] | null = null;
37
+
38
+ constructor(device: Device, props: WebGLAggregatorProps) {
39
+ this.device = device;
40
+ this.channelCount = props.channelCount;
41
+ this.transform = createTransform(device, props);
42
+ this.domainFBO = createRenderTarget(device, 2, 1);
43
+ }
44
+
45
+ destroy() {
46
+ this.transform.destroy();
47
+ this.binBuffer?.destroy();
48
+ this.valueBuffer?.destroy();
49
+ this.domainFBO.colorAttachments[0].texture.destroy();
50
+ this.domainFBO.destroy();
51
+ }
52
+
53
+ get domains(): [min: number, max: number][] {
54
+ if (!this._domains) {
55
+ // Domain model has run, but result has not been read to CPU
56
+ const buffer = this.device.readPixelsToArrayWebGL(this.domainFBO).buffer;
57
+ const domain = new Float32Array(buffer);
58
+ this._domains = [
59
+ [-domain[4], domain[0]],
60
+ [-domain[5], domain[1]],
61
+ [-domain[6], domain[2]]
62
+ ].slice(0, this.channelCount) as [number, number][];
63
+ }
64
+ return this._domains;
65
+ }
66
+
67
+ setDimensions(binCount: number, binIdRange: [number, number][]) {
68
+ const {model, transformFeedback} = this.transform;
69
+ model.setVertexCount(binCount);
70
+ const aggregatorTransformProps: Partial<AggregatorTransformProps> = {
71
+ binIdRange: [
72
+ binIdRange[0][0],
73
+ binIdRange[0][1],
74
+ binIdRange[1]?.[0] || 0,
75
+ binIdRange[1]?.[1] || 0
76
+ ]
77
+ };
78
+ model.shaderInputs.setProps({aggregatorTransform: aggregatorTransformProps});
79
+
80
+ // Only destroy existing buffer if it is not large enough
81
+ const binBufferByteLength = binCount * binIdRange.length * 4;
82
+ if (!this.binBuffer || this.binBuffer.byteLength < binBufferByteLength) {
83
+ this.binBuffer?.destroy();
84
+ this.binBuffer = this.device.createBuffer({byteLength: binBufferByteLength});
85
+ transformFeedback.setBuffer('binIds', this.binBuffer);
86
+ }
87
+
88
+ const valueBufferByteLength = binCount * this.channelCount * 4;
89
+ if (!this.valueBuffer || this.valueBuffer.byteLength < valueBufferByteLength) {
90
+ this.valueBuffer?.destroy();
91
+ this.valueBuffer = this.device.createBuffer({byteLength: valueBufferByteLength});
92
+ transformFeedback.setBuffer('values', this.valueBuffer);
93
+ }
94
+ }
95
+
96
+ update(bins: Texture | null, operations: AggregationOperation[]) {
97
+ if (!bins) {
98
+ return;
99
+ }
100
+ const transform = this.transform;
101
+ const target = this.domainFBO;
102
+
103
+ const isCount = [0, 1, 2].map(i => (operations[i] === 'COUNT' ? 1 : 0));
104
+ const isMean = [0, 1, 2].map(i => (operations[i] === 'MEAN' ? 1 : 0));
105
+ const aggregatorTransformProps: Partial<AggregatorTransformProps> = {
106
+ isCount: isCount as NumberArray3,
107
+ isMean: isMean as NumberArray3,
108
+ bins
109
+ };
110
+ transform.model.shaderInputs.setProps({aggregatorTransform: aggregatorTransformProps});
111
+
112
+ transform.run({
113
+ id: 'gpu-aggregation-domain',
114
+ framebuffer: target,
115
+ parameters: {
116
+ viewport: [0, 0, 2, 1]
117
+ },
118
+ clearColor: [-MAX_FLOAT32, -MAX_FLOAT32, -MAX_FLOAT32, 0],
119
+ clearDepth: false,
120
+ clearStencil: false
121
+ });
122
+
123
+ // Clear the last read results. This will be lazy-populated if used.
124
+ this._domains = null;
125
+ }
126
+ }
127
+
128
+ function createTransform(device: Device, props: WebGLAggregatorProps): BufferTransform {
129
+ const vs = /* glsl */ `\
130
+ #version 300 es
131
+ #define SHADER_NAME gpu-aggregation-domain-vertex
132
+
133
+ uniform sampler2D bins;
134
+
135
+ #if NUM_DIMS == 1
136
+ out float binIds;
137
+ #else
138
+ out vec2 binIds;
139
+ #endif
140
+
141
+ #if NUM_CHANNELS == 1
142
+ flat out float values;
143
+ #elif NUM_CHANNELS == 2
144
+ flat out vec2 values;
145
+ #else
146
+ flat out vec3 values;
147
+ #endif
148
+
149
+ const float NAN = intBitsToFloat(-1);
150
+
151
+ void main() {
152
+ int row = gl_VertexID / SAMPLER_WIDTH;
153
+ int col = gl_VertexID - row * SAMPLER_WIDTH;
154
+ vec4 weights = texelFetch(bins, ivec2(col, row), 0);
155
+ vec3 value3 = mix(
156
+ mix(weights.rgb, vec3(weights.a), aggregatorTransform.isCount),
157
+ weights.rgb / max(weights.a, 1.0),
158
+ aggregatorTransform.isMean
159
+ );
160
+ if (weights.a == 0.0) {
161
+ value3 = vec3(NAN);
162
+ }
163
+
164
+ #if NUM_DIMS == 1
165
+ binIds = float(gl_VertexID + aggregatorTransform.binIdRange.x);
166
+ #else
167
+ int y = gl_VertexID / (aggregatorTransform.binIdRange.y - aggregatorTransform.binIdRange.x);
168
+ int x = gl_VertexID - y * (aggregatorTransform.binIdRange.y - aggregatorTransform.binIdRange.x);
169
+ binIds.y = float(y + aggregatorTransform.binIdRange.z);
170
+ binIds.x = float(x + aggregatorTransform.binIdRange.x);
171
+ #endif
172
+
173
+ #if NUM_CHANNELS == 3
174
+ values = value3;
175
+ #elif NUM_CHANNELS == 2
176
+ values = value3.xy;
177
+ #else
178
+ values = value3.x;
179
+ #endif
180
+
181
+ gl_Position = vec4(0., 0., 0., 1.);
182
+ // This model renders into a 2x1 texture to obtain min and max simultaneously.
183
+ // See comments in fragment shader
184
+ gl_PointSize = 2.0;
185
+ }
186
+ `;
187
+
188
+ const fs = /* glsl */ `\
189
+ #version 300 es
190
+ #define SHADER_NAME gpu-aggregation-domain-fragment
191
+
192
+ precision highp float;
193
+
194
+ #if NUM_CHANNELS == 1
195
+ flat in float values;
196
+ #elif NUM_CHANNELS == 2
197
+ flat in vec2 values;
198
+ #else
199
+ flat in vec3 values;
200
+ #endif
201
+
202
+ out vec4 fragColor;
203
+
204
+ void main() {
205
+ vec3 value3;
206
+ #if NUM_CHANNELS == 3
207
+ value3 = values;
208
+ #elif NUM_CHANNELS == 2
209
+ value3.xy = values;
210
+ #else
211
+ value3.x = values;
212
+ #endif
213
+ if (isnan(value3.x)) discard;
214
+ // This shader renders into a 2x1 texture with blending=max
215
+ // The left pixel yields the max value of each channel
216
+ // The right pixel yields the min value of each channel
217
+ if (gl_FragCoord.x < 1.0) {
218
+ fragColor = vec4(value3, 1.0);
219
+ } else {
220
+ fragColor = vec4(-value3, 1.0);
221
+ }
222
+ }
223
+ `;
224
+
225
+ return new BufferTransform(device, {
226
+ vs,
227
+ fs,
228
+ topology: 'point-list',
229
+ modules: [aggregatorTransformUniforms],
230
+ parameters: {
231
+ blend: true,
232
+ blendColorSrcFactor: 'one',
233
+ blendColorDstFactor: 'one',
234
+ blendColorOperation: 'max',
235
+ blendAlphaSrcFactor: 'one',
236
+ blendAlphaDstFactor: 'one',
237
+ blendAlphaOperation: 'max'
238
+ },
239
+ defines: {
240
+ NUM_DIMS: props.dimensions,
241
+ NUM_CHANNELS: props.channelCount,
242
+ SAMPLER_WIDTH: TEXTURE_WIDTH
243
+ },
244
+ varyings: ['binIds', 'values'],
245
+ disableWarnings: true
246
+ });
247
+ }
@@ -0,0 +1,274 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {ModelProps} from '@luma.gl/engine';
6
+ import {WebGLBinSorter} from './webgl-bin-sorter';
7
+ import {WebGLAggregationTransform} from './webgl-aggregation-transform';
8
+ import {_deepEqual as deepEqual, log, BinaryAttribute} from '@deck.gl/core';
9
+
10
+ import type {Aggregator, AggregationProps, AggregatedBin} from '../aggregator';
11
+ import type {Device, Buffer, BufferLayout, TypedArray} from '@luma.gl/core';
12
+ import type {ShaderModule} from '@luma.gl/shadertools';
13
+
14
+ /** Options used to construct a new WebGLAggregator */
15
+ export type WebGLAggregatorProps = {
16
+ /** Size of bin IDs */
17
+ dimensions: 1 | 2;
18
+ /** How many properties to perform aggregation on */
19
+ channelCount: 1 | 2 | 3;
20
+ /** Buffer layout for input attributes */
21
+ bufferLayout?: BufferLayout[];
22
+ /** Define a shader function with one of the signatures
23
+ * `void getBin(out int binId)`: if dimensions=1
24
+ * `void getBin(out ivec2 binId)`: if dimensions=2
25
+ * And a shader function with one of the signatures
26
+ * `void getValue(out float value)`: if channelCount=1
27
+ * `void getValue(out vec2 value)`: if channelCount=2
28
+ * `void getValue(out vec3 value)`: if channelCount=3
29
+ */
30
+ vs: string;
31
+ /** Shader modules
32
+ * Required to support certain layer extensions (e.g. data filter)
33
+ */
34
+ modules?: ShaderModule[];
35
+ /** Shadertool module defines */
36
+ defines?: Record<string, string | number | boolean>;
37
+ } & Partial<WebGLAggregationProps>;
38
+
39
+ /** Props used to run GPU aggregation, can be changed at any time */
40
+ type WebGLAggregationProps = AggregationProps & {
41
+ /** Limits of binId defined for each dimension. Ids outside of the [start, end) are ignored.
42
+ */
43
+ binIdRange: [start: number, end: number][];
44
+ /** Context props passed to the shader modules */
45
+ shaderModuleProps?: Record<string, any>;
46
+ };
47
+
48
+ /** An Aggregator implementation that calculates aggregation on the GPU */
49
+ export class WebGLAggregator implements Aggregator {
50
+ /** Checks if the current device supports GPU aggregation */
51
+ static isSupported(device: Device): boolean {
52
+ return (
53
+ device.features.has('float32-renderable-webgl') &&
54
+ device.features.has('texture-blend-float-webgl')
55
+ );
56
+ }
57
+
58
+ readonly dimensions: 1 | 2;
59
+ readonly channelCount: 1 | 2 | 3;
60
+ binCount: number = 0;
61
+
62
+ readonly device: Device;
63
+ props: WebGLAggregatorProps & WebGLAggregationProps;
64
+
65
+ /** Dirty flag per channel */
66
+ protected needsUpdate: boolean[];
67
+ /** Step 1. sort data points into bins, blended using an aggregation opera†ion */
68
+ protected binSorter: WebGLBinSorter;
69
+ /** Step 2. (optional) calculate the min/max across all bins */
70
+ protected aggregationTransform: WebGLAggregationTransform;
71
+
72
+ /** Cached outputs */
73
+ protected binIds: BinaryAttribute | null = null;
74
+ protected results: BinaryAttribute[] = [];
75
+
76
+ constructor(device: Device, props: WebGLAggregatorProps) {
77
+ this.device = device;
78
+ this.dimensions = props.dimensions;
79
+ this.channelCount = props.channelCount;
80
+ this.props = {
81
+ ...props,
82
+ pointCount: 0,
83
+ binIdRange: [[0, 0]],
84
+ operations: [],
85
+ attributes: {},
86
+ binOptions: {}
87
+ };
88
+ this.needsUpdate = new Array(this.channelCount).fill(true);
89
+ this.binSorter = new WebGLBinSorter(device, props);
90
+ this.aggregationTransform = new WebGLAggregationTransform(device, props);
91
+ this.setProps(props);
92
+ }
93
+
94
+ getBins(): BinaryAttribute | null {
95
+ const buffer = this.aggregationTransform.binBuffer;
96
+ if (!buffer) {
97
+ return null;
98
+ }
99
+ if (this.binIds?.buffer !== buffer) {
100
+ // deck.gl Attribute.setBinaryValue uses shallow comparison to determine if attribute value has changed
101
+ // For performance, only create a new binary attribute descriptor when Buffer changes
102
+ this.binIds = {buffer, type: 'float32', size: this.dimensions};
103
+ }
104
+ return this.binIds;
105
+ }
106
+
107
+ /** Returns an accessor to the output for a given channel. */
108
+ getResult(channel: 0 | 1 | 2): BinaryAttribute | null {
109
+ const buffer = this.aggregationTransform.valueBuffer;
110
+ if (!buffer || channel >= this.channelCount) {
111
+ return null;
112
+ }
113
+ if (this.results[channel]?.buffer !== buffer) {
114
+ this.results[channel] = {
115
+ buffer,
116
+ type: 'float32',
117
+ size: 1,
118
+ stride: this.channelCount * 4,
119
+ offset: channel * 4
120
+ };
121
+ }
122
+ return this.results[channel];
123
+ }
124
+
125
+ /** Returns the [min, max] of aggregated values for a given channel. */
126
+ getResultDomain(channel: 0 | 1 | 2): [min: number, max: number] {
127
+ return this.aggregationTransform.domains[channel];
128
+ }
129
+
130
+ /** Returns the information for a given bin. */
131
+ getBin(index: number): AggregatedBin | null {
132
+ if (index < 0 || index >= this.binCount) {
133
+ return null;
134
+ }
135
+ const {binIdRange} = this.props;
136
+ let id: number[];
137
+
138
+ if (this.dimensions === 1) {
139
+ id = [index + binIdRange[0][0]];
140
+ } else {
141
+ const [[x0, x1], [y0]] = binIdRange;
142
+ const width = x1 - x0;
143
+ id = [(index % width) + x0, Math.floor(index / width) + y0];
144
+ }
145
+
146
+ const pixel = this.binSorter.getBinValues(index);
147
+ if (!pixel) {
148
+ return null;
149
+ }
150
+ const count = pixel[3];
151
+ const value: number[] = [];
152
+ for (let channel = 0; channel < this.channelCount; channel++) {
153
+ const operation = this.props.operations[channel];
154
+ if (operation === 'COUNT') {
155
+ value[channel] = count;
156
+ } else if (count === 0) {
157
+ value[channel] = NaN;
158
+ } else {
159
+ value[channel] = operation === 'MEAN' ? pixel[channel] / count : pixel[channel];
160
+ }
161
+ }
162
+ return {id, value, count};
163
+ }
164
+
165
+ /** Release GPU resources */
166
+ destroy() {
167
+ this.binSorter.destroy();
168
+ this.aggregationTransform.destroy();
169
+ }
170
+
171
+ /** Update aggregation props. Normalize prop values and set change flags. */
172
+ setProps(props: Partial<WebGLAggregationProps>) {
173
+ const oldProps = this.props;
174
+
175
+ // Update local settings. These will set the flag this._needsUpdate
176
+ if ('binIdRange' in props && !deepEqual(props.binIdRange, oldProps.binIdRange, 2)) {
177
+ const binIdRange = props.binIdRange!;
178
+ log.assert(binIdRange.length === this.dimensions);
179
+
180
+ if (this.dimensions === 1) {
181
+ const [[x0, x1]] = binIdRange;
182
+ this.binCount = x1 - x0;
183
+ } else {
184
+ const [[x0, x1], [y0, y1]] = binIdRange;
185
+ this.binCount = (x1 - x0) * (y1 - y0);
186
+ }
187
+
188
+ this.binSorter.setDimensions(this.binCount, binIdRange);
189
+ this.aggregationTransform.setDimensions(this.binCount, binIdRange);
190
+ this.setNeedsUpdate();
191
+ }
192
+ if (props.operations) {
193
+ for (let channel = 0; channel < this.channelCount; channel++) {
194
+ if (props.operations[channel] !== oldProps.operations[channel]) {
195
+ this.setNeedsUpdate(channel);
196
+ }
197
+ }
198
+ }
199
+ if (props.pointCount !== undefined && props.pointCount !== oldProps.pointCount) {
200
+ this.binSorter.setModelProps({vertexCount: props.pointCount});
201
+ this.setNeedsUpdate();
202
+ }
203
+ if (props.binOptions) {
204
+ if (!deepEqual(props.binOptions, oldProps.binOptions, 2)) {
205
+ this.setNeedsUpdate();
206
+ }
207
+ this.binSorter.model.shaderInputs.setProps({binOptions: props.binOptions});
208
+ }
209
+ if (props.attributes) {
210
+ const attributeBuffers: Record<string, Buffer> = {};
211
+ const constantAttributes: Record<string, TypedArray> = {};
212
+
213
+ for (const attribute of Object.values(props.attributes)) {
214
+ for (const [attributeName, value] of Object.entries(attribute.getValue())) {
215
+ if (ArrayBuffer.isView(value)) {
216
+ constantAttributes[attributeName] = value;
217
+ } else if (value) {
218
+ attributeBuffers[attributeName] = value;
219
+ }
220
+ }
221
+ }
222
+ this.binSorter.setModelProps({attributes: attributeBuffers, constantAttributes});
223
+ }
224
+ if (props.shaderModuleProps) {
225
+ this.binSorter.setModelProps({shaderModuleProps: props.shaderModuleProps});
226
+ }
227
+
228
+ Object.assign(this.props, props);
229
+ }
230
+
231
+ /** Flags a channel to need update.
232
+ * This is called internally by setProps() if certain props change
233
+ * Users of this class still need to manually set the dirty flag sometimes, because even if no props changed
234
+ * the underlying buffers could have been updated and require rerunning the aggregation
235
+ * @param {number} channel - mark the given channel as dirty. If not provided, all channels will be updated.
236
+ */
237
+ setNeedsUpdate(channel?: number) {
238
+ if (channel === undefined) {
239
+ this.needsUpdate.fill(true);
240
+ } else {
241
+ this.needsUpdate[channel] = true;
242
+ }
243
+ }
244
+
245
+ update() {}
246
+
247
+ /** Run aggregation */
248
+ preDraw() {
249
+ if (!this.needsUpdate.some(Boolean)) {
250
+ return;
251
+ }
252
+
253
+ const {operations} = this.props;
254
+ const operationsToUpdate = this.needsUpdate.map((needsUpdate, i) =>
255
+ needsUpdate ? operations[i] : null
256
+ );
257
+ // Render data to bins
258
+ this.binSorter.update(operationsToUpdate);
259
+ // Read to buffer and calculate domain
260
+ this.aggregationTransform.update(this.binSorter.texture, operations);
261
+
262
+ for (let i = 0; i < this.channelCount; i++) {
263
+ if (this.needsUpdate[i]) {
264
+ this.needsUpdate[i] = false;
265
+ this.props.onUpdate?.({channel: i});
266
+ }
267
+ }
268
+
269
+ // Uncomment to debug
270
+ // console.log('binsFBO', new Float32Array(this.device.readPixelsToArrayWebGL(this.binSorter.texture!).buffer));
271
+ // console.log('binsBuffer', new Float32Array(this.aggregationTransform.binBuffer?.readSyncWebGL().buffer!));
272
+ // console.log('resultBuffer', new Float32Array(this.aggregationTransform.valueBuffer?.readSyncWebGL().buffer!));
273
+ }
274
+ }