matterviz 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EmptyState.svelte +10 -4
- package/dist/FilePicker.svelte +12 -14
- package/dist/Icon.svelte +7 -4
- package/dist/MillerIndexInput.svelte +2 -2
- package/dist/app.css +53 -0
- package/dist/brillouin/BrillouinZone.svelte +132 -219
- package/dist/brillouin/BrillouinZone.svelte.d.ts +9 -20
- package/dist/brillouin/BrillouinZoneControls.svelte +3 -6
- package/dist/brillouin/BrillouinZoneExportPane.svelte +47 -96
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +15 -42
- package/dist/brillouin/BrillouinZoneInfoPane.svelte.d.ts +2 -3
- package/dist/brillouin/BrillouinZoneScene.svelte +63 -230
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +3 -23
- package/dist/brillouin/ReciprocalVectors.svelte +39 -0
- package/dist/brillouin/ReciprocalVectors.svelte.d.ts +9 -0
- package/dist/brillouin/compute.d.ts +2 -0
- package/dist/brillouin/compute.js +80 -77
- package/dist/brillouin/geometry.d.ts +8 -0
- package/dist/brillouin/geometry.js +57 -0
- package/dist/brillouin/index.d.ts +2 -0
- package/dist/brillouin/index.js +2 -0
- package/dist/brillouin/types.d.ts +2 -2
- package/dist/chempot-diagram/ChemPotDiagram.svelte +33 -38
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +1 -1
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +143 -246
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +4 -1
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +652 -976
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +7 -1
- package/dist/chempot-diagram/async-compute.svelte.js +1 -1
- package/dist/chempot-diagram/color.d.ts +3 -6
- package/dist/chempot-diagram/color.js +5 -5
- package/dist/chempot-diagram/compute.d.ts +3 -3
- package/dist/chempot-diagram/compute.js +3 -1
- package/dist/chempot-diagram/controls-state.svelte.d.ts +10 -0
- package/dist/chempot-diagram/controls-state.svelte.js +42 -0
- package/dist/chempot-diagram/export.d.ts +47 -0
- package/dist/chempot-diagram/export.js +133 -0
- package/dist/chempot-diagram/index.d.ts +1 -0
- package/dist/chempot-diagram/index.js +1 -0
- package/dist/chempot-diagram/pointer.d.ts +0 -10
- package/dist/chempot-diagram/pointer.js +4 -4
- package/dist/chempot-diagram/types.d.ts +3 -3
- package/dist/colors/index.d.ts +0 -4
- package/dist/colors/index.js +21 -22
- package/dist/composition/BarChart.svelte +37 -31
- package/dist/composition/BubbleChart.svelte +17 -17
- package/dist/composition/Composition.svelte +7 -11
- package/dist/composition/Formula.svelte +18 -25
- package/dist/composition/FormulaFilter.svelte +96 -98
- package/dist/composition/PieChart.svelte +60 -46
- package/dist/composition/chem-sys.js +3 -2
- package/dist/composition/format.js +4 -3
- package/dist/composition/index.d.ts +2 -0
- package/dist/composition/index.js +14 -0
- package/dist/composition/parse.d.ts +2 -3
- package/dist/composition/parse.js +27 -28
- package/dist/constants.js +11 -9
- package/dist/controls.d.ts +1 -0
- package/dist/controls.js +0 -1
- package/dist/convex-hull/ConvexHull.svelte +20 -25
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -4
- package/dist/convex-hull/ConvexHull2D.svelte +176 -256
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +269 -804
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +236 -755
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullChrome.svelte +264 -0
- package/dist/convex-hull/ConvexHullChrome.svelte.d.ts +30 -0
- package/dist/convex-hull/ConvexHullControls.svelte +128 -49
- package/dist/convex-hull/ConvexHullControls.svelte.d.ts +7 -6
- package/dist/convex-hull/ConvexHullInfoPane.svelte +18 -5
- package/dist/convex-hull/ConvexHullInfoPane.svelte.d.ts +6 -5
- package/dist/convex-hull/ConvexHullStats.svelte +210 -351
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +3 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +16 -14
- package/dist/convex-hull/ConvexHullTooltip.svelte.d.ts +2 -1
- package/dist/convex-hull/GasPressureControls.svelte +5 -12
- package/dist/convex-hull/StructurePopup.svelte +17 -21
- package/dist/convex-hull/StructurePopup.svelte.d.ts +2 -0
- package/dist/convex-hull/TemperatureSlider.svelte +4 -10
- package/dist/convex-hull/barycentric-coords.d.ts +2 -4
- package/dist/convex-hull/barycentric-coords.js +6 -33
- package/dist/convex-hull/canvas-interactions.svelte.d.ts +79 -0
- package/dist/convex-hull/canvas-interactions.svelte.js +279 -0
- package/dist/convex-hull/helpers.d.ts +47 -17
- package/dist/convex-hull/helpers.js +186 -101
- package/dist/convex-hull/hull-state.svelte.d.ts +44 -0
- package/dist/convex-hull/hull-state.svelte.js +124 -0
- package/dist/convex-hull/index.d.ts +9 -7
- package/dist/convex-hull/index.js +7 -2
- package/dist/convex-hull/thermodynamics.js +109 -937
- package/dist/convex-hull/types.d.ts +12 -4
- package/dist/convex-hull/types.js +12 -0
- package/dist/coordination/CoordinationBarPlot.svelte +41 -43
- package/dist/coordination/CoordinationBarPlot.svelte.d.ts +1 -1
- package/dist/coordination/calc-coordination.d.ts +1 -1
- package/dist/coordination/calc-coordination.js +28 -25
- package/dist/element/BohrAtom.svelte +6 -8
- package/dist/element/ElementHeading.svelte +4 -1
- package/dist/element/ElementPhoto.svelte +11 -9
- package/dist/element/ElementStats.svelte +12 -10
- package/dist/element/ElementTile.svelte +24 -29
- package/dist/element/ElementTile.svelte.d.ts +1 -1
- package/dist/element/Nucleus.svelte +4 -2
- package/dist/element/data.d.ts +1 -2
- package/dist/element/helpers.d.ts +4 -0
- package/dist/element/helpers.js +18 -0
- package/dist/element/index.d.ts +1 -0
- package/dist/element/index.js +3 -0
- package/dist/feedback/DragOverlay.svelte +5 -3
- package/dist/feedback/DragOverlay.svelte.d.ts +2 -1
- package/dist/feedback/StatusMessage.svelte +20 -7
- package/dist/fermi-surface/FermiSlice.svelte +21 -18
- package/dist/fermi-surface/FermiSurface.svelte +78 -165
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +9 -20
- package/dist/fermi-surface/FermiSurfaceControls.svelte +6 -20
- package/dist/fermi-surface/FermiSurfaceScene.svelte +93 -272
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +3 -23
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +9 -6
- package/dist/fermi-surface/compute.js +14 -13
- package/dist/fermi-surface/export.js +4 -15
- package/dist/fermi-surface/index.d.ts +0 -1
- package/dist/fermi-surface/index.js +0 -1
- package/dist/fermi-surface/parse.d.ts +1 -1
- package/dist/fermi-surface/parse.js +84 -97
- package/dist/fermi-surface/types.d.ts +2 -2
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +161 -185
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +6 -5
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +12 -9
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +5 -5
- package/dist/heatmap-matrix/index.d.ts +8 -2
- package/dist/icons.d.ts +4 -0
- package/dist/icons.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/io/ExportPane.svelte +170 -0
- package/dist/io/ExportPane.svelte.d.ts +17 -0
- package/dist/io/decompress.d.ts +2 -1
- package/dist/io/decompress.js +22 -36
- package/dist/io/export.d.ts +9 -1
- package/dist/io/export.js +37 -29
- package/dist/io/fetch.d.ts +2 -4
- package/dist/io/fetch.js +0 -11
- package/dist/io/file-drop.d.ts +7 -0
- package/dist/io/file-drop.js +13 -0
- package/dist/io/index.d.ts +1 -0
- package/dist/io/index.js +3 -0
- package/dist/io/is-binary.d.ts +9 -0
- package/dist/io/is-binary.js +45 -1
- package/dist/io/types.d.ts +13 -0
- package/dist/io/url-drop.js +13 -25
- package/dist/isosurface/Isosurface.svelte +17 -23
- package/dist/isosurface/IsosurfaceControls.svelte +37 -42
- package/dist/isosurface/parse-vaspwave.d.ts +3 -0
- package/dist/isosurface/parse-vaspwave.js +138 -0
- package/dist/isosurface/parse.js +50 -48
- package/dist/labels.d.ts +6 -2
- package/dist/labels.js +44 -14
- package/dist/layout/FullscreenButton.svelte +34 -0
- package/dist/layout/FullscreenButton.svelte.d.ts +10 -0
- package/dist/layout/FullscreenToggle.svelte +12 -12
- package/dist/layout/InfoCard.svelte +7 -18
- package/dist/layout/InfoTag.svelte +1 -3
- package/dist/layout/NumberRangeInput.svelte +46 -0
- package/dist/layout/NumberRangeInput.svelte.d.ts +12 -0
- package/dist/layout/PropertyFilter.svelte +2 -6
- package/dist/layout/SettingsSection.svelte +21 -17
- package/dist/layout/SubpageGrid.svelte +3 -1
- package/dist/layout/ViewerChrome.svelte +115 -0
- package/dist/layout/ViewerChrome.svelte.d.ts +18 -0
- package/dist/layout/fullscreen.d.ts +4 -0
- package/dist/layout/fullscreen.js +3 -5
- package/dist/layout/fullscreen.svelte.d.ts +8 -0
- package/dist/layout/fullscreen.svelte.js +36 -0
- package/dist/layout/index.d.ts +4 -0
- package/dist/layout/index.js +4 -0
- package/dist/layout/json-tree/JsonNode.svelte +8 -11
- package/dist/layout/json-tree/JsonTree.svelte +53 -77
- package/dist/layout/json-tree/JsonValue.svelte +7 -15
- package/dist/layout/json-tree/utils.js +14 -23
- package/dist/math.d.ts +9 -3
- package/dist/math.js +37 -21
- package/dist/overlays/ContextMenu.svelte +4 -2
- package/dist/overlays/CopyButton.svelte +11 -5
- package/dist/overlays/DragControlTab.svelte +6 -1
- package/dist/overlays/DraggablePane.svelte +81 -26
- package/dist/overlays/DraggablePane.svelte.d.ts +1 -0
- package/dist/overlays/GlassChip.svelte +30 -0
- package/dist/overlays/GlassChip.svelte.d.ts +8 -0
- package/dist/overlays/InfoPaneCards.svelte +11 -23
- package/dist/overlays/index.d.ts +11 -0
- package/dist/overlays/index.js +26 -0
- package/dist/overlays/portal.d.ts +2 -0
- package/dist/overlays/portal.js +14 -0
- package/dist/periodic-table/PeriodicTable.svelte +115 -146
- package/dist/periodic-table/PeriodicTable.svelte.d.ts +5 -3
- package/dist/periodic-table/PeriodicTableControls.svelte +11 -63
- package/dist/periodic-table/TableInset.svelte +9 -4
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +50 -71
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -8
- package/dist/phase-diagram/PhaseDiagramControls.svelte +73 -96
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +4 -3
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +4 -2
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +2 -3
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +49 -134
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +3 -4
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +54 -58
- package/dist/phase-diagram/TdbInfoPanel.svelte +21 -15
- package/dist/phase-diagram/build-diagram.js +3 -3
- package/dist/phase-diagram/colors.js +1 -1
- package/dist/phase-diagram/diagram-input.d.ts +1 -2
- package/dist/phase-diagram/parse.d.ts +2 -1
- package/dist/phase-diagram/parse.js +15 -15
- package/dist/phase-diagram/svg-to-diagram.js +21 -15
- package/dist/phase-diagram/utils.js +2 -3
- package/dist/plot/bar/BarPlot.svelte +494 -692
- package/dist/plot/bar/BarPlot.svelte.d.ts +9 -15
- package/dist/plot/bar/BarPlotControls.svelte +1 -3
- package/dist/plot/bar/BarPlotControls.svelte.d.ts +5 -7
- package/dist/plot/bar/SpacegroupBarPlot.svelte +31 -37
- package/dist/plot/bar/data.d.ts +5 -4
- package/dist/plot/bar/data.js +2 -1
- package/dist/plot/box/BoxPlot.svelte +361 -439
- package/dist/plot/box/BoxPlot.svelte.d.ts +6 -3
- package/dist/plot/box/BoxPlotControls.svelte.d.ts +1 -1
- package/dist/plot/box/Violin.svelte.d.ts +2 -1
- package/dist/plot/box/box-plot.d.ts +3 -2
- package/dist/plot/box/box-plot.js +6 -3
- package/dist/plot/box/kde.d.ts +2 -1
- package/dist/plot/box/kde.js +4 -4
- package/dist/plot/core/auto-place.d.ts +1 -1
- package/dist/plot/core/auto-place.js +5 -2
- package/dist/plot/core/axis-utils.d.ts +12 -7
- package/dist/plot/core/axis-utils.js +48 -48
- package/dist/plot/core/components/AxisLabel.svelte +82 -20
- package/dist/plot/core/components/AxisLabel.svelte.d.ts +1 -0
- package/dist/plot/core/components/ColorBar.svelte +106 -111
- package/dist/plot/core/components/ColorBar.svelte.d.ts +5 -4
- package/dist/plot/core/components/ColorScaleSelect.svelte +1 -1
- package/dist/plot/core/components/FillArea.svelte +10 -17
- package/dist/plot/core/components/HierarchyControls.svelte +249 -0
- package/dist/plot/{sunburst/SunburstControls.svelte.d.ts → core/components/HierarchyControls.svelte.d.ts} +12 -8
- package/dist/plot/core/components/InteractiveAxisLabel.svelte +1 -1
- package/dist/plot/core/components/InteractiveAxisLabel.svelte.d.ts +1 -1
- package/dist/plot/core/components/Line.svelte +21 -11
- package/dist/plot/core/components/Line.svelte.d.ts +5 -2
- package/dist/plot/core/components/PlotAxis.svelte +42 -18
- package/dist/plot/core/components/PlotAxis.svelte.d.ts +2 -1
- package/dist/plot/core/components/PlotControls.svelte +65 -41
- package/dist/plot/core/components/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/core/components/PlotLegend.svelte +31 -35
- package/dist/plot/core/components/PlotMarginals.svelte +616 -0
- package/dist/plot/core/components/PlotMarginals.svelte.d.ts +15 -0
- package/dist/plot/core/components/PlotTooltip.svelte +1 -1
- package/dist/plot/core/components/PortalSelect.svelte +4 -8
- package/dist/plot/core/components/ReferenceLine.svelte +27 -24
- package/dist/plot/core/components/ReferenceLine3D.svelte +56 -59
- package/dist/plot/core/components/ReferenceLine3D.svelte.d.ts +4 -4
- package/dist/plot/core/components/ReferencePlane.svelte +9 -10
- package/dist/plot/core/components/ReferencePlane.svelte.d.ts +4 -4
- package/dist/plot/core/components/ZeroLines.svelte +4 -8
- package/dist/plot/core/components/ZoomRect.svelte +1 -2
- package/dist/plot/core/components/index.d.ts +1 -0
- package/dist/plot/core/components/index.js +1 -0
- package/dist/plot/core/data-cleaning-signal.d.ts +46 -0
- package/dist/plot/core/data-cleaning-signal.js +467 -0
- package/dist/plot/core/data-cleaning.d.ts +2 -42
- package/dist/plot/core/data-cleaning.js +29 -476
- package/dist/plot/core/data-transform.js +9 -5
- package/dist/plot/core/fill-utils.d.ts +7 -4
- package/dist/plot/core/fill-utils.js +34 -9
- package/dist/plot/core/index.d.ts +1 -0
- package/dist/plot/core/index.js +1 -0
- package/dist/plot/core/interactions.d.ts +5 -1
- package/dist/plot/core/interactions.js +14 -2
- package/dist/plot/core/layout.d.ts +3 -1
- package/dist/plot/core/layout.js +22 -13
- package/dist/plot/core/marginals.d.ts +170 -0
- package/dist/plot/core/marginals.js +436 -0
- package/dist/plot/core/pan-zoom.svelte.d.ts +35 -0
- package/dist/plot/core/pan-zoom.svelte.js +221 -0
- package/dist/plot/core/placed-tween.svelte.d.ts +21 -0
- package/dist/plot/core/placed-tween.svelte.js +68 -0
- package/dist/plot/core/reference-line.d.ts +10 -10
- package/dist/plot/core/reference-line.js +7 -7
- package/dist/plot/core/scales.d.ts +40 -25
- package/dist/plot/core/scales.js +49 -21
- package/dist/plot/core/svg.d.ts +2 -1
- package/dist/plot/core/types/fills.d.ts +101 -0
- package/dist/plot/core/types/fills.js +15 -0
- package/dist/plot/core/types/plot-3d.d.ts +87 -0
- package/dist/plot/core/types/plot-3d.js +4 -0
- package/dist/plot/core/types/reference-lines.d.ts +140 -0
- package/dist/plot/core/types/reference-lines.js +9 -0
- package/dist/plot/core/types.d.ts +47 -331
- package/dist/plot/core/types.js +23 -20
- package/dist/plot/core/utils/hierarchy-chart.d.ts +51 -0
- package/dist/plot/core/utils/hierarchy-chart.js +179 -0
- package/dist/plot/core/utils/hierarchy-labels.d.ts +20 -0
- package/dist/plot/core/utils/hierarchy-labels.js +99 -0
- package/dist/plot/core/utils/label-placement.d.ts +1 -1
- package/dist/plot/core/utils/label-placement.js +5 -5
- package/dist/plot/core/utils.d.ts +2 -1
- package/dist/plot/histogram/Histogram.svelte +373 -631
- package/dist/plot/histogram/Histogram.svelte.d.ts +7 -7
- package/dist/plot/histogram/HistogramControls.svelte +30 -28
- package/dist/plot/histogram/HistogramControls.svelte.d.ts +1 -1
- package/dist/plot/histogram/histogram.d.ts +31 -0
- package/dist/plot/histogram/histogram.js +70 -0
- package/dist/plot/histogram/index.d.ts +1 -0
- package/dist/plot/histogram/index.js +1 -0
- package/dist/plot/index.d.ts +1 -0
- package/dist/plot/index.js +1 -0
- package/dist/plot/sankey/Sankey.svelte +79 -73
- package/dist/plot/sankey/Sankey.svelte.d.ts +3 -3
- package/dist/plot/sankey/SankeyControls.svelte +22 -16
- package/dist/plot/sankey/sankey.js +3 -1
- package/dist/plot/scatter/BinnedScatterPlot.svelte +264 -112
- package/dist/plot/scatter/BinnedScatterPlot.svelte.d.ts +11 -4
- package/dist/plot/scatter/ElementScatter.svelte +4 -1
- package/dist/plot/scatter/ScatterPlot.svelte +623 -821
- package/dist/plot/scatter/ScatterPlot.svelte.d.ts +9 -15
- package/dist/plot/scatter/ScatterPlotControls.svelte +18 -19
- package/dist/plot/scatter/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/scatter/ScatterPoint.svelte +16 -9
- package/dist/plot/scatter/binned-scatter-types.d.ts +6 -12
- package/dist/plot/scatter/binned-scatter-types.js +6 -1
- package/dist/plot/scatter/index.d.ts +1 -1
- package/dist/plot/scatter/scatter-data.d.ts +1 -1
- package/dist/plot/scatter/scatter-data.js +8 -7
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte +40 -60
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte.d.ts +6 -14
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte +17 -15
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte.d.ts +5 -5
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte +232 -234
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte.d.ts +5 -14
- package/dist/plot/scatter-3d/Surface3D.svelte +9 -17
- package/dist/plot/scatter-3d/Surface3D.svelte.d.ts +4 -3
- package/dist/plot/sunburst/Sunburst.svelte +256 -338
- package/dist/plot/sunburst/Sunburst.svelte.d.ts +4 -3
- package/dist/plot/sunburst/index.d.ts +1 -1
- package/dist/plot/sunburst/index.js +2 -1
- package/dist/plot/sunburst/render.d.ts +2 -2
- package/dist/plot/sunburst/render.js +47 -22
- package/dist/plot/sunburst/sunburst.d.ts +5 -1
- package/dist/plot/sunburst/sunburst.js +14 -4
- package/dist/plot/treemap/Treemap.svelte +907 -0
- package/dist/plot/treemap/Treemap.svelte.d.ts +84 -0
- package/dist/plot/treemap/index.d.ts +3 -0
- package/dist/plot/treemap/index.js +4 -0
- package/dist/plot/treemap/treemap.d.ts +26 -0
- package/dist/plot/treemap/treemap.js +99 -0
- package/dist/rdf/RdfPlot.svelte +22 -26
- package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
- package/dist/rdf/calc-rdf.js +4 -8
- package/dist/sanitize.js +14 -3
- package/dist/scene/SceneCamera.svelte +62 -0
- package/dist/scene/SceneCamera.svelte.d.ts +19 -0
- package/dist/scene/bind-renderer.svelte.d.ts +2 -0
- package/dist/scene/bind-renderer.svelte.js +22 -0
- package/dist/scene/index.d.ts +4 -0
- package/dist/scene/index.js +5 -0
- package/dist/scene/props.js +52 -0
- package/dist/scene/types.d.ts +26 -0
- package/dist/scene/types.js +1 -0
- package/dist/settings.d.ts +33 -11
- package/dist/settings.js +136 -51
- package/dist/spectral/Bands.svelte +231 -237
- package/dist/spectral/Bands.svelte.d.ts +3 -2
- package/dist/spectral/BandsAndDos.svelte +29 -29
- package/dist/spectral/BrillouinBandsDos.svelte +21 -29
- package/dist/spectral/Dos.svelte +75 -77
- package/dist/spectral/Dos.svelte.d.ts +2 -1
- package/dist/spectral/helpers.d.ts +9 -9
- package/dist/spectral/helpers.js +66 -70
- package/dist/state.svelte.d.ts +0 -7
- package/dist/state.svelte.js +5 -24
- package/dist/structure/Arrow.svelte +6 -21
- package/dist/structure/ArrowInstances.svelte +160 -0
- package/dist/structure/ArrowInstances.svelte.d.ts +16 -0
- package/dist/structure/AtomLegend.svelte +115 -75
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/Bond.svelte +31 -23
- package/dist/structure/CanvasTooltip.svelte +16 -3
- package/dist/structure/CellSelect.svelte +22 -29
- package/dist/structure/CellSelect.svelte.d.ts +2 -1
- package/dist/structure/Cylinder.svelte +24 -40
- package/dist/structure/InstancedAtoms.svelte +114 -0
- package/dist/structure/InstancedAtoms.svelte.d.ts +15 -0
- package/dist/structure/Lattice.svelte +85 -149
- package/dist/structure/SiteLabels.svelte +122 -0
- package/dist/structure/SiteLabels.svelte.d.ts +18 -0
- package/dist/structure/Structure.svelte +725 -735
- package/dist/structure/Structure.svelte.d.ts +8 -16
- package/dist/structure/StructureCarousel.svelte +630 -0
- package/dist/structure/StructureCarousel.svelte.d.ts +19 -0
- package/dist/structure/StructureControls.svelte +298 -325
- package/dist/structure/StructureControls.svelte.d.ts +5 -3
- package/dist/structure/StructureExportPane.svelte +62 -168
- package/dist/structure/StructureExportPane.svelte.d.ts +4 -5
- package/dist/structure/StructureInfoPane.svelte +77 -69
- package/dist/structure/StructureInfoPane.svelte.d.ts +6 -6
- package/dist/structure/StructureScene.svelte +758 -600
- package/dist/structure/StructureScene.svelte.d.ts +24 -20
- package/dist/structure/StructureViewport.svelte +386 -0
- package/dist/structure/StructureViewport.svelte.d.ts +63 -0
- package/dist/structure/atom-label-placement.d.ts +18 -0
- package/dist/structure/atom-label-placement.js +115 -0
- package/dist/structure/atom-properties.d.ts +3 -1
- package/dist/structure/atom-properties.js +115 -54
- package/dist/structure/bond-order-perception.js +2 -4
- package/dist/structure/bonding.d.ts +12 -2
- package/dist/structure/bonding.js +172 -73
- package/dist/structure/edit-history.d.ts +6 -0
- package/dist/structure/edit-history.js +27 -0
- package/dist/structure/export.d.ts +25 -4
- package/dist/structure/export.js +103 -153
- package/dist/structure/format-detect.d.ts +1 -0
- package/dist/structure/format-detect.js +22 -0
- package/dist/structure/geometry.d.ts +9 -0
- package/dist/structure/geometry.js +27 -0
- package/dist/structure/index.d.ts +18 -1
- package/dist/structure/index.js +15 -2
- package/dist/structure/measure.d.ts +1 -1
- package/dist/structure/measure.js +6 -12
- package/dist/structure/parse.d.ts +5 -3
- package/dist/structure/parse.js +551 -567
- package/dist/structure/partial-occupancy.d.ts +0 -1
- package/dist/structure/partial-occupancy.js +5 -3
- package/dist/structure/pbc.d.ts +1 -1
- package/dist/structure/pbc.js +204 -51
- package/dist/structure/polyhedra.d.ts +40 -0
- package/dist/structure/polyhedra.js +587 -0
- package/dist/structure/site.d.ts +4 -0
- package/dist/structure/site.js +1 -0
- package/dist/structure/supercell.d.ts +1 -2
- package/dist/structure/supercell.js +10 -15
- package/dist/structure/validation.js +5 -6
- package/dist/symmetry/SymmetryElementControls.svelte +69 -0
- package/dist/symmetry/SymmetryElementControls.svelte.d.ts +9 -0
- package/dist/symmetry/SymmetryElements.svelte +350 -0
- package/dist/symmetry/SymmetryElements.svelte.d.ts +24 -0
- package/dist/symmetry/SymmetryStats.svelte +142 -49
- package/dist/symmetry/WyckoffTable.svelte +58 -16
- package/dist/symmetry/WyckoffTable.svelte.d.ts +3 -0
- package/dist/symmetry/cell-transform.js +8 -14
- package/dist/symmetry/index.d.ts +15 -4
- package/dist/symmetry/index.js +308 -81
- package/dist/symmetry/spacegroups.d.ts +5 -1
- package/dist/symmetry/spacegroups.js +18 -3
- package/dist/symmetry/symmetry-elements.d.ts +33 -0
- package/dist/symmetry/symmetry-elements.js +521 -0
- package/dist/symmetry/wyckoff-db.d.ts +9 -0
- package/dist/symmetry/wyckoff-db.js +87 -0
- package/dist/table/HeatmapTable.svelte +1104 -378
- package/dist/table/HeatmapTable.svelte.d.ts +12 -2
- package/dist/table/ToggleMenu.svelte +5 -12
- package/dist/table/index.d.ts +21 -6
- package/dist/table/index.js +34 -21
- package/dist/theme/ThemeControl.svelte +16 -8
- package/dist/theme/index.d.ts +1 -5
- package/dist/theme/index.js +4 -10
- package/dist/theme/themes.mjs +14 -7
- package/dist/tooltip/KCoords.svelte +4 -1
- package/dist/tooltip/TooltipContent.svelte +2 -5
- package/dist/trajectory/Trajectory.svelte +556 -352
- package/dist/trajectory/Trajectory.svelte.d.ts +10 -22
- package/dist/trajectory/TrajectoryError.svelte +11 -8
- package/dist/trajectory/TrajectoryExportPane.svelte +28 -54
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +4 -5
- package/dist/trajectory/TrajectoryInfoPane.svelte +88 -99
- package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +3 -2
- package/dist/trajectory/constants.js +6 -2
- package/dist/trajectory/extract.js +73 -71
- package/dist/trajectory/format-detect.d.ts +0 -1
- package/dist/trajectory/format-detect.js +13 -17
- package/dist/trajectory/frame-reader.d.ts +2 -1
- package/dist/trajectory/frame-reader.js +74 -136
- package/dist/trajectory/helpers.d.ts +12 -2
- package/dist/trajectory/helpers.js +68 -37
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +3 -0
- package/dist/trajectory/parse/ase.d.ts +9 -1
- package/dist/trajectory/parse/ase.js +47 -32
- package/dist/trajectory/parse/diagnostics.d.ts +3 -0
- package/dist/trajectory/parse/diagnostics.js +14 -0
- package/dist/trajectory/parse/h5-utils.d.ts +13 -0
- package/dist/trajectory/parse/h5-utils.js +109 -0
- package/dist/trajectory/parse/hdf5.d.ts +1 -1
- package/dist/trajectory/parse/hdf5.js +116 -106
- package/dist/trajectory/parse/index.d.ts +3 -4
- package/dist/trajectory/parse/index.js +68 -119
- package/dist/trajectory/parse/lammps.d.ts +0 -2
- package/dist/trajectory/parse/lammps.js +14 -16
- package/dist/trajectory/parse/pymatgen.d.ts +2 -0
- package/dist/trajectory/parse/pymatgen.js +74 -0
- package/dist/trajectory/parse/vasp.js +13 -9
- package/dist/trajectory/parse/vaspout-electronic.d.ts +13 -0
- package/dist/trajectory/parse/vaspout-electronic.js +207 -0
- package/dist/trajectory/parse/vaspout-h5.d.ts +5 -0
- package/dist/trajectory/parse/vaspout-h5.js +284 -0
- package/dist/trajectory/parse/xyz.d.ts +9 -21
- package/dist/trajectory/parse/xyz.js +38 -39
- package/dist/trajectory/plotting.d.ts +8 -10
- package/dist/trajectory/plotting.js +102 -127
- package/dist/utils.d.ts +4 -0
- package/dist/utils.js +8 -1
- package/dist/xrd/XrdPlot.svelte +56 -85
- package/dist/xrd/broadening.d.ts +2 -1
- package/dist/xrd/broadening.js +2 -1
- package/dist/xrd/calc-xrd.js +8 -15
- package/dist/xrd/index.d.ts +2 -2
- package/dist/xrd/parse.d.ts +0 -1
- package/dist/xrd/parse.js +56 -73
- package/package.json +77 -36
- package/dist/api/mp.d.ts +0 -6
- package/dist/api/mp.js +0 -22
- package/dist/element/data.json +0 -11864
- package/dist/fermi-surface/marching-cubes.d.ts +0 -2
- package/dist/fermi-surface/marching-cubes.js +0 -2
- package/dist/plot/core/hover-lock.svelte.d.ts +0 -14
- package/dist/plot/core/hover-lock.svelte.js +0 -45
- package/dist/plot/sunburst/SunburstControls.svelte +0 -200
- package/dist/structure/label-placement.d.ts +0 -14
- package/dist/structure/label-placement.js +0 -72
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// All atoms of one visual class (base or ghosted PBC image) in a single
|
|
3
|
+
// THREE.InstancedMesh: one draw call and zero per-atom Svelte components.
|
|
4
|
+
// Per-atom colors live in the instanceColor buffer, per-atom position/radius
|
|
5
|
+
// in the instanceMatrix buffer. Pointer handlers spread onto the mesh receive
|
|
6
|
+
// threlte intersection events whose `instanceId` indexes into `atoms`.
|
|
7
|
+
//
|
|
8
|
+
// This replaces one <extras.Instance> component (plus one scene-graph Group and
|
|
9
|
+
// one interactivity registration) per atom, which made structure changes on
|
|
10
|
+
// supercells block the main thread for seconds and hover raycasts O(n²).
|
|
11
|
+
import type { Vec3 } from '../math'
|
|
12
|
+
import { T, useThrelte } from '@threlte/core'
|
|
13
|
+
import { untrack } from 'svelte'
|
|
14
|
+
import { Color, InstancedMesh, Matrix4, MeshStandardMaterial, SphereGeometry } from 'three'
|
|
15
|
+
|
|
16
|
+
type InstancedAtom = {
|
|
17
|
+
position: Vec3
|
|
18
|
+
radius: number
|
|
19
|
+
color?: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let {
|
|
23
|
+
atoms,
|
|
24
|
+
sphere_segments = 20,
|
|
25
|
+
ghost = false,
|
|
26
|
+
...pointer_props
|
|
27
|
+
}: {
|
|
28
|
+
atoms: InstancedAtom[]
|
|
29
|
+
sphere_segments?: number
|
|
30
|
+
// edit-mode PBC image atoms: desaturated + translucent
|
|
31
|
+
ghost?: boolean
|
|
32
|
+
// threlte interactivity handlers (onpointerenter, onclick, ...) forwarded to the mesh
|
|
33
|
+
[key: string]: unknown
|
|
34
|
+
} = $props()
|
|
35
|
+
|
|
36
|
+
const { invalidate } = useThrelte()
|
|
37
|
+
|
|
38
|
+
// One material shared across mesh recreations; per-atom colors come from the
|
|
39
|
+
// instanceColor buffer so the base color stays white.
|
|
40
|
+
const material = new MeshStandardMaterial()
|
|
41
|
+
$effect(() => () => material.dispose())
|
|
42
|
+
|
|
43
|
+
$effect(() => {
|
|
44
|
+
material.transparent = ghost
|
|
45
|
+
material.opacity = ghost ? 0.5 : 1
|
|
46
|
+
material.needsUpdate = true
|
|
47
|
+
invalidate()
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
let geometry = $state.raw<SphereGeometry | null>(null)
|
|
51
|
+
$effect(() => {
|
|
52
|
+
const geo = new SphereGeometry(0.5, sphere_segments, sphere_segments)
|
|
53
|
+
geometry = geo
|
|
54
|
+
return () => geo.dispose()
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
// Recreate the mesh only when capacity must change (instanceMatrix buffer size
|
|
58
|
+
// is fixed at construction); data updates just rewrite the buffers below.
|
|
59
|
+
let mesh = $state.raw<InstancedMesh | null>(null)
|
|
60
|
+
$effect(() => {
|
|
61
|
+
const count = atoms.length
|
|
62
|
+
const prev = untrack(() => mesh)
|
|
63
|
+
if (prev && prev.count === count) return
|
|
64
|
+
prev?.dispose()
|
|
65
|
+
if (count === 0) {
|
|
66
|
+
mesh = null
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
const next = new InstancedMesh(untrack(() => geometry) ?? undefined, material, count)
|
|
70
|
+
next.frustumCulled = false
|
|
71
|
+
// export.ts reads per-instance colors (instead of the material color) when set
|
|
72
|
+
next.userData.per_instance_color = true
|
|
73
|
+
mesh = next
|
|
74
|
+
})
|
|
75
|
+
// Unmount-only cleanup (a cleanup on the effect above would dispose the mesh
|
|
76
|
+
// on every re-run, including runs that keep it; cleanups run untracked)
|
|
77
|
+
$effect(() => () => mesh?.dispose())
|
|
78
|
+
|
|
79
|
+
$effect(() => {
|
|
80
|
+
if (mesh && geometry && mesh.geometry !== geometry) {
|
|
81
|
+
mesh.geometry = geometry
|
|
82
|
+
invalidate()
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
const scratch_matrix = new Matrix4()
|
|
87
|
+
const scratch_color = new Color()
|
|
88
|
+
const gray = new Color(0x999999)
|
|
89
|
+
|
|
90
|
+
$effect(() => {
|
|
91
|
+
const current = mesh
|
|
92
|
+
if (!current) return
|
|
93
|
+
const limit = Math.min(atoms.length, current.count)
|
|
94
|
+
for (let idx = 0; idx < limit; idx++) {
|
|
95
|
+
const { position, radius, color } = atoms[idx]
|
|
96
|
+
scratch_matrix
|
|
97
|
+
.makeScale(radius, radius, radius)
|
|
98
|
+
.setPosition(position[0], position[1], position[2])
|
|
99
|
+
current.setMatrixAt(idx, scratch_matrix)
|
|
100
|
+
scratch_color.set(color ?? gray)
|
|
101
|
+
if (ghost) scratch_color.lerp(gray, 0.4)
|
|
102
|
+
current.setColorAt(idx, scratch_color)
|
|
103
|
+
}
|
|
104
|
+
current.instanceMatrix.needsUpdate = true
|
|
105
|
+
if (current.instanceColor) current.instanceColor.needsUpdate = true
|
|
106
|
+
// keep the whole-mesh bounding sphere in sync so raycasts can early-reject
|
|
107
|
+
current.computeBoundingSphere()
|
|
108
|
+
invalidate()
|
|
109
|
+
})
|
|
110
|
+
</script>
|
|
111
|
+
|
|
112
|
+
{#if mesh}
|
|
113
|
+
<T is={mesh} {...pointer_props} />
|
|
114
|
+
{/if}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Vec3 } from '../math';
|
|
2
|
+
type InstancedAtom = {
|
|
3
|
+
position: Vec3;
|
|
4
|
+
radius: number;
|
|
5
|
+
color?: string;
|
|
6
|
+
};
|
|
7
|
+
type $$ComponentProps = {
|
|
8
|
+
atoms: InstancedAtom[];
|
|
9
|
+
sphere_segments?: number;
|
|
10
|
+
ghost?: boolean;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
declare const InstancedAtoms: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
14
|
+
type InstancedAtoms = ReturnType<typeof InstancedAtoms>;
|
|
15
|
+
export default InstancedAtoms;
|
|
@@ -5,15 +5,10 @@
|
|
|
5
5
|
import * as math from '../math'
|
|
6
6
|
import { DEFAULTS } from '../settings'
|
|
7
7
|
import { CanvasTooltip } from './'
|
|
8
|
+
import Arrow from './Arrow.svelte'
|
|
9
|
+
import Cylinder from './Cylinder.svelte'
|
|
8
10
|
import { T } from '@threlte/core'
|
|
9
|
-
import {
|
|
10
|
-
BoxGeometry,
|
|
11
|
-
EdgesGeometry,
|
|
12
|
-
Euler,
|
|
13
|
-
Matrix4,
|
|
14
|
-
Quaternion,
|
|
15
|
-
Vector3,
|
|
16
|
-
} from 'three'
|
|
11
|
+
import { BoxGeometry, EdgesGeometry, Matrix4, Vector3 } from 'three'
|
|
17
12
|
|
|
18
13
|
let {
|
|
19
14
|
matrix = undefined,
|
|
@@ -24,7 +19,7 @@
|
|
|
24
19
|
cell_surface_opacity = DEFAULTS.structure.cell_surface_opacity,
|
|
25
20
|
show_cell_vectors = true,
|
|
26
21
|
vector_colors = [`red`, `green`, `blue`],
|
|
27
|
-
vector_origin = [-1, -1, -1]
|
|
22
|
+
vector_origin = [-1, -1, -1],
|
|
28
23
|
float_fmt = `.2f`,
|
|
29
24
|
}: {
|
|
30
25
|
matrix?: math.Matrix3x3
|
|
@@ -40,157 +35,98 @@
|
|
|
40
35
|
} = $props()
|
|
41
36
|
|
|
42
37
|
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),
|
|
38
|
+
let lattice_center: Vec3 = $derived(
|
|
39
|
+
matrix ? math.scale(math.add(...matrix), 0.5) : [0, 0, 0],
|
|
47
40
|
)
|
|
48
41
|
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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])
|
|
66
|
-
}
|
|
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
|
-
|
|
80
|
-
if (length === 0) { // Zero-length: no rotation; render a degenerate cylinder
|
|
81
|
-
return { position: center.toArray(), rotation: [0, 0, 0], length }
|
|
42
|
+
// Build the sheared box geometry in an effect so the previous one is disposed on
|
|
43
|
+
// matrix change / unmount (same disposal pattern as the polyhedra in StructureScene).
|
|
44
|
+
let box_geometry = $state<BoxGeometry | null>(null)
|
|
45
|
+
$effect(() => {
|
|
46
|
+
if (!matrix) {
|
|
47
|
+
box_geometry = null
|
|
48
|
+
return
|
|
82
49
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
new Vector3(
|
|
86
|
-
|
|
50
|
+
const shear_matrix = new Matrix4().makeBasis(
|
|
51
|
+
new Vector3(...matrix[0]),
|
|
52
|
+
new Vector3(...matrix[1]),
|
|
53
|
+
new Vector3(...matrix[2]),
|
|
87
54
|
)
|
|
88
|
-
const
|
|
55
|
+
const geo = new BoxGeometry(1, 1, 1).applyMatrix4(shear_matrix)
|
|
56
|
+
box_geometry = geo
|
|
57
|
+
return () => geo.dispose()
|
|
58
|
+
})
|
|
89
59
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
60
|
+
// Edge segments (Cartesian endpoint pairs) from the box geometry; the transient
|
|
61
|
+
// EdgesGeometry is disposed inline since only its extracted positions are kept.
|
|
62
|
+
let edge_segments = $derived.by<[Vec3, Vec3][]>(() => {
|
|
63
|
+
if (!box_geometry || !(cell_edge_opacity > 0)) return []
|
|
64
|
+
const edges_geometry = new EdgesGeometry(box_geometry)
|
|
65
|
+
const positions = edges_geometry.getAttribute(`position`).array as Float32Array
|
|
66
|
+
edges_geometry.dispose()
|
|
67
|
+
const segments: [Vec3, Vec3][] = []
|
|
68
|
+
// each edge is two consecutive xyz triplets (6 floats)
|
|
69
|
+
for (let idx = 0; idx < positions.length; idx += 6) {
|
|
70
|
+
segments.push([
|
|
71
|
+
[positions[idx], positions[idx + 1], positions[idx + 2]],
|
|
72
|
+
[positions[idx + 3], positions[idx + 4], positions[idx + 5]],
|
|
73
|
+
])
|
|
94
74
|
}
|
|
95
|
-
|
|
75
|
+
return segments
|
|
76
|
+
})
|
|
96
77
|
</script>
|
|
97
78
|
|
|
98
|
-
{#if matrix}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
{@const edges_geometry = new EdgesGeometry(box_geometry)}
|
|
110
|
-
{@const edge_segments = get_edge_segments(edges_geometry)}
|
|
111
|
-
|
|
112
|
-
<!-- Use cylinders for thick wireframe lines -->
|
|
113
|
-
<T.Group position={lattice_center}>
|
|
114
|
-
{#each edge_segments as [start, end], idx (idx)}
|
|
115
|
-
{@const { position, rotation, length } = get_cylinder_transform(start, end)}
|
|
116
|
-
<T.Mesh {position} {rotation}>
|
|
117
|
-
<T.CylinderGeometry
|
|
118
|
-
args={[cell_edge_width * 0.01, cell_edge_width * 0.01, length, 8]}
|
|
119
|
-
/>
|
|
120
|
-
<T.MeshStandardMaterial
|
|
121
|
-
color={cell_edge_color}
|
|
122
|
-
opacity={cell_edge_opacity}
|
|
123
|
-
transparent
|
|
124
|
-
depthWrite={false}
|
|
125
|
-
/>
|
|
126
|
-
</T.Mesh>
|
|
127
|
-
{/each}
|
|
128
|
-
</T.Group>
|
|
129
|
-
{/if}
|
|
130
|
-
|
|
131
|
-
<!-- Render transparent surfaces if surface opacity > 0 -->
|
|
132
|
-
{#if cell_surface_opacity > 0}
|
|
133
|
-
<T.Mesh geometry={box_geometry} position={lattice_center}>
|
|
134
|
-
<T.MeshStandardMaterial
|
|
135
|
-
color={cell_surface_color}
|
|
136
|
-
opacity={cell_surface_opacity}
|
|
137
|
-
transparent
|
|
138
|
-
depthWrite={false}
|
|
79
|
+
{#if matrix && box_geometry}
|
|
80
|
+
<!-- Wireframe edges (thick lines via cylinders) when edge opacity > 0 -->
|
|
81
|
+
{#if cell_edge_opacity > 0}
|
|
82
|
+
<T.Group position={lattice_center}>
|
|
83
|
+
{#each edge_segments as [start, end], idx (idx)}
|
|
84
|
+
<Cylinder
|
|
85
|
+
from={start}
|
|
86
|
+
to={end}
|
|
87
|
+
thickness={cell_edge_width * 0.01}
|
|
88
|
+
color={cell_edge_color}
|
|
89
|
+
opacity={cell_edge_opacity}
|
|
139
90
|
/>
|
|
140
|
-
|
|
141
|
-
|
|
91
|
+
{/each}
|
|
92
|
+
</T.Group>
|
|
93
|
+
{/if}
|
|
142
94
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
)}
|
|
155
|
-
{@const rotation = new Euler()
|
|
156
|
-
.setFromQuaternion(quaternion)
|
|
157
|
-
.toArray()
|
|
158
|
-
.slice(0, 3) as Vec3}
|
|
159
|
-
<!-- Arrow shaft - position at center of shaft length -->
|
|
160
|
-
{@const shaft_center = math.scale(vec, 0.425) as Vec3}
|
|
161
|
-
<!-- Center at 42.5% = half of 85% -->
|
|
162
|
-
<T.Mesh
|
|
163
|
-
position={shaft_center}
|
|
164
|
-
{rotation}
|
|
165
|
-
onpointerenter={() => hovered_idx = idx}
|
|
166
|
-
onpointerleave={() => hovered_idx = null}
|
|
167
|
-
>
|
|
168
|
-
<T.CylinderGeometry args={[0.05, 0.05, shaft_length, 16]} />
|
|
169
|
-
<T.MeshStandardMaterial color={vector_colors[idx]} />
|
|
170
|
-
</T.Mesh>
|
|
95
|
+
<!-- Render transparent surfaces if surface opacity > 0 -->
|
|
96
|
+
{#if cell_surface_opacity > 0}
|
|
97
|
+
<T.Mesh geometry={box_geometry} position={lattice_center}>
|
|
98
|
+
<T.MeshStandardMaterial
|
|
99
|
+
color={cell_surface_color}
|
|
100
|
+
opacity={cell_surface_opacity}
|
|
101
|
+
transparent
|
|
102
|
+
depthWrite={false}
|
|
103
|
+
/>
|
|
104
|
+
</T.Mesh>
|
|
105
|
+
{/if}
|
|
171
106
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
{
|
|
183
|
-
|
|
107
|
+
{#if show_cell_vectors}
|
|
108
|
+
{#each matrix as vec, idx (vec)}
|
|
109
|
+
<Arrow
|
|
110
|
+
position={vector_origin}
|
|
111
|
+
vector={vec}
|
|
112
|
+
scale={0.5}
|
|
113
|
+
color={vector_colors[idx]}
|
|
114
|
+
shaft_radius={0.1}
|
|
115
|
+
arrow_head_radius={0.2}
|
|
116
|
+
arrow_head_length={0.8}
|
|
117
|
+
onpointerenter={() => (hovered_idx = idx)}
|
|
118
|
+
onpointerleave={() => (hovered_idx = null)}
|
|
119
|
+
/>
|
|
120
|
+
{/each}
|
|
184
121
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
{/if}
|
|
122
|
+
<!-- Tooltip for hovered vector -->
|
|
123
|
+
{#if hovered_idx !== null && matrix}
|
|
124
|
+
{@const hovered_vec = matrix[hovered_idx]}
|
|
125
|
+
{@const tooltip_position = math.add(vector_origin, hovered_vec)}
|
|
126
|
+
<CanvasTooltip position={tooltip_position}>
|
|
127
|
+
<strong>{[`A`, `B`, `C`][hovered_idx]}</strong>
|
|
128
|
+
({hovered_vec.map((coord) => format_num(coord, float_fmt)).join(`, `)}) Å
|
|
129
|
+
</CanvasTooltip>
|
|
194
130
|
{/if}
|
|
195
|
-
{/
|
|
131
|
+
{/if}
|
|
196
132
|
{/if}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// Single overlay for all site labels: one portaled DOM container plus one
|
|
3
|
+
// per-frame position pass. Replaces per-label threlte <HTML> components (each
|
|
4
|
+
// of which carries its own portal, per-frame task and matrix updates), which
|
|
5
|
+
// made labels on large structures/supercells unusable.
|
|
6
|
+
import type { Vec3 } from '../math'
|
|
7
|
+
import { T, useTask, useThrelte } from '@threlte/core'
|
|
8
|
+
import type { Snippet } from 'svelte'
|
|
9
|
+
import { Group } from 'three'
|
|
10
|
+
import { type LabelPlacement, LabelProjector } from './atom-label-placement'
|
|
11
|
+
|
|
12
|
+
type SiteLabelEntry = {
|
|
13
|
+
site_idx: number
|
|
14
|
+
position: Vec3 // in the local space of the surrounding rotation groups
|
|
15
|
+
radius: number // visual atom scale (SphereGeometry(0.5) scale factor)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
entries,
|
|
20
|
+
get_offset,
|
|
21
|
+
screen_margin,
|
|
22
|
+
label,
|
|
23
|
+
}: {
|
|
24
|
+
entries: SiteLabelEntry[]
|
|
25
|
+
get_offset: (site_idx: number) => Vec3
|
|
26
|
+
screen_margin: number
|
|
27
|
+
label: Snippet<[{ site_idx: number }]>
|
|
28
|
+
} = $props()
|
|
29
|
+
|
|
30
|
+
const { camera, size, dom, renderStage } = useThrelte()
|
|
31
|
+
|
|
32
|
+
// Anchor object inside the scene's rotation groups so label positions follow
|
|
33
|
+
// the same transform as the atoms they annotate.
|
|
34
|
+
const anchor = new Group()
|
|
35
|
+
let container = $state<HTMLDivElement>()
|
|
36
|
+
|
|
37
|
+
const projector = new LabelProjector()
|
|
38
|
+
const placement: LabelPlacement = { x: 0, y: 0, visible: false }
|
|
39
|
+
// Cache last-applied transform per label to skip redundant style writes
|
|
40
|
+
let last_transforms: string[] = []
|
|
41
|
+
|
|
42
|
+
function update_positions() {
|
|
43
|
+
const cam = camera.current
|
|
44
|
+
if (!container || !cam) return
|
|
45
|
+
cam.updateMatrixWorld()
|
|
46
|
+
anchor.updateWorldMatrix(true, false)
|
|
47
|
+
projector.update(cam, anchor.matrixWorld, size.current, screen_margin)
|
|
48
|
+
// Read reactive props once, not per label (prop getters cross a component
|
|
49
|
+
// boundary and would otherwise run 2-3x per label per frame)
|
|
50
|
+
const items = entries
|
|
51
|
+
const offset_of = get_offset
|
|
52
|
+
const kids = container.children
|
|
53
|
+
for (let idx = 0; idx < items.length; idx++) {
|
|
54
|
+
const el = kids[idx] as HTMLElement | undefined
|
|
55
|
+
if (!el) break
|
|
56
|
+
const entry = items[idx]
|
|
57
|
+
projector.place(entry.position, offset_of(entry.site_idx), entry.radius * 0.5, placement)
|
|
58
|
+
// Hide labels behind the camera (same check as threlte's <HTML>)
|
|
59
|
+
if (!placement.visible) {
|
|
60
|
+
if (el.style.display !== `none`) el.style.display = `none`
|
|
61
|
+
continue
|
|
62
|
+
}
|
|
63
|
+
if (el.style.display === `none`) el.style.display = ``
|
|
64
|
+
const transform = `translate(-50%, -50%) translate3d(${placement.x.toFixed(1)}px, ${placement.y.toFixed(
|
|
65
|
+
1,
|
|
66
|
+
)}px, 0)`
|
|
67
|
+
if (last_transforms[idx] !== transform) {
|
|
68
|
+
last_transforms[idx] = transform
|
|
69
|
+
el.style.transform = transform
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Follow camera motion (runs only on rendered frames, like threlte's <HTML>)
|
|
75
|
+
useTask(update_positions, { stage: renderStage, autoInvalidate: false })
|
|
76
|
+
|
|
77
|
+
// Immediate repositioning when label data, offsets or viewport size changes.
|
|
78
|
+
// update_positions is deliberately tracked: it reads entries, screen_margin and
|
|
79
|
+
// (via get_offset) the scene's offset state, so offset changes re-run this
|
|
80
|
+
// effect even when no frame is scheduled.
|
|
81
|
+
$effect(() => {
|
|
82
|
+
void $size
|
|
83
|
+
last_transforms = []
|
|
84
|
+
update_positions()
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
const portal_action = (el: HTMLElement) => {
|
|
88
|
+
if (!dom) return
|
|
89
|
+
dom.append(el)
|
|
90
|
+
return { destroy: () => el.remove() }
|
|
91
|
+
}
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
<T is={anchor} />
|
|
95
|
+
|
|
96
|
+
<div bind:this={container} class="site-labels-overlay" use:portal_action>
|
|
97
|
+
{#each entries as entry (entry.site_idx)}
|
|
98
|
+
<div class="site-label">
|
|
99
|
+
{@render label({ site_idx: entry.site_idx })}
|
|
100
|
+
</div>
|
|
101
|
+
{/each}
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<style>
|
|
105
|
+
.site-labels-overlay {
|
|
106
|
+
position: absolute;
|
|
107
|
+
top: 0;
|
|
108
|
+
left: 0;
|
|
109
|
+
pointer-events: none;
|
|
110
|
+
}
|
|
111
|
+
.site-label {
|
|
112
|
+
position: absolute;
|
|
113
|
+
top: 0;
|
|
114
|
+
left: 0;
|
|
115
|
+
pointer-events: auto;
|
|
116
|
+
white-space: nowrap;
|
|
117
|
+
/* measured A/B (888 labels, 2x2x2 supercell, auto-rotating, dpr 2): 60fps
|
|
118
|
+
with will-change vs ~34fps without - promoting labels to their own layers
|
|
119
|
+
avoids repaints when only transforms change */
|
|
120
|
+
will-change: transform;
|
|
121
|
+
}
|
|
122
|
+
</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Vec3 } from '../math';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
type SiteLabelEntry = {
|
|
4
|
+
site_idx: number;
|
|
5
|
+
position: Vec3;
|
|
6
|
+
radius: number;
|
|
7
|
+
};
|
|
8
|
+
type $$ComponentProps = {
|
|
9
|
+
entries: SiteLabelEntry[];
|
|
10
|
+
get_offset: (site_idx: number) => Vec3;
|
|
11
|
+
screen_margin: number;
|
|
12
|
+
label: Snippet<[{
|
|
13
|
+
site_idx: number;
|
|
14
|
+
}]>;
|
|
15
|
+
};
|
|
16
|
+
declare const SiteLabels: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
17
|
+
type SiteLabels = ReturnType<typeof SiteLabels>;
|
|
18
|
+
export default SiteLabels;
|