minerva-design 1.5.0 → 1.6.0

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 (457) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/custom-elements.json +122 -5
  3. package/dist/angular/fesm2022/minerva-angular.mjs +55 -0
  4. package/dist/angular/fesm2022/minerva-angular.mjs.map +1 -1
  5. package/dist/angular/types/minerva-angular.d.ts +23 -2
  6. package/dist/charts/canvas.d.cts +2 -1
  7. package/dist/charts/canvas.d.ts +2 -1
  8. package/dist/charts/core.d.cts +1 -1
  9. package/dist/charts/core.d.ts +1 -1
  10. package/dist/charts/engine/canvas.cjs +1 -1
  11. package/dist/charts/engine/canvas.cjs.map +1 -1
  12. package/dist/charts/engine/canvas.js +2 -1
  13. package/dist/charts/engine/canvas.js.map +1 -1
  14. package/dist/charts/engine/chart.cjs +1 -1
  15. package/dist/charts/engine/chart.cjs.map +1 -1
  16. package/dist/charts/engine/chart.js +144 -143
  17. package/dist/charts/engine/chart.js.map +1 -1
  18. package/dist/charts/engine/controller.cjs +2 -2
  19. package/dist/charts/engine/controller.cjs.map +1 -1
  20. package/dist/charts/engine/controller.d.cts +3 -1
  21. package/dist/charts/engine/controller.d.ts +3 -1
  22. package/dist/charts/engine/controller.js +130 -132
  23. package/dist/charts/engine/controller.js.map +1 -1
  24. package/dist/charts/engine/defaults.cjs.map +1 -1
  25. package/dist/charts/engine/defaults.d.cts +4 -4
  26. package/dist/charts/engine/defaults.d.ts +4 -4
  27. package/dist/charts/engine/defaults.js.map +1 -1
  28. package/dist/charts/engine/graph/chart.cjs +1 -1
  29. package/dist/charts/engine/graph/chart.cjs.map +1 -1
  30. package/dist/charts/engine/graph/chart.js +740 -597
  31. package/dist/charts/engine/graph/chart.js.map +1 -1
  32. package/dist/charts/engine/graph/dag.cjs +1 -1
  33. package/dist/charts/engine/graph/dag.cjs.map +1 -1
  34. package/dist/charts/engine/graph/dag.js +191 -166
  35. package/dist/charts/engine/graph/dag.js.map +1 -1
  36. package/dist/charts/engine/graph/force.cjs +1 -1
  37. package/dist/charts/engine/graph/force.cjs.map +1 -1
  38. package/dist/charts/engine/graph/force.d.cts +9 -0
  39. package/dist/charts/engine/graph/force.d.ts +9 -0
  40. package/dist/charts/engine/graph/force.js +279 -181
  41. package/dist/charts/engine/graph/force.js.map +1 -1
  42. package/dist/charts/engine/graph/geometry.cjs +1 -1
  43. package/dist/charts/engine/graph/geometry.cjs.map +1 -1
  44. package/dist/charts/engine/graph/geometry.d.cts +14 -1
  45. package/dist/charts/engine/graph/geometry.d.ts +14 -1
  46. package/dist/charts/engine/graph/geometry.js +77 -24
  47. package/dist/charts/engine/graph/geometry.js.map +1 -1
  48. package/dist/charts/engine/graph/model.cjs +1 -1
  49. package/dist/charts/engine/graph/model.cjs.map +1 -1
  50. package/dist/charts/engine/graph/model.d.cts +9 -0
  51. package/dist/charts/engine/graph/model.d.ts +9 -0
  52. package/dist/charts/engine/graph/model.js +63 -43
  53. package/dist/charts/engine/graph/model.js.map +1 -1
  54. package/dist/charts/engine/graph/types.d.cts +14 -0
  55. package/dist/charts/engine/graph/types.d.ts +14 -0
  56. package/dist/charts/engine/graph/worker.cjs +12 -6
  57. package/dist/charts/engine/graph/worker.cjs.map +1 -1
  58. package/dist/charts/engine/graph/worker.js +12 -6
  59. package/dist/charts/engine/graph/worker.js.map +1 -1
  60. package/dist/charts/engine/labels.cjs.map +1 -1
  61. package/dist/charts/engine/labels.d.cts +17 -0
  62. package/dist/charts/engine/labels.d.ts +17 -0
  63. package/dist/charts/engine/labels.js.map +1 -1
  64. package/dist/charts/engine/model.cjs +1 -1
  65. package/dist/charts/engine/model.cjs.map +1 -1
  66. package/dist/charts/engine/model.d.cts +33 -0
  67. package/dist/charts/engine/model.d.ts +33 -0
  68. package/dist/charts/engine/model.js +149 -126
  69. package/dist/charts/engine/model.js.map +1 -1
  70. package/dist/charts/engine/orderbook/field.cjs +37 -0
  71. package/dist/charts/engine/orderbook/field.cjs.map +1 -0
  72. package/dist/charts/engine/orderbook/field.d.cts +92 -0
  73. package/dist/charts/engine/orderbook/field.d.ts +92 -0
  74. package/dist/charts/engine/orderbook/field.js +297 -0
  75. package/dist/charts/engine/orderbook/field.js.map +1 -0
  76. package/dist/charts/engine/orderbook/heatmap.cjs +1 -1
  77. package/dist/charts/engine/orderbook/heatmap.cjs.map +1 -1
  78. package/dist/charts/engine/orderbook/heatmap.js +413 -441
  79. package/dist/charts/engine/orderbook/heatmap.js.map +1 -1
  80. package/dist/charts/engine/orderbook/host.cjs +1 -1
  81. package/dist/charts/engine/orderbook/host.cjs.map +1 -1
  82. package/dist/charts/engine/orderbook/host.d.cts +8 -1
  83. package/dist/charts/engine/orderbook/host.d.ts +8 -1
  84. package/dist/charts/engine/orderbook/host.js +27 -5
  85. package/dist/charts/engine/orderbook/host.js.map +1 -1
  86. package/dist/charts/engine/orderbook/ladder.cjs +1 -1
  87. package/dist/charts/engine/orderbook/ladder.cjs.map +1 -1
  88. package/dist/charts/engine/orderbook/ladder.js +1 -1
  89. package/dist/charts/engine/orderbook/ladder.js.map +1 -1
  90. package/dist/charts/engine/orderbook/layout.cjs +1 -1
  91. package/dist/charts/engine/orderbook/layout.cjs.map +1 -1
  92. package/dist/charts/engine/orderbook/layout.d.cts +5 -0
  93. package/dist/charts/engine/orderbook/layout.d.ts +5 -0
  94. package/dist/charts/engine/orderbook/layout.js +8 -2
  95. package/dist/charts/engine/orderbook/layout.js.map +1 -1
  96. package/dist/charts/engine/orderbook/tape.cjs +1 -1
  97. package/dist/charts/engine/orderbook/tape.cjs.map +1 -1
  98. package/dist/charts/engine/orderbook/tape.js +3 -3
  99. package/dist/charts/engine/orderbook/tape.js.map +1 -1
  100. package/dist/charts/engine/orderbook/types.d.cts +12 -4
  101. package/dist/charts/engine/orderbook/types.d.ts +12 -4
  102. package/dist/charts/engine/overlay.cjs +1 -1
  103. package/dist/charts/engine/overlay.cjs.map +1 -1
  104. package/dist/charts/engine/overlay.d.cts +17 -0
  105. package/dist/charts/engine/overlay.d.ts +17 -0
  106. package/dist/charts/engine/overlay.js +29 -13
  107. package/dist/charts/engine/overlay.js.map +1 -1
  108. package/dist/charts/engine/presets.cjs +1 -1
  109. package/dist/charts/engine/presets.cjs.map +1 -1
  110. package/dist/charts/engine/presets.d.cts +12 -2
  111. package/dist/charts/engine/presets.d.ts +12 -2
  112. package/dist/charts/engine/presets.js +8 -2
  113. package/dist/charts/engine/presets.js.map +1 -1
  114. package/dist/charts/engine/renderers/canvas2d.cjs +1 -1
  115. package/dist/charts/engine/renderers/canvas2d.cjs.map +1 -1
  116. package/dist/charts/engine/renderers/canvas2d.js +13 -9
  117. package/dist/charts/engine/renderers/canvas2d.js.map +1 -1
  118. package/dist/charts/engine/renderers/follow.cjs +2 -0
  119. package/dist/charts/engine/renderers/follow.cjs.map +1 -0
  120. package/dist/charts/engine/renderers/follow.d.cts +8 -0
  121. package/dist/charts/engine/renderers/follow.d.ts +8 -0
  122. package/dist/charts/engine/renderers/follow.js +10 -0
  123. package/dist/charts/engine/renderers/follow.js.map +1 -0
  124. package/dist/charts/engine/renderers/gl-budget.cjs +2 -0
  125. package/dist/charts/engine/renderers/gl-budget.cjs.map +1 -0
  126. package/dist/charts/engine/renderers/gl-budget.d.cts +32 -0
  127. package/dist/charts/engine/renderers/gl-budget.d.ts +32 -0
  128. package/dist/charts/engine/renderers/gl-budget.js +95 -0
  129. package/dist/charts/engine/renderers/gl-budget.js.map +1 -0
  130. package/dist/charts/engine/renderers/gl.cjs +1 -1
  131. package/dist/charts/engine/renderers/gl.cjs.map +1 -1
  132. package/dist/charts/engine/renderers/gl.js +1 -1
  133. package/dist/charts/engine/renderers/gl.js.map +1 -1
  134. package/dist/charts/engine/renderers/shaders.cjs +9 -6
  135. package/dist/charts/engine/renderers/shaders.cjs.map +1 -1
  136. package/dist/charts/engine/renderers/shaders.d.cts +1 -1
  137. package/dist/charts/engine/renderers/shaders.d.ts +1 -1
  138. package/dist/charts/engine/renderers/shaders.js +9 -6
  139. package/dist/charts/engine/renderers/shaders.js.map +1 -1
  140. package/dist/charts/engine/renderers/types.cjs.map +1 -1
  141. package/dist/charts/engine/renderers/types.d.cts +2 -0
  142. package/dist/charts/engine/renderers/types.d.ts +2 -0
  143. package/dist/charts/engine/renderers/types.js.map +1 -1
  144. package/dist/charts/engine/renderers/webgl.cjs +1 -1
  145. package/dist/charts/engine/renderers/webgl.cjs.map +1 -1
  146. package/dist/charts/engine/renderers/webgl.js +85 -64
  147. package/dist/charts/engine/renderers/webgl.js.map +1 -1
  148. package/dist/charts/engine/renderers/webgl2.cjs +1 -1
  149. package/dist/charts/engine/renderers/webgl2.cjs.map +1 -1
  150. package/dist/charts/engine/renderers/webgl2.js +72 -58
  151. package/dist/charts/engine/renderers/webgl2.js.map +1 -1
  152. package/dist/charts/engine/renderers/webgpu.cjs +1 -1
  153. package/dist/charts/engine/renderers/webgpu.cjs.map +1 -1
  154. package/dist/charts/engine/renderers/webgpu.js +1 -1
  155. package/dist/charts/engine/renderers/webgpu.js.map +1 -1
  156. package/dist/charts/engine/scene.cjs +1 -1
  157. package/dist/charts/engine/scene.cjs.map +1 -1
  158. package/dist/charts/engine/scene.d.cts +51 -4
  159. package/dist/charts/engine/scene.d.ts +51 -4
  160. package/dist/charts/engine/scene.js +188 -122
  161. package/dist/charts/engine/scene.js.map +1 -1
  162. package/dist/charts/engine/shapes/chord.cjs +1 -1
  163. package/dist/charts/engine/shapes/chord.cjs.map +1 -1
  164. package/dist/charts/engine/shapes/chord.js +108 -103
  165. package/dist/charts/engine/shapes/chord.js.map +1 -1
  166. package/dist/charts/engine/shapes/types.d.cts +5 -3
  167. package/dist/charts/engine/shapes/types.d.ts +5 -3
  168. package/dist/charts/engine/three-d/canvas2d.cjs +1 -1
  169. package/dist/charts/engine/three-d/canvas2d.cjs.map +1 -1
  170. package/dist/charts/engine/three-d/canvas2d.d.cts +36 -1
  171. package/dist/charts/engine/three-d/canvas2d.d.ts +36 -1
  172. package/dist/charts/engine/three-d/canvas2d.js +155 -80
  173. package/dist/charts/engine/three-d/canvas2d.js.map +1 -1
  174. package/dist/charts/engine/three-d/chart.cjs +1 -1
  175. package/dist/charts/engine/three-d/chart.cjs.map +1 -1
  176. package/dist/charts/engine/three-d/chart.js +219 -215
  177. package/dist/charts/engine/three-d/chart.js.map +1 -1
  178. package/dist/charts/engine/three-d/oit.cjs +109 -0
  179. package/dist/charts/engine/three-d/oit.cjs.map +1 -0
  180. package/dist/charts/engine/three-d/oit.d.cts +34 -0
  181. package/dist/charts/engine/three-d/oit.d.ts +34 -0
  182. package/dist/charts/engine/three-d/oit.js +111 -0
  183. package/dist/charts/engine/three-d/oit.js.map +1 -0
  184. package/dist/charts/engine/three-d/render-types.cjs +1 -1
  185. package/dist/charts/engine/three-d/render-types.cjs.map +1 -1
  186. package/dist/charts/engine/three-d/render-types.d.cts +16 -3
  187. package/dist/charts/engine/three-d/render-types.d.ts +16 -3
  188. package/dist/charts/engine/three-d/render-types.js +6 -9
  189. package/dist/charts/engine/three-d/render-types.js.map +1 -1
  190. package/dist/charts/engine/three-d/shaders.cjs +52 -26
  191. package/dist/charts/engine/three-d/shaders.cjs.map +1 -1
  192. package/dist/charts/engine/three-d/shaders.d.cts +11 -3
  193. package/dist/charts/engine/three-d/shaders.d.ts +11 -3
  194. package/dist/charts/engine/three-d/shaders.js +84 -40
  195. package/dist/charts/engine/three-d/shaders.js.map +1 -1
  196. package/dist/charts/engine/three-d/sort.cjs +1 -1
  197. package/dist/charts/engine/three-d/sort.cjs.map +1 -1
  198. package/dist/charts/engine/three-d/sort.d.cts +6 -4
  199. package/dist/charts/engine/three-d/sort.d.ts +6 -4
  200. package/dist/charts/engine/three-d/sort.js +51 -39
  201. package/dist/charts/engine/three-d/sort.js.map +1 -1
  202. package/dist/charts/engine/three-d/types.d.cts +9 -0
  203. package/dist/charts/engine/three-d/types.d.ts +9 -0
  204. package/dist/charts/engine/three-d/webgl.cjs +1 -1
  205. package/dist/charts/engine/three-d/webgl.cjs.map +1 -1
  206. package/dist/charts/engine/three-d/webgl.d.cts +9 -0
  207. package/dist/charts/engine/three-d/webgl.d.ts +9 -0
  208. package/dist/charts/engine/three-d/webgl.js +199 -76
  209. package/dist/charts/engine/three-d/webgl.js.map +1 -1
  210. package/dist/charts/engine/three-d/webgpu.cjs +1 -1
  211. package/dist/charts/engine/three-d/webgpu.cjs.map +1 -1
  212. package/dist/charts/engine/three-d/webgpu.js +225 -99
  213. package/dist/charts/engine/three-d/webgpu.js.map +1 -1
  214. package/dist/charts/engine/trading/chart.cjs +1 -1
  215. package/dist/charts/engine/trading/chart.cjs.map +1 -1
  216. package/dist/charts/engine/trading/chart.d.cts +0 -1
  217. package/dist/charts/engine/trading/chart.d.ts +0 -1
  218. package/dist/charts/engine/trading/chart.js +1048 -883
  219. package/dist/charts/engine/trading/chart.js.map +1 -1
  220. package/dist/charts/engine/trading/drawings.cjs +2 -2
  221. package/dist/charts/engine/trading/drawings.cjs.map +1 -1
  222. package/dist/charts/engine/trading/drawings.d.cts +6 -0
  223. package/dist/charts/engine/trading/drawings.d.ts +6 -0
  224. package/dist/charts/engine/trading/drawings.js +100 -88
  225. package/dist/charts/engine/trading/drawings.js.map +1 -1
  226. package/dist/charts/engine/trading/format.cjs +1 -1
  227. package/dist/charts/engine/trading/format.cjs.map +1 -1
  228. package/dist/charts/engine/trading/format.d.cts +6 -0
  229. package/dist/charts/engine/trading/format.d.ts +6 -0
  230. package/dist/charts/engine/trading/format.js +42 -30
  231. package/dist/charts/engine/trading/format.js.map +1 -1
  232. package/dist/charts/engine/trading/geometry.cjs +1 -1
  233. package/dist/charts/engine/trading/geometry.cjs.map +1 -1
  234. package/dist/charts/engine/trading/geometry.d.cts +16 -0
  235. package/dist/charts/engine/trading/geometry.d.ts +16 -0
  236. package/dist/charts/engine/trading/geometry.js +19 -4
  237. package/dist/charts/engine/trading/geometry.js.map +1 -1
  238. package/dist/charts/engine/trading/labels.cjs +1 -1
  239. package/dist/charts/engine/trading/labels.cjs.map +1 -1
  240. package/dist/charts/engine/trading/labels.js +24 -4
  241. package/dist/charts/engine/trading/labels.js.map +1 -1
  242. package/dist/charts/engine/trading/studies.cjs +1 -1
  243. package/dist/charts/engine/trading/studies.cjs.map +1 -1
  244. package/dist/charts/engine/trading/studies.d.cts +8 -0
  245. package/dist/charts/engine/trading/studies.d.ts +8 -0
  246. package/dist/charts/engine/trading/studies.js +4 -1
  247. package/dist/charts/engine/trading/studies.js.map +1 -1
  248. package/dist/charts/engine/trading/types.d.cts +34 -11
  249. package/dist/charts/engine/trading/types.d.ts +34 -11
  250. package/dist/charts/engine/types.d.cts +25 -4
  251. package/dist/charts/engine/types.d.ts +25 -4
  252. package/dist/charts/react/charts.cjs +1 -1
  253. package/dist/charts/react/charts.cjs.map +1 -1
  254. package/dist/charts/react/charts.js +20 -15
  255. package/dist/charts/react/charts.js.map +1 -1
  256. package/dist/charts/react/graph.cjs +1 -1
  257. package/dist/charts/react/graph.cjs.map +1 -1
  258. package/dist/charts/react/graph.d.cts +6 -0
  259. package/dist/charts/react/graph.d.ts +6 -0
  260. package/dist/charts/react/graph.js +28 -27
  261. package/dist/charts/react/graph.js.map +1 -1
  262. package/dist/charts/react/orderbook.cjs +1 -1
  263. package/dist/charts/react/orderbook.cjs.map +1 -1
  264. package/dist/charts/react/orderbook.d.cts +3 -1
  265. package/dist/charts/react/orderbook.d.ts +3 -1
  266. package/dist/charts/react/orderbook.js +1 -0
  267. package/dist/charts/react/orderbook.js.map +1 -1
  268. package/dist/charts/react/shapes.cjs.map +1 -1
  269. package/dist/charts/react/shapes.d.cts +4 -3
  270. package/dist/charts/react/shapes.d.ts +4 -3
  271. package/dist/charts/react/shapes.js.map +1 -1
  272. package/dist/charts/react/three-d.cjs +1 -1
  273. package/dist/charts/react/three-d.cjs.map +1 -1
  274. package/dist/charts/react/three-d.d.cts +7 -0
  275. package/dist/charts/react/three-d.d.ts +7 -0
  276. package/dist/charts/react/three-d.js +14 -13
  277. package/dist/charts/react/three-d.js.map +1 -1
  278. package/dist/charts/react/trading.cjs.map +1 -1
  279. package/dist/charts/react/trading.d.cts +3 -3
  280. package/dist/charts/react/trading.d.ts +3 -3
  281. package/dist/charts/react/trading.js.map +1 -1
  282. package/dist/core/contracts.cjs +1 -1
  283. package/dist/core/contracts.cjs.map +1 -1
  284. package/dist/core/contracts.js +1 -1
  285. package/dist/core/contracts.js.map +1 -1
  286. package/dist/native/charts/src/canvas.cjs +1 -1
  287. package/dist/native/charts/src/canvas.js +4 -3
  288. package/dist/native/charts/src/engine/controller.cjs +2 -2
  289. package/dist/native/charts/src/engine/controller.cjs.map +1 -1
  290. package/dist/native/charts/src/engine/controller.js +102 -104
  291. package/dist/native/charts/src/engine/controller.js.map +1 -1
  292. package/dist/native/charts/src/engine/labels.cjs +1 -1
  293. package/dist/native/charts/src/engine/labels.cjs.map +1 -1
  294. package/dist/native/charts/src/engine/labels.js +14 -1
  295. package/dist/native/charts/src/engine/labels.js.map +1 -1
  296. package/dist/native/charts/src/engine/model.cjs +1 -1
  297. package/dist/native/charts/src/engine/model.cjs.map +1 -1
  298. package/dist/native/charts/src/engine/model.js +180 -157
  299. package/dist/native/charts/src/engine/model.js.map +1 -1
  300. package/dist/native/charts/src/engine/overlay.cjs.map +1 -1
  301. package/dist/native/charts/src/engine/overlay.js.map +1 -1
  302. package/dist/native/charts/src/engine/presets.cjs +1 -1
  303. package/dist/native/charts/src/engine/presets.cjs.map +1 -1
  304. package/dist/native/charts/src/engine/presets.js +8 -2
  305. package/dist/native/charts/src/engine/presets.js.map +1 -1
  306. package/dist/native/charts/src/engine/scene.cjs +1 -1
  307. package/dist/native/charts/src/engine/scene.cjs.map +1 -1
  308. package/dist/native/charts/src/engine/scene.js +188 -122
  309. package/dist/native/charts/src/engine/scene.js.map +1 -1
  310. package/dist/native/charts/src/engine/shapes/chord.cjs +1 -1
  311. package/dist/native/charts/src/engine/shapes/chord.cjs.map +1 -1
  312. package/dist/native/charts/src/engine/shapes/chord.js +108 -103
  313. package/dist/native/charts/src/engine/shapes/chord.js.map +1 -1
  314. package/dist/native/charts/src/engine/shapes/layout.cjs +2 -2
  315. package/dist/native/charts/src/engine/shapes/layout.cjs.map +1 -1
  316. package/dist/native/charts/src/engine/shapes/layout.js +88 -73
  317. package/dist/native/charts/src/engine/shapes/layout.js.map +1 -1
  318. package/dist/native/components/Chart/ChartBase.cjs +1 -1
  319. package/dist/native/components/Chart/ChartBase.cjs.map +1 -1
  320. package/dist/native/components/Chart/ChartBase.js +127 -115
  321. package/dist/native/components/Chart/ChartBase.js.map +1 -1
  322. package/dist/native/components/Chart/charts.cjs +1 -1
  323. package/dist/native/components/Chart/charts.cjs.map +1 -1
  324. package/dist/native/components/Chart/charts.js +8 -5
  325. package/dist/native/components/Chart/charts.js.map +1 -1
  326. package/dist/native/components/Chart/scene.cjs +1 -1
  327. package/dist/native/components/Chart/scene.cjs.map +1 -1
  328. package/dist/native/components/Chart/scene.d.cts +6 -1
  329. package/dist/native/components/Chart/scene.d.ts +6 -1
  330. package/dist/native/components/Chart/scene.js +99 -50
  331. package/dist/native/components/Chart/scene.js.map +1 -1
  332. package/dist/native/components/Chart/types.d.cts +7 -1
  333. package/dist/native/components/Chart/types.d.ts +7 -1
  334. package/dist/native/components/Charts/charts.cjs +1 -1
  335. package/dist/native/components/Charts/charts.cjs.map +1 -1
  336. package/dist/native/components/Charts/charts.js +23 -18
  337. package/dist/native/components/Charts/charts.js.map +1 -1
  338. package/dist/native/components/ShapeChart/ShapeChartBase.cjs +1 -1
  339. package/dist/native/components/ShapeChart/ShapeChartBase.cjs.map +1 -1
  340. package/dist/native/components/ShapeChart/ShapeChartBase.d.cts +1 -1
  341. package/dist/native/components/ShapeChart/ShapeChartBase.d.ts +1 -1
  342. package/dist/native/components/ShapeChart/ShapeChartBase.js +97 -107
  343. package/dist/native/components/ShapeChart/ShapeChartBase.js.map +1 -1
  344. package/dist/native/components/ShapeChart/geometry.cjs +1 -1
  345. package/dist/native/components/ShapeChart/geometry.cjs.map +1 -1
  346. package/dist/native/components/ShapeChart/geometry.js +120 -36
  347. package/dist/native/components/ShapeChart/geometry.js.map +1 -1
  348. package/dist/native/components/ShapeChart/types.d.cts +6 -4
  349. package/dist/native/components/ShapeChart/types.d.ts +6 -4
  350. package/dist/native/source/components/Chart/ChartBase.tsx +19 -6
  351. package/dist/native/source/components/Chart/charts.tsx +10 -3
  352. package/dist/native/source/components/Chart/scene.tsx +85 -0
  353. package/dist/native/source/components/Chart/types.ts +7 -0
  354. package/dist/native/source/components/Charts/charts.tsx +7 -0
  355. package/dist/native/source/components/ShapeChart/ShapeChartBase.tsx +10 -36
  356. package/dist/native/source/components/ShapeChart/geometry.ts +188 -18
  357. package/dist/native/source/components/ShapeChart/types.ts +6 -4
  358. package/dist/taro/chart-a11y.d.ts +7 -0
  359. package/dist/taro/charts.d.ts +4 -1
  360. package/dist/taro/index.js +3212 -3049
  361. package/dist/taro/shape-charts.d.ts +6 -4
  362. package/dist/uni/AreaChart.vue +2 -1
  363. package/dist/uni/AreaChart.vue.d.ts +1 -1
  364. package/dist/uni/BarChart.vue +2 -1
  365. package/dist/uni/BarChart.vue.d.ts +1 -1
  366. package/dist/uni/BoxPlotChart.vue +2 -1
  367. package/dist/uni/BubbleChart.vue +2 -1
  368. package/dist/uni/CandlestickChart.vue +2 -1
  369. package/dist/uni/Chart.vue +2 -1
  370. package/dist/uni/Divider.vue.d.ts +1 -1
  371. package/dist/uni/DonutChart.vue.d.ts +1 -1
  372. package/dist/uni/GanttChart.vue +2 -1
  373. package/dist/uni/GanttChart.vue.d.ts +11 -0
  374. package/dist/uni/GaugeChart.vue.d.ts +1 -1
  375. package/dist/uni/HeatmapChart.vue +2 -1
  376. package/dist/uni/HistogramChart.vue +2 -1
  377. package/dist/uni/HorizontalBarChart.vue +2 -1
  378. package/dist/uni/HorizontalBarChart.vue.d.ts +1 -1
  379. package/dist/uni/LineChart.vue +2 -1
  380. package/dist/uni/MixedChart.vue +2 -1
  381. package/dist/uni/PieChart.vue.d.ts +1 -1
  382. package/dist/uni/QuadrantChart.vue +2 -1
  383. package/dist/uni/RangeAreaChart.vue +2 -1
  384. package/dist/uni/ScatterChart.vue +2 -1
  385. package/dist/uni/Sparkline.vue +2 -1
  386. package/dist/uni/WaterfallChart.vue +2 -1
  387. package/dist/uni/chart-a11y.d.ts +7 -0
  388. package/dist/uni/chart-a11y.js +29 -0
  389. package/dist/uni/chart-canvas.d.ts +9 -0
  390. package/dist/uni/chart-canvas.js +11 -1
  391. package/dist/uni/chart-types.d.ts +8 -1
  392. package/dist/uni/chart-types.js +5 -1
  393. package/dist/uni/charts-canvas.js +2 -1
  394. package/dist/uni/named-chart-options.d.ts +2 -0
  395. package/dist/uni/named-chart-options.js +3 -0
  396. package/dist/uni/shape-chart-canvas.d.ts +0 -2
  397. package/dist/uni/shape-chart-canvas.js +4 -36
  398. package/dist/uni/shape-chart-types.d.ts +2 -2
  399. package/dist/uni/shape-chart-types.js +2 -2
  400. package/dist/vue/components/Chart/Bar3DChart.vue.d.ts +2 -0
  401. package/dist/vue/components/Chart/DependencyGraph.vue.d.ts +2 -0
  402. package/dist/vue/components/Chart/GanttChart.vue.d.ts +15 -0
  403. package/dist/vue/components/Chart/GanttChart.vue.js.map +1 -1
  404. package/dist/vue/components/Chart/GanttChart.vue_vue_type_script_setup_true_lang.js +8 -0
  405. package/dist/vue/components/Chart/GanttChart.vue_vue_type_script_setup_true_lang.js.map +1 -1
  406. package/dist/vue/components/Chart/GraphChart.vue.d.ts +2 -0
  407. package/dist/vue/components/Chart/Line3DChart.vue.d.ts +2 -0
  408. package/dist/vue/components/Chart/Scatter3DChart.vue.d.ts +2 -0
  409. package/dist/vue/components/Chart/Surface3DChart.vue.d.ts +2 -0
  410. package/dist/vue/components/Chart/TradingChart.vue.d.ts +9 -0
  411. package/dist/vue/components/Chart/TreeChart.vue.d.ts +2 -0
  412. package/dist/vue/components/Chart/graph.d.ts +3 -0
  413. package/dist/vue/components/Chart/graph.js +2 -0
  414. package/dist/vue/components/Chart/graph.js.map +1 -1
  415. package/dist/vue/components/Chart/three-d.d.ts +3 -0
  416. package/dist/vue/components/Chart/three-d.js +2 -0
  417. package/dist/vue/components/Chart/three-d.js.map +1 -1
  418. package/dist/vue/components/Chart/trading.d.ts +7 -2
  419. package/dist/vue/components/Chart/trading.js +1 -0
  420. package/dist/vue/components/Chart/trading.js.map +1 -1
  421. package/dist/weapp/area-chart/index.wxml +1 -1
  422. package/dist/weapp/bar-chart/index.wxml +1 -1
  423. package/dist/weapp/box-plot-chart/index.wxml +1 -1
  424. package/dist/weapp/bubble-chart/index.wxml +1 -1
  425. package/dist/weapp/candlestick-chart/index.wxml +1 -1
  426. package/dist/weapp/chart/index.wxml +1 -1
  427. package/dist/weapp/charts/canvas.js +326 -54
  428. package/dist/weapp/charts/core.js +2 -0
  429. package/dist/weapp/controls.js +58 -27
  430. package/dist/weapp/gantt-chart/index.wxml +1 -1
  431. package/dist/weapp/heatmap-chart/index.wxml +1 -1
  432. package/dist/weapp/histogram-chart/index.wxml +1 -1
  433. package/dist/weapp/horizontal-bar-chart/index.wxml +1 -1
  434. package/dist/weapp/line-chart/index.wxml +1 -1
  435. package/dist/weapp/mixed-chart/index.wxml +1 -1
  436. package/dist/weapp/quadrant-chart/index.wxml +1 -1
  437. package/dist/weapp/range-area-chart/index.wxml +1 -1
  438. package/dist/weapp/scatter-chart/index.wxml +1 -1
  439. package/dist/weapp/sparkline/index.wxml +1 -1
  440. package/dist/weapp/types.d.ts +11 -2
  441. package/dist/weapp/waterfall-chart/index.wxml +1 -1
  442. package/dist/web-components/components/chart/extended.d.ts +4 -0
  443. package/dist/web-components/components/chart/extended.js +8 -2
  444. package/dist/web-components/components/chart/extended.js.map +1 -1
  445. package/dist/web-components/components/chart-3d/chart-3d.d.ts +1 -1
  446. package/dist/web-components/components/chart-3d/chart-3d.js.map +1 -1
  447. package/dist/web-components/components/graph/graph.d.ts +2 -0
  448. package/dist/web-components/components/graph/graph.js +3 -2
  449. package/dist/web-components/components/graph/graph.js.map +1 -1
  450. package/dist/web-components/components/trading-chart/trading-chart.d.ts +1 -1
  451. package/dist/web-components/components/trading-chart/trading-chart.js.map +1 -1
  452. package/dist/web-components/html-custom-data.json +45 -0
  453. package/dist/web-components/types/react.d.ts +4 -4
  454. package/dist/web-components/types/solid.d.ts +8 -8
  455. package/dist/web-components/types/svelte.d.ts +8 -8
  456. package/dist/web-components/types/vue.d.ts +4 -4
  457. package/package.json +1 -1
@@ -0,0 +1,111 @@
1
+ //#region src/engine/three-d/oit.ts
2
+ var e = 64, t = 12, n = .01, r = .999, i = .6, a = 1, o = 6, s = .35, c = (e) => Number.isInteger(e) ? e.toFixed(1) : String(e), l = `
3
+ struct Oit {
4
+ @location(0) accum: vec4f,
5
+ @location(1) extra: vec4f,
6
+ };
7
+
8
+ fn oit(c: vec4f, depth: f32) -> Oit {
9
+ var o: Oit;
10
+ if (u.light.w > 0.5) {
11
+ o.accum = vec4f(0.0);
12
+ o.extra = vec4f(c.rgb, 0.0);
13
+ return o;
14
+ }
15
+ let a = clamp(c.a, 0.0, ${c(r)});
16
+ let w = max(${c(n)}, ${c(e)} * exp2(-${c(t)} * clamp(depth, 0.0, 1.0)));
17
+ o.accum = vec4f(c.rgb, a) * w;
18
+ o.extra = vec4f(0.0, 0.0, 0.0, -log(1.0 - a));
19
+ return o;
20
+ }
21
+ `, u = `${`
22
+ fn shoulder(x: f32) -> f32 {
23
+ if (x <= ${c(i)}) { return x; }
24
+ let t = (x - ${c(i)}) / ${c(.4)};
25
+ return ${c(i)} + ${c(.4)} * t / (1.0 + t);
26
+ }
27
+
28
+ fn toneMap(rgb: vec3f) -> vec3f {
29
+ let m = max(max(rgb.r, rgb.g), rgb.b);
30
+ if (m <= 1e-6) { return rgb; }
31
+ let peak = shoulder(m);
32
+ let scaled = rgb * (peak / m);
33
+ return mix(scaled, vec3f(peak), smoothstep(${c(a)}, ${c(o)}, m) * ${c(s)});
34
+ }
35
+ `}
36
+ @group(0) @binding(0) var accumTex: texture_2d<f32>;
37
+ @group(0) @binding(1) var extraTex: texture_2d<f32>;
38
+
39
+ @vertex
40
+ fn vs(@builtin(vertex_index) vi: u32) -> @builtin(position) vec4f {
41
+ let p = vec2f(f32((vi << 1u) & 2u), f32(vi & 2u)) * 2.0 - 1.0;
42
+ return vec4f(p, 0.0, 1.0);
43
+ }
44
+
45
+ @fragment
46
+ fn fs(@builtin(position) position: vec4f) -> @location(0) vec4f {
47
+ let xy = vec2i(position.xy);
48
+ let accum = textureLoad(accumTex, xy, 0);
49
+ let extra = textureLoad(extraTex, xy, 0);
50
+ let alpha = 1.0 - exp(-extra.a);
51
+ let light = toneMap(extra.rgb);
52
+ let lightAlpha = clamp(max(max(light.r, light.g), light.b), 0.0, 1.0);
53
+ let rgb = accum.rgb * (alpha / max(accum.a, 1e-6)) + light * (1.0 - alpha);
54
+ let a = alpha + lightAlpha * (1.0 - alpha);
55
+ if (a <= 0.0) { discard; }
56
+ return vec4f(rgb, a);
57
+ }
58
+ `, d = `
59
+ layout(location = 0) out vec4 o_accum;
60
+ layout(location = 1) out vec4 o_extra;
61
+ void emitOit(vec4 c, float depth) {
62
+ if (u_light.w > 0.5) {
63
+ o_accum = vec4(0.0);
64
+ o_extra = vec4(c.rgb, 0.0);
65
+ return;
66
+ }
67
+ float a = clamp(c.a, 0.0, ${c(r)});
68
+ float w = max(${c(n)}, ${c(e)} * exp2(-${c(t)} * clamp(depth, 0.0, 1.0)));
69
+ o_accum = vec4(c.rgb, a) * w;
70
+ o_extra = vec4(0.0, 0.0, 0.0, -log(1.0 - a));
71
+ }
72
+ #define EMIT(c, d) emitOit(c, d)
73
+ `, f = {
74
+ vertex: "#version 300 es\nvoid main() {\n vec2 p = vec2(float((gl_VertexID << 1) & 2), float(gl_VertexID & 2)) * 2.0 - 1.0;\n gl_Position = vec4(p, 0.0, 1.0);\n}\n",
75
+ fragment: `#version 300 es
76
+ precision highp float;
77
+ uniform sampler2D u_accum;
78
+ uniform sampler2D u_extra;
79
+ out vec4 fragColor;
80
+ ${`
81
+ float shoulder(float x) {
82
+ if (x <= ${c(i)}) return x;
83
+ float t = (x - ${c(i)}) / ${c(.4)};
84
+ return ${c(i)} + ${c(.4)} * t / (1.0 + t);
85
+ }
86
+ vec3 toneMap(vec3 rgb) {
87
+ float m = max(max(rgb.r, rgb.g), rgb.b);
88
+ if (m <= 1e-6) return rgb;
89
+ float peak = shoulder(m);
90
+ vec3 scaled = rgb * (peak / m);
91
+ return mix(scaled, vec3(peak), smoothstep(${c(a)}, ${c(o)}, m) * ${c(s)});
92
+ }
93
+ `}
94
+ void main() {
95
+ ivec2 xy = ivec2(gl_FragCoord.xy);
96
+ vec4 accum = texelFetch(u_accum, xy, 0);
97
+ vec4 extra = texelFetch(u_extra, xy, 0);
98
+ float alpha = 1.0 - exp(-extra.a);
99
+ vec3 light = toneMap(extra.rgb);
100
+ float lightAlpha = clamp(max(max(light.r, light.g), light.b), 0.0, 1.0);
101
+ vec3 rgb = accum.rgb * (alpha / max(accum.a, 1e-6)) + light * (1.0 - alpha);
102
+ float a = alpha + lightAlpha * (1.0 - alpha);
103
+ if (a <= 0.0) discard;
104
+ fragColor = vec4(rgb, a);
105
+ }
106
+ `
107
+ };
108
+ //#endregion
109
+ export { f as GLSL_COMPOSITE, d as GLSL_OIT, i as TONE_KNEE, u as WGSL_COMPOSITE, l as WGSL_OIT };
110
+
111
+ //# sourceMappingURL=oit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oit.js","names":["WEIGHT_SCALE","WEIGHT_FALLOFF","WEIGHT_MIN","MAX_ALPHA","TONE_KNEE","WHITE_FROM","WHITE_TO","WHITE_AMOUNT","f","v","WGSL_OIT","WGSL_COMPOSITE","GLSL_OIT","GLSL_COMPOSITE"],"sources":["../../../../../charts/src/engine/three-d/oit.ts"],"sourcesContent":["// Weighted blended order-independent transparency (McGuire & Bavoil 2013)\n// of the WebGPU and WebGL2 backends, and the tone mapping of the additive\n// light. The blended items (transparent meshes, blended and additive points)\n// are drawn in any order, without writing depth, into two float targets\n// cleared to 0 and blended by plain addition (one, one):\n//\n// accum rgb: Σ premultiplied color × w a: Σ alpha × w\n// extra rgb: Σ additive light a: Σ −ln(1 − alpha)\n//\n// w favours the fragments near the camera (`oitWeight`). The revealage\n// Π(1 − alpha) is stored as the sum of its logarithms so that every target\n// uses the same additive blending (WebGL2 has no per-target blend\n// functions). The composite pass blends over the opaque scene:\n//\n// transparent = (accum.rgb / accum.a) × (1 − e^−extra.a), alpha 1 − e^−extra.a\n// light = toneMap(extra.rgb), alpha its largest channel\n//\n// `toneMap` keeps the colors below a knee and rolls the brighter ones off\n// towards 1 (Reinhard) by their largest channel (hue preserving), whitening\n// only the very bright light a little: dense glowing clouds saturate\n// gracefully instead of clipping to white.\n\n/** Weight of the closest fragments; halves every 1/12 of the depth range */\nconst WEIGHT_SCALE = 64;\nconst WEIGHT_FALLOFF = 12;\nconst WEIGHT_MIN = 0.01;\n/** Largest alpha of a blended fragment (keeps −ln(1 − alpha) finite) */\nconst MAX_ALPHA = 0.999;\n/** Light values below the knee are kept */\nexport const TONE_KNEE = 0.6;\n/** Light values where the whitening starts / is full, and its amount */\nconst WHITE_FROM = 1;\nconst WHITE_TO = 6;\nconst WHITE_AMOUNT = 0.35;\n\n/**\n * Weight of a blended fragment at a depth (0 nearest … 1 farthest point of\n * the box sphere): 64 × 2^(−12 depth), at least 0.01. Accumulated in half\n * floats: about a thousand layers of the nearest fragments fit.\n */\nexport const oitWeight = (depth: number): number =>\n Math.max(\n WEIGHT_MIN,\n WEIGHT_SCALE *\n Math.pow(2, -WEIGHT_FALLOFF * Math.min(1, Math.max(0, depth))),\n );\n\n/**\n * Soft shoulder: identity below `TONE_KNEE`, then a Reinhard roll-off\n * towards 1 (never reached) with a continuous slope: bright regions keep a\n * gradient instead of a flat plateau\n */\nexport const shoulder = (x: number): number => {\n if (x <= TONE_KNEE) return x;\n const t = (x - TONE_KNEE) / (1 - TONE_KNEE);\n return TONE_KNEE + (1 - TONE_KNEE) * (t / (1 + t));\n};\n\nconst smoothstep = (a: number, b: number, x: number) => {\n const t = Math.min(1, Math.max(0, (x - a) / (b - a)));\n return t * t * (3 - 2 * t);\n};\n\n/** Tone mapping of additive light (linear, premultiplied) */\nexport const toneMap = (\n rgb: readonly [number, number, number],\n): [number, number, number] => {\n const m = Math.max(rgb[0], rgb[1], rgb[2]);\n if (m <= 1e-6) return [rgb[0], rgb[1], rgb[2]];\n const peak = shoulder(m);\n const s = peak / m;\n const white = smoothstep(WHITE_FROM, WHITE_TO, m) * WHITE_AMOUNT;\n return [\n rgb[0] * s + (peak - rgb[0] * s) * white,\n rgb[1] * s + (peak - rgb[1] * s) * white,\n rgb[2] * s + (peak - rgb[2] * s) * white,\n ];\n};\n\n/** What a blended fragment adds to the two targets (JS mirror of the shaders) */\nexport const oitFragment = (\n premultiplied: readonly [number, number, number, number],\n depth: number,\n additive: boolean,\n): { accum: number[]; extra: number[] } => {\n const [r, g, b, alpha] = premultiplied;\n if (additive) return { accum: [0, 0, 0, 0], extra: [r, g, b, 0] };\n const a = Math.min(MAX_ALPHA, Math.max(0, alpha));\n const w = oitWeight(depth);\n return {\n accum: [r * w, g * w, b * w, a * w],\n extra: [0, 0, 0, -Math.log(1 - a)],\n };\n};\n\n/** Composite of the targets: a premultiplied color (JS mirror of the shaders) */\nexport const oitComposite = (\n accum: readonly number[],\n extra: readonly number[],\n): [number, number, number, number] => {\n const alpha = 1 - Math.exp(-(extra[3] ?? 0));\n const k = alpha / Math.max(accum[3] ?? 0, 1e-6);\n const light = toneMap([extra[0] ?? 0, extra[1] ?? 0, extra[2] ?? 0]);\n const lightAlpha = Math.min(1, Math.max(light[0], light[1], light[2]));\n const behind = 1 - alpha;\n return [\n (accum[0] ?? 0) * k + light[0] * behind,\n (accum[1] ?? 0) * k + light[1] * behind,\n (accum[2] ?? 0) * k + light[2] * behind,\n alpha + lightAlpha * behind,\n ];\n};\n\nconst f = (v: number) => (Number.isInteger(v) ? v.toFixed(1) : String(v));\n\n// ------------------------------------------------------------------- WGSL\n\n/** Second fragment entry point of the points and meshes: `fsOit` */\nexport const WGSL_OIT = /* wgsl */ `\nstruct Oit {\n @location(0) accum: vec4f,\n @location(1) extra: vec4f,\n};\n\nfn oit(c: vec4f, depth: f32) -> Oit {\n var o: Oit;\n if (u.light.w > 0.5) {\n o.accum = vec4f(0.0);\n o.extra = vec4f(c.rgb, 0.0);\n return o;\n }\n let a = clamp(c.a, 0.0, ${f(MAX_ALPHA)});\n let w = max(${f(WEIGHT_MIN)}, ${f(WEIGHT_SCALE)} * exp2(-${f(WEIGHT_FALLOFF)} * clamp(depth, 0.0, 1.0)));\n o.accum = vec4f(c.rgb, a) * w;\n o.extra = vec4f(0.0, 0.0, 0.0, -log(1.0 - a));\n return o;\n}\n`;\n\nconst WGSL_TONE = /* wgsl */ `\nfn shoulder(x: f32) -> f32 {\n if (x <= ${f(TONE_KNEE)}) { return x; }\n let t = (x - ${f(TONE_KNEE)}) / ${f(1 - TONE_KNEE)};\n return ${f(TONE_KNEE)} + ${f(1 - TONE_KNEE)} * t / (1.0 + t);\n}\n\nfn toneMap(rgb: vec3f) -> vec3f {\n let m = max(max(rgb.r, rgb.g), rgb.b);\n if (m <= 1e-6) { return rgb; }\n let peak = shoulder(m);\n let scaled = rgb * (peak / m);\n return mix(scaled, vec3f(peak), smoothstep(${f(WHITE_FROM)}, ${f(WHITE_TO)}, m) * ${f(WHITE_AMOUNT)});\n}\n`;\n\n/** Full-screen composite of the two targets over the opaque scene */\nexport const WGSL_COMPOSITE = /* wgsl */ `${WGSL_TONE}\n@group(0) @binding(0) var accumTex: texture_2d<f32>;\n@group(0) @binding(1) var extraTex: texture_2d<f32>;\n\n@vertex\nfn vs(@builtin(vertex_index) vi: u32) -> @builtin(position) vec4f {\n let p = vec2f(f32((vi << 1u) & 2u), f32(vi & 2u)) * 2.0 - 1.0;\n return vec4f(p, 0.0, 1.0);\n}\n\n@fragment\nfn fs(@builtin(position) position: vec4f) -> @location(0) vec4f {\n let xy = vec2i(position.xy);\n let accum = textureLoad(accumTex, xy, 0);\n let extra = textureLoad(extraTex, xy, 0);\n let alpha = 1.0 - exp(-extra.a);\n let light = toneMap(extra.rgb);\n let lightAlpha = clamp(max(max(light.r, light.g), light.b), 0.0, 1.0);\n let rgb = accum.rgb * (alpha / max(accum.a, 1e-6)) + light * (1.0 - alpha);\n let a = alpha + lightAlpha * (1.0 - alpha);\n if (a <= 0.0) { discard; }\n return vec4f(rgb, a);\n}\n`;\n\n// ------------------------------------------------------------------- GLSL\n\n/** Outputs of the OIT variants (GLSL ES 3.0): `EMIT(color, depth)` */\nexport const GLSL_OIT = `\nlayout(location = 0) out vec4 o_accum;\nlayout(location = 1) out vec4 o_extra;\nvoid emitOit(vec4 c, float depth) {\n if (u_light.w > 0.5) {\n o_accum = vec4(0.0);\n o_extra = vec4(c.rgb, 0.0);\n return;\n }\n float a = clamp(c.a, 0.0, ${f(MAX_ALPHA)});\n float w = max(${f(WEIGHT_MIN)}, ${f(WEIGHT_SCALE)} * exp2(-${f(WEIGHT_FALLOFF)} * clamp(depth, 0.0, 1.0)));\n o_accum = vec4(c.rgb, a) * w;\n o_extra = vec4(0.0, 0.0, 0.0, -log(1.0 - a));\n}\n#define EMIT(c, d) emitOit(c, d)\n`;\n\nconst GLSL_TONE = `\nfloat shoulder(float x) {\n if (x <= ${f(TONE_KNEE)}) return x;\n float t = (x - ${f(TONE_KNEE)}) / ${f(1 - TONE_KNEE)};\n return ${f(TONE_KNEE)} + ${f(1 - TONE_KNEE)} * t / (1.0 + t);\n}\nvec3 toneMap(vec3 rgb) {\n float m = max(max(rgb.r, rgb.g), rgb.b);\n if (m <= 1e-6) return rgb;\n float peak = shoulder(m);\n vec3 scaled = rgb * (peak / m);\n return mix(scaled, vec3(peak), smoothstep(${f(WHITE_FROM)}, ${f(WHITE_TO)}, m) * ${f(WHITE_AMOUNT)});\n}\n`;\n\n/** Composite program of WebGL2 (full-screen triangle from `gl_VertexID`) */\nexport const GLSL_COMPOSITE = {\n vertex: `#version 300 es\nvoid main() {\n vec2 p = vec2(float((gl_VertexID << 1) & 2), float(gl_VertexID & 2)) * 2.0 - 1.0;\n gl_Position = vec4(p, 0.0, 1.0);\n}\n`,\n fragment: `#version 300 es\nprecision highp float;\nuniform sampler2D u_accum;\nuniform sampler2D u_extra;\nout vec4 fragColor;\n${GLSL_TONE}\nvoid main() {\n ivec2 xy = ivec2(gl_FragCoord.xy);\n vec4 accum = texelFetch(u_accum, xy, 0);\n vec4 extra = texelFetch(u_extra, xy, 0);\n float alpha = 1.0 - exp(-extra.a);\n vec3 light = toneMap(extra.rgb);\n float lightAlpha = clamp(max(max(light.r, light.g), light.b), 0.0, 1.0);\n vec3 rgb = accum.rgb * (alpha / max(accum.a, 1e-6)) + light * (1.0 - alpha);\n float a = alpha + lightAlpha * (1.0 - alpha);\n if (a <= 0.0) discard;\n fragColor = vec4(rgb, a);\n}\n`,\n};\n"],"mappings":";AAuBA,IAAMA,IAAe,IACfC,IAAiB,IACjBC,IAAa,KAEbC,IAAY,MAELC,IAAY,IAEnBC,IAAa,GACbC,IAAW,GACXC,IAAe,KAgFfC,KAAK,MAAe,OAAO,UAAUC,CAAC,IAAIA,EAAE,QAAQ,CAAC,IAAI,OAAOA,CAAC,GAK1DC,IAAsB;;;;;;;;;;;;;4BAaPF,EAAEL,CAAS,EAAE;gBACzBK,EAAEN,CAAU,EAAE,IAAIM,EAAER,CAAY,EAAE,WAAWQ,EAAEP,CAAc,EAAE;;;;;GAwBlEU,IAA4B,GAAG;;aAf/BH,EAAEJ,CAAS,EAAE;iBACTI,EAAEJ,CAAS,EAAE,MAAMI,EAAE,EAAa,EAAE;WAC1CA,EAAEJ,CAAS,EAAE,KAAKI,EAAE,EAAa,EAAE;;;;;;;;+CAQCA,EAAEH,CAAU,EAAE,IAAIG,EAAEF,CAAQ,EAAE,SAASE,EAAED,CAAY,EAAE;;EAKhD;;;;;;;;;;;;;;;;;;;;;;;GA4BzCK,IAAW;;;;;;;;;8BASMJ,EAAEL,CAAS,EAAE;kBACzBK,EAAEN,CAAU,EAAE,IAAIM,EAAER,CAAY,EAAE,WAAWQ,EAAEP,CAAc,EAAE;;;;;GAuBpEY,IAAiB;CAC5B,QAAQ;CAMR,UAAU;;;;;EAKV;;aA1BWL,EAAEJ,CAAS,EAAE;mBACPI,EAAEJ,CAAS,EAAE,MAAMI,EAAE,EAAa,EAAE;WAC5CA,EAAEJ,CAAS,EAAE,KAAKI,EAAE,EAAa,EAAE;;;;;;;8CAOAA,EAAEH,CAAU,EAAE,IAAIG,EAAEF,CAAQ,EAAE,SAASE,EAAED,CAAY,EAAE;;EAiBzF;;;;;;;;;;;;;;AAcZ"}
@@ -1,2 +1,2 @@
1
- var e=e=>e.opacity<1?!1:e.kind===`mesh`?!e.transparent:e.kind!==`points`||!e.additive&&e.style!==2,t=t=>{let n=t=>t.kind===`mesh`?e(t)?0:3:t.kind===`points`?e(t)?1:2:4;return t.map((e,t)=>({item:e,i:t,r:n(e)})).sort((e,t)=>e.r-t.r||e.i-t.i).map(e=>e.item)};exports.drawOrder=t,exports.writesDepth=e;
1
+ var e=e=>e.opacity<1?!1:e.kind===`mesh`?!e.transparent:e.kind!==`points`||!e.additive&&e.style!==2,t=t=>t.kind===`lines`?3:e(t)?t.kind===`mesh`?0:1:2,n=e=>e.map((e,n)=>({item:e,i:n,r:t(e)})).sort((e,t)=>e.r-t.r||e.i-t.i).map(e=>e.item);exports.drawOrder=n,exports.drawRank=t,exports.writesDepth=e;
2
2
  //# sourceMappingURL=render-types.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-types.cjs","names":["writesDepth","item","drawOrder","rank","items","a","b"],"sources":["../../../../../charts/src/engine/three-d/render-types.ts"],"sourcesContent":["// Contract between the 3D chart and its data-layer backends.\n\nimport type { Rgba } from \"../color\";\nimport type { ChartRendererKind } from \"../types\";\nimport type { Vec3 } from \"./math\";\n\n/** Bytes per point instance: x, y, z f32, diameter (CSS px) f32, color unorm8x4 */\nexport const POINT_STRIDE = 20;\n/** Bytes per mesh vertex: position f32x3, normal f32x3, color unorm8x4 */\nexport const VERTEX_STRIDE = 28;\n/** Bytes per line segment instance: a f32x3, b f32x3, color unorm8x4 */\nexport const SEGMENT_STRIDE = 28;\n\ninterface ItemBase {\n /** Identifies the GPU resources of the item */\n key: string;\n /** Changes when the buffers must be uploaded again */\n version: number;\n /** 0-1; below 1 the item is drawn without writing depth */\n opacity: number;\n}\n\n/** Shapes of the points (`PointsItem.style`) */\nexport const POINT_SPHERE = 0;\nexport const POINT_DISC = 1;\nexport const POINT_GLOW = 2;\n\n/** Instanced billboards: shaded spheres, flat discs or glowing discs */\nexport interface PointsItem extends ItemBase {\n kind: \"points\";\n data: ArrayBuffer;\n count: number;\n /** Scales the dots with the distance (perspective) */\n perspective: boolean;\n /** `POINT_SPHERE`, `POINT_DISC` or `POINT_GLOW` (sphere when omitted) */\n style?: number;\n /** Adds the light of the dots (no depth writes, order independent) */\n additive?: boolean;\n /**\n * The data was thinned to 1 point out of `thinned` (CPU backend): the\n * drawn dots get denser to keep the look of the cloud\n */\n thinned?: number;\n}\n\n/** Lit triangles (surfaces, bars) */\nexport interface MeshItem extends ItemBase {\n kind: \"mesh\";\n vertices: ArrayBuffer;\n vertexCount: number;\n indices: Uint32Array;\n /**\n * Changes when only the order of the triangles changed (transparent meshes\n * sorted back to front): the index buffer is rewritten, same length\n */\n order?: number;\n /**\n * Blended without writing depth whatever its `opacity` (merged transparent\n * meshes: their opacity is baked into the vertex colors)\n */\n transparent?: boolean;\n}\n\n/** Screen-space wide segments (wireframes, contours, polylines) */\nexport interface LinesItem extends ItemBase {\n kind: \"lines\";\n data: ArrayBuffer;\n count: number;\n /** CSS pixels */\n width: number;\n /** Pulls the lines towards the camera (wireframes over their surface) */\n bias: number;\n}\n\nexport type Item3D = PointsItem | MeshItem | LinesItem;\n\nexport interface Frame3D {\n /** World -> clip (OpenGL convention) */\n viewProj: Float32Array;\n eye: Vec3;\n /** Unit vector towards the light, in world space */\n light: Vec3;\n orthographic: boolean;\n /** Distance of the camera to the box center (reference of the point sizes) */\n distance: number;\n /** Radius of the sphere around the box (depth cue range) */\n radius: number;\n /** Drawing buffer size in device pixels */\n width: number;\n height: number;\n dpr: number;\n /** ambient, diffuse, specular, shininess */\n lighting: readonly [number, number, number, number];\n /** Background color: far points fade towards it */\n fog: Rgba;\n}\n\nexport interface Renderer3D {\n readonly kind: ChartRendererKind;\n readonly canvas: HTMLCanvasElement;\n /** Drawing buffer size in device pixels */\n resize(width: number, height: number): void;\n render(items: readonly Item3D[], frame: Frame3D): void;\n destroy(): void;\n}\n\n/** Whether an item writes the depth buffer (opaque items) */\nexport const writesDepth = (item: Item3D): boolean => {\n if (item.opacity < 1) return false;\n if (item.kind === \"mesh\") return !item.transparent;\n if (item.kind === \"points\")\n return !item.additive && item.style !== POINT_GLOW;\n return true;\n};\n\n/**\n * Order of the draws: opaque meshes, opaque points, blended points,\n * transparent meshes, then lines (wireframes and contours stay visible over\n * transparent surfaces). Stable: items of a rank keep their order.\n */\nexport const drawOrder = (items: readonly Item3D[]): Item3D[] => {\n const rank = (item: Item3D) =>\n item.kind === \"mesh\"\n ? writesDepth(item)\n ? 0\n : 3\n : item.kind === \"points\"\n ? writesDepth(item)\n ? 1\n : 2\n : 4;\n return items\n .map((item, i) => ({ item, i, r: rank(item) }))\n .sort((a, b) => a.r - b.r || a.i - b.i)\n .map((e) => e.item);\n};\n"],"mappings":"AA2GA,IAAaA,EAAe,GACtBC,EAAK,QAAU,EAAU,GACzBA,EAAK,OAAS,OAAe,CAACA,EAAK,YACnCA,EAAK,OAAS,UACT,CAACA,EAAK,UAAYA,EAAK,QAAA,EASrBC,EAAa,GAAuC,CAC/D,IAAMC,EAAQ,GACZF,EAAK,OAAS,OACVD,EAAYC,CAAI,EACd,EACA,EACFA,EAAK,OAAS,SACZD,EAAYC,CAAI,EACd,EACA,EACF,EACR,OAAOG,EACJ,KAAK,EAAM,KAAO,CAAE,OAAM,IAAG,EAAGD,EAAKF,CAAI,CAAE,EAAE,CAAC,CAC9C,MAAM,EAAG,IAAMI,EAAE,EAAIC,EAAE,GAAKD,EAAE,EAAIC,EAAE,CAAC,CAAC,CACtC,IAAK,GAAM,EAAE,IAAI,CACtB"}
1
+ {"version":3,"file":"render-types.cjs","names":["writesDepth","item","drawRank","drawOrder","items","a","b"],"sources":["../../../../../charts/src/engine/three-d/render-types.ts"],"sourcesContent":["// Contract between the 3D chart and its data-layer backends.\n\nimport type { Rgba } from \"../color\";\nimport type { ChartRendererKind } from \"../types\";\nimport type { Vec3 } from \"./math\";\n\n/** Bytes per point instance: x, y, z f32, diameter (CSS px) f32, color unorm8x4 */\nexport const POINT_STRIDE = 20;\n/** Bytes per mesh vertex: position f32x3, normal f32x3, color unorm8x4 */\nexport const VERTEX_STRIDE = 28;\n/** Bytes per line segment instance: a f32x3, b f32x3, color unorm8x4 */\nexport const SEGMENT_STRIDE = 28;\n\ninterface ItemBase {\n /** Identifies the GPU resources of the item */\n key: string;\n /** Changes when the buffers must be uploaded again */\n version: number;\n /** 0-1; below 1 the item is drawn without writing depth */\n opacity: number;\n}\n\n/** Shapes of the points (`PointsItem.style`) */\nexport const POINT_SPHERE = 0;\nexport const POINT_DISC = 1;\nexport const POINT_GLOW = 2;\n\n/** Instanced billboards: shaded spheres, flat discs or glowing discs */\nexport interface PointsItem extends ItemBase {\n kind: \"points\";\n data: ArrayBuffer;\n count: number;\n /** Scales the dots with the distance (perspective) */\n perspective: boolean;\n /** `POINT_SPHERE`, `POINT_DISC` or `POINT_GLOW` (sphere when omitted) */\n style?: number;\n /** Adds the light of the dots (no depth writes, order independent) */\n additive?: boolean;\n /**\n * The data was thinned to 1 point out of `thinned` (CPU backend): the\n * drawn dots get denser to keep the look of the cloud\n */\n thinned?: number;\n}\n\n/** Lit triangles (surfaces, bars) */\nexport interface MeshItem extends ItemBase {\n kind: \"mesh\";\n vertices: ArrayBuffer;\n vertexCount: number;\n indices: Uint32Array;\n /**\n * Changes when only the order of the triangles changed (transparent meshes\n * sorted back to front): the index buffer is rewritten, same length\n */\n order?: number;\n /**\n * Blended without writing depth whatever its `opacity` (merged transparent\n * meshes: their opacity is baked into the vertex colors)\n */\n transparent?: boolean;\n}\n\n/** Screen-space wide segments (wireframes, contours, polylines) */\nexport interface LinesItem extends ItemBase {\n kind: \"lines\";\n data: ArrayBuffer;\n count: number;\n /** CSS pixels */\n width: number;\n /** Pulls the lines towards the camera (wireframes over their surface) */\n bias: number;\n}\n\nexport type Item3D = PointsItem | MeshItem | LinesItem;\n\nexport interface Frame3D {\n /** World -> clip (OpenGL convention) */\n viewProj: Float32Array;\n eye: Vec3;\n /** Unit vector towards the light, in world space */\n light: Vec3;\n orthographic: boolean;\n /** Distance of the camera to the box center (reference of the point sizes) */\n distance: number;\n /** Radius of the sphere around the box (depth cue range) */\n radius: number;\n /** Drawing buffer size in device pixels */\n width: number;\n height: number;\n dpr: number;\n /** ambient, diffuse, specular, shininess */\n lighting: readonly [number, number, number, number];\n /** Background color: far points fade towards it */\n fog: Rgba;\n /** Scale of the light of the additive points (tone mapped when possible) */\n exposure: number;\n}\n\nexport interface Renderer3D {\n readonly kind: ChartRendererKind;\n readonly canvas: HTMLCanvasElement;\n /**\n * Blends the transparent items in any order (weighted blended\n * order-independent transparency): they need no depth sorting\n */\n readonly orderIndependent?: boolean;\n /** Drawing buffer size in device pixels */\n resize(width: number, height: number): void;\n render(items: readonly Item3D[], frame: Frame3D): void;\n destroy(): void;\n}\n\n/** Whether an item writes the depth buffer (opaque items) */\nexport const writesDepth = (item: Item3D): boolean => {\n if (item.opacity < 1) return false;\n if (item.kind === \"mesh\") return !item.transparent;\n if (item.kind === \"points\")\n return !item.additive && item.style !== POINT_GLOW;\n return true;\n};\n\n/**\n * Draw passes of the items: 0 opaque meshes, 1 opaque points, 2 blended\n * items (transparent meshes and points: order independent, or sorted back to\n * front together), 3 lines (wireframes and contours stay visible over\n * transparent surfaces)\n */\nexport const drawRank = (item: Item3D): number =>\n item.kind === \"lines\"\n ? 3\n : !writesDepth(item)\n ? 2\n : item.kind === \"mesh\"\n ? 0\n : 1;\n\n/**\n * Order of the draws (`drawRank`). Stable: items of a rank keep their order\n * (the back-to-front order of the depth sorter for the blended items).\n */\nexport const drawOrder = (items: readonly Item3D[]): Item3D[] =>\n items\n .map((item, i) => ({ item, i, r: drawRank(item) }))\n .sort((a, b) => a.r - b.r || a.i - b.i)\n .map((e) => e.item);\n"],"mappings":"AAkHA,IAAaA,EAAe,GACtBC,EAAK,QAAU,EAAU,GACzBA,EAAK,OAAS,OAAe,CAACA,EAAK,YACnCA,EAAK,OAAS,UACT,CAACA,EAAK,UAAYA,EAAK,QAAA,EAUrBC,EAAY,GACvBD,EAAK,OAAS,QACV,EACCD,EAAYC,CAAI,EAEfA,EAAK,OAAS,OACZ,EACA,EAHF,EASKE,EAAa,GACxBC,EACG,KAAK,EAAM,KAAO,CAAE,OAAM,IAAG,EAAGF,EAASD,CAAI,CAAE,EAAE,CAAC,CAClD,MAAM,EAAG,IAAMI,EAAE,EAAIC,EAAE,GAAKD,EAAE,EAAIC,EAAE,CAAC,CAAC,CACtC,IAAK,GAAM,EAAE,IAAI"}
@@ -83,10 +83,17 @@ export interface Frame3D {
83
83
  lighting: readonly [number, number, number, number];
84
84
  /** Background color: far points fade towards it */
85
85
  fog: Rgba;
86
+ /** Scale of the light of the additive points (tone mapped when possible) */
87
+ exposure: number;
86
88
  }
87
89
  export interface Renderer3D {
88
90
  readonly kind: ChartRendererKind;
89
91
  readonly canvas: HTMLCanvasElement;
92
+ /**
93
+ * Blends the transparent items in any order (weighted blended
94
+ * order-independent transparency): they need no depth sorting
95
+ */
96
+ readonly orderIndependent?: boolean;
90
97
  /** Drawing buffer size in device pixels */
91
98
  resize(width: number, height: number): void;
92
99
  render(items: readonly Item3D[], frame: Frame3D): void;
@@ -95,9 +102,15 @@ export interface Renderer3D {
95
102
  /** Whether an item writes the depth buffer (opaque items) */
96
103
  export declare const writesDepth: (item: Item3D) => boolean;
97
104
  /**
98
- * Order of the draws: opaque meshes, opaque points, blended points,
99
- * transparent meshes, then lines (wireframes and contours stay visible over
100
- * transparent surfaces). Stable: items of a rank keep their order.
105
+ * Draw passes of the items: 0 opaque meshes, 1 opaque points, 2 blended
106
+ * items (transparent meshes and points: order independent, or sorted back to
107
+ * front together), 3 lines (wireframes and contours stay visible over
108
+ * transparent surfaces)
109
+ */
110
+ export declare const drawRank: (item: Item3D) => number;
111
+ /**
112
+ * Order of the draws (`drawRank`). Stable: items of a rank keep their order
113
+ * (the back-to-front order of the depth sorter for the blended items).
101
114
  */
102
115
  export declare const drawOrder: (items: readonly Item3D[]) => Item3D[];
103
116
  export {};
@@ -83,10 +83,17 @@ export interface Frame3D {
83
83
  lighting: readonly [number, number, number, number];
84
84
  /** Background color: far points fade towards it */
85
85
  fog: Rgba;
86
+ /** Scale of the light of the additive points (tone mapped when possible) */
87
+ exposure: number;
86
88
  }
87
89
  export interface Renderer3D {
88
90
  readonly kind: ChartRendererKind;
89
91
  readonly canvas: HTMLCanvasElement;
92
+ /**
93
+ * Blends the transparent items in any order (weighted blended
94
+ * order-independent transparency): they need no depth sorting
95
+ */
96
+ readonly orderIndependent?: boolean;
90
97
  /** Drawing buffer size in device pixels */
91
98
  resize(width: number, height: number): void;
92
99
  render(items: readonly Item3D[], frame: Frame3D): void;
@@ -95,9 +102,15 @@ export interface Renderer3D {
95
102
  /** Whether an item writes the depth buffer (opaque items) */
96
103
  export declare const writesDepth: (item: Item3D) => boolean;
97
104
  /**
98
- * Order of the draws: opaque meshes, opaque points, blended points,
99
- * transparent meshes, then lines (wireframes and contours stay visible over
100
- * transparent surfaces). Stable: items of a rank keep their order.
105
+ * Draw passes of the items: 0 opaque meshes, 1 opaque points, 2 blended
106
+ * items (transparent meshes and points: order independent, or sorted back to
107
+ * front together), 3 lines (wireframes and contours stay visible over
108
+ * transparent surfaces)
109
+ */
110
+ export declare const drawRank: (item: Item3D) => number;
111
+ /**
112
+ * Order of the draws (`drawRank`). Stable: items of a rank keep their order
113
+ * (the back-to-front order of the depth sorter for the blended items).
101
114
  */
102
115
  export declare const drawOrder: (items: readonly Item3D[]) => Item3D[];
103
116
  export {};
@@ -1,12 +1,9 @@
1
- var e = (e) => e.opacity < 1 ? !1 : e.kind === "mesh" ? !e.transparent : e.kind !== "points" || !e.additive && e.style !== 2, t = (t) => {
2
- let n = (t) => t.kind === "mesh" ? e(t) ? 0 : 3 : t.kind === "points" ? e(t) ? 1 : 2 : 4;
3
- return t.map((e, t) => ({
4
- item: e,
5
- i: t,
6
- r: n(e)
7
- })).sort((e, t) => e.r - t.r || e.i - t.i).map((e) => e.item);
8
- };
1
+ var e = (e) => e.opacity < 1 ? !1 : e.kind === "mesh" ? !e.transparent : e.kind !== "points" || !e.additive && e.style !== 2, t = (t) => t.kind === "lines" ? 3 : e(t) ? t.kind === "mesh" ? 0 : 1 : 2, n = (e) => e.map((e, n) => ({
2
+ item: e,
3
+ i: n,
4
+ r: t(e)
5
+ })).sort((e, t) => e.r - t.r || e.i - t.i).map((e) => e.item);
9
6
  //#endregion
10
- export { t as drawOrder, e as writesDepth };
7
+ export { n as drawOrder, t as drawRank, e as writesDepth };
11
8
 
12
9
  //# sourceMappingURL=render-types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-types.js","names":["writesDepth","item","drawOrder","rank","items","a","b"],"sources":["../../../../../charts/src/engine/three-d/render-types.ts"],"sourcesContent":["// Contract between the 3D chart and its data-layer backends.\n\nimport type { Rgba } from \"../color\";\nimport type { ChartRendererKind } from \"../types\";\nimport type { Vec3 } from \"./math\";\n\n/** Bytes per point instance: x, y, z f32, diameter (CSS px) f32, color unorm8x4 */\nexport const POINT_STRIDE = 20;\n/** Bytes per mesh vertex: position f32x3, normal f32x3, color unorm8x4 */\nexport const VERTEX_STRIDE = 28;\n/** Bytes per line segment instance: a f32x3, b f32x3, color unorm8x4 */\nexport const SEGMENT_STRIDE = 28;\n\ninterface ItemBase {\n /** Identifies the GPU resources of the item */\n key: string;\n /** Changes when the buffers must be uploaded again */\n version: number;\n /** 0-1; below 1 the item is drawn without writing depth */\n opacity: number;\n}\n\n/** Shapes of the points (`PointsItem.style`) */\nexport const POINT_SPHERE = 0;\nexport const POINT_DISC = 1;\nexport const POINT_GLOW = 2;\n\n/** Instanced billboards: shaded spheres, flat discs or glowing discs */\nexport interface PointsItem extends ItemBase {\n kind: \"points\";\n data: ArrayBuffer;\n count: number;\n /** Scales the dots with the distance (perspective) */\n perspective: boolean;\n /** `POINT_SPHERE`, `POINT_DISC` or `POINT_GLOW` (sphere when omitted) */\n style?: number;\n /** Adds the light of the dots (no depth writes, order independent) */\n additive?: boolean;\n /**\n * The data was thinned to 1 point out of `thinned` (CPU backend): the\n * drawn dots get denser to keep the look of the cloud\n */\n thinned?: number;\n}\n\n/** Lit triangles (surfaces, bars) */\nexport interface MeshItem extends ItemBase {\n kind: \"mesh\";\n vertices: ArrayBuffer;\n vertexCount: number;\n indices: Uint32Array;\n /**\n * Changes when only the order of the triangles changed (transparent meshes\n * sorted back to front): the index buffer is rewritten, same length\n */\n order?: number;\n /**\n * Blended without writing depth whatever its `opacity` (merged transparent\n * meshes: their opacity is baked into the vertex colors)\n */\n transparent?: boolean;\n}\n\n/** Screen-space wide segments (wireframes, contours, polylines) */\nexport interface LinesItem extends ItemBase {\n kind: \"lines\";\n data: ArrayBuffer;\n count: number;\n /** CSS pixels */\n width: number;\n /** Pulls the lines towards the camera (wireframes over their surface) */\n bias: number;\n}\n\nexport type Item3D = PointsItem | MeshItem | LinesItem;\n\nexport interface Frame3D {\n /** World -> clip (OpenGL convention) */\n viewProj: Float32Array;\n eye: Vec3;\n /** Unit vector towards the light, in world space */\n light: Vec3;\n orthographic: boolean;\n /** Distance of the camera to the box center (reference of the point sizes) */\n distance: number;\n /** Radius of the sphere around the box (depth cue range) */\n radius: number;\n /** Drawing buffer size in device pixels */\n width: number;\n height: number;\n dpr: number;\n /** ambient, diffuse, specular, shininess */\n lighting: readonly [number, number, number, number];\n /** Background color: far points fade towards it */\n fog: Rgba;\n}\n\nexport interface Renderer3D {\n readonly kind: ChartRendererKind;\n readonly canvas: HTMLCanvasElement;\n /** Drawing buffer size in device pixels */\n resize(width: number, height: number): void;\n render(items: readonly Item3D[], frame: Frame3D): void;\n destroy(): void;\n}\n\n/** Whether an item writes the depth buffer (opaque items) */\nexport const writesDepth = (item: Item3D): boolean => {\n if (item.opacity < 1) return false;\n if (item.kind === \"mesh\") return !item.transparent;\n if (item.kind === \"points\")\n return !item.additive && item.style !== POINT_GLOW;\n return true;\n};\n\n/**\n * Order of the draws: opaque meshes, opaque points, blended points,\n * transparent meshes, then lines (wireframes and contours stay visible over\n * transparent surfaces). Stable: items of a rank keep their order.\n */\nexport const drawOrder = (items: readonly Item3D[]): Item3D[] => {\n const rank = (item: Item3D) =>\n item.kind === \"mesh\"\n ? writesDepth(item)\n ? 0\n : 3\n : item.kind === \"points\"\n ? writesDepth(item)\n ? 1\n : 2\n : 4;\n return items\n .map((item, i) => ({ item, i, r: rank(item) }))\n .sort((a, b) => a.r - b.r || a.i - b.i)\n .map((e) => e.item);\n};\n"],"mappings":"AA2GA,IAAaA,KAAe,MACtBC,EAAK,UAAU,IAAU,KACzBA,EAAK,SAAS,SAAe,CAACA,EAAK,cACnCA,EAAK,SAAS,YACT,CAACA,EAAK,YAAYA,EAAK,UAAA,GASrBC,KAAa,MAAuC;CAC/D,IAAMC,KAAQ,MACZF,EAAK,SAAS,SACVD,EAAYC,CAAI,IACd,IACA,IACFA,EAAK,SAAS,WACZD,EAAYC,CAAI,IACd,IACA,IACF;CACR,OAAOG,EACJ,KAAK,GAAM,OAAO;EAAE;EAAM;EAAG,GAAGD,EAAKF,CAAI;CAAE,EAAE,CAAC,CAC9C,MAAM,GAAG,MAAMI,EAAE,IAAIC,EAAE,KAAKD,EAAE,IAAIC,EAAE,CAAC,CAAC,CACtC,KAAK,MAAM,EAAE,IAAI;AACtB"}
1
+ {"version":3,"file":"render-types.js","names":["writesDepth","item","drawRank","drawOrder","items","a","b"],"sources":["../../../../../charts/src/engine/three-d/render-types.ts"],"sourcesContent":["// Contract between the 3D chart and its data-layer backends.\n\nimport type { Rgba } from \"../color\";\nimport type { ChartRendererKind } from \"../types\";\nimport type { Vec3 } from \"./math\";\n\n/** Bytes per point instance: x, y, z f32, diameter (CSS px) f32, color unorm8x4 */\nexport const POINT_STRIDE = 20;\n/** Bytes per mesh vertex: position f32x3, normal f32x3, color unorm8x4 */\nexport const VERTEX_STRIDE = 28;\n/** Bytes per line segment instance: a f32x3, b f32x3, color unorm8x4 */\nexport const SEGMENT_STRIDE = 28;\n\ninterface ItemBase {\n /** Identifies the GPU resources of the item */\n key: string;\n /** Changes when the buffers must be uploaded again */\n version: number;\n /** 0-1; below 1 the item is drawn without writing depth */\n opacity: number;\n}\n\n/** Shapes of the points (`PointsItem.style`) */\nexport const POINT_SPHERE = 0;\nexport const POINT_DISC = 1;\nexport const POINT_GLOW = 2;\n\n/** Instanced billboards: shaded spheres, flat discs or glowing discs */\nexport interface PointsItem extends ItemBase {\n kind: \"points\";\n data: ArrayBuffer;\n count: number;\n /** Scales the dots with the distance (perspective) */\n perspective: boolean;\n /** `POINT_SPHERE`, `POINT_DISC` or `POINT_GLOW` (sphere when omitted) */\n style?: number;\n /** Adds the light of the dots (no depth writes, order independent) */\n additive?: boolean;\n /**\n * The data was thinned to 1 point out of `thinned` (CPU backend): the\n * drawn dots get denser to keep the look of the cloud\n */\n thinned?: number;\n}\n\n/** Lit triangles (surfaces, bars) */\nexport interface MeshItem extends ItemBase {\n kind: \"mesh\";\n vertices: ArrayBuffer;\n vertexCount: number;\n indices: Uint32Array;\n /**\n * Changes when only the order of the triangles changed (transparent meshes\n * sorted back to front): the index buffer is rewritten, same length\n */\n order?: number;\n /**\n * Blended without writing depth whatever its `opacity` (merged transparent\n * meshes: their opacity is baked into the vertex colors)\n */\n transparent?: boolean;\n}\n\n/** Screen-space wide segments (wireframes, contours, polylines) */\nexport interface LinesItem extends ItemBase {\n kind: \"lines\";\n data: ArrayBuffer;\n count: number;\n /** CSS pixels */\n width: number;\n /** Pulls the lines towards the camera (wireframes over their surface) */\n bias: number;\n}\n\nexport type Item3D = PointsItem | MeshItem | LinesItem;\n\nexport interface Frame3D {\n /** World -> clip (OpenGL convention) */\n viewProj: Float32Array;\n eye: Vec3;\n /** Unit vector towards the light, in world space */\n light: Vec3;\n orthographic: boolean;\n /** Distance of the camera to the box center (reference of the point sizes) */\n distance: number;\n /** Radius of the sphere around the box (depth cue range) */\n radius: number;\n /** Drawing buffer size in device pixels */\n width: number;\n height: number;\n dpr: number;\n /** ambient, diffuse, specular, shininess */\n lighting: readonly [number, number, number, number];\n /** Background color: far points fade towards it */\n fog: Rgba;\n /** Scale of the light of the additive points (tone mapped when possible) */\n exposure: number;\n}\n\nexport interface Renderer3D {\n readonly kind: ChartRendererKind;\n readonly canvas: HTMLCanvasElement;\n /**\n * Blends the transparent items in any order (weighted blended\n * order-independent transparency): they need no depth sorting\n */\n readonly orderIndependent?: boolean;\n /** Drawing buffer size in device pixels */\n resize(width: number, height: number): void;\n render(items: readonly Item3D[], frame: Frame3D): void;\n destroy(): void;\n}\n\n/** Whether an item writes the depth buffer (opaque items) */\nexport const writesDepth = (item: Item3D): boolean => {\n if (item.opacity < 1) return false;\n if (item.kind === \"mesh\") return !item.transparent;\n if (item.kind === \"points\")\n return !item.additive && item.style !== POINT_GLOW;\n return true;\n};\n\n/**\n * Draw passes of the items: 0 opaque meshes, 1 opaque points, 2 blended\n * items (transparent meshes and points: order independent, or sorted back to\n * front together), 3 lines (wireframes and contours stay visible over\n * transparent surfaces)\n */\nexport const drawRank = (item: Item3D): number =>\n item.kind === \"lines\"\n ? 3\n : !writesDepth(item)\n ? 2\n : item.kind === \"mesh\"\n ? 0\n : 1;\n\n/**\n * Order of the draws (`drawRank`). Stable: items of a rank keep their order\n * (the back-to-front order of the depth sorter for the blended items).\n */\nexport const drawOrder = (items: readonly Item3D[]): Item3D[] =>\n items\n .map((item, i) => ({ item, i, r: drawRank(item) }))\n .sort((a, b) => a.r - b.r || a.i - b.i)\n .map((e) => e.item);\n"],"mappings":"AAkHA,IAAaA,KAAe,MACtBC,EAAK,UAAU,IAAU,KACzBA,EAAK,SAAS,SAAe,CAACA,EAAK,cACnCA,EAAK,SAAS,YACT,CAACA,EAAK,YAAYA,EAAK,UAAA,GAUrBC,KAAY,MACvBD,EAAK,SAAS,UACV,IACCD,EAAYC,CAAI,IAEfA,EAAK,SAAS,SACZ,IACA,IAHF,GASKE,KAAa,MACxBC,EACG,KAAK,GAAM,OAAO;CAAE;CAAM;CAAG,GAAGF,EAASD,CAAI;AAAE,EAAE,CAAC,CAClD,MAAM,GAAG,MAAMI,EAAE,IAAIC,EAAE,KAAKD,EAAE,IAAIC,EAAE,CAAC,CAAC,CACtC,KAAK,MAAM,EAAE,IAAI"}
@@ -1,4 +1,4 @@
1
- const e=require("./render-types.cjs");var t=(e,t,n,r,i,a,o,s)=>(e.set(t,0),e.set(n,16),e.set(r,20),e.set(i,24),e.set(a,28),e.set(o,32),e.set(s,36),e),n=(e,n,r)=>{let i=e.kind===`points`?+!!e.perspective:e.kind===`lines`?e.width:0;return t(r,n.viewProj,[n.width,n.height,n.dpr,+!!n.orthographic],[n.eye[0],n.eye[1],n.eye[2],e.kind===`lines`?e.bias:e.kind===`points`?e.style??0:0],[n.light[0],n.light[1],n.light[2],e.kind===`points`&&e.additive?1:0],n.lighting,[e.opacity,i,n.distance,n.radius],[n.fog[0],n.fog[1],n.fog[2],1])},r=`
1
+ const e=require("./render-types.cjs"),t=require("./oit.cjs");var n=(e,t,n,r,i,a,o,s)=>(e.set(t,0),e.set(n,16),e.set(r,20),e.set(i,24),e.set(a,28),e.set(o,32),e.set(s,36),e),r=(e,t,r)=>{let i=e.kind===`points`?+!!e.perspective:e.kind===`lines`?e.width:0;return n(r,t.viewProj,[t.width,t.height,t.dpr,+!!t.orthographic],[t.eye[0],t.eye[1],t.eye[2],e.kind===`lines`?e.bias:e.kind===`points`?e.style??0:0],[t.light[0],t.light[1],t.light[2],e.kind===`points`&&e.additive?1:0],t.lighting,[e.opacity,i,t.distance,t.radius],[t.fog[0],t.fog[1],t.fog[2],t.exposure])},i=`
2
2
  struct U {
3
3
  viewProj: mat4x4f,
4
4
  viewport: vec4f,
@@ -18,7 +18,7 @@ fn depthCue(world: vec3f) -> f32 {
18
18
  let near = u.params.z - u.params.w;
19
19
  return clamp((length(world - u.eye.xyz) - near) / (2.0 * u.params.w), 0.0, 1.0);
20
20
  }
21
- `,i=`${r}
21
+ ${t.WGSL_OIT}`,a=`${i}
22
22
  struct Out {
23
23
  @builtin(position) position: vec4f,
24
24
  @location(0) offset: vec2f,
@@ -51,13 +51,12 @@ fn vs(
51
51
  out.offset = corner * reach;
52
52
  out.radius = radius;
53
53
  out.color = color;
54
- out.fog = depthCue(pos) * 0.45;
54
+ out.fog = depthCue(pos);
55
55
  out.coverage = min(1.0, raw * raw / (radius * radius));
56
56
  return out;
57
57
  }
58
58
 
59
- @fragment
60
- fn fs(in: Out) -> @location(0) vec4f {
59
+ fn shade(in: Out) -> vec4f {
61
60
  let d = length(in.offset);
62
61
  let r = in.radius;
63
62
  var alpha = clamp(r + 0.5 - d, 0.0, 1.0);
@@ -77,16 +76,28 @@ fn fs(in: Out) -> @location(0) vec4f {
77
76
  rgb = mix(rgb, shaded, smoothstep(1.5, 3.5, r));
78
77
  }
79
78
  if (alpha <= 0.004) { discard; }
79
+ let fog = in.fog * 0.45;
80
80
  if (u.light.w > 0.5) {
81
81
  // additive light fades with the distance
82
- alpha = alpha * (1.0 - in.fog);
82
+ alpha = alpha * (1.0 - fog);
83
+ rgb = rgb * u.fog.w;
83
84
  } else {
84
- rgb = mix(rgb, u.fog.rgb, in.fog);
85
+ rgb = mix(rgb, u.fog.rgb, fog);
85
86
  }
86
87
  alpha = alpha * in.coverage * in.color.a * u.params.x;
87
88
  return vec4f(rgb * alpha, alpha);
88
89
  }
89
- `,a=`${r}
90
+
91
+ @fragment
92
+ fn fs(in: Out) -> @location(0) vec4f {
93
+ return shade(in);
94
+ }
95
+
96
+ @fragment
97
+ fn fsOit(in: Out) -> Oit {
98
+ return oit(shade(in), in.fog);
99
+ }
100
+ `,o=`${i}
90
101
  struct Out {
91
102
  @builtin(position) position: vec4f,
92
103
  @location(0) world: vec3f,
@@ -108,8 +119,7 @@ fn vs(
108
119
  return out;
109
120
  }
110
121
 
111
- @fragment
112
- fn fs(in: Out) -> @location(0) vec4f {
122
+ fn shade(in: Out) -> vec4f {
113
123
  var n = normalize(in.normal);
114
124
  let v = normalize(u.eye.xyz - in.world);
115
125
  if (dot(n, v) < 0.0) { n = -n; }
@@ -121,7 +131,17 @@ fn fs(in: Out) -> @location(0) vec4f {
121
131
  let alpha = in.color.a * u.params.x;
122
132
  return vec4f(rgb * alpha, alpha);
123
133
  }
124
- `,o=`${r}
134
+
135
+ @fragment
136
+ fn fs(in: Out) -> @location(0) vec4f {
137
+ return shade(in);
138
+ }
139
+
140
+ @fragment
141
+ fn fsOit(in: Out) -> Oit {
142
+ return oit(shade(in), depthCue(in.world));
143
+ }
144
+ `,s=`${i}
125
145
  struct Out {
126
146
  @builtin(position) position: vec4f,
127
147
  @location(0) across: f32,
@@ -165,7 +185,7 @@ fn fs(in: Out) -> @location(0) vec4f {
165
185
  if (alpha <= 0.0) { discard; }
166
186
  return vec4f(in.color.rgb * alpha, alpha);
167
187
  }
168
- `,s=`
188
+ `,c=`
169
189
  uniform mat4 u_viewProj;
170
190
  uniform vec4 u_viewport;
171
191
  uniform vec4 u_eye;
@@ -173,7 +193,7 @@ uniform vec4 u_light;
173
193
  uniform vec4 u_material;
174
194
  uniform vec4 u_params;
175
195
  uniform vec4 u_fog;
176
- `,c=`
196
+ `,l=`
177
197
  attribute vec2 a_corner;
178
198
  attribute vec3 a_pos;
179
199
  attribute float a_size;
@@ -200,10 +220,10 @@ void main() {
200
220
  v_radius = radius;
201
221
  v_color = a_color;
202
222
  float near = u_params.z - u_params.w;
203
- v_fog = clamp((length(a_pos - u_eye.xyz) - near) / (2.0 * u_params.w), 0.0, 1.0) * 0.45;
223
+ v_fog = clamp((length(a_pos - u_eye.xyz) - near) / (2.0 * u_params.w), 0.0, 1.0);
204
224
  v_coverage = min(1.0, raw * raw / (radius * radius));
205
225
  }
206
- `,l=`
226
+ `,u=`
207
227
  varying vec2 v_offset;
208
228
  varying float v_radius;
209
229
  varying vec4 v_color;
@@ -228,15 +248,17 @@ void main() {
228
248
  rgb = mix(rgb, shaded, smoothstep(1.5, 3.5, r));
229
249
  }
230
250
  if (alpha <= 0.004) discard;
251
+ float fog = v_fog * 0.45;
231
252
  if (u_light.w > 0.5) {
232
- alpha = alpha * (1.0 - v_fog);
253
+ alpha = alpha * (1.0 - fog);
254
+ rgb = rgb * u_fog.w;
233
255
  } else {
234
- rgb = mix(rgb, u_fog.rgb, v_fog);
256
+ rgb = mix(rgb, u_fog.rgb, fog);
235
257
  }
236
258
  alpha = alpha * v_coverage * v_color.a * u_params.x;
237
- FRAG = vec4(rgb * alpha, alpha);
259
+ EMIT(vec4(rgb * alpha, alpha), v_fog);
238
260
  }
239
- `,u=`
261
+ `,d=`
240
262
  attribute vec3 a_pos;
241
263
  attribute vec3 a_normal;
242
264
  attribute vec4 a_color;
@@ -249,7 +271,7 @@ void main() {
249
271
  v_normal = a_normal;
250
272
  v_color = a_color;
251
273
  }
252
- `,d=`
274
+ `,f=`
253
275
  varying vec3 v_world;
254
276
  varying vec3 v_normal;
255
277
  varying vec4 v_color;
@@ -263,9 +285,11 @@ void main() {
263
285
  float specular = pow(max(dot(n, h), 0.0), u_material.w) * u_material.z;
264
286
  vec3 rgb = v_color.rgb * (u_material.x + u_material.y * diffuse) + vec3(specular);
265
287
  float alpha = v_color.a * u_params.x;
266
- FRAG = vec4(rgb * alpha, alpha);
288
+ float near = u_params.z - u_params.w;
289
+ float depth = (length(v_world - u_eye.xyz) - near) / (2.0 * u_params.w);
290
+ EMIT(vec4(rgb * alpha, alpha), depth);
267
291
  }
268
- `,f=`
292
+ `,p=`
269
293
  attribute vec2 a_corner;
270
294
  attribute vec3 a_a;
271
295
  attribute vec3 a_b;
@@ -291,7 +315,7 @@ void main() {
291
315
  v_across = side * w;
292
316
  v_color = a_color;
293
317
  }
294
- `,p=`
318
+ `,m=`
295
319
  varying float v_across;
296
320
  varying vec4 v_color;
297
321
  void main() {
@@ -299,13 +323,15 @@ void main() {
299
323
  float coverage = clamp(max(core, 0.5) + 0.5 - abs(v_across), 0.0, 1.0) * min(1.0, core * 2.0);
300
324
  float alpha = coverage * v_color.a * u_params.x;
301
325
  if (alpha <= 0.0) discard;
302
- FRAG = vec4(v_color.rgb * alpha, alpha);
326
+ EMIT(vec4(v_color.rgb * alpha, alpha), 0.0);
303
327
  }
304
- `,m=`
328
+ `,h=`
305
329
  #ifdef GL_FRAGMENT_PRECISION_HIGH
306
330
  precision highp float;
307
331
  #else
308
332
  precision mediump float;
309
333
  #endif
310
- `,h=(e,t,n)=>n===2?{vertex:`#version 300 es\n#define attribute in\n#define varying out\n${s}${e}`,fragment:`#version 300 es\nprecision highp float;\n#define varying in\nout vec4 fragColor;\n#define FRAG fragColor\n${s}${t}`}:{vertex:`${s}${e}`,fragment:`${m}#define FRAG gl_FragColor\n${s}${t}`},g=e=>({points:h(c,l,e),mesh:h(u,d,e),lines:h(f,p,e)}),_={points:[`a_corner`,`a_pos`,`a_size`,`a_color`],mesh:[`a_pos`,`a_normal`,`a_color`],lines:[`a_corner`,`a_a`,`a_b`,`a_color`]};exports.GLSL_ATTRIBUTES=_,exports.WGSL_LINES=o,exports.WGSL_MESH=a,exports.WGSL_POINTS=i,exports.glslPrograms=g,exports.itemUniforms=n,exports.writesDepth=e.writesDepth;
334
+ `,g=(e,n,r,i=!1)=>r===2?{vertex:`#version 300 es\n#define attribute in\n#define varying out\n${c}${e}`,fragment:`#version 300 es\nprecision highp float;\n#define varying in\n${c}${i?t.GLSL_OIT:`out vec4 fragColor;
335
+ #define EMIT(c, d) fragColor = (c)
336
+ `}${n}`}:{vertex:`${c}${e}`,fragment:`${h}#define EMIT(c, d) gl_FragColor = (c)\n${c}${n}`},_=e=>({points:g(l,u,e),mesh:g(d,f,e),lines:g(p,m,e)}),v=()=>({points:g(l,u,2,!0),mesh:g(d,f,2,!0)}),y={points:[`a_corner`,`a_pos`,`a_size`,`a_color`],mesh:[`a_pos`,`a_normal`,`a_color`],lines:[`a_corner`,`a_a`,`a_b`,`a_color`]};exports.GLSL_ATTRIBUTES=y,exports.WGSL_LINES=s,exports.WGSL_MESH=o,exports.WGSL_POINTS=a,exports.glslOitPrograms=v,exports.glslPrograms=_,exports.itemUniforms=r,exports.writesDepth=e.writesDepth;
311
337
  //# sourceMappingURL=shaders.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"shaders.cjs","names":["require_render_types","writeUniforms","out","viewProj","viewport","eye","light","material","params","fog","itemUniforms","second","item","frame","WGSL_UNIFORMS","WGSL_POINTS","WGSL_MESH","WGSL_LINES","GLSL_UNIFORMS","GLSL_POINTS_VS","GLSL_POINTS_FS","GLSL_MESH_VS","GLSL_MESH_FS","GLSL_LINES_VS","GLSL_LINES_FS","PRECISION","glsl","version","vs","fs","glslPrograms","GLSL_ATTRIBUTES"],"sources":["../../../../../charts/src/engine/three-d/shaders.ts"],"sourcesContent":["// Shaders of the 3D data layer: instanced point billboards (shaded spheres,\n// flat discs or glowing discs), lit triangles (two-sided Lambert +\n// Blinn-Phong) and screen-space wide line segments. WGSL for WebGPU, GLSL ES\n// 1.0 for WebGL (turned into GLSL ES 3.0 for WebGL2 by a macro prefix).\n// Outputs are premultiplied.\n//\n// Uniforms (WGSL struct, GLSL vec4 uniforms of the same names):\n// viewProj world -> clip (OpenGL depth convention)\n// viewport drawing buffer width, height (device px), dpr, orthographic\n// eye camera position, depth bias of the lines (NDC) | point style\n// light unit vector towards the light, additive points (0/1)\n// material ambient, diffuse, specular, shininess\n// params opacity, perspective sizes (0/1) | line width (CSS px), distance, radius\n// fog background color (far points fade towards it)\n//\n// Point sizes are CSS pixels times the device pixel ratio (billboards: no\n// point size limit). Dots thinner than the smallest drawn radius keep their\n// energy: their alpha scales with the area they would cover.\n\nimport { POINT_SPHERE, type Frame3D, type Item3D } from \"./render-types\";\n\nexport { writesDepth } from \"./render-types\";\n\n/** Bytes of the WGSL uniform struct */\nexport const UNIFORM_BYTES = 160;\n\n/** Writes the uniforms of an item in the WGSL struct layout */\nconst writeUniforms = (\n out: Float32Array,\n viewProj: Float32Array,\n viewport: readonly [number, number, number, number],\n eye: readonly [number, number, number, number],\n light: readonly [number, number, number, number],\n material: readonly [number, number, number, number],\n params: readonly [number, number, number, number],\n fog: readonly [number, number, number, number],\n): Float32Array => {\n out.set(viewProj, 0);\n out.set(viewport, 16);\n out.set(eye, 20);\n out.set(light, 24);\n out.set(material, 28);\n out.set(params, 32);\n out.set(fog, 36);\n return out;\n};\n\n/** Uniform values of an item (40 floats, the WGSL struct layout) */\nexport const itemUniforms = (\n item: Item3D,\n frame: Frame3D,\n out: Float32Array,\n): Float32Array => {\n const second =\n item.kind === \"points\"\n ? item.perspective\n ? 1\n : 0\n : item.kind === \"lines\"\n ? item.width\n : 0;\n return writeUniforms(\n out,\n frame.viewProj,\n [frame.width, frame.height, frame.dpr, frame.orthographic ? 1 : 0],\n [\n frame.eye[0],\n frame.eye[1],\n frame.eye[2],\n item.kind === \"lines\"\n ? item.bias\n : item.kind === \"points\"\n ? (item.style ?? POINT_SPHERE)\n : 0,\n ],\n [\n frame.light[0],\n frame.light[1],\n frame.light[2],\n item.kind === \"points\" && item.additive ? 1 : 0,\n ],\n frame.lighting,\n [item.opacity, second, frame.distance, frame.radius],\n [frame.fog[0], frame.fog[1], frame.fog[2], 1],\n );\n};\n\n// ------------------------------------------------------------------- WGSL\n\nconst WGSL_UNIFORMS = /* wgsl */ `\nstruct U {\n viewProj: mat4x4f,\n viewport: vec4f,\n eye: vec4f,\n light: vec4f,\n material: vec4f,\n params: vec4f,\n fog: vec4f,\n};\n@group(0) @binding(0) var<uniform> u: U;\n\nfn toWebGpuDepth(p: vec4f) -> vec4f {\n return vec4f(p.x, p.y, (p.z + p.w) * 0.5, p.w);\n}\n\nfn depthCue(world: vec3f) -> f32 {\n let near = u.params.z - u.params.w;\n return clamp((length(world - u.eye.xyz) - near) / (2.0 * u.params.w), 0.0, 1.0);\n}\n`;\n\nexport const WGSL_POINTS = /* wgsl */ `${WGSL_UNIFORMS}\nstruct Out {\n @builtin(position) position: vec4f,\n @location(0) offset: vec2f,\n @location(1) radius: f32,\n @location(2) color: vec4f,\n @location(3) fog: f32,\n @location(4) coverage: f32,\n};\n\n@vertex\nfn vs(\n @builtin(vertex_index) vi: u32,\n @location(0) pos: vec3f,\n @location(1) size: f32,\n @location(2) color: vec4f,\n) -> Out {\n var out: Out;\n let corner = vec2f(f32(vi & 1u), f32(vi >> 1u)) * 2.0 - 1.0;\n let clip = u.viewProj * vec4f(pos, 1.0);\n var factor = 1.0;\n if (u.params.y > 0.5 && u.viewport.w < 0.5) {\n factor = clamp(u.params.z / max(clip.w, 1e-6), 0.5, 2.0);\n }\n let glow = u.eye.w > 1.5;\n let raw = max(size, 0.0) * u.viewport.z * factor * 0.5;\n let radius = max(raw, select(0.5, 0.75, glow));\n let reach = select(radius + 1.0, radius * 2.2 + 1.0, glow);\n let shift = corner * reach * 2.0 / u.viewport.xy * clip.w;\n out.position = toWebGpuDepth(vec4f(clip.xy + shift, clip.z, clip.w));\n out.offset = corner * reach;\n out.radius = radius;\n out.color = color;\n out.fog = depthCue(pos) * 0.45;\n out.coverage = min(1.0, raw * raw / (radius * radius));\n return out;\n}\n\n@fragment\nfn fs(in: Out) -> @location(0) vec4f {\n let d = length(in.offset);\n let r = in.radius;\n var alpha = clamp(r + 0.5 - d, 0.0, 1.0);\n var rgb = in.color.rgb;\n if (u.eye.w > 1.5) {\n // glow: an anti-aliased core and a gaussian halo\n let core = clamp(r * 0.6 + 0.5 - d, 0.0, 1.0);\n let q = d / r;\n alpha = core + (1.0 - core) * exp(-1.2 * q * q);\n rgb = rgb + (vec3f(1.0) - rgb) * (0.2 * core);\n } else if (u.eye.w < 0.5) {\n let q = min(d / r, 1.0);\n let n = vec3f(in.offset.x / r, in.offset.y / r, sqrt(max(0.0, 1.0 - q * q)));\n let l = normalize(vec3f(-0.45, 0.55, 0.7));\n let lambert = max(dot(n, l), 0.0);\n let shaded = rgb * (0.62 + 0.45 * lambert) + vec3f(pow(lambert, 18.0) * 0.28);\n rgb = mix(rgb, shaded, smoothstep(1.5, 3.5, r));\n }\n if (alpha <= 0.004) { discard; }\n if (u.light.w > 0.5) {\n // additive light fades with the distance\n alpha = alpha * (1.0 - in.fog);\n } else {\n rgb = mix(rgb, u.fog.rgb, in.fog);\n }\n alpha = alpha * in.coverage * in.color.a * u.params.x;\n return vec4f(rgb * alpha, alpha);\n}\n`;\n\nexport const WGSL_MESH = /* wgsl */ `${WGSL_UNIFORMS}\nstruct Out {\n @builtin(position) position: vec4f,\n @location(0) world: vec3f,\n @location(1) normal: vec3f,\n @location(2) color: vec4f,\n};\n\n@vertex\nfn vs(\n @location(0) pos: vec3f,\n @location(1) normal: vec3f,\n @location(2) color: vec4f,\n) -> Out {\n var out: Out;\n out.position = toWebGpuDepth(u.viewProj * vec4f(pos, 1.0));\n out.world = pos;\n out.normal = normal;\n out.color = color;\n return out;\n}\n\n@fragment\nfn fs(in: Out) -> @location(0) vec4f {\n var n = normalize(in.normal);\n let v = normalize(u.eye.xyz - in.world);\n if (dot(n, v) < 0.0) { n = -n; }\n let l = u.light.xyz;\n let diffuse = max(dot(n, l), 0.0);\n let h = normalize(l + v);\n let specular = pow(max(dot(n, h), 0.0), u.material.w) * u.material.z;\n let rgb = in.color.rgb * (u.material.x + u.material.y * diffuse) + vec3f(specular);\n let alpha = in.color.a * u.params.x;\n return vec4f(rgb * alpha, alpha);\n}\n`;\n\nexport const WGSL_LINES = /* wgsl */ `${WGSL_UNIFORMS}\nstruct Out {\n @builtin(position) position: vec4f,\n @location(0) across: f32,\n @location(1) color: vec4f,\n};\n\n@vertex\nfn vs(\n @builtin(vertex_index) vi: u32,\n @location(0) a: vec3f,\n @location(1) b: vec3f,\n @location(2) color: vec4f,\n) -> Out {\n var out: Out;\n let corner = vec2f(f32(vi & 1u), f32(vi >> 1u));\n let ca = u.viewProj * vec4f(a, 1.0);\n let cb = u.viewProj * vec4f(b, 1.0);\n let halfSize = u.viewport.xy * 0.5;\n let sa = ca.xy / ca.w * halfSize;\n let sb = cb.xy / cb.w * halfSize;\n var dir = sb - sa;\n let len = length(dir);\n dir = select(vec2f(1.0, 0.0), dir / len, len > 1e-6);\n let normal = vec2f(-dir.y, dir.x);\n let w = max(0.5, u.params.y * u.viewport.z * 0.5) + 0.5;\n let clip = select(ca, cb, corner.x > 0.5);\n let side = corner.y * 2.0 - 1.0;\n let pixel = select(sa, sb, corner.x > 0.5) + dir * (corner.x * 2.0 - 1.0) * w + normal * side * w;\n let z = clip.z - u.eye.w * clip.w;\n out.position = toWebGpuDepth(vec4f(pixel / halfSize * clip.w, z, clip.w));\n out.across = side * w;\n out.color = color;\n return out;\n}\n\n@fragment\nfn fs(in: Out) -> @location(0) vec4f {\n let core = u.params.y * u.viewport.z * 0.5;\n let coverage = clamp(max(core, 0.5) + 0.5 - abs(in.across), 0.0, 1.0) * min(1.0, core * 2.0);\n let alpha = coverage * in.color.a * u.params.x;\n if (alpha <= 0.0) { discard; }\n return vec4f(in.color.rgb * alpha, alpha);\n}\n`;\n\n// ------------------------------------------------------------------- GLSL\n\nconst GLSL_UNIFORMS = `\nuniform mat4 u_viewProj;\nuniform vec4 u_viewport;\nuniform vec4 u_eye;\nuniform vec4 u_light;\nuniform vec4 u_material;\nuniform vec4 u_params;\nuniform vec4 u_fog;\n`;\n\nconst GLSL_POINTS_VS = `\nattribute vec2 a_corner;\nattribute vec3 a_pos;\nattribute float a_size;\nattribute vec4 a_color;\nvarying vec2 v_offset;\nvarying float v_radius;\nvarying vec4 v_color;\nvarying float v_fog;\nvarying float v_coverage;\nvoid main() {\n vec2 corner = a_corner * 2.0 - 1.0;\n vec4 clip = u_viewProj * vec4(a_pos, 1.0);\n float factor = 1.0;\n if (u_params.y > 0.5 && u_viewport.w < 0.5) {\n factor = clamp(u_params.z / max(clip.w, 1e-6), 0.5, 2.0);\n }\n bool glow = u_eye.w > 1.5;\n float raw = max(a_size, 0.0) * u_viewport.z * factor * 0.5;\n float radius = max(raw, glow ? 0.75 : 0.5);\n float reach = glow ? radius * 2.2 + 1.0 : radius + 1.0;\n vec2 shift = corner * reach * 2.0 / u_viewport.xy * clip.w;\n gl_Position = vec4(clip.xy + shift, clip.z, clip.w);\n v_offset = corner * reach;\n v_radius = radius;\n v_color = a_color;\n float near = u_params.z - u_params.w;\n v_fog = clamp((length(a_pos - u_eye.xyz) - near) / (2.0 * u_params.w), 0.0, 1.0) * 0.45;\n v_coverage = min(1.0, raw * raw / (radius * radius));\n}\n`;\n\nconst GLSL_POINTS_FS = `\nvarying vec2 v_offset;\nvarying float v_radius;\nvarying vec4 v_color;\nvarying float v_fog;\nvarying float v_coverage;\nvoid main() {\n float d = length(v_offset);\n float r = v_radius;\n float alpha = clamp(r + 0.5 - d, 0.0, 1.0);\n vec3 rgb = v_color.rgb;\n if (u_eye.w > 1.5) {\n float core = clamp(r * 0.6 + 0.5 - d, 0.0, 1.0);\n float q = d / r;\n alpha = core + (1.0 - core) * exp(-1.2 * q * q);\n rgb = rgb + (vec3(1.0) - rgb) * (0.2 * core);\n } else if (u_eye.w < 0.5) {\n float q = min(d / r, 1.0);\n vec3 n = vec3(v_offset / r, sqrt(max(0.0, 1.0 - q * q)));\n vec3 l = normalize(vec3(-0.45, 0.55, 0.7));\n float lambert = max(dot(n, l), 0.0);\n vec3 shaded = rgb * (0.62 + 0.45 * lambert) + vec3(pow(lambert, 18.0) * 0.28);\n rgb = mix(rgb, shaded, smoothstep(1.5, 3.5, r));\n }\n if (alpha <= 0.004) discard;\n if (u_light.w > 0.5) {\n alpha = alpha * (1.0 - v_fog);\n } else {\n rgb = mix(rgb, u_fog.rgb, v_fog);\n }\n alpha = alpha * v_coverage * v_color.a * u_params.x;\n FRAG = vec4(rgb * alpha, alpha);\n}\n`;\n\nconst GLSL_MESH_VS = `\nattribute vec3 a_pos;\nattribute vec3 a_normal;\nattribute vec4 a_color;\nvarying vec3 v_world;\nvarying vec3 v_normal;\nvarying vec4 v_color;\nvoid main() {\n gl_Position = u_viewProj * vec4(a_pos, 1.0);\n v_world = a_pos;\n v_normal = a_normal;\n v_color = a_color;\n}\n`;\n\nconst GLSL_MESH_FS = `\nvarying vec3 v_world;\nvarying vec3 v_normal;\nvarying vec4 v_color;\nvoid main() {\n vec3 n = normalize(v_normal);\n vec3 v = normalize(u_eye.xyz - v_world);\n if (dot(n, v) < 0.0) n = -n;\n vec3 l = u_light.xyz;\n float diffuse = max(dot(n, l), 0.0);\n vec3 h = normalize(l + v);\n float specular = pow(max(dot(n, h), 0.0), u_material.w) * u_material.z;\n vec3 rgb = v_color.rgb * (u_material.x + u_material.y * diffuse) + vec3(specular);\n float alpha = v_color.a * u_params.x;\n FRAG = vec4(rgb * alpha, alpha);\n}\n`;\n\nconst GLSL_LINES_VS = `\nattribute vec2 a_corner;\nattribute vec3 a_a;\nattribute vec3 a_b;\nattribute vec4 a_color;\nvarying float v_across;\nvarying vec4 v_color;\nvoid main() {\n vec4 ca = u_viewProj * vec4(a_a, 1.0);\n vec4 cb = u_viewProj * vec4(a_b, 1.0);\n vec2 halfSize = u_viewport.xy * 0.5;\n vec2 sa = ca.xy / ca.w * halfSize;\n vec2 sb = cb.xy / cb.w * halfSize;\n vec2 dir = sb - sa;\n float len = length(dir);\n dir = len > 1e-6 ? dir / len : vec2(1.0, 0.0);\n vec2 normal = vec2(-dir.y, dir.x);\n float w = max(0.5, u_params.y * u_viewport.z * 0.5) + 0.5;\n bool atEnd = a_corner.x > 0.5;\n vec4 clip = atEnd ? cb : ca;\n float side = a_corner.y * 2.0 - 1.0;\n vec2 pixel = (atEnd ? sb : sa) + dir * (a_corner.x * 2.0 - 1.0) * w + normal * side * w;\n gl_Position = vec4(pixel / halfSize * clip.w, clip.z - u_eye.w * clip.w, clip.w);\n v_across = side * w;\n v_color = a_color;\n}\n`;\n\nconst GLSL_LINES_FS = `\nvarying float v_across;\nvarying vec4 v_color;\nvoid main() {\n float core = u_params.y * u_viewport.z * 0.5;\n float coverage = clamp(max(core, 0.5) + 0.5 - abs(v_across), 0.0, 1.0) * min(1.0, core * 2.0);\n float alpha = coverage * v_color.a * u_params.x;\n if (alpha <= 0.0) discard;\n FRAG = vec4(v_color.rgb * alpha, alpha);\n}\n`;\n\nconst PRECISION = `\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n`;\n\nexport interface GlslSource {\n vertex: string;\n fragment: string;\n}\n\nconst glsl = (vs: string, fs: string, version: 1 | 2): GlslSource =>\n version === 2\n ? {\n vertex: `#version 300 es\\n#define attribute in\\n#define varying out\\n${GLSL_UNIFORMS}${vs}`,\n fragment: `#version 300 es\\nprecision highp float;\\n#define varying in\\nout vec4 fragColor;\\n#define FRAG fragColor\\n${GLSL_UNIFORMS}${fs}`,\n }\n : {\n vertex: `${GLSL_UNIFORMS}${vs}`,\n fragment: `${PRECISION}#define FRAG gl_FragColor\\n${GLSL_UNIFORMS}${fs}`,\n };\n\n/** GLSL programs of the three primitives for WebGL (1) or WebGL2 */\nexport const glslPrograms = (version: 1 | 2) => ({\n points: glsl(GLSL_POINTS_VS, GLSL_POINTS_FS, version),\n mesh: glsl(GLSL_MESH_VS, GLSL_MESH_FS, version),\n lines: glsl(GLSL_LINES_VS, GLSL_LINES_FS, version),\n});\n\n/** Attribute names of every program, bound to locations 0, 1, ... */\nexport const GLSL_ATTRIBUTES = {\n points: [\"a_corner\", \"a_pos\", \"a_size\", \"a_color\"],\n mesh: [\"a_pos\", \"a_normal\", \"a_color\"],\n lines: [\"a_corner\", \"a_a\", \"a_b\", \"a_color\"],\n} as const;\n"],"mappings":"sCA2BA,IAAMC,GACJ,EACA,EACA,EACA,EACA,EACA,EACA,EACA,KAEAC,EAAI,IAAIC,EAAU,CAAC,EACnBD,EAAI,IAAIE,EAAU,EAAE,EACpBF,EAAI,IAAIG,EAAK,EAAE,EACfH,EAAI,IAAII,EAAO,EAAE,EACjBJ,EAAI,IAAIK,EAAU,EAAE,EACpBL,EAAI,IAAIM,EAAQ,EAAE,EAClBN,EAAI,IAAIO,EAAK,EAAE,EACRP,GAIIQ,GACX,EACA,EACA,IACiB,CACjB,IAAMC,EACJC,EAAK,OAAS,SACV,KAAK,YAGLA,EAAK,OAAS,QACZA,EAAK,MACL,EACR,OAAOX,EACLC,EACAW,EAAM,SACN,CAACA,EAAM,MAAOA,EAAM,OAAQA,EAAM,IAAK,KAAM,YAAoB,EACjE,CACEA,EAAM,IAAI,GACVA,EAAM,IAAI,GACVA,EAAM,IAAI,GACVD,EAAK,OAAS,QACVA,EAAK,KACLA,EAAK,OAAS,SACXA,EAAK,OAAA,EACN,CACR,EACA,CACEC,EAAM,MAAM,GACZA,EAAM,MAAM,GACZA,EAAM,MAAM,GACZD,EAAK,OAAS,UAAYA,EAAK,SAAW,EAAI,CAChD,EACAC,EAAM,SACN,CAACD,EAAK,QAASD,EAAQE,EAAM,SAAUA,EAAM,MAAM,EACnD,CAACA,EAAM,IAAI,GAAIA,EAAM,IAAI,GAAIA,EAAM,IAAI,GAAI,CAAC,CAC9C,CACF,EAIMC,EAA2B;;;;;;;;;;;;;;;;;;;;EAsBpBC,EAAyB,GAAGD,EAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsE1CE,EAAuB,GAAGF,EAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqCxCG,EAAwB,GAAGH,EAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgDhDI,EAAgB;;;;;;;;EAUhBC,EAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCjBC,EAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmCjBC,EAAe;;;;;;;;;;;;;EAefC,EAAe;;;;;;;;;;;;;;;;EAkBfC,EAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BhBC,EAAgB;;;;;;;;;;EAYhBC,EAAY;;;;;;EAaZC,GAAQ,EAAY,EAAY,IACpCC,IAAY,EACR,CACE,OAAQ,+DAA+DT,IAAgBU,IACvF,SAAU,6GAA6GV,IAAgBW,GACzI,EACA,CACE,OAAQ,GAAGX,IAAgBU,IAC3B,SAAU,GAAGH,EAAU,6BAA6BP,IAAgBW,GACtE,EAGOC,EAAgB,IAAoB,CAC/C,OAAQJ,EAAKP,EAAgBC,EAAgBO,CAAO,EACpD,KAAMD,EAAKL,EAAcC,EAAcK,CAAO,EAC9C,MAAOD,EAAKH,EAAeC,EAAeG,CAAO,CACnD,GAGaI,EAAkB,CAC7B,OAAQ,CAAC,WAAY,QAAS,SAAU,SAAS,EACjD,KAAM,CAAC,QAAS,WAAY,SAAS,EACrC,MAAO,CAAC,WAAY,MAAO,MAAO,SAAS,CAC7C"}
1
+ {"version":3,"file":"shaders.cjs","names":["WGSL_OIT","GLSL_OIT","require_render_types","require_oit","writeUniforms","out","viewProj","viewport","eye","light","material","params","fog","itemUniforms","second","item","frame","WGSL_UNIFORMS","WGSL_POINTS","WGSL_MESH","WGSL_LINES","GLSL_UNIFORMS","GLSL_POINTS_VS","GLSL_POINTS_FS","GLSL_MESH_VS","GLSL_MESH_FS","GLSL_LINES_VS","GLSL_LINES_FS","PRECISION","glsl","version","vs","oit","fs","glslPrograms","glslOitPrograms","GLSL_ATTRIBUTES"],"sources":["../../../../../charts/src/engine/three-d/shaders.ts"],"sourcesContent":["// Shaders of the 3D data layer: instanced point billboards (shaded spheres,\n// flat discs or glowing discs), lit triangles (two-sided Lambert +\n// Blinn-Phong) and screen-space wide line segments. WGSL for WebGPU, GLSL ES\n// 1.0 for WebGL (turned into GLSL ES 3.0 for WebGL2 by a macro prefix).\n// Outputs are premultiplied.\n//\n// Uniforms (WGSL struct, GLSL vec4 uniforms of the same names):\n// viewProj world -> clip (OpenGL depth convention)\n// viewport drawing buffer width, height (device px), dpr, orthographic\n// eye camera position, depth bias of the lines (NDC) | point style\n// light unit vector towards the light, additive points (0/1)\n// material ambient, diffuse, specular, shininess\n// params opacity, perspective sizes (0/1) | line width (CSS px), distance, radius\n// fog background color (far points fade towards it), exposure of the\n// additive light\n//\n// Points and meshes have a second fragment entry point writing the targets\n// of the order-independent transparency (`oit.ts`): `fsOit` in WGSL, the\n// `oit` variant of the GLSL programs (WebGL2).\n//\n// Point sizes are CSS pixels times the device pixel ratio (billboards: no\n// point size limit). Dots thinner than the smallest drawn radius keep their\n// energy: their alpha scales with the area they would cover.\n\nimport { GLSL_OIT, WGSL_OIT } from \"./oit\";\nimport { POINT_SPHERE, type Frame3D, type Item3D } from \"./render-types\";\n\nexport { writesDepth } from \"./render-types\";\n\n/** Bytes of the WGSL uniform struct */\nexport const UNIFORM_BYTES = 160;\n\n/** Writes the uniforms of an item in the WGSL struct layout */\nconst writeUniforms = (\n out: Float32Array,\n viewProj: Float32Array,\n viewport: readonly [number, number, number, number],\n eye: readonly [number, number, number, number],\n light: readonly [number, number, number, number],\n material: readonly [number, number, number, number],\n params: readonly [number, number, number, number],\n fog: readonly [number, number, number, number],\n): Float32Array => {\n out.set(viewProj, 0);\n out.set(viewport, 16);\n out.set(eye, 20);\n out.set(light, 24);\n out.set(material, 28);\n out.set(params, 32);\n out.set(fog, 36);\n return out;\n};\n\n/** Uniform values of an item (40 floats, the WGSL struct layout) */\nexport const itemUniforms = (\n item: Item3D,\n frame: Frame3D,\n out: Float32Array,\n): Float32Array => {\n const second =\n item.kind === \"points\"\n ? item.perspective\n ? 1\n : 0\n : item.kind === \"lines\"\n ? item.width\n : 0;\n return writeUniforms(\n out,\n frame.viewProj,\n [frame.width, frame.height, frame.dpr, frame.orthographic ? 1 : 0],\n [\n frame.eye[0],\n frame.eye[1],\n frame.eye[2],\n item.kind === \"lines\"\n ? item.bias\n : item.kind === \"points\"\n ? (item.style ?? POINT_SPHERE)\n : 0,\n ],\n [\n frame.light[0],\n frame.light[1],\n frame.light[2],\n item.kind === \"points\" && item.additive ? 1 : 0,\n ],\n frame.lighting,\n [item.opacity, second, frame.distance, frame.radius],\n [frame.fog[0], frame.fog[1], frame.fog[2], frame.exposure],\n );\n};\n\n// ------------------------------------------------------------------- WGSL\n\nconst WGSL_UNIFORMS = /* wgsl */ `\nstruct U {\n viewProj: mat4x4f,\n viewport: vec4f,\n eye: vec4f,\n light: vec4f,\n material: vec4f,\n params: vec4f,\n fog: vec4f,\n};\n@group(0) @binding(0) var<uniform> u: U;\n\nfn toWebGpuDepth(p: vec4f) -> vec4f {\n return vec4f(p.x, p.y, (p.z + p.w) * 0.5, p.w);\n}\n\nfn depthCue(world: vec3f) -> f32 {\n let near = u.params.z - u.params.w;\n return clamp((length(world - u.eye.xyz) - near) / (2.0 * u.params.w), 0.0, 1.0);\n}\n${WGSL_OIT}`;\n\nexport const WGSL_POINTS = /* wgsl */ `${WGSL_UNIFORMS}\nstruct Out {\n @builtin(position) position: vec4f,\n @location(0) offset: vec2f,\n @location(1) radius: f32,\n @location(2) color: vec4f,\n @location(3) fog: f32,\n @location(4) coverage: f32,\n};\n\n@vertex\nfn vs(\n @builtin(vertex_index) vi: u32,\n @location(0) pos: vec3f,\n @location(1) size: f32,\n @location(2) color: vec4f,\n) -> Out {\n var out: Out;\n let corner = vec2f(f32(vi & 1u), f32(vi >> 1u)) * 2.0 - 1.0;\n let clip = u.viewProj * vec4f(pos, 1.0);\n var factor = 1.0;\n if (u.params.y > 0.5 && u.viewport.w < 0.5) {\n factor = clamp(u.params.z / max(clip.w, 1e-6), 0.5, 2.0);\n }\n let glow = u.eye.w > 1.5;\n let raw = max(size, 0.0) * u.viewport.z * factor * 0.5;\n let radius = max(raw, select(0.5, 0.75, glow));\n let reach = select(radius + 1.0, radius * 2.2 + 1.0, glow);\n let shift = corner * reach * 2.0 / u.viewport.xy * clip.w;\n out.position = toWebGpuDepth(vec4f(clip.xy + shift, clip.z, clip.w));\n out.offset = corner * reach;\n out.radius = radius;\n out.color = color;\n out.fog = depthCue(pos);\n out.coverage = min(1.0, raw * raw / (radius * radius));\n return out;\n}\n\nfn shade(in: Out) -> vec4f {\n let d = length(in.offset);\n let r = in.radius;\n var alpha = clamp(r + 0.5 - d, 0.0, 1.0);\n var rgb = in.color.rgb;\n if (u.eye.w > 1.5) {\n // glow: an anti-aliased core and a gaussian halo\n let core = clamp(r * 0.6 + 0.5 - d, 0.0, 1.0);\n let q = d / r;\n alpha = core + (1.0 - core) * exp(-1.2 * q * q);\n rgb = rgb + (vec3f(1.0) - rgb) * (0.2 * core);\n } else if (u.eye.w < 0.5) {\n let q = min(d / r, 1.0);\n let n = vec3f(in.offset.x / r, in.offset.y / r, sqrt(max(0.0, 1.0 - q * q)));\n let l = normalize(vec3f(-0.45, 0.55, 0.7));\n let lambert = max(dot(n, l), 0.0);\n let shaded = rgb * (0.62 + 0.45 * lambert) + vec3f(pow(lambert, 18.0) * 0.28);\n rgb = mix(rgb, shaded, smoothstep(1.5, 3.5, r));\n }\n if (alpha <= 0.004) { discard; }\n let fog = in.fog * 0.45;\n if (u.light.w > 0.5) {\n // additive light fades with the distance\n alpha = alpha * (1.0 - fog);\n rgb = rgb * u.fog.w;\n } else {\n rgb = mix(rgb, u.fog.rgb, fog);\n }\n alpha = alpha * in.coverage * in.color.a * u.params.x;\n return vec4f(rgb * alpha, alpha);\n}\n\n@fragment\nfn fs(in: Out) -> @location(0) vec4f {\n return shade(in);\n}\n\n@fragment\nfn fsOit(in: Out) -> Oit {\n return oit(shade(in), in.fog);\n}\n`;\n\nexport const WGSL_MESH = /* wgsl */ `${WGSL_UNIFORMS}\nstruct Out {\n @builtin(position) position: vec4f,\n @location(0) world: vec3f,\n @location(1) normal: vec3f,\n @location(2) color: vec4f,\n};\n\n@vertex\nfn vs(\n @location(0) pos: vec3f,\n @location(1) normal: vec3f,\n @location(2) color: vec4f,\n) -> Out {\n var out: Out;\n out.position = toWebGpuDepth(u.viewProj * vec4f(pos, 1.0));\n out.world = pos;\n out.normal = normal;\n out.color = color;\n return out;\n}\n\nfn shade(in: Out) -> vec4f {\n var n = normalize(in.normal);\n let v = normalize(u.eye.xyz - in.world);\n if (dot(n, v) < 0.0) { n = -n; }\n let l = u.light.xyz;\n let diffuse = max(dot(n, l), 0.0);\n let h = normalize(l + v);\n let specular = pow(max(dot(n, h), 0.0), u.material.w) * u.material.z;\n let rgb = in.color.rgb * (u.material.x + u.material.y * diffuse) + vec3f(specular);\n let alpha = in.color.a * u.params.x;\n return vec4f(rgb * alpha, alpha);\n}\n\n@fragment\nfn fs(in: Out) -> @location(0) vec4f {\n return shade(in);\n}\n\n@fragment\nfn fsOit(in: Out) -> Oit {\n return oit(shade(in), depthCue(in.world));\n}\n`;\n\nexport const WGSL_LINES = /* wgsl */ `${WGSL_UNIFORMS}\nstruct Out {\n @builtin(position) position: vec4f,\n @location(0) across: f32,\n @location(1) color: vec4f,\n};\n\n@vertex\nfn vs(\n @builtin(vertex_index) vi: u32,\n @location(0) a: vec3f,\n @location(1) b: vec3f,\n @location(2) color: vec4f,\n) -> Out {\n var out: Out;\n let corner = vec2f(f32(vi & 1u), f32(vi >> 1u));\n let ca = u.viewProj * vec4f(a, 1.0);\n let cb = u.viewProj * vec4f(b, 1.0);\n let halfSize = u.viewport.xy * 0.5;\n let sa = ca.xy / ca.w * halfSize;\n let sb = cb.xy / cb.w * halfSize;\n var dir = sb - sa;\n let len = length(dir);\n dir = select(vec2f(1.0, 0.0), dir / len, len > 1e-6);\n let normal = vec2f(-dir.y, dir.x);\n let w = max(0.5, u.params.y * u.viewport.z * 0.5) + 0.5;\n let clip = select(ca, cb, corner.x > 0.5);\n let side = corner.y * 2.0 - 1.0;\n let pixel = select(sa, sb, corner.x > 0.5) + dir * (corner.x * 2.0 - 1.0) * w + normal * side * w;\n let z = clip.z - u.eye.w * clip.w;\n out.position = toWebGpuDepth(vec4f(pixel / halfSize * clip.w, z, clip.w));\n out.across = side * w;\n out.color = color;\n return out;\n}\n\n@fragment\nfn fs(in: Out) -> @location(0) vec4f {\n let core = u.params.y * u.viewport.z * 0.5;\n let coverage = clamp(max(core, 0.5) + 0.5 - abs(in.across), 0.0, 1.0) * min(1.0, core * 2.0);\n let alpha = coverage * in.color.a * u.params.x;\n if (alpha <= 0.0) { discard; }\n return vec4f(in.color.rgb * alpha, alpha);\n}\n`;\n\n// ------------------------------------------------------------------- GLSL\n\nconst GLSL_UNIFORMS = `\nuniform mat4 u_viewProj;\nuniform vec4 u_viewport;\nuniform vec4 u_eye;\nuniform vec4 u_light;\nuniform vec4 u_material;\nuniform vec4 u_params;\nuniform vec4 u_fog;\n`;\n\nconst GLSL_POINTS_VS = `\nattribute vec2 a_corner;\nattribute vec3 a_pos;\nattribute float a_size;\nattribute vec4 a_color;\nvarying vec2 v_offset;\nvarying float v_radius;\nvarying vec4 v_color;\nvarying float v_fog;\nvarying float v_coverage;\nvoid main() {\n vec2 corner = a_corner * 2.0 - 1.0;\n vec4 clip = u_viewProj * vec4(a_pos, 1.0);\n float factor = 1.0;\n if (u_params.y > 0.5 && u_viewport.w < 0.5) {\n factor = clamp(u_params.z / max(clip.w, 1e-6), 0.5, 2.0);\n }\n bool glow = u_eye.w > 1.5;\n float raw = max(a_size, 0.0) * u_viewport.z * factor * 0.5;\n float radius = max(raw, glow ? 0.75 : 0.5);\n float reach = glow ? radius * 2.2 + 1.0 : radius + 1.0;\n vec2 shift = corner * reach * 2.0 / u_viewport.xy * clip.w;\n gl_Position = vec4(clip.xy + shift, clip.z, clip.w);\n v_offset = corner * reach;\n v_radius = radius;\n v_color = a_color;\n float near = u_params.z - u_params.w;\n v_fog = clamp((length(a_pos - u_eye.xyz) - near) / (2.0 * u_params.w), 0.0, 1.0);\n v_coverage = min(1.0, raw * raw / (radius * radius));\n}\n`;\n\nconst GLSL_POINTS_FS = `\nvarying vec2 v_offset;\nvarying float v_radius;\nvarying vec4 v_color;\nvarying float v_fog;\nvarying float v_coverage;\nvoid main() {\n float d = length(v_offset);\n float r = v_radius;\n float alpha = clamp(r + 0.5 - d, 0.0, 1.0);\n vec3 rgb = v_color.rgb;\n if (u_eye.w > 1.5) {\n float core = clamp(r * 0.6 + 0.5 - d, 0.0, 1.0);\n float q = d / r;\n alpha = core + (1.0 - core) * exp(-1.2 * q * q);\n rgb = rgb + (vec3(1.0) - rgb) * (0.2 * core);\n } else if (u_eye.w < 0.5) {\n float q = min(d / r, 1.0);\n vec3 n = vec3(v_offset / r, sqrt(max(0.0, 1.0 - q * q)));\n vec3 l = normalize(vec3(-0.45, 0.55, 0.7));\n float lambert = max(dot(n, l), 0.0);\n vec3 shaded = rgb * (0.62 + 0.45 * lambert) + vec3(pow(lambert, 18.0) * 0.28);\n rgb = mix(rgb, shaded, smoothstep(1.5, 3.5, r));\n }\n if (alpha <= 0.004) discard;\n float fog = v_fog * 0.45;\n if (u_light.w > 0.5) {\n alpha = alpha * (1.0 - fog);\n rgb = rgb * u_fog.w;\n } else {\n rgb = mix(rgb, u_fog.rgb, fog);\n }\n alpha = alpha * v_coverage * v_color.a * u_params.x;\n EMIT(vec4(rgb * alpha, alpha), v_fog);\n}\n`;\n\nconst GLSL_MESH_VS = `\nattribute vec3 a_pos;\nattribute vec3 a_normal;\nattribute vec4 a_color;\nvarying vec3 v_world;\nvarying vec3 v_normal;\nvarying vec4 v_color;\nvoid main() {\n gl_Position = u_viewProj * vec4(a_pos, 1.0);\n v_world = a_pos;\n v_normal = a_normal;\n v_color = a_color;\n}\n`;\n\nconst GLSL_MESH_FS = `\nvarying vec3 v_world;\nvarying vec3 v_normal;\nvarying vec4 v_color;\nvoid main() {\n vec3 n = normalize(v_normal);\n vec3 v = normalize(u_eye.xyz - v_world);\n if (dot(n, v) < 0.0) n = -n;\n vec3 l = u_light.xyz;\n float diffuse = max(dot(n, l), 0.0);\n vec3 h = normalize(l + v);\n float specular = pow(max(dot(n, h), 0.0), u_material.w) * u_material.z;\n vec3 rgb = v_color.rgb * (u_material.x + u_material.y * diffuse) + vec3(specular);\n float alpha = v_color.a * u_params.x;\n float near = u_params.z - u_params.w;\n float depth = (length(v_world - u_eye.xyz) - near) / (2.0 * u_params.w);\n EMIT(vec4(rgb * alpha, alpha), depth);\n}\n`;\n\nconst GLSL_LINES_VS = `\nattribute vec2 a_corner;\nattribute vec3 a_a;\nattribute vec3 a_b;\nattribute vec4 a_color;\nvarying float v_across;\nvarying vec4 v_color;\nvoid main() {\n vec4 ca = u_viewProj * vec4(a_a, 1.0);\n vec4 cb = u_viewProj * vec4(a_b, 1.0);\n vec2 halfSize = u_viewport.xy * 0.5;\n vec2 sa = ca.xy / ca.w * halfSize;\n vec2 sb = cb.xy / cb.w * halfSize;\n vec2 dir = sb - sa;\n float len = length(dir);\n dir = len > 1e-6 ? dir / len : vec2(1.0, 0.0);\n vec2 normal = vec2(-dir.y, dir.x);\n float w = max(0.5, u_params.y * u_viewport.z * 0.5) + 0.5;\n bool atEnd = a_corner.x > 0.5;\n vec4 clip = atEnd ? cb : ca;\n float side = a_corner.y * 2.0 - 1.0;\n vec2 pixel = (atEnd ? sb : sa) + dir * (a_corner.x * 2.0 - 1.0) * w + normal * side * w;\n gl_Position = vec4(pixel / halfSize * clip.w, clip.z - u_eye.w * clip.w, clip.w);\n v_across = side * w;\n v_color = a_color;\n}\n`;\n\nconst GLSL_LINES_FS = `\nvarying float v_across;\nvarying vec4 v_color;\nvoid main() {\n float core = u_params.y * u_viewport.z * 0.5;\n float coverage = clamp(max(core, 0.5) + 0.5 - abs(v_across), 0.0, 1.0) * min(1.0, core * 2.0);\n float alpha = coverage * v_color.a * u_params.x;\n if (alpha <= 0.0) discard;\n EMIT(vec4(v_color.rgb * alpha, alpha), 0.0);\n}\n`;\n\nconst PRECISION = `\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n`;\n\nexport interface GlslSource {\n vertex: string;\n fragment: string;\n}\n\nconst glsl = (\n vs: string,\n fs: string,\n version: 1 | 2,\n oit = false,\n): GlslSource =>\n version === 2\n ? {\n vertex: `#version 300 es\\n#define attribute in\\n#define varying out\\n${GLSL_UNIFORMS}${vs}`,\n fragment: `#version 300 es\\nprecision highp float;\\n#define varying in\\n${GLSL_UNIFORMS}${\n oit\n ? GLSL_OIT\n : \"out vec4 fragColor;\\n#define EMIT(c, d) fragColor = (c)\\n\"\n }${fs}`,\n }\n : {\n vertex: `${GLSL_UNIFORMS}${vs}`,\n fragment: `${PRECISION}#define EMIT(c, d) gl_FragColor = (c)\\n${GLSL_UNIFORMS}${fs}`,\n };\n\n/** GLSL programs of the three primitives for WebGL (1) or WebGL2 */\nexport const glslPrograms = (version: 1 | 2) => ({\n points: glsl(GLSL_POINTS_VS, GLSL_POINTS_FS, version),\n mesh: glsl(GLSL_MESH_VS, GLSL_MESH_FS, version),\n lines: glsl(GLSL_LINES_VS, GLSL_LINES_FS, version),\n});\n\n/**\n * Variants of the points and meshes writing the targets of the\n * order-independent transparency (WebGL2)\n */\nexport const glslOitPrograms = () => ({\n points: glsl(GLSL_POINTS_VS, GLSL_POINTS_FS, 2, true),\n mesh: glsl(GLSL_MESH_VS, GLSL_MESH_FS, 2, true),\n});\n\n/** Attribute names of every program, bound to locations 0, 1, ... */\nexport const GLSL_ATTRIBUTES = {\n points: [\"a_corner\", \"a_pos\", \"a_size\", \"a_color\"],\n mesh: [\"a_pos\", \"a_normal\", \"a_color\"],\n lines: [\"a_corner\", \"a_a\", \"a_b\", \"a_color\"],\n} as const;\n"],"mappings":"6DAiCA,IAAMI,GACJ,EACA,EACA,EACA,EACA,EACA,EACA,EACA,KAEAC,EAAI,IAAIC,EAAU,CAAC,EACnBD,EAAI,IAAIE,EAAU,EAAE,EACpBF,EAAI,IAAIG,EAAK,EAAE,EACfH,EAAI,IAAII,EAAO,EAAE,EACjBJ,EAAI,IAAIK,EAAU,EAAE,EACpBL,EAAI,IAAIM,EAAQ,EAAE,EAClBN,EAAI,IAAIO,EAAK,EAAE,EACRP,GAIIQ,GACX,EACA,EACA,IACiB,CACjB,IAAMC,EACJC,EAAK,OAAS,SACV,KAAK,YAGLA,EAAK,OAAS,QACZA,EAAK,MACL,EACR,OAAOX,EACLC,EACAW,EAAM,SACN,CAACA,EAAM,MAAOA,EAAM,OAAQA,EAAM,IAAK,KAAM,YAAoB,EACjE,CACEA,EAAM,IAAI,GACVA,EAAM,IAAI,GACVA,EAAM,IAAI,GACVD,EAAK,OAAS,QACVA,EAAK,KACLA,EAAK,OAAS,SACXA,EAAK,OAAA,EACN,CACR,EACA,CACEC,EAAM,MAAM,GACZA,EAAM,MAAM,GACZA,EAAM,MAAM,GACZD,EAAK,OAAS,UAAYA,EAAK,SAAW,EAAI,CAChD,EACAC,EAAM,SACN,CAACD,EAAK,QAASD,EAAQE,EAAM,SAAUA,EAAM,MAAM,EACnD,CAACA,EAAM,IAAI,GAAIA,EAAM,IAAI,GAAIA,EAAM,IAAI,GAAIA,EAAM,QAAQ,CAC3D,CACF,EAIMC,EAA2B;;;;;;;;;;;;;;;;;;;;EAoB/BjB,EAAAA,WAEWkB,EAAyB,GAAGD,EAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiF1CE,EAAuB,GAAGF,EAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8CxCG,EAAwB,GAAGH,EAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgDhDI,EAAgB;;;;;;;;EAUhBC,EAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCjBC,EAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqCjBC,EAAe;;;;;;;;;;;;;EAefC,EAAe;;;;;;;;;;;;;;;;;;EAoBfC,EAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BhBC,EAAgB;;;;;;;;;;EAYhBC,EAAY;;;;;;EAaZC,GACJ,EACA,EACA,EACA,EAAM,KAENC,IAAY,EACR,CACE,OAAQ,+DAA+DT,IAAgBU,IACvF,SAAU,gEAAgEV,IACxEW,EACI/B,EAAAA,SACA;;IACHgC,GACL,EACA,CACE,OAAQ,GAAGZ,IAAgBU,IAC3B,SAAU,GAAGH,EAAU,yCAAyCP,IAAgBY,GAClF,EAGOC,EAAgB,IAAoB,CAC/C,OAAQL,EAAKP,EAAgBC,EAAgBO,CAAO,EACpD,KAAMD,EAAKL,EAAcC,EAAcK,CAAO,EAC9C,MAAOD,EAAKH,EAAeC,EAAeG,CAAO,CACnD,GAMaK,OAAyB,CACpC,OAAQN,EAAKP,EAAgBC,EAAgB,EAAG,EAAI,EACpD,KAAMM,EAAKL,EAAcC,EAAc,EAAG,EAAI,CAChD,GAGaW,EAAkB,CAC7B,OAAQ,CAAC,WAAY,QAAS,SAAU,SAAS,EACjD,KAAM,CAAC,QAAS,WAAY,SAAS,EACrC,MAAO,CAAC,WAAY,MAAO,MAAO,SAAS,CAC7C"}
@@ -4,9 +4,9 @@ export { writesDepth } from './render-types.cjs';
4
4
  export declare const UNIFORM_BYTES = 160;
5
5
  /** Uniform values of an item (40 floats, the WGSL struct layout) */
6
6
  export declare const itemUniforms: (item: Item3D, frame: Frame3D, out: Float32Array) => Float32Array;
7
- export declare const WGSL_POINTS = "\nstruct U {\n viewProj: mat4x4f,\n viewport: vec4f,\n eye: vec4f,\n light: vec4f,\n material: vec4f,\n params: vec4f,\n fog: vec4f,\n};\n@group(0) @binding(0) var<uniform> u: U;\n\nfn toWebGpuDepth(p: vec4f) -> vec4f {\n return vec4f(p.x, p.y, (p.z + p.w) * 0.5, p.w);\n}\n\nfn depthCue(world: vec3f) -> f32 {\n let near = u.params.z - u.params.w;\n return clamp((length(world - u.eye.xyz) - near) / (2.0 * u.params.w), 0.0, 1.0);\n}\n\nstruct Out {\n @builtin(position) position: vec4f,\n @location(0) offset: vec2f,\n @location(1) radius: f32,\n @location(2) color: vec4f,\n @location(3) fog: f32,\n @location(4) coverage: f32,\n};\n\n@vertex\nfn vs(\n @builtin(vertex_index) vi: u32,\n @location(0) pos: vec3f,\n @location(1) size: f32,\n @location(2) color: vec4f,\n) -> Out {\n var out: Out;\n let corner = vec2f(f32(vi & 1u), f32(vi >> 1u)) * 2.0 - 1.0;\n let clip = u.viewProj * vec4f(pos, 1.0);\n var factor = 1.0;\n if (u.params.y > 0.5 && u.viewport.w < 0.5) {\n factor = clamp(u.params.z / max(clip.w, 1e-6), 0.5, 2.0);\n }\n let glow = u.eye.w > 1.5;\n let raw = max(size, 0.0) * u.viewport.z * factor * 0.5;\n let radius = max(raw, select(0.5, 0.75, glow));\n let reach = select(radius + 1.0, radius * 2.2 + 1.0, glow);\n let shift = corner * reach * 2.0 / u.viewport.xy * clip.w;\n out.position = toWebGpuDepth(vec4f(clip.xy + shift, clip.z, clip.w));\n out.offset = corner * reach;\n out.radius = radius;\n out.color = color;\n out.fog = depthCue(pos) * 0.45;\n out.coverage = min(1.0, raw * raw / (radius * radius));\n return out;\n}\n\n@fragment\nfn fs(in: Out) -> @location(0) vec4f {\n let d = length(in.offset);\n let r = in.radius;\n var alpha = clamp(r + 0.5 - d, 0.0, 1.0);\n var rgb = in.color.rgb;\n if (u.eye.w > 1.5) {\n // glow: an anti-aliased core and a gaussian halo\n let core = clamp(r * 0.6 + 0.5 - d, 0.0, 1.0);\n let q = d / r;\n alpha = core + (1.0 - core) * exp(-1.2 * q * q);\n rgb = rgb + (vec3f(1.0) - rgb) * (0.2 * core);\n } else if (u.eye.w < 0.5) {\n let q = min(d / r, 1.0);\n let n = vec3f(in.offset.x / r, in.offset.y / r, sqrt(max(0.0, 1.0 - q * q)));\n let l = normalize(vec3f(-0.45, 0.55, 0.7));\n let lambert = max(dot(n, l), 0.0);\n let shaded = rgb * (0.62 + 0.45 * lambert) + vec3f(pow(lambert, 18.0) * 0.28);\n rgb = mix(rgb, shaded, smoothstep(1.5, 3.5, r));\n }\n if (alpha <= 0.004) { discard; }\n if (u.light.w > 0.5) {\n // additive light fades with the distance\n alpha = alpha * (1.0 - in.fog);\n } else {\n rgb = mix(rgb, u.fog.rgb, in.fog);\n }\n alpha = alpha * in.coverage * in.color.a * u.params.x;\n return vec4f(rgb * alpha, alpha);\n}\n";
8
- export declare const WGSL_MESH = "\nstruct U {\n viewProj: mat4x4f,\n viewport: vec4f,\n eye: vec4f,\n light: vec4f,\n material: vec4f,\n params: vec4f,\n fog: vec4f,\n};\n@group(0) @binding(0) var<uniform> u: U;\n\nfn toWebGpuDepth(p: vec4f) -> vec4f {\n return vec4f(p.x, p.y, (p.z + p.w) * 0.5, p.w);\n}\n\nfn depthCue(world: vec3f) -> f32 {\n let near = u.params.z - u.params.w;\n return clamp((length(world - u.eye.xyz) - near) / (2.0 * u.params.w), 0.0, 1.0);\n}\n\nstruct Out {\n @builtin(position) position: vec4f,\n @location(0) world: vec3f,\n @location(1) normal: vec3f,\n @location(2) color: vec4f,\n};\n\n@vertex\nfn vs(\n @location(0) pos: vec3f,\n @location(1) normal: vec3f,\n @location(2) color: vec4f,\n) -> Out {\n var out: Out;\n out.position = toWebGpuDepth(u.viewProj * vec4f(pos, 1.0));\n out.world = pos;\n out.normal = normal;\n out.color = color;\n return out;\n}\n\n@fragment\nfn fs(in: Out) -> @location(0) vec4f {\n var n = normalize(in.normal);\n let v = normalize(u.eye.xyz - in.world);\n if (dot(n, v) < 0.0) { n = -n; }\n let l = u.light.xyz;\n let diffuse = max(dot(n, l), 0.0);\n let h = normalize(l + v);\n let specular = pow(max(dot(n, h), 0.0), u.material.w) * u.material.z;\n let rgb = in.color.rgb * (u.material.x + u.material.y * diffuse) + vec3f(specular);\n let alpha = in.color.a * u.params.x;\n return vec4f(rgb * alpha, alpha);\n}\n";
9
- export declare const WGSL_LINES = "\nstruct U {\n viewProj: mat4x4f,\n viewport: vec4f,\n eye: vec4f,\n light: vec4f,\n material: vec4f,\n params: vec4f,\n fog: vec4f,\n};\n@group(0) @binding(0) var<uniform> u: U;\n\nfn toWebGpuDepth(p: vec4f) -> vec4f {\n return vec4f(p.x, p.y, (p.z + p.w) * 0.5, p.w);\n}\n\nfn depthCue(world: vec3f) -> f32 {\n let near = u.params.z - u.params.w;\n return clamp((length(world - u.eye.xyz) - near) / (2.0 * u.params.w), 0.0, 1.0);\n}\n\nstruct Out {\n @builtin(position) position: vec4f,\n @location(0) across: f32,\n @location(1) color: vec4f,\n};\n\n@vertex\nfn vs(\n @builtin(vertex_index) vi: u32,\n @location(0) a: vec3f,\n @location(1) b: vec3f,\n @location(2) color: vec4f,\n) -> Out {\n var out: Out;\n let corner = vec2f(f32(vi & 1u), f32(vi >> 1u));\n let ca = u.viewProj * vec4f(a, 1.0);\n let cb = u.viewProj * vec4f(b, 1.0);\n let halfSize = u.viewport.xy * 0.5;\n let sa = ca.xy / ca.w * halfSize;\n let sb = cb.xy / cb.w * halfSize;\n var dir = sb - sa;\n let len = length(dir);\n dir = select(vec2f(1.0, 0.0), dir / len, len > 1e-6);\n let normal = vec2f(-dir.y, dir.x);\n let w = max(0.5, u.params.y * u.viewport.z * 0.5) + 0.5;\n let clip = select(ca, cb, corner.x > 0.5);\n let side = corner.y * 2.0 - 1.0;\n let pixel = select(sa, sb, corner.x > 0.5) + dir * (corner.x * 2.0 - 1.0) * w + normal * side * w;\n let z = clip.z - u.eye.w * clip.w;\n out.position = toWebGpuDepth(vec4f(pixel / halfSize * clip.w, z, clip.w));\n out.across = side * w;\n out.color = color;\n return out;\n}\n\n@fragment\nfn fs(in: Out) -> @location(0) vec4f {\n let core = u.params.y * u.viewport.z * 0.5;\n let coverage = clamp(max(core, 0.5) + 0.5 - abs(in.across), 0.0, 1.0) * min(1.0, core * 2.0);\n let alpha = coverage * in.color.a * u.params.x;\n if (alpha <= 0.0) { discard; }\n return vec4f(in.color.rgb * alpha, alpha);\n}\n";
7
+ export declare const WGSL_POINTS: string;
8
+ export declare const WGSL_MESH: string;
9
+ export declare const WGSL_LINES: string;
10
10
  export interface GlslSource {
11
11
  vertex: string;
12
12
  fragment: string;
@@ -17,6 +17,14 @@ export declare const glslPrograms: (version: 1 | 2) => {
17
17
  mesh: GlslSource;
18
18
  lines: GlslSource;
19
19
  };
20
+ /**
21
+ * Variants of the points and meshes writing the targets of the
22
+ * order-independent transparency (WebGL2)
23
+ */
24
+ export declare const glslOitPrograms: () => {
25
+ points: GlslSource;
26
+ mesh: GlslSource;
27
+ };
20
28
  /** Attribute names of every program, bound to locations 0, 1, ... */
21
29
  export declare const GLSL_ATTRIBUTES: {
22
30
  readonly points: readonly ["a_corner", "a_pos", "a_size", "a_color"];