@deck.gl/aggregation-layers 9.0.0-beta.2 → 9.0.0-beta.4

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 (335) hide show
  1. package/dist/aggregation-layer.js +153 -0
  2. package/{typed → dist}/contour-layer/contour-layer.d.ts +1 -1
  3. package/dist/contour-layer/contour-layer.d.ts.map +1 -0
  4. package/dist/contour-layer/contour-layer.js +241 -0
  5. package/dist/contour-layer/contour-utils.js +64 -0
  6. package/dist/contour-layer/marching-squares-codes.js +337 -0
  7. package/dist/contour-layer/marching-squares.js +147 -0
  8. package/{typed → dist}/cpu-grid-layer/cpu-grid-layer.d.ts +3 -3
  9. package/dist/cpu-grid-layer/cpu-grid-layer.d.ts.map +1 -0
  10. package/dist/cpu-grid-layer/cpu-grid-layer.js +130 -0
  11. package/dist/cpu-grid-layer/grid-aggregator.js +141 -0
  12. package/dist/dist.dev.js +1296 -13614
  13. package/dist/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +34 -0
  14. package/dist/{esm/gpu-grid-layer → gpu-grid-layer}/gpu-grid-cell-layer-vertex.glsl.js +20 -1
  15. package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer.d.ts +1 -1
  16. package/dist/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +1 -0
  17. package/dist/gpu-grid-layer/gpu-grid-cell-layer.js +145 -0
  18. package/{typed → dist}/gpu-grid-layer/gpu-grid-layer.d.ts +3 -3
  19. package/dist/gpu-grid-layer/gpu-grid-layer.d.ts.map +1 -0
  20. package/dist/gpu-grid-layer/gpu-grid-layer.js +288 -0
  21. package/{typed → dist}/grid-aggregation-layer.d.ts +3 -3
  22. package/dist/grid-aggregation-layer.d.ts.map +1 -0
  23. package/dist/grid-aggregation-layer.js +172 -0
  24. package/{typed → dist}/grid-layer/grid-layer.d.ts +2 -2
  25. package/dist/grid-layer/grid-layer.d.ts.map +1 -0
  26. package/dist/grid-layer/grid-layer.js +63 -0
  27. package/dist/heatmap-layer/heatmap-layer-utils.js +63 -0
  28. package/{typed → dist}/heatmap-layer/heatmap-layer.d.ts +1 -1
  29. package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -0
  30. package/dist/heatmap-layer/heatmap-layer.js +471 -0
  31. package/dist/{esm/heatmap-layer → heatmap-layer}/max-fs.glsl.js +0 -1
  32. package/dist/{esm/heatmap-layer → heatmap-layer}/max-vs.glsl.js +0 -1
  33. package/dist/heatmap-layer/triangle-layer-fragment.glsl.js +61 -0
  34. package/dist/heatmap-layer/triangle-layer-vertex.glsl.js +52 -0
  35. package/dist/heatmap-layer/triangle-layer.js +59 -0
  36. package/dist/{esm/heatmap-layer → heatmap-layer}/weights-fs.glsl.js +0 -1
  37. package/dist/{esm/heatmap-layer → heatmap-layer}/weights-vs.glsl.js +0 -1
  38. package/dist/hexagon-layer/hexagon-aggregator.js +112 -0
  39. package/{typed → dist}/hexagon-layer/hexagon-layer.d.ts +3 -3
  40. package/dist/hexagon-layer/hexagon-layer.d.ts.map +1 -0
  41. package/dist/hexagon-layer/hexagon-layer.js +174 -0
  42. package/dist/index.cjs +4494 -0
  43. package/dist/index.cjs.map +7 -0
  44. package/dist/index.d.ts +20 -0
  45. package/dist/index.d.ts.map +1 -0
  46. package/dist/index.js +32 -0
  47. package/{typed → dist}/screen-grid-layer/screen-grid-cell-layer.d.ts +1 -1
  48. package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -0
  49. package/dist/screen-grid-layer/screen-grid-cell-layer.js +166 -0
  50. package/dist/screen-grid-layer/screen-grid-layer-fragment.glsl.js +40 -0
  51. package/dist/{esm/screen-grid-layer → screen-grid-layer}/screen-grid-layer-vertex.glsl.js +19 -1
  52. package/{typed → dist}/screen-grid-layer/screen-grid-layer.d.ts +1 -1
  53. package/dist/screen-grid-layer/screen-grid-layer.d.ts.map +1 -0
  54. package/dist/screen-grid-layer/screen-grid-layer.js +216 -0
  55. package/dist/types.js +1 -0
  56. package/dist/utils/aggregation-operation-utils.js +94 -0
  57. package/dist/utils/bin-sorter.js +167 -0
  58. package/dist/utils/color-utils.js +53 -0
  59. package/dist/utils/cpu-aggregator.js +421 -0
  60. package/dist/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +39 -0
  61. package/dist/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +53 -0
  62. package/dist/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +34 -0
  63. package/dist/{esm/utils → utils}/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +19 -1
  64. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +41 -0
  65. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +1 -0
  66. package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts.map +1 -1
  67. package/dist/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +566 -0
  68. package/dist/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +37 -0
  69. package/dist/utils/grid-aggregation-utils.js +114 -0
  70. package/dist/utils/prop-utils.js +28 -0
  71. package/dist/utils/resource-utils.js +38 -0
  72. package/dist/utils/scale-utils.js +184 -0
  73. package/dist.min.js +60 -174
  74. package/package.json +18 -11
  75. package/src/utils/gpu-grid-aggregation/gpu-grid-aggregator.ts +10 -13
  76. package/dist/es5/aggregation-layer.js +0 -215
  77. package/dist/es5/aggregation-layer.js.map +0 -1
  78. package/dist/es5/contour-layer/contour-layer.js +0 -353
  79. package/dist/es5/contour-layer/contour-layer.js.map +0 -1
  80. package/dist/es5/contour-layer/contour-utils.js +0 -110
  81. package/dist/es5/contour-layer/contour-utils.js.map +0 -1
  82. package/dist/es5/contour-layer/marching-squares-codes.js +0 -152
  83. package/dist/es5/contour-layer/marching-squares-codes.js.map +0 -1
  84. package/dist/es5/contour-layer/marching-squares.js +0 -168
  85. package/dist/es5/contour-layer/marching-squares.js.map +0 -1
  86. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js +0 -235
  87. package/dist/es5/cpu-grid-layer/cpu-grid-layer.js.map +0 -1
  88. package/dist/es5/cpu-grid-layer/grid-aggregator.js +0 -180
  89. package/dist/es5/cpu-grid-layer/grid-aggregator.js.map +0 -1
  90. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -9
  91. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +0 -1
  92. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -9
  93. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +0 -1
  94. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js +0 -247
  95. package/dist/es5/gpu-grid-layer/gpu-grid-cell-layer.js.map +0 -1
  96. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +0 -424
  97. package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +0 -1
  98. package/dist/es5/grid-aggregation-layer.js +0 -280
  99. package/dist/es5/grid-aggregation-layer.js.map +0 -1
  100. package/dist/es5/grid-layer/grid-layer.js +0 -125
  101. package/dist/es5/grid-layer/grid-layer.js.map +0 -1
  102. package/dist/es5/heatmap-layer/heatmap-layer-utils.js +0 -107
  103. package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +0 -1
  104. package/dist/es5/heatmap-layer/heatmap-layer.js +0 -678
  105. package/dist/es5/heatmap-layer/heatmap-layer.js.map +0 -1
  106. package/dist/es5/heatmap-layer/max-fs.glsl.js +0 -9
  107. package/dist/es5/heatmap-layer/max-fs.glsl.js.map +0 -1
  108. package/dist/es5/heatmap-layer/max-vs.glsl.js +0 -9
  109. package/dist/es5/heatmap-layer/max-vs.glsl.js.map +0 -1
  110. package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js +0 -9
  111. package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js.map +0 -1
  112. package/dist/es5/heatmap-layer/triangle-layer-vertex.glsl.js +0 -9
  113. package/dist/es5/heatmap-layer/triangle-layer-vertex.glsl.js.map +0 -1
  114. package/dist/es5/heatmap-layer/triangle-layer.js +0 -121
  115. package/dist/es5/heatmap-layer/triangle-layer.js.map +0 -1
  116. package/dist/es5/heatmap-layer/weights-fs.glsl.js +0 -9
  117. package/dist/es5/heatmap-layer/weights-fs.glsl.js.map +0 -1
  118. package/dist/es5/heatmap-layer/weights-vs.glsl.js +0 -9
  119. package/dist/es5/heatmap-layer/weights-vs.glsl.js.map +0 -1
  120. package/dist/es5/hexagon-layer/hexagon-aggregator.js +0 -118
  121. package/dist/es5/hexagon-layer/hexagon-aggregator.js.map +0 -1
  122. package/dist/es5/hexagon-layer/hexagon-layer.js +0 -289
  123. package/dist/es5/hexagon-layer/hexagon-layer.js.map +0 -1
  124. package/dist/es5/index.js +0 -104
  125. package/dist/es5/index.js.map +0 -1
  126. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js +0 -244
  127. package/dist/es5/screen-grid-layer/screen-grid-cell-layer.js.map +0 -1
  128. package/dist/es5/screen-grid-layer/screen-grid-layer-fragment.glsl.js +0 -9
  129. package/dist/es5/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +0 -1
  130. package/dist/es5/screen-grid-layer/screen-grid-layer-vertex.glsl.js +0 -9
  131. package/dist/es5/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +0 -1
  132. package/dist/es5/screen-grid-layer/screen-grid-layer.js +0 -317
  133. package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +0 -1
  134. package/dist/es5/types.js +0 -2
  135. package/dist/es5/types.js.map +0 -1
  136. package/dist/es5/utils/aggregation-operation-utils.js +0 -123
  137. package/dist/es5/utils/aggregation-operation-utils.js.map +0 -1
  138. package/dist/es5/utils/bin-sorter.js +0 -248
  139. package/dist/es5/utils/bin-sorter.js.map +0 -1
  140. package/dist/es5/utils/color-utils.js +0 -39
  141. package/dist/es5/utils/color-utils.js.map +0 -1
  142. package/dist/es5/utils/cpu-aggregator.js +0 -496
  143. package/dist/es5/utils/cpu-aggregator.js.map +0 -1
  144. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -9
  145. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +0 -1
  146. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -9
  147. package/dist/es5/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +0 -1
  148. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -9
  149. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +0 -1
  150. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -9
  151. package/dist/es5/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +0 -1
  152. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -63
  153. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +0 -1
  154. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -2
  155. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js.map +0 -1
  156. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -732
  157. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +0 -1
  158. package/dist/es5/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
  159. package/dist/es5/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -9
  160. package/dist/es5/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +0 -1
  161. package/dist/es5/utils/grid-aggregation-utils.js +0 -118
  162. package/dist/es5/utils/grid-aggregation-utils.js.map +0 -1
  163. package/dist/es5/utils/prop-utils.js +0 -19
  164. package/dist/es5/utils/prop-utils.js.map +0 -1
  165. package/dist/es5/utils/resource-utils.js +0 -59
  166. package/dist/es5/utils/resource-utils.js.map +0 -1
  167. package/dist/es5/utils/scale-utils.js +0 -254
  168. package/dist/es5/utils/scale-utils.js.map +0 -1
  169. package/dist/esm/aggregation-layer.js +0 -156
  170. package/dist/esm/aggregation-layer.js.map +0 -1
  171. package/dist/esm/contour-layer/contour-layer.js +0 -316
  172. package/dist/esm/contour-layer/contour-layer.js.map +0 -1
  173. package/dist/esm/contour-layer/contour-utils.js +0 -81
  174. package/dist/esm/contour-layer/contour-utils.js.map +0 -1
  175. package/dist/esm/contour-layer/marching-squares-codes.js +0 -219
  176. package/dist/esm/contour-layer/marching-squares-codes.js.map +0 -1
  177. package/dist/esm/contour-layer/marching-squares.js +0 -151
  178. package/dist/esm/contour-layer/marching-squares.js.map +0 -1
  179. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js +0 -186
  180. package/dist/esm/cpu-grid-layer/cpu-grid-layer.js.map +0 -1
  181. package/dist/esm/cpu-grid-layer/grid-aggregator.js +0 -142
  182. package/dist/esm/cpu-grid-layer/grid-aggregator.js.map +0 -1
  183. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -16
  184. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js.map +0 -1
  185. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js.map +0 -1
  186. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js +0 -196
  187. package/dist/esm/gpu-grid-layer/gpu-grid-cell-layer.js.map +0 -1
  188. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +0 -399
  189. package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +0 -1
  190. package/dist/esm/grid-aggregation-layer.js +0 -240
  191. package/dist/esm/grid-aggregation-layer.js.map +0 -1
  192. package/dist/esm/grid-layer/grid-layer.js +0 -80
  193. package/dist/esm/grid-layer/grid-layer.js.map +0 -1
  194. package/dist/esm/heatmap-layer/heatmap-layer-utils.js +0 -55
  195. package/dist/esm/heatmap-layer/heatmap-layer-utils.js.map +0 -1
  196. package/dist/esm/heatmap-layer/heatmap-layer.js +0 -638
  197. package/dist/esm/heatmap-layer/heatmap-layer.js.map +0 -1
  198. package/dist/esm/heatmap-layer/max-fs.glsl.js.map +0 -1
  199. package/dist/esm/heatmap-layer/max-vs.glsl.js.map +0 -1
  200. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js +0 -43
  201. package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js.map +0 -1
  202. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js +0 -33
  203. package/dist/esm/heatmap-layer/triangle-layer-vertex.glsl.js.map +0 -1
  204. package/dist/esm/heatmap-layer/triangle-layer.js +0 -78
  205. package/dist/esm/heatmap-layer/triangle-layer.js.map +0 -1
  206. package/dist/esm/heatmap-layer/weights-fs.glsl.js.map +0 -1
  207. package/dist/esm/heatmap-layer/weights-vs.glsl.js.map +0 -1
  208. package/dist/esm/hexagon-layer/hexagon-aggregator.js +0 -87
  209. package/dist/esm/hexagon-layer/hexagon-aggregator.js.map +0 -1
  210. package/dist/esm/hexagon-layer/hexagon-layer.js +0 -232
  211. package/dist/esm/hexagon-layer/hexagon-layer.js.map +0 -1
  212. package/dist/esm/index.js +0 -13
  213. package/dist/esm/index.js.map +0 -1
  214. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js +0 -203
  215. package/dist/esm/screen-grid-layer/screen-grid-cell-layer.js.map +0 -1
  216. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js +0 -21
  217. package/dist/esm/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +0 -1
  218. package/dist/esm/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +0 -1
  219. package/dist/esm/screen-grid-layer/screen-grid-layer.js +0 -285
  220. package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +0 -1
  221. package/dist/esm/types.js +0 -2
  222. package/dist/esm/types.js.map +0 -1
  223. package/dist/esm/utils/aggregation-operation-utils.js +0 -91
  224. package/dist/esm/utils/aggregation-operation-utils.js.map +0 -1
  225. package/dist/esm/utils/bin-sorter.js +0 -165
  226. package/dist/esm/utils/bin-sorter.js.map +0 -1
  227. package/dist/esm/utils/color-utils.js +0 -28
  228. package/dist/esm/utils/color-utils.js.map +0 -1
  229. package/dist/esm/utils/cpu-aggregator.js +0 -487
  230. package/dist/esm/utils/cpu-aggregator.js.map +0 -1
  231. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -21
  232. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js.map +0 -1
  233. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -35
  234. package/dist/esm/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js.map +0 -1
  235. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -16
  236. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js.map +0 -1
  237. package/dist/esm/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js.map +0 -1
  238. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -42
  239. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js.map +0 -1
  240. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -2
  241. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js.map +0 -1
  242. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -720
  243. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.js.map +0 -1
  244. package/dist/esm/utils/gpu-grid-aggregation/gpu-grid-aggregator.md +0 -155
  245. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -19
  246. package/dist/esm/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js.map +0 -1
  247. package/dist/esm/utils/grid-aggregation-utils.js +0 -109
  248. package/dist/esm/utils/grid-aggregation-utils.js.map +0 -1
  249. package/dist/esm/utils/prop-utils.js +0 -12
  250. package/dist/esm/utils/prop-utils.js.map +0 -1
  251. package/dist/esm/utils/resource-utils.js +0 -44
  252. package/dist/esm/utils/resource-utils.js.map +0 -1
  253. package/dist/esm/utils/scale-utils.js +0 -192
  254. package/dist/esm/utils/scale-utils.js.map +0 -1
  255. package/typed/contour-layer/contour-layer.d.ts.map +0 -1
  256. package/typed/cpu-grid-layer/cpu-grid-layer.d.ts.map +0 -1
  257. package/typed/gpu-grid-layer/gpu-grid-cell-layer.d.ts.map +0 -1
  258. package/typed/gpu-grid-layer/gpu-grid-layer.d.ts.map +0 -1
  259. package/typed/grid-aggregation-layer.d.ts.map +0 -1
  260. package/typed/grid-layer/grid-layer.d.ts.map +0 -1
  261. package/typed/heatmap-layer/heatmap-layer.d.ts.map +0 -1
  262. package/typed/hexagon-layer/hexagon-layer.d.ts.map +0 -1
  263. package/typed/index.d.ts +0 -20
  264. package/typed/index.d.ts.map +0 -1
  265. package/typed/screen-grid-layer/screen-grid-cell-layer.d.ts.map +0 -1
  266. package/typed/screen-grid-layer/screen-grid-layer.d.ts.map +0 -1
  267. /package/{typed → dist}/aggregation-layer.d.ts +0 -0
  268. /package/{typed → dist}/aggregation-layer.d.ts.map +0 -0
  269. /package/{typed → dist}/contour-layer/contour-utils.d.ts +0 -0
  270. /package/{typed → dist}/contour-layer/contour-utils.d.ts.map +0 -0
  271. /package/{typed → dist}/contour-layer/marching-squares-codes.d.ts +0 -0
  272. /package/{typed → dist}/contour-layer/marching-squares-codes.d.ts.map +0 -0
  273. /package/{typed → dist}/contour-layer/marching-squares.d.ts +0 -0
  274. /package/{typed → dist}/contour-layer/marching-squares.d.ts.map +0 -0
  275. /package/{typed → dist}/cpu-grid-layer/grid-aggregator.d.ts +0 -0
  276. /package/{typed → dist}/cpu-grid-layer/grid-aggregator.d.ts.map +0 -0
  277. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts +0 -0
  278. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.d.ts.map +0 -0
  279. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts +0 -0
  280. /package/{typed → dist}/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.d.ts.map +0 -0
  281. /package/{typed → dist}/heatmap-layer/heatmap-layer-utils.d.ts +0 -0
  282. /package/{typed → dist}/heatmap-layer/heatmap-layer-utils.d.ts.map +0 -0
  283. /package/{typed → dist}/heatmap-layer/max-fs.glsl.d.ts +0 -0
  284. /package/{typed → dist}/heatmap-layer/max-fs.glsl.d.ts.map +0 -0
  285. /package/{typed → dist}/heatmap-layer/max-vs.glsl.d.ts +0 -0
  286. /package/{typed → dist}/heatmap-layer/max-vs.glsl.d.ts.map +0 -0
  287. /package/{typed → dist}/heatmap-layer/triangle-layer-fragment.glsl.d.ts +0 -0
  288. /package/{typed → dist}/heatmap-layer/triangle-layer-fragment.glsl.d.ts.map +0 -0
  289. /package/{typed → dist}/heatmap-layer/triangle-layer-vertex.glsl.d.ts +0 -0
  290. /package/{typed → dist}/heatmap-layer/triangle-layer-vertex.glsl.d.ts.map +0 -0
  291. /package/{typed → dist}/heatmap-layer/triangle-layer.d.ts +0 -0
  292. /package/{typed → dist}/heatmap-layer/triangle-layer.d.ts.map +0 -0
  293. /package/{typed → dist}/heatmap-layer/weights-fs.glsl.d.ts +0 -0
  294. /package/{typed → dist}/heatmap-layer/weights-fs.glsl.d.ts.map +0 -0
  295. /package/{typed → dist}/heatmap-layer/weights-vs.glsl.d.ts +0 -0
  296. /package/{typed → dist}/heatmap-layer/weights-vs.glsl.d.ts.map +0 -0
  297. /package/{typed → dist}/hexagon-layer/hexagon-aggregator.d.ts +0 -0
  298. /package/{typed → dist}/hexagon-layer/hexagon-aggregator.d.ts.map +0 -0
  299. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts +0 -0
  300. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-fragment.glsl.d.ts.map +0 -0
  301. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +0 -0
  302. /package/{typed → dist}/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +0 -0
  303. /package/{typed → dist}/types.d.ts +0 -0
  304. /package/{typed → dist}/types.d.ts.map +0 -0
  305. /package/{typed → dist}/utils/aggregation-operation-utils.d.ts +0 -0
  306. /package/{typed → dist}/utils/aggregation-operation-utils.d.ts.map +0 -0
  307. /package/{typed → dist}/utils/bin-sorter.d.ts +0 -0
  308. /package/{typed → dist}/utils/bin-sorter.d.ts.map +0 -0
  309. /package/{typed → dist}/utils/color-utils.d.ts +0 -0
  310. /package/{typed → dist}/utils/color-utils.d.ts.map +0 -0
  311. /package/{typed → dist}/utils/cpu-aggregator.d.ts +0 -0
  312. /package/{typed → dist}/utils/cpu-aggregator.d.ts.map +0 -0
  313. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts +0 -0
  314. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.d.ts.map +0 -0
  315. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts +0 -0
  316. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.d.ts.map +0 -0
  317. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts +0 -0
  318. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.d.ts.map +0 -0
  319. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts +0 -0
  320. /package/{typed → dist}/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.d.ts.map +0 -0
  321. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts +0 -0
  322. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.d.ts.map +0 -0
  323. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts +0 -0
  324. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.d.ts.map +0 -0
  325. /package/{typed → dist}/utils/gpu-grid-aggregation/gpu-grid-aggregator.d.ts +0 -0
  326. /package/{typed → dist}/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts +0 -0
  327. /package/{typed → dist}/utils/gpu-grid-aggregation/transform-mean-vs.glsl.d.ts.map +0 -0
  328. /package/{typed → dist}/utils/grid-aggregation-utils.d.ts +0 -0
  329. /package/{typed → dist}/utils/grid-aggregation-utils.d.ts.map +0 -0
  330. /package/{typed → dist}/utils/prop-utils.d.ts +0 -0
  331. /package/{typed → dist}/utils/prop-utils.d.ts.map +0 -0
  332. /package/{typed → dist}/utils/resource-utils.d.ts +0 -0
  333. /package/{typed → dist}/utils/resource-utils.d.ts.map +0 -0
  334. /package/{typed → dist}/utils/scale-utils.d.ts +0 -0
  335. /package/{typed → dist}/utils/scale-utils.d.ts.map +0 -0
@@ -0,0 +1,471 @@
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 { GL } from '@luma.gl/constants';
23
+ import { TextureTransform } from '@luma.gl/engine';
24
+ import { AttributeManager, COORDINATE_SYSTEM, log } from '@deck.gl/core';
25
+ import TriangleLayer from "./triangle-layer.js";
26
+ import AggregationLayer from "../aggregation-layer.js";
27
+ import { defaultColorRange, colorRangeToFlatArray } from "../utils/color-utils.js";
28
+ import weightsVs from "./weights-vs.glsl.js";
29
+ import weightsFs from "./weights-fs.glsl.js";
30
+ import maxVs from "./max-vs.glsl.js";
31
+ import maxFs from "./max-fs.glsl.js";
32
+ const RESOLUTION = 2; // (number of common space pixels) / (number texels)
33
+ const TEXTURE_PROPS = {
34
+ format: 'rgba8unorm',
35
+ mipmaps: false,
36
+ sampler: {
37
+ minFilter: 'linear',
38
+ magFilter: 'linear',
39
+ addressModeU: 'clamp-to-edge',
40
+ addressModeV: 'clamp-to-edge'
41
+ }
42
+ };
43
+ const DEFAULT_COLOR_DOMAIN = [0, 0];
44
+ const AGGREGATION_MODE = {
45
+ SUM: 0,
46
+ MEAN: 1
47
+ };
48
+ const defaultProps = {
49
+ getPosition: { type: 'accessor', value: (x) => x.position },
50
+ getWeight: { type: 'accessor', value: 1 },
51
+ intensity: { type: 'number', min: 0, value: 1 },
52
+ radiusPixels: { type: 'number', min: 1, max: 100, value: 50 },
53
+ colorRange: defaultColorRange,
54
+ threshold: { type: 'number', min: 0, max: 1, value: 0.05 },
55
+ colorDomain: { type: 'array', value: null, optional: true },
56
+ // 'SUM' or 'MEAN'
57
+ aggregation: 'SUM',
58
+ weightsTextureSize: { type: 'number', min: 128, max: 2048, value: 2048 },
59
+ debounceTimeout: { type: 'number', min: 0, max: 1000, value: 500 }
60
+ };
61
+ const REQUIRED_FEATURES = [
62
+ 'blend-minmax-webgl1', // max weight calculation
63
+ 'texture-formats-float32-webgl1' // weight-map as texture
64
+ ];
65
+ const FLOAT_TARGET_FEATURES = [
66
+ 'texture-renderable-float32-webgl', // ability to render to float texture
67
+ 'texture-blend-float-webgl1' // ability to blend when rendering to float texture
68
+ ];
69
+ const DIMENSIONS = {
70
+ data: {
71
+ props: ['radiusPixels']
72
+ }
73
+ };
74
+ /** Visualizes the spatial distribution of data. */
75
+ export default class HeatmapLayer extends AggregationLayer {
76
+ static { this.layerName = 'HeatmapLayer'; }
77
+ static { this.defaultProps = defaultProps; }
78
+ initializeState() {
79
+ if (!REQUIRED_FEATURES.every(feature => this.context.device.features.has(feature))) {
80
+ this.setState({ supported: false });
81
+ log.error(`HeatmapLayer: ${this.id} is not supported on this browser`)();
82
+ return;
83
+ }
84
+ super.initializeAggregationLayer(DIMENSIONS);
85
+ this.setState({ supported: true, colorDomain: DEFAULT_COLOR_DOMAIN });
86
+ this._setupTextureParams();
87
+ this._setupAttributes();
88
+ this._setupResources();
89
+ }
90
+ shouldUpdateState({ changeFlags }) {
91
+ // Need to be updated when viewport changes
92
+ return changeFlags.somethingChanged;
93
+ }
94
+ /* eslint-disable max-statements,complexity */
95
+ updateState(opts) {
96
+ if (!this.state.supported) {
97
+ return;
98
+ }
99
+ super.updateState(opts);
100
+ this._updateHeatmapState(opts);
101
+ }
102
+ _updateHeatmapState(opts) {
103
+ const { props, oldProps } = opts;
104
+ const changeFlags = this._getChangeFlags(opts);
105
+ if (changeFlags.dataChanged || changeFlags.viewportChanged) {
106
+ // if data is changed, do not debounce and immediately update the weight map
107
+ changeFlags.boundsChanged = this._updateBounds(changeFlags.dataChanged);
108
+ this._updateTextureRenderingBounds();
109
+ }
110
+ if (changeFlags.dataChanged || changeFlags.boundsChanged) {
111
+ // Update weight map immediately
112
+ clearTimeout(this.state.updateTimer);
113
+ this.setState({ isWeightMapDirty: true });
114
+ }
115
+ else if (changeFlags.viewportZoomChanged) {
116
+ // Update weight map when zoom stops
117
+ this._debouncedUpdateWeightmap();
118
+ }
119
+ if (props.colorRange !== oldProps.colorRange) {
120
+ this._updateColorTexture(opts);
121
+ }
122
+ if (this.state.isWeightMapDirty) {
123
+ this._updateWeightmap();
124
+ }
125
+ this.setState({ zoom: opts.context.viewport.zoom });
126
+ }
127
+ renderLayers() {
128
+ if (!this.state.supported) {
129
+ return [];
130
+ }
131
+ const { weightsTexture, triPositionBuffer, triTexCoordBuffer, maxWeightsTexture, colorTexture, colorDomain } = this.state;
132
+ const { updateTriggers, intensity, threshold, aggregation } = this.props;
133
+ const TriangleLayerClass = this.getSubLayerClass('triangle', TriangleLayer);
134
+ return new TriangleLayerClass(this.getSubLayerProps({
135
+ id: 'triangle-layer',
136
+ updateTriggers
137
+ }), {
138
+ // position buffer is filled with world coordinates generated from viewport.unproject
139
+ // i.e. LNGLAT if geospatial, CARTESIAN otherwise
140
+ coordinateSystem: COORDINATE_SYSTEM.DEFAULT,
141
+ data: {
142
+ attributes: {
143
+ positions: triPositionBuffer,
144
+ texCoords: triTexCoordBuffer
145
+ }
146
+ },
147
+ vertexCount: 4,
148
+ maxTexture: maxWeightsTexture,
149
+ colorTexture,
150
+ aggregationMode: AGGREGATION_MODE[aggregation] || 0,
151
+ weightsTexture,
152
+ intensity,
153
+ threshold,
154
+ colorDomain
155
+ });
156
+ }
157
+ finalizeState(context) {
158
+ super.finalizeState(context);
159
+ const { weightsTransform, weightsTexture, maxWeightTransform, maxWeightsTexture, triPositionBuffer, triTexCoordBuffer, colorTexture, updateTimer } = this.state;
160
+ weightsTransform?.destroy();
161
+ weightsTexture?.destroy();
162
+ maxWeightTransform?.destroy();
163
+ maxWeightsTexture?.destroy();
164
+ triPositionBuffer?.destroy();
165
+ triTexCoordBuffer?.destroy();
166
+ colorTexture?.destroy();
167
+ if (updateTimer) {
168
+ clearTimeout(updateTimer);
169
+ }
170
+ }
171
+ // PRIVATE
172
+ // override Composite layer private method to create AttributeManager instance
173
+ _getAttributeManager() {
174
+ return new AttributeManager(this.context.device, {
175
+ id: this.props.id,
176
+ stats: this.context.stats
177
+ });
178
+ }
179
+ _getChangeFlags(opts) {
180
+ const changeFlags = {};
181
+ const { dimensions } = this.state;
182
+ changeFlags.dataChanged =
183
+ (this.isAttributeChanged() && 'attribute changed') || // if any attribute is changed
184
+ (this.isAggregationDirty(opts, {
185
+ compareAll: true,
186
+ dimension: dimensions.data
187
+ }) &&
188
+ 'aggregation is dirty');
189
+ changeFlags.viewportChanged = opts.changeFlags.viewportChanged;
190
+ const { zoom } = this.state;
191
+ if (!opts.context.viewport || opts.context.viewport.zoom !== zoom) {
192
+ changeFlags.viewportZoomChanged = true;
193
+ }
194
+ return changeFlags;
195
+ }
196
+ _createTextures() {
197
+ const { textureSize, format } = this.state;
198
+ this.setState({
199
+ weightsTexture: this.context.device.createTexture({
200
+ ...TEXTURE_PROPS,
201
+ width: textureSize,
202
+ height: textureSize,
203
+ format
204
+ }),
205
+ maxWeightsTexture: this.context.device.createTexture({
206
+ ...TEXTURE_PROPS,
207
+ width: 1,
208
+ height: 1,
209
+ format
210
+ })
211
+ });
212
+ }
213
+ _setupAttributes() {
214
+ const attributeManager = this.getAttributeManager();
215
+ attributeManager.add({
216
+ positions: { size: 3, type: GL.DOUBLE, accessor: 'getPosition' },
217
+ weights: { size: 1, accessor: 'getWeight' }
218
+ });
219
+ this.setState({ positionAttributeName: 'positions' });
220
+ }
221
+ _setupTextureParams() {
222
+ const { device } = this.context;
223
+ const { weightsTextureSize } = this.props;
224
+ const textureSize = Math.min(weightsTextureSize, device.limits.maxTextureDimension2D);
225
+ const floatTargetSupport = FLOAT_TARGET_FEATURES.every(feature => device.features.has(feature));
226
+ const format = floatTargetSupport ? 'rgba32float' : 'rgba8unorm';
227
+ const weightsScale = floatTargetSupport ? 1 : 1 / 255;
228
+ this.setState({ textureSize, format, weightsScale });
229
+ if (!floatTargetSupport) {
230
+ log.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`)();
231
+ }
232
+ }
233
+ _createWeightsTransform(shaders) {
234
+ let { weightsTransform } = this.state;
235
+ const { weightsTexture } = this.state;
236
+ const attributeManager = this.getAttributeManager();
237
+ weightsTransform?.destroy();
238
+ weightsTransform = new TextureTransform(this.context.device, {
239
+ id: `${this.id}-weights-transform`,
240
+ bufferLayout: attributeManager.getBufferLayouts(),
241
+ vertexCount: 1,
242
+ targetTexture: weightsTexture,
243
+ parameters: {
244
+ depthWriteEnabled: false,
245
+ blendColorOperation: 'add',
246
+ blendColorSrcFactor: 'one',
247
+ blendColorDstFactor: 'one',
248
+ blendAlphaSrcFactor: 'one',
249
+ blendAlphaDstFactor: 'one'
250
+ },
251
+ topology: 'point-list',
252
+ ...shaders
253
+ });
254
+ this.setState({ weightsTransform });
255
+ }
256
+ _setupResources() {
257
+ this._createTextures();
258
+ const { device } = this.context;
259
+ const { textureSize, weightsTexture, maxWeightsTexture } = this.state;
260
+ const weightsTransformShaders = this.getShaders({
261
+ vs: weightsVs,
262
+ fs: weightsFs
263
+ });
264
+ this._createWeightsTransform(weightsTransformShaders);
265
+ const maxWeightsTransformShaders = this.getShaders({ vs: maxVs, fs: maxFs });
266
+ const maxWeightTransform = new TextureTransform(device, {
267
+ id: `${this.id}-max-weights-transform`,
268
+ bindings: { inTexture: weightsTexture },
269
+ uniforms: { textureSize },
270
+ targetTexture: maxWeightsTexture,
271
+ ...maxWeightsTransformShaders,
272
+ vertexCount: textureSize * textureSize,
273
+ topology: 'point-list',
274
+ parameters: {
275
+ depthWriteEnabled: false,
276
+ blendColorOperation: 'max',
277
+ blendAlphaOperation: 'max',
278
+ blendColorSrcFactor: 'one',
279
+ blendColorDstFactor: 'one',
280
+ blendAlphaSrcFactor: 'one',
281
+ blendAlphaDstFactor: 'one'
282
+ }
283
+ });
284
+ this.setState({
285
+ weightsTexture,
286
+ maxWeightsTexture,
287
+ maxWeightTransform,
288
+ zoom: null,
289
+ triPositionBuffer: device.createBuffer({ byteLength: 48 }),
290
+ triTexCoordBuffer: device.createBuffer({ byteLength: 48 })
291
+ });
292
+ }
293
+ // overwrite super class method to update transform model
294
+ updateShaders(shaderOptions) {
295
+ // shader params (modules, injects) changed, update model object
296
+ this._createWeightsTransform({
297
+ vs: weightsVs,
298
+ fs: weightsFs,
299
+ ...shaderOptions
300
+ });
301
+ }
302
+ _updateMaxWeightValue() {
303
+ const { maxWeightTransform, textureSize } = this.state;
304
+ maxWeightTransform.run({
305
+ parameters: { viewport: [0, 0, 1, 1] },
306
+ clearColor: [0, 0, 0, 0]
307
+ });
308
+ }
309
+ // Computes world bounds area that needs to be processed for generate heatmap
310
+ _updateBounds(forceUpdate = false) {
311
+ const { viewport } = this.context;
312
+ // Unproject all 4 corners of the current screen coordinates into world coordinates (lng/lat)
313
+ // Takes care of viewport has non zero bearing/pitch (i.e axis not aligned with world coordiante system)
314
+ const viewportCorners = [
315
+ viewport.unproject([0, 0]),
316
+ viewport.unproject([viewport.width, 0]),
317
+ viewport.unproject([viewport.width, viewport.height]),
318
+ viewport.unproject([0, viewport.height])
319
+ ].map(p => p.map(Math.fround));
320
+ // #1: get world bounds for current viewport extends
321
+ const visibleWorldBounds = getBounds(viewportCorners); // TODO: Change to visible bounds
322
+ const newState = { visibleWorldBounds, viewportCorners };
323
+ let boundsChanged = false;
324
+ if (forceUpdate ||
325
+ !this.state.worldBounds ||
326
+ !boundsContain(this.state.worldBounds, visibleWorldBounds)) {
327
+ // #2 : convert world bounds to common (Flat) bounds
328
+ // #3 : extend common bounds to match aspect ratio with viewport
329
+ const scaledCommonBounds = this._worldToCommonBounds(visibleWorldBounds);
330
+ // #4 :convert aligned common bounds to world bounds
331
+ const worldBounds = this._commonToWorldBounds(scaledCommonBounds);
332
+ // Clip webmercator projection limits
333
+ if (this.props.coordinateSystem === COORDINATE_SYSTEM.LNGLAT) {
334
+ worldBounds[1] = Math.max(worldBounds[1], -85.051129);
335
+ worldBounds[3] = Math.min(worldBounds[3], 85.051129);
336
+ worldBounds[0] = Math.max(worldBounds[0], -360);
337
+ worldBounds[2] = Math.min(worldBounds[2], 360);
338
+ }
339
+ // #5: now convert world bounds to common using Layer's coordiante system and origin
340
+ const normalizedCommonBounds = this._worldToCommonBounds(worldBounds);
341
+ newState.worldBounds = worldBounds;
342
+ newState.normalizedCommonBounds = normalizedCommonBounds;
343
+ boundsChanged = true;
344
+ }
345
+ this.setState(newState);
346
+ return boundsChanged;
347
+ }
348
+ _updateTextureRenderingBounds() {
349
+ // Just render visible portion of the texture
350
+ const { triPositionBuffer, triTexCoordBuffer, normalizedCommonBounds, viewportCorners } = this.state;
351
+ const { viewport } = this.context;
352
+ triPositionBuffer.write(packVertices(viewportCorners, 3));
353
+ const textureBounds = viewportCorners.map(p => getTextureCoordinates(viewport.projectPosition(p), normalizedCommonBounds));
354
+ triTexCoordBuffer.write(packVertices(textureBounds, 2));
355
+ }
356
+ _updateColorTexture(opts) {
357
+ const { colorRange } = opts.props;
358
+ let { colorTexture } = this.state;
359
+ const colors = colorRangeToFlatArray(colorRange, false, Uint8Array);
360
+ if (colorTexture && colorTexture?.width === colorRange.length) {
361
+ // TODO(v9): Unclear whether `setSubImageData` is a public API, or what to use if not.
362
+ colorTexture.setSubImageData({ data: colors });
363
+ }
364
+ else {
365
+ colorTexture?.destroy();
366
+ colorTexture = this.context.device.createTexture({
367
+ ...TEXTURE_PROPS,
368
+ data: colors,
369
+ width: colorRange.length,
370
+ height: 1
371
+ });
372
+ }
373
+ this.setState({ colorTexture });
374
+ }
375
+ _updateWeightmap() {
376
+ const { radiusPixels, colorDomain, aggregation } = this.props;
377
+ const { worldBounds, textureSize, weightsScale } = this.state;
378
+ const weightsTransform = this.state.weightsTransform;
379
+ this.state.isWeightMapDirty = false;
380
+ // convert world bounds to common using Layer's coordiante system and origin
381
+ const commonBounds = this._worldToCommonBounds(worldBounds, {
382
+ useLayerCoordinateSystem: true
383
+ });
384
+ if (colorDomain && aggregation === 'SUM') {
385
+ // scale color domain to weight per pixel
386
+ const { viewport } = this.context;
387
+ const metersPerPixel = (viewport.distanceScales.metersPerUnit[2] * (commonBounds[2] - commonBounds[0])) /
388
+ textureSize;
389
+ this.state.colorDomain = colorDomain.map(x => x * metersPerPixel * weightsScale);
390
+ }
391
+ else {
392
+ this.state.colorDomain = colorDomain || DEFAULT_COLOR_DOMAIN;
393
+ }
394
+ const attributeManager = this.getAttributeManager();
395
+ const attributes = attributeManager.getAttributes();
396
+ const moduleSettings = this.getModuleSettings();
397
+ const positions = attributes.positions.buffer;
398
+ const uniforms = { radiusPixels, commonBounds, textureWidth: textureSize, weightsScale };
399
+ const weights = attributes.weights.buffer;
400
+ weightsTransform.model.setAttributes({ positions, weights });
401
+ weightsTransform.model.setVertexCount(this.getNumInstances());
402
+ weightsTransform.model.setUniforms(uniforms);
403
+ weightsTransform.model.updateModuleSettings(moduleSettings);
404
+ weightsTransform.run({
405
+ parameters: { viewport: [0, 0, textureSize, textureSize] },
406
+ clearColor: [0, 0, 0, 0]
407
+ });
408
+ this._updateMaxWeightValue();
409
+ }
410
+ _debouncedUpdateWeightmap(fromTimer = false) {
411
+ let { updateTimer } = this.state;
412
+ const { debounceTimeout } = this.props;
413
+ if (fromTimer) {
414
+ updateTimer = null;
415
+ // update
416
+ this._updateBounds(true);
417
+ this._updateTextureRenderingBounds();
418
+ this.setState({ isWeightMapDirty: true });
419
+ }
420
+ else {
421
+ this.setState({ isWeightMapDirty: false });
422
+ clearTimeout(updateTimer);
423
+ updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), debounceTimeout);
424
+ }
425
+ this.setState({ updateTimer });
426
+ }
427
+ // input: worldBounds: [minLong, minLat, maxLong, maxLat]
428
+ // input: opts.useLayerCoordinateSystem : layers coordiante system is used
429
+ // optput: commonBounds: [minX, minY, maxX, maxY] scaled to fit the current texture
430
+ _worldToCommonBounds(worldBounds, opts = {}) {
431
+ const { useLayerCoordinateSystem = false } = opts;
432
+ const [minLong, minLat, maxLong, maxLat] = worldBounds;
433
+ const { viewport } = this.context;
434
+ const { textureSize } = this.state;
435
+ const { coordinateSystem } = this.props;
436
+ const offsetMode = useLayerCoordinateSystem &&
437
+ (coordinateSystem === COORDINATE_SYSTEM.LNGLAT_OFFSETS ||
438
+ coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS);
439
+ const offsetOriginCommon = offsetMode
440
+ ? viewport.projectPosition(this.props.coordinateOrigin)
441
+ : [0, 0];
442
+ const size = (textureSize * RESOLUTION) / viewport.scale;
443
+ let bottomLeftCommon;
444
+ let topRightCommon;
445
+ // Y-axis is flipped between World and Common bounds
446
+ if (useLayerCoordinateSystem && !offsetMode) {
447
+ bottomLeftCommon = this.projectPosition([minLong, minLat, 0]);
448
+ topRightCommon = this.projectPosition([maxLong, maxLat, 0]);
449
+ }
450
+ else {
451
+ bottomLeftCommon = viewport.projectPosition([minLong, minLat, 0]);
452
+ topRightCommon = viewport.projectPosition([maxLong, maxLat, 0]);
453
+ }
454
+ // Ignore z component
455
+ return scaleToAspectRatio([
456
+ bottomLeftCommon[0] - offsetOriginCommon[0],
457
+ bottomLeftCommon[1] - offsetOriginCommon[1],
458
+ topRightCommon[0] - offsetOriginCommon[0],
459
+ topRightCommon[1] - offsetOriginCommon[1]
460
+ ], size, size);
461
+ }
462
+ // input commonBounds: [xMin, yMin, xMax, yMax]
463
+ // output worldBounds: [minLong, minLat, maxLong, maxLat]
464
+ _commonToWorldBounds(commonBounds) {
465
+ const [xMin, yMin, xMax, yMax] = commonBounds;
466
+ const { viewport } = this.context;
467
+ const bottomLeftWorld = viewport.unprojectPosition([xMin, yMin]);
468
+ const topRightWorld = viewport.unprojectPosition([xMax, yMax]);
469
+ return bottomLeftWorld.slice(0, 2).concat(topRightWorld.slice(0, 2));
470
+ }
471
+ }
@@ -7,4 +7,3 @@ void main() {
7
7
  fragColor.g = outTexture.r / max(1.0, outTexture.a);
8
8
  }
9
9
  `;
10
- //# sourceMappingURL=max-fs.glsl.js.map
@@ -17,4 +17,3 @@ void main()
17
17
  gl_PointSize = 1.0;
18
18
  }
19
19
  `;
20
- //# sourceMappingURL=max-vs.glsl.js.map
@@ -0,0 +1,61 @@
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
+
24
+ precision highp float;
25
+
26
+ uniform float opacity;
27
+ uniform sampler2D weightsTexture;
28
+ uniform sampler2D colorTexture;
29
+ uniform float aggregationMode;
30
+
31
+ in vec2 vTexCoords;
32
+ in float vIntensityMin;
33
+ in float vIntensityMax;
34
+
35
+ out vec4 fragColor;
36
+
37
+ vec4 getLinearColor(float value) {
38
+ float factor = clamp(value * vIntensityMax, 0., 1.);
39
+ vec4 color = texture(colorTexture, vec2(factor, 0.5));
40
+ color.a *= min(value * vIntensityMin, 1.0);
41
+ return color;
42
+ }
43
+
44
+ void main(void) {
45
+ vec4 weights = texture(weightsTexture, vTexCoords);
46
+ float weight = weights.r;
47
+
48
+ if (aggregationMode > 0.5) {
49
+ weight /= max(1.0, weights.a);
50
+ }
51
+
52
+ // discard pixels with 0 weight.
53
+ if (weight <= 0.) {
54
+ discard;
55
+ }
56
+
57
+ vec4 linearColor = getLinearColor(weight);
58
+ linearColor.a *= opacity;
59
+ fragColor = linearColor;
60
+ }
61
+ `;
@@ -0,0 +1,52 @@
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
+
25
+ uniform sampler2D maxTexture;
26
+ uniform float intensity;
27
+ uniform vec2 colorDomain;
28
+ uniform float threshold;
29
+ uniform float aggregationMode;
30
+
31
+ in vec3 positions;
32
+ in vec2 texCoords;
33
+
34
+ out vec2 vTexCoords;
35
+ out float vIntensityMin;
36
+ out float vIntensityMax;
37
+
38
+ void main(void) {
39
+ gl_Position = project_position_to_clipspace(positions, vec3(0.0), vec3(0.0));
40
+ vTexCoords = texCoords;
41
+ vec4 maxTexture = texture(maxTexture, vec2(0.5));
42
+ float maxValue = aggregationMode < 0.5 ? maxTexture.r : maxTexture.g;
43
+ float minValue = maxValue * threshold;
44
+ if (colorDomain[1] > 0.) {
45
+ // if user specified custom domain use it.
46
+ maxValue = colorDomain[1];
47
+ minValue = colorDomain[0];
48
+ }
49
+ vIntensityMax = intensity / maxValue;
50
+ vIntensityMin = intensity / minValue;
51
+ }
52
+ `;
@@ -0,0 +1,59 @@
1
+ // Copyright (c) 2015 - 2019 Uber Technologies, Inc.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ // THE SOFTWARE.
20
+ import { Model } from '@luma.gl/engine';
21
+ import { Layer, project32 } from '@deck.gl/core';
22
+ import vs from "./triangle-layer-vertex.glsl.js";
23
+ import fs from "./triangle-layer-fragment.glsl.js";
24
+ export default class TriangleLayer extends Layer {
25
+ static { this.layerName = 'TriangleLayer'; }
26
+ getShaders() {
27
+ return { vs, fs, modules: [project32] };
28
+ }
29
+ initializeState({ device }) {
30
+ this.setState({ model: this._getModel(device) });
31
+ }
32
+ _getModel(device) {
33
+ const { vertexCount, data, weightsTexture, maxTexture, colorTexture } = this.props;
34
+ return new Model(device, {
35
+ ...this.getShaders(),
36
+ id: this.props.id,
37
+ bindings: { weightsTexture, maxTexture, colorTexture },
38
+ attributes: data.attributes,
39
+ bufferLayout: [
40
+ { name: 'positions', format: 'float32x3' },
41
+ { name: 'texCoords', format: 'float32x2' }
42
+ ],
43
+ topology: 'triangle-fan-webgl',
44
+ vertexCount
45
+ });
46
+ }
47
+ draw({ uniforms }) {
48
+ const { model } = this.state;
49
+ const { intensity, threshold, aggregationMode, colorDomain } = this.props;
50
+ model.setUniforms({
51
+ ...uniforms,
52
+ intensity,
53
+ threshold,
54
+ aggregationMode,
55
+ colorDomain
56
+ });
57
+ model.draw(this.context.renderPass);
58
+ }
59
+ }
@@ -19,4 +19,3 @@ void main()
19
19
  DECKGL_FILTER_COLOR(fragColor, geometry);
20
20
  }
21
21
  `;
22
- //# sourceMappingURL=weights-fs.glsl.js.map
@@ -24,4 +24,3 @@ void main()
24
24
  gl_Position.w = 1.0;
25
25
  }
26
26
  `;
27
- //# sourceMappingURL=weights-vs.glsl.js.map