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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (318) hide show
  1. package/dist/common/aggregation-layer.d.ts +30 -0
  2. package/dist/common/aggregation-layer.d.ts.map +1 -0
  3. package/dist/common/aggregation-layer.js +69 -0
  4. package/dist/common/aggregator/aggregator.d.ts +76 -0
  5. package/dist/common/aggregator/aggregator.d.ts.map +1 -0
  6. package/dist/common/aggregator/aggregator.js +4 -0
  7. package/dist/common/aggregator/cpu-aggregator/aggregate.d.ts +27 -0
  8. package/dist/common/aggregator/cpu-aggregator/aggregate.d.ts.map +1 -0
  9. package/dist/common/aggregator/cpu-aggregator/aggregate.js +66 -0
  10. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.d.ts +70 -0
  11. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.d.ts.map +1 -0
  12. package/dist/common/aggregator/cpu-aggregator/cpu-aggregator.js +139 -0
  13. package/dist/common/aggregator/cpu-aggregator/sort-bins.d.ts +15 -0
  14. package/dist/common/aggregator/cpu-aggregator/sort-bins.d.ts.map +1 -0
  15. package/dist/common/aggregator/cpu-aggregator/sort-bins.js +43 -0
  16. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.d.ts +21 -0
  17. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.d.ts.map +1 -0
  18. package/dist/common/aggregator/cpu-aggregator/vertex-accessor.js +55 -0
  19. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.d.ts +18 -0
  20. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.d.ts.map +1 -0
  21. package/dist/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.js +20 -0
  22. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.d.ts +14 -0
  23. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.d.ts.map +1 -0
  24. package/dist/common/aggregator/gpu-aggregator/bin-sorter-uniforms.js +17 -0
  25. package/dist/common/aggregator/gpu-aggregator/utils.d.ts +6 -0
  26. package/dist/common/aggregator/gpu-aggregator/utils.d.ts.map +1 -0
  27. package/dist/common/aggregator/gpu-aggregator/utils.js +24 -0
  28. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts +24 -0
  29. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts.map +1 -0
  30. package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js +215 -0
  31. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.d.ts +81 -0
  32. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.d.ts.map +1 -0
  33. package/dist/common/aggregator/gpu-aggregator/webgl-aggregator.js +201 -0
  34. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.d.ts +38 -0
  35. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.d.ts.map +1 -0
  36. package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js +223 -0
  37. package/dist/common/aggregator/index.d.ts +6 -0
  38. package/dist/common/aggregator/index.d.ts.map +1 -0
  39. package/dist/common/aggregator/index.js +5 -0
  40. package/dist/common/types.d.ts +11 -0
  41. package/dist/common/types.d.ts.map +1 -0
  42. package/dist/common/types.js +4 -0
  43. package/dist/common/utils/bounds-utils.d.ts +10 -0
  44. package/dist/common/utils/bounds-utils.d.ts.map +1 -0
  45. package/dist/common/utils/bounds-utils.js +20 -0
  46. package/dist/common/utils/color-utils.d.ts +10 -0
  47. package/dist/common/utils/color-utils.d.ts.map +1 -0
  48. package/dist/common/utils/color-utils.js +65 -0
  49. package/dist/common/utils/prop-utils.d.ts.map +1 -0
  50. package/dist/common/utils/prop-utils.js +12 -0
  51. package/dist/common/utils/scale-utils.d.ts +46 -0
  52. package/dist/common/utils/scale-utils.d.ts.map +1 -0
  53. package/dist/common/utils/scale-utils.js +180 -0
  54. package/dist/contour-layer/bin-options-uniforms.d.ts +13 -0
  55. package/dist/contour-layer/bin-options-uniforms.d.ts.map +1 -0
  56. package/dist/contour-layer/bin-options-uniforms.js +17 -0
  57. package/dist/contour-layer/contour-layer.d.ts +42 -50
  58. package/dist/contour-layer/contour-layer.d.ts.map +1 -1
  59. package/dist/contour-layer/contour-layer.js +232 -192
  60. package/dist/contour-layer/contour-utils.d.ts +36 -15
  61. package/dist/contour-layer/contour-utils.d.ts.map +1 -1
  62. package/dist/contour-layer/contour-utils.js +24 -29
  63. package/dist/contour-layer/marching-squares-codes.d.ts.map +1 -1
  64. package/dist/contour-layer/marching-squares-codes.js +3 -0
  65. package/dist/contour-layer/marching-squares.d.ts +22 -6
  66. package/dist/contour-layer/marching-squares.d.ts.map +1 -1
  67. package/dist/contour-layer/marching-squares.js +71 -68
  68. package/dist/contour-layer/value-reader.d.ts +10 -0
  69. package/dist/contour-layer/value-reader.d.ts.map +1 -0
  70. package/dist/contour-layer/value-reader.js +46 -0
  71. package/dist/dist.dev.js +4842 -4081
  72. package/dist/grid-layer/bin-options-uniforms.d.ts +13 -0
  73. package/dist/grid-layer/bin-options-uniforms.d.ts.map +1 -0
  74. package/dist/grid-layer/bin-options-uniforms.js +17 -0
  75. package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts +3 -0
  76. package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts.map +1 -0
  77. package/dist/grid-layer/grid-cell-layer-vertex.glsl.js +51 -0
  78. package/dist/grid-layer/grid-cell-layer.d.ts +32 -0
  79. package/dist/grid-layer/grid-cell-layer.d.ts.map +1 -0
  80. package/dist/grid-layer/grid-cell-layer.js +93 -0
  81. package/dist/grid-layer/grid-layer-uniforms.d.ts +21 -0
  82. package/dist/grid-layer/grid-layer-uniforms.d.ts.map +1 -0
  83. package/dist/grid-layer/grid-layer-uniforms.js +23 -0
  84. package/dist/grid-layer/grid-layer.d.ts +175 -13
  85. package/dist/grid-layer/grid-layer.d.ts.map +1 -1
  86. package/dist/grid-layer/grid-layer.js +342 -46
  87. package/dist/{aggregation-layer.d.ts → heatmap-layer/aggregation-layer.d.ts} +1 -0
  88. package/dist/heatmap-layer/aggregation-layer.d.ts.map +1 -0
  89. package/dist/{aggregation-layer.js → heatmap-layer/aggregation-layer.js} +6 -21
  90. package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts +30 -0
  91. package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts.map +1 -0
  92. package/dist/heatmap-layer/heatmap-layer-uniforms.js +32 -0
  93. package/dist/heatmap-layer/heatmap-layer-utils.d.ts +1 -1
  94. package/dist/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -1
  95. package/dist/heatmap-layer/heatmap-layer-utils.js +3 -0
  96. package/dist/heatmap-layer/heatmap-layer.d.ts +6 -4
  97. package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -1
  98. package/dist/heatmap-layer/heatmap-layer.js +43 -33
  99. package/dist/heatmap-layer/max-fs.glsl.d.ts.map +1 -1
  100. package/dist/heatmap-layer/max-fs.glsl.js +3 -0
  101. package/dist/heatmap-layer/max-vs.glsl.d.ts +1 -1
  102. package/dist/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
  103. package/dist/heatmap-layer/max-vs.glsl.js +6 -4
  104. package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts +1 -1
  105. package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +1 -1
  106. package/dist/heatmap-layer/triangle-layer-fragment.glsl.js +5 -23
  107. package/dist/heatmap-layer/triangle-layer-uniforms.d.ts +22 -0
  108. package/dist/heatmap-layer/triangle-layer-uniforms.d.ts.map +1 -0
  109. package/dist/heatmap-layer/triangle-layer-uniforms.js +22 -0
  110. package/dist/heatmap-layer/triangle-layer-vertex.glsl.d.ts +1 -1
  111. package/dist/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +1 -1
  112. package/dist/heatmap-layer/triangle-layer-vertex.glsl.js +10 -30
  113. package/dist/heatmap-layer/triangle-layer.d.ts +4 -10
  114. package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -1
  115. package/dist/heatmap-layer/triangle-layer.js +17 -30
  116. package/dist/heatmap-layer/weights-fs.glsl.d.ts.map +1 -1
  117. package/dist/heatmap-layer/weights-fs.glsl.js +3 -0
  118. package/dist/heatmap-layer/weights-vs.glsl.d.ts +1 -1
  119. package/dist/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
  120. package/dist/heatmap-layer/weights-vs.glsl.js +6 -7
  121. package/dist/hexagon-layer/bin-options-uniforms.d.ts +14 -0
  122. package/dist/hexagon-layer/bin-options-uniforms.d.ts.map +1 -0
  123. package/dist/hexagon-layer/bin-options-uniforms.js +17 -0
  124. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts +3 -0
  125. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts.map +1 -0
  126. package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.js +55 -0
  127. package/dist/hexagon-layer/hexagon-cell-layer.d.ts +29 -0
  128. package/dist/hexagon-layer/hexagon-cell-layer.d.ts.map +1 -0
  129. package/dist/hexagon-layer/hexagon-cell-layer.js +94 -0
  130. package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts +19 -0
  131. package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts.map +1 -0
  132. package/dist/hexagon-layer/hexagon-layer-uniforms.js +21 -0
  133. package/dist/hexagon-layer/hexagon-layer.d.ts +84 -54
  134. package/dist/hexagon-layer/hexagon-layer.d.ts.map +1 -1
  135. package/dist/hexagon-layer/hexagon-layer.js +307 -123
  136. package/dist/hexagon-layer/hexbin.d.ts +17 -0
  137. package/dist/hexagon-layer/hexbin.d.ts.map +1 -0
  138. package/dist/hexagon-layer/hexbin.js +69 -0
  139. package/dist/index.cjs +3025 -2946
  140. package/dist/index.cjs.map +4 -4
  141. package/dist/index.d.ts +7 -13
  142. package/dist/index.d.ts.map +1 -1
  143. package/dist/index.js +5 -27
  144. package/dist/screen-grid-layer/bin-options-uniforms.d.ts +11 -0
  145. package/dist/screen-grid-layer/bin-options-uniforms.d.ts.map +1 -0
  146. package/dist/screen-grid-layer/bin-options-uniforms.js +15 -0
  147. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts +11 -16
  148. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
  149. package/dist/screen-grid-layer/screen-grid-cell-layer.js +52 -134
  150. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +1 -1
  151. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +1 -1
  152. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js +4 -24
  153. package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts +17 -0
  154. package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts.map +1 -0
  155. package/dist/screen-grid-layer/screen-grid-layer-uniforms.js +19 -0
  156. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +1 -1
  157. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +1 -1
  158. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js +21 -62
  159. package/dist/screen-grid-layer/screen-grid-layer.d.ts +33 -40
  160. package/dist/screen-grid-layer/screen-grid-layer.d.ts.map +1 -1
  161. package/dist/screen-grid-layer/screen-grid-layer.js +157 -174
  162. package/dist.min.js +401 -382
  163. package/package.json +10 -9
  164. package/src/common/aggregation-layer.ts +107 -0
  165. package/src/common/aggregator/aggregator.ts +88 -0
  166. package/src/common/aggregator/cpu-aggregator/aggregate.ts +101 -0
  167. package/src/common/aggregator/cpu-aggregator/cpu-aggregator.ts +203 -0
  168. package/src/common/aggregator/cpu-aggregator/sort-bins.ts +63 -0
  169. package/src/common/aggregator/cpu-aggregator/vertex-accessor.ts +86 -0
  170. package/src/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.ts +33 -0
  171. package/src/common/aggregator/gpu-aggregator/bin-sorter-uniforms.ts +27 -0
  172. package/src/common/aggregator/gpu-aggregator/utils.ts +27 -0
  173. package/src/common/aggregator/gpu-aggregator/webgl-aggregation-transform.ts +247 -0
  174. package/src/common/aggregator/gpu-aggregator/webgl-aggregator.ts +274 -0
  175. package/src/common/aggregator/gpu-aggregator/webgl-bin-sorter.ts +258 -0
  176. package/src/common/aggregator/index.ts +10 -0
  177. package/src/{types.ts → common/types.ts} +10 -4
  178. package/src/common/utils/bounds-utils.ts +34 -0
  179. package/src/common/utils/color-utils.ts +86 -0
  180. package/src/common/utils/prop-utils.ts +13 -0
  181. package/src/common/utils/scale-utils.ts +236 -0
  182. package/src/contour-layer/bin-options-uniforms.ts +26 -0
  183. package/src/contour-layer/contour-layer.ts +300 -265
  184. package/src/contour-layer/contour-utils.ts +68 -39
  185. package/src/contour-layer/marching-squares-codes.ts +4 -0
  186. package/src/contour-layer/marching-squares.ts +93 -82
  187. package/src/contour-layer/value-reader.ts +65 -0
  188. package/src/grid-layer/bin-options-uniforms.ts +26 -0
  189. package/src/grid-layer/grid-cell-layer-vertex.glsl.ts +68 -0
  190. package/src/grid-layer/grid-cell-layer.ts +141 -0
  191. package/src/grid-layer/grid-layer-uniforms.ts +37 -0
  192. package/src/grid-layer/grid-layer.ts +614 -73
  193. package/src/{aggregation-layer.ts → heatmap-layer/aggregation-layer.ts} +6 -21
  194. package/src/heatmap-layer/heatmap-layer-uniforms.ts +50 -0
  195. package/src/heatmap-layer/heatmap-layer-utils.ts +9 -1
  196. package/src/heatmap-layer/heatmap-layer.ts +59 -36
  197. package/src/heatmap-layer/max-fs.glsl.ts +4 -0
  198. package/src/heatmap-layer/max-vs.glsl.ts +7 -4
  199. package/src/heatmap-layer/triangle-layer-fragment.glsl.ts +5 -23
  200. package/src/heatmap-layer/triangle-layer-uniforms.ts +37 -0
  201. package/src/heatmap-layer/triangle-layer-vertex.glsl.ts +10 -30
  202. package/src/heatmap-layer/triangle-layer.ts +26 -31
  203. package/src/heatmap-layer/weights-fs.glsl.ts +4 -0
  204. package/src/heatmap-layer/weights-vs.glsl.ts +7 -7
  205. package/src/hexagon-layer/bin-options-uniforms.ts +27 -0
  206. package/src/hexagon-layer/hexagon-cell-layer-vertex.glsl.ts +73 -0
  207. package/src/hexagon-layer/hexagon-cell-layer.ts +141 -0
  208. package/src/hexagon-layer/hexagon-layer-uniforms.ts +34 -0
  209. package/src/hexagon-layer/hexagon-layer.ts +454 -186
  210. package/src/hexagon-layer/hexbin.ts +79 -0
  211. package/src/index.ts +21 -34
  212. package/src/screen-grid-layer/bin-options-uniforms.ts +23 -0
  213. package/src/screen-grid-layer/screen-grid-cell-layer.ts +71 -156
  214. package/src/screen-grid-layer/screen-grid-layer-fragment.glsl.ts +4 -24
  215. package/src/screen-grid-layer/screen-grid-layer-uniforms.ts +31 -0
  216. package/src/screen-grid-layer/screen-grid-layer-vertex.glsl.ts +21 -64
  217. package/src/screen-grid-layer/screen-grid-layer.ts +194 -222
  218. package/dist/aggregation-layer.d.ts.map +0 -1
  219. package/dist/cpu-grid-layer/cpu-grid-layer.d.ts +0 -158
  220. package/dist/cpu-grid-layer/cpu-grid-layer.d.ts.map +0 -1
  221. package/dist/cpu-grid-layer/cpu-grid-layer.js +0 -130
  222. package/dist/cpu-grid-layer/grid-aggregator.d.ts +0 -35
  223. package/dist/cpu-grid-layer/grid-aggregator.d.ts.map +0 -1
  224. package/dist/cpu-grid-layer/grid-aggregator.js +0 -141
  225. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +0 -3
  226. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +0 -1
  227. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -30
  228. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +0 -3
  229. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +0 -1
  230. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -112
  231. package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts +0 -48
  232. package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +0 -1
  233. package/dist/gpu-grid-layer/gpu-grid-cell-layer.js +0 -146
  234. package/dist/gpu-grid-layer/gpu-grid-layer.d.ts +0 -99
  235. package/dist/gpu-grid-layer/gpu-grid-layer.d.ts.map +0 -1
  236. package/dist/gpu-grid-layer/gpu-grid-layer.js +0 -289
  237. package/dist/grid-aggregation-layer.d.ts +0 -67
  238. package/dist/grid-aggregation-layer.d.ts.map +0 -1
  239. package/dist/grid-aggregation-layer.js +0 -173
  240. package/dist/hexagon-layer/hexagon-aggregator.d.ts +0 -27
  241. package/dist/hexagon-layer/hexagon-aggregator.d.ts.map +0 -1
  242. package/dist/hexagon-layer/hexagon-aggregator.js +0 -112
  243. package/dist/types.d.ts +0 -12
  244. package/dist/types.d.ts.map +0 -1
  245. package/dist/types.js +0 -1
  246. package/dist/utils/aggregation-operation-utils.d.ts +0 -19
  247. package/dist/utils/aggregation-operation-utils.d.ts.map +0 -1
  248. package/dist/utils/aggregation-operation-utils.js +0 -94
  249. package/dist/utils/bin-sorter.d.ts +0 -52
  250. package/dist/utils/bin-sorter.d.ts.map +0 -1
  251. package/dist/utils/bin-sorter.js +0 -167
  252. package/dist/utils/color-utils.d.ts +0 -3
  253. package/dist/utils/color-utils.d.ts.map +0 -1
  254. package/dist/utils/color-utils.js +0 -53
  255. package/dist/utils/cpu-aggregator.d.ts +0 -169
  256. package/dist/utils/cpu-aggregator.d.ts.map +0 -1
  257. package/dist/utils/cpu-aggregator.js +0 -421
  258. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +0 -3
  259. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +0 -1
  260. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -36
  261. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +0 -3
  262. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +0 -1
  263. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -42
  264. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +0 -3
  265. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +0 -1
  266. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -30
  267. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +0 -3
  268. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +0 -1
  269. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -61
  270. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +0 -38
  271. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +0 -1
  272. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -41
  273. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts +0 -1
  274. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +0 -1
  275. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -1
  276. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +0 -76
  277. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +0 -1
  278. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -555
  279. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +0 -3
  280. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +0 -1
  281. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -32
  282. package/dist/utils/grid-aggregation-utils.d.ts +0 -30
  283. package/dist/utils/grid-aggregation-utils.d.ts.map +0 -1
  284. package/dist/utils/grid-aggregation-utils.js +0 -114
  285. package/dist/utils/prop-utils.d.ts.map +0 -1
  286. package/dist/utils/prop-utils.js +0 -28
  287. package/dist/utils/resource-utils.d.ts +0 -14
  288. package/dist/utils/resource-utils.d.ts.map +0 -1
  289. package/dist/utils/resource-utils.js +0 -38
  290. package/dist/utils/scale-utils.d.ts +0 -15
  291. package/dist/utils/scale-utils.d.ts.map +0 -1
  292. package/dist/utils/scale-utils.js +0 -184
  293. package/src/cpu-grid-layer/cpu-grid-layer.ts +0 -329
  294. package/src/cpu-grid-layer/grid-aggregator.ts +0 -184
  295. package/src/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.ts +0 -35
  296. package/src/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.ts +0 -143
  297. package/src/gpu-grid-layer/gpu-grid-cell-layer.ts +0 -201
  298. package/src/gpu-grid-layer/gpu-grid-layer.ts +0 -455
  299. package/src/grid-aggregation-layer.ts +0 -243
  300. package/src/hexagon-layer/hexagon-aggregator.ts +0 -127
  301. package/src/utils/aggregation-operation-utils.ts +0 -118
  302. package/src/utils/bin-sorter.ts +0 -218
  303. package/src/utils/color-utils.ts +0 -57
  304. package/src/utils/cpu-aggregator.ts +0 -503
  305. package/src/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.ts +0 -40
  306. package/src/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.ts +0 -54
  307. package/src/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.ts +0 -35
  308. package/src/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.ts +0 -79
  309. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.ts +0 -46
  310. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.ts +0 -0
  311. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
  312. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.ts +0 -690
  313. package/src/utils/gpu-grid-aggregation/transform-mean-vs.glsl.ts +0 -38
  314. package/src/utils/grid-aggregation-utils.ts +0 -147
  315. package/src/utils/prop-utils.ts +0 -29
  316. package/src/utils/resource-utils.ts +0 -53
  317. package/src/utils/scale-utils.js +0 -219
  318. /package/dist/{utils → common/utils}/prop-utils.d.ts +0 -0
@@ -0,0 +1,13 @@
1
+ export type BinOptions = {
2
+ cellOriginCommon: [number, number];
3
+ cellSizeCommon: [number, number];
4
+ };
5
+ export declare const binOptionsUniforms: {
6
+ readonly name: "binOptions";
7
+ readonly vs: "uniform binOptionsUniforms {\n vec2 cellOriginCommon;\n vec2 cellSizeCommon;\n} binOptions;\n";
8
+ readonly uniformTypes: {
9
+ readonly cellOriginCommon: "vec2<f32>";
10
+ readonly cellSizeCommon: "vec2<f32>";
11
+ };
12
+ };
13
+ //# sourceMappingURL=bin-options-uniforms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin-options-uniforms.d.ts","sourceRoot":"","sources":["../../src/contour-layer/bin-options-uniforms.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,UAAU,GAAG;IACvB,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;CAOc,CAAC"}
@@ -0,0 +1,17 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ const uniformBlock = /* glsl */ `\
5
+ uniform binOptionsUniforms {
6
+ vec2 cellOriginCommon;
7
+ vec2 cellSizeCommon;
8
+ } binOptions;
9
+ `;
10
+ export const binOptionsUniforms = {
11
+ name: 'binOptions',
12
+ vs: uniformBlock,
13
+ uniformTypes: {
14
+ cellOriginCommon: 'vec2<f32>',
15
+ cellSizeCommon: 'vec2<f32>'
16
+ }
17
+ };
@@ -1,48 +1,38 @@
1
- import { Accessor, AccessorFunction, Color, Position, UpdateParameters, DefaultProps, LayersList } from '@deck.gl/core';
2
- import GridAggregationLayer, { GridAggregationLayerProps } from "../grid-aggregation-layer.js";
3
- /** All properties supported by ContourLayer. */
4
- export type ContourLayerProps<DataT = unknown> = _ContourLayerProps<DataT> & GridAggregationLayerProps<DataT>;
5
- /** Properties added by ContourLayer. */
6
- export type _ContourLayerProps<DataT> = {
1
+ import { Accessor, GetPickingInfoParams, LayersList, PickingInfo, Position, Viewport, UpdateParameters, DefaultProps } from '@deck.gl/core';
2
+ import { WebGLAggregator, CPUAggregator, AggregationOperation } from "../common/aggregator/index.js";
3
+ import AggregationLayer from "../common/aggregation-layer.js";
4
+ import { AggregationLayerProps } from "../common/aggregation-layer.js";
5
+ import { Contour, ContourLine, ContourPolygon } from "./contour-utils.js";
6
+ import { BinOptions } from "./bin-options-uniforms.js";
7
+ /** All properties supported by GridLayer. */
8
+ export type ContourLayerProps<DataT = unknown> = _ContourLayerProps<DataT> & AggregationLayerProps<DataT>;
9
+ /** Properties added by GridLayer. */
10
+ type _ContourLayerProps<DataT> = {
7
11
  /**
8
12
  * Size of each cell in meters.
9
13
  * @default 1000
10
14
  */
11
15
  cellSize?: number;
16
+ /**
17
+ * The grid origin
18
+ * @default [0, 0]
19
+ */
20
+ gridOrigin?: [number, number];
12
21
  /**
13
22
  * When set to true, aggregation is performed on GPU, provided other conditions are met.
14
- * @default true
23
+ * @default false
15
24
  */
16
25
  gpuAggregation?: boolean;
17
26
  /**
18
27
  * Defines the type of aggregation operation, valid values are 'SUM', 'MEAN', 'MIN' and 'MAX'.
19
28
  * @default 'SUM'
20
29
  */
21
- aggregation?: 'SUM' | 'MEAN' | 'MIN' | 'MAX';
30
+ aggregation?: AggregationOperation;
22
31
  /**
23
32
  * Definition of contours to be drawn.
24
33
  * @default [{threshold: 1}]
25
34
  */
26
- contours: {
27
- /**
28
- * Isolines: `threshold` value must be a single `Number`, Isolines are generated based on this threshold value.
29
- *
30
- * Isobands: `threshold` value must be an Array of two `Number`s. Isobands are generated using `[threshold[0], threshold[1])` as threshold range, i.e area that has values `>= threshold[0]` and `< threshold[1]` are rendered with corresponding color. NOTE: `threshold[0]` is inclusive and `threshold[1]` is not inclusive.
31
- */
32
- threshold: number | number[];
33
- /**
34
- * RGBA color array to be used to render the contour.
35
- * @default [255, 255, 255, 255]
36
- */
37
- color?: Color;
38
- /**
39
- * Applicable for `Isoline`s only, width of the Isoline in pixels.
40
- * @default 1
41
- */
42
- strokeWidth?: number;
43
- /** Defines z order of the contour. */
44
- zIndex?: number;
45
- }[];
35
+ contours?: Contour[];
46
36
  /**
47
37
  * A very small z offset that is added for each vertex of a contour (Isoline or Isoband).
48
38
  * @default 0.005
@@ -52,38 +42,40 @@ export type _ContourLayerProps<DataT> = {
52
42
  * Method called to retrieve the position of each object.
53
43
  * @default object => object.position
54
44
  */
55
- getPosition?: AccessorFunction<DataT, Position>;
45
+ getPosition?: Accessor<DataT, Position>;
56
46
  /**
57
47
  * The weight of each object.
58
48
  * @default 1
59
49
  */
60
50
  getWeight?: Accessor<DataT, number>;
61
51
  };
62
- /** Aggregate data into iso-lines or iso-bands for a given threshold and cell size. */
63
- export default class ContourLayer<DataT = any, ExtraPropsT extends {} = {}> extends GridAggregationLayer<DataT, ExtraPropsT & Required<_ContourLayerProps<DataT>>> {
52
+ export type ContourLayerPickingInfo = PickingInfo<{
53
+ contour: Contour;
54
+ }>;
55
+ /** Aggregate data into a grid-based heatmap. The color and height of a cell are determined based on the objects it contains. */
56
+ export default class GridLayer<DataT = any, ExtraPropsT extends {} = {}> extends AggregationLayer<DataT, ExtraPropsT & Required<_ContourLayerProps<DataT>>> {
64
57
  static layerName: string;
65
58
  static defaultProps: DefaultProps<ContourLayerProps<unknown>>;
66
- state: GridAggregationLayer<DataT>['state'] & {
67
- contourData: {
68
- contourSegments: {
69
- start: number[];
70
- end: number[];
71
- contour: any;
72
- }[];
73
- contourPolygons: {
74
- vertices: number[][];
75
- contour: any;
76
- }[];
59
+ state: AggregationLayer<DataT>['state'] & BinOptions & {
60
+ aggregatedValueReader?: (x: number, y: number) => number;
61
+ contourData?: {
62
+ lines: ContourLine[];
63
+ polygons: ContourPolygon[];
77
64
  };
78
- thresholdData: any;
65
+ binIdRange: [number, number][];
66
+ aggregatorViewport: Viewport;
79
67
  };
68
+ getAggregatorType(): string;
69
+ createAggregator(type: string): WebGLAggregator | CPUAggregator;
80
70
  initializeState(): void;
81
- updateState(opts: UpdateParameters<this>): void;
82
- renderLayers(): LayersList;
83
- updateAggregationState(opts: UpdateParameters<this>): void;
84
- private _updateAccessors;
85
- private _resetResults;
86
- private _generateContours;
87
- private _updateThresholdData;
71
+ updateState(params: UpdateParameters<this>): boolean;
72
+ private _updateBinOptions;
73
+ draw(opts: any): void;
74
+ private _onAggregationUpdate;
75
+ private _getContours;
76
+ onAttributeChange(id: string): void;
77
+ renderLayers(): LayersList | null;
78
+ getPickingInfo(params: GetPickingInfoParams): ContourLayerPickingInfo;
88
79
  }
80
+ export {};
89
81
  //# sourceMappingURL=contour-layer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contour-layer.d.ts","sourceRoot":"","sources":["../../src/contour-layer/contour-layer.ts"],"names":[],"mappings":"AAsBA,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,KAAK,EAEL,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACX,MAAM,eAAe,CAAC;AAKvB,OAAO,oBAAoB,EAAE,EAAC,yBAAyB,EAAC,qCAAkC;AAqC1F,gDAAgD;AAChD,MAAM,MAAM,iBAAiB,CAAC,KAAK,GAAG,OAAO,IAAI,kBAAkB,CAAC,KAAK,CAAC,GACxE,yBAAyB,CAAC,KAAK,CAAC,CAAC;AAEnC,wCAAwC;AACxC,MAAM,MAAM,kBAAkB,CAAC,KAAK,IAAI;IACtC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,WAAW,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KA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AAiB,CAAC,EAAE,EAAE,MAAM;IA2B5B,YAAY,IAAI,UAAU,GAAG,IAAI;IAsDjC,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,uBAAuB;CAWtE"}
@@ -1,241 +1,281 @@
1
- // Copyright (c) 2015 - 2018 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 { LineLayer, SolidPolygonLayer } from '@deck.gl/layers';
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ import { COORDINATE_SYSTEM, project32, Viewport, _deepEqual } from '@deck.gl/core';
5
+ import { PathLayer, SolidPolygonLayer } from '@deck.gl/layers';
6
+ import { WebGLAggregator, CPUAggregator } from "../common/aggregator/index.js";
7
+ import AggregationLayer from "../common/aggregation-layer.js";
21
8
  import { generateContours } from "./contour-utils.js";
22
- import { log } from '@deck.gl/core';
23
- import GPUGridAggregator from "../utils/gpu-grid-aggregation/gpu-grid-aggregator.js";
24
- import { AGGREGATION_OPERATION, getValueFunc } from "../utils/aggregation-operation-utils.js";
25
- import { getBoundingBox, getGridParams } from "../utils/grid-aggregation-utils.js";
26
- import GridAggregationLayer from "../grid-aggregation-layer.js";
9
+ import { getAggregatorValueReader } from "./value-reader.js";
10
+ import { getBinIdRange } from "../common/utils/bounds-utils.js";
11
+ import { Matrix4 } from '@math.gl/core';
12
+ import { binOptionsUniforms } from "./bin-options-uniforms.js";
27
13
  const DEFAULT_COLOR = [255, 255, 255, 255];
28
14
  const DEFAULT_STROKE_WIDTH = 1;
29
- const DEFAULT_THRESHOLD = 1;
30
15
  const defaultProps = {
31
16
  // grid aggregation
32
- cellSize: { type: 'number', min: 1, max: 1000, value: 1000 },
17
+ cellSize: { type: 'number', min: 1, value: 1000 },
18
+ gridOrigin: { type: 'array', compare: true, value: [0, 0] },
33
19
  getPosition: { type: 'accessor', value: (x) => x.position },
34
20
  getWeight: { type: 'accessor', value: 1 },
35
- gpuAggregation: false, // TODO(v9): Re-enable GPU aggregation.
21
+ gpuAggregation: true,
36
22
  aggregation: 'SUM',
37
23
  // contour lines
38
24
  contours: {
39
25
  type: 'object',
40
- value: [{ threshold: DEFAULT_THRESHOLD }],
26
+ value: [{ threshold: 1 }],
41
27
  optional: true,
42
28
  compare: 3
43
29
  },
44
30
  zOffset: 0.005
45
31
  };
46
- const POSITION_ATTRIBUTE_NAME = 'positions';
47
- const DIMENSIONS = {
48
- data: {
49
- props: ['cellSize']
50
- },
51
- weights: {
52
- props: ['aggregation'],
53
- accessors: ['getWeight']
32
+ /** Aggregate data into a grid-based heatmap. The color and height of a cell are determined based on the objects it contains. */
33
+ class GridLayer extends AggregationLayer {
34
+ getAggregatorType() {
35
+ return this.props.gpuAggregation && WebGLAggregator.isSupported(this.context.device)
36
+ ? 'gpu'
37
+ : 'cpu';
54
38
  }
55
- };
56
- /** Aggregate data into iso-lines or iso-bands for a given threshold and cell size. */
57
- class ContourLayer extends GridAggregationLayer {
58
- initializeState() {
59
- super.initializeAggregationLayer({
60
- dimensions: DIMENSIONS
61
- });
62
- this.setState({
63
- contourData: {},
64
- projectPoints: false,
65
- weights: {
66
- count: {
67
- size: 1,
68
- operation: AGGREGATION_OPERATION.SUM
69
- }
70
- }
39
+ createAggregator(type) {
40
+ if (type === 'cpu') {
41
+ return new CPUAggregator({
42
+ dimensions: 2,
43
+ getBin: {
44
+ sources: ['positions'],
45
+ getValue: ({ positions }, index, opts) => {
46
+ const viewport = this.state.aggregatorViewport;
47
+ // project to common space
48
+ const p = viewport.projectPosition(positions);
49
+ const { cellSizeCommon, cellOriginCommon } = opts;
50
+ return [
51
+ Math.floor((p[0] - cellOriginCommon[0]) / cellSizeCommon[0]),
52
+ Math.floor((p[1] - cellOriginCommon[1]) / cellSizeCommon[1])
53
+ ];
54
+ }
55
+ },
56
+ getValue: [{ sources: ['counts'], getValue: ({ counts }) => counts }],
57
+ onUpdate: this._onAggregationUpdate.bind(this)
58
+ });
59
+ }
60
+ return new WebGLAggregator(this.context.device, {
61
+ dimensions: 2,
62
+ channelCount: 1,
63
+ bufferLayout: this.getAttributeManager().getBufferLayouts({ isInstanced: false }),
64
+ ...super.getShaders({
65
+ modules: [project32, binOptionsUniforms],
66
+ vs: /* glsl */ `
67
+ in vec3 positions;
68
+ in vec3 positions64Low;
69
+ in float counts;
70
+
71
+ void getBin(out ivec2 binId) {
72
+ vec3 positionCommon = project_position(positions, positions64Low);
73
+ vec2 gridCoords = floor(positionCommon.xy / binOptions.cellSizeCommon);
74
+ binId = ivec2(gridCoords);
75
+ }
76
+ void getValue(out float value) {
77
+ value = counts;
78
+ }
79
+ `
80
+ }),
81
+ onUpdate: this._onAggregationUpdate.bind(this)
71
82
  });
83
+ }
84
+ initializeState() {
85
+ super.initializeState();
72
86
  const attributeManager = this.getAttributeManager();
73
87
  attributeManager.add({
74
- [POSITION_ATTRIBUTE_NAME]: {
88
+ positions: {
75
89
  size: 3,
76
90
  accessor: 'getPosition',
77
91
  type: 'float64',
78
92
  fp64: this.use64bitPositions()
79
93
  },
80
- // this attribute is used in gpu aggregation path only
81
- count: { size: 3, accessor: 'getWeight' }
94
+ counts: { size: 1, accessor: 'getWeight' }
95
+ });
96
+ }
97
+ updateState(params) {
98
+ const aggregatorChanged = super.updateState(params);
99
+ const { props, oldProps, changeFlags } = params;
100
+ const { aggregator } = this.state;
101
+ if (aggregatorChanged ||
102
+ changeFlags.dataChanged ||
103
+ props.cellSize !== oldProps.cellSize ||
104
+ !_deepEqual(props.gridOrigin, oldProps.gridOrigin, 1) ||
105
+ props.aggregation !== oldProps.aggregation) {
106
+ this._updateBinOptions();
107
+ const { cellSizeCommon, cellOriginCommon, binIdRange } = this.state;
108
+ aggregator.setProps({
109
+ // @ts-expect-error only used by GPUAggregator
110
+ binIdRange,
111
+ pointCount: this.getNumInstances(),
112
+ operations: [props.aggregation],
113
+ binOptions: {
114
+ cellSizeCommon,
115
+ cellOriginCommon
116
+ }
117
+ });
118
+ }
119
+ if (!_deepEqual(oldProps.contours, props.contours, 2)) {
120
+ // Recalculate contours
121
+ this.setState({ contourData: null });
122
+ }
123
+ return aggregatorChanged;
124
+ }
125
+ _updateBinOptions() {
126
+ const bounds = this.getBounds();
127
+ const cellSizeCommon = [1, 1];
128
+ let cellOriginCommon = [0, 0];
129
+ let binIdRange = [
130
+ [0, 1],
131
+ [0, 1]
132
+ ];
133
+ let viewport = this.context.viewport;
134
+ if (bounds && Number.isFinite(bounds[0][0])) {
135
+ let centroid = [(bounds[0][0] + bounds[1][0]) / 2, (bounds[0][1] + bounds[1][1]) / 2];
136
+ const { cellSize, gridOrigin } = this.props;
137
+ const { unitsPerMeter } = viewport.getDistanceScales(centroid);
138
+ cellSizeCommon[0] = unitsPerMeter[0] * cellSize;
139
+ cellSizeCommon[1] = unitsPerMeter[1] * cellSize;
140
+ // Offset common space to center at the origin of the grid cell where the data center is in
141
+ // This improves precision without affecting the cell positions
142
+ const centroidCommon = viewport.projectFlat(centroid);
143
+ cellOriginCommon = [
144
+ Math.floor((centroidCommon[0] - gridOrigin[0]) / cellSizeCommon[0]) * cellSizeCommon[0] +
145
+ gridOrigin[0],
146
+ Math.floor((centroidCommon[1] - gridOrigin[1]) / cellSizeCommon[1]) * cellSizeCommon[1] +
147
+ gridOrigin[1]
148
+ ];
149
+ centroid = viewport.unprojectFlat(cellOriginCommon);
150
+ const ViewportType = viewport.constructor;
151
+ // We construct a viewport for the GPU aggregator's project module
152
+ // This viewport is determined by data
153
+ // removes arbitrary precision variance that depends on initial view state
154
+ viewport = viewport.isGeospatial
155
+ ? new ViewportType({ longitude: centroid[0], latitude: centroid[1], zoom: 12 })
156
+ : new Viewport({ position: [centroid[0], centroid[1], 0], zoom: 12 });
157
+ // Round to the nearest 32-bit float to match CPU and GPU results
158
+ cellOriginCommon = [Math.fround(viewport.center[0]), Math.fround(viewport.center[1])];
159
+ binIdRange = getBinIdRange({
160
+ dataBounds: bounds,
161
+ getBinId: (p) => {
162
+ const positionCommon = viewport.projectFlat(p);
163
+ return [
164
+ Math.floor((positionCommon[0] - cellOriginCommon[0]) / cellSizeCommon[0]),
165
+ Math.floor((positionCommon[1] - cellOriginCommon[1]) / cellSizeCommon[1])
166
+ ];
167
+ }
168
+ });
169
+ }
170
+ this.setState({ cellSizeCommon, cellOriginCommon, binIdRange, aggregatorViewport: viewport });
171
+ }
172
+ draw(opts) {
173
+ // Replaces render time viewport with our own
174
+ if (opts.shaderModuleProps.project) {
175
+ opts.shaderModuleProps.project.viewport = this.state.aggregatorViewport;
176
+ }
177
+ super.draw(opts);
178
+ }
179
+ _onAggregationUpdate() {
180
+ const { aggregator, binIdRange } = this.state;
181
+ this.setState({
182
+ aggregatedValueReader: getAggregatorValueReader({ aggregator, binIdRange, channel: 0 }),
183
+ contourData: null
82
184
  });
83
185
  }
84
- updateState(opts) {
85
- super.updateState(opts);
86
- let contoursChanged = false;
87
- const { oldProps, props } = opts;
88
- const { aggregationDirty } = this.state;
89
- if (oldProps.contours !== props.contours || oldProps.zOffset !== props.zOffset) {
90
- contoursChanged = true;
91
- this._updateThresholdData(opts.props);
186
+ _getContours() {
187
+ const { aggregatedValueReader } = this.state;
188
+ if (!aggregatedValueReader) {
189
+ return null;
92
190
  }
93
- if (this.getNumInstances() > 0 && (aggregationDirty || contoursChanged)) {
94
- this._generateContours();
191
+ if (!this.state.contourData) {
192
+ const { binIdRange } = this.state;
193
+ const { contours } = this.props;
194
+ const contourData = generateContours({
195
+ contours,
196
+ getValue: aggregatedValueReader,
197
+ xRange: binIdRange[0],
198
+ yRange: binIdRange[1]
199
+ });
200
+ this.state.contourData = contourData;
201
+ }
202
+ return this.state.contourData;
203
+ }
204
+ onAttributeChange(id) {
205
+ const { aggregator } = this.state;
206
+ switch (id) {
207
+ case 'positions':
208
+ aggregator.setNeedsUpdate();
209
+ this._updateBinOptions();
210
+ const { cellSizeCommon, cellOriginCommon, binIdRange } = this.state;
211
+ aggregator.setProps({
212
+ // @ts-expect-error only used by GPUAggregator
213
+ binIdRange,
214
+ binOptions: {
215
+ cellSizeCommon,
216
+ cellOriginCommon
217
+ }
218
+ });
219
+ break;
220
+ case 'counts':
221
+ aggregator.setNeedsUpdate(0);
222
+ break;
223
+ default:
224
+ // This should not happen
95
225
  }
96
226
  }
97
227
  renderLayers() {
98
- const { contourSegments, contourPolygons } = this.state.contourData;
99
- const LinesSubLayerClass = this.getSubLayerClass('lines', LineLayer);
228
+ const contourData = this._getContours();
229
+ if (!contourData) {
230
+ return null;
231
+ }
232
+ const { lines, polygons } = contourData;
233
+ const { zOffset } = this.props;
234
+ const { cellOriginCommon, cellSizeCommon } = this.state;
235
+ const LinesSubLayerClass = this.getSubLayerClass('lines', PathLayer);
100
236
  const BandsSubLayerClass = this.getSubLayerClass('bands', SolidPolygonLayer);
237
+ const modelMatrix = new Matrix4()
238
+ .translate([cellOriginCommon[0], cellOriginCommon[1], 0])
239
+ .scale([cellSizeCommon[0], cellSizeCommon[1], zOffset]);
101
240
  // Contour lines layer
102
- const lineLayer = contourSegments &&
103
- contourSegments.length > 0 &&
241
+ const lineLayer = lines &&
242
+ lines.length > 0 &&
104
243
  new LinesSubLayerClass(this.getSubLayerProps({
105
244
  id: 'lines'
106
245
  }), {
107
- data: this.state.contourData.contourSegments,
108
- getSourcePosition: d => d.start,
109
- getTargetPosition: d => d.end,
110
- getColor: d => d.contour.color || DEFAULT_COLOR,
111
- getWidth: d => d.contour.strokeWidth || DEFAULT_STROKE_WIDTH
246
+ data: lines,
247
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
248
+ modelMatrix,
249
+ getPath: d => d.vertices,
250
+ getColor: d => d.contour.color ?? DEFAULT_COLOR,
251
+ getWidth: d => d.contour.strokeWidth ?? DEFAULT_STROKE_WIDTH,
252
+ widthUnits: 'pixels'
112
253
  });
113
254
  // Contour bands layer
114
- const bandsLayer = contourPolygons &&
115
- contourPolygons.length > 0 &&
255
+ const bandsLayer = polygons &&
256
+ polygons.length > 0 &&
116
257
  new BandsSubLayerClass(this.getSubLayerProps({
117
258
  id: 'bands'
118
259
  }), {
119
- data: this.state.contourData.contourPolygons,
260
+ data: polygons,
261
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
262
+ modelMatrix,
120
263
  getPolygon: d => d.vertices,
121
- getFillColor: d => d.contour.color || DEFAULT_COLOR
264
+ getFillColor: d => d.contour.color ?? DEFAULT_COLOR
122
265
  });
123
266
  return [lineLayer, bandsLayer];
124
267
  }
125
- // Aggregation Overrides
126
- /* eslint-disable max-statements, complexity */
127
- updateAggregationState(opts) {
128
- const { props, oldProps } = opts;
129
- const { cellSize, coordinateSystem } = props;
130
- const { viewport } = this.context;
131
- const cellSizeChanged = oldProps.cellSize !== cellSize;
132
- let gpuAggregation = props.gpuAggregation;
133
- if (this.state.gpuAggregation !== props.gpuAggregation) {
134
- if (gpuAggregation && !GPUGridAggregator.isSupported(this.context.device)) {
135
- log.warn('GPU Grid Aggregation not supported, falling back to CPU')();
136
- gpuAggregation = false;
137
- }
138
- }
139
- const gpuAggregationChanged = gpuAggregation !== this.state.gpuAggregation;
140
- this.setState({
141
- gpuAggregation
142
- });
143
- const { dimensions } = this.state;
144
- const positionsChanged = this.isAttributeChanged(POSITION_ATTRIBUTE_NAME);
145
- const { data, weights } = dimensions;
146
- let { boundingBox } = this.state;
147
- if (positionsChanged) {
148
- boundingBox = getBoundingBox(this.getAttributes(), this.getNumInstances());
149
- this.setState({ boundingBox });
150
- }
151
- if (positionsChanged || cellSizeChanged) {
152
- const { gridOffset, translation, width, height, numCol, numRow } = getGridParams(boundingBox, cellSize, viewport, coordinateSystem);
153
- this.allocateResources(numRow, numCol);
154
- this.setState({
155
- gridOffset,
156
- boundingBox,
157
- translation,
158
- posOffset: translation.slice(), // Used for CPU aggregation, to offset points
159
- gridOrigin: [-1 * translation[0], -1 * translation[1]],
160
- width,
161
- height,
162
- numCol,
163
- numRow
164
- });
165
- }
166
- const aggregationDataDirty = positionsChanged ||
167
- gpuAggregationChanged ||
168
- this.isAggregationDirty(opts, {
169
- dimension: data,
170
- compareAll: gpuAggregation // check for all (including extentions props) when using gpu aggregation
171
- });
172
- const aggregationWeightsDirty = this.isAggregationDirty(opts, {
173
- dimension: weights
174
- });
175
- if (aggregationWeightsDirty) {
176
- this._updateAccessors(opts);
177
- }
178
- if (aggregationDataDirty || aggregationWeightsDirty) {
179
- this._resetResults();
180
- }
181
- this.setState({
182
- aggregationDataDirty,
183
- aggregationWeightsDirty
184
- });
185
- }
186
- /* eslint-enable max-statements, complexity */
187
- // Private (Aggregation)
188
- _updateAccessors(opts) {
189
- const { getWeight, aggregation, data } = opts.props;
190
- const { count } = this.state.weights;
191
- if (count) {
192
- count.getWeight = getWeight;
193
- count.operation = AGGREGATION_OPERATION[aggregation];
194
- }
195
- this.setState({ getValue: getValueFunc(aggregation, getWeight, { data }) });
196
- }
197
- _resetResults() {
198
- const { count } = this.state.weights;
199
- if (count) {
200
- count.aggregationData = null;
201
- }
202
- }
203
- // Private (Contours)
204
- _generateContours() {
205
- const { numCol, numRow, gridOrigin, gridOffset, thresholdData } = this.state;
206
- const { count } = this.state.weights;
207
- let { aggregationData } = count;
208
- if (!aggregationData) {
209
- // @ts-ignore
210
- aggregationData = count.aggregationBuffer.readSyncWebGL();
211
- count.aggregationData = aggregationData;
212
- }
213
- const { cellWeights } = GPUGridAggregator.getCellData({ countsData: aggregationData });
214
- const contourData = generateContours({
215
- thresholdData,
216
- cellWeights,
217
- gridSize: [numCol, numRow],
218
- gridOrigin,
219
- cellSize: [gridOffset.xOffset, gridOffset.yOffset]
220
- });
221
- // contourData contains both iso-lines and iso-bands if requested.
222
- this.setState({ contourData });
223
- }
224
- _updateThresholdData(props) {
225
- const { contours, zOffset } = props;
226
- const count = contours.length;
227
- const thresholdData = new Array(count);
228
- for (let i = 0; i < count; i++) {
229
- const contour = contours[i];
230
- thresholdData[i] = {
231
- contour,
232
- zIndex: contour.zIndex || i,
233
- zOffset
268
+ getPickingInfo(params) {
269
+ const info = params.info;
270
+ const { object } = info;
271
+ if (object) {
272
+ info.object = {
273
+ contour: object.contour
234
274
  };
235
275
  }
236
- this.setState({ thresholdData });
276
+ return info;
237
277
  }
238
278
  }
239
- ContourLayer.layerName = 'ContourLayer';
240
- ContourLayer.defaultProps = defaultProps;
241
- export default ContourLayer;
279
+ GridLayer.layerName = 'ContourLayer';
280
+ GridLayer.defaultProps = defaultProps;
281
+ export default GridLayer;