matterviz 0.3.4 → 0.3.6

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 (852) hide show
  1. package/.vscode/launch.json +13 -0
  2. package/.vscodeignore +7 -0
  3. package/dist/assets/STLExporter-BpTH3YHE.js +8 -0
  4. package/dist/assets/browser-DdDecX_W.js +1 -0
  5. package/dist/assets/export-qgn-H9y6.js +2 -0
  6. package/dist/assets/main-DiKYzti2.css +1 -0
  7. package/dist/assets/moyo_wasm_bg-0ocwg7xY.wasm +0 -0
  8. package/dist/extension.js +31293 -0
  9. package/dist/src/lib/FilePicker.svelte +360 -0
  10. package/dist/src/lib/MillerIndexInput.svelte +66 -0
  11. package/dist/src/lib/api/mp.ts +26 -0
  12. package/dist/src/lib/api/optimade.ts +204 -0
  13. package/dist/src/lib/app.css +247 -0
  14. package/dist/src/lib/brillouin/BrillouinZone.svelte +549 -0
  15. package/dist/src/lib/brillouin/BrillouinZoneControls.svelte +144 -0
  16. package/dist/src/lib/brillouin/BrillouinZoneExportPane.svelte +146 -0
  17. package/dist/src/lib/brillouin/BrillouinZoneInfoPane.svelte +146 -0
  18. package/dist/src/lib/brillouin/BrillouinZoneScene.svelte +476 -0
  19. package/dist/src/lib/brillouin/BrillouinZoneTooltip.svelte +92 -0
  20. package/dist/src/lib/brillouin/compute.ts +529 -0
  21. package/dist/src/lib/brillouin/index.ts +8 -0
  22. package/dist/src/lib/brillouin/types.ts +51 -0
  23. package/dist/src/lib/chempot-diagram/ChemPotDiagram.svelte +327 -0
  24. package/dist/src/lib/chempot-diagram/ChemPotDiagram2D.svelte +846 -0
  25. package/dist/src/lib/chempot-diagram/ChemPotDiagram3D.svelte +3193 -0
  26. package/dist/src/lib/chempot-diagram/async-compute.svelte.ts +94 -0
  27. package/dist/src/lib/chempot-diagram/chempot-worker.ts +11 -0
  28. package/dist/src/lib/chempot-diagram/color.ts +42 -0
  29. package/dist/src/lib/chempot-diagram/compute.ts +1014 -0
  30. package/dist/src/lib/chempot-diagram/index.ts +6 -0
  31. package/dist/src/lib/chempot-diagram/pointer.ts +56 -0
  32. package/dist/src/lib/chempot-diagram/temperature.ts +77 -0
  33. package/dist/src/lib/chempot-diagram/types.ts +130 -0
  34. package/dist/src/lib/colors/index.ts +249 -0
  35. package/dist/src/lib/composition/BarChart.svelte +297 -0
  36. package/dist/src/lib/composition/BubbleChart.svelte +218 -0
  37. package/dist/src/lib/composition/Composition.svelte +165 -0
  38. package/dist/src/lib/composition/Formula.svelte +268 -0
  39. package/dist/src/lib/composition/FormulaFilter.svelte +1257 -0
  40. package/dist/src/lib/composition/PieChart.svelte +323 -0
  41. package/dist/src/lib/composition/format.ts +155 -0
  42. package/dist/src/lib/composition/index.ts +37 -0
  43. package/dist/src/lib/composition/parse.ts +605 -0
  44. package/dist/src/lib/constants.ts +134 -0
  45. package/dist/src/lib/controls.ts +42 -0
  46. package/dist/src/lib/convex-hull/ConvexHull.svelte +157 -0
  47. package/dist/src/lib/convex-hull/ConvexHull2D.svelte +825 -0
  48. package/dist/src/lib/convex-hull/ConvexHull3D.svelte +1801 -0
  49. package/dist/src/lib/convex-hull/ConvexHull4D.svelte +1398 -0
  50. package/dist/src/lib/convex-hull/ConvexHullControls.svelte +535 -0
  51. package/dist/src/lib/convex-hull/ConvexHullInfoPane.svelte +125 -0
  52. package/dist/src/lib/convex-hull/ConvexHullStats.svelte +929 -0
  53. package/dist/src/lib/convex-hull/ConvexHullTooltip.svelte +131 -0
  54. package/dist/src/lib/convex-hull/GasPressureControls.svelte +247 -0
  55. package/dist/src/lib/convex-hull/StructurePopup.svelte +151 -0
  56. package/dist/src/lib/convex-hull/TemperatureSlider.svelte +140 -0
  57. package/dist/src/lib/convex-hull/barycentric-coords.ts +246 -0
  58. package/dist/src/lib/convex-hull/demo-temperature.ts +63 -0
  59. package/dist/src/lib/convex-hull/gas-thermodynamics.ts +405 -0
  60. package/dist/src/lib/convex-hull/helpers.ts +932 -0
  61. package/dist/src/lib/convex-hull/index.ts +202 -0
  62. package/dist/src/lib/convex-hull/thermodynamics.ts +2192 -0
  63. package/dist/src/lib/convex-hull/types.ts +267 -0
  64. package/dist/src/lib/coordination/CoordinationBarPlot.svelte +311 -0
  65. package/dist/src/lib/coordination/calc-coordination.ts +93 -0
  66. package/dist/src/lib/coordination/index.ts +9 -0
  67. package/dist/src/lib/effects.svelte.ts +48 -0
  68. package/dist/src/lib/element/BohrAtom.svelte +147 -0
  69. package/dist/src/lib/element/ElementHeading.svelte +26 -0
  70. package/dist/src/lib/element/ElementPhoto.svelte +57 -0
  71. package/dist/src/lib/element/ElementStats.svelte +80 -0
  72. package/dist/src/lib/element/ElementTile.svelte +484 -0
  73. package/dist/src/lib/element/data.json.gz.d.ts +4 -0
  74. package/dist/src/lib/element/data.ts +14 -0
  75. package/dist/src/lib/element/index.ts +8 -0
  76. package/dist/src/lib/element/types.ts +62 -0
  77. package/dist/src/lib/feedback/ClickFeedback.svelte +58 -0
  78. package/dist/src/lib/feedback/DragOverlay.svelte +42 -0
  79. package/dist/src/lib/feedback/index.ts +4 -0
  80. package/dist/src/lib/fermi-surface/FermiSlice.svelte +189 -0
  81. package/dist/src/lib/fermi-surface/FermiSurface.svelte +600 -0
  82. package/dist/src/lib/fermi-surface/FermiSurfaceControls.svelte +448 -0
  83. package/dist/src/lib/fermi-surface/FermiSurfaceScene.svelte +794 -0
  84. package/dist/src/lib/fermi-surface/FermiSurfaceTooltip.svelte +111 -0
  85. package/dist/src/lib/fermi-surface/compute.ts +728 -0
  86. package/dist/src/lib/fermi-surface/constants.ts +32 -0
  87. package/dist/src/lib/fermi-surface/export.ts +64 -0
  88. package/dist/src/lib/fermi-surface/index.ts +14 -0
  89. package/dist/src/lib/fermi-surface/marching-cubes.ts +3 -0
  90. package/dist/src/lib/fermi-surface/parse.ts +574 -0
  91. package/dist/src/lib/fermi-surface/symmetry.ts +56 -0
  92. package/dist/src/lib/fermi-surface/types.ts +159 -0
  93. package/dist/src/lib/heatmap-matrix/HeatmapMatrix.svelte +1545 -0
  94. package/dist/src/lib/heatmap-matrix/HeatmapMatrixControls.svelte +225 -0
  95. package/dist/src/lib/heatmap-matrix/index.ts +167 -0
  96. package/dist/src/lib/heatmap-matrix/shared.ts +7 -0
  97. package/dist/src/lib/icons.ts +650 -0
  98. package/dist/src/lib/index.ts +61 -0
  99. package/dist/src/lib/io/decompress.ts +92 -0
  100. package/dist/src/lib/io/export.ts +385 -0
  101. package/dist/src/lib/io/fetch.ts +46 -0
  102. package/dist/src/lib/io/file-drop.ts +51 -0
  103. package/dist/src/lib/io/index.ts +7 -0
  104. package/dist/src/lib/io/is-binary.ts +24 -0
  105. package/dist/src/lib/io/types.ts +8 -0
  106. package/dist/src/lib/io/url-drop.ts +141 -0
  107. package/dist/src/lib/isosurface/Isosurface.svelte +285 -0
  108. package/dist/src/lib/isosurface/IsosurfaceControls.svelte +277 -0
  109. package/dist/src/lib/isosurface/index.ts +7 -0
  110. package/dist/src/lib/isosurface/parse.ts +656 -0
  111. package/dist/src/lib/isosurface/slice.ts +175 -0
  112. package/dist/src/lib/isosurface/types.ts +309 -0
  113. package/dist/src/lib/labels.ts +320 -0
  114. package/dist/src/lib/layout/FullscreenToggle.svelte +50 -0
  115. package/dist/src/lib/layout/InfoCard.svelte +120 -0
  116. package/dist/src/lib/layout/InfoTag.svelte +185 -0
  117. package/dist/src/lib/layout/PropertyFilter.svelte +246 -0
  118. package/dist/src/lib/layout/SettingsSection.svelte +148 -0
  119. package/dist/src/lib/layout/SubpageGrid.svelte +82 -0
  120. package/dist/src/lib/layout/fullscreen.ts +65 -0
  121. package/dist/src/lib/layout/index.ts +11 -0
  122. package/dist/src/lib/layout/json-tree/JsonNode.svelte +548 -0
  123. package/dist/src/lib/layout/json-tree/JsonTree.svelte +1230 -0
  124. package/dist/src/lib/layout/json-tree/JsonValue.svelte +334 -0
  125. package/dist/src/lib/layout/json-tree/index.ts +3 -0
  126. package/dist/src/lib/layout/json-tree/types.ts +126 -0
  127. package/dist/src/lib/layout/json-tree/utils.ts +682 -0
  128. package/dist/src/lib/marching-cubes.ts +614 -0
  129. package/dist/src/lib/math.ts +1081 -0
  130. package/dist/src/lib/overlays/ContextMenu.svelte +162 -0
  131. package/dist/src/lib/overlays/CopyButton.svelte +45 -0
  132. package/dist/src/lib/overlays/DragControlTab.svelte +98 -0
  133. package/dist/src/lib/overlays/DraggablePane.svelte +487 -0
  134. package/dist/src/lib/overlays/InfoPaneCards.svelte +149 -0
  135. package/dist/src/lib/overlays/index.ts +3 -0
  136. package/dist/src/lib/periodic-table/PeriodicTable.svelte +469 -0
  137. package/dist/src/lib/periodic-table/PeriodicTableControls.svelte +557 -0
  138. package/dist/src/lib/periodic-table/PropertySelect.svelte +37 -0
  139. package/dist/src/lib/periodic-table/index.ts +12 -0
  140. package/dist/src/lib/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +1086 -0
  141. package/dist/src/lib/phase-diagram/PhaseDiagramControls.svelte +444 -0
  142. package/dist/src/lib/phase-diagram/PhaseDiagramEditorPane.svelte +126 -0
  143. package/dist/src/lib/phase-diagram/PhaseDiagramExportPane.svelte +184 -0
  144. package/dist/src/lib/phase-diagram/PhaseDiagramTooltip.svelte +391 -0
  145. package/dist/src/lib/phase-diagram/TdbInfoPanel.svelte +203 -0
  146. package/dist/src/lib/phase-diagram/build-diagram.ts +186 -0
  147. package/dist/src/lib/phase-diagram/colors.ts +58 -0
  148. package/dist/src/lib/phase-diagram/diagram-input.ts +40 -0
  149. package/dist/src/lib/phase-diagram/index.ts +13 -0
  150. package/dist/src/lib/phase-diagram/parse.ts +348 -0
  151. package/dist/src/lib/phase-diagram/svg-to-diagram.ts +1023 -0
  152. package/dist/src/lib/phase-diagram/types.ts +144 -0
  153. package/dist/src/lib/phase-diagram/utils.ts +775 -0
  154. package/dist/src/lib/plot/AxisLabel.svelte +51 -0
  155. package/dist/src/lib/plot/BarPlot.svelte +2113 -0
  156. package/dist/src/lib/plot/BarPlotControls.svelte +66 -0
  157. package/dist/src/lib/plot/BinnedScatterPlot.svelte +1114 -0
  158. package/dist/src/lib/plot/ColorBar.svelte +721 -0
  159. package/dist/src/lib/plot/ColorScaleSelect.svelte +54 -0
  160. package/dist/src/lib/plot/ElementScatter.svelte +63 -0
  161. package/dist/src/lib/plot/FillArea.svelte +223 -0
  162. package/dist/src/lib/plot/Histogram.svelte +1558 -0
  163. package/dist/src/lib/plot/HistogramControls.svelte +212 -0
  164. package/dist/src/lib/plot/InteractiveAxisLabel.svelte +96 -0
  165. package/dist/src/lib/plot/Line.svelte +84 -0
  166. package/dist/src/lib/plot/PlotAxis.svelte +169 -0
  167. package/dist/src/lib/plot/PlotControls.svelte +537 -0
  168. package/dist/src/lib/plot/PlotLegend.svelte +569 -0
  169. package/dist/src/lib/plot/PlotTooltip.svelte +67 -0
  170. package/dist/src/lib/plot/PortalSelect.svelte +253 -0
  171. package/dist/src/lib/plot/ReferenceLine3D.svelte +156 -0
  172. package/dist/src/lib/plot/ReferencePlane.svelte +175 -0
  173. package/dist/src/lib/plot/ScatterPlot.svelte +2778 -0
  174. package/dist/src/lib/plot/ScatterPlot3D.svelte +529 -0
  175. package/dist/src/lib/plot/ScatterPlot3DControls.svelte +437 -0
  176. package/dist/src/lib/plot/ScatterPlot3DScene.svelte +912 -0
  177. package/dist/src/lib/plot/ScatterPlotControls.svelte +306 -0
  178. package/dist/src/lib/plot/ScatterPoint.svelte +182 -0
  179. package/dist/src/lib/plot/SpacegroupBarPlot.svelte +293 -0
  180. package/dist/src/lib/plot/Surface3D.svelte +197 -0
  181. package/dist/src/lib/plot/ZeroLines.svelte +97 -0
  182. package/dist/src/lib/plot/ZoomRect.svelte +23 -0
  183. package/dist/src/lib/plot/adaptive-density.ts +316 -0
  184. package/dist/src/lib/plot/auto-place.ts +184 -0
  185. package/dist/src/lib/plot/axis-utils.ts +122 -0
  186. package/dist/src/lib/plot/binned-scatter-types.ts +83 -0
  187. package/dist/src/lib/plot/data-cleaning.ts +1069 -0
  188. package/dist/src/lib/plot/data-transform.ts +69 -0
  189. package/dist/src/lib/plot/defaults.ts +9 -0
  190. package/dist/src/lib/plot/fill-utils.ts +494 -0
  191. package/dist/src/lib/plot/hover-lock.svelte.ts +60 -0
  192. package/dist/src/lib/plot/index.ts +53 -0
  193. package/dist/src/lib/plot/interactions.ts +119 -0
  194. package/dist/src/lib/plot/layout.ts +425 -0
  195. package/dist/src/lib/plot/reference-line.ts +426 -0
  196. package/dist/src/lib/plot/scales.ts +654 -0
  197. package/dist/src/lib/plot/svg.ts +23 -0
  198. package/dist/src/lib/plot/types.ts +1144 -0
  199. package/dist/src/lib/plot/utils/label-placement.ts +541 -0
  200. package/dist/src/lib/plot/utils/series-visibility.ts +140 -0
  201. package/dist/src/lib/plot/utils.ts +11 -0
  202. package/dist/src/lib/rdf/RdfPlot.svelte +247 -0
  203. package/dist/src/lib/rdf/calc-rdf.ts +167 -0
  204. package/dist/src/lib/rdf/index.ts +27 -0
  205. package/dist/src/lib/sanitize.ts +126 -0
  206. package/dist/src/lib/settings.ts +1479 -0
  207. package/dist/src/lib/spectral/Bands.svelte +1040 -0
  208. package/dist/src/lib/spectral/BandsAndDos.svelte +134 -0
  209. package/dist/src/lib/spectral/BrillouinBandsDos.svelte +252 -0
  210. package/dist/src/lib/spectral/Dos.svelte +697 -0
  211. package/dist/src/lib/spectral/helpers.ts +1381 -0
  212. package/dist/src/lib/spectral/index.ts +8 -0
  213. package/dist/src/lib/spectral/types.ts +112 -0
  214. package/dist/src/lib/state.svelte.ts +64 -0
  215. package/dist/src/lib/structure/Arrow.svelte +72 -0
  216. package/dist/src/lib/structure/AtomLegend.svelte +815 -0
  217. package/dist/src/lib/structure/Bond.svelte +140 -0
  218. package/dist/src/lib/structure/CanvasTooltip.svelte +33 -0
  219. package/dist/src/lib/structure/CellSelect.svelte +349 -0
  220. package/dist/src/lib/structure/Cylinder.svelte +45 -0
  221. package/dist/src/lib/structure/Lattice.svelte +196 -0
  222. package/dist/src/lib/structure/Structure.svelte +2248 -0
  223. package/dist/src/lib/structure/StructureControls.svelte +1273 -0
  224. package/dist/src/lib/structure/StructureExportPane.svelte +252 -0
  225. package/dist/src/lib/structure/StructureInfoPane.svelte +737 -0
  226. package/dist/src/lib/structure/StructureScene.svelte +2255 -0
  227. package/dist/src/lib/structure/atom-properties.ts +316 -0
  228. package/dist/src/lib/structure/bond-order-perception.ts +447 -0
  229. package/dist/src/lib/structure/bonding.ts +944 -0
  230. package/dist/src/lib/structure/export.ts +861 -0
  231. package/dist/src/lib/structure/index.ts +291 -0
  232. package/dist/src/lib/structure/label-placement.ts +130 -0
  233. package/dist/src/lib/structure/measure.ts +45 -0
  234. package/dist/src/lib/structure/parse.ts +1705 -0
  235. package/dist/src/lib/structure/partial-occupancy.ts +183 -0
  236. package/dist/src/lib/structure/pbc.ts +164 -0
  237. package/dist/src/lib/structure/supercell.ts +226 -0
  238. package/dist/src/lib/structure/validation.ts +11 -0
  239. package/dist/src/lib/symmetry/SymmetryStats.svelte +226 -0
  240. package/dist/src/lib/symmetry/WyckoffTable.svelte +120 -0
  241. package/dist/src/lib/symmetry/cell-transform.ts +118 -0
  242. package/dist/src/lib/symmetry/index.ts +348 -0
  243. package/dist/src/lib/symmetry/spacegroups.ts +404 -0
  244. package/dist/src/lib/table/HeatmapTable.svelte +1833 -0
  245. package/dist/src/lib/table/ToggleMenu.svelte +385 -0
  246. package/dist/src/lib/table/index.ts +139 -0
  247. package/dist/src/lib/theme/ThemeControl.svelte +53 -0
  248. package/dist/src/lib/theme/index.ts +107 -0
  249. package/dist/src/lib/theme/themes.mjs +297 -0
  250. package/dist/src/lib/time.ts +71 -0
  251. package/dist/src/lib/tooltip/TooltipContent.svelte +58 -0
  252. package/dist/src/lib/tooltip/index.ts +2 -0
  253. package/dist/src/lib/tooltip/types.ts +13 -0
  254. package/dist/src/lib/trajectory/Trajectory.svelte +1545 -0
  255. package/dist/src/lib/trajectory/TrajectoryError.svelte +128 -0
  256. package/dist/src/lib/trajectory/TrajectoryExportPane.svelte +357 -0
  257. package/dist/src/lib/trajectory/TrajectoryInfoPane.svelte +313 -0
  258. package/dist/src/lib/trajectory/constants.ts +7 -0
  259. package/dist/src/lib/trajectory/extract.ts +196 -0
  260. package/dist/src/lib/trajectory/format-detect.ts +96 -0
  261. package/dist/src/lib/trajectory/frame-reader.ts +456 -0
  262. package/dist/src/lib/trajectory/helpers.ts +217 -0
  263. package/dist/src/lib/trajectory/index.ts +218 -0
  264. package/dist/src/lib/trajectory/parse/ase.ts +109 -0
  265. package/dist/src/lib/trajectory/parse/hdf5.ts +173 -0
  266. package/dist/src/lib/trajectory/parse/index.ts +411 -0
  267. package/dist/src/lib/trajectory/parse/lammps.ts +215 -0
  268. package/dist/src/lib/trajectory/parse/vasp.ts +102 -0
  269. package/dist/src/lib/trajectory/parse/xyz.ts +143 -0
  270. package/dist/src/lib/trajectory/plotting.ts +599 -0
  271. package/dist/src/lib/trajectory/types.ts +13 -0
  272. package/dist/src/lib/utils.ts +56 -0
  273. package/dist/src/lib/xrd/XrdPlot.svelte +615 -0
  274. package/dist/src/lib/xrd/broadening.ts +130 -0
  275. package/dist/src/lib/xrd/calc-xrd.ts +397 -0
  276. package/dist/src/lib/xrd/index.ts +38 -0
  277. package/dist/src/lib/xrd/parse.ts +858 -0
  278. package/dist/webview.js +29421 -0
  279. package/icon.png +0 -0
  280. package/license +1 -1
  281. package/matterviz-0.3.2.vsix +0 -0
  282. package/matterviz-0.3.4.vsix +0 -0
  283. package/matterviz-0.3.5.vsix +0 -0
  284. package/package.json +1461 -231
  285. package/readme.md +171 -98
  286. package/scripts/sync-config.ts +101 -0
  287. package/src/declarations.d.ts +2 -0
  288. package/src/extension.ts +972 -0
  289. package/src/node-io.ts +65 -0
  290. package/src/types.ts +17 -0
  291. package/src/webview/JsonBrowser.svelte +1079 -0
  292. package/src/webview/PlotPanel.svelte +346 -0
  293. package/src/webview/detect.ts +444 -0
  294. package/src/webview/main.ts +764 -0
  295. package/src/webview/plot-utils.ts +250 -0
  296. package/test-fixtures/all-viz-types.json.gz +0 -0
  297. package/test-fixtures/plot-demo-data.json.gz +0 -0
  298. package/tests/detect.test.ts +604 -0
  299. package/tests/extension.test.ts +2041 -0
  300. package/tests/node-io.test.ts +39 -0
  301. package/tests/plot-utils.test.ts +302 -0
  302. package/tests/vite-plugin-json-gz.test.ts +114 -0
  303. package/tests/vscode-mock.ts +18 -0
  304. package/tests/webview.test.ts +231 -0
  305. package/tsconfig.json +20 -0
  306. package/vite-plugin-json-gz.ts +29 -0
  307. package/vite.config.ts +34 -0
  308. package/vite.extension.config.ts +34 -0
  309. package/dist/EmptyState.svelte.d.ts +0 -9
  310. package/dist/FilePicker.svelte +0 -360
  311. package/dist/FilePicker.svelte.d.ts +0 -17
  312. package/dist/Icon.svelte.d.ts +0 -13
  313. package/dist/MillerIndexInput.svelte +0 -66
  314. package/dist/MillerIndexInput.svelte.d.ts +0 -7
  315. package/dist/api/mp.d.ts +0 -6
  316. package/dist/api/mp.js +0 -22
  317. package/dist/api/optimade.d.ts +0 -45
  318. package/dist/api/optimade.js +0 -135
  319. package/dist/app.css +0 -240
  320. package/dist/brillouin/BrillouinZone.svelte +0 -543
  321. package/dist/brillouin/BrillouinZone.svelte.d.ts +0 -83
  322. package/dist/brillouin/BrillouinZoneControls.svelte +0 -144
  323. package/dist/brillouin/BrillouinZoneControls.svelte.d.ts +0 -17
  324. package/dist/brillouin/BrillouinZoneExportPane.svelte +0 -148
  325. package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +0 -15
  326. package/dist/brillouin/BrillouinZoneInfoPane.svelte +0 -146
  327. package/dist/brillouin/BrillouinZoneInfoPane.svelte.d.ts +0 -13
  328. package/dist/brillouin/BrillouinZoneScene.svelte +0 -476
  329. package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +0 -48
  330. package/dist/brillouin/BrillouinZoneTooltip.svelte +0 -92
  331. package/dist/brillouin/BrillouinZoneTooltip.svelte.d.ts +0 -8
  332. package/dist/brillouin/compute.d.ts +0 -17
  333. package/dist/brillouin/compute.js +0 -422
  334. package/dist/brillouin/index.d.ts +0 -8
  335. package/dist/brillouin/index.js +0 -8
  336. package/dist/brillouin/types.d.ts +0 -48
  337. package/dist/brillouin/types.js +0 -1
  338. package/dist/chempot-diagram/ChemPotDiagram.svelte +0 -327
  339. package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +0 -13
  340. package/dist/chempot-diagram/ChemPotDiagram2D.svelte +0 -847
  341. package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +0 -16
  342. package/dist/chempot-diagram/ChemPotDiagram3D.svelte +0 -3194
  343. package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +0 -16
  344. package/dist/chempot-diagram/ChemPotScene3D.svelte.d.ts +0 -7
  345. package/dist/chempot-diagram/async-compute.svelte.d.ts +0 -3
  346. package/dist/chempot-diagram/async-compute.svelte.js +0 -77
  347. package/dist/chempot-diagram/chempot-worker.d.ts +0 -1
  348. package/dist/chempot-diagram/chempot-worker.js +0 -11
  349. package/dist/chempot-diagram/color.d.ts +0 -10
  350. package/dist/chempot-diagram/color.js +0 -32
  351. package/dist/chempot-diagram/compute.d.ts +0 -48
  352. package/dist/chempot-diagram/compute.js +0 -812
  353. package/dist/chempot-diagram/index.d.ts +0 -6
  354. package/dist/chempot-diagram/index.js +0 -6
  355. package/dist/chempot-diagram/pointer.d.ts +0 -16
  356. package/dist/chempot-diagram/pointer.js +0 -40
  357. package/dist/chempot-diagram/temperature.d.ts +0 -15
  358. package/dist/chempot-diagram/temperature.js +0 -36
  359. package/dist/chempot-diagram/types.d.ts +0 -86
  360. package/dist/chempot-diagram/types.js +0 -28
  361. package/dist/colors/index.d.ts +0 -47
  362. package/dist/colors/index.js +0 -203
  363. package/dist/composition/BarChart.svelte +0 -297
  364. package/dist/composition/BarChart.svelte.d.ts +0 -39
  365. package/dist/composition/BubbleChart.svelte +0 -218
  366. package/dist/composition/BubbleChart.svelte.d.ts +0 -28
  367. package/dist/composition/Composition.svelte +0 -164
  368. package/dist/composition/Composition.svelte.d.ts +0 -15
  369. package/dist/composition/Formula.svelte +0 -265
  370. package/dist/composition/Formula.svelte.d.ts +0 -19
  371. package/dist/composition/FormulaFilter.svelte +0 -1259
  372. package/dist/composition/FormulaFilter.svelte.d.ts +0 -51
  373. package/dist/composition/PieChart.svelte +0 -323
  374. package/dist/composition/PieChart.svelte.d.ts +0 -37
  375. package/dist/composition/format.d.ts +0 -15
  376. package/dist/composition/format.js +0 -109
  377. package/dist/composition/index.d.ts +0 -20
  378. package/dist/composition/index.js +0 -14
  379. package/dist/composition/parse.d.ts +0 -55
  380. package/dist/composition/parse.js +0 -459
  381. package/dist/constants.d.ts +0 -29
  382. package/dist/constants.js +0 -105
  383. package/dist/controls.d.ts +0 -14
  384. package/dist/controls.js +0 -30
  385. package/dist/convex-hull/ConvexHull.svelte +0 -157
  386. package/dist/convex-hull/ConvexHull.svelte.d.ts +0 -13
  387. package/dist/convex-hull/ConvexHull2D.svelte +0 -813
  388. package/dist/convex-hull/ConvexHull2D.svelte.d.ts +0 -11
  389. package/dist/convex-hull/ConvexHull3D.svelte +0 -1788
  390. package/dist/convex-hull/ConvexHull3D.svelte.d.ts +0 -8
  391. package/dist/convex-hull/ConvexHull4D.svelte +0 -1374
  392. package/dist/convex-hull/ConvexHull4D.svelte.d.ts +0 -8
  393. package/dist/convex-hull/ConvexHullControls.svelte +0 -546
  394. package/dist/convex-hull/ConvexHullControls.svelte.d.ts +0 -48
  395. package/dist/convex-hull/ConvexHullInfoPane.svelte +0 -115
  396. package/dist/convex-hull/ConvexHullInfoPane.svelte.d.ts +0 -18
  397. package/dist/convex-hull/ConvexHullStats.svelte +0 -905
  398. package/dist/convex-hull/ConvexHullStats.svelte.d.ts +0 -15
  399. package/dist/convex-hull/ConvexHullTooltip.svelte +0 -131
  400. package/dist/convex-hull/ConvexHullTooltip.svelte.d.ts +0 -33
  401. package/dist/convex-hull/GasPressureControls.svelte +0 -247
  402. package/dist/convex-hull/GasPressureControls.svelte.d.ts +0 -11
  403. package/dist/convex-hull/StructurePopup.svelte +0 -116
  404. package/dist/convex-hull/StructurePopup.svelte.d.ts +0 -18
  405. package/dist/convex-hull/TemperatureSlider.svelte +0 -137
  406. package/dist/convex-hull/TemperatureSlider.svelte.d.ts +0 -8
  407. package/dist/convex-hull/barycentric-coords.d.ts +0 -18
  408. package/dist/convex-hull/barycentric-coords.js +0 -182
  409. package/dist/convex-hull/demo-temperature.d.ts +0 -6
  410. package/dist/convex-hull/demo-temperature.js +0 -40
  411. package/dist/convex-hull/gas-thermodynamics.d.ts +0 -16
  412. package/dist/convex-hull/gas-thermodynamics.js +0 -316
  413. package/dist/convex-hull/helpers.d.ts +0 -103
  414. package/dist/convex-hull/helpers.js +0 -671
  415. package/dist/convex-hull/index.d.ts +0 -118
  416. package/dist/convex-hull/index.js +0 -57
  417. package/dist/convex-hull/thermodynamics.d.ts +0 -66
  418. package/dist/convex-hull/thermodynamics.js +0 -1752
  419. package/dist/convex-hull/types.d.ts +0 -162
  420. package/dist/convex-hull/types.js +0 -36
  421. package/dist/coordination/CoordinationBarPlot.svelte +0 -311
  422. package/dist/coordination/CoordinationBarPlot.svelte.d.ts +0 -30
  423. package/dist/coordination/calc-coordination.d.ts +0 -15
  424. package/dist/coordination/calc-coordination.js +0 -63
  425. package/dist/coordination/index.d.ts +0 -8
  426. package/dist/coordination/index.js +0 -7
  427. package/dist/element/BohrAtom.svelte +0 -149
  428. package/dist/element/BohrAtom.svelte.d.ts +0 -20
  429. package/dist/element/ElementHeading.svelte +0 -26
  430. package/dist/element/ElementHeading.svelte.d.ts +0 -8
  431. package/dist/element/ElementPhoto.svelte +0 -57
  432. package/dist/element/ElementPhoto.svelte.d.ts +0 -9
  433. package/dist/element/ElementStats.svelte +0 -80
  434. package/dist/element/ElementStats.svelte.d.ts +0 -8
  435. package/dist/element/ElementTile.svelte +0 -484
  436. package/dist/element/ElementTile.svelte.d.ts +0 -29
  437. package/dist/element/Nucleus.svelte.d.ts +0 -17
  438. package/dist/element/data.d.ts +0 -3
  439. package/dist/element/data.js +0 -2
  440. package/dist/element/data.json.gz.d.ts +0 -2
  441. package/dist/element/index.d.ts +0 -8
  442. package/dist/element/index.js +0 -8
  443. package/dist/element/types.d.ts +0 -57
  444. package/dist/element/types.js +0 -1
  445. package/dist/feedback/ClickFeedback.svelte +0 -58
  446. package/dist/feedback/ClickFeedback.svelte.d.ts +0 -12
  447. package/dist/feedback/DragOverlay.svelte +0 -42
  448. package/dist/feedback/DragOverlay.svelte.d.ts +0 -7
  449. package/dist/feedback/Spinner.svelte.d.ts +0 -7
  450. package/dist/feedback/StatusMessage.svelte.d.ts +0 -9
  451. package/dist/feedback/index.d.ts +0 -4
  452. package/dist/feedback/index.js +0 -4
  453. package/dist/fermi-surface/FermiSlice.svelte +0 -189
  454. package/dist/fermi-surface/FermiSlice.svelte.d.ts +0 -24
  455. package/dist/fermi-surface/FermiSurface.svelte +0 -597
  456. package/dist/fermi-surface/FermiSurface.svelte.d.ts +0 -83
  457. package/dist/fermi-surface/FermiSurfaceControls.svelte +0 -452
  458. package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +0 -35
  459. package/dist/fermi-surface/FermiSurfaceScene.svelte +0 -792
  460. package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +0 -50
  461. package/dist/fermi-surface/FermiSurfaceTooltip.svelte +0 -111
  462. package/dist/fermi-surface/FermiSurfaceTooltip.svelte.d.ts +0 -8
  463. package/dist/fermi-surface/compute.d.ts +0 -5
  464. package/dist/fermi-surface/compute.js +0 -538
  465. package/dist/fermi-surface/constants.d.ts +0 -9
  466. package/dist/fermi-surface/constants.js +0 -27
  467. package/dist/fermi-surface/export.d.ts +0 -5
  468. package/dist/fermi-surface/export.js +0 -63
  469. package/dist/fermi-surface/index.d.ts +0 -12
  470. package/dist/fermi-surface/index.js +0 -13
  471. package/dist/fermi-surface/marching-cubes.d.ts +0 -2
  472. package/dist/fermi-surface/marching-cubes.js +0 -2
  473. package/dist/fermi-surface/parse.d.ts +0 -2
  474. package/dist/fermi-surface/parse.js +0 -495
  475. package/dist/fermi-surface/symmetry.d.ts +0 -3
  476. package/dist/fermi-surface/symmetry.js +0 -46
  477. package/dist/fermi-surface/types.d.ts +0 -113
  478. package/dist/fermi-surface/types.js +0 -4
  479. package/dist/heatmap-matrix/HeatmapMatrix.svelte +0 -1527
  480. package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +0 -110
  481. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +0 -225
  482. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +0 -30
  483. package/dist/heatmap-matrix/index.d.ts +0 -53
  484. package/dist/heatmap-matrix/index.js +0 -100
  485. package/dist/heatmap-matrix/shared.d.ts +0 -2
  486. package/dist/heatmap-matrix/shared.js +0 -4
  487. package/dist/icons.d.ts +0 -569
  488. package/dist/icons.js +0 -648
  489. package/dist/index.d.ts +0 -39
  490. package/dist/index.js +0 -39
  491. package/dist/io/decompress.d.ts +0 -10
  492. package/dist/io/decompress.js +0 -69
  493. package/dist/io/export.d.ts +0 -16
  494. package/dist/io/export.js +0 -312
  495. package/dist/io/fetch.d.ts +0 -5
  496. package/dist/io/fetch.js +0 -39
  497. package/dist/io/file-drop.d.ts +0 -7
  498. package/dist/io/file-drop.js +0 -43
  499. package/dist/io/index.d.ts +0 -7
  500. package/dist/io/index.js +0 -7
  501. package/dist/io/is-binary.d.ts +0 -1
  502. package/dist/io/is-binary.js +0 -5
  503. package/dist/io/types.d.ts +0 -8
  504. package/dist/io/types.js +0 -1
  505. package/dist/io/url-drop.d.ts +0 -2
  506. package/dist/io/url-drop.js +0 -117
  507. package/dist/isosurface/Isosurface.svelte +0 -285
  508. package/dist/isosurface/Isosurface.svelte.d.ts +0 -8
  509. package/dist/isosurface/IsosurfaceControls.svelte +0 -291
  510. package/dist/isosurface/IsosurfaceControls.svelte.d.ts +0 -9
  511. package/dist/isosurface/index.d.ts +0 -5
  512. package/dist/isosurface/index.js +0 -6
  513. package/dist/isosurface/parse.d.ts +0 -6
  514. package/dist/isosurface/parse.js +0 -553
  515. package/dist/isosurface/slice.d.ts +0 -11
  516. package/dist/isosurface/slice.js +0 -140
  517. package/dist/isosurface/types.d.ts +0 -56
  518. package/dist/isosurface/types.js +0 -227
  519. package/dist/labels.d.ts +0 -53
  520. package/dist/labels.js +0 -274
  521. package/dist/layout/FullscreenToggle.svelte +0 -50
  522. package/dist/layout/FullscreenToggle.svelte.d.ts +0 -7
  523. package/dist/layout/InfoCard.svelte +0 -120
  524. package/dist/layout/InfoCard.svelte.d.ts +0 -21
  525. package/dist/layout/InfoTag.svelte +0 -183
  526. package/dist/layout/InfoTag.svelte.d.ts +0 -19
  527. package/dist/layout/PropertyFilter.svelte +0 -244
  528. package/dist/layout/PropertyFilter.svelte.d.ts +0 -24
  529. package/dist/layout/SettingsSection.svelte +0 -148
  530. package/dist/layout/SettingsSection.svelte.d.ts +0 -17
  531. package/dist/layout/SubpageGrid.svelte +0 -82
  532. package/dist/layout/SubpageGrid.svelte.d.ts +0 -14
  533. package/dist/layout/fullscreen.d.ts +0 -9
  534. package/dist/layout/fullscreen.js +0 -53
  535. package/dist/layout/index.d.ts +0 -10
  536. package/dist/layout/index.js +0 -8
  537. package/dist/layout/json-tree/JsonNode.svelte +0 -547
  538. package/dist/layout/json-tree/JsonNode.svelte.d.ts +0 -11
  539. package/dist/layout/json-tree/JsonTree.svelte +0 -1222
  540. package/dist/layout/json-tree/JsonTree.svelte.d.ts +0 -6
  541. package/dist/layout/json-tree/JsonValue.svelte +0 -334
  542. package/dist/layout/json-tree/JsonValue.svelte.d.ts +0 -9
  543. package/dist/layout/json-tree/index.d.ts +0 -3
  544. package/dist/layout/json-tree/index.js +0 -3
  545. package/dist/layout/json-tree/types.d.ts +0 -73
  546. package/dist/layout/json-tree/types.js +0 -3
  547. package/dist/layout/json-tree/utils.d.ts +0 -29
  548. package/dist/layout/json-tree/utils.js +0 -648
  549. package/dist/marching-cubes.d.ts +0 -14
  550. package/dist/marching-cubes.js +0 -542
  551. package/dist/math.d.ts +0 -91
  552. package/dist/math.js +0 -896
  553. package/dist/overlays/ContextMenu.svelte +0 -162
  554. package/dist/overlays/ContextMenu.svelte.d.ts +0 -25
  555. package/dist/overlays/DraggablePane.svelte +0 -564
  556. package/dist/overlays/DraggablePane.svelte.d.ts +0 -36
  557. package/dist/overlays/index.d.ts +0 -2
  558. package/dist/overlays/index.js +0 -2
  559. package/dist/periodic-table/PeriodicTable.svelte +0 -469
  560. package/dist/periodic-table/PeriodicTable.svelte.d.ts +0 -55
  561. package/dist/periodic-table/PeriodicTableControls.svelte +0 -557
  562. package/dist/periodic-table/PeriodicTableControls.svelte.d.ts +0 -24
  563. package/dist/periodic-table/PropertySelect.svelte +0 -37
  564. package/dist/periodic-table/PropertySelect.svelte.d.ts +0 -13
  565. package/dist/periodic-table/TableInset.svelte.d.ts +0 -9
  566. package/dist/periodic-table/index.d.ts +0 -10
  567. package/dist/periodic-table/index.js +0 -4
  568. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +0 -1086
  569. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +0 -44
  570. package/dist/phase-diagram/PhaseDiagramControls.svelte +0 -451
  571. package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +0 -30
  572. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +0 -126
  573. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +0 -15
  574. package/dist/phase-diagram/PhaseDiagramExportPane.svelte +0 -192
  575. package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +0 -19
  576. package/dist/phase-diagram/PhaseDiagramTooltip.svelte +0 -392
  577. package/dist/phase-diagram/PhaseDiagramTooltip.svelte.d.ts +0 -16
  578. package/dist/phase-diagram/TdbInfoPanel.svelte +0 -203
  579. package/dist/phase-diagram/TdbInfoPanel.svelte.d.ts +0 -12
  580. package/dist/phase-diagram/build-diagram.d.ts +0 -11
  581. package/dist/phase-diagram/build-diagram.js +0 -167
  582. package/dist/phase-diagram/colors.d.ts +0 -35
  583. package/dist/phase-diagram/colors.js +0 -51
  584. package/dist/phase-diagram/diagram-input.d.ts +0 -33
  585. package/dist/phase-diagram/diagram-input.js +0 -3
  586. package/dist/phase-diagram/index.d.ts +0 -13
  587. package/dist/phase-diagram/index.js +0 -13
  588. package/dist/phase-diagram/parse.d.ts +0 -55
  589. package/dist/phase-diagram/parse.js +0 -276
  590. package/dist/phase-diagram/svg-to-diagram.d.ts +0 -2
  591. package/dist/phase-diagram/svg-to-diagram.js +0 -869
  592. package/dist/phase-diagram/types.d.ts +0 -99
  593. package/dist/phase-diagram/types.js +0 -1
  594. package/dist/phase-diagram/utils.d.ts +0 -118
  595. package/dist/phase-diagram/utils.js +0 -606
  596. package/dist/plot/AxisLabel.svelte +0 -51
  597. package/dist/plot/AxisLabel.svelte.d.ts +0 -16
  598. package/dist/plot/BarPlot.svelte +0 -2256
  599. package/dist/plot/BarPlot.svelte.d.ts +0 -82
  600. package/dist/plot/BarPlotControls.svelte +0 -66
  601. package/dist/plot/BarPlotControls.svelte.d.ts +0 -18
  602. package/dist/plot/ColorBar.svelte +0 -719
  603. package/dist/plot/ColorBar.svelte.d.ts +0 -31
  604. package/dist/plot/ColorScaleSelect.svelte +0 -54
  605. package/dist/plot/ColorScaleSelect.svelte.d.ts +0 -15
  606. package/dist/plot/ElementScatter.svelte +0 -63
  607. package/dist/plot/ElementScatter.svelte.d.ts +0 -14
  608. package/dist/plot/FillArea.svelte +0 -226
  609. package/dist/plot/FillArea.svelte.d.ts +0 -20
  610. package/dist/plot/Histogram.svelte +0 -1654
  611. package/dist/plot/Histogram.svelte.d.ts +0 -50
  612. package/dist/plot/HistogramControls.svelte +0 -212
  613. package/dist/plot/HistogramControls.svelte.d.ts +0 -22
  614. package/dist/plot/InteractiveAxisLabel.svelte +0 -94
  615. package/dist/plot/InteractiveAxisLabel.svelte.d.ts +0 -14
  616. package/dist/plot/Line.svelte +0 -85
  617. package/dist/plot/Line.svelte.d.ts +0 -15
  618. package/dist/plot/PlotControls.svelte +0 -537
  619. package/dist/plot/PlotControls.svelte.d.ts +0 -4
  620. package/dist/plot/PlotLegend.svelte +0 -498
  621. package/dist/plot/PlotLegend.svelte.d.ts +0 -25
  622. package/dist/plot/PlotTooltip.svelte +0 -67
  623. package/dist/plot/PlotTooltip.svelte.d.ts +0 -17
  624. package/dist/plot/PortalSelect.svelte +0 -253
  625. package/dist/plot/PortalSelect.svelte.d.ts +0 -16
  626. package/dist/plot/ReferenceLine.svelte.d.ts +0 -20
  627. package/dist/plot/ReferenceLine3D.svelte +0 -154
  628. package/dist/plot/ReferenceLine3D.svelte.d.ts +0 -14
  629. package/dist/plot/ReferencePlane.svelte +0 -178
  630. package/dist/plot/ReferencePlane.svelte.d.ts +0 -14
  631. package/dist/plot/ScatterPlot.svelte +0 -2831
  632. package/dist/plot/ScatterPlot.svelte.d.ts +0 -92
  633. package/dist/plot/ScatterPlot3D.svelte +0 -499
  634. package/dist/plot/ScatterPlot3D.svelte.d.ts +0 -94
  635. package/dist/plot/ScatterPlot3DControls.svelte +0 -437
  636. package/dist/plot/ScatterPlot3DControls.svelte.d.ts +0 -20
  637. package/dist/plot/ScatterPlot3DScene.svelte +0 -912
  638. package/dist/plot/ScatterPlot3DScene.svelte.d.ts +0 -74
  639. package/dist/plot/ScatterPlotControls.svelte +0 -307
  640. package/dist/plot/ScatterPlotControls.svelte.d.ts +0 -17
  641. package/dist/plot/ScatterPoint.svelte +0 -185
  642. package/dist/plot/ScatterPoint.svelte.d.ts +0 -19
  643. package/dist/plot/SpacegroupBarPlot.svelte +0 -292
  644. package/dist/plot/SpacegroupBarPlot.svelte.d.ts +0 -9
  645. package/dist/plot/Surface3D.svelte +0 -200
  646. package/dist/plot/Surface3D.svelte.d.ts +0 -13
  647. package/dist/plot/ZeroLines.svelte +0 -96
  648. package/dist/plot/ZeroLines.svelte.d.ts +0 -32
  649. package/dist/plot/ZoomRect.svelte +0 -23
  650. package/dist/plot/ZoomRect.svelte.d.ts +0 -8
  651. package/dist/plot/axis-utils.d.ts +0 -19
  652. package/dist/plot/axis-utils.js +0 -80
  653. package/dist/plot/data-cleaning.d.ts +0 -37
  654. package/dist/plot/data-cleaning.js +0 -855
  655. package/dist/plot/data-transform.d.ts +0 -16
  656. package/dist/plot/data-transform.js +0 -45
  657. package/dist/plot/defaults.d.ts +0 -19
  658. package/dist/plot/defaults.js +0 -9
  659. package/dist/plot/fill-utils.d.ts +0 -51
  660. package/dist/plot/fill-utils.js +0 -337
  661. package/dist/plot/hover-lock.svelte.d.ts +0 -14
  662. package/dist/plot/hover-lock.svelte.js +0 -46
  663. package/dist/plot/index.d.ts +0 -43
  664. package/dist/plot/index.js +0 -37
  665. package/dist/plot/interactions.d.ts +0 -12
  666. package/dist/plot/interactions.js +0 -100
  667. package/dist/plot/layout.d.ts +0 -60
  668. package/dist/plot/layout.js +0 -230
  669. package/dist/plot/reference-line.d.ts +0 -60
  670. package/dist/plot/reference-line.js +0 -316
  671. package/dist/plot/scales.d.ts +0 -48
  672. package/dist/plot/scales.js +0 -484
  673. package/dist/plot/svg.d.ts +0 -1
  674. package/dist/plot/svg.js +0 -11
  675. package/dist/plot/types.d.ts +0 -863
  676. package/dist/plot/types.js +0 -103
  677. package/dist/plot/utils/label-placement.d.ts +0 -47
  678. package/dist/plot/utils/label-placement.js +0 -256
  679. package/dist/plot/utils/series-visibility.d.ts +0 -9
  680. package/dist/plot/utils/series-visibility.js +0 -67
  681. package/dist/plot/utils.d.ts +0 -1
  682. package/dist/plot/utils.js +0 -14
  683. package/dist/rdf/RdfPlot.svelte +0 -247
  684. package/dist/rdf/RdfPlot.svelte.d.ts +0 -27
  685. package/dist/rdf/calc-rdf.d.ts +0 -4
  686. package/dist/rdf/calc-rdf.js +0 -111
  687. package/dist/rdf/index.d.ts +0 -23
  688. package/dist/rdf/index.js +0 -2
  689. package/dist/sanitize.d.ts +0 -4
  690. package/dist/sanitize.js +0 -107
  691. package/dist/settings.d.ts +0 -253
  692. package/dist/settings.js +0 -1123
  693. package/dist/spectral/Bands.svelte +0 -1040
  694. package/dist/spectral/Bands.svelte.d.ts +0 -40
  695. package/dist/spectral/BandsAndDos.svelte +0 -128
  696. package/dist/spectral/BandsAndDos.svelte.d.ts +0 -18
  697. package/dist/spectral/BrillouinBandsDos.svelte +0 -248
  698. package/dist/spectral/BrillouinBandsDos.svelte.d.ts +0 -20
  699. package/dist/spectral/Dos.svelte +0 -697
  700. package/dist/spectral/Dos.svelte.d.ts +0 -29
  701. package/dist/spectral/helpers.d.ts +0 -117
  702. package/dist/spectral/helpers.js +0 -1023
  703. package/dist/spectral/index.d.ts +0 -6
  704. package/dist/spectral/index.js +0 -7
  705. package/dist/spectral/types.d.ts +0 -84
  706. package/dist/spectral/types.js +0 -2
  707. package/dist/state.svelte.d.ts +0 -25
  708. package/dist/state.svelte.js +0 -45
  709. package/dist/structure/Arrow.svelte +0 -72
  710. package/dist/structure/Arrow.svelte.d.ts +0 -15
  711. package/dist/structure/AtomLegend.svelte +0 -798
  712. package/dist/structure/AtomLegend.svelte.d.ts +0 -34
  713. package/dist/structure/Bond.svelte +0 -140
  714. package/dist/structure/Bond.svelte.d.ts +0 -9
  715. package/dist/structure/CanvasTooltip.svelte +0 -33
  716. package/dist/structure/CanvasTooltip.svelte.d.ts +0 -12
  717. package/dist/structure/CellSelect.svelte +0 -351
  718. package/dist/structure/CellSelect.svelte.d.ts +0 -13
  719. package/dist/structure/Cylinder.svelte +0 -45
  720. package/dist/structure/Cylinder.svelte.d.ts +0 -10
  721. package/dist/structure/Lattice.svelte +0 -196
  722. package/dist/structure/Lattice.svelte.d.ts +0 -17
  723. package/dist/structure/Structure.svelte +0 -1857
  724. package/dist/structure/Structure.svelte.d.ts +0 -83
  725. package/dist/structure/StructureControls.svelte +0 -1184
  726. package/dist/structure/StructureControls.svelte.d.ts +0 -31
  727. package/dist/structure/StructureExportPane.svelte +0 -251
  728. package/dist/structure/StructureExportPane.svelte.d.ts +0 -17
  729. package/dist/structure/StructureInfoPane.svelte +0 -434
  730. package/dist/structure/StructureInfoPane.svelte.d.ts +0 -18
  731. package/dist/structure/StructureScene.svelte +0 -1574
  732. package/dist/structure/StructureScene.svelte.d.ts +0 -104
  733. package/dist/structure/atom-properties.d.ts +0 -37
  734. package/dist/structure/atom-properties.js +0 -198
  735. package/dist/structure/bonding.d.ts +0 -33
  736. package/dist/structure/bonding.js +0 -304
  737. package/dist/structure/export.d.ts +0 -20
  738. package/dist/structure/export.js +0 -725
  739. package/dist/structure/ferrox-wasm-types.d.ts +0 -46
  740. package/dist/structure/ferrox-wasm-types.js +0 -18
  741. package/dist/structure/ferrox-wasm.d.ts +0 -94
  742. package/dist/structure/ferrox-wasm.js +0 -249
  743. package/dist/structure/index.d.ts +0 -110
  744. package/dist/structure/index.js +0 -168
  745. package/dist/structure/measure.d.ts +0 -6
  746. package/dist/structure/measure.js +0 -29
  747. package/dist/structure/parse.d.ts +0 -65
  748. package/dist/structure/parse.js +0 -1374
  749. package/dist/structure/partial-occupancy.d.ts +0 -25
  750. package/dist/structure/partial-occupancy.js +0 -99
  751. package/dist/structure/pbc.d.ts +0 -9
  752. package/dist/structure/pbc.js +0 -123
  753. package/dist/structure/supercell.d.ts +0 -8
  754. package/dist/structure/supercell.js +0 -137
  755. package/dist/structure/validation.d.ts +0 -2
  756. package/dist/structure/validation.js +0 -10
  757. package/dist/symmetry/SymmetryStats.svelte +0 -226
  758. package/dist/symmetry/SymmetryStats.svelte.d.ts +0 -21
  759. package/dist/symmetry/WyckoffTable.svelte +0 -113
  760. package/dist/symmetry/WyckoffTable.svelte.d.ts +0 -11
  761. package/dist/symmetry/cell-transform.d.ts +0 -12
  762. package/dist/symmetry/cell-transform.js +0 -77
  763. package/dist/symmetry/index.d.ts +0 -43
  764. package/dist/symmetry/index.js +0 -229
  765. package/dist/symmetry/spacegroups.d.ts +0 -9
  766. package/dist/symmetry/spacegroups.js +0 -394
  767. package/dist/table/HeatmapTable.svelte +0 -1854
  768. package/dist/table/HeatmapTable.svelte.d.ts +0 -49
  769. package/dist/table/ToggleMenu.svelte +0 -376
  770. package/dist/table/ToggleMenu.svelte.d.ts +0 -11
  771. package/dist/table/index.d.ts +0 -74
  772. package/dist/table/index.js +0 -38
  773. package/dist/theme/ThemeControl.svelte +0 -53
  774. package/dist/theme/ThemeControl.svelte.d.ts +0 -9
  775. package/dist/theme/index.d.ts +0 -29
  776. package/dist/theme/index.js +0 -79
  777. package/dist/theme/themes.mjs +0 -285
  778. package/dist/time.d.ts +0 -4
  779. package/dist/time.js +0 -70
  780. package/dist/tooltip/TooltipContent.svelte +0 -58
  781. package/dist/tooltip/TooltipContent.svelte.d.ts +0 -31
  782. package/dist/tooltip/index.d.ts +0 -2
  783. package/dist/tooltip/index.js +0 -2
  784. package/dist/tooltip/types.d.ts +0 -8
  785. package/dist/tooltip/types.js +0 -1
  786. package/dist/trajectory/Trajectory.svelte +0 -1517
  787. package/dist/trajectory/Trajectory.svelte.d.ts +0 -77
  788. package/dist/trajectory/TrajectoryError.svelte +0 -128
  789. package/dist/trajectory/TrajectoryError.svelte.d.ts +0 -13
  790. package/dist/trajectory/TrajectoryExportPane.svelte +0 -357
  791. package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +0 -17
  792. package/dist/trajectory/TrajectoryInfoPane.svelte +0 -387
  793. package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +0 -17
  794. package/dist/trajectory/constants.d.ts +0 -6
  795. package/dist/trajectory/constants.js +0 -7
  796. package/dist/trajectory/extract.d.ts +0 -5
  797. package/dist/trajectory/extract.js +0 -162
  798. package/dist/trajectory/format-detect.d.ts +0 -9
  799. package/dist/trajectory/format-detect.js +0 -76
  800. package/dist/trajectory/frame-reader.d.ts +0 -17
  801. package/dist/trajectory/frame-reader.js +0 -332
  802. package/dist/trajectory/helpers.d.ts +0 -14
  803. package/dist/trajectory/helpers.js +0 -172
  804. package/dist/trajectory/index.d.ts +0 -63
  805. package/dist/trajectory/index.js +0 -126
  806. package/dist/trajectory/parse/ase.d.ts +0 -2
  807. package/dist/trajectory/parse/ase.js +0 -77
  808. package/dist/trajectory/parse/hdf5.d.ts +0 -2
  809. package/dist/trajectory/parse/hdf5.js +0 -129
  810. package/dist/trajectory/parse/index.d.ts +0 -12
  811. package/dist/trajectory/parse/index.js +0 -299
  812. package/dist/trajectory/parse/lammps.d.ts +0 -5
  813. package/dist/trajectory/parse/lammps.js +0 -179
  814. package/dist/trajectory/parse/vasp.d.ts +0 -2
  815. package/dist/trajectory/parse/vasp.js +0 -68
  816. package/dist/trajectory/parse/xyz.d.ts +0 -2
  817. package/dist/trajectory/parse/xyz.js +0 -110
  818. package/dist/trajectory/plotting.d.ts +0 -28
  819. package/dist/trajectory/plotting.js +0 -423
  820. package/dist/trajectory/types.d.ts +0 -11
  821. package/dist/trajectory/types.js +0 -1
  822. package/dist/utils.d.ts +0 -5
  823. package/dist/utils.js +0 -36
  824. package/dist/xrd/XrdPlot.svelte +0 -615
  825. package/dist/xrd/XrdPlot.svelte.d.ts +0 -28
  826. package/dist/xrd/broadening.d.ts +0 -20
  827. package/dist/xrd/broadening.js +0 -97
  828. package/dist/xrd/calc-xrd.d.ts +0 -37
  829. package/dist/xrd/calc-xrd.js +0 -337
  830. package/dist/xrd/index.d.ts +0 -37
  831. package/dist/xrd/index.js +0 -4
  832. package/dist/xrd/parse.d.ts +0 -13
  833. package/dist/xrd/parse.js +0 -749
  834. /package/dist/{EmptyState.svelte → src/lib/EmptyState.svelte} +0 -0
  835. /package/dist/{Icon.svelte → src/lib/Icon.svelte} +0 -0
  836. /package/dist/{chempot-diagram → src/lib/chempot-diagram}/ChemPotScene3D.svelte +0 -0
  837. /package/dist/{colors → src/lib/colors}/alloy-colors.json +0 -0
  838. /package/dist/{colors → src/lib/colors}/dark-mode-colors.json +0 -0
  839. /package/dist/{colors → src/lib/colors}/jmol-colors.json +0 -0
  840. /package/dist/{colors → src/lib/colors}/muted-colors.json +0 -0
  841. /package/dist/{colors → src/lib/colors}/pastel-colors.json +0 -0
  842. /package/dist/{colors → src/lib/colors}/vesta-colors.json +0 -0
  843. /package/dist/{element → src/lib/element}/Nucleus.svelte +0 -0
  844. /package/dist/{element → src/lib/element}/data.json +0 -0
  845. /package/dist/{element → src/lib/element}/data.json.gz +0 -0
  846. /package/dist/{element → src/lib/element}/data.schema.json +0 -0
  847. /package/dist/{element-image-urls.json → src/lib/element-image-urls.json} +0 -0
  848. /package/dist/{feedback → src/lib/feedback}/Spinner.svelte +0 -0
  849. /package/dist/{feedback → src/lib/feedback}/StatusMessage.svelte +0 -0
  850. /package/dist/{periodic-table → src/lib/periodic-table}/TableInset.svelte +0 -0
  851. /package/dist/{plot → src/lib/plot}/ReferenceLine.svelte +0 -0
  852. /package/dist/{xrd → src/lib/xrd}/atomic_scattering_params.json +0 -0
@@ -1,1374 +0,0 @@
1
- <script lang="ts">
2
- import type { D3InterpolateName } from '../colors'
3
- import {
4
- add_alpha,
5
- is_dark_mode,
6
- PLOT_COLORS,
7
- vesta_hex,
8
- watch_dark_mode,
9
- } from '../colors'
10
- import { normalize_show_controls } from '../controls'
11
- import { sanitize_html } from '../sanitize'
12
- import { ClickFeedback, DragOverlay, Spinner } from '../feedback'
13
- import Icon from '../Icon.svelte'
14
- import {
15
- set_fullscreen_bg,
16
- setup_fullscreen_effect,
17
- toggle_fullscreen,
18
- } from '../layout'
19
- import { ColorBar, PlotTooltip } from '../plot'
20
- import { DEFAULTS } from '../settings'
21
- import type { AnyStructure } from '../structure'
22
- import {
23
- barycentric_to_tetrahedral,
24
- compute_4d_coords,
25
- TETRAHEDRON_VERTICES,
26
- } from './barycentric-coords'
27
- import ConvexHullControls from './ConvexHullControls.svelte'
28
- import ConvexHullInfoPane from './ConvexHullInfoPane.svelte'
29
- import ConvexHullTooltip from './ConvexHullTooltip.svelte'
30
- import GasPressureControls from './GasPressureControls.svelte'
31
- import * as helpers from './helpers'
32
- import type { BaseConvexHullProps, Hull3DProps } from './index'
33
- import { CONVEX_HULL_STYLE, default_controls, default_hull_config } from './index'
34
- import StructurePopup from './StructurePopup.svelte'
35
- import TemperatureSlider from './TemperatureSlider.svelte'
36
- import type { Point4D } from './thermodynamics'
37
- import * as thermo from './thermodynamics'
38
- import type {
39
- ConvexHullEntry,
40
- HighlightStyle,
41
- HoverData3D,
42
- HullFaceColorMode,
43
- } from './types'
44
- import { compute_hull_stability } from './helpers'
45
-
46
- let {
47
- entries = [],
48
- controls = {},
49
- config = {},
50
- on_point_click,
51
- on_point_hover,
52
- fullscreen = $bindable(DEFAULTS.convex_hull.quaternary.fullscreen),
53
- enable_fullscreen = true,
54
- enable_info_pane = true,
55
- wrapper = $bindable(),
56
- label_threshold = 50,
57
- show_stable = $bindable(DEFAULTS.convex_hull.quaternary.show_stable),
58
- show_unstable = $bindable(DEFAULTS.convex_hull.quaternary.show_unstable),
59
- show_hull_faces = $bindable(DEFAULTS.convex_hull.quaternary.show_hull_faces),
60
- hull_face_opacity = $bindable(DEFAULTS.convex_hull.quaternary.hull_face_opacity),
61
- hull_face_color_mode = $bindable(
62
- DEFAULTS.convex_hull.quaternary.hull_face_color_mode as HullFaceColorMode,
63
- ),
64
- element_colors = vesta_hex,
65
- color_mode = $bindable(DEFAULTS.convex_hull.quaternary.color_mode),
66
- color_scale = $bindable(
67
- DEFAULTS.convex_hull.quaternary.color_scale as D3InterpolateName,
68
- ),
69
- info_pane_open = $bindable(DEFAULTS.convex_hull.quaternary.info_pane_open),
70
- legend_pane_open = $bindable(DEFAULTS.convex_hull.quaternary.legend_pane_open),
71
- max_hull_dist_show_phases = $bindable(
72
- DEFAULTS.convex_hull.quaternary.max_hull_dist_show_phases,
73
- ),
74
- max_hull_dist_show_labels = $bindable(
75
- DEFAULTS.convex_hull.quaternary.max_hull_dist_show_labels,
76
- ),
77
- show_stable_labels = $bindable(
78
- DEFAULTS.convex_hull.quaternary.show_stable_labels,
79
- ),
80
- show_unstable_labels = $bindable(
81
- DEFAULTS.convex_hull.quaternary.show_unstable_labels,
82
- ),
83
- on_file_drop,
84
- enable_click_selection = true,
85
- enable_structure_preview = true,
86
- energy_source_mode = $bindable(`precomputed`),
87
- phase_stats = $bindable(null),
88
- stable_entries = $bindable([]),
89
- unstable_entries = $bindable([]),
90
- highlighted_entries = $bindable([]),
91
- highlight_style = {},
92
- selected_entry = $bindable(null),
93
- temperature = $bindable(),
94
- interpolate_temperature = true,
95
- max_interpolation_gap = 500,
96
- gas_config,
97
- gas_pressures = $bindable({}),
98
- children,
99
- tooltip,
100
- ...rest
101
- }: BaseConvexHullProps<ConvexHullEntry> & Hull3DProps & {
102
- highlight_style?: HighlightStyle
103
- } = $props()
104
-
105
- const merged_controls = $derived({ ...default_controls, ...controls })
106
- const controls_config = $derived(normalize_show_controls(merged_controls.show))
107
- const merged_config = $derived({
108
- ...default_hull_config,
109
- ...config,
110
- colors: { ...default_hull_config.colors, ...(config.colors || {}) },
111
- margin: { t: 60, r: 60, b: 60, l: 60, ...(config.margin || {}) },
112
- })
113
-
114
- // Reactive dark mode detection for canvas text color
115
- let dark_mode = $state(is_dark_mode())
116
- $effect(() => watch_dark_mode((dark) => dark_mode = dark))
117
- const text_color = $derived(helpers.get_canvas_text_color(dark_mode))
118
-
119
- // Temperature-dependent free energy support
120
- const { has_temp_data, available_temperatures } = $derived(
121
- helpers.analyze_temperature_data(entries),
122
- )
123
-
124
- // Initialize or reset temperature when it's undefined or no longer valid
125
- $effect(() => {
126
- if (
127
- has_temp_data &&
128
- available_temperatures.length > 0 &&
129
- (temperature === undefined || !available_temperatures.includes(temperature))
130
- ) temperature = available_temperatures[0]
131
- })
132
-
133
- // Filter entries by temperature when in temperature mode
134
- const temp_filtered_entries = $derived(
135
- has_temp_data && temperature !== undefined
136
- ? helpers.filter_entries_at_temperature(entries, temperature, {
137
- interpolate: interpolate_temperature,
138
- max_interpolation_gap,
139
- })
140
- : entries,
141
- )
142
-
143
- // Gas-dependent chemical potential support (corrections based on T, P)
144
- const {
145
- entries: gas_corrected_entries,
146
- analysis: gas_analysis,
147
- merged_config: merged_gas_config,
148
- } = $derived(
149
- helpers.get_gas_corrected_entries(
150
- temp_filtered_entries,
151
- gas_config,
152
- gas_pressures,
153
- temperature ?? helpers.DEFAULT_GAS_TEMP,
154
- ),
155
- )
156
-
157
- let { // Compute energy mode information
158
- has_precomputed_e_form,
159
- has_precomputed_hull,
160
- can_compute_e_form,
161
- can_compute_hull,
162
- energy_mode,
163
- unary_refs,
164
- } = $derived(
165
- helpers.compute_energy_mode_info(
166
- gas_corrected_entries,
167
- thermo.find_lowest_energy_unary_refs,
168
- energy_source_mode,
169
- ),
170
- )
171
-
172
- const effective_entries = $derived(
173
- helpers.get_effective_entries(
174
- gas_corrected_entries,
175
- energy_mode,
176
- unary_refs,
177
- thermo.compute_e_form_per_atom,
178
- ),
179
- )
180
-
181
- // Process convex hull data with unified PhaseData interface using effective entries
182
- const pd_data = $derived(thermo.process_hull_entries(effective_entries))
183
-
184
- // Pre-compute polymorph stats once for O(1) tooltip lookups
185
- const polymorph_stats_map = $derived(
186
- helpers.compute_all_polymorph_stats(effective_entries),
187
- )
188
-
189
- const elements = $derived.by(() => {
190
- if (pd_data.elements.length > 4) {
191
- console.error(
192
- `ConvexHull4D: Dataset contains ${pd_data.elements.length} elements, but quaternary diagrams require exactly 4. Found: [${
193
- pd_data.elements.join(`, `)
194
- }]`,
195
- )
196
- return []
197
- }
198
- return pd_data.elements
199
- })
200
-
201
- // Compute 4D hull for visualization (always compute when we have formation energies)
202
- const hull_4d = $derived.by(() => {
203
- if (elements.length !== 4) return []
204
-
205
- try {
206
- // Get coords with formation energies, excluding entries that don't participate in hull
207
- const coords = compute_4d_coords(pd_data.entries, elements)
208
- .filter((ent) => !ent.exclude_from_hull)
209
-
210
- // Convert to 4D points for hull computation using barycentric coordinates (composition fractions)
211
- const points_4d: Point4D[] = coords
212
- .filter(
213
- (ent) =>
214
- Number.isFinite(ent.e_form_per_atom) &&
215
- [ent.x, ent.y, ent.z].every(Number.isFinite),
216
- )
217
- .map((ent) => {
218
- const amounts = elements.map((el) => ent.composition[el] || 0)
219
- const total = amounts.reduce((sum, amt) => sum + amt, 0)
220
- if (!(total > 0)) return { x: NaN, y: NaN, z: NaN, w: NaN }
221
- const [x, y, z] = amounts.map((amt) => amt / total)
222
- return { x, y, z, w: ent.e_form_per_atom ?? NaN }
223
- })
224
- .filter((point) => [point.x, point.y, point.z, point.w].every(Number.isFinite))
225
-
226
- if (points_4d.length < 5) return [] // Need at least 5 points for 4D hull
227
-
228
- return thermo.compute_lower_hull_4d(points_4d)
229
- } catch (error) {
230
- console.error(`Error computing 4D hull:`, error)
231
- return []
232
- }
233
- })
234
-
235
- // Enrich coords with e_above_hull (before filtering)
236
- const all_enriched_entries = $derived.by(() => {
237
- if (elements.length !== 4) return []
238
- try {
239
- const coords = compute_4d_coords(pd_data.entries, elements)
240
- if (energy_mode !== `on-the-fly` || hull_4d.length === 0) return coords
241
-
242
- // Build 4D points, tracking original indices for mapping hull distances back
243
- const valid = coords.flatMap((entry, idx) => {
244
- if (
245
- !Number.isFinite(entry.e_form_per_atom) ||
246
- ![entry.x, entry.y, entry.z].every(Number.isFinite)
247
- ) return []
248
- const amounts = elements.map((el) => entry.composition[el] || 0)
249
- const total = amounts.reduce((sum, amt) => sum + amt, 0)
250
- if (!(total > 0)) return []
251
- const [x, y, z] = amounts.map((amt) => amt / total)
252
- return [x, y, z].every(Number.isFinite)
253
- ? [{ idx, pt: { x, y, z, w: entry.e_form_per_atom ?? NaN } }]
254
- : []
255
- })
256
- const raw_dists = thermo.compute_e_above_hull_4d(valid.map((item) => item.pt), hull_4d)
257
- const hull_map = new Map(valid.map((item, hull_idx) => [item.idx, raw_dists[hull_idx]]))
258
- return coords.map((entry, idx) => {
259
- const raw = hull_map.get(idx)
260
- if (raw === undefined) return { ...entry, e_above_hull: raw, is_stable: false }
261
- return { ...entry, ...compute_hull_stability(raw, entry.exclude_from_hull) }
262
- })
263
- } catch (err) {
264
- console.error(`Error computing quaternary coordinates:`, err)
265
- return []
266
- }
267
- })
268
-
269
- // Auto threshold: show all for few entries, use default for many, interpolate between
270
- const max_hull_dist_in_data = $derived(
271
- helpers.calc_max_hull_dist_in_data(all_enriched_entries),
272
- )
273
- const auto_default_threshold = $derived(helpers.compute_auto_hull_dist_threshold(
274
- all_enriched_entries.length,
275
- max_hull_dist_in_data,
276
- DEFAULTS.convex_hull.quaternary.max_hull_dist_show_phases,
277
- ))
278
-
279
- // Initialize threshold to auto value on first load
280
- let initialized = $state(false)
281
- $effect(() => {
282
- if (!initialized && all_enriched_entries.length > 0) {
283
- initialized = true
284
- max_hull_dist_show_phases = auto_default_threshold
285
- }
286
- })
287
-
288
- // Filter by threshold and compute visibility
289
- const plot_entries = $derived(
290
- all_enriched_entries.filter((entry) => {
291
- // Always include stable entries and elemental reference points
292
- if (entry.is_stable || (entry.e_above_hull ?? Infinity) <= 1e-6) return true
293
- return typeof entry.e_above_hull === `number` &&
294
- entry.e_above_hull <= max_hull_dist_show_phases
295
- }).map((entry) => {
296
- const is_stable = entry.is_stable || entry.e_above_hull === 0
297
- return {
298
- ...entry,
299
- visible: (is_stable && show_stable) || (!is_stable && show_unstable),
300
- }
301
- }),
302
- )
303
-
304
- // Stable and unstable entries exposed as bindable props
305
- $effect(() => {
306
- stable_entries = plot_entries.filter((entry: ConvexHullEntry) =>
307
- entry.is_stable || entry.e_above_hull === 0
308
- )
309
- unstable_entries = plot_entries.filter((entry: ConvexHullEntry) =>
310
- (entry.e_above_hull ?? 0) > 0 && !entry.is_stable
311
- )
312
- })
313
-
314
- let canvas: HTMLCanvasElement
315
- let ctx: CanvasRenderingContext2D | null = null
316
- let frame_id = 0 // Performance optimization
317
-
318
- // Camera state - following Materials Project's 3D camera setup
319
- let camera = $state({
320
- rotation_x: DEFAULTS.convex_hull.quaternary.camera_rotation_x,
321
- rotation_y: DEFAULTS.convex_hull.quaternary.camera_rotation_y,
322
- zoom: DEFAULTS.convex_hull.quaternary.camera_zoom,
323
- center_x: 0,
324
- center_y: 20, // Slight offset to avoid legend overlap
325
- })
326
-
327
- // Interaction state
328
- let is_dragging = $state(false)
329
- let drag_started = $state(false)
330
- let last_mouse = $state({ x: 0, y: 0 })
331
- let hover_data = $state<HoverData3D<ConvexHullEntry> | null>(null)
332
- let copy_feedback = $state({ visible: false, position: { x: 0, y: 0 } })
333
-
334
- // Drag and drop state
335
- let drag_over = $state(false)
336
-
337
- // Structure popup state
338
- let modal_open = $state(false)
339
- let selected_structure = $state<AnyStructure | null>(null)
340
- let modal_place_right = $state(true)
341
-
342
- // Hull face color (customizable via controls)
343
- let hull_face_color = $state(`#4caf50`)
344
-
345
- // Pulsating highlight for selected point and highlighted entries
346
- let pulse_time = $state(0)
347
- let pulse_opacity = $derived(0.3 + 0.4 * Math.sin(pulse_time * 4))
348
- let pulse_frame_id = 0
349
-
350
- // Merge highlight style with defaults
351
- const merged_highlight_style = $derived(
352
- helpers.merge_highlight_style(highlight_style),
353
- )
354
-
355
- // Helper to check if entry is highlighted
356
- const is_highlighted = (entry: ConvexHullEntry): boolean =>
357
- helpers.is_entry_highlighted(entry, highlighted_entries)
358
-
359
- $effect(() => {
360
- if (!selected_entry && !highlighted_entries.length) return
361
- const reduce = globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches
362
- if (reduce) return
363
- const animate = () => {
364
- pulse_time += 0.02
365
- render_once()
366
- pulse_frame_id = requestAnimationFrame(animate)
367
- }
368
- pulse_frame_id = requestAnimationFrame(animate)
369
- return () => {
370
- if (pulse_frame_id) cancelAnimationFrame(pulse_frame_id)
371
- }
372
- })
373
-
374
- // Re-render when important state changes
375
- $effect(() => {
376
- // oxfmt-ignore
377
- void [show_hull_faces, color_mode, color_scale, camera.rotation_x, camera.rotation_y, camera.zoom, camera.center_x, camera.center_y, plot_entries, hull_face_color, hull_face_opacity, hull_face_color_mode, element_colors, text_color, elements] // track reactively
378
-
379
- render_once()
380
- })
381
-
382
- // Visibility toggles are now bindable props
383
-
384
- // Smart label defaults - hide labels if too many entries
385
- $effect(() => {
386
- const total_entries = effective_entries.length
387
- if (total_entries > label_threshold) {
388
- show_stable_labels = false
389
- show_unstable_labels = false
390
- } else {
391
- // For smaller datasets, show stable labels by default
392
- show_stable_labels = true
393
- show_unstable_labels = false
394
- }
395
- })
396
-
397
- // Function to extract structure data from a convex hull entry
398
- function extract_structure_from_entry(
399
- entry: ConvexHullEntry,
400
- ): AnyStructure | null {
401
- const orig_entry = entries.find((ent) => ent.entry_id === entry.entry_id)
402
- return orig_entry?.structure as AnyStructure || null
403
- }
404
-
405
- const reset_camera = () => {
406
- camera.rotation_x = DEFAULTS.convex_hull.quaternary.camera_rotation_x
407
- camera.rotation_y = DEFAULTS.convex_hull.quaternary.camera_rotation_y
408
- camera.zoom = DEFAULTS.convex_hull.quaternary.camera_zoom
409
- camera.center_x = 0
410
- camera.center_y = 20 // Slight offset to avoid legend overlap
411
- }
412
- function reset_all() {
413
- reset_camera()
414
- fullscreen = DEFAULTS.convex_hull.quaternary.fullscreen
415
- info_pane_open = DEFAULTS.convex_hull.quaternary.info_pane_open
416
- legend_pane_open = DEFAULTS.convex_hull.quaternary.legend_pane_open
417
- color_mode = DEFAULTS.convex_hull.quaternary.color_mode
418
- color_scale = DEFAULTS.convex_hull.quaternary.color_scale as D3InterpolateName
419
- show_stable = DEFAULTS.convex_hull.quaternary.show_stable
420
- show_unstable = DEFAULTS.convex_hull.quaternary.show_unstable
421
- show_stable_labels = DEFAULTS.convex_hull.quaternary.show_stable_labels
422
- show_unstable_labels = DEFAULTS.convex_hull.quaternary.show_unstable_labels
423
- // Use auto-computed threshold based on entry count instead of static default
424
- max_hull_dist_show_phases = auto_default_threshold
425
- max_hull_dist_show_labels =
426
- DEFAULTS.convex_hull.quaternary.max_hull_dist_show_labels
427
- show_hull_faces = DEFAULTS.convex_hull.quaternary.show_hull_faces
428
- hull_face_color = DEFAULTS.convex_hull.quaternary.hull_face_color
429
- hull_face_opacity = DEFAULTS.convex_hull.quaternary.hull_face_opacity
430
- hull_face_color_mode = DEFAULTS.convex_hull.quaternary
431
- .hull_face_color_mode as HullFaceColorMode
432
- }
433
-
434
- const handle_keydown = (event: KeyboardEvent) => {
435
- const target = event.target as HTMLElement
436
- // Skip if focus is on an interactive element that handles Enter natively
437
- const interactive_selector =
438
- `input,textarea,select,button,a,[contenteditable="true"],[role="button"],[tabindex]:not([tabindex="-1"])`
439
- if (target.matches(interactive_selector) && target !== canvas) return
440
-
441
- // Prevent double handling from canvas + wrapper bubbling
442
- if (event.target !== event.currentTarget && event.currentTarget !== canvas) return
443
-
444
- // Handle Enter for keyboard accessibility - select hovered entry
445
- if (event.key === `Enter`) {
446
- const entry = hover_data?.entry
447
- if (entry) {
448
- on_point_click?.(entry)
449
- if (enable_click_selection) {
450
- selected_entry = entry
451
- if (enable_structure_preview) {
452
- const structure = extract_structure_from_entry(entry)
453
- if (structure) {
454
- selected_structure = structure
455
- modal_place_right = helpers.calculate_modal_side(wrapper)
456
- modal_open = true
457
- }
458
- }
459
- }
460
- } else if (modal_open) {
461
- close_structure_popup()
462
- }
463
- return
464
- }
465
-
466
- const actions: Record<string, () => void> = {
467
- r: reset_camera,
468
- b: () => color_mode = color_mode === `stability` ? `energy` : `stability`,
469
- s: () => show_stable = !show_stable,
470
- u: () => show_unstable = !show_unstable,
471
- h: () => show_hull_faces = !show_hull_faces,
472
- l: () => show_stable_labels = !show_stable_labels,
473
- }
474
- actions[event.key.toLowerCase()]?.()
475
- }
476
-
477
- async function handle_file_drop(event: DragEvent): Promise<void> {
478
- drag_over = false
479
- const data = await helpers.parse_hull_entries_from_drop(event)
480
- if (data) on_file_drop?.(data)
481
- }
482
-
483
- async function copy_entry_data(
484
- entry: ConvexHullEntry,
485
- position: { x: number; y: number },
486
- ) {
487
- await helpers.copy_entry_to_clipboard(entry, position, (visible, pos) => {
488
- copy_feedback.visible = visible
489
- copy_feedback.position = pos
490
- })
491
- }
492
-
493
- const get_point_color = (entry: ConvexHullEntry): string =>
494
- helpers.get_point_color_for_entry(
495
- entry,
496
- color_mode,
497
- merged_config.colors,
498
- energy_color_scale,
499
- )
500
-
501
- // Cache energy color scale per frame/setting
502
- const energy_color_scale = $derived.by(() =>
503
- helpers.get_energy_color_scale(color_mode, color_scale, plot_entries)
504
- )
505
-
506
- // Convex hull statistics - compute internally and expose via bindable prop
507
- $effect(() => {
508
- phase_stats = thermo.get_convex_hull_stats(plot_entries, elements, 4)
509
- })
510
-
511
- // 3D to 2D projection following Materials Project approach
512
- function project_3d_point(
513
- x: number,
514
- y: number,
515
- z: number,
516
- ): { x: number; y: number; depth: number } {
517
- if (!canvas) return { x: 0, y: 0, depth: 0 }
518
-
519
- // Center coordinates around tetrahedron/triangle centroid
520
- let [centered_x, centered_y, centered_z] = [x, y, z]
521
-
522
- // Tetrahedron centroid: average of vertices (1,0,0), (0.5,√3/2,0), (0.5,√3/6,√6/3), (0,0,0)
523
- const centroid_x = (1 + 0.5 + 0.5 + 0) / 4 // = 0.5
524
- const centroid_y = (0 + Math.sqrt(3) / 2 + Math.sqrt(3) / 6 + 0) / 4 // = √3/6
525
- const centroid_z = (0 + 0 + Math.sqrt(6) / 3 + 0) / 4 // = √6/12
526
- centered_x = x - centroid_x
527
- centered_y = y - centroid_y
528
- centered_z = z - centroid_z
529
-
530
- // Apply 3D transformations around the centered coordinates
531
- const cos_x = Math.cos(camera.rotation_x)
532
- const sin_x = Math.sin(camera.rotation_x)
533
- const cos_y = Math.cos(camera.rotation_y)
534
- const sin_y = Math.sin(camera.rotation_y)
535
-
536
- // Rotate around Y axis first
537
- const x1 = centered_x * cos_y - centered_z * sin_y
538
- const z1 = centered_x * sin_y + centered_z * cos_y
539
-
540
- // Then rotate around X axis
541
- const y2 = centered_y * cos_x - z1 * sin_x
542
- const z2 = centered_y * sin_x + z1 * cos_x
543
-
544
- // Apply perspective projection using cached canvas dimensions for consistency
545
- const scale = Math.min(canvas_dims.width, canvas_dims.height) * 0.6 * camera.zoom
546
- const center_x = canvas_dims.width / 2 + camera.center_x
547
- const center_y = canvas_dims.height / 2 + camera.center_y
548
-
549
- return {
550
- x: center_x + x1 * scale,
551
- y: center_y - y2 * scale, // Flip Y for canvas coordinates
552
- depth: z2, // For depth sorting
553
- }
554
- }
555
-
556
- function draw_structure_outline(): void {
557
- if (!ctx) return
558
-
559
- const styles = getComputedStyle(canvas)
560
- // Match gray dashed structure lines used in 3D
561
- ctx.strokeStyle = CONVEX_HULL_STYLE.structure_line.color
562
- ctx.lineWidth = CONVEX_HULL_STYLE.structure_line.line_width
563
- ctx.setLineDash(CONVEX_HULL_STYLE.structure_line.dash)
564
-
565
- // Draw tetrahedron edges
566
- draw_tetrahedron()
567
-
568
- // Reset dash and stroke for subsequent drawings
569
- ctx.setLineDash([])
570
- ctx.strokeStyle = styles.getPropertyValue(`--hull-edge-color`) || `#212121`
571
- }
572
-
573
- function draw_tetrahedron(): void {
574
- if (!ctx) return
575
-
576
- // Convert vertices to Point3D objects
577
- const vertices = TETRAHEDRON_VERTICES.map(([x, y, z]) => ({ x, y, z }))
578
-
579
- // Tetrahedron edges (connecting vertices)
580
- const edges = [
581
- [0, 1],
582
- [0, 2],
583
- [0, 3], // From vertex 0
584
- [1, 2],
585
- [1, 3], // From vertex 1
586
- [2, 3], // From vertex 2
587
- ]
588
-
589
- // Draw edges
590
- ctx.beginPath()
591
- for (const [start, end] of edges) {
592
- const v1 = vertices[start]
593
- const v2 = vertices[end]
594
-
595
- const proj1 = project_3d_point(v1.x, v1.y, v1.z)
596
- const proj2 = project_3d_point(v2.x, v2.y, v2.z)
597
-
598
- ctx.moveTo(proj1.x, proj1.y)
599
- ctx.lineTo(proj2.x, proj2.y)
600
- }
601
- ctx.stroke()
602
-
603
- // Corner element labels: place just outside along line towards tetrahedron centroid
604
- if (elements.length === 4) {
605
- // Tetrahedron centroid in barycentric space maps to average of vertices
606
- const centroid = {
607
- x: (vertices[0].x + vertices[1].x + vertices[2].x + vertices[3].x) / 4,
608
- y: (vertices[0].y + vertices[1].y + vertices[2].y + vertices[3].y) / 4,
609
- z: (vertices[0].z + vertices[1].z + vertices[2].z + vertices[3].z) / 4,
610
- }
611
-
612
- ctx.fillStyle = text_color
613
- ctx.font = `bold 18px Arial`
614
- ctx.textAlign = `center`
615
- ctx.textBaseline = `middle`
616
-
617
- const distance = 0.06
618
- for (let idx = 0; idx < 4; idx++) {
619
- const vx = vertices[idx]
620
- // Direction from centroid to vertex
621
- const dir = {
622
- x: vx.x - centroid.x,
623
- y: vx.y - centroid.y,
624
- z: vx.z - centroid.z,
625
- }
626
- const len = Math.hypot(dir.x, dir.y, dir.z) || 1
627
- const label_pos = {
628
- x: vx.x + (dir.x / len) * distance,
629
- y: vx.y + (dir.y / len) * distance,
630
- z: vx.z + (dir.z / len) * distance,
631
- }
632
- const proj = project_3d_point(label_pos.x, label_pos.y, label_pos.z)
633
- ctx.fillText(elements[idx], proj.x, proj.y)
634
- }
635
- }
636
- }
637
-
638
- // Draw convex hull faces connecting stable points
639
- function draw_convex_hull_faces(): void {
640
- if (!ctx || !show_hull_faces || hull_4d.length === 0) return
641
-
642
- // Get stable points to determine which hull facets to draw
643
- const stable_points = plot_entries.filter((entry) =>
644
- entry.is_stable || entry.e_above_hull === 0
645
- )
646
- if (stable_points.length === 0) return
647
-
648
- // Each tetrahedral facet has 4 triangular faces - we need to draw these
649
- // Collect all triangular faces with depth for sorting
650
- type TriangleFace = {
651
- vertices: [
652
- { x: number; y: number; depth: number },
653
- { x: number; y: number; depth: number },
654
- { x: number; y: number; depth: number },
655
- ]
656
- avg_depth: number
657
- avg_w: number // Average formation energy for coloring
658
- tet_idx: number // Tetrahedron index for facet_index mode
659
- centroid_bary: number[] // Barycentric centroid [el0, el1, el2, el3] for dominant_element mode
660
- }
661
-
662
- const triangles: TriangleFace[] = []
663
-
664
- for (let tet_idx = 0; tet_idx < hull_4d.length; tet_idx++) {
665
- const tet = hull_4d[tet_idx]
666
- const [p0, p1, p2, p3] = tet.vertices
667
-
668
- // Convert barycentric coordinates to tetrahedral 3D coordinates
669
- const tet0 = barycentric_to_tetrahedral([
670
- p0.x,
671
- p0.y,
672
- p0.z,
673
- 1 - p0.x - p0.y - p0.z,
674
- ])
675
- const tet1 = barycentric_to_tetrahedral([
676
- p1.x,
677
- p1.y,
678
- p1.z,
679
- 1 - p1.x - p1.y - p1.z,
680
- ])
681
- const tet2 = barycentric_to_tetrahedral([
682
- p2.x,
683
- p2.y,
684
- p2.z,
685
- 1 - p2.x - p2.y - p2.z,
686
- ])
687
- const tet3 = barycentric_to_tetrahedral([
688
- p3.x,
689
- p3.y,
690
- p3.z,
691
- 1 - p3.x - p3.y - p3.z,
692
- ])
693
-
694
- // Project to 2D screen space
695
- const proj0 = project_3d_point(tet0.x, tet0.y, tet0.z)
696
- const proj1 = project_3d_point(tet1.x, tet1.y, tet1.z)
697
- const proj2 = project_3d_point(tet2.x, tet2.y, tet2.z)
698
- const proj3 = project_3d_point(tet3.x, tet3.y, tet3.z)
699
-
700
- // Compute tetrahedron centroid in barycentric coords (for dominant_element mode)
701
- // All 4 faces share the same tetrahedron, so they get the same color for facet_index
702
- const tet_centroid_bary = [
703
- (p0.x + p1.x + p2.x + p3.x) / 4,
704
- (p0.y + p1.y + p2.y + p3.y) / 4,
705
- (p0.z + p1.z + p2.z + p3.z) / 4,
706
- ((1 - p0.x - p0.y - p0.z) + (1 - p1.x - p1.y - p1.z) +
707
- (1 - p2.x - p2.y - p2.z) + (1 - p3.x - p3.y - p3.z)) / 4,
708
- ]
709
-
710
- // Each tetrahedron has 4 triangular faces
711
- const faces: [typeof proj0, typeof proj1, typeof proj2, number][] = [
712
- [proj0, proj1, proj2, (p0.w + p1.w + p2.w) / 3],
713
- [proj0, proj1, proj3, (p0.w + p1.w + p3.w) / 3],
714
- [proj0, proj2, proj3, (p0.w + p2.w + p3.w) / 3],
715
- [proj1, proj2, proj3, (p1.w + p2.w + p3.w) / 3],
716
- ]
717
-
718
- for (const [v0, v1, v2, avg_w] of faces) {
719
- triangles.push({
720
- vertices: [v0, v1, v2],
721
- avg_depth: (v0.depth + v1.depth + v2.depth) / 3,
722
- avg_w,
723
- tet_idx,
724
- centroid_bary: tet_centroid_bary,
725
- })
726
- }
727
- }
728
-
729
- // Sort by depth (back to front)
730
- triangles.sort((a, b) => a.avg_depth - b.avg_depth)
731
-
732
- // Lazy computation for uniform mode: normalize alpha by formation energy
733
- let norm_alpha: ((w: number) => number) | null = null
734
- if (hull_face_color_mode === `uniform`) {
735
- const formation_energies = plot_entries.map((e) => e.e_form_per_atom ?? 0)
736
- const min_fe = Math.min(0, ...formation_energies)
737
- norm_alpha = (energy: number) => {
738
- const t = Math.max(0, Math.min(1, (0 - energy) / Math.max(1e-6, 0 - min_fe)))
739
- return t * hull_face_opacity
740
- }
741
- }
742
-
743
- // Lazy computation for formation_energy mode
744
- let energy_face_scale: ((val: number) => string) | null = null
745
- let min_w = 0
746
- if (hull_face_color_mode === `formation_energy`) {
747
- const all_avg_w = triangles.map((tri) => tri.avg_w)
748
- min_w = Math.min(...all_avg_w)
749
- energy_face_scale = helpers.get_energy_color_scale(
750
- `energy`,
751
- color_scale,
752
- all_avg_w.map((energy) => ({ e_above_hull: energy - min_w })), // Normalize to 0-based
753
- )
754
- }
755
-
756
- // Helper to get face color based on mode
757
- const get_face_color = (tri: TriangleFace): string => {
758
- if (hull_face_color_mode === `uniform`) {
759
- return hull_face_color
760
- }
761
- if (hull_face_color_mode === `formation_energy`) {
762
- return energy_face_scale?.(tri.avg_w - min_w) ?? hull_face_color
763
- }
764
- if (hull_face_color_mode === `dominant_element`) {
765
- // Find element with highest fraction
766
- const max_idx = tri.centroid_bary.indexOf(Math.max(...tri.centroid_bary))
767
- const el = elements[max_idx]
768
- return element_colors[el] ?? `#888888`
769
- }
770
- if (hull_face_color_mode === `facet_index`) {
771
- return PLOT_COLORS[tri.tet_idx % PLOT_COLORS.length]
772
- }
773
- return hull_face_color
774
- }
775
-
776
- // Draw each triangle
777
- for (const tri of triangles) {
778
- const [v0, v1, v2] = tri.vertices
779
- // Uniform mode uses variable opacity; other modes use fixed opacity
780
- const alpha = hull_face_color_mode === `uniform`
781
- ? (norm_alpha?.(tri.avg_w) ?? hull_face_opacity)
782
- : hull_face_opacity
783
- const face_color = get_face_color(tri)
784
-
785
- ctx.save()
786
- ctx.beginPath()
787
- ctx.moveTo(v0.x, v0.y)
788
- ctx.lineTo(v1.x, v1.y)
789
- ctx.lineTo(v2.x, v2.y)
790
- ctx.closePath()
791
-
792
- ctx.fillStyle = add_alpha(face_color, alpha)
793
- ctx.fill()
794
-
795
- // Edge lines more pronounced with higher opacity
796
- ctx.strokeStyle = add_alpha(face_color, Math.min(0.4, alpha * 4))
797
- ctx.lineWidth = 1
798
- ctx.stroke()
799
- ctx.restore()
800
- }
801
- }
802
-
803
- function draw_data_points(): void {
804
- if (!ctx || sorted_points_cache.length === 0) return
805
-
806
- for (const { entry, projected } of sorted_points_cache) {
807
- const is_stable = entry.is_stable || entry.e_above_hull === 0
808
- const is_entry_highlighted = is_highlighted(entry)
809
- const color = get_point_color(entry)
810
- const size = (entry.size || (is_stable ? 6 : 4)) * canvas_dims.scale
811
- const marker = entry.marker || `circle`
812
-
813
- // Shadow
814
- const shadow_offset = Math.abs(entry.z) * 2 * canvas_dims.scale
815
- ctx.fillStyle = `rgba(0, 0, 0, 0.2)`
816
- const shadow_path = helpers.create_marker_path(size * 0.8, marker)
817
- ctx.save()
818
- ctx.translate(projected.x + shadow_offset, projected.y + shadow_offset)
819
- ctx.fill(shadow_path)
820
- ctx.restore()
821
-
822
- // Highlights
823
- if (selected_entry && entry.entry_id === selected_entry.entry_id) {
824
- helpers.draw_selection_highlight(
825
- ctx,
826
- projected,
827
- size,
828
- canvas_dims.scale,
829
- pulse_time,
830
- pulse_opacity,
831
- )
832
- }
833
- if (is_entry_highlighted) {
834
- helpers.draw_highlight_effect(
835
- ctx,
836
- projected,
837
- size,
838
- canvas_dims.scale,
839
- pulse_time,
840
- merged_highlight_style,
841
- )
842
- }
843
-
844
- // Main point with marker symbol
845
- ctx.fillStyle =
846
- is_entry_highlighted && merged_highlight_style.effect === `color`
847
- ? merged_highlight_style.color
848
- : color
849
- ctx.strokeStyle = is_stable ? `#ffffff` : `#000000`
850
- ctx.lineWidth = 0.5 * canvas_dims.scale
851
- const marker_path = helpers.create_marker_path(size, marker)
852
- ctx.save()
853
- ctx.translate(projected.x, projected.y)
854
- ctx.fill(marker_path)
855
- ctx.stroke(marker_path)
856
- ctx.restore()
857
- }
858
-
859
- if (!merged_config.show_labels) return
860
-
861
- const label_entries = helpers.get_composition_label_entries(
862
- sorted_points_cache
863
- .map(({ entry }) => entry)
864
- .filter((entry) => {
865
- if (entry.is_element) return false
866
- const is_stable = entry.is_stable || entry.e_above_hull === 0
867
- return (is_stable && show_stable_labels) ||
868
- (!is_stable && show_unstable_labels &&
869
- (entry.e_above_hull ?? 0) <= max_hull_dist_show_labels)
870
- }),
871
- )
872
-
873
- ctx.fillStyle = text_color
874
- ctx.font = `${Math.round(12 * canvas_dims.scale)}px Arial`
875
- ctx.textAlign = `center`
876
- ctx.textBaseline = `middle`
877
-
878
- for (const entry of label_entries) {
879
- const is_stable = entry.is_stable || entry.e_above_hull === 0
880
- const size = (entry.size || (is_stable ? 6 : 4)) * canvas_dims.scale
881
- const projected = project_3d_point(entry.x, entry.y, entry.z)
882
- const label = helpers.get_entry_label(entry, elements)
883
- ctx.fillText(label, projected.x, projected.y + size + 6 * canvas_dims.scale)
884
- }
885
- }
886
-
887
- function render_frame(): void {
888
- if (!ctx || !canvas) return
889
-
890
- // Use CSS dimensions for rendering (already scaled by DPR in context)
891
- const display_width = canvas.clientWidth || 600
892
- const display_height = canvas.clientHeight || 600
893
-
894
- ctx.clearRect(0, 0, display_width, display_height) // Clear canvas
895
-
896
- ctx.fillStyle = `transparent` // Set background - use transparent to inherit from container
897
- ctx.fillRect(0, 0, display_width, display_height)
898
-
899
- if (elements.length !== 4) {
900
- if (elements.length > 0) {
901
- ctx.fillStyle = text_color
902
- ctx.font = `16px Arial`
903
- ctx.textAlign = `center`
904
- ctx.textBaseline = `middle`
905
- ctx.fillText(
906
- `Quaternary convex hull requires exactly 4 elements (got ${elements.length})`,
907
- display_width / 2,
908
- display_height / 2,
909
- )
910
- }
911
- return
912
- }
913
-
914
- draw_structure_outline() // Draw tetrahedron outline
915
-
916
- draw_convex_hull_faces() // Draw convex hull faces (before points so they appear behind)
917
-
918
- draw_data_points() // Draw data points (on top)
919
- }
920
-
921
- function handle_mouse_down(event: MouseEvent) {
922
- is_dragging = true
923
- drag_started = false
924
- hover_data = null
925
- on_point_hover?.(null)
926
- last_mouse = { x: event.clientX, y: event.clientY }
927
- }
928
-
929
- const handle_mouse_move = (event: MouseEvent) => {
930
- if (!is_dragging) return
931
- const [dx, dy] = [event.clientX - last_mouse.x, event.clientY - last_mouse.y]
932
-
933
- // Mark as drag if any movement occurred
934
- if (dx !== 0 || dy !== 0) drag_started = true
935
-
936
- // With Cmd/Ctrl held: pan the view instead of rotating
937
- if (event.metaKey || event.ctrlKey) {
938
- camera.center_x += dx
939
- camera.center_y += dy
940
- } else {
941
- camera.rotation_y += dx * 0.005
942
- camera.rotation_x = Math.max(
943
- -Math.PI / 3,
944
- Math.min(Math.PI / 3, camera.rotation_x - dy * 0.005),
945
- )
946
- }
947
- last_mouse = { x: event.clientX, y: event.clientY }
948
- }
949
-
950
- const handle_wheel = (event: WheelEvent) => {
951
- event.preventDefault()
952
- camera.zoom = Math.max(
953
- 1.0,
954
- Math.min(15, camera.zoom * (event.deltaY > 0 ? 0.98 : 1.02)),
955
- )
956
- }
957
-
958
- const handle_hover = (event: MouseEvent) => {
959
- if (is_dragging) return
960
- const entry = find_entry_at_mouse(event)
961
- hover_data = entry
962
- ? { entry, position: { x: event.clientX, y: event.clientY } }
963
- : null
964
- on_point_hover?.(hover_data)
965
- }
966
-
967
- const find_entry_at_mouse = (event: MouseEvent): ConvexHullEntry | null =>
968
- helpers.find_hull_entry_at_mouse(
969
- canvas,
970
- event,
971
- plot_entries,
972
- (x: number, y: number, z: number) => {
973
- const projected = project_3d_point(x, y, z)
974
- return { x: projected.x, y: projected.y }
975
- },
976
- )
977
-
978
- const handle_click = (event: MouseEvent) => {
979
- event.stopPropagation()
980
-
981
- // Check if this was a drag operation (any mouse movement during drag)
982
- const was_drag = drag_started
983
- drag_started = false // Reset for next interaction
984
- if (was_drag) return // Don't trigger click if this was a drag
985
-
986
- const entry = find_entry_at_mouse(event)
987
- if (entry) {
988
- on_point_click?.(entry)
989
- if (enable_click_selection) {
990
- selected_entry = entry
991
- if (enable_structure_preview) {
992
- const structure = extract_structure_from_entry(entry)
993
- if (structure) {
994
- selected_structure = structure
995
- modal_place_right = helpers.calculate_modal_side(wrapper)
996
- modal_open = true
997
- }
998
- }
999
- }
1000
- } else if (modal_open) close_structure_popup()
1001
- }
1002
-
1003
- function close_structure_popup() {
1004
- modal_open = false
1005
- selected_structure = null
1006
- selected_entry = null
1007
- }
1008
-
1009
- const handle_double_click = (event: MouseEvent) => {
1010
- const entry = find_entry_at_mouse(event)
1011
- if (entry) {
1012
- copy_entry_data(entry, {
1013
- x: event.clientX,
1014
- y: event.clientY,
1015
- })
1016
- }
1017
- }
1018
-
1019
- const render_once = () => {
1020
- if (!frame_id) {
1021
- frame_id = requestAnimationFrame(() => {
1022
- render_frame()
1023
- frame_id = 0
1024
- })
1025
- }
1026
- }
1027
-
1028
- function update_canvas_size() {
1029
- if (!canvas) return
1030
- const dpr = globalThis.devicePixelRatio || 1
1031
- const container = canvas.parentElement
1032
- const rect = container?.getBoundingClientRect()
1033
- const [width, height] = rect ? [rect.width, rect.height] : [400, 400]
1034
-
1035
- canvas.width = Math.max(0, Math.round(width * dpr))
1036
- canvas.height = Math.max(0, Math.round(height * dpr))
1037
- canvas_dims = { width, height, scale: Math.min(width, height) / 600 }
1038
-
1039
- ctx = canvas.getContext(`2d`)
1040
- if (ctx) {
1041
- ctx.setTransform(dpr, 0, 0, dpr, 0, 0)
1042
- ctx.imageSmoothingEnabled = true
1043
- ctx.imageSmoothingQuality = `high`
1044
- }
1045
- render_once()
1046
- }
1047
-
1048
- $effect(() => {
1049
- if (!canvas) return
1050
-
1051
- // Initial setup
1052
- update_canvas_size()
1053
-
1054
- // Watch for resize events - only update canvas, don't reset camera
1055
- const resize_observer = new ResizeObserver(update_canvas_size)
1056
-
1057
- const container = canvas.parentElement
1058
- if (container) resize_observer.observe(container)
1059
-
1060
- return () => { // Cleanup on unmount
1061
- if (frame_id) cancelAnimationFrame(frame_id)
1062
- resize_observer.disconnect()
1063
- }
1064
- })
1065
-
1066
- // Fullscreen handling with camera reset
1067
- let was_fullscreen = $state(fullscreen)
1068
- $effect(() => {
1069
- setup_fullscreen_effect(fullscreen, wrapper, (entering_fullscreen) => {
1070
- if (entering_fullscreen !== was_fullscreen) {
1071
- camera.center_x = 0
1072
- camera.center_y = 20
1073
- was_fullscreen = entering_fullscreen
1074
- }
1075
- })
1076
- set_fullscreen_bg(wrapper, fullscreen, `--hull-4d-bg-fullscreen`)
1077
- })
1078
-
1079
- // Performance: Cache canvas dimensions and pre-compute sorted point projections
1080
- let canvas_dims = $state({ width: 600, height: 600, scale: 1 })
1081
- const sorted_points_cache = $derived.by(() => {
1082
- if (!canvas || plot_entries.length === 0) return []
1083
- return plot_entries
1084
- .filter((entry) => entry.visible)
1085
- .map((entry) => ({
1086
- entry,
1087
- projected: project_3d_point(entry.x, entry.y, entry.z),
1088
- }))
1089
- .sort((a, b) => a.projected.depth - b.projected.depth)
1090
- })
1091
-
1092
- let style = $derived(
1093
- `--hull-stable-color:${merged_config.colors?.stable || `#0072B2`};
1094
- --hull-unstable-color:${merged_config.colors?.unstable || `#E69F00`};
1095
- --hull-edge-color:${merged_config.colors?.edge || `var(--text-color, #212121)`};
1096
- --hull-text-color:${
1097
- merged_config.colors?.annotation || `var(--text-color, #212121)`
1098
- }`,
1099
- )
1100
- </script>
1101
-
1102
- <svelte:document
1103
- onfullscreenchange={() => {
1104
- fullscreen = Boolean(document.fullscreenElement)
1105
- }}
1106
- onmousemove={handle_mouse_move}
1107
- onmouseup={() => [is_dragging, drag_started] = [false, false]}
1108
- />
1109
-
1110
- <div
1111
- {...rest}
1112
- class="convex-hull-4d {rest.class ?? ``}"
1113
- class:dragover={drag_over}
1114
- style={`${style}; ${rest.style ?? ``}`}
1115
- data-has-selection={selected_entry !== null}
1116
- data-has-hover={hover_data !== null}
1117
- data-is-dragging={is_dragging}
1118
- data-rotation-x={camera.rotation_x.toFixed(4)}
1119
- data-rotation-y={camera.rotation_y.toFixed(4)}
1120
- bind:this={wrapper}
1121
- role="application"
1122
- tabindex="-1"
1123
- onkeydown={handle_keydown}
1124
- ondrop={handle_file_drop}
1125
- ondragover={(event) => {
1126
- event.preventDefault()
1127
- drag_over = true
1128
- }}
1129
- ondragleave={(event) => {
1130
- event.preventDefault()
1131
- drag_over = false
1132
- }}
1133
- aria-label="Convex hull visualization"
1134
- >
1135
- {@render children?.({
1136
- stable_entries,
1137
- unstable_entries,
1138
- highlighted_entries,
1139
- selected_entry,
1140
- })}
1141
- <h3 style="position: absolute; left: 1em; top: 1ex; margin: 0">
1142
- {@html sanitize_html(merged_controls.title || phase_stats?.chemical_system || ``)}
1143
- </h3>
1144
-
1145
- <canvas
1146
- bind:this={canvas}
1147
- tabindex="0"
1148
- aria-label={merged_controls.title || phase_stats?.chemical_system || `4D Convex Hull`}
1149
- onmousedown={handle_mouse_down}
1150
- onmousemove={handle_hover}
1151
- onclick={handle_click}
1152
- onkeydown={handle_keydown}
1153
- ondblclick={handle_double_click}
1154
- onwheel={handle_wheel}
1155
- ></canvas>
1156
-
1157
- {#if entries.length === 0}
1158
- <Spinner
1159
- text="Loading data..."
1160
- style="position: absolute; inset: 0; display: flex; align-items: center; justify-content: center"
1161
- />
1162
- {/if}
1163
-
1164
- <!-- Energy above hull Color Bar -->
1165
- {#if color_mode === `energy` && plot_entries.length > 0}
1166
- {@const hull_distances = plot_entries
1167
- .map((entry) => entry.e_above_hull)
1168
- .filter((val): val is number => typeof val === `number`)}
1169
- {@const min_energy = hull_distances.length > 0 ? Math.min(...hull_distances) : 0}
1170
- {@const max_energy = hull_distances.length > 0 ? Math.max(...hull_distances, 0.1) : 0.1}
1171
- <ColorBar
1172
- title="Energy above hull (eV/atom)"
1173
- range={[min_energy, max_energy]}
1174
- {color_scale}
1175
- wrapper_style="position: absolute; bottom: 2em; left: 1em; width: 200px;"
1176
- bar_style="height: 12px;"
1177
- title_style="margin-bottom: 4px;"
1178
- />
1179
- {/if}
1180
-
1181
- <!-- Control buttons (top-right corner like Structure.svelte) -->
1182
- {#if controls_config.mode !== `never`}
1183
- <section class="control-buttons {controls_config.class}">
1184
- {#if controls_config.visible(`reset`)}
1185
- <button
1186
- type="button"
1187
- onclick={reset_all}
1188
- title="Reset camera view (R key)"
1189
- class="reset-camera-btn"
1190
- >
1191
- <Icon icon="Reset" />
1192
- </button>
1193
- {/if}
1194
-
1195
- {#if enable_info_pane && phase_stats && controls_config.visible(`info-pane`)}
1196
- <ConvexHullInfoPane
1197
- bind:pane_open={info_pane_open}
1198
- {phase_stats}
1199
- {stable_entries}
1200
- {unstable_entries}
1201
- {max_hull_dist_show_phases}
1202
- {max_hull_dist_show_labels}
1203
- {label_threshold}
1204
- toggle_props={{ class: `info-btn` }}
1205
- />
1206
- {/if}
1207
-
1208
- {#if enable_fullscreen && controls_config.visible(`fullscreen`)}
1209
- <button
1210
- type="button"
1211
- onclick={() => toggle_fullscreen(wrapper)}
1212
- title="{fullscreen ? `Exit` : `Enter`} fullscreen"
1213
- class="fullscreen-btn"
1214
- >
1215
- <Icon icon="{fullscreen ? `Exit` : ``}Fullscreen" />
1216
- </button>
1217
- {/if}
1218
-
1219
- <!-- Legend controls pane -->
1220
- {#if controls_config.visible(`controls`)}
1221
- <ConvexHullControls
1222
- bind:controls_open={legend_pane_open}
1223
- bind:color_mode
1224
- bind:color_scale
1225
- bind:show_stable
1226
- bind:show_unstable
1227
- bind:show_stable_labels
1228
- bind:show_unstable_labels
1229
- bind:max_hull_dist_show_phases
1230
- bind:max_hull_dist_show_labels
1231
- {max_hull_dist_in_data}
1232
- {stable_entries}
1233
- {unstable_entries}
1234
- {camera}
1235
- {merged_controls}
1236
- toggle_props={{ class: `legend-controls-btn` }}
1237
- {show_hull_faces}
1238
- on_hull_faces_change={(value) => show_hull_faces = value}
1239
- {hull_face_color}
1240
- on_hull_face_color_change={(value) => hull_face_color = value}
1241
- {hull_face_opacity}
1242
- on_hull_face_opacity_change={(value) => hull_face_opacity = value}
1243
- {hull_face_color_mode}
1244
- on_hull_face_color_mode_change={(value) => hull_face_color_mode = value}
1245
- bind:energy_source_mode
1246
- {has_precomputed_e_form}
1247
- {can_compute_e_form}
1248
- {has_precomputed_hull}
1249
- {can_compute_hull}
1250
- />
1251
- {/if}
1252
- </section>
1253
- {/if}
1254
-
1255
- {#if has_temp_data && temperature !== undefined}
1256
- <TemperatureSlider {available_temperatures} bind:temperature />
1257
- {/if}
1258
-
1259
- {#if gas_analysis.has_gas_dependent_elements && merged_gas_config}
1260
- <GasPressureControls
1261
- config={merged_gas_config}
1262
- bind:pressures={gas_pressures}
1263
- temperature={temperature ?? 300}
1264
- />
1265
- {/if}
1266
-
1267
- <!-- Hover tooltip -->
1268
- {#if hover_data}
1269
- {@const { entry, position } = hover_data}
1270
- {@const entry_highlight = is_highlighted(entry) ? merged_highlight_style : undefined}
1271
- {@const tooltip_style =
1272
- `z-index: ${CONVEX_HULL_STYLE.z_index.tooltip}; backdrop-filter: blur(4px);
1273
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);`}
1274
- <PlotTooltip
1275
- x={position.x}
1276
- y={position.y}
1277
- offset={{ x: 10, y: -10 }}
1278
- bg_color={get_point_color(entry)}
1279
- fixed
1280
- style={tooltip_style}
1281
- >
1282
- <ConvexHullTooltip
1283
- {entry}
1284
- {polymorph_stats_map}
1285
- highlight_style={entry_highlight}
1286
- {tooltip}
1287
- />
1288
- </PlotTooltip>
1289
- {/if}
1290
-
1291
- <!-- Copy-to-clipboard feedback (double-click on point) -->
1292
- <ClickFeedback bind:visible={copy_feedback.visible} position={copy_feedback.position} />
1293
-
1294
- <!-- Drag over overlay -->
1295
- <DragOverlay visible={drag_over} />
1296
-
1297
- {#if modal_open && selected_structure}
1298
- <StructurePopup
1299
- structure={selected_structure}
1300
- place_right={modal_place_right}
1301
- stats={{
1302
- id: selected_entry?.entry_id,
1303
- e_above_hull: selected_entry?.e_above_hull,
1304
- e_form: selected_entry?.e_form_per_atom,
1305
- }}
1306
- onclose={close_structure_popup}
1307
- />
1308
- {/if}
1309
- </div>
1310
-
1311
- <style>
1312
- .convex-hull-4d {
1313
- position: relative;
1314
- container-type: size; /* enable cqh/cqw for responsive sizing */
1315
- width: 100%;
1316
- height: var(--hull-height, 500px);
1317
- background: var(--hull-4d-bg, var(--hull-bg));
1318
- border-radius: var(--hull-border-radius, var(--border-radius, 3pt));
1319
- }
1320
- .convex-hull-4d:fullscreen {
1321
- border-radius: 0;
1322
- background: var(--hull-4d-bg-fullscreen, var(--hull-4d-bg, var(--hull-bg)));
1323
- overflow: hidden;
1324
- }
1325
- .convex-hull-4d.dragover {
1326
- border: 2px dashed var(--accent-color, #1976d2);
1327
- }
1328
- canvas {
1329
- width: 100%;
1330
- height: 100%;
1331
- cursor: grab;
1332
- }
1333
- canvas:active {
1334
- cursor: grabbing;
1335
- }
1336
- .control-buttons {
1337
- position: absolute;
1338
- top: 1ex;
1339
- right: 1ex;
1340
- display: flex;
1341
- gap: 8px;
1342
- transition: opacity 0.2s ease-in-out;
1343
- }
1344
- .control-buttons.hover-visible {
1345
- opacity: 0;
1346
- pointer-events: none;
1347
- }
1348
- .convex-hull-4d:hover .control-buttons.hover-visible,
1349
- .convex-hull-4d:focus-within .control-buttons.hover-visible {
1350
- opacity: 1;
1351
- pointer-events: auto;
1352
- }
1353
- .control-buttons.always-visible {
1354
- opacity: 1;
1355
- pointer-events: auto;
1356
- }
1357
- .control-buttons :global(.draggable-pane) {
1358
- z-index: 1001 !important;
1359
- }
1360
- .control-buttons :global(button) {
1361
- background: transparent;
1362
- border: none;
1363
- padding: 4px;
1364
- cursor: pointer;
1365
- border-radius: 3px;
1366
- color: var(--text-color, currentColor);
1367
- transition: background-color 0.2s;
1368
- display: flex;
1369
- font-size: clamp(0.85em, 2cqmin, 1.3em);
1370
- }
1371
- .control-buttons :global(button):hover {
1372
- background-color: color-mix(in srgb, currentColor 8%, transparent);
1373
- }
1374
- </style>