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
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { get_d3_interpolator } from '../colors';
|
|
2
|
+
import { rgb } from 'd3-color';
|
|
3
|
+
const SLICE_LUT_SIZE = 256;
|
|
4
|
+
const MAX_CONTOUR_LEVELS = 256;
|
|
5
|
+
const slice_lut_cache = new Map();
|
|
6
|
+
const get_slice_lut = (colormap) => {
|
|
7
|
+
const cached = slice_lut_cache.get(colormap);
|
|
8
|
+
if (cached)
|
|
9
|
+
return cached;
|
|
10
|
+
const interpolator = get_d3_interpolator(colormap);
|
|
11
|
+
const lut = new Uint8ClampedArray(SLICE_LUT_SIZE * 3);
|
|
12
|
+
for (let color_idx = 0; color_idx < SLICE_LUT_SIZE; color_idx++) {
|
|
13
|
+
const color = rgb(interpolator(color_idx / (SLICE_LUT_SIZE - 1)));
|
|
14
|
+
lut[color_idx * 3] = color.r;
|
|
15
|
+
lut[color_idx * 3 + 1] = color.g;
|
|
16
|
+
lut[color_idx * 3 + 2] = color.b;
|
|
17
|
+
}
|
|
18
|
+
slice_lut_cache.set(colormap, lut);
|
|
19
|
+
return lut;
|
|
20
|
+
};
|
|
21
|
+
/** Resolve an explicit or automatic slice color range. */
|
|
22
|
+
export function resolve_slice_color_range(slice, color_range, symmetric = `auto`) {
|
|
23
|
+
if (color_range)
|
|
24
|
+
return [...color_range];
|
|
25
|
+
if (symmetric === true || (symmetric === `auto` && slice.min < 0 && slice.max > 0)) {
|
|
26
|
+
const abs_max = Math.max(Math.abs(slice.min), Math.abs(slice.max));
|
|
27
|
+
return [-abs_max, abs_max];
|
|
28
|
+
}
|
|
29
|
+
return [slice.min, slice.max];
|
|
30
|
+
}
|
|
31
|
+
/** Convert a sampled slice to browser-sRGB RGBA pixels, preserving its exact mask. */
|
|
32
|
+
export function slice_to_rgba(slice, colormap, color_range, { flip_y = true, out } = {}) {
|
|
33
|
+
const pixels = out?.length === slice.data.length * 4 ? out : new Uint8ClampedArray(slice.data.length * 4);
|
|
34
|
+
const lut = get_slice_lut(colormap);
|
|
35
|
+
const [range_min, range_max] = color_range;
|
|
36
|
+
const span = range_max - range_min;
|
|
37
|
+
const inv_span = span === 0 ? 0 : 1 / span;
|
|
38
|
+
for (let row_idx = 0; row_idx < slice.height; row_idx++) {
|
|
39
|
+
const target_row = flip_y ? slice.height - 1 - row_idx : row_idx;
|
|
40
|
+
for (let col_idx = 0; col_idx < slice.width; col_idx++) {
|
|
41
|
+
const source_idx = row_idx * slice.width + col_idx;
|
|
42
|
+
const pixel_idx = (target_row * slice.width + col_idx) * 4;
|
|
43
|
+
if (!slice.mask[source_idx] || !Number.isFinite(slice.data[source_idx])) {
|
|
44
|
+
pixels[pixel_idx] = 0;
|
|
45
|
+
pixels[pixel_idx + 1] = 0;
|
|
46
|
+
pixels[pixel_idx + 2] = 0;
|
|
47
|
+
pixels[pixel_idx + 3] = 0;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const normalized = span === 0
|
|
51
|
+
? 0.5
|
|
52
|
+
: Math.max(0, Math.min(1, (slice.data[source_idx] - range_min) * inv_span));
|
|
53
|
+
const lut_idx = Math.round(normalized * (SLICE_LUT_SIZE - 1)) * 3;
|
|
54
|
+
pixels[pixel_idx] = lut[lut_idx];
|
|
55
|
+
pixels[pixel_idx + 1] = lut[lut_idx + 1];
|
|
56
|
+
pixels[pixel_idx + 2] = lut[lut_idx + 2];
|
|
57
|
+
pixels[pixel_idx + 3] = 255;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return pixels;
|
|
61
|
+
}
|
|
62
|
+
/** Resolve a contour count or explicit threshold list against a color range. */
|
|
63
|
+
export function resolve_contour_thresholds(color_range, contour_levels) {
|
|
64
|
+
if (Array.isArray(contour_levels)) {
|
|
65
|
+
// Sort before truncating so the cap keeps the lowest thresholds deterministically
|
|
66
|
+
// regardless of input order
|
|
67
|
+
return contour_levels
|
|
68
|
+
.filter(Number.isFinite)
|
|
69
|
+
.sort((left, right) => left - right)
|
|
70
|
+
.slice(0, MAX_CONTOUR_LEVELS);
|
|
71
|
+
}
|
|
72
|
+
const count = Number.isFinite(contour_levels)
|
|
73
|
+
? Math.min(MAX_CONTOUR_LEVELS, Math.max(0, Math.floor(contour_levels)))
|
|
74
|
+
: 0;
|
|
75
|
+
const [range_min, range_max] = color_range;
|
|
76
|
+
if (count === 0 || range_min === range_max)
|
|
77
|
+
return [];
|
|
78
|
+
return Array.from({ length: count }, (_, level_idx) => range_min + ((level_idx + 1) / (count + 1)) * (range_max - range_min)).sort((left, right) => left - right);
|
|
79
|
+
}
|
|
@@ -1,11 +1,31 @@
|
|
|
1
|
-
import type { Vec3 } from '../math';
|
|
1
|
+
import type { Vec2, Vec3 } from '../math';
|
|
2
|
+
import { type DisplayRange } from './sampling';
|
|
2
3
|
import type { VolumetricData } from './types';
|
|
4
|
+
export interface CartesianPlane {
|
|
5
|
+
point: Vec3;
|
|
6
|
+
normal: Vec3;
|
|
7
|
+
up?: Vec3;
|
|
8
|
+
}
|
|
9
|
+
export interface PlaneSliceOptions {
|
|
10
|
+
resolution?: number | Vec2;
|
|
11
|
+
max_pixels?: number;
|
|
12
|
+
fractional_bounds?: DisplayRange;
|
|
13
|
+
}
|
|
3
14
|
export interface SliceResult {
|
|
4
15
|
data: Float64Array;
|
|
16
|
+
mask: Uint8Array;
|
|
5
17
|
width: number;
|
|
6
18
|
height: number;
|
|
7
19
|
min: number;
|
|
8
20
|
max: number;
|
|
21
|
+
point: Vec3;
|
|
22
|
+
normal: Vec3;
|
|
23
|
+
u_axis: Vec3;
|
|
24
|
+
v_axis: Vec3;
|
|
25
|
+
u_range: Vec2;
|
|
26
|
+
v_range: Vec2;
|
|
27
|
+
polygon: Vec2[];
|
|
9
28
|
}
|
|
10
|
-
|
|
29
|
+
/** Sample a scalar volume on an arbitrary absolute Cartesian plane. */
|
|
30
|
+
export declare function sample_plane_slice(volume: VolumetricData, plane: CartesianPlane, options?: PlaneSliceOptions): SliceResult | null;
|
|
11
31
|
export declare function sample_hkl_slice(volume: VolumetricData, miller_indices: Vec3, distance: number, n_points?: number): SliceResult | null;
|
package/dist/isosurface/slice.js
CHANGED
|
@@ -2,56 +2,194 @@
|
|
|
2
2
|
// crystallographic plane defined by Miller indices, using trilinear interpolation.
|
|
3
3
|
import { reciprocal_lattice } from '../brillouin';
|
|
4
4
|
import * as math from '../math';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
5
|
+
import { create_volume_sampler, sanitize_display_range } from './sampling';
|
|
6
|
+
const CELL_EDGES = [
|
|
7
|
+
[0, 1],
|
|
8
|
+
[0, 2],
|
|
9
|
+
[0, 4],
|
|
10
|
+
[1, 3],
|
|
11
|
+
[1, 5],
|
|
12
|
+
[2, 3],
|
|
13
|
+
[2, 6],
|
|
14
|
+
[3, 7],
|
|
15
|
+
[4, 5],
|
|
16
|
+
[4, 6],
|
|
17
|
+
[5, 7],
|
|
18
|
+
[6, 7],
|
|
19
|
+
];
|
|
20
|
+
const PLANE_TOLERANCE = 1e-9;
|
|
21
|
+
const DEFAULT_MAX_PIXELS = 512 * 512;
|
|
22
|
+
const UNIT_CELL_RANGE = [
|
|
23
|
+
[0, 1],
|
|
24
|
+
[0, 1],
|
|
25
|
+
[0, 1],
|
|
26
|
+
];
|
|
27
|
+
const cell_corners = (volume, bounds) => {
|
|
28
|
+
const frac_to_cart = math.create_frac_to_cart(volume.lattice);
|
|
29
|
+
return Array.from({ length: 8 }, (_, corner_idx) => math.add(volume.origin, frac_to_cart([
|
|
30
|
+
bounds[0][corner_idx & 1 ? 1 : 0],
|
|
31
|
+
bounds[1][corner_idx & 2 ? 1 : 0],
|
|
32
|
+
bounds[2][corner_idx & 4 ? 1 : 0],
|
|
33
|
+
])));
|
|
34
|
+
};
|
|
35
|
+
const add_unique_point = (points, point) => {
|
|
36
|
+
if (points.some((existing) => (existing[0] - point[0]) ** 2 +
|
|
37
|
+
(existing[1] - point[1]) ** 2 +
|
|
38
|
+
(existing[2] - point[2]) ** 2 <
|
|
39
|
+
PLANE_TOLERANCE ** 2))
|
|
40
|
+
return;
|
|
41
|
+
points.push(point);
|
|
42
|
+
};
|
|
43
|
+
const plane_basis = (normal, up) => {
|
|
44
|
+
if (!up)
|
|
45
|
+
return math.compute_in_plane_basis(normal);
|
|
46
|
+
const normal_projection = math.dot(up, normal);
|
|
47
|
+
const projected = math.subtract(up, math.scale(normal, normal_projection));
|
|
48
|
+
if (Math.hypot(...projected) < PLANE_TOLERANCE) {
|
|
49
|
+
return math.compute_in_plane_basis(normal);
|
|
22
50
|
}
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
const u_axis = math.normalize_vec(projected);
|
|
52
|
+
return [u_axis, math.cross_3d(normal, u_axis)];
|
|
53
|
+
};
|
|
54
|
+
const intersect_plane_cell = (corners, point, normal, u_axis, v_axis) => {
|
|
55
|
+
const intersections = [];
|
|
56
|
+
for (const [start_idx, end_idx] of CELL_EDGES) {
|
|
57
|
+
const start = corners[start_idx];
|
|
58
|
+
const end = corners[end_idx];
|
|
59
|
+
const start_distance = math.dot(math.subtract(start, point), normal);
|
|
60
|
+
const end_distance = math.dot(math.subtract(end, point), normal);
|
|
61
|
+
if (Math.abs(start_distance) <= PLANE_TOLERANCE)
|
|
62
|
+
add_unique_point(intersections, start);
|
|
63
|
+
if (Math.abs(end_distance) <= PLANE_TOLERANCE)
|
|
64
|
+
add_unique_point(intersections, end);
|
|
65
|
+
if (start_distance * end_distance >= -(PLANE_TOLERANCE ** 2))
|
|
66
|
+
continue;
|
|
67
|
+
const fraction = start_distance / (start_distance - end_distance);
|
|
68
|
+
add_unique_point(intersections, [
|
|
69
|
+
start[0] + fraction * (end[0] - start[0]),
|
|
70
|
+
start[1] + fraction * (end[1] - start[1]),
|
|
71
|
+
start[2] + fraction * (end[2] - start[2]),
|
|
72
|
+
]);
|
|
73
|
+
}
|
|
74
|
+
return math.convex_hull_2d(intersections.map((intersection) => {
|
|
75
|
+
const relative = math.subtract(intersection, point);
|
|
76
|
+
return [math.dot(relative, u_axis), math.dot(relative, v_axis)];
|
|
77
|
+
}), PLANE_TOLERANCE);
|
|
78
|
+
};
|
|
79
|
+
const point_in_convex_polygon = (point, polygon) => {
|
|
80
|
+
let orientation = 0;
|
|
81
|
+
for (let point_idx = 0; point_idx < polygon.length; point_idx++) {
|
|
82
|
+
const start = polygon[point_idx];
|
|
83
|
+
const end = polygon[(point_idx + 1) % polygon.length];
|
|
84
|
+
const cross = (end[0] - start[0]) * (point[1] - start[1]) - (end[1] - start[1]) * (point[0] - start[0]);
|
|
85
|
+
if (Math.abs(cross) <= PLANE_TOLERANCE)
|
|
86
|
+
continue;
|
|
87
|
+
const current_orientation = Math.sign(cross);
|
|
88
|
+
if (orientation && current_orientation !== orientation)
|
|
89
|
+
return false;
|
|
90
|
+
orientation = current_orientation;
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
};
|
|
94
|
+
const resolve_resolution = (resolution, u_span, v_span, max_grid_dim, max_pixels) => {
|
|
95
|
+
let counts;
|
|
96
|
+
if (Array.isArray(resolution)) {
|
|
97
|
+
counts = [Math.max(2, Math.round(resolution[0])), Math.max(2, Math.round(resolution[1]))];
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
const longest_count = Math.max(2, Math.round(resolution ?? max_grid_dim));
|
|
101
|
+
const longest_span = Math.max(u_span, v_span, PLANE_TOLERANCE);
|
|
102
|
+
counts = [
|
|
103
|
+
Math.max(2, Math.round((longest_count * u_span) / longest_span)),
|
|
104
|
+
Math.max(2, Math.round((longest_count * v_span) / longest_span)),
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
const pixel_budget = Number.isFinite(max_pixels)
|
|
108
|
+
? Math.max(4, Math.floor(max_pixels))
|
|
109
|
+
: DEFAULT_MAX_PIXELS;
|
|
110
|
+
const shrink = Math.min(1, Math.sqrt(pixel_budget / (counts[0] * counts[1])));
|
|
111
|
+
if (shrink >= 1)
|
|
112
|
+
return counts;
|
|
113
|
+
counts = counts.map((count) => Math.max(2, Math.floor(count * shrink)));
|
|
114
|
+
if (counts[0] * counts[1] > pixel_budget) {
|
|
115
|
+
const axis = counts[0] >= counts[1] ? 0 : 1;
|
|
116
|
+
counts[axis] = Math.max(2, Math.floor(pixel_budget / counts[axis === 0 ? 1 : 0]));
|
|
117
|
+
}
|
|
118
|
+
return counts;
|
|
119
|
+
};
|
|
120
|
+
/** Sample a scalar volume on an arbitrary absolute Cartesian plane. */
|
|
121
|
+
export function sample_plane_slice(volume, plane, options = {}) {
|
|
122
|
+
if (!plane.point.every(Number.isFinite) || !plane.normal.every(Number.isFinite))
|
|
123
|
+
return null;
|
|
124
|
+
if (plane.up && !plane.up.every(Number.isFinite))
|
|
125
|
+
return null;
|
|
126
|
+
if (Math.hypot(...plane.normal) < PLANE_TOLERANCE)
|
|
127
|
+
return null; // degenerate normal
|
|
128
|
+
const normal = math.normalize_vec(plane.normal);
|
|
129
|
+
// In-plane basis vectors
|
|
130
|
+
const [u_axis, v_axis] = plane_basis(normal, plane.up);
|
|
131
|
+
const bounds = sanitize_display_range(options.fractional_bounds ?? UNIT_CELL_RANGE, volume.periodic);
|
|
132
|
+
const corners = cell_corners(volume, bounds);
|
|
133
|
+
const polygon = intersect_plane_cell(corners, plane.point, normal, u_axis, v_axis);
|
|
134
|
+
if (polygon.length < 3)
|
|
135
|
+
return null;
|
|
136
|
+
// Project all 8 unit cell corners onto the (u, v) plane to find sampling bounds.
|
|
137
|
+
// Corners are at fractional coords (0 or 1) for each axis.
|
|
138
|
+
const { min, max, width: u_span, height: v_span } = math.compute_bounding_box_2d(polygon);
|
|
139
|
+
const u_range = [min[0], max[0]];
|
|
140
|
+
const v_range = [min[1], max[1]];
|
|
141
|
+
if (u_span <= PLANE_TOLERANCE || v_span <= PLANE_TOLERANCE)
|
|
142
|
+
return null;
|
|
143
|
+
// Sampling resolution: caller-specified or default to max grid dimension
|
|
144
|
+
const [width, height] = resolve_resolution(options.resolution, u_span, v_span, Math.max(...volume.grid_dims), options.max_pixels ?? DEFAULT_MAX_PIXELS);
|
|
145
|
+
const data = new Float64Array(width * height);
|
|
146
|
+
data.fill(Number.NaN);
|
|
147
|
+
const mask = new Uint8Array(width * height);
|
|
148
|
+
let data_min = Infinity;
|
|
149
|
+
let data_max = -Infinity;
|
|
150
|
+
const sample = create_volume_sampler(volume, {
|
|
151
|
+
out_of_bounds: volume.periodic ? `clamp` : `fallback`,
|
|
152
|
+
});
|
|
153
|
+
const u_step = u_span / (width - 1);
|
|
154
|
+
const v_step = v_span / (height - 1);
|
|
155
|
+
const cartesian = [0, 0, 0];
|
|
156
|
+
for (let row = 0; row < height; row++) {
|
|
157
|
+
const v_value = v_range[0] + row * v_step;
|
|
158
|
+
for (let col = 0; col < width; col++) {
|
|
159
|
+
const u_value = u_range[0] + col * u_step;
|
|
160
|
+
if (!point_in_convex_polygon([u_value, v_value], polygon))
|
|
161
|
+
continue;
|
|
162
|
+
const data_idx = row * width + col;
|
|
163
|
+
mask[data_idx] = 1;
|
|
164
|
+
// Cartesian position on the plane
|
|
165
|
+
cartesian[0] = plane.point[0] + u_value * u_axis[0] + v_value * v_axis[0];
|
|
166
|
+
cartesian[1] = plane.point[1] + u_value * u_axis[1] + v_value * v_axis[1];
|
|
167
|
+
cartesian[2] = plane.point[2] + u_value * u_axis[2] + v_value * v_axis[2];
|
|
168
|
+
const value = sample(cartesian);
|
|
169
|
+
if (!Number.isFinite(value))
|
|
170
|
+
continue;
|
|
171
|
+
data[data_idx] = value;
|
|
172
|
+
if (value < data_min)
|
|
173
|
+
data_min = value;
|
|
174
|
+
if (value > data_max)
|
|
175
|
+
data_max = value;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
data,
|
|
180
|
+
mask,
|
|
181
|
+
width,
|
|
182
|
+
height,
|
|
183
|
+
min: data_min === Infinity ? 0 : data_min,
|
|
184
|
+
max: data_max === -Infinity ? 0 : data_max,
|
|
185
|
+
point: [...plane.point],
|
|
186
|
+
normal,
|
|
187
|
+
u_axis,
|
|
188
|
+
v_axis,
|
|
189
|
+
u_range,
|
|
190
|
+
v_range,
|
|
191
|
+
polygon,
|
|
192
|
+
};
|
|
55
193
|
}
|
|
56
194
|
// Sample a 2D slice through volumetric data along a Miller-index plane.
|
|
57
195
|
// `miller_indices` [h,k,l] defines the plane normal in reciprocal space.
|
|
@@ -61,81 +199,27 @@ export function sample_hkl_slice(volume, miller_indices, distance, n_points) {
|
|
|
61
199
|
const [h_idx, k_idx, l_idx] = miller_indices;
|
|
62
200
|
if (h_idx === 0 && k_idx === 0 && l_idx === 0)
|
|
63
201
|
return null;
|
|
64
|
-
const { grid, grid_dims, lattice, periodic } = volume;
|
|
65
|
-
const [nx, ny, nz] = grid_dims;
|
|
66
202
|
// Plane normal G = h*b1 + k*b2 + l*b3 where b_i are reciprocal lattice rows
|
|
67
|
-
const recip = reciprocal_lattice(lattice);
|
|
203
|
+
const recip = reciprocal_lattice(volume.lattice);
|
|
68
204
|
const plane_normal = [
|
|
69
205
|
h_idx * recip[0][0] + k_idx * recip[1][0] + l_idx * recip[2][0],
|
|
70
206
|
h_idx * recip[0][1] + k_idx * recip[1][1] + l_idx * recip[2][1],
|
|
71
207
|
h_idx * recip[0][2] + k_idx * recip[1][2] + l_idx * recip[2][2],
|
|
72
208
|
];
|
|
73
|
-
if (Math.hypot(...plane_normal) <
|
|
209
|
+
if (Math.hypot(...plane_normal) < PLANE_TOLERANCE)
|
|
74
210
|
return null; // degenerate normal
|
|
75
211
|
const unit_normal = math.normalize_vec(plane_normal);
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
// Corners are at fractional coords (0 or 1) for each axis.
|
|
81
|
-
let u_min = Infinity;
|
|
82
|
-
let u_max = -Infinity;
|
|
83
|
-
let v_min = Infinity;
|
|
84
|
-
let v_max = -Infinity;
|
|
85
|
-
let normal_min = Infinity;
|
|
86
|
-
let normal_max = -Infinity;
|
|
87
|
-
for (let ci = 0; ci < 8; ci++) {
|
|
88
|
-
const fi = ci & 1 ? 1 : 0;
|
|
89
|
-
const fj = ci & 2 ? 1 : 0;
|
|
90
|
-
const fk = ci & 4 ? 1 : 0;
|
|
91
|
-
// Corner in Cartesian: frac * lattice
|
|
92
|
-
const corner = [
|
|
93
|
-
fi * lattice[0][0] + fj * lattice[1][0] + fk * lattice[2][0],
|
|
94
|
-
fi * lattice[0][1] + fj * lattice[1][1] + fk * lattice[2][1],
|
|
95
|
-
fi * lattice[0][2] + fj * lattice[1][2] + fk * lattice[2][2],
|
|
96
|
-
];
|
|
97
|
-
const u_proj = math.dot(corner, u_vec);
|
|
98
|
-
const v_proj = math.dot(corner, v_vec);
|
|
99
|
-
const n_proj = math.dot(corner, unit_normal);
|
|
100
|
-
if (u_proj < u_min)
|
|
101
|
-
u_min = u_proj;
|
|
102
|
-
if (u_proj > u_max)
|
|
103
|
-
u_max = u_proj;
|
|
104
|
-
if (v_proj < v_min)
|
|
105
|
-
v_min = v_proj;
|
|
106
|
-
if (v_proj > v_max)
|
|
107
|
-
v_max = v_proj;
|
|
108
|
-
if (n_proj < normal_min)
|
|
109
|
-
normal_min = n_proj;
|
|
110
|
-
if (n_proj > normal_max)
|
|
111
|
-
normal_max = n_proj;
|
|
112
|
-
}
|
|
212
|
+
const corners = cell_corners(volume, UNIT_CELL_RANGE);
|
|
213
|
+
const projections = corners.map((corner) => math.dot(corner, unit_normal));
|
|
214
|
+
const normal_min = Math.min(...projections);
|
|
215
|
+
const normal_max = Math.max(...projections);
|
|
113
216
|
// Plane position: fractional distance [0,1] along the normal extent
|
|
114
217
|
const d_cartesian = normal_min + distance * (normal_max - normal_min);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const v_step = (v_max - v_min) / (height - 1 || 1);
|
|
123
|
-
for (let row = 0; row < height; row++) {
|
|
124
|
-
const v_val = v_min + row * v_step;
|
|
125
|
-
for (let col = 0; col < width; col++) {
|
|
126
|
-
const u_val = u_min + col * u_step;
|
|
127
|
-
// Cartesian position on the plane
|
|
128
|
-
const px = d_cartesian * unit_normal[0] + u_val * u_vec[0] + v_val * v_vec[0];
|
|
129
|
-
const py = d_cartesian * unit_normal[1] + u_val * u_vec[1] + v_val * v_vec[1];
|
|
130
|
-
const pz = d_cartesian * unit_normal[2] + u_val * u_vec[2] + v_val * v_vec[2];
|
|
131
|
-
const [fx, fy, fz] = cart_to_frac([px, py, pz]);
|
|
132
|
-
const val = trilinear_interpolate(grid, fx, fy, fz, periodic);
|
|
133
|
-
data[row * width + col] = val;
|
|
134
|
-
if (val < data_min)
|
|
135
|
-
data_min = val;
|
|
136
|
-
if (val > data_max)
|
|
137
|
-
data_max = val;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return { data, width, height, min: data_min, max: data_max };
|
|
218
|
+
const point = [
|
|
219
|
+
d_cartesian * unit_normal[0],
|
|
220
|
+
d_cartesian * unit_normal[1],
|
|
221
|
+
d_cartesian * unit_normal[2],
|
|
222
|
+
];
|
|
223
|
+
const resolution = n_points ?? Math.max(...volume.grid_dims);
|
|
224
|
+
return sample_plane_slice(volume, { point, normal: unit_normal }, { resolution: [resolution, resolution] });
|
|
141
225
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { D3InterpolateName } from '../colors';
|
|
2
|
+
import type { Matrix3x3, Vec2, Vec3 } from '../math';
|
|
2
3
|
import type { ParsedStructure } from '../structure/parse';
|
|
3
4
|
export interface DataRange {
|
|
4
5
|
min: number;
|
|
@@ -15,6 +16,7 @@ export interface VolumetricData {
|
|
|
15
16
|
data_order?: `x_fastest` | `z_fastest`;
|
|
16
17
|
periodic: boolean;
|
|
17
18
|
label?: string;
|
|
19
|
+
source?: string;
|
|
18
20
|
}
|
|
19
21
|
export interface VolumetricFileData {
|
|
20
22
|
structure: ParsedStructure;
|
|
@@ -27,6 +29,10 @@ export interface IsosurfaceLayer {
|
|
|
27
29
|
visible: boolean;
|
|
28
30
|
show_negative: boolean;
|
|
29
31
|
negative_color: string;
|
|
32
|
+
volume_idx?: number;
|
|
33
|
+
color_volume_idx?: number;
|
|
34
|
+
colormap?: D3InterpolateName;
|
|
35
|
+
color_range?: Vec2;
|
|
30
36
|
}
|
|
31
37
|
export interface IsosurfaceSettings {
|
|
32
38
|
isovalue: number;
|
|
@@ -37,6 +43,7 @@ export interface IsosurfaceSettings {
|
|
|
37
43
|
wireframe: boolean;
|
|
38
44
|
halo: number;
|
|
39
45
|
layers?: IsosurfaceLayer[];
|
|
46
|
+
display_range?: [Vec2, Vec2, Vec2];
|
|
40
47
|
}
|
|
41
48
|
export declare const LAYER_COLORS: readonly ["#3b82f6", "#ef4444", "#22c55e", "#a855f7", "#f97316", "#06b6d4", "#eab308", "#ec4899"];
|
|
42
49
|
export declare function grid_data_range(grid: number[][][]): DataRange;
|
|
@@ -45,6 +52,7 @@ export declare function pad_periodic_grid(grid: number[][][], dims: Vec3, pad_fr
|
|
|
45
52
|
dims: Vec3;
|
|
46
53
|
offset: Vec3;
|
|
47
54
|
};
|
|
55
|
+
export declare const MAX_GRID_POINTS = 500000;
|
|
48
56
|
export declare function downsample_grid(grid: number[][][], dims: Vec3, max_points?: number): {
|
|
49
57
|
grid: number[][][];
|
|
50
58
|
dims: Vec3;
|
|
@@ -53,4 +61,19 @@ export declare function downsample_grid(grid: number[][][], dims: Vec3, max_poin
|
|
|
53
61
|
export declare const DEFAULT_ISOSURFACE_SETTINGS: IsosurfaceSettings;
|
|
54
62
|
export declare function auto_isosurface_settings(data_range: DataRange): IsosurfaceSettings;
|
|
55
63
|
export declare function generate_layers(data_range: DataRange, n_layers: number): IsosurfaceLayer[];
|
|
64
|
+
export declare function auto_volume_layer(volume: VolumetricData, volume_idx: number, color_offset?: number): IsosurfaceLayer;
|
|
65
|
+
export declare function materialize_layers(settings: IsosurfaceSettings, active_volume_idx: number): IsosurfaceLayer[];
|
|
66
|
+
export declare function remove_volume(volumes: VolumetricData[], layers: IsosurfaceLayer[], removed_idx: number, active_volume_idx?: number): {
|
|
67
|
+
volumes: VolumetricData[];
|
|
68
|
+
layers: IsosurfaceLayer[];
|
|
69
|
+
};
|
|
70
|
+
export declare function label_file_volumes(volumes: VolumetricData[], filename: string): VolumetricData[];
|
|
71
|
+
export declare const lattices_match: (lattice_a: readonly (readonly number[])[] | undefined, lattice_b: readonly (readonly number[])[] | undefined, tolerance?: number) => boolean;
|
|
72
|
+
export interface VolumeMergeResult {
|
|
73
|
+
volumes: VolumetricData[];
|
|
74
|
+
layers: IsosurfaceLayer[];
|
|
75
|
+
first_touched_idx: number;
|
|
76
|
+
n_added: number;
|
|
77
|
+
}
|
|
78
|
+
export declare function merge_imported_volumes(existing: VolumetricData[], existing_layers: IsosurfaceLayer[], incoming: VolumetricData[], active_volume_idx?: number): VolumeMergeResult;
|
|
56
79
|
export declare function tile_volumetric_data(volume: VolumetricData, scaling: Vec3): VolumetricData;
|