matterviz 0.3.1 → 0.3.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 -2
- package/dist/FilePicker.svelte +154 -96
- package/dist/Icon.svelte +20 -14
- package/dist/MillerIndexInput.svelte +27 -21
- package/dist/api/optimade.js +6 -6
- package/dist/app.css +216 -178
- package/dist/brillouin/BrillouinZone.svelte +299 -198
- package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneControls.svelte +32 -5
- package/dist/brillouin/BrillouinZoneExportPane.svelte +74 -55
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +99 -68
- package/dist/brillouin/BrillouinZoneScene.svelte +277 -165
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneTooltip.svelte +17 -7
- package/dist/brillouin/compute.js +11 -6
- package/dist/chempot-diagram/ChemPotDiagram.svelte +327 -0
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +13 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +847 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +3194 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte +11 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte.d.ts +7 -0
- package/dist/chempot-diagram/async-compute.svelte.d.ts +3 -0
- package/dist/chempot-diagram/async-compute.svelte.js +77 -0
- package/dist/chempot-diagram/chempot-worker.d.ts +1 -0
- package/dist/chempot-diagram/chempot-worker.js +11 -0
- package/dist/chempot-diagram/color.d.ts +10 -0
- package/dist/chempot-diagram/color.js +32 -0
- package/dist/chempot-diagram/compute.d.ts +48 -0
- package/dist/chempot-diagram/compute.js +812 -0
- package/dist/chempot-diagram/index.d.ts +6 -0
- package/dist/chempot-diagram/index.js +6 -0
- package/dist/chempot-diagram/pointer.d.ts +16 -0
- package/dist/chempot-diagram/pointer.js +40 -0
- package/dist/chempot-diagram/temperature.d.ts +15 -0
- package/dist/chempot-diagram/temperature.js +36 -0
- package/dist/chempot-diagram/types.d.ts +86 -0
- package/dist/chempot-diagram/types.js +28 -0
- package/dist/colors/index.d.ts +3 -1
- package/dist/colors/index.js +9 -3
- package/dist/composition/BarChart.svelte +141 -77
- package/dist/composition/BubbleChart.svelte +107 -52
- package/dist/composition/Composition.svelte +100 -79
- package/dist/composition/Formula.svelte +108 -62
- package/dist/composition/FormulaFilter.svelte +973 -353
- package/dist/composition/FormulaFilter.svelte.d.ts +35 -1
- package/dist/composition/PieChart.svelte +199 -99
- package/dist/composition/PieChart.svelte.d.ts +1 -1
- package/dist/composition/format.d.ts +5 -0
- package/dist/composition/format.js +20 -3
- package/dist/composition/parse.js +14 -9
- package/dist/convex-hull/ConvexHull.svelte +93 -38
- package/dist/convex-hull/ConvexHull2D.svelte +551 -393
- package/dist/convex-hull/ConvexHull3D.svelte +1303 -825
- package/dist/convex-hull/ConvexHull4D.svelte +1012 -686
- package/dist/convex-hull/ConvexHullControls.svelte +115 -28
- package/dist/convex-hull/ConvexHullInfoPane.svelte +29 -3
- package/dist/convex-hull/ConvexHullStats.svelte +821 -249
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +6 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +41 -16
- package/dist/convex-hull/GasPressureControls.svelte +104 -61
- package/dist/convex-hull/StructurePopup.svelte +25 -4
- package/dist/convex-hull/TemperatureSlider.svelte +45 -25
- package/dist/convex-hull/barycentric-coords.js +13 -7
- package/dist/convex-hull/demo-temperature.d.ts +6 -0
- package/dist/convex-hull/demo-temperature.js +40 -0
- package/dist/convex-hull/gas-thermodynamics.js +17 -12
- package/dist/convex-hull/helpers.d.ts +10 -1
- package/dist/convex-hull/helpers.js +79 -38
- package/dist/convex-hull/index.d.ts +1 -0
- package/dist/convex-hull/index.js +1 -0
- package/dist/convex-hull/thermodynamics.d.ts +8 -21
- package/dist/convex-hull/thermodynamics.js +163 -69
- package/dist/convex-hull/types.d.ts +12 -12
- package/dist/convex-hull/types.js +0 -12
- package/dist/coordination/CoordinationBarPlot.svelte +232 -176
- package/dist/element/BohrAtom.svelte +56 -13
- package/dist/element/ElementHeading.svelte +7 -2
- package/dist/element/ElementPhoto.svelte +15 -9
- package/dist/element/ElementStats.svelte +10 -4
- package/dist/element/ElementTile.svelte +137 -73
- package/dist/element/Nucleus.svelte +39 -11
- package/dist/element/data.js +2 -14
- package/dist/element/data.json.gz +0 -0
- package/dist/element/types.d.ts +1 -0
- package/dist/feedback/ClickFeedback.svelte +16 -5
- package/dist/feedback/DragOverlay.svelte +10 -2
- package/dist/feedback/Spinner.svelte +4 -2
- package/dist/feedback/StatusMessage.svelte +8 -2
- package/dist/fermi-surface/FermiSlice.svelte +118 -88
- package/dist/fermi-surface/FermiSurface.svelte +336 -239
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceControls.svelte +113 -46
- package/dist/fermi-surface/FermiSurfaceScene.svelte +536 -343
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +14 -5
- package/dist/fermi-surface/compute.js +16 -20
- package/dist/fermi-surface/parse.js +37 -33
- package/dist/fermi-surface/symmetry.js +2 -7
- package/dist/fermi-surface/types.d.ts +3 -5
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +1527 -0
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +110 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +225 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +30 -0
- package/dist/heatmap-matrix/index.d.ts +53 -0
- package/dist/heatmap-matrix/index.js +100 -0
- package/dist/heatmap-matrix/shared.d.ts +2 -0
- package/dist/heatmap-matrix/shared.js +4 -0
- package/dist/icons.d.ts +111 -0
- package/dist/icons.js +158 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -2
- package/dist/io/decompress.js +1 -1
- package/dist/io/export.d.ts +3 -0
- package/dist/io/export.js +138 -140
- package/dist/io/file-drop.d.ts +7 -0
- package/dist/io/file-drop.js +43 -0
- package/dist/io/index.d.ts +2 -2
- package/dist/io/index.js +2 -112
- package/dist/io/is-binary.js +2 -3
- package/dist/io/types.d.ts +1 -0
- package/dist/io/url-drop.d.ts +2 -0
- package/dist/io/url-drop.js +117 -0
- package/dist/isosurface/Isosurface.svelte +220 -110
- package/dist/isosurface/IsosurfaceControls.svelte +65 -28
- package/dist/isosurface/parse.js +104 -56
- package/dist/isosurface/slice.d.ts +2 -1
- package/dist/isosurface/slice.js +8 -13
- package/dist/isosurface/types.d.ts +14 -1
- package/dist/isosurface/types.js +152 -5
- package/dist/labels.d.ts +2 -1
- package/dist/labels.js +12 -8
- package/dist/layout/FullscreenToggle.svelte +11 -2
- package/dist/layout/InfoCard.svelte +38 -6
- package/dist/layout/InfoTag.svelte +125 -94
- package/dist/layout/PropertyFilter.svelte +82 -37
- package/dist/layout/SettingsSection.svelte +85 -55
- package/dist/layout/SubpageGrid.svelte +82 -0
- package/dist/layout/SubpageGrid.svelte.d.ts +14 -0
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.js +1 -0
- package/dist/layout/json-tree/JsonNode.svelte +266 -223
- package/dist/layout/json-tree/JsonTree.svelte +516 -429
- package/dist/layout/json-tree/JsonTree.svelte.d.ts +1 -1
- package/dist/layout/json-tree/JsonValue.svelte +281 -173
- package/dist/layout/json-tree/types.d.ts +10 -2
- package/dist/layout/json-tree/utils.d.ts +2 -0
- package/dist/layout/json-tree/utils.js +37 -2
- package/dist/marching-cubes.js +25 -2
- package/dist/math.d.ts +20 -17
- package/dist/math.js +474 -57
- package/dist/overlays/ContextMenu.svelte +66 -40
- package/dist/overlays/DraggablePane.svelte +331 -154
- package/dist/overlays/DraggablePane.svelte.d.ts +2 -0
- package/dist/periodic-table/PeriodicTable.svelte +278 -145
- package/dist/periodic-table/PeriodicTableControls.svelte +178 -128
- package/dist/periodic-table/PropertySelect.svelte +25 -7
- package/dist/periodic-table/TableInset.svelte +8 -3
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +559 -267
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -2
- package/dist/phase-diagram/PhaseDiagramControls.svelte +131 -51
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +3 -2
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +126 -0
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +15 -0
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +160 -110
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +8 -1
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +217 -86
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte.d.ts +6 -3
- package/dist/phase-diagram/TdbInfoPanel.svelte +28 -4
- package/dist/phase-diagram/build-diagram.js +9 -9
- package/dist/phase-diagram/colors.js +1 -3
- package/dist/phase-diagram/index.d.ts +2 -0
- package/dist/phase-diagram/index.js +2 -0
- package/dist/phase-diagram/parse.js +10 -9
- package/dist/phase-diagram/svg-to-diagram.d.ts +2 -0
- package/dist/phase-diagram/svg-to-diagram.js +869 -0
- package/dist/phase-diagram/types.d.ts +10 -0
- package/dist/phase-diagram/utils.d.ts +8 -4
- package/dist/phase-diagram/utils.js +219 -74
- package/dist/plot/AxisLabel.svelte +51 -0
- package/dist/plot/AxisLabel.svelte.d.ts +16 -0
- package/dist/plot/BarPlot.svelte +1461 -768
- package/dist/plot/BarPlot.svelte.d.ts +3 -3
- package/dist/plot/BarPlotControls.svelte +33 -6
- package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ColorBar.svelte +533 -383
- package/dist/plot/ColorBar.svelte.d.ts +1 -1
- package/dist/plot/ColorScaleSelect.svelte +28 -7
- package/dist/plot/ElementScatter.svelte +38 -16
- package/dist/plot/FillArea.svelte +152 -92
- package/dist/plot/Histogram.svelte +1162 -709
- package/dist/plot/Histogram.svelte.d.ts +1 -1
- package/dist/plot/HistogramControls.svelte +81 -18
- package/dist/plot/HistogramControls.svelte.d.ts +6 -2
- package/dist/plot/InteractiveAxisLabel.svelte +34 -11
- package/dist/plot/InteractiveAxisLabel.svelte.d.ts +1 -1
- package/dist/plot/Line.svelte +63 -28
- package/dist/plot/PlotControls.svelte +221 -96
- package/dist/plot/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/PlotLegend.svelte +174 -91
- package/dist/plot/PlotTooltip.svelte +45 -6
- package/dist/plot/PortalSelect.svelte +175 -146
- package/dist/plot/ReferenceLine.svelte +77 -22
- package/dist/plot/ReferenceLine.svelte.d.ts +1 -0
- package/dist/plot/ReferenceLine3D.svelte +132 -107
- package/dist/plot/ReferencePlane.svelte +146 -123
- package/dist/plot/ScatterPlot.svelte +1880 -1156
- package/dist/plot/ScatterPlot.svelte.d.ts +3 -3
- package/dist/plot/ScatterPlot3D.svelte +256 -131
- package/dist/plot/ScatterPlot3D.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlot3DControls.svelte +300 -297
- package/dist/plot/ScatterPlot3DControls.svelte.d.ts +2 -1
- package/dist/plot/ScatterPlot3DScene.svelte +608 -406
- package/dist/plot/ScatterPlot3DScene.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlotControls.svelte +150 -70
- package/dist/plot/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ScatterPoint.svelte +98 -26
- package/dist/plot/ScatterPoint.svelte.d.ts +1 -0
- package/dist/plot/SpacegroupBarPlot.svelte +142 -85
- package/dist/plot/Surface3D.svelte +159 -108
- package/dist/plot/ZeroLines.svelte +96 -0
- package/dist/plot/ZeroLines.svelte.d.ts +32 -0
- package/dist/plot/ZoomRect.svelte +23 -0
- package/dist/plot/ZoomRect.svelte.d.ts +8 -0
- package/dist/plot/axis-utils.d.ts +1 -1
- package/dist/plot/axis-utils.js +1 -3
- package/dist/plot/data-cleaning.js +12 -28
- package/dist/plot/data-transform.js +2 -1
- package/dist/plot/fill-utils.js +2 -0
- package/dist/plot/index.d.ts +6 -2
- package/dist/plot/index.js +6 -2
- package/dist/plot/interactions.d.ts +8 -10
- package/dist/plot/interactions.js +2 -3
- package/dist/plot/layout.d.ts +11 -2
- package/dist/plot/layout.js +44 -17
- package/dist/plot/reference-line.d.ts +5 -22
- package/dist/plot/reference-line.js +12 -84
- package/dist/plot/scales.js +24 -36
- package/dist/plot/types.d.ts +53 -40
- package/dist/plot/types.js +12 -7
- package/dist/plot/utils/label-placement.d.ts +32 -15
- package/dist/plot/utils/label-placement.js +227 -63
- package/dist/plot/utils/series-visibility.js +2 -3
- package/dist/plot/utils.d.ts +1 -0
- package/dist/plot/utils.js +14 -0
- package/dist/rdf/RdfPlot.svelte +173 -132
- package/dist/rdf/calc-rdf.js +4 -5
- package/dist/sanitize.d.ts +4 -0
- package/dist/sanitize.js +107 -0
- package/dist/settings.d.ts +21 -6
- package/dist/settings.js +63 -19
- package/dist/spectral/Bands.svelte +963 -412
- package/dist/spectral/Bands.svelte.d.ts +22 -2
- package/dist/spectral/BandsAndDos.svelte +90 -49
- package/dist/spectral/BrillouinBandsDos.svelte +151 -93
- package/dist/spectral/Dos.svelte +389 -258
- package/dist/spectral/helpers.d.ts +23 -1
- package/dist/spectral/helpers.js +119 -51
- package/dist/spectral/types.d.ts +2 -0
- package/dist/state.svelte.d.ts +1 -1
- package/dist/state.svelte.js +3 -2
- package/dist/structure/Arrow.svelte +59 -20
- package/dist/structure/AtomLegend.svelte +231 -129
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/Bond.svelte +73 -47
- package/dist/structure/CanvasTooltip.svelte +10 -2
- package/dist/structure/CellSelect.svelte +148 -51
- package/dist/structure/Cylinder.svelte +33 -17
- package/dist/structure/Lattice.svelte +88 -33
- package/dist/structure/Structure.svelte +1077 -821
- package/dist/structure/Structure.svelte.d.ts +1 -1
- package/dist/structure/StructureControls.svelte +373 -139
- package/dist/structure/StructureControls.svelte.d.ts +1 -1
- package/dist/structure/StructureExportPane.svelte +124 -89
- package/dist/structure/StructureExportPane.svelte.d.ts +1 -1
- package/dist/structure/StructureInfoPane.svelte +304 -231
- package/dist/structure/StructureScene.svelte +919 -445
- package/dist/structure/StructureScene.svelte.d.ts +16 -7
- package/dist/structure/atom-properties.d.ts +6 -2
- package/dist/structure/atom-properties.js +42 -29
- package/dist/structure/bonding.js +6 -7
- package/dist/structure/export.js +22 -34
- package/dist/structure/ferrox-wasm-types.d.ts +3 -2
- package/dist/structure/ferrox-wasm-types.js +0 -3
- package/dist/structure/ferrox-wasm.d.ts +3 -2
- package/dist/structure/ferrox-wasm.js +2 -3
- package/dist/structure/index.d.ts +16 -0
- package/dist/structure/index.js +88 -6
- package/dist/structure/measure.d.ts +2 -2
- package/dist/structure/measure.js +4 -44
- package/dist/structure/parse.js +130 -155
- package/dist/structure/partial-occupancy.d.ts +25 -0
- package/dist/structure/partial-occupancy.js +99 -0
- package/dist/structure/pbc.d.ts +1 -0
- package/dist/structure/pbc.js +16 -6
- package/dist/structure/supercell.d.ts +2 -2
- package/dist/structure/supercell.js +12 -22
- package/dist/structure/validation.js +5 -3
- package/dist/symmetry/SymmetryStats.svelte +94 -37
- package/dist/symmetry/WyckoffTable.svelte +42 -14
- package/dist/symmetry/cell-transform.js +5 -3
- package/dist/symmetry/index.d.ts +7 -4
- package/dist/symmetry/index.js +87 -21
- package/dist/symmetry/spacegroups.js +148 -148
- package/dist/table/HeatmapTable.svelte +1112 -516
- package/dist/table/HeatmapTable.svelte.d.ts +12 -1
- package/dist/table/ToggleMenu.svelte +125 -90
- package/dist/table/index.d.ts +2 -0
- package/dist/table/index.js +2 -4
- package/dist/theme/ThemeControl.svelte +21 -12
- package/dist/time.js +4 -1
- package/dist/tooltip/TooltipContent.svelte +33 -8
- package/dist/trajectory/Trajectory.svelte +889 -687
- package/dist/trajectory/TrajectoryError.svelte +14 -3
- package/dist/trajectory/TrajectoryExportPane.svelte +148 -90
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +1 -1
- package/dist/trajectory/TrajectoryInfoPane.svelte +272 -143
- package/dist/trajectory/constants.d.ts +6 -0
- package/dist/trajectory/constants.js +7 -0
- package/dist/trajectory/extract.js +13 -31
- package/dist/trajectory/format-detect.d.ts +9 -0
- package/dist/trajectory/format-detect.js +76 -0
- package/dist/trajectory/frame-reader.d.ts +17 -0
- package/dist/trajectory/frame-reader.js +332 -0
- package/dist/trajectory/helpers.d.ts +14 -0
- package/dist/trajectory/helpers.js +172 -0
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +23 -14
- package/dist/trajectory/parse/ase.d.ts +2 -0
- package/dist/trajectory/parse/ase.js +77 -0
- package/dist/trajectory/parse/hdf5.d.ts +2 -0
- package/dist/trajectory/parse/hdf5.js +129 -0
- package/dist/trajectory/parse/index.d.ts +12 -0
- package/dist/trajectory/parse/index.js +299 -0
- package/dist/trajectory/parse/lammps.d.ts +5 -0
- package/dist/trajectory/parse/lammps.js +179 -0
- package/dist/trajectory/parse/vasp.d.ts +2 -0
- package/dist/trajectory/parse/vasp.js +68 -0
- package/dist/trajectory/parse/xyz.d.ts +2 -0
- package/dist/trajectory/parse/xyz.js +110 -0
- package/dist/trajectory/plotting.js +13 -8
- package/dist/trajectory/types.d.ts +11 -0
- package/dist/trajectory/types.js +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +17 -0
- package/dist/xrd/XrdPlot.svelte +337 -245
- package/dist/xrd/broadening.js +14 -9
- package/dist/xrd/calc-xrd.js +12 -19
- package/dist/xrd/parse.d.ts +1 -1
- package/dist/xrd/parse.js +17 -17
- package/package.json +103 -101
- package/readme.md +4 -4
- package/dist/trajectory/parse.d.ts +0 -42
- package/dist/trajectory/parse.js +0 -1267
- /package/dist/element/{data.json.d.ts → data.json.gz.d.ts} +0 -0
- /package/dist/theme/{themes.js → themes.mjs} +0 -0
|
@@ -1,42 +1,85 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Icon from '../Icon.svelte'
|
|
3
|
+
import Spinner from '../feedback/Spinner.svelte'
|
|
4
|
+
import { is_valid_supercell_input } from './supercell'
|
|
5
|
+
import type { CellType } from '../symmetry'
|
|
6
|
+
import type { MoyoDataset } from '@spglib/moyo-wasm'
|
|
7
|
+
import { click_outside, tooltip } from 'svelte-multiselect/attachments'
|
|
8
|
+
import { fade } from 'svelte/transition'
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
supercell_scaling = $bindable(`1x1x1`),
|
|
12
|
+
cell_type = $bindable(`original`),
|
|
13
|
+
sym_data = null,
|
|
14
|
+
loading = $bindable(false),
|
|
15
|
+
direction = `down`,
|
|
16
|
+
align = `right`,
|
|
17
|
+
}: {
|
|
18
|
+
supercell_scaling: string
|
|
19
|
+
cell_type?: CellType
|
|
20
|
+
sym_data?: MoyoDataset | null
|
|
21
|
+
loading?: boolean
|
|
22
|
+
direction?: `up` | `down`
|
|
23
|
+
align?: `left` | `right`
|
|
24
|
+
} = $props()
|
|
25
|
+
|
|
26
|
+
let menu_open = $state(false)
|
|
27
|
+
let input_value = $state(supercell_scaling)
|
|
28
|
+
let input_valid = $derived(is_valid_supercell_input(input_value))
|
|
29
|
+
|
|
30
|
+
const supercell_presets = [`1x1x1`, `2x2x2`, `3x3x3`, `2x2x1`, `3x3x1`, `2x1x1`]
|
|
31
|
+
|
|
32
|
+
// Always show all 3 cell types - Prim/Conv disabled without sym_data
|
|
33
|
+
const cell_types: CellType[] = [`original`, `primitive`, `conventional`]
|
|
34
|
+
const cell_labels: Record<CellType, string> = {
|
|
14
35
|
original: `Orig`,
|
|
15
36
|
primitive: `Prim`,
|
|
16
37
|
conventional: `Conv`,
|
|
17
|
-
}
|
|
18
|
-
const cell_tooltips = {
|
|
38
|
+
}
|
|
39
|
+
const cell_tooltips: Record<CellType, string> = {
|
|
19
40
|
original: `Original unit cell (as provided)`,
|
|
20
41
|
primitive: `Primitive cell (smallest repeating unit)`,
|
|
21
42
|
conventional: `Conventional cell (standardized representation)`,
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function
|
|
43
|
+
}
|
|
44
|
+
const hair_space = `\u200A`
|
|
45
|
+
|
|
46
|
+
const format_supercell_label = (supercell_value: string): string =>
|
|
47
|
+
supercell_value.replaceAll(`x`, `${hair_space}x${hair_space}`)
|
|
48
|
+
|
|
49
|
+
function apply_preset(preset: string) {
|
|
50
|
+
supercell_scaling = preset
|
|
51
|
+
input_value = preset
|
|
52
|
+
menu_open = false
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function handle_input_submit() {
|
|
29
56
|
if (input_valid && input_value !== supercell_scaling) {
|
|
30
|
-
|
|
31
|
-
|
|
57
|
+
supercell_scaling = input_value
|
|
58
|
+
menu_open = false
|
|
32
59
|
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function handle_focus_out(event: FocusEvent) {
|
|
63
|
+
const next_target = event.relatedTarget
|
|
64
|
+
const current_target = event.currentTarget
|
|
65
|
+
if (
|
|
66
|
+
!(current_target instanceof Node) ||
|
|
67
|
+
!(next_target instanceof Node) ||
|
|
68
|
+
!current_target.contains(next_target)
|
|
69
|
+
) menu_open = false
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function handle_key_down(event: KeyboardEvent, submit_on_enter: boolean = false) {
|
|
73
|
+
if (event.key === `Escape`) menu_open = false
|
|
74
|
+
if (submit_on_enter && event.key === `Enter`) handle_input_submit()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Sync input value when external prop changes
|
|
78
|
+
$effect(() => {
|
|
36
79
|
if (!menu_open && supercell_scaling && supercell_scaling !== input_value) {
|
|
37
|
-
|
|
80
|
+
input_value = supercell_scaling
|
|
38
81
|
}
|
|
39
|
-
})
|
|
82
|
+
})
|
|
40
83
|
</script>
|
|
41
84
|
|
|
42
85
|
<div
|
|
@@ -46,10 +89,12 @@ $effect(() => {
|
|
|
46
89
|
onmouseenter={() => (menu_open = true)}
|
|
47
90
|
onmouseleave={() => (menu_open = false)}
|
|
48
91
|
onfocusin={() => (menu_open = true)}
|
|
92
|
+
onfocusout={handle_focus_out}
|
|
49
93
|
>
|
|
50
94
|
<button
|
|
51
95
|
type="button"
|
|
52
96
|
onclick={() => (menu_open = !menu_open)}
|
|
97
|
+
onkeydown={handle_key_down}
|
|
53
98
|
class="toggle-btn"
|
|
54
99
|
class:active={menu_open}
|
|
55
100
|
aria-expanded={menu_open}
|
|
@@ -60,7 +105,9 @@ $effect(() => {
|
|
|
60
105
|
style="--spinner-border-width: 2px; --spinner-size: 1em; --spinner-margin: 0; display: inline-block; vertical-align: middle"
|
|
61
106
|
/>
|
|
62
107
|
{:else}
|
|
63
|
-
{cell_type !== `original` ? `${cell_labels[cell_type]} ` : ``}{
|
|
108
|
+
{cell_type !== `original` ? `${cell_labels[cell_type]} ` : ``}{
|
|
109
|
+
format_supercell_label(supercell_scaling)
|
|
110
|
+
}
|
|
64
111
|
{/if}
|
|
65
112
|
</button>
|
|
66
113
|
|
|
@@ -101,7 +148,7 @@ $effect(() => {
|
|
|
101
148
|
class:selected={supercell_scaling === preset}
|
|
102
149
|
onclick={() => apply_preset(preset)}
|
|
103
150
|
>
|
|
104
|
-
{preset}
|
|
151
|
+
{format_supercell_label(preset)}
|
|
105
152
|
</button>
|
|
106
153
|
{/each}
|
|
107
154
|
</div>
|
|
@@ -113,7 +160,7 @@ $effect(() => {
|
|
|
113
160
|
bind:value={input_value}
|
|
114
161
|
placeholder="e.g. 2x2x2"
|
|
115
162
|
class:invalid={!input_valid}
|
|
116
|
-
onkeydown={(event) => event
|
|
163
|
+
onkeydown={(event) => handle_key_down(event, true)}
|
|
117
164
|
/>
|
|
118
165
|
<button
|
|
119
166
|
class="apply-btn"
|
|
@@ -131,27 +178,47 @@ $effect(() => {
|
|
|
131
178
|
<style>
|
|
132
179
|
.cell-select {
|
|
133
180
|
position: relative;
|
|
134
|
-
font-size:
|
|
181
|
+
font-size: inherit;
|
|
182
|
+
align-self: center;
|
|
183
|
+
--cell-select-accent: var(--accent-color, light-dark(#2563eb, #60a5fa));
|
|
184
|
+
--cell-select-surface: var(--surface-bg, light-dark(rgba(255, 255, 255, 0.96), #222));
|
|
185
|
+
--cell-select-border: var(
|
|
186
|
+
--border-color,
|
|
187
|
+
light-dark(rgba(0, 0, 0, 0.2), rgba(255, 255, 255, 0.25))
|
|
188
|
+
);
|
|
135
189
|
}
|
|
136
190
|
.toggle-btn {
|
|
137
191
|
padding: var(--struct-legend-padding, 0 4pt);
|
|
138
192
|
line-height: var(--struct-legend-line-height, 1.3);
|
|
139
193
|
vertical-align: middle;
|
|
194
|
+
color: var(--text-color);
|
|
195
|
+
background: var(--btn-bg, light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.1)));
|
|
196
|
+
border: 1px solid var(--border-color);
|
|
197
|
+
border-radius: var(--border-radius, 3pt);
|
|
198
|
+
transition: background 0.15s ease;
|
|
199
|
+
}
|
|
200
|
+
@media (hover: hover) {
|
|
201
|
+
.toggle-btn:hover {
|
|
202
|
+
background: var(
|
|
203
|
+
--btn-bg-hover,
|
|
204
|
+
light-dark(rgba(0, 0, 0, 0.12), rgba(255, 255, 255, 0.15))
|
|
205
|
+
);
|
|
206
|
+
}
|
|
140
207
|
}
|
|
141
208
|
.dropdown {
|
|
142
209
|
position: absolute;
|
|
143
210
|
top: 100%;
|
|
144
211
|
right: 0;
|
|
145
212
|
margin-top: 2px;
|
|
146
|
-
background: var(--surface-bg, #222);
|
|
147
|
-
padding:
|
|
213
|
+
background: var(--surface-bg, light-dark(rgba(255, 255, 255, 0.96), #222));
|
|
214
|
+
padding: 6px;
|
|
148
215
|
border-radius: var(--struct-border-radius, var(--border-radius, 3pt));
|
|
149
216
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
|
|
150
217
|
display: flex;
|
|
151
218
|
flex-direction: column;
|
|
152
|
-
gap:
|
|
219
|
+
gap: 5px;
|
|
153
220
|
z-index: 100;
|
|
154
|
-
min-width:
|
|
221
|
+
min-width: 118px;
|
|
155
222
|
}
|
|
156
223
|
/* Invisible bridge to prevent menu closing when moving mouse from toggle to dropdown */
|
|
157
224
|
.dropdown::before {
|
|
@@ -180,26 +247,41 @@ $effect(() => {
|
|
|
180
247
|
/* Cell type row - compact buttons with minimal padding */
|
|
181
248
|
.cell-type-row {
|
|
182
249
|
display: flex;
|
|
183
|
-
gap:
|
|
184
|
-
padding-bottom:
|
|
185
|
-
border-bottom: 1px solid rgba(128, 128, 128, 0.3);
|
|
250
|
+
gap: 3px;
|
|
251
|
+
padding-bottom: 5px;
|
|
252
|
+
border-bottom: 1px solid var(--border-color, rgba(128, 128, 128, 0.3));
|
|
186
253
|
}
|
|
187
254
|
.cell-type-btn {
|
|
188
255
|
flex: 1;
|
|
189
|
-
padding:
|
|
256
|
+
padding: 2px 6px;
|
|
190
257
|
font-size: 0.9em;
|
|
258
|
+
color: var(--text-color);
|
|
259
|
+
background: var(--btn-bg, light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.1)));
|
|
260
|
+
border: 1px solid var(--border-color);
|
|
191
261
|
border-radius: var(--border-radius, 3pt);
|
|
192
262
|
transition: background 0.15s ease;
|
|
193
263
|
white-space: nowrap;
|
|
194
264
|
}
|
|
195
265
|
@media (hover: hover) {
|
|
196
266
|
.cell-type-btn:hover:not(.disabled) {
|
|
197
|
-
background:
|
|
267
|
+
background: var(
|
|
268
|
+
--btn-bg-hover,
|
|
269
|
+
light-dark(rgba(0, 0, 0, 0.12), rgba(255, 255, 255, 0.15))
|
|
270
|
+
);
|
|
198
271
|
}
|
|
199
272
|
}
|
|
200
273
|
.cell-type-btn.selected {
|
|
201
|
-
|
|
202
|
-
|
|
274
|
+
color: var(--cell-select-accent);
|
|
275
|
+
background: color-mix(
|
|
276
|
+
in srgb,
|
|
277
|
+
var(--cell-select-accent) 18%,
|
|
278
|
+
var(--cell-select-surface)
|
|
279
|
+
);
|
|
280
|
+
border-color: color-mix(
|
|
281
|
+
in srgb,
|
|
282
|
+
var(--cell-select-accent) 45%,
|
|
283
|
+
var(--cell-select-border)
|
|
284
|
+
);
|
|
203
285
|
}
|
|
204
286
|
.cell-type-btn.disabled {
|
|
205
287
|
opacity: 0.4;
|
|
@@ -215,16 +297,31 @@ $effect(() => {
|
|
|
215
297
|
.preset-btn {
|
|
216
298
|
padding: 2px 4px;
|
|
217
299
|
font-size: 0.9em;
|
|
300
|
+
color: var(--text-color);
|
|
301
|
+
background: var(--btn-bg, light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.1)));
|
|
302
|
+
border: 1px solid var(--border-color);
|
|
218
303
|
border-radius: var(--border-radius, 3pt);
|
|
219
304
|
}
|
|
220
305
|
@media (hover: hover) {
|
|
221
306
|
.preset-btn:hover {
|
|
222
|
-
background:
|
|
307
|
+
background: var(
|
|
308
|
+
--btn-bg-hover,
|
|
309
|
+
light-dark(rgba(0, 0, 0, 0.12), rgba(255, 255, 255, 0.15))
|
|
310
|
+
);
|
|
223
311
|
}
|
|
224
312
|
}
|
|
225
313
|
.preset-btn.selected {
|
|
226
|
-
|
|
227
|
-
background:
|
|
314
|
+
color: var(--cell-select-accent);
|
|
315
|
+
background: color-mix(
|
|
316
|
+
in srgb,
|
|
317
|
+
var(--cell-select-accent) 18%,
|
|
318
|
+
var(--cell-select-surface)
|
|
319
|
+
);
|
|
320
|
+
border-color: color-mix(
|
|
321
|
+
in srgb,
|
|
322
|
+
var(--cell-select-accent) 45%,
|
|
323
|
+
var(--cell-select-border)
|
|
324
|
+
);
|
|
228
325
|
}
|
|
229
326
|
|
|
230
327
|
/* Custom input row */
|
|
@@ -234,10 +331,10 @@ $effect(() => {
|
|
|
234
331
|
gap: 4px;
|
|
235
332
|
}
|
|
236
333
|
.custom-input-row input {
|
|
237
|
-
max-width:
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
font-size: 0.
|
|
334
|
+
max-width: 60px;
|
|
335
|
+
min-height: 0;
|
|
336
|
+
padding: 1px 4px;
|
|
337
|
+
font-size: 0.85em;
|
|
241
338
|
}
|
|
242
339
|
.custom-input-row input.invalid {
|
|
243
340
|
border-color: rgba(255, 100, 100, 0.6);
|
|
@@ -1,26 +1,42 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
let {
|
|
7
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Vec3 } from '../math'
|
|
3
|
+
import { T } from '@threlte/core'
|
|
4
|
+
import { Euler, Quaternion, Vector3 } from 'three'
|
|
5
|
+
|
|
6
|
+
let { from, to, color = `#808080`, thickness = 0.1 }: {
|
|
7
|
+
from: Vec3
|
|
8
|
+
to: Vec3
|
|
9
|
+
color?: string
|
|
10
|
+
thickness?: number
|
|
11
|
+
} = $props()
|
|
12
|
+
|
|
13
|
+
let from_vec = $derived(new Vector3(...from))
|
|
14
|
+
let to_vec = $derived(new Vector3(...to))
|
|
15
|
+
let { position, rotation, height } = $derived(calc_bond(from_vec, to_vec))
|
|
16
|
+
|
|
17
|
+
function calc_bond(
|
|
18
|
+
from_vec: Vector3,
|
|
19
|
+
to_vec: Vector3,
|
|
20
|
+
): { position: Vec3; rotation: Vec3; height: number } {
|
|
8
21
|
// find the axis of the cylinder
|
|
9
|
-
const delta_vec = to_vec.clone().sub(from_vec)
|
|
22
|
+
const delta_vec = to_vec.clone().sub(from_vec)
|
|
10
23
|
// length of the cylinder
|
|
11
|
-
const height = delta_vec.length()
|
|
24
|
+
const height = delta_vec.length()
|
|
12
25
|
// calculate position (midpoint between from and to)
|
|
13
26
|
const position = from_vec
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
27
|
+
.clone()
|
|
28
|
+
.add(delta_vec.multiplyScalar(0.5))
|
|
29
|
+
.toArray() as Vec3
|
|
17
30
|
// calculate rotation
|
|
18
|
-
const quaternion = new Quaternion().setFromUnitVectors(
|
|
19
|
-
|
|
20
|
-
|
|
31
|
+
const quaternion = new Quaternion().setFromUnitVectors(
|
|
32
|
+
new Vector3(0, 1, 0),
|
|
33
|
+
delta_vec.normalize(),
|
|
34
|
+
)
|
|
35
|
+
const euler = new Euler().setFromQuaternion(quaternion)
|
|
36
|
+
const rotation: Vec3 = [euler.x, euler.y, euler.z]
|
|
21
37
|
// return results
|
|
22
|
-
return { height, position, rotation }
|
|
23
|
-
}
|
|
38
|
+
return { height, position, rotation }
|
|
39
|
+
}
|
|
24
40
|
</script>
|
|
25
41
|
|
|
26
42
|
<T.Mesh {position} {rotation} scale={[thickness, height, thickness]}>
|
|
@@ -1,43 +1,98 @@
|
|
|
1
1
|
<!-- Export default values for use in other components -->
|
|
2
|
-
<script lang="ts">
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import { format_num } from '../labels'
|
|
4
|
+
import type { Vec3 } from '../math'
|
|
5
|
+
import * as math from '../math'
|
|
6
|
+
import { DEFAULTS } from '../settings'
|
|
7
|
+
import { CanvasTooltip } from './'
|
|
8
|
+
import { T } from '@threlte/core'
|
|
9
|
+
import {
|
|
10
|
+
BoxGeometry,
|
|
11
|
+
EdgesGeometry,
|
|
12
|
+
Euler,
|
|
13
|
+
Matrix4,
|
|
14
|
+
Quaternion,
|
|
15
|
+
Vector3,
|
|
16
|
+
} from 'three'
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
matrix = undefined,
|
|
20
|
+
cell_edge_color = DEFAULTS.structure.cell_edge_color,
|
|
21
|
+
cell_surface_color = DEFAULTS.structure.cell_surface_color,
|
|
22
|
+
cell_edge_width = DEFAULTS.structure.cell_edge_width,
|
|
23
|
+
cell_edge_opacity = DEFAULTS.structure.cell_edge_opacity,
|
|
24
|
+
cell_surface_opacity = DEFAULTS.structure.cell_surface_opacity,
|
|
25
|
+
show_cell_vectors = true,
|
|
26
|
+
vector_colors = [`red`, `green`, `blue`],
|
|
27
|
+
vector_origin = [-1, -1, -1] satisfies Vec3,
|
|
28
|
+
float_fmt = `.2f`,
|
|
29
|
+
}: {
|
|
30
|
+
matrix?: math.Matrix3x3
|
|
31
|
+
cell_edge_color?: string
|
|
32
|
+
cell_surface_color?: string
|
|
33
|
+
cell_edge_width?: number // thickness of the cell edges
|
|
34
|
+
cell_edge_opacity?: number // opacity of the cell edges
|
|
35
|
+
cell_surface_opacity?: number // opacity of the cell surfaces
|
|
36
|
+
show_cell_vectors?: boolean // whether to show the lattice vectors
|
|
37
|
+
vector_colors?: readonly [string, string, string] // lattice vector colors
|
|
38
|
+
vector_origin?: Vec3 // lattice vector origin (all arrows start from this point)
|
|
39
|
+
float_fmt?: string
|
|
40
|
+
} = $props()
|
|
41
|
+
|
|
42
|
+
let hovered_idx = $state<number | null>(null) // track hovered vector
|
|
43
|
+
let lattice_center = $derived(
|
|
44
|
+
matrix
|
|
45
|
+
? (math.scale(math.add(...matrix), 0.5) satisfies Vec3)
|
|
46
|
+
: ([0, 0, 0] satisfies Vec3),
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
// Extract line segments from EdgesGeometry for cylinder-based thick lines
|
|
50
|
+
function get_edge_segments(edges_geometry: EdgesGeometry): [Vector3, Vector3][] {
|
|
51
|
+
const positions = edges_geometry.getAttribute(`position`).array as Float32Array
|
|
52
|
+
const segments: [Vector3, Vector3][] = []
|
|
53
|
+
|
|
17
54
|
for (let idx = 0; idx < positions.length; idx += 6) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
55
|
+
const start = new Vector3(
|
|
56
|
+
positions[idx + 0],
|
|
57
|
+
positions[idx + 1],
|
|
58
|
+
positions[idx + 2],
|
|
59
|
+
)
|
|
60
|
+
const end = new Vector3(
|
|
61
|
+
positions[idx + 3],
|
|
62
|
+
positions[idx + 4],
|
|
63
|
+
positions[idx + 5],
|
|
64
|
+
)
|
|
65
|
+
segments.push([start, end])
|
|
21
66
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
67
|
+
|
|
68
|
+
return segments
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Calculate cylinder transform for a line segment
|
|
72
|
+
function get_cylinder_transform(
|
|
73
|
+
start: Vector3,
|
|
74
|
+
end: Vector3,
|
|
75
|
+
): { position: Vec3; rotation: Vec3; length: number } {
|
|
76
|
+
const direction = end.clone().sub(start)
|
|
77
|
+
const length = direction.length()
|
|
78
|
+
const center = start.clone().add(end).multiplyScalar(0.5)
|
|
79
|
+
|
|
29
80
|
if (length === 0) { // Zero-length: no rotation; render a degenerate cylinder
|
|
30
|
-
|
|
81
|
+
return { position: center.toArray(), rotation: [0, 0, 0], length }
|
|
31
82
|
}
|
|
32
83
|
// Calculate rotation to align cylinder with the line (zero-length guarded above)
|
|
33
|
-
const quaternion = new Quaternion().setFromUnitVectors(
|
|
34
|
-
|
|
84
|
+
const quaternion = new Quaternion().setFromUnitVectors(
|
|
85
|
+
new Vector3(0, 1, 0),
|
|
86
|
+
direction.normalize(),
|
|
87
|
+
)
|
|
88
|
+
const euler = new Euler().setFromQuaternion(quaternion)
|
|
89
|
+
|
|
35
90
|
return {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
}
|
|
91
|
+
position: center.toArray(),
|
|
92
|
+
rotation: euler.toArray().slice(0, 3) as Vec3,
|
|
93
|
+
length,
|
|
94
|
+
}
|
|
95
|
+
}
|
|
41
96
|
</script>
|
|
42
97
|
|
|
43
98
|
{#if matrix}
|