matterviz 0.4.0 → 0.4.2
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.
- package/dist/EmptyState.svelte +10 -4
- package/dist/FilePicker.svelte +12 -14
- package/dist/Icon.svelte +7 -4
- package/dist/MillerIndexInput.svelte +2 -2
- package/dist/app.css +53 -0
- package/dist/brillouin/BrillouinZone.svelte +132 -219
- package/dist/brillouin/BrillouinZone.svelte.d.ts +9 -20
- package/dist/brillouin/BrillouinZoneControls.svelte +3 -6
- package/dist/brillouin/BrillouinZoneExportPane.svelte +47 -96
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +15 -42
- package/dist/brillouin/BrillouinZoneInfoPane.svelte.d.ts +2 -3
- package/dist/brillouin/BrillouinZoneScene.svelte +63 -230
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +3 -23
- package/dist/brillouin/ReciprocalVectors.svelte +39 -0
- package/dist/brillouin/ReciprocalVectors.svelte.d.ts +9 -0
- package/dist/brillouin/compute.d.ts +2 -0
- package/dist/brillouin/compute.js +80 -77
- package/dist/brillouin/geometry.d.ts +8 -0
- package/dist/brillouin/geometry.js +57 -0
- package/dist/brillouin/index.d.ts +2 -0
- package/dist/brillouin/index.js +2 -0
- package/dist/brillouin/types.d.ts +2 -2
- package/dist/chempot-diagram/ChemPotDiagram.svelte +33 -38
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +1 -1
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +143 -246
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +4 -1
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +652 -976
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +7 -1
- package/dist/chempot-diagram/async-compute.svelte.js +1 -1
- package/dist/chempot-diagram/color.d.ts +3 -6
- package/dist/chempot-diagram/color.js +5 -5
- package/dist/chempot-diagram/compute.d.ts +3 -3
- package/dist/chempot-diagram/compute.js +3 -1
- package/dist/chempot-diagram/controls-state.svelte.d.ts +10 -0
- package/dist/chempot-diagram/controls-state.svelte.js +42 -0
- package/dist/chempot-diagram/export.d.ts +47 -0
- package/dist/chempot-diagram/export.js +133 -0
- package/dist/chempot-diagram/index.d.ts +1 -0
- package/dist/chempot-diagram/index.js +1 -0
- package/dist/chempot-diagram/pointer.d.ts +0 -10
- package/dist/chempot-diagram/pointer.js +4 -4
- package/dist/chempot-diagram/types.d.ts +3 -3
- package/dist/colors/index.d.ts +0 -4
- package/dist/colors/index.js +21 -22
- package/dist/composition/BarChart.svelte +37 -31
- package/dist/composition/BubbleChart.svelte +17 -17
- package/dist/composition/Composition.svelte +7 -11
- package/dist/composition/Formula.svelte +18 -25
- package/dist/composition/FormulaFilter.svelte +96 -98
- package/dist/composition/PieChart.svelte +60 -46
- package/dist/composition/chem-sys.js +3 -2
- package/dist/composition/format.js +4 -3
- package/dist/composition/index.d.ts +2 -0
- package/dist/composition/index.js +14 -0
- package/dist/composition/parse.d.ts +2 -3
- package/dist/composition/parse.js +27 -28
- package/dist/constants.js +11 -9
- package/dist/controls.d.ts +1 -0
- package/dist/controls.js +0 -1
- package/dist/convex-hull/ConvexHull.svelte +20 -25
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -4
- package/dist/convex-hull/ConvexHull2D.svelte +176 -256
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +269 -804
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +236 -755
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullChrome.svelte +264 -0
- package/dist/convex-hull/ConvexHullChrome.svelte.d.ts +30 -0
- package/dist/convex-hull/ConvexHullControls.svelte +128 -49
- package/dist/convex-hull/ConvexHullControls.svelte.d.ts +7 -6
- package/dist/convex-hull/ConvexHullInfoPane.svelte +18 -5
- package/dist/convex-hull/ConvexHullInfoPane.svelte.d.ts +6 -5
- package/dist/convex-hull/ConvexHullStats.svelte +210 -351
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +3 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +16 -14
- package/dist/convex-hull/ConvexHullTooltip.svelte.d.ts +2 -1
- package/dist/convex-hull/GasPressureControls.svelte +5 -12
- package/dist/convex-hull/StructurePopup.svelte +17 -21
- package/dist/convex-hull/StructurePopup.svelte.d.ts +2 -0
- package/dist/convex-hull/TemperatureSlider.svelte +4 -10
- package/dist/convex-hull/barycentric-coords.d.ts +2 -4
- package/dist/convex-hull/barycentric-coords.js +6 -33
- package/dist/convex-hull/canvas-interactions.svelte.d.ts +79 -0
- package/dist/convex-hull/canvas-interactions.svelte.js +279 -0
- package/dist/convex-hull/helpers.d.ts +47 -17
- package/dist/convex-hull/helpers.js +186 -101
- package/dist/convex-hull/hull-state.svelte.d.ts +44 -0
- package/dist/convex-hull/hull-state.svelte.js +124 -0
- package/dist/convex-hull/index.d.ts +9 -7
- package/dist/convex-hull/index.js +7 -2
- package/dist/convex-hull/thermodynamics.js +109 -937
- package/dist/convex-hull/types.d.ts +12 -4
- package/dist/convex-hull/types.js +12 -0
- package/dist/coordination/CoordinationBarPlot.svelte +41 -43
- package/dist/coordination/CoordinationBarPlot.svelte.d.ts +1 -1
- package/dist/coordination/calc-coordination.d.ts +1 -1
- package/dist/coordination/calc-coordination.js +28 -25
- package/dist/element/BohrAtom.svelte +6 -8
- package/dist/element/ElementHeading.svelte +4 -1
- package/dist/element/ElementPhoto.svelte +11 -9
- package/dist/element/ElementStats.svelte +12 -10
- package/dist/element/ElementTile.svelte +24 -29
- package/dist/element/ElementTile.svelte.d.ts +1 -1
- package/dist/element/Nucleus.svelte +4 -2
- package/dist/element/data.d.ts +1 -2
- package/dist/element/helpers.d.ts +4 -0
- package/dist/element/helpers.js +18 -0
- package/dist/element/index.d.ts +1 -0
- package/dist/element/index.js +3 -0
- package/dist/feedback/DragOverlay.svelte +5 -3
- package/dist/feedback/DragOverlay.svelte.d.ts +2 -1
- package/dist/feedback/StatusMessage.svelte +20 -7
- package/dist/fermi-surface/FermiSlice.svelte +21 -18
- package/dist/fermi-surface/FermiSurface.svelte +78 -165
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +9 -20
- package/dist/fermi-surface/FermiSurfaceControls.svelte +6 -20
- package/dist/fermi-surface/FermiSurfaceScene.svelte +93 -272
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +3 -23
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +9 -6
- package/dist/fermi-surface/compute.js +14 -13
- package/dist/fermi-surface/export.js +4 -15
- package/dist/fermi-surface/index.d.ts +0 -1
- package/dist/fermi-surface/index.js +0 -1
- package/dist/fermi-surface/parse.d.ts +1 -1
- package/dist/fermi-surface/parse.js +84 -97
- package/dist/fermi-surface/types.d.ts +2 -2
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +161 -185
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +6 -5
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +12 -9
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +5 -5
- package/dist/heatmap-matrix/index.d.ts +8 -2
- package/dist/icons.d.ts +4 -0
- package/dist/icons.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/io/ExportPane.svelte +170 -0
- package/dist/io/ExportPane.svelte.d.ts +17 -0
- package/dist/io/decompress.d.ts +2 -1
- package/dist/io/decompress.js +22 -36
- package/dist/io/export.d.ts +9 -1
- package/dist/io/export.js +37 -29
- package/dist/io/fetch.d.ts +2 -4
- package/dist/io/fetch.js +0 -11
- package/dist/io/file-drop.d.ts +7 -0
- package/dist/io/file-drop.js +13 -0
- package/dist/io/index.d.ts +1 -0
- package/dist/io/index.js +3 -0
- package/dist/io/is-binary.d.ts +9 -0
- package/dist/io/is-binary.js +45 -1
- package/dist/io/types.d.ts +13 -0
- package/dist/io/url-drop.js +13 -25
- package/dist/isosurface/Isosurface.svelte +17 -23
- package/dist/isosurface/IsosurfaceControls.svelte +37 -42
- package/dist/isosurface/parse-vaspwave.d.ts +3 -0
- package/dist/isosurface/parse-vaspwave.js +138 -0
- package/dist/isosurface/parse.js +50 -48
- package/dist/labels.d.ts +6 -2
- package/dist/labels.js +44 -14
- package/dist/layout/FullscreenButton.svelte +34 -0
- package/dist/layout/FullscreenButton.svelte.d.ts +10 -0
- package/dist/layout/FullscreenToggle.svelte +12 -12
- package/dist/layout/InfoCard.svelte +7 -18
- package/dist/layout/InfoTag.svelte +1 -3
- package/dist/layout/NumberRangeInput.svelte +46 -0
- package/dist/layout/NumberRangeInput.svelte.d.ts +12 -0
- package/dist/layout/PropertyFilter.svelte +2 -6
- package/dist/layout/SettingsSection.svelte +21 -17
- package/dist/layout/SubpageGrid.svelte +3 -1
- package/dist/layout/ViewerChrome.svelte +115 -0
- package/dist/layout/ViewerChrome.svelte.d.ts +18 -0
- package/dist/layout/fullscreen.d.ts +4 -0
- package/dist/layout/fullscreen.js +3 -5
- package/dist/layout/fullscreen.svelte.d.ts +8 -0
- package/dist/layout/fullscreen.svelte.js +36 -0
- package/dist/layout/index.d.ts +4 -0
- package/dist/layout/index.js +4 -0
- package/dist/layout/json-tree/JsonNode.svelte +8 -11
- package/dist/layout/json-tree/JsonTree.svelte +53 -77
- package/dist/layout/json-tree/JsonValue.svelte +7 -15
- package/dist/layout/json-tree/utils.js +14 -23
- package/dist/math.d.ts +9 -3
- package/dist/math.js +37 -21
- package/dist/overlays/ContextMenu.svelte +4 -2
- package/dist/overlays/CopyButton.svelte +11 -5
- package/dist/overlays/DragControlTab.svelte +6 -1
- package/dist/overlays/DraggablePane.svelte +81 -26
- package/dist/overlays/DraggablePane.svelte.d.ts +1 -0
- package/dist/overlays/GlassChip.svelte +30 -0
- package/dist/overlays/GlassChip.svelte.d.ts +8 -0
- package/dist/overlays/InfoPaneCards.svelte +11 -23
- package/dist/overlays/index.d.ts +11 -0
- package/dist/overlays/index.js +26 -0
- package/dist/overlays/portal.d.ts +2 -0
- package/dist/overlays/portal.js +14 -0
- package/dist/periodic-table/PeriodicTable.svelte +115 -146
- package/dist/periodic-table/PeriodicTable.svelte.d.ts +5 -3
- package/dist/periodic-table/PeriodicTableControls.svelte +11 -63
- package/dist/periodic-table/TableInset.svelte +9 -4
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +50 -71
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -8
- package/dist/phase-diagram/PhaseDiagramControls.svelte +73 -96
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +4 -3
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +4 -2
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +2 -3
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +49 -134
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +3 -4
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +54 -58
- package/dist/phase-diagram/TdbInfoPanel.svelte +21 -15
- package/dist/phase-diagram/build-diagram.js +3 -3
- package/dist/phase-diagram/colors.js +1 -1
- package/dist/phase-diagram/diagram-input.d.ts +1 -2
- package/dist/phase-diagram/parse.d.ts +2 -1
- package/dist/phase-diagram/parse.js +15 -15
- package/dist/phase-diagram/svg-to-diagram.js +21 -15
- package/dist/phase-diagram/utils.js +2 -3
- package/dist/plot/bar/BarPlot.svelte +494 -692
- package/dist/plot/bar/BarPlot.svelte.d.ts +9 -15
- package/dist/plot/bar/BarPlotControls.svelte +1 -3
- package/dist/plot/bar/BarPlotControls.svelte.d.ts +5 -7
- package/dist/plot/bar/SpacegroupBarPlot.svelte +31 -37
- package/dist/plot/bar/data.d.ts +5 -4
- package/dist/plot/bar/data.js +2 -1
- package/dist/plot/box/BoxPlot.svelte +361 -439
- package/dist/plot/box/BoxPlot.svelte.d.ts +6 -3
- package/dist/plot/box/BoxPlotControls.svelte.d.ts +1 -1
- package/dist/plot/box/Violin.svelte.d.ts +2 -1
- package/dist/plot/box/box-plot.d.ts +3 -2
- package/dist/plot/box/box-plot.js +6 -3
- package/dist/plot/box/kde.d.ts +2 -1
- package/dist/plot/box/kde.js +4 -4
- package/dist/plot/core/auto-place.d.ts +1 -1
- package/dist/plot/core/auto-place.js +5 -2
- package/dist/plot/core/axis-utils.d.ts +12 -7
- package/dist/plot/core/axis-utils.js +48 -48
- package/dist/plot/core/components/AxisLabel.svelte +82 -20
- package/dist/plot/core/components/AxisLabel.svelte.d.ts +1 -0
- package/dist/plot/core/components/ColorBar.svelte +106 -111
- package/dist/plot/core/components/ColorBar.svelte.d.ts +5 -4
- package/dist/plot/core/components/ColorScaleSelect.svelte +1 -1
- package/dist/plot/core/components/FillArea.svelte +10 -17
- package/dist/plot/core/components/HierarchyControls.svelte +249 -0
- package/dist/plot/{sunburst/SunburstControls.svelte.d.ts → core/components/HierarchyControls.svelte.d.ts} +12 -8
- package/dist/plot/core/components/InteractiveAxisLabel.svelte +1 -1
- package/dist/plot/core/components/InteractiveAxisLabel.svelte.d.ts +1 -1
- package/dist/plot/core/components/Line.svelte +21 -11
- package/dist/plot/core/components/Line.svelte.d.ts +5 -2
- package/dist/plot/core/components/PlotAxis.svelte +42 -18
- package/dist/plot/core/components/PlotAxis.svelte.d.ts +2 -1
- package/dist/plot/core/components/PlotControls.svelte +65 -41
- package/dist/plot/core/components/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/core/components/PlotLegend.svelte +31 -35
- package/dist/plot/core/components/PlotMarginals.svelte +616 -0
- package/dist/plot/core/components/PlotMarginals.svelte.d.ts +15 -0
- package/dist/plot/core/components/PlotTooltip.svelte +1 -1
- package/dist/plot/core/components/PortalSelect.svelte +4 -8
- package/dist/plot/core/components/ReferenceLine.svelte +27 -24
- package/dist/plot/core/components/ReferenceLine3D.svelte +56 -59
- package/dist/plot/core/components/ReferenceLine3D.svelte.d.ts +4 -4
- package/dist/plot/core/components/ReferencePlane.svelte +9 -10
- package/dist/plot/core/components/ReferencePlane.svelte.d.ts +4 -4
- package/dist/plot/core/components/ZeroLines.svelte +4 -8
- package/dist/plot/core/components/ZoomRect.svelte +1 -2
- package/dist/plot/core/components/index.d.ts +1 -0
- package/dist/plot/core/components/index.js +1 -0
- package/dist/plot/core/data-cleaning-signal.d.ts +46 -0
- package/dist/plot/core/data-cleaning-signal.js +467 -0
- package/dist/plot/core/data-cleaning.d.ts +2 -42
- package/dist/plot/core/data-cleaning.js +29 -476
- package/dist/plot/core/data-transform.js +9 -5
- package/dist/plot/core/fill-utils.d.ts +7 -4
- package/dist/plot/core/fill-utils.js +34 -9
- package/dist/plot/core/index.d.ts +1 -0
- package/dist/plot/core/index.js +1 -0
- package/dist/plot/core/interactions.d.ts +5 -1
- package/dist/plot/core/interactions.js +14 -2
- package/dist/plot/core/layout.d.ts +3 -1
- package/dist/plot/core/layout.js +22 -13
- package/dist/plot/core/marginals.d.ts +170 -0
- package/dist/plot/core/marginals.js +436 -0
- package/dist/plot/core/pan-zoom.svelte.d.ts +35 -0
- package/dist/plot/core/pan-zoom.svelte.js +221 -0
- package/dist/plot/core/placed-tween.svelte.d.ts +21 -0
- package/dist/plot/core/placed-tween.svelte.js +68 -0
- package/dist/plot/core/reference-line.d.ts +10 -10
- package/dist/plot/core/reference-line.js +7 -7
- package/dist/plot/core/scales.d.ts +40 -25
- package/dist/plot/core/scales.js +49 -21
- package/dist/plot/core/svg.d.ts +2 -1
- package/dist/plot/core/types/fills.d.ts +101 -0
- package/dist/plot/core/types/fills.js +15 -0
- package/dist/plot/core/types/plot-3d.d.ts +87 -0
- package/dist/plot/core/types/plot-3d.js +4 -0
- package/dist/plot/core/types/reference-lines.d.ts +140 -0
- package/dist/plot/core/types/reference-lines.js +9 -0
- package/dist/plot/core/types.d.ts +47 -331
- package/dist/plot/core/types.js +23 -20
- package/dist/plot/core/utils/hierarchy-chart.d.ts +51 -0
- package/dist/plot/core/utils/hierarchy-chart.js +179 -0
- package/dist/plot/core/utils/hierarchy-labels.d.ts +20 -0
- package/dist/plot/core/utils/hierarchy-labels.js +99 -0
- package/dist/plot/core/utils/label-placement.d.ts +1 -1
- package/dist/plot/core/utils/label-placement.js +5 -5
- package/dist/plot/core/utils.d.ts +2 -1
- package/dist/plot/histogram/Histogram.svelte +373 -631
- package/dist/plot/histogram/Histogram.svelte.d.ts +7 -7
- package/dist/plot/histogram/HistogramControls.svelte +30 -28
- package/dist/plot/histogram/HistogramControls.svelte.d.ts +1 -1
- package/dist/plot/histogram/histogram.d.ts +31 -0
- package/dist/plot/histogram/histogram.js +70 -0
- package/dist/plot/histogram/index.d.ts +1 -0
- package/dist/plot/histogram/index.js +1 -0
- package/dist/plot/index.d.ts +1 -0
- package/dist/plot/index.js +1 -0
- package/dist/plot/sankey/Sankey.svelte +79 -73
- package/dist/plot/sankey/Sankey.svelte.d.ts +3 -3
- package/dist/plot/sankey/SankeyControls.svelte +22 -16
- package/dist/plot/sankey/sankey.js +3 -1
- package/dist/plot/scatter/BinnedScatterPlot.svelte +264 -112
- package/dist/plot/scatter/BinnedScatterPlot.svelte.d.ts +11 -4
- package/dist/plot/scatter/ElementScatter.svelte +4 -1
- package/dist/plot/scatter/ScatterPlot.svelte +623 -821
- package/dist/plot/scatter/ScatterPlot.svelte.d.ts +9 -15
- package/dist/plot/scatter/ScatterPlotControls.svelte +18 -19
- package/dist/plot/scatter/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/scatter/ScatterPoint.svelte +16 -9
- package/dist/plot/scatter/binned-scatter-types.d.ts +6 -12
- package/dist/plot/scatter/binned-scatter-types.js +6 -1
- package/dist/plot/scatter/index.d.ts +1 -1
- package/dist/plot/scatter/scatter-data.d.ts +1 -1
- package/dist/plot/scatter/scatter-data.js +8 -7
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte +40 -60
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte.d.ts +6 -14
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte +17 -15
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte.d.ts +5 -5
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte +232 -234
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte.d.ts +5 -14
- package/dist/plot/scatter-3d/Surface3D.svelte +9 -17
- package/dist/plot/scatter-3d/Surface3D.svelte.d.ts +4 -3
- package/dist/plot/sunburst/Sunburst.svelte +256 -338
- package/dist/plot/sunburst/Sunburst.svelte.d.ts +4 -3
- package/dist/plot/sunburst/index.d.ts +1 -1
- package/dist/plot/sunburst/index.js +2 -1
- package/dist/plot/sunburst/render.d.ts +2 -2
- package/dist/plot/sunburst/render.js +47 -22
- package/dist/plot/sunburst/sunburst.d.ts +5 -1
- package/dist/plot/sunburst/sunburst.js +14 -4
- package/dist/plot/treemap/Treemap.svelte +907 -0
- package/dist/plot/treemap/Treemap.svelte.d.ts +84 -0
- package/dist/plot/treemap/index.d.ts +3 -0
- package/dist/plot/treemap/index.js +4 -0
- package/dist/plot/treemap/treemap.d.ts +26 -0
- package/dist/plot/treemap/treemap.js +99 -0
- package/dist/rdf/RdfPlot.svelte +22 -26
- package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
- package/dist/rdf/calc-rdf.js +4 -8
- package/dist/sanitize.js +14 -3
- package/dist/scene/SceneCamera.svelte +62 -0
- package/dist/scene/SceneCamera.svelte.d.ts +19 -0
- package/dist/scene/bind-renderer.svelte.d.ts +2 -0
- package/dist/scene/bind-renderer.svelte.js +22 -0
- package/dist/scene/index.d.ts +4 -0
- package/dist/scene/index.js +5 -0
- package/dist/scene/props.js +52 -0
- package/dist/scene/types.d.ts +26 -0
- package/dist/scene/types.js +1 -0
- package/dist/settings.d.ts +33 -11
- package/dist/settings.js +136 -51
- package/dist/spectral/Bands.svelte +231 -237
- package/dist/spectral/Bands.svelte.d.ts +3 -2
- package/dist/spectral/BandsAndDos.svelte +29 -29
- package/dist/spectral/BrillouinBandsDos.svelte +21 -29
- package/dist/spectral/Dos.svelte +75 -77
- package/dist/spectral/Dos.svelte.d.ts +2 -1
- package/dist/spectral/helpers.d.ts +9 -9
- package/dist/spectral/helpers.js +66 -70
- package/dist/state.svelte.d.ts +0 -7
- package/dist/state.svelte.js +5 -24
- package/dist/structure/Arrow.svelte +6 -21
- package/dist/structure/ArrowInstances.svelte +160 -0
- package/dist/structure/ArrowInstances.svelte.d.ts +16 -0
- package/dist/structure/AtomLegend.svelte +115 -75
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/Bond.svelte +31 -23
- package/dist/structure/CanvasTooltip.svelte +16 -3
- package/dist/structure/CellSelect.svelte +22 -29
- package/dist/structure/CellSelect.svelte.d.ts +2 -1
- package/dist/structure/Cylinder.svelte +24 -40
- package/dist/structure/InstancedAtoms.svelte +114 -0
- package/dist/structure/InstancedAtoms.svelte.d.ts +15 -0
- package/dist/structure/Lattice.svelte +85 -149
- package/dist/structure/SiteLabels.svelte +122 -0
- package/dist/structure/SiteLabels.svelte.d.ts +18 -0
- package/dist/structure/Structure.svelte +725 -735
- package/dist/structure/Structure.svelte.d.ts +8 -16
- package/dist/structure/StructureCarousel.svelte +630 -0
- package/dist/structure/StructureCarousel.svelte.d.ts +19 -0
- package/dist/structure/StructureControls.svelte +298 -325
- package/dist/structure/StructureControls.svelte.d.ts +5 -3
- package/dist/structure/StructureExportPane.svelte +62 -168
- package/dist/structure/StructureExportPane.svelte.d.ts +4 -5
- package/dist/structure/StructureInfoPane.svelte +77 -69
- package/dist/structure/StructureInfoPane.svelte.d.ts +6 -6
- package/dist/structure/StructureScene.svelte +758 -600
- package/dist/structure/StructureScene.svelte.d.ts +24 -20
- package/dist/structure/StructureViewport.svelte +386 -0
- package/dist/structure/StructureViewport.svelte.d.ts +63 -0
- package/dist/structure/atom-label-placement.d.ts +18 -0
- package/dist/structure/atom-label-placement.js +115 -0
- package/dist/structure/atom-properties.d.ts +3 -1
- package/dist/structure/atom-properties.js +115 -54
- package/dist/structure/bond-order-perception.js +2 -4
- package/dist/structure/bonding.d.ts +12 -2
- package/dist/structure/bonding.js +172 -73
- package/dist/structure/edit-history.d.ts +6 -0
- package/dist/structure/edit-history.js +27 -0
- package/dist/structure/export.d.ts +25 -4
- package/dist/structure/export.js +103 -153
- package/dist/structure/format-detect.d.ts +1 -0
- package/dist/structure/format-detect.js +22 -0
- package/dist/structure/geometry.d.ts +9 -0
- package/dist/structure/geometry.js +27 -0
- package/dist/structure/index.d.ts +18 -1
- package/dist/structure/index.js +15 -2
- package/dist/structure/measure.d.ts +1 -1
- package/dist/structure/measure.js +6 -12
- package/dist/structure/parse.d.ts +5 -3
- package/dist/structure/parse.js +551 -567
- package/dist/structure/partial-occupancy.d.ts +0 -1
- package/dist/structure/partial-occupancy.js +5 -3
- package/dist/structure/pbc.d.ts +1 -1
- package/dist/structure/pbc.js +204 -51
- package/dist/structure/polyhedra.d.ts +40 -0
- package/dist/structure/polyhedra.js +587 -0
- package/dist/structure/site.d.ts +4 -0
- package/dist/structure/site.js +1 -0
- package/dist/structure/supercell.d.ts +1 -2
- package/dist/structure/supercell.js +10 -15
- package/dist/structure/validation.js +5 -6
- package/dist/symmetry/SymmetryElementControls.svelte +69 -0
- package/dist/symmetry/SymmetryElementControls.svelte.d.ts +9 -0
- package/dist/symmetry/SymmetryElements.svelte +350 -0
- package/dist/symmetry/SymmetryElements.svelte.d.ts +24 -0
- package/dist/symmetry/SymmetryStats.svelte +142 -49
- package/dist/symmetry/WyckoffTable.svelte +58 -16
- package/dist/symmetry/WyckoffTable.svelte.d.ts +3 -0
- package/dist/symmetry/cell-transform.js +8 -14
- package/dist/symmetry/index.d.ts +15 -4
- package/dist/symmetry/index.js +308 -81
- package/dist/symmetry/spacegroups.d.ts +5 -1
- package/dist/symmetry/spacegroups.js +18 -3
- package/dist/symmetry/symmetry-elements.d.ts +33 -0
- package/dist/symmetry/symmetry-elements.js +521 -0
- package/dist/symmetry/wyckoff-db.d.ts +9 -0
- package/dist/symmetry/wyckoff-db.js +87 -0
- package/dist/table/HeatmapTable.svelte +1104 -378
- package/dist/table/HeatmapTable.svelte.d.ts +12 -2
- package/dist/table/ToggleMenu.svelte +5 -12
- package/dist/table/index.d.ts +21 -6
- package/dist/table/index.js +34 -21
- package/dist/theme/ThemeControl.svelte +16 -8
- package/dist/theme/index.d.ts +1 -5
- package/dist/theme/index.js +4 -10
- package/dist/theme/themes.mjs +14 -7
- package/dist/tooltip/KCoords.svelte +4 -1
- package/dist/tooltip/TooltipContent.svelte +2 -5
- package/dist/trajectory/Trajectory.svelte +556 -352
- package/dist/trajectory/Trajectory.svelte.d.ts +10 -22
- package/dist/trajectory/TrajectoryError.svelte +11 -8
- package/dist/trajectory/TrajectoryExportPane.svelte +28 -54
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +4 -5
- package/dist/trajectory/TrajectoryInfoPane.svelte +88 -99
- package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +3 -2
- package/dist/trajectory/constants.js +6 -2
- package/dist/trajectory/extract.js +73 -71
- package/dist/trajectory/format-detect.d.ts +0 -1
- package/dist/trajectory/format-detect.js +13 -17
- package/dist/trajectory/frame-reader.d.ts +2 -1
- package/dist/trajectory/frame-reader.js +74 -136
- package/dist/trajectory/helpers.d.ts +12 -2
- package/dist/trajectory/helpers.js +68 -37
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +3 -0
- package/dist/trajectory/parse/ase.d.ts +9 -1
- package/dist/trajectory/parse/ase.js +47 -32
- package/dist/trajectory/parse/diagnostics.d.ts +3 -0
- package/dist/trajectory/parse/diagnostics.js +14 -0
- package/dist/trajectory/parse/h5-utils.d.ts +13 -0
- package/dist/trajectory/parse/h5-utils.js +109 -0
- package/dist/trajectory/parse/hdf5.d.ts +1 -1
- package/dist/trajectory/parse/hdf5.js +116 -106
- package/dist/trajectory/parse/index.d.ts +3 -4
- package/dist/trajectory/parse/index.js +68 -119
- package/dist/trajectory/parse/lammps.d.ts +0 -2
- package/dist/trajectory/parse/lammps.js +14 -16
- package/dist/trajectory/parse/pymatgen.d.ts +2 -0
- package/dist/trajectory/parse/pymatgen.js +74 -0
- package/dist/trajectory/parse/vasp.js +13 -9
- package/dist/trajectory/parse/vaspout-electronic.d.ts +13 -0
- package/dist/trajectory/parse/vaspout-electronic.js +207 -0
- package/dist/trajectory/parse/vaspout-h5.d.ts +5 -0
- package/dist/trajectory/parse/vaspout-h5.js +284 -0
- package/dist/trajectory/parse/xyz.d.ts +9 -21
- package/dist/trajectory/parse/xyz.js +38 -39
- package/dist/trajectory/plotting.d.ts +8 -10
- package/dist/trajectory/plotting.js +102 -127
- package/dist/utils.d.ts +4 -0
- package/dist/utils.js +8 -1
- package/dist/xrd/XrdPlot.svelte +56 -85
- package/dist/xrd/broadening.d.ts +2 -1
- package/dist/xrd/broadening.js +2 -1
- package/dist/xrd/calc-xrd.js +8 -15
- package/dist/xrd/index.d.ts +2 -2
- package/dist/xrd/parse.d.ts +0 -1
- package/dist/xrd/parse.js +56 -73
- package/package.json +77 -36
- package/dist/api/mp.d.ts +0 -6
- package/dist/api/mp.js +0 -22
- package/dist/element/data.json +0 -11864
- package/dist/fermi-surface/marching-cubes.d.ts +0 -2
- package/dist/fermi-surface/marching-cubes.js +0 -2
- package/dist/plot/core/hover-lock.svelte.d.ts +0 -14
- package/dist/plot/core/hover-lock.svelte.js +0 -45
- package/dist/plot/sunburst/SunburstControls.svelte +0 -200
- package/dist/structure/label-placement.d.ts +0 -14
- package/dist/structure/label-placement.js +0 -72
package/dist/spectral/helpers.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Helper utilities for band structure and DOS data processing
|
|
2
2
|
import { SUBSCRIPT_MAP } from '../labels';
|
|
3
|
-
import {
|
|
3
|
+
import { is_plain_object } from '../utils';
|
|
4
|
+
import { euclidean_dist, is_square_matrix } from '../math';
|
|
4
5
|
const is_subscript_key = (key) => key in SUBSCRIPT_MAP;
|
|
5
6
|
// Check if range is a valid [min, max] tuple (strict 2-element array of finite numbers)
|
|
6
7
|
export const is_valid_range = (range) => Array.isArray(range) &&
|
|
@@ -91,7 +92,7 @@ export function pretty_sym_point(symbol) {
|
|
|
91
92
|
.replaceAll(/\\?DELTA/gi, `Δ`)
|
|
92
93
|
.replaceAll(/\\?SIGMA/gi, `Σ`)
|
|
93
94
|
.replaceAll(/\\?LAMBDA/gi, `Λ`)
|
|
94
|
-
.replaceAll(/(
|
|
95
|
+
.replaceAll(/(?<letter>\p{L})(?<num>\d+)/gu, (_, letter, num) => letter +
|
|
95
96
|
num
|
|
96
97
|
.split(``)
|
|
97
98
|
.map((digit) => (is_subscript_key(digit) ? SUBSCRIPT_MAP[digit] : digit))
|
|
@@ -194,33 +195,24 @@ export function convert_frequencies(frequencies, unit = `THz`) {
|
|
|
194
195
|
}
|
|
195
196
|
// Normalize DOS densities according to specified mode.
|
|
196
197
|
export function normalize_densities(densities, freqs_or_energies, mode) {
|
|
197
|
-
if (!mode)
|
|
198
|
-
return densities;
|
|
199
|
-
const normalized = [...densities];
|
|
200
198
|
if (mode === `max`) {
|
|
201
|
-
const max_val = Math.max(...
|
|
202
|
-
|
|
203
|
-
return normalized;
|
|
204
|
-
return normalized.map((dens) => dens / max_val);
|
|
199
|
+
const max_val = Math.max(...densities);
|
|
200
|
+
return max_val === 0 ? densities : densities.map((dens) => dens / max_val);
|
|
205
201
|
}
|
|
206
|
-
|
|
207
|
-
const sum =
|
|
208
|
-
|
|
209
|
-
return normalized;
|
|
210
|
-
return normalized.map((dens) => dens / sum);
|
|
202
|
+
if (mode === `sum`) {
|
|
203
|
+
const sum = densities.reduce((acc, dens) => acc + dens, 0);
|
|
204
|
+
return sum === 0 ? densities : densities.map((dens) => dens / sum);
|
|
211
205
|
}
|
|
212
|
-
|
|
206
|
+
if (mode === `integral`) {
|
|
213
207
|
if (freqs_or_energies.length < 2)
|
|
214
|
-
return
|
|
208
|
+
return densities;
|
|
215
209
|
const bin_width = freqs_or_energies[1] - freqs_or_energies[0];
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
return normalized;
|
|
221
|
-
return normalized.map((dens) => dens / (sum * bin_width));
|
|
210
|
+
const sum = densities.reduce((acc, dens) => acc + dens, 0);
|
|
211
|
+
if (bin_width === 0 || sum === 0)
|
|
212
|
+
return densities;
|
|
213
|
+
return densities.map((dens) => dens / (sum * bin_width));
|
|
222
214
|
}
|
|
223
|
-
return
|
|
215
|
+
return densities;
|
|
224
216
|
}
|
|
225
217
|
// Simple LRU cache for Gaussian smearing results
|
|
226
218
|
// Key: hash of (frequencies, densities, sigma), Value: smeared densities
|
|
@@ -250,26 +242,24 @@ function generate_smearing_cache_key(freqs_or_energies, densities, sigma) {
|
|
|
250
242
|
}
|
|
251
243
|
// Core Gaussian smearing computation (unmemoized)
|
|
252
244
|
function apply_gaussian_smearing_core(freqs_or_energies, densities, sigma) {
|
|
253
|
-
const orig_sum = densities.reduce((acc,
|
|
245
|
+
const orig_sum = densities.reduce((acc, dens) => acc + dens, 0);
|
|
254
246
|
if (sigma <= 0 || orig_sum === 0)
|
|
255
247
|
return densities;
|
|
256
248
|
const smeared = Array(densities.length).fill(0);
|
|
257
|
-
const
|
|
249
|
+
const cutoff = 4 * sigma; // Truncate Gaussian at ±4σ (contribution < 0.01%)
|
|
250
|
+
const inv_two_sigma_sq = 1 / (2 * sigma ** 2);
|
|
258
251
|
for (let idx = 0; idx < freqs_or_energies.length; idx++) {
|
|
259
252
|
const energy = freqs_or_energies[idx];
|
|
260
|
-
const cutoff = truncation_width * sigma;
|
|
261
253
|
for (let jdx = 0; jdx < freqs_or_energies.length; jdx++) {
|
|
262
|
-
const
|
|
263
|
-
const delta = Math.abs(energy - e_j);
|
|
254
|
+
const delta = energy - freqs_or_energies[jdx];
|
|
264
255
|
// Skip points beyond truncation width
|
|
265
|
-
if (delta > cutoff)
|
|
256
|
+
if (Math.abs(delta) > cutoff)
|
|
266
257
|
continue;
|
|
267
|
-
|
|
268
|
-
smeared[idx] += densities[jdx] * gaussian;
|
|
258
|
+
smeared[idx] += densities[jdx] * Math.exp(-(delta ** 2) * inv_two_sigma_sq);
|
|
269
259
|
}
|
|
270
260
|
}
|
|
271
261
|
// Normalize to preserve integral
|
|
272
|
-
const smeared_sum = smeared.reduce((acc,
|
|
262
|
+
const smeared_sum = smeared.reduce((acc, dens) => acc + dens, 0);
|
|
273
263
|
if (smeared_sum === 0)
|
|
274
264
|
return densities;
|
|
275
265
|
const normalization = orig_sum / smeared_sum;
|
|
@@ -491,10 +481,9 @@ function convert_pymatgen_band_structure(pmg) {
|
|
|
491
481
|
},
|
|
492
482
|
};
|
|
493
483
|
}
|
|
494
|
-
export function normalize_band_structure(
|
|
495
|
-
if (!
|
|
484
|
+
export function normalize_band_structure(band_struct) {
|
|
485
|
+
if (!is_plain_object(band_struct))
|
|
496
486
|
return null;
|
|
497
|
-
const band_struct = bs;
|
|
498
487
|
// Check if this is pymatgen format and convert if so
|
|
499
488
|
if (is_pymatgen_format(band_struct)) {
|
|
500
489
|
return convert_pymatgen_band_structure(band_struct);
|
|
@@ -516,27 +505,42 @@ export function normalize_band_structure(bs) {
|
|
|
516
505
|
branch.end_index >= n_qpts ||
|
|
517
506
|
branch.start_index > branch.end_index))
|
|
518
507
|
return null;
|
|
519
|
-
|
|
508
|
+
// Fill required defaults (recip_lattice/labels_dict/nb_bands) not covered above so the cast below is sound
|
|
509
|
+
const recip_lattice = band_struct.recip_lattice;
|
|
510
|
+
const normalized = {
|
|
511
|
+
...band_struct,
|
|
512
|
+
nb_bands: typeof band_struct.nb_bands === `number` ? band_struct.nb_bands : bands.length,
|
|
513
|
+
labels_dict: band_struct.labels_dict ?? {},
|
|
514
|
+
recip_lattice: is_square_matrix(recip_lattice?.matrix, 3)
|
|
515
|
+
? recip_lattice
|
|
516
|
+
: {
|
|
517
|
+
matrix: [
|
|
518
|
+
[1, 0, 0],
|
|
519
|
+
[0, 1, 0],
|
|
520
|
+
[0, 0, 1],
|
|
521
|
+
],
|
|
522
|
+
},
|
|
523
|
+
};
|
|
524
|
+
return normalized;
|
|
520
525
|
}
|
|
521
526
|
// Validate and normalize a DOS object.
|
|
522
527
|
// Supports both matterviz and pymatgen formats.
|
|
523
528
|
// Also auto-detects and converts cm⁻¹ to THz for legacy data (disable with auto_convert_units: false).
|
|
524
529
|
export function normalize_dos(dos, options = {}) {
|
|
525
530
|
const { auto_convert_units = true } = options;
|
|
526
|
-
if (!dos
|
|
531
|
+
if (!is_plain_object(dos))
|
|
527
532
|
return null;
|
|
528
|
-
const dos_obj = dos;
|
|
529
533
|
// Check for pymatgen format (has @class or @module)
|
|
530
|
-
const is_pymatgen = typeof
|
|
531
|
-
const { frequencies, energies, spin_polarized } =
|
|
534
|
+
const is_pymatgen = typeof dos[`@class`] === `string` || typeof dos[`@module`] === `string`;
|
|
535
|
+
const { frequencies, energies, spin_polarized } = dos;
|
|
532
536
|
// Handle densities as either array or dict with spin keys (pymatgen format)
|
|
533
537
|
// Pymatgen stores densities as {1: [...], -1: [...]} or {"Spin.up": [...], ...}
|
|
534
|
-
const spin_channels = extract_spin_channels(
|
|
538
|
+
const spin_channels = extract_spin_channels(dos.densities);
|
|
535
539
|
if (!spin_channels)
|
|
536
540
|
return null;
|
|
537
541
|
const densities = spin_channels.up;
|
|
538
542
|
// Use extracted spin-down or fallback to explicit field (for already-normalized DosData)
|
|
539
|
-
const spin_down_densities = spin_channels.down ??
|
|
543
|
+
const spin_down_densities = spin_channels.down ?? dos.spin_down_densities ?? null;
|
|
540
544
|
if (!Array.isArray(densities))
|
|
541
545
|
return null;
|
|
542
546
|
// Phonon DOS: has frequencies
|
|
@@ -743,13 +747,12 @@ export function find_qpoint_at_rescaled_x(band_struct, rescaled_x, x_positions)
|
|
|
743
747
|
// Returns a dict of label → DosData for each atom or orbital.
|
|
744
748
|
// filter_keys: optional list of keys to include (e.g., ["Fe", "O"] for atoms or ["s", "p", "d"] for orbitals)
|
|
745
749
|
export function extract_pdos(dos, pdos_type, filter_keys) {
|
|
746
|
-
if (!dos
|
|
750
|
+
if (!is_plain_object(dos))
|
|
747
751
|
return null;
|
|
748
|
-
const dos_obj = dos;
|
|
749
752
|
// Get the appropriate projected DOS dict
|
|
750
753
|
const pdos_dict = pdos_type === `atom`
|
|
751
|
-
?
|
|
752
|
-
:
|
|
754
|
+
? dos.atom_dos
|
|
755
|
+
: dos.spd_dos;
|
|
753
756
|
if (!pdos_dict || typeof pdos_dict !== `object`)
|
|
754
757
|
return null;
|
|
755
758
|
const result = {};
|
|
@@ -852,21 +855,15 @@ export function generate_ribbon_path(x_values, y_values, width_values, x_scale_f
|
|
|
852
855
|
// Handles both single objects with an efermi field and dicts of objects.
|
|
853
856
|
// Returns undefined if no valid efermi is found or if the source is empty.
|
|
854
857
|
export function extract_efermi(data) {
|
|
855
|
-
if (!data
|
|
858
|
+
if (!is_plain_object(data))
|
|
856
859
|
return undefined;
|
|
857
|
-
const obj = data;
|
|
858
860
|
// Direct efermi field on the object
|
|
859
|
-
if (
|
|
860
|
-
return
|
|
861
|
+
if (typeof data.efermi === `number`)
|
|
862
|
+
return data.efermi;
|
|
861
863
|
// Dict of objects - try to get efermi from first value
|
|
862
|
-
const
|
|
863
|
-
if (
|
|
864
|
-
return
|
|
865
|
-
const first_val = values[0];
|
|
866
|
-
if (first_val && typeof first_val === `object`) {
|
|
867
|
-
const efermi = first_val.efermi;
|
|
868
|
-
if (typeof efermi === `number`)
|
|
869
|
-
return efermi;
|
|
864
|
+
const first_val = Object.values(data)[0];
|
|
865
|
+
if (is_plain_object(first_val) && typeof first_val.efermi === `number`) {
|
|
866
|
+
return first_val.efermi;
|
|
870
867
|
}
|
|
871
868
|
return undefined;
|
|
872
869
|
}
|
|
@@ -886,18 +883,16 @@ export function negative_fraction(values) {
|
|
|
886
883
|
// Check if raw band structure input has electronic markers (efermi, kpoints, or electronic @class).
|
|
887
884
|
// Must be called on raw input before normalization since these fields aren't preserved.
|
|
888
885
|
function is_electronic_band_struct(bs) {
|
|
889
|
-
if (!bs
|
|
886
|
+
if (!is_plain_object(bs))
|
|
890
887
|
return false;
|
|
891
|
-
const obj = bs;
|
|
892
888
|
// Electronic band structures have efermi field
|
|
893
|
-
if (
|
|
889
|
+
if (typeof bs.efermi === `number`)
|
|
894
890
|
return true;
|
|
895
891
|
// Pymatgen electronic format uses kpoints (not qpoints)
|
|
896
|
-
if (
|
|
892
|
+
if (Array.isArray(bs.kpoints) && bs.kpoints.length > 0)
|
|
897
893
|
return true;
|
|
898
|
-
}
|
|
899
894
|
// Pymatgen @class: BandStructure* but not Phonon*
|
|
900
|
-
const raw_class =
|
|
895
|
+
const raw_class = bs[`@class`];
|
|
901
896
|
const py_class_name = typeof raw_class === `string` ? raw_class : ``;
|
|
902
897
|
if (py_class_name.startsWith(`BandStructure`) && !py_class_name.includes(`Phonon`)) {
|
|
903
898
|
return true;
|
|
@@ -952,7 +947,7 @@ export function compute_frequency_range(band_structs, doses, padding_factor = 0.
|
|
|
952
947
|
}
|
|
953
948
|
}
|
|
954
949
|
}
|
|
955
|
-
const dos_list = doses
|
|
950
|
+
const dos_list = doses && typeof doses === `object`
|
|
956
951
|
? `densities` in doses
|
|
957
952
|
? [normalize_dos(doses)]
|
|
958
953
|
: Object.values(doses).map((dos) => normalize_dos(dos))
|
|
@@ -975,18 +970,19 @@ export function compute_frequency_range(band_structs, doses, padding_factor = 0.
|
|
|
975
970
|
}
|
|
976
971
|
if (!Number.isFinite(min_val) || !Number.isFinite(max_val))
|
|
977
972
|
return undefined;
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
973
|
+
// clamp phonon noise to 0
|
|
974
|
+
if (is_phonon &&
|
|
975
|
+
min_val < 0 &&
|
|
976
|
+
negative_fraction(all_freqs) < IMAGINARY_MODE_NOISE_THRESHOLD) {
|
|
982
977
|
min_val = 0;
|
|
978
|
+
}
|
|
983
979
|
// Calculate padding from (possibly clamped) range for consistency with Bands.svelte
|
|
984
980
|
const padding = (max_val - min_val) * padding_factor;
|
|
985
981
|
return [min_val === 0 ? 0 : min_val - padding, max_val + padding];
|
|
986
982
|
}
|
|
987
983
|
// Parse axis label: "Frequency (THz)" → { name: "Frequency", unit: "THz" }
|
|
988
984
|
function parse_axis_label(label) {
|
|
989
|
-
const match = /^(
|
|
985
|
+
const match = /^(?<name>.+?)\s*\((?<unit>[^)]+)\)$/.exec(label);
|
|
990
986
|
return match ? { name: match[1], unit: match[2] } : { name: label };
|
|
991
987
|
}
|
|
992
988
|
const format_tooltip_line = (name, value, unit) => `${name}: ${value}${unit ? ` ${unit}` : ``}`;
|
package/dist/state.svelte.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ChemicalElement, ElementCategory } from './element/types';
|
|
2
2
|
import { DEFAULT_CATEGORY_COLORS, default_element_colors } from './colors';
|
|
3
|
-
import type { Tooltip } from './plot';
|
|
4
3
|
import { type ThemeMode, type ThemeType } from './theme';
|
|
5
4
|
export declare const selected: {
|
|
6
5
|
category: ElementCategory | null;
|
|
@@ -12,12 +11,6 @@ export declare const colors: {
|
|
|
12
11
|
category: typeof DEFAULT_CATEGORY_COLORS;
|
|
13
12
|
element: typeof default_element_colors;
|
|
14
13
|
};
|
|
15
|
-
export declare const tooltip: Tooltip;
|
|
16
|
-
export declare const periodic_table_state: {
|
|
17
|
-
show_bonding_info: boolean;
|
|
18
|
-
show_oxidation_state: boolean;
|
|
19
|
-
highlighted_elements: string[];
|
|
20
|
-
};
|
|
21
14
|
export declare const theme_state: {
|
|
22
15
|
mode: ThemeMode;
|
|
23
16
|
system_mode: ThemeType;
|
package/dist/state.svelte.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AUTO_THEME, COLOR_THEMES, THEME_TYPE } from './theme/index';
|
|
2
2
|
import { DEFAULT_CATEGORY_COLORS, default_element_colors } from './colors';
|
|
3
|
-
import {
|
|
3
|
+
import { get_theme_preference } from './theme';
|
|
4
4
|
export const selected = $state({
|
|
5
5
|
category: null,
|
|
6
6
|
element: null,
|
|
@@ -11,29 +11,10 @@ export const colors = $state({
|
|
|
11
11
|
category: { ...DEFAULT_CATEGORY_COLORS },
|
|
12
12
|
element: { ...default_element_colors },
|
|
13
13
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
highlighted_elements: [],
|
|
19
|
-
});
|
|
20
|
-
// Theme state with safe initialization
|
|
21
|
-
let initial_theme_mode = AUTO_THEME;
|
|
22
|
-
let initial_system_mode = COLOR_THEMES.light;
|
|
23
|
-
// Safe theme initialization for test environments
|
|
24
|
-
try {
|
|
25
|
-
if (typeof window !== `undefined` && globalThis.localStorage) {
|
|
26
|
-
const saved_theme = localStorage.getItem(`matterviz-theme`) ?? ``;
|
|
27
|
-
initial_theme_mode = is_valid_theme_mode(saved_theme) ? saved_theme : AUTO_THEME;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
initial_theme_mode = AUTO_THEME;
|
|
31
|
-
initial_system_mode = COLOR_THEMES.light;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
// Fallback for test environments or when localStorage is not available
|
|
36
|
-
}
|
|
14
|
+
// Theme state with safe initialization (get_theme_preference handles SSR +
|
|
15
|
+
// missing/invalid localStorage, falling back to AUTO_THEME)
|
|
16
|
+
const initial_theme_mode = get_theme_preference();
|
|
17
|
+
const initial_system_mode = COLOR_THEMES.light;
|
|
37
18
|
export const theme_state = $state({
|
|
38
19
|
mode: initial_theme_mode,
|
|
39
20
|
system_mode: initial_system_mode,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { DEFAULTS } from '../settings'
|
|
5
5
|
import { T } from '@threlte/core'
|
|
6
6
|
import type { ComponentProps } from 'svelte'
|
|
7
|
-
import {
|
|
7
|
+
import { rotation_from_direction } from './geometry'
|
|
8
8
|
|
|
9
9
|
let {
|
|
10
10
|
position,
|
|
@@ -26,37 +26,22 @@
|
|
|
26
26
|
} = $props()
|
|
27
27
|
|
|
28
28
|
const mag = $derived(Math.hypot(...vector))
|
|
29
|
-
const dir = $derived(
|
|
30
|
-
mag > math.EPS ? math.scale(vector, 1 / mag) : ([0, 1, 0] as Vec3),
|
|
31
|
-
)
|
|
29
|
+
const dir = $derived(mag > math.EPS ? math.scale(vector, 1 / mag) : ([0, 1, 0] as Vec3))
|
|
32
30
|
const vec_len = $derived(mag * scale)
|
|
33
31
|
|
|
34
32
|
const head_len = $derived(
|
|
35
33
|
arrow_head_length < 0 ? vec_len * -arrow_head_length : arrow_head_length,
|
|
36
34
|
)
|
|
37
35
|
const shaft_len = $derived(Math.max(0, vec_len - head_len * 0.5))
|
|
38
|
-
const shaft_r = $derived(
|
|
39
|
-
shaft_radius < 0 ? shaft_len * -shaft_radius : shaft_radius,
|
|
40
|
-
)
|
|
36
|
+
const shaft_r = $derived(shaft_radius < 0 ? shaft_len * -shaft_radius : shaft_radius)
|
|
41
37
|
const head_r = $derived(
|
|
42
38
|
arrow_head_radius < 0 ? shaft_len * -arrow_head_radius : arrow_head_radius,
|
|
43
39
|
)
|
|
44
40
|
|
|
45
|
-
const shaft_pos = $derived(
|
|
46
|
-
|
|
47
|
-
)
|
|
48
|
-
const head_pos = $derived(
|
|
49
|
-
math.add(position, math.scale(dir, shaft_len + head_len * 0.5)) as Vec3,
|
|
50
|
-
)
|
|
41
|
+
const shaft_pos = $derived(math.add(position, math.scale(dir, shaft_len * 0.5)))
|
|
42
|
+
const head_pos = $derived(math.add(position, math.scale(dir, shaft_len + head_len * 0.5)))
|
|
51
43
|
|
|
52
|
-
const rotation = $derived
|
|
53
|
-
if (mag < math.EPS) return [0, 0, 0]
|
|
54
|
-
const quat = new Quaternion().setFromUnitVectors(
|
|
55
|
-
new Vector3(0, 1, 0),
|
|
56
|
-
new Vector3(...dir),
|
|
57
|
-
)
|
|
58
|
-
return new Euler().setFromQuaternion(quat).toArray().slice(0, 3) as Vec3
|
|
59
|
-
})
|
|
44
|
+
const rotation = $derived(rotation_from_direction(vector))
|
|
60
45
|
</script>
|
|
61
46
|
|
|
62
47
|
{#if shaft_len > 0.01}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// Instanced arrows (shaft cylinders + head cones) for per-site vector layers
|
|
3
|
+
// (forces, magnetic moments, ...). Replaces one <Arrow> component per site
|
|
4
|
+
// (2 meshes + 2 geometries + 2 materials each) with 2 draw calls per layer.
|
|
5
|
+
// Sizing math mirrors Arrow.svelte so the two render identically.
|
|
6
|
+
import type { Vec3 } from '../math'
|
|
7
|
+
import { EPS } from '../math'
|
|
8
|
+
import { T, useThrelte } from '@threlte/core'
|
|
9
|
+
import { untrack } from 'svelte'
|
|
10
|
+
import type { BufferGeometry } from 'three'
|
|
11
|
+
import {
|
|
12
|
+
Color,
|
|
13
|
+
ConeGeometry,
|
|
14
|
+
CylinderGeometry,
|
|
15
|
+
InstancedMesh,
|
|
16
|
+
Matrix4,
|
|
17
|
+
MeshStandardMaterial,
|
|
18
|
+
Quaternion,
|
|
19
|
+
Vector3,
|
|
20
|
+
} from 'three'
|
|
21
|
+
|
|
22
|
+
type ArrowInstance = {
|
|
23
|
+
position: Vec3
|
|
24
|
+
vector: Vec3
|
|
25
|
+
scale: number
|
|
26
|
+
color: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let {
|
|
30
|
+
arrows,
|
|
31
|
+
shaft_radius,
|
|
32
|
+
arrow_head_radius,
|
|
33
|
+
arrow_head_length,
|
|
34
|
+
}: {
|
|
35
|
+
arrows: ArrowInstance[]
|
|
36
|
+
shaft_radius: number // negative = relative to shaft length
|
|
37
|
+
arrow_head_radius: number // negative = relative to shaft length
|
|
38
|
+
arrow_head_length: number // negative = relative to arrow length
|
|
39
|
+
} = $props()
|
|
40
|
+
|
|
41
|
+
const { invalidate } = useThrelte()
|
|
42
|
+
|
|
43
|
+
// Unit primitives scaled per instance: cylinder radius/length via (x=r, y=len, z=r)
|
|
44
|
+
const shaft_geometry = new CylinderGeometry(1, 1, 1, 12)
|
|
45
|
+
const head_geometry = new ConeGeometry(1, 1, 12)
|
|
46
|
+
const shaft_material = new MeshStandardMaterial()
|
|
47
|
+
const head_material = new MeshStandardMaterial()
|
|
48
|
+
$effect(() => () => {
|
|
49
|
+
shaft_geometry.dispose()
|
|
50
|
+
head_geometry.dispose()
|
|
51
|
+
shaft_material.dispose()
|
|
52
|
+
head_material.dispose()
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const make_mesh = (
|
|
56
|
+
geometry: BufferGeometry,
|
|
57
|
+
material: MeshStandardMaterial,
|
|
58
|
+
count: number,
|
|
59
|
+
): InstancedMesh => {
|
|
60
|
+
const mesh = new InstancedMesh(geometry, material, count)
|
|
61
|
+
mesh.frustumCulled = false
|
|
62
|
+
mesh.raycast = () => undefined // arrows are display-only
|
|
63
|
+
mesh.userData.per_instance_color = true
|
|
64
|
+
return mesh
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Recreate meshes only when the arrow count changes (fixed buffer capacity)
|
|
68
|
+
let shaft_mesh = $state.raw<InstancedMesh | null>(null)
|
|
69
|
+
let head_mesh = $state.raw<InstancedMesh | null>(null)
|
|
70
|
+
$effect(() => {
|
|
71
|
+
const count = arrows.length
|
|
72
|
+
const prev = untrack(() => shaft_mesh)
|
|
73
|
+
if (prev && prev.count === count) return
|
|
74
|
+
prev?.dispose()
|
|
75
|
+
untrack(() => head_mesh)?.dispose()
|
|
76
|
+
if (count === 0) {
|
|
77
|
+
shaft_mesh = null
|
|
78
|
+
head_mesh = null
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
shaft_mesh = make_mesh(shaft_geometry, shaft_material, count)
|
|
82
|
+
head_mesh = make_mesh(head_geometry, head_material, count)
|
|
83
|
+
})
|
|
84
|
+
// Unmount-only cleanup (a cleanup on the effect above would dispose meshes
|
|
85
|
+
// on every re-run, including runs that keep them; cleanups run untracked)
|
|
86
|
+
$effect(() => () => {
|
|
87
|
+
shaft_mesh?.dispose()
|
|
88
|
+
head_mesh?.dispose()
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
const up_axis = new Vector3(0, 1, 0)
|
|
92
|
+
const scratch_dir = new Vector3()
|
|
93
|
+
const scratch_quat = new Quaternion()
|
|
94
|
+
const scratch_pos = new Vector3()
|
|
95
|
+
const scratch_scale = new Vector3()
|
|
96
|
+
const scratch_matrix = new Matrix4()
|
|
97
|
+
const scratch_color = new Color()
|
|
98
|
+
|
|
99
|
+
$effect(() => {
|
|
100
|
+
const shafts = shaft_mesh
|
|
101
|
+
const heads = head_mesh
|
|
102
|
+
if (!shafts || !heads) return
|
|
103
|
+
const limit = Math.min(arrows.length, shafts.count)
|
|
104
|
+
for (let idx = 0; idx < limit; idx++) {
|
|
105
|
+
const { position, vector, scale, color } = arrows[idx]
|
|
106
|
+
const mag = Math.hypot(vector[0], vector[1], vector[2])
|
|
107
|
+
if (mag > EPS) {
|
|
108
|
+
scratch_dir.set(vector[0] / mag, vector[1] / mag, vector[2] / mag)
|
|
109
|
+
scratch_quat.setFromUnitVectors(up_axis, scratch_dir)
|
|
110
|
+
} else {
|
|
111
|
+
scratch_dir.set(0, 1, 0)
|
|
112
|
+
scratch_quat.identity()
|
|
113
|
+
}
|
|
114
|
+
const vec_len = mag * scale
|
|
115
|
+
const head_len = arrow_head_length < 0 ? vec_len * -arrow_head_length : arrow_head_length
|
|
116
|
+
const shaft_len = Math.max(0, vec_len - head_len * 0.5)
|
|
117
|
+
const shaft_r = shaft_radius < 0 ? shaft_len * -shaft_radius : shaft_radius
|
|
118
|
+
const head_r = arrow_head_radius < 0 ? shaft_len * -arrow_head_radius : arrow_head_radius
|
|
119
|
+
|
|
120
|
+
// Shafts shorter than Arrow.svelte's 0.01 render threshold collapse to zero scale
|
|
121
|
+
const draw_shaft = shaft_len > 0.01
|
|
122
|
+
scratch_pos.set(
|
|
123
|
+
position[0] + scratch_dir.x * shaft_len * 0.5,
|
|
124
|
+
position[1] + scratch_dir.y * shaft_len * 0.5,
|
|
125
|
+
position[2] + scratch_dir.z * shaft_len * 0.5,
|
|
126
|
+
)
|
|
127
|
+
scratch_scale.set(
|
|
128
|
+
draw_shaft ? shaft_r : 0,
|
|
129
|
+
draw_shaft ? shaft_len : 0,
|
|
130
|
+
draw_shaft ? shaft_r : 0,
|
|
131
|
+
)
|
|
132
|
+
shafts.setMatrixAt(idx, scratch_matrix.compose(scratch_pos, scratch_quat, scratch_scale))
|
|
133
|
+
|
|
134
|
+
const head_offset = shaft_len + head_len * 0.5
|
|
135
|
+
scratch_pos.set(
|
|
136
|
+
position[0] + scratch_dir.x * head_offset,
|
|
137
|
+
position[1] + scratch_dir.y * head_offset,
|
|
138
|
+
position[2] + scratch_dir.z * head_offset,
|
|
139
|
+
)
|
|
140
|
+
scratch_scale.set(head_r, head_len, head_r)
|
|
141
|
+
heads.setMatrixAt(idx, scratch_matrix.compose(scratch_pos, scratch_quat, scratch_scale))
|
|
142
|
+
|
|
143
|
+
scratch_color.set(color)
|
|
144
|
+
shafts.setColorAt(idx, scratch_color)
|
|
145
|
+
heads.setColorAt(idx, scratch_color)
|
|
146
|
+
}
|
|
147
|
+
for (const mesh of [shafts, heads]) {
|
|
148
|
+
mesh.instanceMatrix.needsUpdate = true
|
|
149
|
+
if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true
|
|
150
|
+
}
|
|
151
|
+
invalidate()
|
|
152
|
+
})
|
|
153
|
+
</script>
|
|
154
|
+
|
|
155
|
+
{#if shaft_mesh}
|
|
156
|
+
<T is={shaft_mesh} />
|
|
157
|
+
{/if}
|
|
158
|
+
{#if head_mesh}
|
|
159
|
+
<T is={head_mesh} />
|
|
160
|
+
{/if}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Vec3 } from '../math';
|
|
2
|
+
type ArrowInstance = {
|
|
3
|
+
position: Vec3;
|
|
4
|
+
vector: Vec3;
|
|
5
|
+
scale: number;
|
|
6
|
+
color: string;
|
|
7
|
+
};
|
|
8
|
+
type $$ComponentProps = {
|
|
9
|
+
arrows: ArrowInstance[];
|
|
10
|
+
shaft_radius: number;
|
|
11
|
+
arrow_head_radius: number;
|
|
12
|
+
arrow_head_length: number;
|
|
13
|
+
};
|
|
14
|
+
declare const ArrowInstances: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
15
|
+
type ArrowInstances = ReturnType<typeof ArrowInstances>;
|
|
16
|
+
export default ArrowInstances;
|