@deck.gl/aggregation-layers 9.0.0-beta.1 → 9.0.0-beta.11

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 (362) hide show
  1. package/{typed → dist}/aggregation-layer.d.ts +2 -2
  2. package/dist/aggregation-layer.d.ts.map +1 -0
  3. package/dist/aggregation-layer.js +153 -0
  4. package/{typed → dist}/contour-layer/contour-layer.d.ts +1 -1
  5. package/dist/contour-layer/contour-layer.d.ts.map +1 -0
  6. package/dist/contour-layer/contour-layer.js +240 -0
  7. package/dist/contour-layer/contour-utils.js +64 -0
  8. package/dist/contour-layer/marching-squares-codes.js +337 -0
  9. package/dist/contour-layer/marching-squares.js +147 -0
  10. package/{typed → dist}/cpu-grid-layer/cpu-grid-layer.d.ts +3 -3
  11. package/dist/cpu-grid-layer/cpu-grid-layer.d.ts.map +1 -0
  12. package/dist/cpu-grid-layer/cpu-grid-layer.js +129 -0
  13. package/dist/cpu-grid-layer/grid-aggregator.js +141 -0
  14. package/dist/dist.dev.js +1442 -10868
  15. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +30 -0
  16. package/dist/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +112 -0
  17. package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer.d.ts +1 -1
  18. package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +1 -0
  19. package/dist/gpu-grid-layer/gpu-grid-cell-layer.js +145 -0
  20. package/{typed → dist}/gpu-grid-layer/gpu-grid-layer.d.ts +4 -4
  21. package/dist/gpu-grid-layer/gpu-grid-layer.d.ts.map +1 -0
  22. package/dist/gpu-grid-layer/gpu-grid-layer.js +288 -0
  23. package/{typed → dist}/grid-aggregation-layer.d.ts +3 -3
  24. package/dist/grid-aggregation-layer.d.ts.map +1 -0
  25. package/dist/grid-aggregation-layer.js +172 -0
  26. package/{typed → dist}/grid-layer/grid-layer.d.ts +2 -2
  27. package/dist/grid-layer/grid-layer.d.ts.map +1 -0
  28. package/dist/grid-layer/grid-layer.js +63 -0
  29. package/{typed → dist}/heatmap-layer/heatmap-layer-utils.d.ts +0 -9
  30. package/dist/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -0
  31. package/dist/heatmap-layer/heatmap-layer-utils.js +63 -0
  32. package/{typed → dist}/heatmap-layer/heatmap-layer.d.ts +5 -6
  33. package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -0
  34. package/dist/heatmap-layer/heatmap-layer.js +455 -0
  35. package/dist/heatmap-layer/max-fs.glsl.js +9 -0
  36. package/dist/heatmap-layer/max-vs.glsl.d.ts +3 -0
  37. package/{typed → dist}/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
  38. package/dist/heatmap-layer/max-vs.glsl.js +15 -0
  39. package/dist/heatmap-layer/triangle-layer-fragment.glsl.d.ts +3 -0
  40. package/dist/heatmap-layer/triangle-layer-fragment.glsl.js +51 -0
  41. package/dist/heatmap-layer/triangle-layer-vertex.glsl.js +47 -0
  42. package/{typed → dist}/heatmap-layer/triangle-layer.d.ts +10 -2
  43. package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -0
  44. package/dist/heatmap-layer/triangle-layer.js +59 -0
  45. package/dist/heatmap-layer/weights-fs.glsl.js +17 -0
  46. package/dist/heatmap-layer/weights-vs.glsl.d.ts +3 -0
  47. package/{typed → dist}/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
  48. package/dist/heatmap-layer/weights-vs.glsl.js +21 -0
  49. package/dist/hexagon-layer/hexagon-aggregator.js +112 -0
  50. package/{typed → dist}/hexagon-layer/hexagon-layer.d.ts +4 -4
  51. package/dist/hexagon-layer/hexagon-layer.d.ts.map +1 -0
  52. package/dist/hexagon-layer/hexagon-layer.js +173 -0
  53. package/dist/index.cjs +4328 -0
  54. package/dist/index.cjs.map +7 -0
  55. package/dist/index.d.ts +20 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +32 -0
  58. package/{typed → dist}/screen-grid-layer/screen-grid-cell-layer.d.ts +2 -3
  59. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -0
  60. package/dist/screen-grid-layer/screen-grid-cell-layer.js +164 -0
  61. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js +35 -0
  62. package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js +72 -0
  63. package/{typed → dist}/screen-grid-layer/screen-grid-layer.d.ts +1 -4
  64. package/dist/screen-grid-layer/screen-grid-layer.d.ts.map +1 -0
  65. package/dist/screen-grid-layer/screen-grid-layer.js +209 -0
  66. package/dist/types.js +1 -0
  67. package/dist/utils/aggregation-operation-utils.js +94 -0
  68. package/{typed → dist}/utils/bin-sorter.d.ts +1 -1
  69. package/dist/utils/bin-sorter.js +167 -0
  70. package/dist/utils/color-utils.js +53 -0
  71. package/dist/utils/cpu-aggregator.js +421 -0
  72. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +36 -0
  73. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +42 -0
  74. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +30 -0
  75. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +61 -0
  76. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +41 -0
  77. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +1 -0
  78. package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +1 -1
  79. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +555 -0
  80. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +32 -0
  81. package/dist/utils/grid-aggregation-utils.js +114 -0
  82. package/dist/utils/prop-utils.js +28 -0
  83. package/dist/utils/resource-utils.js +38 -0
  84. package/dist/utils/scale-utils.js +184 -0
  85. package/dist.min.js +299 -555
  86. package/package.json +19 -14
  87. package/src/aggregation-layer.ts +3 -2
  88. package/src/contour-layer/contour-layer.ts +2 -3
  89. package/src/cpu-grid-layer/cpu-grid-layer.ts +1 -2
  90. package/src/gpu-grid-layer/gpu-grid-cell-layer.ts +1 -1
  91. package/src/gpu-grid-layer/gpu-grid-layer.ts +2 -2
  92. package/src/heatmap-layer/heatmap-layer-utils.ts +0 -23
  93. package/src/heatmap-layer/heatmap-layer.ts +91 -127
  94. package/src/heatmap-layer/max-vs.glsl.ts +11 -5
  95. package/src/heatmap-layer/triangle-layer-fragment.glsl.ts +2 -2
  96. package/src/heatmap-layer/triangle-layer.ts +17 -23
  97. package/src/heatmap-layer/weights-vs.glsl.ts +4 -2
  98. package/src/hexagon-layer/hexagon-layer.ts +2 -3
  99. package/src/screen-grid-layer/screen-grid-cell-layer.ts +3 -6
  100. package/src/screen-grid-layer/screen-grid-layer.ts +1 -11
  101. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.ts +16 -30
  102. package/dist/es5/aggregation-layer.js +0 -215
  103. package/dist/es5/aggregation-layer.js.map +0 -1
  104. package/dist/es5/contour-layer/contour-layer.js +0 -353
  105. package/dist/es5/contour-layer/contour-layer.js.map +0 -1
  106. package/dist/es5/contour-layer/contour-utils.js +0 -110
  107. package/dist/es5/contour-layer/contour-utils.js.map +0 -1
  108. package/dist/es5/contour-layer/marching-squares-codes.js +0 -152
  109. package/dist/es5/contour-layer/marching-squares-codes.js.map +0 -1
  110. package/dist/es5/contour-layer/marching-squares.js +0 -168
  111. package/dist/es5/contour-layer/marching-squares.js.map +0 -1
  112. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +0 -235
  113. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +0 -1
  114. package/dist/es5/cpu-grid-layer/grid-aggregator.js +0 -180
  115. package/dist/es5/cpu-grid-layer/grid-aggregator.js.map +0 -1
  116. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -9
  117. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +0 -1
  118. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -9
  119. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +0 -1
  120. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +0 -247
  121. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +0 -1
  122. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +0 -424
  123. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +0 -1
  124. package/dist/es5/grid-aggregation-layer.js +0 -280
  125. package/dist/es5/grid-aggregation-layer.js.map +0 -1
  126. package/dist/es5/grid-layer/grid-layer.js +0 -125
  127. package/dist/es5/grid-layer/grid-layer.js.map +0 -1
  128. package/dist/es5/heatmap-layer/heatmap-layer-utils.js +0 -122
  129. package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +0 -1
  130. package/dist/es5/heatmap-layer/heatmap-layer.js +0 -672
  131. package/dist/es5/heatmap-layer/heatmap-layer.js.map +0 -1
  132. package/dist/es5/heatmap-layer/max-fs.glsl.js +0 -9
  133. package/dist/es5/heatmap-layer/max-fs.glsl.js.map +0 -1
  134. package/dist/es5/heatmap-layer/max-vs.glsl.js +0 -9
  135. package/dist/es5/heatmap-layer/max-vs.glsl.js.map +0 -1
  136. package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js +0 -9
  137. package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js.map +0 -1
  138. package/dist/es5/heatmap-layer/triangle-layer-vertex.glsl.js +0 -9
  139. package/dist/es5/heatmap-layer/triangle-layer-vertex.glsl.js.map +0 -1
  140. package/dist/es5/heatmap-layer/triangle-layer.js +0 -122
  141. package/dist/es5/heatmap-layer/triangle-layer.js.map +0 -1
  142. package/dist/es5/heatmap-layer/weights-fs.glsl.js +0 -9
  143. package/dist/es5/heatmap-layer/weights-fs.glsl.js.map +0 -1
  144. package/dist/es5/heatmap-layer/weights-vs.glsl.js +0 -9
  145. package/dist/es5/heatmap-layer/weights-vs.glsl.js.map +0 -1
  146. package/dist/es5/hexagon-layer/hexagon-aggregator.js +0 -118
  147. package/dist/es5/hexagon-layer/hexagon-aggregator.js.map +0 -1
  148. package/dist/es5/hexagon-layer/hexagon-layer.js +0 -289
  149. package/dist/es5/hexagon-layer/hexagon-layer.js.map +0 -1
  150. package/dist/es5/index.js +0 -104
  151. package/dist/es5/index.js.map +0 -1
  152. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +0 -244
  153. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +0 -1
  154. package/dist/es5/screen-grid-layer/screen-grid-layer-fragment.glsl.js +0 -9
  155. package/dist/es5/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +0 -1
  156. package/dist/es5/screen-grid-layer/screen-grid-layer-vertex.glsl.js +0 -9
  157. package/dist/es5/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +0 -1
  158. package/dist/es5/screen-grid-layer/screen-grid-layer.js +0 -317
  159. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +0 -1
  160. package/dist/es5/types.js +0 -2
  161. package/dist/es5/types.js.map +0 -1
  162. package/dist/es5/utils/aggregation-operation-utils.js +0 -123
  163. package/dist/es5/utils/aggregation-operation-utils.js.map +0 -1
  164. package/dist/es5/utils/bin-sorter.js +0 -248
  165. package/dist/es5/utils/bin-sorter.js.map +0 -1
  166. package/dist/es5/utils/color-utils.js +0 -39
  167. package/dist/es5/utils/color-utils.js.map +0 -1
  168. package/dist/es5/utils/cpu-aggregator.js +0 -496
  169. package/dist/es5/utils/cpu-aggregator.js.map +0 -1
  170. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -9
  171. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +0 -1
  172. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -9
  173. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +0 -1
  174. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -9
  175. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +0 -1
  176. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -9
  177. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +0 -1
  178. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -63
  179. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +0 -1
  180. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -2
  181. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js.map +0 -1
  182. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -732
  183. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +0 -1
  184. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
  185. package/dist/es5/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -9
  186. package/dist/es5/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +0 -1
  187. package/dist/es5/utils/grid-aggregation-utils.js +0 -118
  188. package/dist/es5/utils/grid-aggregation-utils.js.map +0 -1
  189. package/dist/es5/utils/prop-utils.js +0 -19
  190. package/dist/es5/utils/prop-utils.js.map +0 -1
  191. package/dist/es5/utils/resource-utils.js +0 -59
  192. package/dist/es5/utils/resource-utils.js.map +0 -1
  193. package/dist/es5/utils/scale-utils.js +0 -254
  194. package/dist/es5/utils/scale-utils.js.map +0 -1
  195. package/dist/esm/aggregation-layer.js +0 -156
  196. package/dist/esm/aggregation-layer.js.map +0 -1
  197. package/dist/esm/contour-layer/contour-layer.js +0 -316
  198. package/dist/esm/contour-layer/contour-layer.js.map +0 -1
  199. package/dist/esm/contour-layer/contour-utils.js +0 -81
  200. package/dist/esm/contour-layer/contour-utils.js.map +0 -1
  201. package/dist/esm/contour-layer/marching-squares-codes.js +0 -219
  202. package/dist/esm/contour-layer/marching-squares-codes.js.map +0 -1
  203. package/dist/esm/contour-layer/marching-squares.js +0 -151
  204. package/dist/esm/contour-layer/marching-squares.js.map +0 -1
  205. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +0 -186
  206. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +0 -1
  207. package/dist/esm/cpu-grid-layer/grid-aggregator.js +0 -142
  208. package/dist/esm/cpu-grid-layer/grid-aggregator.js.map +0 -1
  209. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -16
  210. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +0 -1
  211. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -122
  212. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +0 -1
  213. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js +0 -196
  214. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +0 -1
  215. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +0 -399
  216. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +0 -1
  217. package/dist/esm/grid-aggregation-layer.js +0 -240
  218. package/dist/esm/grid-aggregation-layer.js.map +0 -1
  219. package/dist/esm/grid-layer/grid-layer.js +0 -80
  220. package/dist/esm/grid-layer/grid-layer.js.map +0 -1
  221. package/dist/esm/heatmap-layer/heatmap-layer-utils.js +0 -68
  222. package/dist/esm/heatmap-layer/heatmap-layer-utils.js.map +0 -1
  223. package/dist/esm/heatmap-layer/heatmap-layer.js +0 -626
  224. package/dist/esm/heatmap-layer/heatmap-layer.js.map +0 -1
  225. package/dist/esm/heatmap-layer/max-fs.glsl.js +0 -10
  226. package/dist/esm/heatmap-layer/max-fs.glsl.js.map +0 -1
  227. package/dist/esm/heatmap-layer/max-vs.glsl.js +0 -14
  228. package/dist/esm/heatmap-layer/max-vs.glsl.js.map +0 -1
  229. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js +0 -43
  230. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js.map +0 -1
  231. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js +0 -33
  232. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js.map +0 -1
  233. package/dist/esm/heatmap-layer/triangle-layer.js +0 -80
  234. package/dist/esm/heatmap-layer/triangle-layer.js.map +0 -1
  235. package/dist/esm/heatmap-layer/weights-fs.glsl.js +0 -22
  236. package/dist/esm/heatmap-layer/weights-fs.glsl.js.map +0 -1
  237. package/dist/esm/heatmap-layer/weights-vs.glsl.js +0 -25
  238. package/dist/esm/heatmap-layer/weights-vs.glsl.js.map +0 -1
  239. package/dist/esm/hexagon-layer/hexagon-aggregator.js +0 -87
  240. package/dist/esm/hexagon-layer/hexagon-aggregator.js.map +0 -1
  241. package/dist/esm/hexagon-layer/hexagon-layer.js +0 -232
  242. package/dist/esm/hexagon-layer/hexagon-layer.js.map +0 -1
  243. package/dist/esm/index.js +0 -13
  244. package/dist/esm/index.js.map +0 -1
  245. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +0 -203
  246. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +0 -1
  247. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js +0 -21
  248. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +0 -1
  249. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js +0 -66
  250. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +0 -1
  251. package/dist/esm/screen-grid-layer/screen-grid-layer.js +0 -285
  252. package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +0 -1
  253. package/dist/esm/types.js +0 -2
  254. package/dist/esm/types.js.map +0 -1
  255. package/dist/esm/utils/aggregation-operation-utils.js +0 -91
  256. package/dist/esm/utils/aggregation-operation-utils.js.map +0 -1
  257. package/dist/esm/utils/bin-sorter.js +0 -165
  258. package/dist/esm/utils/bin-sorter.js.map +0 -1
  259. package/dist/esm/utils/color-utils.js +0 -28
  260. package/dist/esm/utils/color-utils.js.map +0 -1
  261. package/dist/esm/utils/cpu-aggregator.js +0 -487
  262. package/dist/esm/utils/cpu-aggregator.js.map +0 -1
  263. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -21
  264. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +0 -1
  265. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -35
  266. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +0 -1
  267. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -16
  268. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +0 -1
  269. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -60
  270. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +0 -1
  271. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -42
  272. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +0 -1
  273. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -2
  274. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js.map +0 -1
  275. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -720
  276. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +0 -1
  277. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
  278. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -19
  279. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +0 -1
  280. package/dist/esm/utils/grid-aggregation-utils.js +0 -109
  281. package/dist/esm/utils/grid-aggregation-utils.js.map +0 -1
  282. package/dist/esm/utils/prop-utils.js +0 -12
  283. package/dist/esm/utils/prop-utils.js.map +0 -1
  284. package/dist/esm/utils/resource-utils.js +0 -44
  285. package/dist/esm/utils/resource-utils.js.map +0 -1
  286. package/dist/esm/utils/scale-utils.js +0 -192
  287. package/dist/esm/utils/scale-utils.js.map +0 -1
  288. package/typed/aggregation-layer.d.ts.map +0 -1
  289. package/typed/contour-layer/contour-layer.d.ts.map +0 -1
  290. package/typed/cpu-grid-layer/cpu-grid-layer.d.ts.map +0 -1
  291. package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +0 -1
  292. package/typed/gpu-grid-layer/gpu-grid-layer.d.ts.map +0 -1
  293. package/typed/grid-aggregation-layer.d.ts.map +0 -1
  294. package/typed/grid-layer/grid-layer.d.ts.map +0 -1
  295. package/typed/heatmap-layer/heatmap-layer-utils.d.ts.map +0 -1
  296. package/typed/heatmap-layer/heatmap-layer.d.ts.map +0 -1
  297. package/typed/heatmap-layer/max-vs.glsl.d.ts +0 -3
  298. package/typed/heatmap-layer/triangle-layer-fragment.glsl.d.ts +0 -3
  299. package/typed/heatmap-layer/triangle-layer.d.ts.map +0 -1
  300. package/typed/heatmap-layer/weights-vs.glsl.d.ts +0 -3
  301. package/typed/hexagon-layer/hexagon-layer.d.ts.map +0 -1
  302. package/typed/index.d.ts +0 -20
  303. package/typed/index.d.ts.map +0 -1
  304. package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts.map +0 -1
  305. package/typed/screen-grid-layer/screen-grid-layer.d.ts.map +0 -1
  306. /package/{typed → dist}/contour-layer/contour-utils.d.ts +0 -0
  307. /package/{typed → dist}/contour-layer/contour-utils.d.ts.map +0 -0
  308. /package/{typed → dist}/contour-layer/marching-squares-codes.d.ts +0 -0
  309. /package/{typed → dist}/contour-layer/marching-squares-codes.d.ts.map +0 -0
  310. /package/{typed → dist}/contour-layer/marching-squares.d.ts +0 -0
  311. /package/{typed → dist}/contour-layer/marching-squares.d.ts.map +0 -0
  312. /package/{typed → dist}/cpu-grid-layer/grid-aggregator.d.ts +0 -0
  313. /package/{typed → dist}/cpu-grid-layer/grid-aggregator.d.ts.map +0 -0
  314. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +0 -0
  315. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +0 -0
  316. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +0 -0
  317. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +0 -0
  318. /package/{typed → dist}/heatmap-layer/max-fs.glsl.d.ts +0 -0
  319. /package/{typed → dist}/heatmap-layer/max-fs.glsl.d.ts.map +0 -0
  320. /package/{typed → dist}/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +0 -0
  321. /package/{typed → dist}/heatmap-layer/triangle-layer-vertex.glsl.d.ts +0 -0
  322. /package/{typed → dist}/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +0 -0
  323. /package/{typed → dist}/heatmap-layer/weights-fs.glsl.d.ts +0 -0
  324. /package/{typed → dist}/heatmap-layer/weights-fs.glsl.d.ts.map +0 -0
  325. /package/{typed → dist}/hexagon-layer/hexagon-aggregator.d.ts +0 -0
  326. /package/{typed → dist}/hexagon-layer/hexagon-aggregator.d.ts.map +0 -0
  327. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +0 -0
  328. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +0 -0
  329. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +0 -0
  330. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +0 -0
  331. /package/{typed → dist}/types.d.ts +0 -0
  332. /package/{typed → dist}/types.d.ts.map +0 -0
  333. /package/{typed → dist}/utils/aggregation-operation-utils.d.ts +0 -0
  334. /package/{typed → dist}/utils/aggregation-operation-utils.d.ts.map +0 -0
  335. /package/{typed → dist}/utils/bin-sorter.d.ts.map +0 -0
  336. /package/{typed → dist}/utils/color-utils.d.ts +0 -0
  337. /package/{typed → dist}/utils/color-utils.d.ts.map +0 -0
  338. /package/{typed → dist}/utils/cpu-aggregator.d.ts +0 -0
  339. /package/{typed → dist}/utils/cpu-aggregator.d.ts.map +0 -0
  340. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +0 -0
  341. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +0 -0
  342. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +0 -0
  343. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +0 -0
  344. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +0 -0
  345. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +0 -0
  346. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +0 -0
  347. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +0 -0
  348. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +0 -0
  349. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +0 -0
  350. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts +0 -0
  351. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +0 -0
  352. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +0 -0
  353. /package/{typed → dist}/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +0 -0
  354. /package/{typed → dist}/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +0 -0
  355. /package/{typed → dist}/utils/grid-aggregation-utils.d.ts +0 -0
  356. /package/{typed → dist}/utils/grid-aggregation-utils.d.ts.map +0 -0
  357. /package/{typed → dist}/utils/prop-utils.d.ts +0 -0
  358. /package/{typed → dist}/utils/prop-utils.d.ts.map +0 -0
  359. /package/{typed → dist}/utils/resource-utils.d.ts +0 -0
  360. /package/{typed → dist}/utils/resource-utils.d.ts.map +0 -0
  361. /package/{typed → dist}/utils/scale-utils.d.ts +0 -0
  362. /package/{typed → dist}/utils/scale-utils.d.ts.map +0 -0
@@ -0,0 +1,455 @@
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
+ /* global setTimeout clearTimeout */
21
+ import { getBounds, boundsContain, packVertices, scaleToAspectRatio, getTextureCoordinates } from "./heatmap-layer-utils.js";
22
+ import { TextureTransform } from '@luma.gl/engine';
23
+ import { AttributeManager, COORDINATE_SYSTEM, log } from '@deck.gl/core';
24
+ import TriangleLayer from "./triangle-layer.js";
25
+ import AggregationLayer from "../aggregation-layer.js";
26
+ import { defaultColorRange, colorRangeToFlatArray } from "../utils/color-utils.js";
27
+ import weightsVs from "./weights-vs.glsl.js";
28
+ import weightsFs from "./weights-fs.glsl.js";
29
+ import maxVs from "./max-vs.glsl.js";
30
+ import maxFs from "./max-fs.glsl.js";
31
+ const RESOLUTION = 2; // (number of common space pixels) / (number texels)
32
+ const TEXTURE_PROPS = {
33
+ format: 'rgba8unorm',
34
+ mipmaps: false,
35
+ sampler: {
36
+ minFilter: 'linear',
37
+ magFilter: 'linear',
38
+ addressModeU: 'clamp-to-edge',
39
+ addressModeV: 'clamp-to-edge'
40
+ }
41
+ };
42
+ const DEFAULT_COLOR_DOMAIN = [0, 0];
43
+ const AGGREGATION_MODE = {
44
+ SUM: 0,
45
+ MEAN: 1
46
+ };
47
+ const defaultProps = {
48
+ getPosition: { type: 'accessor', value: (x) => x.position },
49
+ getWeight: { type: 'accessor', value: 1 },
50
+ intensity: { type: 'number', min: 0, value: 1 },
51
+ radiusPixels: { type: 'number', min: 1, max: 100, value: 50 },
52
+ colorRange: defaultColorRange,
53
+ threshold: { type: 'number', min: 0, max: 1, value: 0.05 },
54
+ colorDomain: { type: 'array', value: null, optional: true },
55
+ // 'SUM' or 'MEAN'
56
+ aggregation: 'SUM',
57
+ weightsTextureSize: { type: 'number', min: 128, max: 2048, value: 2048 },
58
+ debounceTimeout: { type: 'number', min: 0, max: 1000, value: 500 }
59
+ };
60
+ const FLOAT_TARGET_FEATURES = [
61
+ 'float32-renderable-webgl', // ability to render to float texture
62
+ 'texture-blend-float-webgl' // ability to blend when rendering to float texture
63
+ ];
64
+ const DIMENSIONS = {
65
+ data: {
66
+ props: ['radiusPixels']
67
+ }
68
+ };
69
+ /** Visualizes the spatial distribution of data. */
70
+ export default class HeatmapLayer extends AggregationLayer {
71
+ static { this.layerName = 'HeatmapLayer'; }
72
+ static { this.defaultProps = defaultProps; }
73
+ initializeState() {
74
+ super.initializeAggregationLayer(DIMENSIONS);
75
+ this.setState({ colorDomain: DEFAULT_COLOR_DOMAIN });
76
+ this._setupTextureParams();
77
+ this._setupAttributes();
78
+ this._setupResources();
79
+ }
80
+ shouldUpdateState({ changeFlags }) {
81
+ // Need to be updated when viewport changes
82
+ return changeFlags.somethingChanged;
83
+ }
84
+ /* eslint-disable max-statements,complexity */
85
+ updateState(opts) {
86
+ super.updateState(opts);
87
+ this._updateHeatmapState(opts);
88
+ }
89
+ _updateHeatmapState(opts) {
90
+ const { props, oldProps } = opts;
91
+ const changeFlags = this._getChangeFlags(opts);
92
+ if (changeFlags.dataChanged || changeFlags.viewportChanged) {
93
+ // if data is changed, do not debounce and immediately update the weight map
94
+ changeFlags.boundsChanged = this._updateBounds(changeFlags.dataChanged);
95
+ this._updateTextureRenderingBounds();
96
+ }
97
+ if (changeFlags.dataChanged || changeFlags.boundsChanged) {
98
+ // Update weight map immediately
99
+ clearTimeout(this.state.updateTimer);
100
+ this.setState({ isWeightMapDirty: true });
101
+ }
102
+ else if (changeFlags.viewportZoomChanged) {
103
+ // Update weight map when zoom stops
104
+ this._debouncedUpdateWeightmap();
105
+ }
106
+ if (props.colorRange !== oldProps.colorRange) {
107
+ this._updateColorTexture(opts);
108
+ }
109
+ if (this.state.isWeightMapDirty) {
110
+ this._updateWeightmap();
111
+ }
112
+ this.setState({ zoom: opts.context.viewport.zoom });
113
+ }
114
+ renderLayers() {
115
+ const { weightsTexture, triPositionBuffer, triTexCoordBuffer, maxWeightsTexture, colorTexture, colorDomain } = this.state;
116
+ const { updateTriggers, intensity, threshold, aggregation } = this.props;
117
+ const TriangleLayerClass = this.getSubLayerClass('triangle', TriangleLayer);
118
+ return new TriangleLayerClass(this.getSubLayerProps({
119
+ id: 'triangle-layer',
120
+ updateTriggers
121
+ }), {
122
+ // position buffer is filled with world coordinates generated from viewport.unproject
123
+ // i.e. LNGLAT if geospatial, CARTESIAN otherwise
124
+ coordinateSystem: COORDINATE_SYSTEM.DEFAULT,
125
+ data: {
126
+ attributes: {
127
+ positions: triPositionBuffer,
128
+ texCoords: triTexCoordBuffer
129
+ }
130
+ },
131
+ vertexCount: 4,
132
+ maxTexture: maxWeightsTexture,
133
+ colorTexture,
134
+ aggregationMode: AGGREGATION_MODE[aggregation] || 0,
135
+ weightsTexture,
136
+ intensity,
137
+ threshold,
138
+ colorDomain
139
+ });
140
+ }
141
+ finalizeState(context) {
142
+ super.finalizeState(context);
143
+ const { weightsTransform, weightsTexture, maxWeightTransform, maxWeightsTexture, triPositionBuffer, triTexCoordBuffer, colorTexture, updateTimer } = this.state;
144
+ weightsTransform?.destroy();
145
+ weightsTexture?.destroy();
146
+ maxWeightTransform?.destroy();
147
+ maxWeightsTexture?.destroy();
148
+ triPositionBuffer?.destroy();
149
+ triTexCoordBuffer?.destroy();
150
+ colorTexture?.destroy();
151
+ if (updateTimer) {
152
+ clearTimeout(updateTimer);
153
+ }
154
+ }
155
+ // PRIVATE
156
+ // override Composite layer private method to create AttributeManager instance
157
+ _getAttributeManager() {
158
+ return new AttributeManager(this.context.device, {
159
+ id: this.props.id,
160
+ stats: this.context.stats
161
+ });
162
+ }
163
+ _getChangeFlags(opts) {
164
+ const changeFlags = {};
165
+ const { dimensions } = this.state;
166
+ changeFlags.dataChanged =
167
+ (this.isAttributeChanged() && 'attribute changed') || // if any attribute is changed
168
+ (this.isAggregationDirty(opts, {
169
+ compareAll: true,
170
+ dimension: dimensions.data
171
+ }) &&
172
+ 'aggregation is dirty');
173
+ changeFlags.viewportChanged = opts.changeFlags.viewportChanged;
174
+ const { zoom } = this.state;
175
+ if (!opts.context.viewport || opts.context.viewport.zoom !== zoom) {
176
+ changeFlags.viewportZoomChanged = true;
177
+ }
178
+ return changeFlags;
179
+ }
180
+ _createTextures() {
181
+ const { textureSize, format } = this.state;
182
+ this.setState({
183
+ weightsTexture: this.context.device.createTexture({
184
+ ...TEXTURE_PROPS,
185
+ width: textureSize,
186
+ height: textureSize,
187
+ format
188
+ }),
189
+ maxWeightsTexture: this.context.device.createTexture({
190
+ ...TEXTURE_PROPS,
191
+ width: 1,
192
+ height: 1,
193
+ format
194
+ })
195
+ });
196
+ }
197
+ _setupAttributes() {
198
+ const attributeManager = this.getAttributeManager();
199
+ attributeManager.add({
200
+ positions: { size: 3, type: 'float64', accessor: 'getPosition' },
201
+ weights: { size: 1, accessor: 'getWeight' }
202
+ });
203
+ this.setState({ positionAttributeName: 'positions' });
204
+ }
205
+ _setupTextureParams() {
206
+ const { device } = this.context;
207
+ const { weightsTextureSize } = this.props;
208
+ const textureSize = Math.min(weightsTextureSize, device.limits.maxTextureDimension2D);
209
+ const floatTargetSupport = FLOAT_TARGET_FEATURES.every(feature => device.features.has(feature));
210
+ const format = floatTargetSupport ? 'rgba32float' : 'rgba8unorm';
211
+ const weightsScale = floatTargetSupport ? 1 : 1 / 255;
212
+ this.setState({ textureSize, format, weightsScale });
213
+ if (!floatTargetSupport) {
214
+ log.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`)();
215
+ }
216
+ }
217
+ _createWeightsTransform(shaders) {
218
+ let { weightsTransform } = this.state;
219
+ const { weightsTexture } = this.state;
220
+ const attributeManager = this.getAttributeManager();
221
+ weightsTransform?.destroy();
222
+ weightsTransform = new TextureTransform(this.context.device, {
223
+ id: `${this.id}-weights-transform`,
224
+ bufferLayout: attributeManager.getBufferLayouts(),
225
+ vertexCount: 1,
226
+ targetTexture: weightsTexture,
227
+ parameters: {
228
+ depthWriteEnabled: false,
229
+ blendColorOperation: 'add',
230
+ blendColorSrcFactor: 'one',
231
+ blendColorDstFactor: 'one',
232
+ blendAlphaSrcFactor: 'one',
233
+ blendAlphaDstFactor: 'one'
234
+ },
235
+ topology: 'point-list',
236
+ ...shaders
237
+ });
238
+ this.setState({ weightsTransform });
239
+ }
240
+ _setupResources() {
241
+ this._createTextures();
242
+ const { device } = this.context;
243
+ const { textureSize, weightsTexture, maxWeightsTexture } = this.state;
244
+ const weightsTransformShaders = this.getShaders({
245
+ vs: weightsVs,
246
+ fs: weightsFs
247
+ });
248
+ this._createWeightsTransform(weightsTransformShaders);
249
+ const maxWeightsTransformShaders = this.getShaders({ vs: maxVs, fs: maxFs });
250
+ const maxWeightTransform = new TextureTransform(device, {
251
+ id: `${this.id}-max-weights-transform`,
252
+ bindings: { inTexture: weightsTexture },
253
+ uniforms: { textureSize },
254
+ targetTexture: maxWeightsTexture,
255
+ ...maxWeightsTransformShaders,
256
+ vertexCount: textureSize * textureSize,
257
+ topology: 'point-list',
258
+ parameters: {
259
+ depthWriteEnabled: false,
260
+ blendColorOperation: 'max',
261
+ blendAlphaOperation: 'max',
262
+ blendColorSrcFactor: 'one',
263
+ blendColorDstFactor: 'one',
264
+ blendAlphaSrcFactor: 'one',
265
+ blendAlphaDstFactor: 'one'
266
+ }
267
+ });
268
+ this.setState({
269
+ weightsTexture,
270
+ maxWeightsTexture,
271
+ maxWeightTransform,
272
+ zoom: null,
273
+ triPositionBuffer: device.createBuffer({ byteLength: 48 }),
274
+ triTexCoordBuffer: device.createBuffer({ byteLength: 48 })
275
+ });
276
+ }
277
+ // overwrite super class method to update transform model
278
+ updateShaders(shaderOptions) {
279
+ // shader params (modules, injects) changed, update model object
280
+ this._createWeightsTransform({
281
+ vs: weightsVs,
282
+ fs: weightsFs,
283
+ ...shaderOptions
284
+ });
285
+ }
286
+ _updateMaxWeightValue() {
287
+ const { maxWeightTransform } = this.state;
288
+ maxWeightTransform.run({
289
+ parameters: { viewport: [0, 0, 1, 1] },
290
+ clearColor: [0, 0, 0, 0]
291
+ });
292
+ }
293
+ // Computes world bounds area that needs to be processed for generate heatmap
294
+ _updateBounds(forceUpdate = false) {
295
+ const { viewport } = this.context;
296
+ // Unproject all 4 corners of the current screen coordinates into world coordinates (lng/lat)
297
+ // Takes care of viewport has non zero bearing/pitch (i.e axis not aligned with world coordiante system)
298
+ const viewportCorners = [
299
+ viewport.unproject([0, 0]),
300
+ viewport.unproject([viewport.width, 0]),
301
+ viewport.unproject([viewport.width, viewport.height]),
302
+ viewport.unproject([0, viewport.height])
303
+ ].map(p => p.map(Math.fround));
304
+ // #1: get world bounds for current viewport extends
305
+ const visibleWorldBounds = getBounds(viewportCorners); // TODO: Change to visible bounds
306
+ const newState = { visibleWorldBounds, viewportCorners };
307
+ let boundsChanged = false;
308
+ if (forceUpdate ||
309
+ !this.state.worldBounds ||
310
+ !boundsContain(this.state.worldBounds, visibleWorldBounds)) {
311
+ // #2 : convert world bounds to common (Flat) bounds
312
+ // #3 : extend common bounds to match aspect ratio with viewport
313
+ const scaledCommonBounds = this._worldToCommonBounds(visibleWorldBounds);
314
+ // #4 :convert aligned common bounds to world bounds
315
+ const worldBounds = this._commonToWorldBounds(scaledCommonBounds);
316
+ // Clip webmercator projection limits
317
+ if (this.props.coordinateSystem === COORDINATE_SYSTEM.LNGLAT) {
318
+ worldBounds[1] = Math.max(worldBounds[1], -85.051129);
319
+ worldBounds[3] = Math.min(worldBounds[3], 85.051129);
320
+ worldBounds[0] = Math.max(worldBounds[0], -360);
321
+ worldBounds[2] = Math.min(worldBounds[2], 360);
322
+ }
323
+ // #5: now convert world bounds to common using Layer's coordiante system and origin
324
+ const normalizedCommonBounds = this._worldToCommonBounds(worldBounds);
325
+ newState.worldBounds = worldBounds;
326
+ newState.normalizedCommonBounds = normalizedCommonBounds;
327
+ boundsChanged = true;
328
+ }
329
+ this.setState(newState);
330
+ return boundsChanged;
331
+ }
332
+ _updateTextureRenderingBounds() {
333
+ // Just render visible portion of the texture
334
+ const { triPositionBuffer, triTexCoordBuffer, normalizedCommonBounds, viewportCorners } = this.state;
335
+ const { viewport } = this.context;
336
+ triPositionBuffer.write(packVertices(viewportCorners, 3));
337
+ const textureBounds = viewportCorners.map(p => getTextureCoordinates(viewport.projectPosition(p), normalizedCommonBounds));
338
+ triTexCoordBuffer.write(packVertices(textureBounds, 2));
339
+ }
340
+ _updateColorTexture(opts) {
341
+ const { colorRange } = opts.props;
342
+ let { colorTexture } = this.state;
343
+ const colors = colorRangeToFlatArray(colorRange, false, Uint8Array);
344
+ if (colorTexture && colorTexture?.width === colorRange.length) {
345
+ // TODO(v9): Unclear whether `setSubImageData` is a public API, or what to use if not.
346
+ colorTexture.setSubImageData({ data: colors });
347
+ }
348
+ else {
349
+ colorTexture?.destroy();
350
+ colorTexture = this.context.device.createTexture({
351
+ ...TEXTURE_PROPS,
352
+ data: colors,
353
+ width: colorRange.length,
354
+ height: 1
355
+ });
356
+ }
357
+ this.setState({ colorTexture });
358
+ }
359
+ _updateWeightmap() {
360
+ const { radiusPixels, colorDomain, aggregation } = this.props;
361
+ const { worldBounds, textureSize, weightsScale } = this.state;
362
+ const weightsTransform = this.state.weightsTransform;
363
+ this.state.isWeightMapDirty = false;
364
+ // convert world bounds to common using Layer's coordiante system and origin
365
+ const commonBounds = this._worldToCommonBounds(worldBounds, {
366
+ useLayerCoordinateSystem: true
367
+ });
368
+ if (colorDomain && aggregation === 'SUM') {
369
+ // scale color domain to weight per pixel
370
+ const { viewport } = this.context;
371
+ const metersPerPixel = (viewport.distanceScales.metersPerUnit[2] * (commonBounds[2] - commonBounds[0])) /
372
+ textureSize;
373
+ this.state.colorDomain = colorDomain.map(x => x * metersPerPixel * weightsScale);
374
+ }
375
+ else {
376
+ this.state.colorDomain = colorDomain || DEFAULT_COLOR_DOMAIN;
377
+ }
378
+ const attributeManager = this.getAttributeManager();
379
+ const attributes = attributeManager.getAttributes();
380
+ const moduleSettings = this.getModuleSettings();
381
+ const positions = attributes.positions.buffer;
382
+ const uniforms = { radiusPixels, commonBounds, textureWidth: textureSize, weightsScale };
383
+ const weights = attributes.weights.buffer;
384
+ weightsTransform.model.setAttributes({ positions, weights });
385
+ weightsTransform.model.setVertexCount(this.getNumInstances());
386
+ weightsTransform.model.setUniforms(uniforms);
387
+ weightsTransform.model.updateModuleSettings(moduleSettings);
388
+ weightsTransform.run({
389
+ parameters: { viewport: [0, 0, textureSize, textureSize] },
390
+ clearColor: [0, 0, 0, 0]
391
+ });
392
+ this._updateMaxWeightValue();
393
+ }
394
+ _debouncedUpdateWeightmap(fromTimer = false) {
395
+ let { updateTimer } = this.state;
396
+ const { debounceTimeout } = this.props;
397
+ if (fromTimer) {
398
+ updateTimer = null;
399
+ // update
400
+ this._updateBounds(true);
401
+ this._updateTextureRenderingBounds();
402
+ this.setState({ isWeightMapDirty: true });
403
+ }
404
+ else {
405
+ this.setState({ isWeightMapDirty: false });
406
+ clearTimeout(updateTimer);
407
+ updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), debounceTimeout);
408
+ }
409
+ this.setState({ updateTimer });
410
+ }
411
+ // input: worldBounds: [minLong, minLat, maxLong, maxLat]
412
+ // input: opts.useLayerCoordinateSystem : layers coordiante system is used
413
+ // optput: commonBounds: [minX, minY, maxX, maxY] scaled to fit the current texture
414
+ _worldToCommonBounds(worldBounds, opts = {}) {
415
+ const { useLayerCoordinateSystem = false } = opts;
416
+ const [minLong, minLat, maxLong, maxLat] = worldBounds;
417
+ const { viewport } = this.context;
418
+ const { textureSize } = this.state;
419
+ const { coordinateSystem } = this.props;
420
+ const offsetMode = useLayerCoordinateSystem &&
421
+ (coordinateSystem === COORDINATE_SYSTEM.LNGLAT_OFFSETS ||
422
+ coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS);
423
+ const offsetOriginCommon = offsetMode
424
+ ? viewport.projectPosition(this.props.coordinateOrigin)
425
+ : [0, 0];
426
+ const size = (textureSize * RESOLUTION) / viewport.scale;
427
+ let bottomLeftCommon;
428
+ let topRightCommon;
429
+ // Y-axis is flipped between World and Common bounds
430
+ if (useLayerCoordinateSystem && !offsetMode) {
431
+ bottomLeftCommon = this.projectPosition([minLong, minLat, 0]);
432
+ topRightCommon = this.projectPosition([maxLong, maxLat, 0]);
433
+ }
434
+ else {
435
+ bottomLeftCommon = viewport.projectPosition([minLong, minLat, 0]);
436
+ topRightCommon = viewport.projectPosition([maxLong, maxLat, 0]);
437
+ }
438
+ // Ignore z component
439
+ return scaleToAspectRatio([
440
+ bottomLeftCommon[0] - offsetOriginCommon[0],
441
+ bottomLeftCommon[1] - offsetOriginCommon[1],
442
+ topRightCommon[0] - offsetOriginCommon[0],
443
+ topRightCommon[1] - offsetOriginCommon[1]
444
+ ], size, size);
445
+ }
446
+ // input commonBounds: [xMin, yMin, xMax, yMax]
447
+ // output worldBounds: [minLong, minLat, maxLong, maxLat]
448
+ _commonToWorldBounds(commonBounds) {
449
+ const [xMin, yMin, xMax, yMax] = commonBounds;
450
+ const { viewport } = this.context;
451
+ const bottomLeftWorld = viewport.unprojectPosition([xMin, yMin]);
452
+ const topRightWorld = viewport.unprojectPosition([xMax, yMax]);
453
+ return bottomLeftWorld.slice(0, 2).concat(topRightWorld.slice(0, 2));
454
+ }
455
+ }
@@ -0,0 +1,9 @@
1
+ export default `\
2
+ #version 300 es
3
+ in vec4 outTexture;
4
+ out vec4 fragColor;
5
+ void main() {
6
+ fragColor = outTexture;
7
+ fragColor.g = outTexture.r / max(1.0, outTexture.a);
8
+ }
9
+ `;
@@ -0,0 +1,3 @@
1
+ declare const _default: "#version 300 es\nuniform sampler2D inTexture;\nuniform float textureSize;\nout vec4 outTexture;\n\nvoid main()\n{\n // Sample every pixel in texture\n int yIndex = gl_VertexID / int(textureSize);\n int xIndex = gl_VertexID - (yIndex * int(textureSize));\n vec2 uv = (0.5 + vec2(float(xIndex), float(yIndex))) / textureSize;\n outTexture = texture(inTexture, uv);\n\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n // Enforce default value for ANGLE issue (https://bugs.chromium.org/p/angleproject/issues/detail?id=3941)\n gl_PointSize = 1.0;\n}\n";
2
+ export default _default;
3
+ //# sourceMappingURL=max-vs.glsl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"max-vs.glsl.d.ts","sourceRoot":"","sources":["../../src/heatmap-layer/max-vs.glsl.ts"],"names":[],"mappings":";AAAA,wBAYE"}
1
+ {"version":3,"file":"max-vs.glsl.d.ts","sourceRoot":"","sources":["../../src/heatmap-layer/max-vs.glsl.ts"],"names":[],"mappings":";AAAA,wBAkBE"}
@@ -0,0 +1,15 @@
1
+ export default `\
2
+ #version 300 es
3
+ uniform sampler2D inTexture;
4
+ uniform float textureSize;
5
+ out vec4 outTexture;
6
+ void main()
7
+ {
8
+ int yIndex = gl_VertexID / int(textureSize);
9
+ int xIndex = gl_VertexID - (yIndex * int(textureSize));
10
+ vec2 uv = (0.5 + vec2(float(xIndex), float(yIndex))) / textureSize;
11
+ outTexture = texture(inTexture, uv);
12
+ gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
13
+ gl_PointSize = 1.0;
14
+ }
15
+ `;
@@ -0,0 +1,3 @@
1
+ declare const _default: "#version 300 es\n#define SHADER_NAME triangle-layer-fragment-shader\n\nprecision highp float;\n\nuniform float opacity;\nuniform sampler2D weightsTexture;\nuniform sampler2D colorTexture;\nuniform float aggregationMode;\n\nin vec2 vTexCoords;\nin float vIntensityMin;\nin float vIntensityMax;\n\nout vec4 fragColor;\n\nvec4 getLinearColor(float value) {\n float factor = clamp(value * vIntensityMax, 0., 1.);\n vec4 color = texture(colorTexture, vec2(factor, 0.5));\n color.a *= min(value * vIntensityMin, 1.0);\n return color;\n}\n\nvoid main(void) {\n vec4 weights = texture(weightsTexture, vTexCoords);\n float weight = weights.r;\n\n if (aggregationMode > 0.5) {\n weight /= max(1.0, weights.a);\n }\n\n // discard pixels with 0 weight.\n if (weight <= 0.) {\n discard;\n }\n\n vec4 linearColor = getLinearColor(weight);\n linearColor.a *= opacity;\n fragColor = linearColor;\n}\n";
2
+ export default _default;
3
+ //# sourceMappingURL=triangle-layer-fragment.glsl.d.ts.map
@@ -0,0 +1,51 @@
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 `\
21
+ #version 300 es
22
+ #define SHADER_NAME triangle-layer-fragment-shader
23
+ precision highp float;
24
+ uniform float opacity;
25
+ uniform sampler2D weightsTexture;
26
+ uniform sampler2D colorTexture;
27
+ uniform float aggregationMode;
28
+ in vec2 vTexCoords;
29
+ in float vIntensityMin;
30
+ in float vIntensityMax;
31
+ out vec4 fragColor;
32
+ vec4 getLinearColor(float value) {
33
+ float factor = clamp(value * vIntensityMax, 0., 1.);
34
+ vec4 color = texture(colorTexture, vec2(factor, 0.5));
35
+ color.a *= min(value * vIntensityMin, 1.0);
36
+ return color;
37
+ }
38
+ void main(void) {
39
+ vec4 weights = texture(weightsTexture, vTexCoords);
40
+ float weight = weights.r;
41
+ if (aggregationMode > 0.5) {
42
+ weight /= max(1.0, weights.a);
43
+ }
44
+ if (weight <= 0.) {
45
+ discard;
46
+ }
47
+ vec4 linearColor = getLinearColor(weight);
48
+ linearColor.a *= opacity;
49
+ fragColor = linearColor;
50
+ }
51
+ `;
@@ -0,0 +1,47 @@
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
+ // Inspired by screen-grid-layer vertex shader in deck.gl
21
+ export default `\
22
+ #version 300 es
23
+ #define SHADER_NAME heatp-map-layer-vertex-shader
24
+ uniform sampler2D maxTexture;
25
+ uniform float intensity;
26
+ uniform vec2 colorDomain;
27
+ uniform float threshold;
28
+ uniform float aggregationMode;
29
+ in vec3 positions;
30
+ in vec2 texCoords;
31
+ out vec2 vTexCoords;
32
+ out float vIntensityMin;
33
+ out float vIntensityMax;
34
+ void main(void) {
35
+ gl_Position = project_position_to_clipspace(positions, vec3(0.0), vec3(0.0));
36
+ vTexCoords = texCoords;
37
+ vec4 maxTexture = texture(maxTexture, vec2(0.5));
38
+ float maxValue = aggregationMode < 0.5 ? maxTexture.r : maxTexture.g;
39
+ float minValue = maxValue * threshold;
40
+ if (colorDomain[1] > 0.) {
41
+ maxValue = colorDomain[1];
42
+ minValue = colorDomain[0];
43
+ }
44
+ vIntensityMax = intensity / maxValue;
45
+ vIntensityMin = intensity / minValue;
46
+ }
47
+ `;
@@ -1,7 +1,13 @@
1
- import type { Device, Texture } from '@luma.gl/core';
1
+ import type { Buffer, Device, Texture } from '@luma.gl/core';
2
2
  import { Model } from '@luma.gl/engine';
3
3
  import { Layer, LayerContext } from '@deck.gl/core';
4
4
  type _TriangleLayerProps = {
5
+ data: {
6
+ attributes: {
7
+ positions: Buffer;
8
+ texCoords: Buffer;
9
+ };
10
+ };
5
11
  colorDomain: number[];
6
12
  aggregationMode: string;
7
13
  threshold: number;
@@ -9,12 +15,14 @@ type _TriangleLayerProps = {
9
15
  vertexCount: number;
10
16
  colorTexture: Texture;
11
17
  maxTexture: Texture;
12
- texture: Texture;
18
+ weightsTexture: Texture;
13
19
  };
14
20
  export default class TriangleLayer extends Layer<_TriangleLayerProps> {
15
21
  static layerName: string;
16
22
  state: {
17
23
  model: Model;
24
+ positions: Buffer;
25
+ texCoords: Buffer;
18
26
  };
19
27
  getShaders(): {
20
28
  vs: string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"triangle-layer.d.ts","sourceRoot":"","sources":["../../src/heatmap-layer/triangle-layer.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAC,KAAK,EAAE,YAAY,EAAY,MAAM,eAAe,CAAC;AAI7D,KAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE;QAAC,UAAU,EAAE;YAAC,SAAS,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAC,CAAA;KAAC,CAAC;IAC3D,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,KAAK,CAAC,mBAAmB,CAAC;IACnE,MAAM,CAAC,SAAS,SAAmB;IAEnC,KAAK,EAAG;QACN,KAAK,EAAE,KAAK,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IAEF,UAAU;;;;;IAIV,eAAe,CAAC,EAAC,MAAM,EAAC,EAAE,YAAY,GAAG,IAAI;IAI7C,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK;IAiBhC,IAAI,CAAC,EAAC,QAAQ,EAAC;;KAAA,GAAG,IAAI;CAYvB"}