matterviz 0.4.1 → 0.4.3
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 +48 -60
- package/dist/Icon.svelte +7 -4
- package/dist/MillerIndexInput.svelte +2 -2
- package/dist/api/optimade.js +10 -7
- package/dist/app.css +68 -0
- package/dist/brillouin/BrillouinZone.svelte +90 -91
- package/dist/brillouin/BrillouinZone.svelte.d.ts +5 -7
- package/dist/brillouin/BrillouinZoneControls.svelte +3 -6
- package/dist/brillouin/BrillouinZoneExportPane.svelte +18 -14
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +6 -10
- package/dist/brillouin/BrillouinZoneScene.svelte +46 -68
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
- package/dist/brillouin/compute.js +10 -16
- package/dist/brillouin/geometry.js +2 -2
- package/dist/chempot-diagram/ChemPotDiagram.svelte +48 -50
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +61 -169
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +1 -1
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +559 -755
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +1 -1
- package/dist/chempot-diagram/async-compute.svelte.js +13 -14
- package/dist/chempot-diagram/color.d.ts +21 -1
- package/dist/chempot-diagram/color.js +70 -1
- package/dist/chempot-diagram/compute.d.ts +7 -0
- package/dist/chempot-diagram/compute.js +85 -26
- package/dist/chempot-diagram/controls-state.svelte.js +1 -1
- package/dist/chempot-diagram/export.js +1 -6
- package/dist/chempot-diagram/temperature.js +9 -10
- package/dist/colors/index.d.ts +0 -4
- package/dist/colors/index.js +19 -20
- package/dist/composition/BarChart.svelte +30 -26
- package/dist/composition/BubbleChart.svelte +17 -17
- package/dist/composition/Composition.svelte +10 -19
- package/dist/composition/Formula.svelte +20 -27
- package/dist/composition/FormulaFilter.svelte +115 -184
- package/dist/composition/PieChart.svelte +55 -41
- package/dist/composition/format.js +7 -9
- package/dist/composition/index.d.ts +2 -0
- package/dist/composition/index.js +14 -0
- package/dist/composition/parse.d.ts +2 -2
- package/dist/composition/parse.js +61 -115
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +17 -26
- package/dist/convex-hull/ConvexHull.svelte +12 -15
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull2D.svelte +93 -94
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +127 -186
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +131 -180
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullChrome.svelte +36 -40
- package/dist/convex-hull/ConvexHullControls.svelte +46 -48
- package/dist/convex-hull/ConvexHullStats.svelte +193 -195
- package/dist/convex-hull/ConvexHullTooltip.svelte +5 -12
- package/dist/convex-hull/GasPressureControls.svelte +5 -12
- package/dist/convex-hull/StructurePopup.svelte +18 -22
- package/dist/convex-hull/StructurePopup.svelte.d.ts +2 -0
- package/dist/convex-hull/TemperatureSlider.svelte +4 -10
- package/dist/convex-hull/canvas-interactions.svelte.js +2 -1
- package/dist/convex-hull/gas-thermodynamics.js +21 -53
- package/dist/convex-hull/helpers.d.ts +8 -10
- package/dist/convex-hull/helpers.js +37 -43
- package/dist/convex-hull/hull-state.svelte.d.ts +1 -1
- package/dist/convex-hull/thermodynamics.js +37 -44
- package/dist/coordination/CoordinationBarPlot.svelte +49 -53
- 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 +5 -9
- 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 +44 -67
- package/dist/element/Nucleus.svelte +4 -2
- package/dist/element/data.d.ts +3 -2
- package/dist/element/data.js +5 -1
- package/dist/element/helpers.d.ts +4 -0
- package/dist/element/helpers.js +18 -0
- package/dist/element/index.d.ts +2 -5
- package/dist/element/index.js +4 -19
- package/dist/feedback/DragOverlay.svelte +5 -5
- package/dist/feedback/DragOverlay.svelte.d.ts +2 -2
- package/dist/feedback/StatusMessage.svelte +7 -4
- package/dist/fermi-surface/FermiSlice.svelte +21 -18
- package/dist/fermi-surface/FermiSurface.svelte +35 -44
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +7 -13
- package/dist/fermi-surface/FermiSurfaceControls.svelte +6 -20
- package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte +64 -136
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +9 -6
- package/dist/fermi-surface/compute.js +25 -58
- package/dist/fermi-surface/parse.js +54 -88
- package/dist/file-viewer/JsonBrowser.svelte +1043 -0
- package/dist/file-viewer/JsonBrowser.svelte.d.ts +9 -0
- package/dist/file-viewer/PlotPanel.svelte +350 -0
- package/dist/file-viewer/PlotPanel.svelte.d.ts +9 -0
- package/dist/file-viewer/TrajectoryWithDos.svelte +30 -0
- package/dist/file-viewer/TrajectoryWithDos.svelte.d.ts +10 -0
- package/dist/file-viewer/detect.d.ts +11 -0
- package/dist/file-viewer/detect.js +381 -0
- package/dist/file-viewer/eligibility.d.ts +4 -0
- package/dist/file-viewer/eligibility.js +53 -0
- package/dist/file-viewer/host-protocol.d.ts +50 -0
- package/dist/file-viewer/host-transfer.d.ts +25 -0
- package/dist/file-viewer/host-transfer.js +42 -0
- package/dist/file-viewer/index.d.ts +5 -0
- package/dist/file-viewer/index.js +5 -0
- package/dist/file-viewer/main.d.ts +44 -0
- package/dist/file-viewer/main.js +535 -0
- package/dist/file-viewer/parse.d.ts +9 -0
- package/dist/file-viewer/parse.js +170 -0
- package/dist/file-viewer/plot-utils.d.ts +24 -0
- package/dist/file-viewer/plot-utils.js +191 -0
- package/dist/file-viewer/types.d.ts +4 -0
- package/dist/file-viewer/types.js +5 -0
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +153 -219
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +2 -2
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +9 -7
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +1 -1
- package/dist/heatmap-matrix/index.d.ts +5 -0
- package/dist/icons.d.ts +4 -0
- package/dist/icons.js +4 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/io/ExportPane.svelte +11 -7
- package/dist/io/decompress.d.ts +4 -1
- package/dist/io/decompress.js +24 -36
- package/dist/io/export.d.ts +11 -4
- package/dist/io/export.js +75 -19
- package/dist/io/fetch.d.ts +0 -3
- package/dist/io/fetch.js +0 -11
- package/dist/io/file-drop.js +60 -35
- package/dist/io/index.d.ts +0 -1
- package/dist/io/index.js +2 -9
- package/dist/io/is-binary.d.ts +9 -0
- package/dist/io/is-binary.js +45 -1
- package/dist/io/url-drop.d.ts +2 -0
- package/dist/io/url-drop.js +40 -40
- package/dist/isosurface/Isosurface.svelte +700 -215
- package/dist/isosurface/Isosurface.svelte.d.ts +7 -1
- package/dist/isosurface/IsosurfaceControls.svelte +590 -116
- package/dist/isosurface/IsosurfaceControls.svelte.d.ts +1 -1
- package/dist/isosurface/VolumeSlice.svelte +224 -0
- package/dist/isosurface/VolumeSlice.svelte.d.ts +28 -0
- package/dist/isosurface/coloring.d.ts +20 -0
- package/dist/isosurface/coloring.js +118 -0
- package/dist/isosurface/geometry-worker-types.d.ts +38 -0
- package/dist/isosurface/geometry.worker.d.ts +1 -0
- package/dist/isosurface/geometry.worker.js +59 -0
- package/dist/isosurface/grid.d.ts +10 -0
- package/dist/isosurface/grid.js +31 -0
- package/dist/isosurface/index.d.ts +4 -0
- package/dist/isosurface/index.js +4 -0
- package/dist/isosurface/parse-vaspwave.d.ts +3 -0
- package/dist/isosurface/parse-vaspwave.js +138 -0
- package/dist/isosurface/parse.js +6 -6
- package/dist/isosurface/profile.d.ts +12 -0
- package/dist/isosurface/profile.js +19 -0
- package/dist/isosurface/sampling.d.ts +34 -0
- package/dist/isosurface/sampling.js +408 -0
- package/dist/isosurface/slice-rendering.d.ts +13 -0
- package/dist/isosurface/slice-rendering.js +79 -0
- package/dist/isosurface/slice.d.ts +22 -2
- package/dist/isosurface/slice.js +200 -116
- package/dist/isosurface/types.d.ts +24 -1
- package/dist/isosurface/types.js +120 -8
- package/dist/json-path.d.ts +4 -0
- package/dist/json-path.js +89 -0
- package/dist/labels.d.ts +6 -2
- package/dist/labels.js +44 -14
- package/dist/layout/FullscreenButton.svelte +2 -1
- package/dist/layout/FullscreenToggle.svelte +10 -4
- package/dist/layout/InfoCard.svelte +8 -21
- 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 +57 -62
- package/dist/layout/SettingsSection.svelte.d.ts +6 -7
- package/dist/layout/SubpageGrid.svelte +3 -1
- package/dist/layout/ViewerChrome.svelte +16 -11
- package/dist/layout/ViewerChrome.svelte.d.ts +2 -1
- package/dist/layout/fullscreen.js +3 -5
- package/dist/layout/fullscreen.svelte.js +1 -2
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.js +1 -0
- package/dist/layout/json-tree/JsonNode.svelte +22 -59
- package/dist/layout/json-tree/JsonTree.svelte +101 -172
- package/dist/layout/json-tree/JsonValue.svelte +9 -32
- package/dist/layout/json-tree/utils.d.ts +0 -3
- package/dist/layout/json-tree/utils.js +50 -188
- package/dist/marching-cubes.d.ts +8 -1
- package/dist/marching-cubes.js +115 -48
- package/dist/math.d.ts +5 -2
- package/dist/math.js +48 -38
- package/dist/overlays/ContextMenu.svelte +19 -34
- package/dist/overlays/CopyButton.svelte +11 -5
- package/dist/overlays/DragControlTab.svelte +6 -1
- package/dist/overlays/DraggablePane.svelte +110 -74
- package/dist/overlays/DraggablePane.svelte.d.ts +2 -1
- package/dist/overlays/GlassChip.svelte +32 -0
- package/dist/overlays/GlassChip.svelte.d.ts +8 -0
- package/dist/overlays/InfoPaneCards.svelte +11 -23
- package/dist/overlays/index.d.ts +7 -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 +113 -145
- package/dist/periodic-table/PeriodicTable.svelte.d.ts +5 -3
- package/dist/periodic-table/PeriodicTableControls.svelte +37 -115
- package/dist/periodic-table/TableInset.svelte +9 -4
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +68 -105
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -8
- package/dist/phase-diagram/PhaseDiagramControls.svelte +70 -94
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +2 -1
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +12 -12
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +54 -58
- package/dist/phase-diagram/TdbInfoPanel.svelte +21 -15
- package/dist/phase-diagram/build-diagram.js +4 -9
- package/dist/phase-diagram/diagram-input.d.ts +1 -2
- package/dist/phase-diagram/parse.js +15 -15
- package/dist/phase-diagram/svg-to-diagram.js +28 -27
- package/dist/phase-diagram/utils.js +2 -3
- package/dist/plot/bar/BarPlot.svelte +461 -426
- package/dist/plot/bar/BarPlot.svelte.d.ts +2 -0
- package/dist/plot/bar/BarPlotControls.svelte +1 -3
- package/dist/plot/bar/BarPlotControls.svelte.d.ts +4 -6
- package/dist/plot/bar/SpacegroupBarPlot.svelte +46 -77
- package/dist/plot/bar/data.d.ts +5 -4
- package/dist/plot/bar/data.js +2 -1
- package/dist/plot/box/BoxPlot.svelte +322 -226
- package/dist/plot/box/BoxPlot.svelte.d.ts +2 -0
- package/dist/plot/box/Violin.svelte.d.ts +1 -0
- package/dist/plot/box/box-plot.js +1 -1
- package/dist/plot/core/auto-place.d.ts +1 -1
- package/dist/plot/core/auto-place.js +2 -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 +101 -106
- 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 +18 -9
- package/dist/plot/core/components/Line.svelte.d.ts +2 -0
- package/dist/plot/core/components/PlotAxis.svelte +40 -17
- package/dist/plot/core/components/PlotControls.svelte +65 -41
- 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 +54 -57
- package/dist/plot/core/components/ReferencePlane.svelte +7 -8
- 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 +27 -474
- package/dist/plot/core/data-transform.d.ts +1 -2
- package/dist/plot/core/data-transform.js +9 -15
- package/dist/plot/core/fill-utils.d.ts +3 -1
- package/dist/plot/core/fill-utils.js +28 -6
- package/dist/plot/core/index.d.ts +1 -0
- package/dist/plot/core/index.js +1 -0
- package/dist/plot/core/interactions.js +0 -2
- package/dist/plot/core/layout.d.ts +15 -6
- package/dist/plot/core/layout.js +57 -38
- 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 +2 -4
- package/dist/plot/core/pan-zoom.svelte.js +34 -17
- package/dist/plot/core/placed-tween.svelte.d.ts +3 -0
- package/dist/plot/core/placed-tween.svelte.js +68 -21
- package/dist/plot/core/reference-line.js +1 -1
- package/dist/plot/core/scales.d.ts +23 -0
- package/dist/plot/core/scales.js +39 -13
- package/dist/plot/core/svg.js +0 -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 +29 -324
- package/dist/plot/core/types.js +23 -20
- package/dist/plot/core/utils/hierarchy-chart.d.ts +52 -0
- package/dist/plot/core/utils/hierarchy-chart.js +191 -0
- package/dist/plot/core/utils/hierarchy-labels.d.ts +20 -0
- package/dist/plot/core/utils/hierarchy-labels.js +100 -0
- package/dist/plot/core/utils/label-placement.js +2 -2
- package/dist/plot/histogram/Histogram.svelte +314 -340
- package/dist/plot/histogram/Histogram.svelte.d.ts +7 -7
- package/dist/plot/histogram/HistogramControls.svelte +30 -28
- 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 +78 -69
- package/dist/plot/sankey/Sankey.svelte.d.ts +2 -2
- package/dist/plot/sankey/SankeyControls.svelte +22 -16
- package/dist/plot/sankey/sankey.js +13 -9
- package/dist/plot/scatter/BinnedScatterPlot.svelte +311 -141
- package/dist/plot/scatter/BinnedScatterPlot.svelte.d.ts +7 -0
- package/dist/plot/scatter/ElementScatter.svelte +4 -1
- package/dist/plot/scatter/ScatterPlot.svelte +517 -410
- package/dist/plot/scatter/ScatterPlot.svelte.d.ts +2 -0
- 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/adaptive-density.d.ts +1 -1
- package/dist/plot/scatter/adaptive-density.js +36 -20
- package/dist/plot/scatter/binned-scatter-types.d.ts +3 -2
- package/dist/plot/scatter/binned-scatter-types.js +6 -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 +25 -34
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte.d.ts +2 -2
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte +8 -5
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte +113 -116
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte.d.ts +2 -2
- package/dist/plot/scatter-3d/Surface3D.svelte +4 -13
- package/dist/plot/sunburst/Sunburst.svelte +269 -347
- package/dist/plot/sunburst/Sunburst.svelte.d.ts +2 -2
- 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 +10 -3
- package/dist/plot/treemap/Treemap.svelte +1022 -0
- package/dist/plot/treemap/Treemap.svelte.d.ts +90 -0
- package/dist/plot/treemap/index.d.ts +4 -0
- package/dist/plot/treemap/index.js +4 -0
- package/dist/plot/treemap/labels.d.ts +38 -0
- package/dist/plot/treemap/labels.js +80 -0
- package/dist/plot/treemap/treemap.d.ts +28 -0
- package/dist/plot/treemap/treemap.js +102 -0
- package/dist/rdf/RdfPlot.svelte +37 -59
- package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
- package/dist/rdf/calc-rdf.js +63 -52
- package/dist/rdf/index.d.ts +0 -1
- package/dist/sanitize.js +85 -27
- package/dist/scene/SceneCamera.svelte +1 -1
- package/dist/scene/SceneCamera.svelte.d.ts +1 -1
- package/dist/scene/bind-renderer.svelte.js +14 -6
- package/dist/scene/index.d.ts +1 -2
- package/dist/scene/index.js +1 -1
- package/dist/scene/{props.js → props.svelte.js} +15 -1
- package/dist/settings.d.ts +19 -9
- package/dist/settings.js +229 -525
- package/dist/spectral/Bands.svelte +207 -221
- package/dist/spectral/BandsAndDos.svelte +11 -9
- package/dist/spectral/BrillouinBandsDos.svelte +19 -42
- package/dist/spectral/Dos.svelte +92 -93
- package/dist/spectral/helpers.d.ts +3 -3
- package/dist/spectral/helpers.js +65 -140
- package/dist/state.svelte.js +5 -18
- package/dist/structure/Arrow.svelte +5 -18
- package/dist/structure/ArrowInstances.svelte +160 -0
- package/dist/structure/ArrowInstances.svelte.d.ts +16 -0
- package/dist/structure/AtomLegend.svelte +120 -85
- package/dist/structure/AtomLegend.svelte.d.ts +2 -3
- package/dist/structure/Bond.svelte +31 -23
- package/dist/structure/CanvasTooltip.svelte +15 -3
- package/dist/structure/CellSelect.svelte +45 -35
- 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 +636 -504
- package/dist/structure/Structure.svelte.d.ts +4 -2
- package/dist/structure/StructureCarousel.svelte +637 -0
- package/dist/structure/StructureCarousel.svelte.d.ts +19 -0
- package/dist/structure/StructureControls.svelte +165 -425
- package/dist/structure/StructureControls.svelte.d.ts +1 -1
- package/dist/structure/StructureExportPane.svelte +17 -21
- package/dist/structure/StructureInfoPane.svelte +128 -133
- package/dist/structure/StructureInfoPane.svelte.d.ts +1 -1
- package/dist/structure/StructureScene.svelte +535 -578
- package/dist/structure/StructureScene.svelte.d.ts +6 -2
- package/dist/structure/StructureViewport.svelte +451 -0
- package/dist/structure/StructureViewport.svelte.d.ts +65 -0
- package/dist/structure/atom-label-placement.d.ts +16 -12
- package/dist/structure/atom-label-placement.js +70 -37
- package/dist/structure/atom-properties.d.ts +2 -0
- package/dist/structure/atom-properties.js +105 -38
- package/dist/structure/bond-order-perception.js +3 -8
- package/dist/structure/bonding.d.ts +9 -3
- package/dist/structure/bonding.js +95 -46
- package/dist/structure/edit-history.d.ts +6 -0
- package/dist/structure/edit-history.js +27 -0
- package/dist/structure/export.d.ts +1 -0
- package/dist/structure/export.js +89 -105
- package/dist/structure/format-detect.d.ts +1 -0
- package/dist/structure/format-detect.js +20 -0
- package/dist/structure/geometry.d.ts +9 -0
- package/dist/structure/geometry.js +27 -0
- package/dist/structure/index.d.ts +16 -1
- package/dist/structure/index.js +15 -10
- package/dist/structure/measure.d.ts +1 -1
- package/dist/structure/measure.js +6 -12
- package/dist/structure/parse.d.ts +2 -1
- package/dist/structure/parse.js +272 -313
- package/dist/structure/partial-occupancy.js +10 -5
- package/dist/structure/pbc.js +85 -107
- package/dist/structure/polyhedra.d.ts +0 -1
- package/dist/structure/polyhedra.js +7 -21
- package/dist/structure/prop-groups.d.ts +85 -0
- package/dist/structure/prop-groups.js +18 -0
- package/dist/structure/supercell.d.ts +1 -2
- package/dist/structure/supercell.js +7 -13
- package/dist/symmetry/SymmetryElements.svelte +11 -15
- package/dist/symmetry/SymmetryStats.svelte +55 -71
- package/dist/symmetry/WyckoffTable.svelte +10 -28
- package/dist/symmetry/cell-transform.js +6 -14
- package/dist/symmetry/index.d.ts +1 -0
- package/dist/symmetry/index.js +13 -10
- package/dist/symmetry/spacegroups.js +3 -2
- package/dist/table/HeatmapTable.svelte +1142 -447
- package/dist/table/HeatmapTable.svelte.d.ts +12 -2
- package/dist/table/ToggleMenu.svelte +168 -53
- package/dist/table/ToggleMenu.svelte.d.ts +1 -1
- 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/embedded.d.ts +18 -0
- package/dist/theme/embedded.js +206 -0
- package/dist/theme/index.d.ts +5 -5
- package/dist/theme/index.js +5 -12
- package/dist/theme/themes.mjs +44 -66
- package/dist/tooltip/KCoords.svelte +4 -1
- package/dist/tooltip/TooltipContent.svelte +3 -6
- package/dist/tooltip/TooltipContent.svelte.d.ts +1 -1
- package/dist/tooltip/index.d.ts +8 -1
- package/dist/trajectory/Trajectory.svelte +613 -386
- package/dist/trajectory/Trajectory.svelte.d.ts +1 -1
- package/dist/trajectory/TrajectoryError.svelte +12 -74
- package/dist/trajectory/TrajectoryExportPane.svelte +14 -32
- package/dist/trajectory/TrajectoryInfoPane.svelte +127 -164
- package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +2 -1
- package/dist/trajectory/extract.js +61 -49
- package/dist/trajectory/format-detect.d.ts +2 -0
- package/dist/trajectory/format-detect.js +17 -13
- package/dist/trajectory/frame-reader.d.ts +2 -0
- package/dist/trajectory/frame-reader.js +35 -32
- package/dist/trajectory/helpers.d.ts +2 -0
- package/dist/trajectory/helpers.js +34 -56
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +5 -8
- package/dist/trajectory/parse/ase.js +1 -1
- 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 +6 -6
- package/dist/trajectory/parse/index.js +25 -33
- package/dist/trajectory/parse/lammps.js +8 -12
- package/dist/trajectory/parse/vasp.js +10 -7
- 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 +4 -0
- package/dist/trajectory/parse/vaspout-h5.js +281 -0
- package/dist/trajectory/parse/xyz.js +59 -9
- package/dist/trajectory/plotting.d.ts +8 -9
- package/dist/trajectory/plotting.js +113 -64
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +7 -0
- package/dist/xrd/XrdPlot.svelte +79 -118
- package/dist/xrd/broadening.js +2 -1
- package/dist/xrd/calc-xrd.js +24 -62
- package/dist/xrd/parse.d.ts +0 -1
- package/dist/xrd/parse.js +69 -95
- package/package.json +94 -34
- package/readme.md +6 -5
- package/dist/api/mp.d.ts +0 -6
- package/dist/api/mp.js +0 -22
- package/dist/plot/sunburst/SunburstControls.svelte +0 -200
- package/dist/scene/types.d.ts +0 -26
- package/dist/tooltip/types.d.ts +0 -8
- package/dist/trajectory/constants.d.ts +0 -6
- package/dist/trajectory/constants.js +0 -11
- /package/dist/{scene/types.js → file-viewer/host-protocol.js} +0 -0
- /package/dist/{tooltip/types.js → isosurface/geometry-worker-types.js} +0 -0
|
@@ -4,6 +4,6 @@ type $$ComponentProps = {
|
|
|
4
4
|
volumes?: VolumetricData[];
|
|
5
5
|
active_volume_idx?: number;
|
|
6
6
|
};
|
|
7
|
-
declare const IsosurfaceControls: import("svelte").Component<$$ComponentProps, {}, "settings" | "active_volume_idx">;
|
|
7
|
+
declare const IsosurfaceControls: import("svelte").Component<$$ComponentProps, {}, "volumes" | "settings" | "active_volume_idx">;
|
|
8
8
|
type IsosurfaceControls = ReturnType<typeof IsosurfaceControls>;
|
|
9
9
|
export default IsosurfaceControls;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { get_d3_interpolator, type D3InterpolateName } from '../colors'
|
|
3
|
+
import type { Vec2 } from '../math'
|
|
4
|
+
import ColorBar from '../plot/core/components/ColorBar.svelte'
|
|
5
|
+
import { contours as create_contours } from 'd3-contour'
|
|
6
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
7
|
+
import type { SliceResult } from './slice'
|
|
8
|
+
import {
|
|
9
|
+
resolve_contour_thresholds,
|
|
10
|
+
resolve_slice_color_range,
|
|
11
|
+
slice_to_rgba,
|
|
12
|
+
type VolumeSliceMode,
|
|
13
|
+
} from './slice-rendering'
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
slice,
|
|
17
|
+
mode = `both`,
|
|
18
|
+
colormap = `interpolateRdBu`,
|
|
19
|
+
color_range,
|
|
20
|
+
symmetric = `auto`,
|
|
21
|
+
contour_levels = 10,
|
|
22
|
+
contour_color = `currentColor`,
|
|
23
|
+
contour_width = 1,
|
|
24
|
+
flip_y = true,
|
|
25
|
+
show_colorbar = true,
|
|
26
|
+
colorbar_title = `Value`,
|
|
27
|
+
canvas = $bindable(),
|
|
28
|
+
onrender,
|
|
29
|
+
...rest
|
|
30
|
+
}: HTMLAttributes<HTMLDivElement> & {
|
|
31
|
+
slice?: SliceResult | null
|
|
32
|
+
mode?: VolumeSliceMode
|
|
33
|
+
colormap?: D3InterpolateName
|
|
34
|
+
color_range?: Vec2
|
|
35
|
+
symmetric?: boolean | `auto`
|
|
36
|
+
contour_levels?: number | number[]
|
|
37
|
+
contour_color?: string
|
|
38
|
+
contour_width?: number
|
|
39
|
+
flip_y?: boolean
|
|
40
|
+
show_colorbar?: boolean
|
|
41
|
+
colorbar_title?: string
|
|
42
|
+
canvas?: HTMLCanvasElement
|
|
43
|
+
onrender?: (detail: {
|
|
44
|
+
canvas: HTMLCanvasElement
|
|
45
|
+
color_range: Vec2
|
|
46
|
+
contour_thresholds: number[]
|
|
47
|
+
slice: SliceResult
|
|
48
|
+
}) => void
|
|
49
|
+
} = $props()
|
|
50
|
+
|
|
51
|
+
let resolved_color_range = $derived<Vec2>(
|
|
52
|
+
slice ? resolve_slice_color_range(slice, color_range, symmetric) : [0, 1],
|
|
53
|
+
)
|
|
54
|
+
let contour_thresholds = $derived(
|
|
55
|
+
resolve_contour_thresholds(resolved_color_range, contour_levels),
|
|
56
|
+
)
|
|
57
|
+
let colorbar_color_scale = $derived.by(() => {
|
|
58
|
+
const interpolator = get_d3_interpolator(colormap)
|
|
59
|
+
const [range_start, range_end] = resolved_color_range
|
|
60
|
+
const span = range_end - range_start
|
|
61
|
+
return (value: number): string => {
|
|
62
|
+
const normalized =
|
|
63
|
+
span === 0 ? 0.5 : Math.max(0, Math.min(1, (value - range_start) / span))
|
|
64
|
+
return interpolator(normalized)
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
let image_data: ImageData | undefined
|
|
68
|
+
let contour_values = new Float64Array()
|
|
69
|
+
let aspect_ratio = $derived.by(() => {
|
|
70
|
+
if (!slice) return 1
|
|
71
|
+
const u_span = slice.u_range[1] - slice.u_range[0]
|
|
72
|
+
const v_span = slice.v_range[1] - slice.v_range[0]
|
|
73
|
+
return v_span > 0 ? u_span / v_span : 1
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
function clip_to_slice_polygon(
|
|
77
|
+
context: CanvasRenderingContext2D,
|
|
78
|
+
current_slice: SliceResult,
|
|
79
|
+
): void {
|
|
80
|
+
const u_span = current_slice.u_range[1] - current_slice.u_range[0]
|
|
81
|
+
const v_span = current_slice.v_range[1] - current_slice.v_range[0]
|
|
82
|
+
context.beginPath()
|
|
83
|
+
for (let point_idx = 0; point_idx < current_slice.polygon.length; point_idx++) {
|
|
84
|
+
const point = current_slice.polygon[point_idx]
|
|
85
|
+
const pixel_x =
|
|
86
|
+
((point[0] - current_slice.u_range[0]) / u_span) * (current_slice.width - 1) + 0.5
|
|
87
|
+
const sampled_y =
|
|
88
|
+
((point[1] - current_slice.v_range[0]) / v_span) * (current_slice.height - 1) + 0.5
|
|
89
|
+
const pixel_y = flip_y ? current_slice.height - sampled_y : sampled_y
|
|
90
|
+
if (point_idx === 0) context.moveTo(pixel_x, pixel_y)
|
|
91
|
+
else context.lineTo(pixel_x, pixel_y)
|
|
92
|
+
}
|
|
93
|
+
context.closePath()
|
|
94
|
+
context.clip()
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function draw_contours(context: CanvasRenderingContext2D, current_slice: SliceResult): void {
|
|
98
|
+
if (contour_thresholds.length === 0) return
|
|
99
|
+
const threshold_min = contour_thresholds[0]
|
|
100
|
+
const outside_value =
|
|
101
|
+
Math.min(...resolved_color_range, threshold_min) -
|
|
102
|
+
Math.max(
|
|
103
|
+
1,
|
|
104
|
+
Math.abs(threshold_min),
|
|
105
|
+
Math.abs(resolved_color_range[1] - resolved_color_range[0]),
|
|
106
|
+
)
|
|
107
|
+
if (contour_values.length !== current_slice.data.length) {
|
|
108
|
+
contour_values = new Float64Array(current_slice.data.length)
|
|
109
|
+
}
|
|
110
|
+
for (let data_idx = 0; data_idx < current_slice.data.length; data_idx++) {
|
|
111
|
+
const value = current_slice.data[data_idx]
|
|
112
|
+
contour_values[data_idx] =
|
|
113
|
+
current_slice.mask[data_idx] && Number.isFinite(value) ? value : outside_value
|
|
114
|
+
}
|
|
115
|
+
const shapes = create_contours()
|
|
116
|
+
.size([current_slice.width, current_slice.height])
|
|
117
|
+
.thresholds(contour_thresholds)(contour_values as unknown as number[])
|
|
118
|
+
|
|
119
|
+
context.save()
|
|
120
|
+
clip_to_slice_polygon(context, current_slice)
|
|
121
|
+
context.strokeStyle =
|
|
122
|
+
contour_color === `currentColor` && canvas
|
|
123
|
+
? getComputedStyle(canvas).color
|
|
124
|
+
: contour_color
|
|
125
|
+
context.lineWidth = Math.max(0.1, contour_width)
|
|
126
|
+
context.lineJoin = `round`
|
|
127
|
+
for (const shape of shapes) {
|
|
128
|
+
context.beginPath()
|
|
129
|
+
for (const polygon of shape.coordinates) {
|
|
130
|
+
for (const ring of polygon) {
|
|
131
|
+
for (let point_idx = 0; point_idx < ring.length; point_idx++) {
|
|
132
|
+
const [point_x, sampled_y] = ring[point_idx]
|
|
133
|
+
const point_y = flip_y ? current_slice.height - sampled_y : sampled_y
|
|
134
|
+
if (point_idx === 0) context.moveTo(point_x, point_y)
|
|
135
|
+
else context.lineTo(point_x, point_y)
|
|
136
|
+
}
|
|
137
|
+
context.closePath()
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
context.stroke()
|
|
141
|
+
}
|
|
142
|
+
context.restore()
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function render_slice(): void {
|
|
146
|
+
if (!canvas) return
|
|
147
|
+
if (!slice) {
|
|
148
|
+
canvas.getContext(`2d`)?.clearRect(0, 0, canvas.width, canvas.height)
|
|
149
|
+
image_data = undefined
|
|
150
|
+
return
|
|
151
|
+
}
|
|
152
|
+
canvas.width = slice.width
|
|
153
|
+
canvas.height = slice.height
|
|
154
|
+
const context = canvas.getContext(`2d`)
|
|
155
|
+
if (!context) return
|
|
156
|
+
context.clearRect(0, 0, slice.width, slice.height)
|
|
157
|
+
if (mode !== `contours`) {
|
|
158
|
+
if (image_data?.width !== slice.width || image_data?.height !== slice.height) {
|
|
159
|
+
image_data = context.createImageData(slice.width, slice.height)
|
|
160
|
+
}
|
|
161
|
+
slice_to_rgba(slice, colormap, resolved_color_range, {
|
|
162
|
+
flip_y,
|
|
163
|
+
out: image_data.data,
|
|
164
|
+
})
|
|
165
|
+
context.putImageData(image_data, 0, 0)
|
|
166
|
+
}
|
|
167
|
+
if (mode !== `filled`) draw_contours(context, slice)
|
|
168
|
+
onrender?.({
|
|
169
|
+
canvas,
|
|
170
|
+
color_range: resolved_color_range,
|
|
171
|
+
contour_thresholds,
|
|
172
|
+
slice,
|
|
173
|
+
})
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
$effect(render_slice)
|
|
177
|
+
</script>
|
|
178
|
+
|
|
179
|
+
<div {...rest} class={[`volume-slice`, rest.class]}>
|
|
180
|
+
<div class="canvas-wrapper">
|
|
181
|
+
<canvas
|
|
182
|
+
bind:this={canvas}
|
|
183
|
+
aria-label="Volumetric scalar-field slice"
|
|
184
|
+
style:aspect-ratio={aspect_ratio}
|
|
185
|
+
></canvas>
|
|
186
|
+
</div>
|
|
187
|
+
{#if show_colorbar && slice}
|
|
188
|
+
<ColorBar
|
|
189
|
+
title={colorbar_title}
|
|
190
|
+
color_scale={colormap}
|
|
191
|
+
color_scale_fn={colorbar_color_scale}
|
|
192
|
+
color_scale_domain={resolved_color_range}
|
|
193
|
+
range={resolved_color_range}
|
|
194
|
+
tick_labels={5}
|
|
195
|
+
bar_style="width: 100%"
|
|
196
|
+
wrapper_style="width: 100%"
|
|
197
|
+
--cbar-font-size="0.75em"
|
|
198
|
+
--cbar-tick-label-font-weight="normal"
|
|
199
|
+
/>
|
|
200
|
+
{/if}
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
<style>
|
|
204
|
+
.volume-slice {
|
|
205
|
+
display: grid;
|
|
206
|
+
gap: 0.5rem;
|
|
207
|
+
width: 100%;
|
|
208
|
+
}
|
|
209
|
+
.canvas-wrapper {
|
|
210
|
+
display: grid;
|
|
211
|
+
place-items: center;
|
|
212
|
+
min-width: 0;
|
|
213
|
+
}
|
|
214
|
+
canvas {
|
|
215
|
+
display: block;
|
|
216
|
+
width: min(100%, var(--volume-slice-max-width, 600px));
|
|
217
|
+
height: auto;
|
|
218
|
+
max-height: var(--volume-slice-max-height, 600px);
|
|
219
|
+
color: var(--volume-slice-contour-color, currentColor);
|
|
220
|
+
outline: 1px solid var(--border-color, #ccc);
|
|
221
|
+
border-radius: 4px;
|
|
222
|
+
image-rendering: auto;
|
|
223
|
+
}
|
|
224
|
+
</style>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type D3InterpolateName } from '../colors';
|
|
2
|
+
import type { Vec2 } from '../math';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
import type { SliceResult } from './slice';
|
|
5
|
+
import { type VolumeSliceMode } from './slice-rendering';
|
|
6
|
+
type $$ComponentProps = HTMLAttributes<HTMLDivElement> & {
|
|
7
|
+
slice?: SliceResult | null;
|
|
8
|
+
mode?: VolumeSliceMode;
|
|
9
|
+
colormap?: D3InterpolateName;
|
|
10
|
+
color_range?: Vec2;
|
|
11
|
+
symmetric?: boolean | `auto`;
|
|
12
|
+
contour_levels?: number | number[];
|
|
13
|
+
contour_color?: string;
|
|
14
|
+
contour_width?: number;
|
|
15
|
+
flip_y?: boolean;
|
|
16
|
+
show_colorbar?: boolean;
|
|
17
|
+
colorbar_title?: string;
|
|
18
|
+
canvas?: HTMLCanvasElement;
|
|
19
|
+
onrender?: (detail: {
|
|
20
|
+
canvas: HTMLCanvasElement;
|
|
21
|
+
color_range: Vec2;
|
|
22
|
+
contour_thresholds: number[];
|
|
23
|
+
slice: SliceResult;
|
|
24
|
+
}) => void;
|
|
25
|
+
};
|
|
26
|
+
declare const VolumeSlice: import("svelte").Component<$$ComponentProps, {}, "canvas">;
|
|
27
|
+
type VolumeSlice = ReturnType<typeof VolumeSlice>;
|
|
28
|
+
export default VolumeSlice;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { D3InterpolateName } from '../colors';
|
|
2
|
+
import type { Vec2 } from '../math';
|
|
3
|
+
import type { DataRange } from './types';
|
|
4
|
+
export declare const ISO_COLORMAPS: readonly ["interpolateViridis", "interpolatePlasma", "interpolateInferno", "interpolateMagma", "interpolateCividis", "interpolateTurbo", "interpolateRdBu", "interpolateRdYlBu", "interpolateSpectral", "interpolatePiYG", "interpolateBrBG", "interpolatePuOr"];
|
|
5
|
+
export type IsoColormap = (typeof ISO_COLORMAPS)[number];
|
|
6
|
+
export declare const DEFAULT_ISO_COLORMAP: IsoColormap;
|
|
7
|
+
export declare const is_signed_range: (data_range: DataRange) => boolean;
|
|
8
|
+
export interface VertexColorOptions {
|
|
9
|
+
colormap: D3InterpolateName;
|
|
10
|
+
color_range: Vec2;
|
|
11
|
+
fallback_color?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function scalars_to_vertex_colors(scalars: Float32Array, { colormap, color_range, fallback_color }: VertexColorOptions, out?: Float32Array): Float32Array;
|
|
14
|
+
export declare function auto_color_config(data_range: DataRange): {
|
|
15
|
+
colormap: IsoColormap;
|
|
16
|
+
color_range: Vec2;
|
|
17
|
+
};
|
|
18
|
+
export declare function compute_scalar_range(scalar_arrays: Float32Array[], { symmetric }?: {
|
|
19
|
+
symmetric?: boolean;
|
|
20
|
+
}): Vec2;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { get_d3_interpolator } from '../colors';
|
|
2
|
+
import { Color } from 'three';
|
|
3
|
+
// Curated continuous colormaps offered in the isosurface controls UI.
|
|
4
|
+
// Sequential maps for densities/potential magnitudes, diverging for signed fields.
|
|
5
|
+
export const ISO_COLORMAPS = [
|
|
6
|
+
`interpolateViridis`,
|
|
7
|
+
`interpolatePlasma`,
|
|
8
|
+
`interpolateInferno`,
|
|
9
|
+
`interpolateMagma`,
|
|
10
|
+
`interpolateCividis`,
|
|
11
|
+
`interpolateTurbo`,
|
|
12
|
+
`interpolateRdBu`,
|
|
13
|
+
`interpolateRdYlBu`,
|
|
14
|
+
`interpolateSpectral`,
|
|
15
|
+
`interpolatePiYG`,
|
|
16
|
+
`interpolateBrBG`,
|
|
17
|
+
`interpolatePuOr`,
|
|
18
|
+
];
|
|
19
|
+
export const DEFAULT_ISO_COLORMAP = `interpolateViridis`;
|
|
20
|
+
// A field counts as signed when it has significant values of both signs
|
|
21
|
+
// (e.g. ESP, magnetization, orbitals) — drives diverging-colormap defaults.
|
|
22
|
+
export const is_signed_range = (data_range) => data_range.min < -data_range.abs_max * 0.01 && data_range.max > data_range.abs_max * 0.01;
|
|
23
|
+
const LUT_SIZE = 256;
|
|
24
|
+
// LUTs cached per colormap name — building one parses 256 CSS color strings.
|
|
25
|
+
// Private so the mutable cached arrays cannot be corrupted by consumers.
|
|
26
|
+
const lut_cache = new Map();
|
|
27
|
+
// Parse a CSS color to linear-space RGB via Three.js (vertex color attributes
|
|
28
|
+
// are interpreted as Linear-sRGB by the renderer, so sRGB values from d3 must
|
|
29
|
+
// be converted or surfaces render too bright)
|
|
30
|
+
const scratch_color = new Color();
|
|
31
|
+
const parse_linear_rgb = (css_color) => {
|
|
32
|
+
scratch_color.set(css_color);
|
|
33
|
+
return [scratch_color.r, scratch_color.g, scratch_color.b];
|
|
34
|
+
};
|
|
35
|
+
function get_colormap_lut(colormap) {
|
|
36
|
+
const cached = lut_cache.get(colormap);
|
|
37
|
+
if (cached)
|
|
38
|
+
return cached;
|
|
39
|
+
const interpolator = get_d3_interpolator(colormap);
|
|
40
|
+
const lut = new Float32Array(LUT_SIZE * 3);
|
|
41
|
+
for (let idx = 0; idx < LUT_SIZE; idx++) {
|
|
42
|
+
const [red, green, blue] = parse_linear_rgb(interpolator(idx / (LUT_SIZE - 1)));
|
|
43
|
+
lut[idx * 3] = red;
|
|
44
|
+
lut[idx * 3 + 1] = green;
|
|
45
|
+
lut[idx * 3 + 2] = blue;
|
|
46
|
+
}
|
|
47
|
+
lut_cache.set(colormap, lut);
|
|
48
|
+
return lut;
|
|
49
|
+
}
|
|
50
|
+
// Map per-vertex scalars to a flat linear-RGB Float32Array (3 components per
|
|
51
|
+
// vertex) suitable for a Three.js 'color' BufferAttribute. Values outside
|
|
52
|
+
// color_range clamp to the ends of the colormap; non-finite values get
|
|
53
|
+
// fallback_color. Pass an existing array of the right size to fill in place
|
|
54
|
+
// (avoids reallocating GPU-bound buffers on recolor).
|
|
55
|
+
export function scalars_to_vertex_colors(scalars, { colormap, color_range, fallback_color = `#808080` }, out) {
|
|
56
|
+
const lut = get_colormap_lut(colormap);
|
|
57
|
+
const [range_min, range_max] = color_range;
|
|
58
|
+
const span = range_max - range_min;
|
|
59
|
+
const inv_span = span !== 0 ? 1 / span : 0;
|
|
60
|
+
const [fb_r, fb_g, fb_b] = parse_linear_rgb(fallback_color);
|
|
61
|
+
const colors = out?.length === scalars.length * 3 ? out : new Float32Array(scalars.length * 3);
|
|
62
|
+
for (let idx = 0; idx < scalars.length; idx++) {
|
|
63
|
+
const value = scalars[idx];
|
|
64
|
+
if (!Number.isFinite(value)) {
|
|
65
|
+
colors[idx * 3] = fb_r;
|
|
66
|
+
colors[idx * 3 + 1] = fb_g;
|
|
67
|
+
colors[idx * 3 + 2] = fb_b;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
// span === 0 maps everything to the middle of the colormap
|
|
71
|
+
const normalized = span === 0 ? 0.5 : (value - range_min) * inv_span;
|
|
72
|
+
const clamped = normalized < 0 ? 0 : Math.min(1, normalized);
|
|
73
|
+
const lut_idx = Math.round(clamped * (LUT_SIZE - 1)) * 3;
|
|
74
|
+
colors[idx * 3] = lut[lut_idx];
|
|
75
|
+
colors[idx * 3 + 1] = lut[lut_idx + 1];
|
|
76
|
+
colors[idx * 3 + 2] = lut[lut_idx + 2];
|
|
77
|
+
}
|
|
78
|
+
return colors;
|
|
79
|
+
}
|
|
80
|
+
// Suggest a colormap and value range for coloring by a volume with the given
|
|
81
|
+
// data range: signed fields (e.g. ESP, magnetization) get a diverging RdBu map
|
|
82
|
+
// with a symmetric range about zero; non-negative fields get Viridis over [min, max].
|
|
83
|
+
export function auto_color_config(data_range) {
|
|
84
|
+
const { min, max, abs_max } = data_range;
|
|
85
|
+
if (is_signed_range(data_range)) {
|
|
86
|
+
// RdBu with symmetric range: negative → red, positive → blue (ESP convention)
|
|
87
|
+
return { colormap: `interpolateRdBu`, color_range: [-abs_max, abs_max] };
|
|
88
|
+
}
|
|
89
|
+
return { colormap: DEFAULT_ISO_COLORMAP, color_range: [min, max] };
|
|
90
|
+
}
|
|
91
|
+
// Fit a color range to the scalar values actually present on the surface(s),
|
|
92
|
+
// ignoring non-finite (out-of-bounds) markers. This is the default when a layer
|
|
93
|
+
// has no explicit color_range: the whole-volume range is usually dominated by
|
|
94
|
+
// extreme values near nuclei that never appear on the rendered surface.
|
|
95
|
+
// `symmetric` (pass when the source field is signed) forces a range symmetric
|
|
96
|
+
// about zero even when the sampled values happen to be one-signed, so diverging
|
|
97
|
+
// colormaps keep zero at their center.
|
|
98
|
+
export function compute_scalar_range(scalar_arrays, { symmetric = false } = {}) {
|
|
99
|
+
let min = Infinity;
|
|
100
|
+
let max = -Infinity;
|
|
101
|
+
for (const scalars of scalar_arrays) {
|
|
102
|
+
for (const value of scalars) {
|
|
103
|
+
if (!Number.isFinite(value))
|
|
104
|
+
continue;
|
|
105
|
+
if (value < min)
|
|
106
|
+
min = value;
|
|
107
|
+
if (value > max)
|
|
108
|
+
max = value;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (min === Infinity)
|
|
112
|
+
return [0, 1]; // no finite samples
|
|
113
|
+
if (symmetric || (min < 0 && max > 0)) {
|
|
114
|
+
const abs_max = Math.max(Math.abs(min), Math.abs(max));
|
|
115
|
+
return [-abs_max, abs_max];
|
|
116
|
+
}
|
|
117
|
+
return [min, max];
|
|
118
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Matrix3x3, Vec3 } from '../math';
|
|
2
|
+
import type { DisplayRange } from './sampling';
|
|
3
|
+
import type { VolumetricData } from './types';
|
|
4
|
+
export type TransferableVolume = Pick<VolumetricData, `grid_dims` | `lattice` | `origin` | `periodic`> & {
|
|
5
|
+
grid_values: Float64Array;
|
|
6
|
+
};
|
|
7
|
+
export interface GeometryWorkerRequest {
|
|
8
|
+
volumes: {
|
|
9
|
+
token: number;
|
|
10
|
+
volume: TransferableVolume;
|
|
11
|
+
range: DisplayRange | null;
|
|
12
|
+
reference_origin: Vec3;
|
|
13
|
+
surfaces: {
|
|
14
|
+
token: string;
|
|
15
|
+
isovalue: number;
|
|
16
|
+
}[];
|
|
17
|
+
}[];
|
|
18
|
+
}
|
|
19
|
+
interface GeometryWorkerVolumeResult {
|
|
20
|
+
token: number;
|
|
21
|
+
grid_dims: Vec3;
|
|
22
|
+
lattice: Matrix3x3;
|
|
23
|
+
origin: Vec3;
|
|
24
|
+
prepared_values: Float64Array;
|
|
25
|
+
prepare_geometry_ms: number;
|
|
26
|
+
surfaces: {
|
|
27
|
+
token: string;
|
|
28
|
+
positions: Float32Array;
|
|
29
|
+
indices: Uint32Array;
|
|
30
|
+
marching_cubes_ms: number;
|
|
31
|
+
}[];
|
|
32
|
+
}
|
|
33
|
+
export type GeometryWorkerResponse = {
|
|
34
|
+
volumes: GeometryWorkerVolumeResult[];
|
|
35
|
+
} | {
|
|
36
|
+
error: string;
|
|
37
|
+
};
|
|
38
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { marching_cubes_buffers } from '../marching-cubes';
|
|
2
|
+
import { flatten_grid, inflate_grid } from './grid';
|
|
3
|
+
import { prepare_geometry_grid } from './sampling';
|
|
4
|
+
const worker_scope = globalThis;
|
|
5
|
+
const inflate_volume = ({ grid_values, ...metadata }) => ({
|
|
6
|
+
...metadata,
|
|
7
|
+
grid: inflate_grid(grid_values, metadata.grid_dims),
|
|
8
|
+
data_range: { min: 0, max: 0, mean: 0, abs_max: 0 },
|
|
9
|
+
});
|
|
10
|
+
worker_scope.addEventListener(`message`, ({ data: request }) => {
|
|
11
|
+
try {
|
|
12
|
+
const transfer = [];
|
|
13
|
+
const volume_results = [];
|
|
14
|
+
for (const job of request.volumes) {
|
|
15
|
+
const prepare_start = performance.now();
|
|
16
|
+
const volume = inflate_volume(job.volume);
|
|
17
|
+
const { grid, lattice, origin } = prepare_geometry_grid(volume, job.range);
|
|
18
|
+
const { values: prepared_values, dims: grid_dims } = flatten_grid(grid);
|
|
19
|
+
transfer.push(prepared_values.buffer);
|
|
20
|
+
const prepare_geometry_ms = performance.now() - prepare_start;
|
|
21
|
+
const surfaces = job.surfaces.map(({ token, isovalue }) => {
|
|
22
|
+
const marching_start = performance.now();
|
|
23
|
+
const buffers = marching_cubes_buffers(grid, isovalue, lattice, {
|
|
24
|
+
periodic: false,
|
|
25
|
+
interpolate: true,
|
|
26
|
+
centered: false,
|
|
27
|
+
normals: false,
|
|
28
|
+
position_offset: [
|
|
29
|
+
origin[0] - job.reference_origin[0],
|
|
30
|
+
origin[1] - job.reference_origin[1],
|
|
31
|
+
origin[2] - job.reference_origin[2],
|
|
32
|
+
],
|
|
33
|
+
});
|
|
34
|
+
transfer.push(buffers.positions.buffer, buffers.indices.buffer);
|
|
35
|
+
return {
|
|
36
|
+
token,
|
|
37
|
+
positions: buffers.positions,
|
|
38
|
+
indices: buffers.indices,
|
|
39
|
+
marching_cubes_ms: performance.now() - marching_start,
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
volume_results.push({
|
|
43
|
+
token: job.token,
|
|
44
|
+
grid_dims,
|
|
45
|
+
lattice,
|
|
46
|
+
origin,
|
|
47
|
+
prepared_values,
|
|
48
|
+
prepare_geometry_ms,
|
|
49
|
+
surfaces,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
worker_scope.postMessage({ volumes: volume_results }, transfer);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
worker_scope.postMessage({
|
|
56
|
+
error: error instanceof Error ? error.message : String(error),
|
|
57
|
+
}, []);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Vec3 } from '../math';
|
|
2
|
+
interface FlatGrid3D {
|
|
3
|
+
values: Float64Array;
|
|
4
|
+
dims: Vec3;
|
|
5
|
+
}
|
|
6
|
+
export declare const grid_dimensions: (grid: number[][][]) => Vec3;
|
|
7
|
+
export declare const grid_point_count: (grid: number[][][]) => number;
|
|
8
|
+
export declare function flatten_grid(grid: number[][][]): FlatGrid3D;
|
|
9
|
+
export declare function inflate_grid(values: Float64Array, [nx, ny, nz]: Vec3): number[][][];
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const grid_dimensions = (grid) => [
|
|
2
|
+
grid.length,
|
|
3
|
+
grid[0]?.length ?? 0,
|
|
4
|
+
grid[0]?.[0]?.length ?? 0,
|
|
5
|
+
];
|
|
6
|
+
export const grid_point_count = (grid) => grid_dimensions(grid).reduce((product, count) => product * count, 1);
|
|
7
|
+
export function flatten_grid(grid) {
|
|
8
|
+
const dims = grid_dimensions(grid);
|
|
9
|
+
const values = new Float64Array(dims[0] * dims[1] * dims[2]);
|
|
10
|
+
let offset = 0;
|
|
11
|
+
for (const plane of grid) {
|
|
12
|
+
for (const row of plane) {
|
|
13
|
+
values.set(row, offset);
|
|
14
|
+
offset += row.length;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return { values, dims };
|
|
18
|
+
}
|
|
19
|
+
export function inflate_grid(values, [nx, ny, nz]) {
|
|
20
|
+
const grid = Array(nx);
|
|
21
|
+
let offset = 0;
|
|
22
|
+
for (let x_idx = 0; x_idx < nx; x_idx++) {
|
|
23
|
+
const plane = Array(ny);
|
|
24
|
+
for (let y_idx = 0; y_idx < ny; y_idx++) {
|
|
25
|
+
plane[y_idx] = Array.from(values.subarray(offset, offset + nz));
|
|
26
|
+
offset += nz;
|
|
27
|
+
}
|
|
28
|
+
grid[x_idx] = plane;
|
|
29
|
+
}
|
|
30
|
+
return grid;
|
|
31
|
+
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export { default as Isosurface } from './Isosurface.svelte';
|
|
2
2
|
export { default as IsosurfaceControls } from './IsosurfaceControls.svelte';
|
|
3
|
+
export { default as VolumeSlice } from './VolumeSlice.svelte';
|
|
4
|
+
export * from './coloring';
|
|
3
5
|
export * from './parse';
|
|
6
|
+
export * from './sampling';
|
|
4
7
|
export * from './slice';
|
|
8
|
+
export * from './slice-rendering';
|
|
5
9
|
export * from './types';
|
package/dist/isosurface/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// Isosurface visualization module for volumetric data (CHGCAR, .cube files)
|
|
2
2
|
export { default as Isosurface } from './Isosurface.svelte';
|
|
3
3
|
export { default as IsosurfaceControls } from './IsosurfaceControls.svelte';
|
|
4
|
+
export { default as VolumeSlice } from './VolumeSlice.svelte';
|
|
5
|
+
export * from './coloring';
|
|
4
6
|
export * from './parse';
|
|
7
|
+
export * from './sampling';
|
|
5
8
|
export * from './slice';
|
|
9
|
+
export * from './slice-rendering';
|
|
6
10
|
export * from './types';
|