@deck.gl/aggregation-layers 9.0.0-beta.1 → 9.0.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 (336) hide show
  1. package/dist/aggregation-layer.js +153 -0
  2. package/dist/contour-layer/contour-layer.js +241 -0
  3. package/dist/contour-layer/contour-utils.js +64 -0
  4. package/dist/contour-layer/marching-squares-codes.js +337 -0
  5. package/dist/contour-layer/marching-squares.js +147 -0
  6. package/dist/cpu-grid-layer/cpu-grid-layer.js +130 -0
  7. package/dist/cpu-grid-layer/grid-aggregator.js +141 -0
  8. package/dist/dist.dev.js +1187 -10528
  9. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +34 -0
  10. package/dist/{esm/gpu-grid-layer → gpu-grid-layer}/gpu-grid-cell-layer-vertex.glsl.js +20 -1
  11. package/dist/gpu-grid-layer/gpu-grid-cell-layer.js +145 -0
  12. package/dist/gpu-grid-layer/gpu-grid-layer.js +288 -0
  13. package/dist/grid-aggregation-layer.js +172 -0
  14. package/dist/grid-layer/grid-layer.js +63 -0
  15. package/{typed → dist}/heatmap-layer/heatmap-layer-utils.d.ts +0 -9
  16. package/dist/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -0
  17. package/dist/heatmap-layer/heatmap-layer-utils.js +63 -0
  18. package/{typed → dist}/heatmap-layer/heatmap-layer.d.ts +4 -4
  19. package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -0
  20. package/dist/heatmap-layer/heatmap-layer.js +471 -0
  21. package/dist/{esm/heatmap-layer → heatmap-layer}/max-fs.glsl.js +0 -1
  22. package/dist/heatmap-layer/max-vs.glsl.d.ts +3 -0
  23. package/{typed → dist}/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
  24. package/dist/heatmap-layer/max-vs.glsl.js +19 -0
  25. package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts +3 -0
  26. package/dist/heatmap-layer/triangle-layer-fragment.glsl.js +61 -0
  27. package/dist/heatmap-layer/triangle-layer-vertex.glsl.js +52 -0
  28. package/{typed → dist}/heatmap-layer/triangle-layer.d.ts +10 -2
  29. package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -0
  30. package/dist/heatmap-layer/triangle-layer.js +59 -0
  31. package/dist/{esm/heatmap-layer → heatmap-layer}/weights-fs.glsl.js +0 -1
  32. package/dist/heatmap-layer/weights-vs.glsl.d.ts +3 -0
  33. package/{typed → dist}/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
  34. package/dist/{esm/heatmap-layer → heatmap-layer}/weights-vs.glsl.js +4 -3
  35. package/dist/hexagon-layer/hexagon-aggregator.js +112 -0
  36. package/dist/hexagon-layer/hexagon-layer.js +174 -0
  37. package/dist/index.cjs +4494 -0
  38. package/dist/index.cjs.map +7 -0
  39. package/dist/index.js +32 -0
  40. package/dist/screen-grid-layer/screen-grid-cell-layer.js +166 -0
  41. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js +40 -0
  42. package/dist/{esm/screen-grid-layer → screen-grid-layer}/screen-grid-layer-vertex.glsl.js +19 -1
  43. package/dist/screen-grid-layer/screen-grid-layer.js +216 -0
  44. package/dist/types.js +1 -0
  45. package/dist/utils/aggregation-operation-utils.js +94 -0
  46. package/dist/utils/bin-sorter.js +167 -0
  47. package/dist/utils/color-utils.js +53 -0
  48. package/dist/utils/cpu-aggregator.js +421 -0
  49. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +39 -0
  50. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +53 -0
  51. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +34 -0
  52. package/dist/{esm/utils → utils}/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +19 -1
  53. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +41 -0
  54. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +1 -0
  55. package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +1 -1
  56. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +566 -0
  57. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +37 -0
  58. package/dist/utils/grid-aggregation-utils.js +114 -0
  59. package/dist/utils/prop-utils.js +28 -0
  60. package/dist/utils/resource-utils.js +38 -0
  61. package/dist/utils/scale-utils.js +184 -0
  62. package/dist.min.js +74 -178
  63. package/package.json +18 -11
  64. package/src/heatmap-layer/heatmap-layer-utils.ts +0 -23
  65. package/src/heatmap-layer/heatmap-layer.ts +87 -105
  66. package/src/heatmap-layer/max-vs.glsl.ts +11 -5
  67. package/src/heatmap-layer/triangle-layer-fragment.glsl.ts +2 -2
  68. package/src/heatmap-layer/triangle-layer.ts +17 -23
  69. package/src/heatmap-layer/weights-vs.glsl.ts +4 -2
  70. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.ts +10 -13
  71. package/dist/es5/aggregation-layer.js +0 -215
  72. package/dist/es5/aggregation-layer.js.map +0 -1
  73. package/dist/es5/contour-layer/contour-layer.js +0 -353
  74. package/dist/es5/contour-layer/contour-layer.js.map +0 -1
  75. package/dist/es5/contour-layer/contour-utils.js +0 -110
  76. package/dist/es5/contour-layer/contour-utils.js.map +0 -1
  77. package/dist/es5/contour-layer/marching-squares-codes.js +0 -152
  78. package/dist/es5/contour-layer/marching-squares-codes.js.map +0 -1
  79. package/dist/es5/contour-layer/marching-squares.js +0 -168
  80. package/dist/es5/contour-layer/marching-squares.js.map +0 -1
  81. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +0 -235
  82. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +0 -1
  83. package/dist/es5/cpu-grid-layer/grid-aggregator.js +0 -180
  84. package/dist/es5/cpu-grid-layer/grid-aggregator.js.map +0 -1
  85. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -9
  86. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +0 -1
  87. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -9
  88. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +0 -1
  89. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +0 -247
  90. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +0 -1
  91. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +0 -424
  92. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +0 -1
  93. package/dist/es5/grid-aggregation-layer.js +0 -280
  94. package/dist/es5/grid-aggregation-layer.js.map +0 -1
  95. package/dist/es5/grid-layer/grid-layer.js +0 -125
  96. package/dist/es5/grid-layer/grid-layer.js.map +0 -1
  97. package/dist/es5/heatmap-layer/heatmap-layer-utils.js +0 -122
  98. package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +0 -1
  99. package/dist/es5/heatmap-layer/heatmap-layer.js +0 -672
  100. package/dist/es5/heatmap-layer/heatmap-layer.js.map +0 -1
  101. package/dist/es5/heatmap-layer/max-fs.glsl.js +0 -9
  102. package/dist/es5/heatmap-layer/max-fs.glsl.js.map +0 -1
  103. package/dist/es5/heatmap-layer/max-vs.glsl.js +0 -9
  104. package/dist/es5/heatmap-layer/max-vs.glsl.js.map +0 -1
  105. package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js +0 -9
  106. package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js.map +0 -1
  107. package/dist/es5/heatmap-layer/triangle-layer-vertex.glsl.js +0 -9
  108. package/dist/es5/heatmap-layer/triangle-layer-vertex.glsl.js.map +0 -1
  109. package/dist/es5/heatmap-layer/triangle-layer.js +0 -122
  110. package/dist/es5/heatmap-layer/triangle-layer.js.map +0 -1
  111. package/dist/es5/heatmap-layer/weights-fs.glsl.js +0 -9
  112. package/dist/es5/heatmap-layer/weights-fs.glsl.js.map +0 -1
  113. package/dist/es5/heatmap-layer/weights-vs.glsl.js +0 -9
  114. package/dist/es5/heatmap-layer/weights-vs.glsl.js.map +0 -1
  115. package/dist/es5/hexagon-layer/hexagon-aggregator.js +0 -118
  116. package/dist/es5/hexagon-layer/hexagon-aggregator.js.map +0 -1
  117. package/dist/es5/hexagon-layer/hexagon-layer.js +0 -289
  118. package/dist/es5/hexagon-layer/hexagon-layer.js.map +0 -1
  119. package/dist/es5/index.js +0 -104
  120. package/dist/es5/index.js.map +0 -1
  121. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +0 -244
  122. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +0 -1
  123. package/dist/es5/screen-grid-layer/screen-grid-layer-fragment.glsl.js +0 -9
  124. package/dist/es5/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +0 -1
  125. package/dist/es5/screen-grid-layer/screen-grid-layer-vertex.glsl.js +0 -9
  126. package/dist/es5/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +0 -1
  127. package/dist/es5/screen-grid-layer/screen-grid-layer.js +0 -317
  128. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +0 -1
  129. package/dist/es5/types.js +0 -2
  130. package/dist/es5/types.js.map +0 -1
  131. package/dist/es5/utils/aggregation-operation-utils.js +0 -123
  132. package/dist/es5/utils/aggregation-operation-utils.js.map +0 -1
  133. package/dist/es5/utils/bin-sorter.js +0 -248
  134. package/dist/es5/utils/bin-sorter.js.map +0 -1
  135. package/dist/es5/utils/color-utils.js +0 -39
  136. package/dist/es5/utils/color-utils.js.map +0 -1
  137. package/dist/es5/utils/cpu-aggregator.js +0 -496
  138. package/dist/es5/utils/cpu-aggregator.js.map +0 -1
  139. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -9
  140. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +0 -1
  141. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -9
  142. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +0 -1
  143. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -9
  144. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +0 -1
  145. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -9
  146. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +0 -1
  147. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -63
  148. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +0 -1
  149. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -2
  150. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js.map +0 -1
  151. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -732
  152. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +0 -1
  153. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
  154. package/dist/es5/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -9
  155. package/dist/es5/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +0 -1
  156. package/dist/es5/utils/grid-aggregation-utils.js +0 -118
  157. package/dist/es5/utils/grid-aggregation-utils.js.map +0 -1
  158. package/dist/es5/utils/prop-utils.js +0 -19
  159. package/dist/es5/utils/prop-utils.js.map +0 -1
  160. package/dist/es5/utils/resource-utils.js +0 -59
  161. package/dist/es5/utils/resource-utils.js.map +0 -1
  162. package/dist/es5/utils/scale-utils.js +0 -254
  163. package/dist/es5/utils/scale-utils.js.map +0 -1
  164. package/dist/esm/aggregation-layer.js +0 -156
  165. package/dist/esm/aggregation-layer.js.map +0 -1
  166. package/dist/esm/contour-layer/contour-layer.js +0 -316
  167. package/dist/esm/contour-layer/contour-layer.js.map +0 -1
  168. package/dist/esm/contour-layer/contour-utils.js +0 -81
  169. package/dist/esm/contour-layer/contour-utils.js.map +0 -1
  170. package/dist/esm/contour-layer/marching-squares-codes.js +0 -219
  171. package/dist/esm/contour-layer/marching-squares-codes.js.map +0 -1
  172. package/dist/esm/contour-layer/marching-squares.js +0 -151
  173. package/dist/esm/contour-layer/marching-squares.js.map +0 -1
  174. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +0 -186
  175. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +0 -1
  176. package/dist/esm/cpu-grid-layer/grid-aggregator.js +0 -142
  177. package/dist/esm/cpu-grid-layer/grid-aggregator.js.map +0 -1
  178. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -16
  179. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +0 -1
  180. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +0 -1
  181. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js +0 -196
  182. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +0 -1
  183. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +0 -399
  184. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +0 -1
  185. package/dist/esm/grid-aggregation-layer.js +0 -240
  186. package/dist/esm/grid-aggregation-layer.js.map +0 -1
  187. package/dist/esm/grid-layer/grid-layer.js +0 -80
  188. package/dist/esm/grid-layer/grid-layer.js.map +0 -1
  189. package/dist/esm/heatmap-layer/heatmap-layer-utils.js +0 -68
  190. package/dist/esm/heatmap-layer/heatmap-layer-utils.js.map +0 -1
  191. package/dist/esm/heatmap-layer/heatmap-layer.js +0 -626
  192. package/dist/esm/heatmap-layer/heatmap-layer.js.map +0 -1
  193. package/dist/esm/heatmap-layer/max-fs.glsl.js.map +0 -1
  194. package/dist/esm/heatmap-layer/max-vs.glsl.js +0 -14
  195. package/dist/esm/heatmap-layer/max-vs.glsl.js.map +0 -1
  196. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js +0 -43
  197. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js.map +0 -1
  198. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js +0 -33
  199. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js.map +0 -1
  200. package/dist/esm/heatmap-layer/triangle-layer.js +0 -80
  201. package/dist/esm/heatmap-layer/triangle-layer.js.map +0 -1
  202. package/dist/esm/heatmap-layer/weights-fs.glsl.js.map +0 -1
  203. package/dist/esm/heatmap-layer/weights-vs.glsl.js.map +0 -1
  204. package/dist/esm/hexagon-layer/hexagon-aggregator.js +0 -87
  205. package/dist/esm/hexagon-layer/hexagon-aggregator.js.map +0 -1
  206. package/dist/esm/hexagon-layer/hexagon-layer.js +0 -232
  207. package/dist/esm/hexagon-layer/hexagon-layer.js.map +0 -1
  208. package/dist/esm/index.js +0 -13
  209. package/dist/esm/index.js.map +0 -1
  210. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +0 -203
  211. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +0 -1
  212. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js +0 -21
  213. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +0 -1
  214. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +0 -1
  215. package/dist/esm/screen-grid-layer/screen-grid-layer.js +0 -285
  216. package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +0 -1
  217. package/dist/esm/types.js +0 -2
  218. package/dist/esm/types.js.map +0 -1
  219. package/dist/esm/utils/aggregation-operation-utils.js +0 -91
  220. package/dist/esm/utils/aggregation-operation-utils.js.map +0 -1
  221. package/dist/esm/utils/bin-sorter.js +0 -165
  222. package/dist/esm/utils/bin-sorter.js.map +0 -1
  223. package/dist/esm/utils/color-utils.js +0 -28
  224. package/dist/esm/utils/color-utils.js.map +0 -1
  225. package/dist/esm/utils/cpu-aggregator.js +0 -487
  226. package/dist/esm/utils/cpu-aggregator.js.map +0 -1
  227. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -21
  228. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +0 -1
  229. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -35
  230. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +0 -1
  231. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -16
  232. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +0 -1
  233. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +0 -1
  234. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -42
  235. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +0 -1
  236. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -2
  237. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js.map +0 -1
  238. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -720
  239. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +0 -1
  240. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
  241. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -19
  242. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +0 -1
  243. package/dist/esm/utils/grid-aggregation-utils.js +0 -109
  244. package/dist/esm/utils/grid-aggregation-utils.js.map +0 -1
  245. package/dist/esm/utils/prop-utils.js +0 -12
  246. package/dist/esm/utils/prop-utils.js.map +0 -1
  247. package/dist/esm/utils/resource-utils.js +0 -44
  248. package/dist/esm/utils/resource-utils.js.map +0 -1
  249. package/dist/esm/utils/scale-utils.js +0 -192
  250. package/dist/esm/utils/scale-utils.js.map +0 -1
  251. package/typed/heatmap-layer/heatmap-layer-utils.d.ts.map +0 -1
  252. package/typed/heatmap-layer/heatmap-layer.d.ts.map +0 -1
  253. package/typed/heatmap-layer/max-vs.glsl.d.ts +0 -3
  254. package/typed/heatmap-layer/triangle-layer-fragment.glsl.d.ts +0 -3
  255. package/typed/heatmap-layer/triangle-layer.d.ts.map +0 -1
  256. package/typed/heatmap-layer/weights-vs.glsl.d.ts +0 -3
  257. /package/{typed → dist}/aggregation-layer.d.ts +0 -0
  258. /package/{typed → dist}/aggregation-layer.d.ts.map +0 -0
  259. /package/{typed → dist}/contour-layer/contour-layer.d.ts +0 -0
  260. /package/{typed → dist}/contour-layer/contour-layer.d.ts.map +0 -0
  261. /package/{typed → dist}/contour-layer/contour-utils.d.ts +0 -0
  262. /package/{typed → dist}/contour-layer/contour-utils.d.ts.map +0 -0
  263. /package/{typed → dist}/contour-layer/marching-squares-codes.d.ts +0 -0
  264. /package/{typed → dist}/contour-layer/marching-squares-codes.d.ts.map +0 -0
  265. /package/{typed → dist}/contour-layer/marching-squares.d.ts +0 -0
  266. /package/{typed → dist}/contour-layer/marching-squares.d.ts.map +0 -0
  267. /package/{typed → dist}/cpu-grid-layer/cpu-grid-layer.d.ts +0 -0
  268. /package/{typed → dist}/cpu-grid-layer/cpu-grid-layer.d.ts.map +0 -0
  269. /package/{typed → dist}/cpu-grid-layer/grid-aggregator.d.ts +0 -0
  270. /package/{typed → dist}/cpu-grid-layer/grid-aggregator.d.ts.map +0 -0
  271. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +0 -0
  272. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +0 -0
  273. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +0 -0
  274. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +0 -0
  275. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer.d.ts +0 -0
  276. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +0 -0
  277. /package/{typed → dist}/gpu-grid-layer/gpu-grid-layer.d.ts +0 -0
  278. /package/{typed → dist}/gpu-grid-layer/gpu-grid-layer.d.ts.map +0 -0
  279. /package/{typed → dist}/grid-aggregation-layer.d.ts +0 -0
  280. /package/{typed → dist}/grid-aggregation-layer.d.ts.map +0 -0
  281. /package/{typed → dist}/grid-layer/grid-layer.d.ts +0 -0
  282. /package/{typed → dist}/grid-layer/grid-layer.d.ts.map +0 -0
  283. /package/{typed → dist}/heatmap-layer/max-fs.glsl.d.ts +0 -0
  284. /package/{typed → dist}/heatmap-layer/max-fs.glsl.d.ts.map +0 -0
  285. /package/{typed → dist}/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +0 -0
  286. /package/{typed → dist}/heatmap-layer/triangle-layer-vertex.glsl.d.ts +0 -0
  287. /package/{typed → dist}/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +0 -0
  288. /package/{typed → dist}/heatmap-layer/weights-fs.glsl.d.ts +0 -0
  289. /package/{typed → dist}/heatmap-layer/weights-fs.glsl.d.ts.map +0 -0
  290. /package/{typed → dist}/hexagon-layer/hexagon-aggregator.d.ts +0 -0
  291. /package/{typed → dist}/hexagon-layer/hexagon-aggregator.d.ts.map +0 -0
  292. /package/{typed → dist}/hexagon-layer/hexagon-layer.d.ts +0 -0
  293. /package/{typed → dist}/hexagon-layer/hexagon-layer.d.ts.map +0 -0
  294. /package/{typed → dist}/index.d.ts +0 -0
  295. /package/{typed → dist}/index.d.ts.map +0 -0
  296. /package/{typed → dist}/screen-grid-layer/screen-grid-cell-layer.d.ts +0 -0
  297. /package/{typed → dist}/screen-grid-layer/screen-grid-cell-layer.d.ts.map +0 -0
  298. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +0 -0
  299. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +0 -0
  300. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +0 -0
  301. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +0 -0
  302. /package/{typed → dist}/screen-grid-layer/screen-grid-layer.d.ts +0 -0
  303. /package/{typed → dist}/screen-grid-layer/screen-grid-layer.d.ts.map +0 -0
  304. /package/{typed → dist}/types.d.ts +0 -0
  305. /package/{typed → dist}/types.d.ts.map +0 -0
  306. /package/{typed → dist}/utils/aggregation-operation-utils.d.ts +0 -0
  307. /package/{typed → dist}/utils/aggregation-operation-utils.d.ts.map +0 -0
  308. /package/{typed → dist}/utils/bin-sorter.d.ts +0 -0
  309. /package/{typed → dist}/utils/bin-sorter.d.ts.map +0 -0
  310. /package/{typed → dist}/utils/color-utils.d.ts +0 -0
  311. /package/{typed → dist}/utils/color-utils.d.ts.map +0 -0
  312. /package/{typed → dist}/utils/cpu-aggregator.d.ts +0 -0
  313. /package/{typed → dist}/utils/cpu-aggregator.d.ts.map +0 -0
  314. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +0 -0
  315. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +0 -0
  316. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +0 -0
  317. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +0 -0
  318. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +0 -0
  319. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +0 -0
  320. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +0 -0
  321. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +0 -0
  322. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +0 -0
  323. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +0 -0
  324. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts +0 -0
  325. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +0 -0
  326. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +0 -0
  327. /package/{typed → dist}/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +0 -0
  328. /package/{typed → dist}/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +0 -0
  329. /package/{typed → dist}/utils/grid-aggregation-utils.d.ts +0 -0
  330. /package/{typed → dist}/utils/grid-aggregation-utils.d.ts.map +0 -0
  331. /package/{typed → dist}/utils/prop-utils.d.ts +0 -0
  332. /package/{typed → dist}/utils/prop-utils.d.ts.map +0 -0
  333. /package/{typed → dist}/utils/resource-utils.d.ts +0 -0
  334. /package/{typed → dist}/utils/resource-utils.d.ts.map +0 -0
  335. /package/{typed → dist}/utils/scale-utils.d.ts +0 -0
  336. /package/{typed → dist}/utils/scale-utils.d.ts.map +0 -0
package/dist/index.js ADDED
@@ -0,0 +1,32 @@
1
+ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ // THE SOFTWARE.
20
+ export { default as ScreenGridLayer } from "./screen-grid-layer/screen-grid-layer.js";
21
+ export { default as CPUGridLayer } from "./cpu-grid-layer/cpu-grid-layer.js";
22
+ export { default as HexagonLayer } from "./hexagon-layer/hexagon-layer.js";
23
+ export { default as ContourLayer } from "./contour-layer/contour-layer.js";
24
+ export { default as GridLayer } from "./grid-layer/grid-layer.js";
25
+ export { default as GPUGridLayer } from "./gpu-grid-layer/gpu-grid-layer.js";
26
+ export { AGGREGATION_OPERATION } from "./utils/aggregation-operation-utils.js";
27
+ // experimental export
28
+ export { default as HeatmapLayer } from "./heatmap-layer/heatmap-layer.js";
29
+ export { default as _GPUGridAggregator } from "./utils/gpu-grid-aggregation/gpu-grid-aggregator.js";
30
+ export { default as _CPUAggregator } from "./utils/cpu-aggregator.js";
31
+ export { default as _AggregationLayer } from "./aggregation-layer.js";
32
+ export { default as _BinSorter } from "./utils/bin-sorter.js";
@@ -0,0 +1,166 @@
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.
20
+ import { Model, Geometry } from '@luma.gl/engine';
21
+ import { Layer, log, picking } from '@deck.gl/core';
22
+ import { defaultColorRange, colorRangeToFlatArray } from "../utils/color-utils.js";
23
+ import vs from "./screen-grid-layer-vertex.glsl.js";
24
+ import fs from "./screen-grid-layer-fragment.glsl.js";
25
+ const DEFAULT_MINCOLOR = [0, 0, 0, 0];
26
+ const DEFAULT_MAXCOLOR = [0, 255, 0, 255];
27
+ const COLOR_PROPS = ['minColor', 'maxColor', 'colorRange', 'colorDomain'];
28
+ const defaultProps = {
29
+ cellSizePixels: { type: 'number', value: 100, min: 1 },
30
+ cellMarginPixels: { type: 'number', value: 2, min: 0, max: 5 },
31
+ colorDomain: null,
32
+ colorRange: defaultColorRange
33
+ };
34
+ export default class ScreenGridCellLayer extends Layer {
35
+ static { this.layerName = 'ScreenGridCellLayer'; }
36
+ static { this.defaultProps = defaultProps; }
37
+ static isSupported(device) {
38
+ return device.features.has('texture-formats-float32-webgl1');
39
+ }
40
+ getShaders() {
41
+ return { vs, fs, modules: [picking] };
42
+ }
43
+ initializeState() {
44
+ const attributeManager = this.getAttributeManager();
45
+ attributeManager.addInstanced({
46
+ // eslint-disable-next-line @typescript-eslint/unbound-method
47
+ instancePositions: { size: 3, update: this.calculateInstancePositions },
48
+ instanceCounts: { size: 4, noAlloc: true }
49
+ });
50
+ this.setState({
51
+ model: this._getModel()
52
+ });
53
+ }
54
+ shouldUpdateState({ changeFlags }) {
55
+ // 'instanceCounts' buffer contetns change on viewport change.
56
+ return changeFlags.somethingChanged;
57
+ }
58
+ updateState(params) {
59
+ super.updateState(params);
60
+ const { oldProps, props, changeFlags } = params;
61
+ const attributeManager = this.getAttributeManager();
62
+ if (props.numInstances !== oldProps.numInstances) {
63
+ attributeManager.invalidateAll();
64
+ }
65
+ else if (oldProps.cellSizePixels !== props.cellSizePixels) {
66
+ attributeManager.invalidate('instancePositions');
67
+ }
68
+ this._updateUniforms(oldProps, props, changeFlags);
69
+ }
70
+ draw({ uniforms }) {
71
+ const { parameters, maxTexture } = this.props;
72
+ const minColor = this.props.minColor || DEFAULT_MINCOLOR;
73
+ const maxColor = this.props.maxColor || DEFAULT_MAXCOLOR;
74
+ // If colorDomain not specified we use default domain [1, maxCount]
75
+ // maxCount value will be sampled form maxTexture in vertex shader.
76
+ const colorDomain = this.props.colorDomain || [1, 0];
77
+ const model = this.state.model;
78
+ model.setUniforms(uniforms);
79
+ model.setBindings({
80
+ maxTexture
81
+ });
82
+ model.setUniforms({
83
+ minColor,
84
+ maxColor,
85
+ colorDomain
86
+ });
87
+ model.setParameters({
88
+ depthWriteEnabled: false,
89
+ // How to specify depth mask in WebGPU?
90
+ // depthMask: false,
91
+ ...parameters
92
+ });
93
+ model.draw(this.context.renderPass);
94
+ }
95
+ calculateInstancePositions(attribute, { numInstances }) {
96
+ const { width, height } = this.context.viewport;
97
+ const { cellSizePixels } = this.props;
98
+ const numCol = Math.ceil(width / cellSizePixels);
99
+ const { value, size } = attribute;
100
+ for (let i = 0; i < numInstances; i++) {
101
+ const x = i % numCol;
102
+ const y = Math.floor(i / numCol);
103
+ value[i * size + 0] = ((x * cellSizePixels) / width) * 2 - 1;
104
+ value[i * size + 1] = 1 - ((y * cellSizePixels) / height) * 2;
105
+ value[i * size + 2] = 0;
106
+ }
107
+ }
108
+ // Private Methods
109
+ _getModel() {
110
+ return new Model(this.context.device, {
111
+ ...this.getShaders(),
112
+ id: this.props.id,
113
+ bufferLayout: this.getAttributeManager().getBufferLayouts(),
114
+ geometry: new Geometry({
115
+ topology: 'triangle-list',
116
+ attributes: {
117
+ // prettier-ignore
118
+ positions: new Float32Array([
119
+ 0, 0, 0,
120
+ 1, 0, 0,
121
+ 1, 1, 0,
122
+ 0, 0, 0,
123
+ 1, 1, 0,
124
+ 0, 1, 0,
125
+ ])
126
+ }
127
+ })
128
+ });
129
+ }
130
+ _shouldUseMinMax() {
131
+ const { minColor, maxColor, colorDomain, colorRange } = this.props;
132
+ if (minColor || maxColor) {
133
+ log.deprecated('ScreenGridLayer props: minColor and maxColor', 'colorRange, colorDomain')();
134
+ return true;
135
+ }
136
+ // minColor and maxColor not supplied, check if colorRange or colorDomain supplied.
137
+ // NOTE: colorDomain and colorRange are experimental features, use them only when supplied.
138
+ if (colorDomain || colorRange) {
139
+ return false;
140
+ }
141
+ // None specified, use default minColor and maxColor
142
+ return true;
143
+ }
144
+ _updateUniforms(oldProps, props, changeFlags) {
145
+ const model = this.state.model;
146
+ if (COLOR_PROPS.some(key => oldProps[key] !== props[key])) {
147
+ model.setUniforms({ shouldUseMinMax: this._shouldUseMinMax() });
148
+ }
149
+ if (oldProps.colorRange !== props.colorRange) {
150
+ model.setUniforms({ colorRange: colorRangeToFlatArray(props.colorRange) });
151
+ }
152
+ if (oldProps.cellMarginPixels !== props.cellMarginPixels ||
153
+ oldProps.cellSizePixels !== props.cellSizePixels ||
154
+ changeFlags.viewportChanged) {
155
+ const { width, height } = this.context.viewport;
156
+ const { cellSizePixels, cellMarginPixels } = this.props;
157
+ const margin = cellSizePixels > cellMarginPixels ? cellMarginPixels : 0;
158
+ const cellScale = new Float32Array([
159
+ ((cellSizePixels - margin) / width) * 2,
160
+ (-(cellSizePixels - margin) / height) * 2,
161
+ 1
162
+ ]);
163
+ model.setUniforms({ cellScale });
164
+ }
165
+ }
166
+ }
@@ -0,0 +1,40 @@
1
+ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ // THE SOFTWARE.
20
+ /* fragment shader for the grid-layer */
21
+ export default `\
22
+ #version 300 es
23
+ #define SHADER_NAME screen-grid-layer-fragment-shader
24
+
25
+ precision highp float;
26
+
27
+ in vec4 vColor;
28
+ in float vSampleCount;
29
+
30
+ out vec4 fragColor;
31
+
32
+ void main(void) {
33
+ if (vSampleCount <= 0.0) {
34
+ discard;
35
+ }
36
+ fragColor = vColor;
37
+
38
+ DECKGL_FILTER_COLOR(fragColor, geometry);
39
+ }
40
+ `;
@@ -1,3 +1,22 @@
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
20
  export default `\
2
21
  #version 300 es
3
22
  #define SHADER_NAME screen-grid-layer-vertex-shader
@@ -63,4 +82,3 @@ void main(void) {
63
82
  gl_Position = vec4(instancePositions + positions * cellScale, 1.);
64
83
  }
65
84
  `;
66
- //# sourceMappingURL=screen-grid-layer-vertex.glsl.js.map
@@ -0,0 +1,216 @@
1
+ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ // THE SOFTWARE.
20
+ import { log } from '@deck.gl/core';
21
+ import { GL } from '@luma.gl/constants';
22
+ import GPUGridAggregator from "../utils/gpu-grid-aggregation/gpu-grid-aggregator.js";
23
+ import { AGGREGATION_OPERATION, getValueFunc } from "../utils/aggregation-operation-utils.js";
24
+ import ScreenGridCellLayer from "./screen-grid-cell-layer.js";
25
+ import GridAggregationLayer from "../grid-aggregation-layer.js";
26
+ import { getFloatTexture } from "../utils/resource-utils.js";
27
+ const defaultProps = {
28
+ ...ScreenGridCellLayer.defaultProps,
29
+ getPosition: { type: 'accessor', value: (d) => d.position },
30
+ getWeight: { type: 'accessor', value: 1 },
31
+ gpuAggregation: false, // TODO(v9): Re-enable GPU aggregation.
32
+ aggregation: 'SUM'
33
+ };
34
+ const POSITION_ATTRIBUTE_NAME = 'positions';
35
+ const DIMENSIONS = {
36
+ data: {
37
+ props: ['cellSizePixels']
38
+ },
39
+ weights: {
40
+ props: ['aggregation'],
41
+ accessors: ['getWeight']
42
+ }
43
+ };
44
+ /** Aggregates data into histogram bins and renders them as a grid. */
45
+ export default class ScreenGridLayer extends GridAggregationLayer {
46
+ static { this.layerName = 'ScreenGridLayer'; }
47
+ static { this.defaultProps = defaultProps; }
48
+ initializeState() {
49
+ if (!ScreenGridCellLayer.isSupported(this.context.device)) {
50
+ // max aggregated value is sampled from a float texture
51
+ this.setState({ supported: false });
52
+ log.error(`ScreenGridLayer: ${this.id} is not supported on this browser`)();
53
+ return;
54
+ }
55
+ super.initializeAggregationLayer({
56
+ dimensions: DIMENSIONS,
57
+ // @ts-expect-error
58
+ getCellSize: props => props.cellSizePixels // TODO
59
+ });
60
+ const weights = {
61
+ count: {
62
+ size: 1,
63
+ operation: AGGREGATION_OPERATION.SUM,
64
+ needMax: true,
65
+ maxTexture: getFloatTexture(this.context.device, { id: `${this.id}-max-texture` })
66
+ }
67
+ };
68
+ this.setState({
69
+ supported: true,
70
+ projectPoints: true, // aggregation in screen space
71
+ weights,
72
+ subLayerData: { attributes: {} },
73
+ maxTexture: weights.count.maxTexture,
74
+ positionAttributeName: 'positions',
75
+ posOffset: [0, 0],
76
+ translation: [1, -1]
77
+ });
78
+ const attributeManager = this.getAttributeManager();
79
+ attributeManager.add({
80
+ [POSITION_ATTRIBUTE_NAME]: {
81
+ size: 3,
82
+ accessor: 'getPosition',
83
+ type: GL.DOUBLE,
84
+ fp64: this.use64bitPositions()
85
+ },
86
+ // this attribute is used in gpu aggregation path only
87
+ count: { size: 3, accessor: 'getWeight' }
88
+ });
89
+ }
90
+ shouldUpdateState({ changeFlags }) {
91
+ return this.state.supported && changeFlags.somethingChanged;
92
+ }
93
+ updateState(opts) {
94
+ super.updateState(opts);
95
+ }
96
+ renderLayers() {
97
+ if (!this.state.supported) {
98
+ return [];
99
+ }
100
+ const { maxTexture, numRow, numCol, weights } = this.state;
101
+ const { updateTriggers } = this.props;
102
+ const { aggregationBuffer } = weights.count;
103
+ const CellLayerClass = this.getSubLayerClass('cells', ScreenGridCellLayer);
104
+ return new CellLayerClass(this.props, this.getSubLayerProps({
105
+ id: 'cell-layer',
106
+ updateTriggers
107
+ }), {
108
+ data: { attributes: { instanceCounts: aggregationBuffer } },
109
+ maxTexture,
110
+ numInstances: numRow * numCol
111
+ });
112
+ }
113
+ finalizeState(context) {
114
+ super.finalizeState(context);
115
+ const { aggregationBuffer, maxBuffer, maxTexture } = this.state;
116
+ aggregationBuffer?.delete();
117
+ maxBuffer?.delete();
118
+ maxTexture?.delete();
119
+ }
120
+ getPickingInfo({ info }) {
121
+ const { index } = info;
122
+ if (index >= 0) {
123
+ const { gpuGridAggregator, gpuAggregation, weights } = this.state;
124
+ // Get count aggregation results
125
+ const aggregationResults = gpuAggregation
126
+ ? gpuGridAggregator.getData('count')
127
+ : weights.count;
128
+ // Each instance (one cell) is aggregated into single pixel,
129
+ // Get current instance's aggregation details.
130
+ info.object = GPUGridAggregator.getAggregationData({
131
+ pixelIndex: index,
132
+ ...aggregationResults
133
+ });
134
+ }
135
+ return info;
136
+ }
137
+ // Aggregation Overrides
138
+ updateResults({ aggregationData, maxData }) {
139
+ const { count } = this.state.weights;
140
+ count.aggregationData = aggregationData;
141
+ count.aggregationBuffer.write(aggregationData);
142
+ count.maxData = maxData;
143
+ count.maxTexture.setImageData({ data: maxData });
144
+ }
145
+ /* eslint-disable complexity, max-statements */
146
+ updateAggregationState(opts) {
147
+ const cellSize = opts.props.cellSizePixels;
148
+ const cellSizeChanged = opts.oldProps.cellSizePixels !== cellSize;
149
+ const { viewportChanged } = opts.changeFlags;
150
+ let gpuAggregation = opts.props.gpuAggregation;
151
+ if (this.state.gpuAggregation !== opts.props.gpuAggregation) {
152
+ if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.device)) {
153
+ log.warn('GPU Grid Aggregation not supported, falling back to CPU')();
154
+ gpuAggregation = false;
155
+ }
156
+ }
157
+ const gpuAggregationChanged = gpuAggregation !== this.state.gpuAggregation;
158
+ this.setState({
159
+ gpuAggregation
160
+ });
161
+ const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);
162
+ const { dimensions } = this.state;
163
+ const { data, weights } = dimensions;
164
+ const aggregationDataDirty = positionsChanged ||
165
+ gpuAggregationChanged ||
166
+ viewportChanged ||
167
+ this.isAggregationDirty(opts, {
168
+ compareAll: gpuAggregation, // check for all (including extentions props) when using gpu aggregation
169
+ dimension: data
170
+ });
171
+ const aggregationWeightsDirty = this.isAggregationDirty(opts, { dimension: weights });
172
+ this.setState({
173
+ aggregationDataDirty,
174
+ aggregationWeightsDirty
175
+ });
176
+ const { viewport } = this.context;
177
+ if (viewportChanged || cellSizeChanged) {
178
+ const { width, height } = viewport;
179
+ const numCol = Math.ceil(width / cellSize);
180
+ const numRow = Math.ceil(height / cellSize);
181
+ this.allocateResources(numRow, numCol);
182
+ this.setState({
183
+ // transformation from clipspace to screen(pixel) space
184
+ scaling: [width / 2, -height / 2, 1],
185
+ gridOffset: { xOffset: cellSize, yOffset: cellSize },
186
+ width,
187
+ height,
188
+ numCol,
189
+ numRow
190
+ });
191
+ }
192
+ if (aggregationWeightsDirty) {
193
+ this._updateAccessors(opts);
194
+ }
195
+ if (aggregationDataDirty || aggregationWeightsDirty) {
196
+ this._resetResults();
197
+ }
198
+ }
199
+ /* eslint-enable complexity, max-statements */
200
+ // Private
201
+ _updateAccessors(opts) {
202
+ const { getWeight, aggregation, data } = opts.props;
203
+ const { count } = this.state.weights;
204
+ if (count) {
205
+ count.getWeight = getWeight;
206
+ count.operation = AGGREGATION_OPERATION[aggregation];
207
+ }
208
+ this.setState({ getValue: getValueFunc(aggregation, getWeight, { data }) });
209
+ }
210
+ _resetResults() {
211
+ const { count } = this.state.weights;
212
+ if (count) {
213
+ count.aggregationData = null;
214
+ }
215
+ }
216
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,94 @@
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.
20
+ export const AGGREGATION_OPERATION = {
21
+ SUM: 1,
22
+ MEAN: 2,
23
+ MIN: 3,
24
+ MAX: 4
25
+ };
26
+ function sumReducer(accu, cur) {
27
+ return accu + cur;
28
+ }
29
+ function maxReducer(accu, cur) {
30
+ return cur > accu ? cur : accu;
31
+ }
32
+ function minReducer(accu, cur) {
33
+ return cur < accu ? cur : accu;
34
+ }
35
+ export function getMean(pts, accessor) {
36
+ if (Number.isFinite(accessor)) {
37
+ return pts.length ? accessor : null;
38
+ }
39
+ const filtered = pts.map(accessor).filter(Number.isFinite);
40
+ return filtered.length ? filtered.reduce(sumReducer, 0) / filtered.length : null;
41
+ }
42
+ export function getSum(pts, accessor) {
43
+ if (Number.isFinite(accessor)) {
44
+ return pts.length ? pts.length * accessor : null;
45
+ }
46
+ const filtered = pts.map(accessor).filter(Number.isFinite);
47
+ return filtered.length ? filtered.reduce(sumReducer, 0) : null;
48
+ }
49
+ export function getMax(pts, accessor) {
50
+ if (Number.isFinite(accessor)) {
51
+ return pts.length ? accessor : null;
52
+ }
53
+ const filtered = pts.map(accessor).filter(Number.isFinite);
54
+ return filtered.length ? filtered.reduce(maxReducer, -Infinity) : null;
55
+ }
56
+ export function getMin(pts, accessor) {
57
+ if (Number.isFinite(accessor)) {
58
+ return pts.length ? accessor : null;
59
+ }
60
+ const filtered = pts.map(accessor).filter(Number.isFinite);
61
+ return filtered.length ? filtered.reduce(minReducer, Infinity) : null;
62
+ }
63
+ // Function to convert from aggregation/accessor props (like colorAggregation and getColorWeight) to getValue prop (like getColorValue)
64
+ export function getValueFunc(aggregation, accessor, context) {
65
+ const op = AGGREGATION_OPERATION[aggregation] || AGGREGATION_OPERATION.SUM;
66
+ accessor = wrapAccessor(accessor, context);
67
+ switch (op) {
68
+ case AGGREGATION_OPERATION.MIN:
69
+ return pts => getMin(pts, accessor);
70
+ case AGGREGATION_OPERATION.SUM:
71
+ return pts => getSum(pts, accessor);
72
+ case AGGREGATION_OPERATION.MEAN:
73
+ return pts => getMean(pts, accessor);
74
+ case AGGREGATION_OPERATION.MAX:
75
+ return pts => getMax(pts, accessor);
76
+ default:
77
+ return null;
78
+ }
79
+ }
80
+ function wrapAccessor(accessor, context = {}) {
81
+ if (Number.isFinite(accessor)) {
82
+ return accessor;
83
+ }
84
+ return pt => {
85
+ context.index = pt.index;
86
+ return accessor(pt.source, context);
87
+ };
88
+ }
89
+ export function wrapGetValueFunc(getValue, context = {}) {
90
+ return pts => {
91
+ context.indices = pts.map(pt => pt.index);
92
+ return getValue(pts.map(pt => pt.source), context);
93
+ };
94
+ }