matterviz 0.4.0 → 0.4.1
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/brillouin/BrillouinZone.svelte +68 -145
- package/dist/brillouin/BrillouinZone.svelte.d.ts +5 -14
- package/dist/brillouin/BrillouinZoneExportPane.svelte +43 -96
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +9 -32
- package/dist/brillouin/BrillouinZoneInfoPane.svelte.d.ts +2 -3
- package/dist/brillouin/BrillouinZoneScene.svelte +49 -203
- 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.d.ts +1 -1
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +100 -191
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +4 -1
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +176 -464
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +7 -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.js +2 -2
- package/dist/composition/FormulaFilter.svelte +6 -5
- package/dist/composition/PieChart.svelte +5 -5
- package/dist/composition/chem-sys.js +3 -2
- package/dist/composition/format.js +3 -2
- package/dist/composition/parse.d.ts +0 -1
- package/dist/composition/parse.js +17 -19
- package/dist/controls.d.ts +1 -0
- package/dist/controls.js +0 -1
- package/dist/convex-hull/ConvexHull.svelte +8 -10
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -4
- package/dist/convex-hull/ConvexHull2D.svelte +94 -175
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +176 -680
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +180 -680
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullChrome.svelte +268 -0
- package/dist/convex-hull/ConvexHullChrome.svelte.d.ts +30 -0
- package/dist/convex-hull/ConvexHullControls.svelte +88 -7
- 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 +29 -168
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +3 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +11 -2
- package/dist/convex-hull/ConvexHullTooltip.svelte.d.ts +2 -1
- 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 +278 -0
- package/dist/convex-hull/helpers.d.ts +39 -7
- package/dist/convex-hull/helpers.js +154 -69
- 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 +91 -920
- package/dist/convex-hull/types.d.ts +12 -4
- package/dist/convex-hull/types.js +12 -0
- package/dist/coordination/CoordinationBarPlot.svelte +4 -11
- package/dist/element/BohrAtom.svelte +2 -1
- package/dist/element/ElementTile.svelte.d.ts +1 -1
- package/dist/element/index.d.ts +4 -0
- package/dist/element/index.js +18 -0
- package/dist/feedback/DragOverlay.svelte +3 -1
- package/dist/feedback/DragOverlay.svelte.d.ts +1 -0
- package/dist/feedback/StatusMessage.svelte +13 -3
- package/dist/fermi-surface/FermiSurface.svelte +67 -146
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +5 -14
- package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte +72 -224
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +3 -23
- package/dist/fermi-surface/compute.js +11 -10
- 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 +64 -75
- package/dist/fermi-surface/types.d.ts +2 -2
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +55 -40
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +4 -3
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +3 -2
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +5 -5
- package/dist/heatmap-matrix/index.d.ts +3 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/io/ExportPane.svelte +166 -0
- package/dist/io/ExportPane.svelte.d.ts +17 -0
- package/dist/io/decompress.js +1 -2
- package/dist/io/export.d.ts +5 -1
- package/dist/io/export.js +32 -28
- package/dist/io/fetch.d.ts +2 -1
- package/dist/io/file-drop.d.ts +7 -0
- package/dist/io/file-drop.js +13 -0
- package/dist/io/index.d.ts +2 -0
- package/dist/io/index.js +10 -0
- package/dist/io/types.d.ts +13 -0
- package/dist/isosurface/parse.js +46 -44
- package/dist/labels.js +1 -1
- package/dist/layout/FullscreenButton.svelte +33 -0
- package/dist/layout/FullscreenButton.svelte.d.ts +10 -0
- package/dist/layout/FullscreenToggle.svelte +8 -14
- package/dist/layout/ViewerChrome.svelte +116 -0
- package/dist/layout/ViewerChrome.svelte.d.ts +17 -0
- package/dist/layout/fullscreen.d.ts +4 -0
- package/dist/layout/fullscreen.svelte.d.ts +8 -0
- package/dist/layout/fullscreen.svelte.js +37 -0
- package/dist/layout/index.d.ts +3 -0
- package/dist/layout/index.js +3 -0
- package/dist/math.d.ts +7 -3
- package/dist/math.js +18 -21
- package/dist/overlays/index.d.ts +4 -0
- package/dist/periodic-table/PeriodicTable.svelte +9 -8
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramControls.svelte +3 -2
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +4 -3
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +2 -1
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +2 -3
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +47 -132
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +3 -4
- package/dist/phase-diagram/colors.js +1 -1
- package/dist/phase-diagram/parse.d.ts +2 -1
- package/dist/plot/bar/BarPlot.svelte +79 -316
- package/dist/plot/bar/BarPlot.svelte.d.ts +7 -15
- package/dist/plot/bar/BarPlotControls.svelte.d.ts +1 -1
- package/dist/plot/bar/SpacegroupBarPlot.svelte +2 -1
- package/dist/plot/box/BoxPlot.svelte +76 -246
- package/dist/plot/box/BoxPlot.svelte.d.ts +4 -3
- package/dist/plot/box/BoxPlotControls.svelte.d.ts +1 -1
- package/dist/plot/box/Violin.svelte.d.ts +1 -1
- package/dist/plot/box/box-plot.d.ts +3 -2
- package/dist/plot/box/box-plot.js +5 -2
- 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 +4 -1
- package/dist/plot/core/components/ColorBar.svelte +5 -5
- package/dist/plot/core/components/ColorBar.svelte.d.ts +5 -4
- package/dist/plot/core/components/Line.svelte +3 -2
- package/dist/plot/core/components/Line.svelte.d.ts +3 -2
- package/dist/plot/core/components/PlotAxis.svelte +2 -1
- package/dist/plot/core/components/PlotAxis.svelte.d.ts +2 -1
- package/dist/plot/core/components/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/core/components/ReferenceLine3D.svelte +2 -2
- package/dist/plot/core/components/ReferenceLine3D.svelte.d.ts +4 -4
- package/dist/plot/core/components/ReferencePlane.svelte +2 -2
- package/dist/plot/core/components/ReferencePlane.svelte.d.ts +4 -4
- package/dist/plot/core/data-cleaning.js +18 -18
- package/dist/plot/core/fill-utils.d.ts +4 -3
- package/dist/plot/core/fill-utils.js +6 -3
- package/dist/plot/core/interactions.d.ts +5 -1
- package/dist/plot/core/interactions.js +14 -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 +6 -6
- package/dist/plot/core/scales.d.ts +17 -25
- package/dist/plot/core/scales.js +10 -8
- package/dist/plot/core/svg.d.ts +2 -1
- package/dist/plot/core/types.d.ts +18 -7
- package/dist/plot/core/utils/label-placement.d.ts +1 -1
- package/dist/plot/core/utils/label-placement.js +3 -3
- package/dist/plot/core/utils.d.ts +2 -1
- package/dist/plot/histogram/Histogram.svelte +77 -314
- package/dist/plot/histogram/HistogramControls.svelte.d.ts +1 -1
- package/dist/plot/sankey/Sankey.svelte +2 -5
- package/dist/plot/sankey/Sankey.svelte.d.ts +1 -1
- package/dist/plot/sankey/sankey.js +3 -1
- package/dist/plot/scatter/BinnedScatterPlot.svelte +3 -5
- package/dist/plot/scatter/BinnedScatterPlot.svelte.d.ts +4 -4
- package/dist/plot/scatter/ScatterPlot.svelte +160 -450
- package/dist/plot/scatter/ScatterPlot.svelte.d.ts +7 -15
- package/dist/plot/scatter/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/scatter/binned-scatter-types.d.ts +4 -11
- package/dist/plot/scatter/index.d.ts +1 -1
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte +15 -26
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte.d.ts +6 -14
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte +9 -10
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte.d.ts +5 -5
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte +122 -121
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte.d.ts +5 -14
- package/dist/plot/scatter-3d/Surface3D.svelte +6 -5
- package/dist/plot/scatter-3d/Surface3D.svelte.d.ts +4 -3
- package/dist/plot/sunburst/Sunburst.svelte +16 -20
- package/dist/plot/sunburst/Sunburst.svelte.d.ts +4 -3
- package/dist/plot/sunburst/SunburstControls.svelte.d.ts +1 -1
- package/dist/plot/sunburst/sunburst.js +4 -1
- package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
- package/dist/sanitize.js +13 -2
- 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 +14 -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 +14 -2
- package/dist/settings.js +59 -1
- package/dist/spectral/Bands.svelte +8 -7
- package/dist/spectral/Bands.svelte.d.ts +3 -2
- package/dist/spectral/BandsAndDos.svelte +22 -24
- package/dist/spectral/BrillouinBandsDos.svelte +3 -3
- package/dist/spectral/Dos.svelte +5 -4
- package/dist/spectral/Dos.svelte.d.ts +2 -1
- package/dist/spectral/helpers.d.ts +6 -6
- package/dist/spectral/helpers.js +43 -37
- package/dist/state.svelte.d.ts +0 -7
- package/dist/state.svelte.js +0 -6
- package/dist/structure/Arrow.svelte +2 -4
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/CanvasTooltip.svelte +1 -0
- package/dist/structure/CellSelect.svelte +11 -3
- package/dist/structure/CellSelect.svelte.d.ts +2 -1
- package/dist/structure/Lattice.svelte +2 -2
- package/dist/structure/Structure.svelte +291 -355
- package/dist/structure/Structure.svelte.d.ts +5 -15
- package/dist/structure/StructureControls.svelte +217 -2
- package/dist/structure/StructureControls.svelte.d.ts +5 -3
- package/dist/structure/StructureExportPane.svelte +54 -156
- package/dist/structure/StructureExportPane.svelte.d.ts +4 -5
- package/dist/structure/StructureInfoPane.svelte +5 -3
- package/dist/structure/StructureInfoPane.svelte.d.ts +5 -5
- package/dist/structure/StructureScene.svelte +365 -198
- package/dist/structure/StructureScene.svelte.d.ts +22 -20
- package/dist/structure/{label-placement.d.ts → atom-label-placement.d.ts} +3 -3
- package/dist/structure/{label-placement.js → atom-label-placement.js} +12 -2
- package/dist/structure/atom-properties.d.ts +1 -1
- package/dist/structure/atom-properties.js +11 -16
- package/dist/structure/bond-order-perception.js +2 -4
- package/dist/structure/bonding.d.ts +3 -0
- package/dist/structure/bonding.js +91 -48
- package/dist/structure/export.d.ts +24 -4
- package/dist/structure/export.js +64 -122
- package/dist/structure/index.d.ts +2 -0
- package/dist/structure/index.js +2 -0
- package/dist/structure/parse.d.ts +3 -2
- package/dist/structure/parse.js +333 -370
- package/dist/structure/partial-occupancy.d.ts +0 -1
- package/dist/structure/partial-occupancy.js +1 -1
- package/dist/structure/pbc.d.ts +1 -1
- package/dist/structure/pbc.js +186 -13
- package/dist/structure/polyhedra.d.ts +41 -0
- package/dist/structure/polyhedra.js +602 -0
- package/dist/structure/site.d.ts +4 -0
- package/dist/structure/site.js +1 -0
- package/dist/structure/supercell.js +3 -2
- 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 +354 -0
- package/dist/symmetry/SymmetryElements.svelte.d.ts +24 -0
- package/dist/symmetry/SymmetryStats.svelte +111 -6
- package/dist/symmetry/WyckoffTable.svelte +68 -7
- package/dist/symmetry/WyckoffTable.svelte.d.ts +3 -0
- package/dist/symmetry/cell-transform.js +7 -14
- package/dist/symmetry/index.d.ts +14 -4
- package/dist/symmetry/index.js +301 -80
- package/dist/symmetry/spacegroups.d.ts +5 -1
- package/dist/symmetry/spacegroups.js +15 -1
- 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 +4 -15
- package/dist/table/HeatmapTable.svelte.d.ts +1 -1
- package/dist/trajectory/Trajectory.svelte +58 -61
- package/dist/trajectory/Trajectory.svelte.d.ts +10 -22
- package/dist/trajectory/TrajectoryExportPane.svelte +15 -24
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +4 -5
- package/dist/trajectory/TrajectoryInfoPane.svelte +3 -2
- package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +3 -2
- package/dist/trajectory/constants.js +6 -2
- package/dist/trajectory/extract.js +17 -37
- package/dist/trajectory/format-detect.d.ts +0 -1
- package/dist/trajectory/format-detect.js +3 -9
- package/dist/trajectory/frame-reader.d.ts +0 -1
- package/dist/trajectory/frame-reader.js +62 -128
- package/dist/trajectory/helpers.d.ts +10 -2
- package/dist/trajectory/helpers.js +56 -36
- 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/index.d.ts +1 -1
- package/dist/trajectory/parse/index.js +54 -102
- package/dist/trajectory/parse/lammps.d.ts +0 -2
- package/dist/trajectory/parse/lammps.js +8 -6
- package/dist/trajectory/parse/pymatgen.d.ts +2 -0
- package/dist/trajectory/parse/pymatgen.js +74 -0
- package/dist/trajectory/parse/vasp.js +4 -3
- package/dist/trajectory/parse/xyz.d.ts +9 -21
- package/dist/trajectory/parse/xyz.js +28 -33
- package/dist/trajectory/plotting.d.ts +0 -1
- package/dist/trajectory/plotting.js +3 -100
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +1 -1
- package/dist/xrd/XrdPlot.svelte +14 -29
- package/dist/xrd/broadening.d.ts +2 -1
- package/dist/xrd/calc-xrd.js +6 -11
- package/dist/xrd/index.d.ts +2 -2
- package/package.json +29 -16
- 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
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { BrillouinZoneData } from '../brillouin'
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
cartesian_to_fractional,
|
|
5
|
+
default_camera_position,
|
|
6
|
+
k_lattice_inverse,
|
|
7
|
+
k_space_size,
|
|
8
|
+
polyhedron_centroid,
|
|
9
|
+
polyhedron_geometry,
|
|
10
|
+
ReciprocalVectors,
|
|
11
|
+
} from '../brillouin'
|
|
12
|
+
import type { D3InterpolateName } from '../colors'
|
|
13
|
+
import { get_d3_interpolator } from '../colors'
|
|
14
|
+
import type { Matrix4Tuple, Vec2, Vec3 } from '../math'
|
|
5
15
|
import * as math from '../math'
|
|
6
|
-
import
|
|
16
|
+
import { bind_renderer, build_orbit_props, SceneCamera } from '../scene'
|
|
17
|
+
import type { SceneControlProps, ThreltePointerEvent } from '../scene'
|
|
7
18
|
import { DEFAULTS } from '../settings'
|
|
8
|
-
import {
|
|
9
|
-
import { T
|
|
19
|
+
import { Cylinder } from '../structure'
|
|
20
|
+
import { T } from '@threlte/core'
|
|
10
21
|
import * as extras from '@threlte/extras'
|
|
11
|
-
import * as d3_sc from 'd3-scale-chromatic'
|
|
12
|
-
import type { ComponentProps } from 'svelte'
|
|
13
22
|
import { SvelteMap } from 'svelte/reactivity'
|
|
14
|
-
import type { Camera, Scene } from 'three'
|
|
15
23
|
import {
|
|
16
24
|
BackSide,
|
|
17
25
|
BufferAttribute,
|
|
@@ -33,9 +41,6 @@
|
|
|
33
41
|
RepresentationMode,
|
|
34
42
|
} from './types'
|
|
35
43
|
|
|
36
|
-
// Threlte pointer event type for mesh interactions
|
|
37
|
-
type ThreltePointerEvent = { point: Vector3; nativeEvent: PointerEvent }
|
|
38
|
-
|
|
39
44
|
let {
|
|
40
45
|
fermi_data = $bindable(),
|
|
41
46
|
bz_data = $bindable(),
|
|
@@ -75,15 +80,13 @@
|
|
|
75
80
|
directional_light = DEFAULTS.structure.directional_light,
|
|
76
81
|
gizmo = DEFAULTS.structure.show_gizmo,
|
|
77
82
|
auto_rotate = DEFAULTS.structure.auto_rotate,
|
|
78
|
-
camera_is_moving = $bindable(false),
|
|
79
83
|
scene = $bindable(),
|
|
80
84
|
camera = $bindable(),
|
|
81
85
|
hover_data = $bindable<FermiHoverData | null>(null),
|
|
82
|
-
}: {
|
|
86
|
+
}: SceneControlProps & {
|
|
83
87
|
fermi_data?: FermiSurfaceData
|
|
84
88
|
bz_data?: BrillouinZoneData
|
|
85
89
|
camera_position?: Vec3 | undefined
|
|
86
|
-
camera_projection?: CameraProjection
|
|
87
90
|
color_property?: ColorProperty
|
|
88
91
|
color_scale?: string
|
|
89
92
|
representation?: RepresentationMode
|
|
@@ -101,33 +104,20 @@
|
|
|
101
104
|
clip_position?: number
|
|
102
105
|
clip_flip?: boolean
|
|
103
106
|
vector_scale?: number
|
|
104
|
-
rotation_damping?: number
|
|
105
|
-
max_zoom?: number
|
|
106
|
-
min_zoom?: number
|
|
107
|
-
rotate_speed?: number
|
|
108
|
-
zoom_speed?: number
|
|
109
|
-
pan_speed?: number
|
|
110
|
-
zoom_to_cursor?: boolean
|
|
111
|
-
fov?: number
|
|
112
|
-
initial_zoom?: number
|
|
113
|
-
ambient_light?: number
|
|
114
|
-
directional_light?: number
|
|
115
|
-
gizmo?: boolean | ComponentProps<typeof extras.Gizmo>
|
|
116
|
-
auto_rotate?: number
|
|
117
|
-
camera_is_moving?: boolean
|
|
118
|
-
scene?: Scene
|
|
119
|
-
camera?: Camera
|
|
120
107
|
hover_data?: FermiHoverData | null
|
|
121
108
|
} = $props()
|
|
122
109
|
|
|
123
|
-
const threlte =
|
|
110
|
+
const threlte = bind_renderer(
|
|
111
|
+
(threlte_scene, threlte_camera) => {
|
|
112
|
+
scene = threlte_scene
|
|
113
|
+
camera = threlte_camera
|
|
114
|
+
},
|
|
115
|
+
// Enable object sorting for proper depth ordering of transparent surfaces
|
|
116
|
+
(renderer) => (renderer.sortObjects = true),
|
|
117
|
+
)
|
|
124
118
|
|
|
125
|
-
//
|
|
126
|
-
|
|
127
|
-
if (!fermi_data?.k_lattice) return 10
|
|
128
|
-
const mags = fermi_data.k_lattice.map((vec) => Math.hypot(...vec))
|
|
129
|
-
return mags.reduce((sum, mag) => sum + mag, 0) / 3
|
|
130
|
-
}
|
|
119
|
+
// Characteristic scene size, used for clipping and camera positioning
|
|
120
|
+
const scene_size = $derived(k_space_size(fermi_data?.k_lattice))
|
|
131
121
|
|
|
132
122
|
// Compute clipping plane based on axis and position
|
|
133
123
|
// Plane equation: dot(normal, point) + constant >= 0 means point is visible
|
|
@@ -138,7 +128,7 @@
|
|
|
138
128
|
const normal_arr: Vec3 = [0, 0, 0]
|
|
139
129
|
normal_arr[axis_idx] = clip_flip ? -1 : 1
|
|
140
130
|
|
|
141
|
-
const scaled_position = clip_position *
|
|
131
|
+
const scaled_position = clip_position * scene_size
|
|
142
132
|
// constant = -position for normal case (keep points >= position)
|
|
143
133
|
// constant = +position for flipped case (keep points <= position)
|
|
144
134
|
const constant = clip_flip ? scaled_position : -scaled_position
|
|
@@ -159,24 +149,8 @@
|
|
|
159
149
|
}
|
|
160
150
|
})
|
|
161
151
|
|
|
162
|
-
$effect(() => {
|
|
163
|
-
scene = threlte.scene
|
|
164
|
-
camera = threlte.camera.current
|
|
165
|
-
if (threlte.renderer) {
|
|
166
|
-
// Enable object sorting for proper depth ordering of transparent surfaces
|
|
167
|
-
threlte.renderer.sortObjects = true
|
|
168
|
-
Object.assign(threlte.renderer.domElement, { __renderer: threlte.renderer })
|
|
169
|
-
}
|
|
170
|
-
})
|
|
171
|
-
|
|
172
152
|
extras.interactivity()
|
|
173
153
|
|
|
174
|
-
// Get color interpolator from d3
|
|
175
|
-
const get_interpolator = (name: string): (t: number) => string => {
|
|
176
|
-
const fn = d3_sc[name as keyof typeof d3_sc]
|
|
177
|
-
return typeof fn === `function` ? fn : d3_sc.interpolateViridis
|
|
178
|
-
}
|
|
179
|
-
|
|
180
154
|
// Filter surfaces based on selected bands
|
|
181
155
|
let visible_surfaces = $derived(
|
|
182
156
|
fermi_data?.isosurfaces.filter((surface) =>
|
|
@@ -216,7 +190,7 @@
|
|
|
216
190
|
})
|
|
217
191
|
|
|
218
192
|
// Compute property range for color scaling
|
|
219
|
-
let property_range = $derived.by(():
|
|
193
|
+
let property_range = $derived.by((): Vec2 => {
|
|
220
194
|
if (color_property !== `velocity` && color_property !== `custom`) {
|
|
221
195
|
return [0, 1]
|
|
222
196
|
}
|
|
@@ -247,7 +221,7 @@
|
|
|
247
221
|
const normalized = max_val > min_val
|
|
248
222
|
? (prop - min_val) / (max_val - min_val)
|
|
249
223
|
: 0.5
|
|
250
|
-
return
|
|
224
|
+
return get_d3_interpolator(color_scale as D3InterpolateName)(normalized)
|
|
251
225
|
}
|
|
252
226
|
// Spin coloring
|
|
253
227
|
if (color_property === `spin` && surface.spin) {
|
|
@@ -377,108 +351,30 @@
|
|
|
377
351
|
}
|
|
378
352
|
})
|
|
379
353
|
|
|
380
|
-
//
|
|
381
|
-
const rotation_target = $derived
|
|
382
|
-
if (bz_data?.vertices && bz_data.vertices.length > 0) {
|
|
383
|
-
const sum = bz_data.vertices.reduce(
|
|
384
|
-
(acc, vert) => math.add(acc, vert),
|
|
385
|
-
[0, 0, 0] as Vec3,
|
|
386
|
-
)
|
|
387
|
-
return math.scale(sum, 1 / bz_data.vertices.length)
|
|
388
|
-
}
|
|
389
|
-
return [0, 0, 0]
|
|
390
|
-
})
|
|
391
|
-
|
|
392
|
-
// Scene size for camera positioning (uses helper function defined earlier)
|
|
393
|
-
const scene_size = $derived(get_scene_size())
|
|
354
|
+
// BZ centroid as rotation center
|
|
355
|
+
const rotation_target = $derived(polyhedron_centroid(bz_data?.vertices))
|
|
394
356
|
|
|
395
|
-
const computed_camera_position = $derived
|
|
396
|
-
()
|
|
397
|
-
camera_position || ([10, 3, 8].map((coord) =>
|
|
398
|
-
coord * Math.max(1, scene_size)
|
|
399
|
-
) as Vec3),
|
|
357
|
+
const computed_camera_position = $derived(
|
|
358
|
+
camera_position || default_camera_position(scene_size),
|
|
400
359
|
)
|
|
401
360
|
|
|
402
|
-
const
|
|
403
|
-
|
|
404
|
-
className: `responsive-gizmo`,
|
|
405
|
-
...Object.fromEntries(
|
|
406
|
-
[...AXIS_COLORS, ...NEG_AXIS_COLORS].map(([axis, color, hover]) => [
|
|
407
|
-
axis,
|
|
408
|
-
{
|
|
409
|
-
color,
|
|
410
|
-
labelColor: `#111`,
|
|
411
|
-
opacity: axis.startsWith(`n`) ? 0.9 : 0.8,
|
|
412
|
-
hover: {
|
|
413
|
-
color: hover,
|
|
414
|
-
labelColor: `#222`,
|
|
415
|
-
opacity: axis.startsWith(`n`) ? 1 : 0.9,
|
|
416
|
-
},
|
|
417
|
-
},
|
|
418
|
-
]),
|
|
419
|
-
),
|
|
420
|
-
...(typeof gizmo === `object` ? gizmo : {}),
|
|
421
|
-
offset: { left: 5, bottom: 5 },
|
|
422
|
-
})
|
|
423
|
-
|
|
424
|
-
const is_ortho = $derived(camera_projection === `orthographic`)
|
|
425
|
-
const orbit_controls_props = $derived({
|
|
426
|
-
position: [0, 0, 0],
|
|
361
|
+
const orbit_controls_props = $derived(build_orbit_props({
|
|
362
|
+
camera_projection,
|
|
427
363
|
target: rotation_target,
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
autoRotate: Boolean(auto_rotate),
|
|
438
|
-
autoRotateSpeed: auto_rotate,
|
|
439
|
-
enableDamping: Boolean(rotation_damping),
|
|
440
|
-
dampingFactor: rotation_damping,
|
|
441
|
-
onstart: () => (camera_is_moving = true),
|
|
442
|
-
onend: () => (camera_is_moving = false),
|
|
443
|
-
})
|
|
444
|
-
|
|
445
|
-
const vector_colors = [`red`, `green`, `blue`]
|
|
446
|
-
const vector_labels = [`b₁`, `b₂`, `b₃`]
|
|
364
|
+
rotate_speed,
|
|
365
|
+
zoom_speed,
|
|
366
|
+
zoom_to_cursor,
|
|
367
|
+
pan_speed,
|
|
368
|
+
max_zoom,
|
|
369
|
+
min_zoom,
|
|
370
|
+
auto_rotate,
|
|
371
|
+
rotation_damping,
|
|
372
|
+
}))
|
|
447
373
|
|
|
448
374
|
// Create BZ geometry
|
|
449
|
-
const bz_geometry = $derived
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
const positions: number[] = []
|
|
453
|
-
const normals: number[] = []
|
|
454
|
-
|
|
455
|
-
for (const face of bz_data.faces) {
|
|
456
|
-
if (face.length < 3) continue
|
|
457
|
-
|
|
458
|
-
for (let face_idx = 1; face_idx < face.length - 1; face_idx++) {
|
|
459
|
-
const indices = [face[0], face[face_idx], face[face_idx + 1]]
|
|
460
|
-
if (indices.some((idx) => idx < 0 || idx >= bz_data.vertices.length)) continue
|
|
461
|
-
const [v0, v1, v2] = indices.map((idx) => bz_data.vertices[idx])
|
|
462
|
-
positions.push(...v0, ...v1, ...v2)
|
|
463
|
-
|
|
464
|
-
const e1: Vec3 = math.subtract(v1, v0)
|
|
465
|
-
const e2: Vec3 = math.subtract(v2, v0)
|
|
466
|
-
const normal_vec = math.cross_3d(e1, e2)
|
|
467
|
-
const len = Math.hypot(...normal_vec)
|
|
468
|
-
const norm = len > 1e-10 ? normal_vec.map((coord) => coord / len) : [0, 0, 0]
|
|
469
|
-
normals.push(...norm, ...norm, ...norm)
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
const geometry = new BufferGeometry()
|
|
474
|
-
geometry.setAttribute(
|
|
475
|
-
`position`,
|
|
476
|
-
new BufferAttribute(new Float32Array(positions), 3),
|
|
477
|
-
)
|
|
478
|
-
geometry.setAttribute(`normal`, new BufferAttribute(new Float32Array(normals), 3))
|
|
479
|
-
geometry.computeBoundingSphere()
|
|
480
|
-
return geometry
|
|
481
|
-
})
|
|
375
|
+
const bz_geometry = $derived(
|
|
376
|
+
bz_data ? polyhedron_geometry(bz_data.vertices, bz_data.faces) : null,
|
|
377
|
+
)
|
|
482
378
|
|
|
483
379
|
$effect(() => {
|
|
484
380
|
const prev_geometry = bz_geometry
|
|
@@ -516,26 +412,12 @@
|
|
|
516
412
|
return { ...base, color: surface_color }
|
|
517
413
|
}
|
|
518
414
|
|
|
519
|
-
//
|
|
520
|
-
const k_lattice_inv = $derived
|
|
521
|
-
if (!fermi_data?.k_lattice) return null
|
|
522
|
-
try {
|
|
523
|
-
return math.matrix_inverse_3x3(fermi_data.k_lattice)
|
|
524
|
-
} catch {
|
|
525
|
-
return null
|
|
526
|
-
}
|
|
527
|
-
})
|
|
415
|
+
// Inverse of k_lattice for Cartesian->fractional conversion (cached)
|
|
416
|
+
const k_lattice_inv = $derived(k_lattice_inverse(fermi_data?.k_lattice))
|
|
528
417
|
|
|
529
418
|
// Throttle state for pointer move events to avoid O(n) vertex lookups causing jank
|
|
530
419
|
let last_hover_time = 0
|
|
531
420
|
|
|
532
|
-
// Convert Cartesian k-coordinates to fractional (reciprocal lattice units)
|
|
533
|
-
// Returns null if k_lattice is unavailable or inversion failed
|
|
534
|
-
function cartesian_to_fractional(cart: Vec3): Vec3 | null {
|
|
535
|
-
if (!k_lattice_inv) return null
|
|
536
|
-
return math.mat3x3_vec3_multiply(k_lattice_inv, cart)
|
|
537
|
-
}
|
|
538
|
-
|
|
539
421
|
// Find index of nearest vertex to a point in a surface
|
|
540
422
|
function find_nearest_vertex(surface: Isosurface, point: Vec3): number {
|
|
541
423
|
let [min_dist, nearest_idx] = [Infinity, 0]
|
|
@@ -564,7 +446,7 @@
|
|
|
564
446
|
): FermiHoverData {
|
|
565
447
|
// event.point is in world space (after sym_matrix transformation)
|
|
566
448
|
const position_cartesian: Vec3 = [event.point.x, event.point.y, event.point.z]
|
|
567
|
-
const position_fractional = cartesian_to_fractional(position_cartesian)
|
|
449
|
+
const position_fractional = cartesian_to_fractional(k_lattice_inv, position_cartesian)
|
|
568
450
|
|
|
569
451
|
// Transform world-space point to local space for nearest-vertex lookup
|
|
570
452
|
// surface.vertices are in local space (raw geometry before sym_matrix)
|
|
@@ -610,26 +492,20 @@
|
|
|
610
492
|
last_hover_time = now
|
|
611
493
|
hover_data = create_hover_data(event, surface, surface_color, sym_idx, sym_matrix)
|
|
612
494
|
}
|
|
495
|
+
|
|
496
|
+
const clear_hover = () => {
|
|
497
|
+
hover_data = null
|
|
498
|
+
}
|
|
613
499
|
</script>
|
|
614
500
|
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
{
|
|
622
|
-
|
|
623
|
-
makeDefault
|
|
624
|
-
position={computed_camera_position}
|
|
625
|
-
zoom={initial_zoom}
|
|
626
|
-
near={-100}
|
|
627
|
-
>
|
|
628
|
-
<extras.OrbitControls {...orbit_controls_props}>
|
|
629
|
-
{#if gizmo}<extras.Gizmo {...gizmo_props} />{/if}
|
|
630
|
-
</extras.OrbitControls>
|
|
631
|
-
</T.OrthographicCamera>
|
|
632
|
-
{/if}
|
|
501
|
+
<SceneCamera
|
|
502
|
+
{camera_projection}
|
|
503
|
+
position={computed_camera_position}
|
|
504
|
+
{fov}
|
|
505
|
+
zoom={initial_zoom}
|
|
506
|
+
orbit_props={orbit_controls_props}
|
|
507
|
+
{gizmo}
|
|
508
|
+
/>
|
|
633
509
|
|
|
634
510
|
<T.DirectionalLight position={[3, 10, 10]} intensity={directional_light} />
|
|
635
511
|
<T.DirectionalLight position={[-3, -5, -10]} intensity={directional_light * 0.5} />
|
|
@@ -657,24 +533,11 @@
|
|
|
657
533
|
|
|
658
534
|
<!-- Reciprocal lattice vectors -->
|
|
659
535
|
{#if show_vectors && fermi_data?.k_lattice}
|
|
660
|
-
|
|
661
|
-
{
|
|
662
|
-
{
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
vector={scaled_vec}
|
|
666
|
-
color={vector_colors[idx]}
|
|
667
|
-
scale={1}
|
|
668
|
-
shaft_radius={scene_size * 0.008}
|
|
669
|
-
arrow_head_radius={scene_size * 0.028}
|
|
670
|
-
arrow_head_length={-0.1}
|
|
671
|
-
/>
|
|
672
|
-
<extras.HTML center position={label_position}>
|
|
673
|
-
<span style:color={vector_colors[idx]} style:font-size="1.2em">
|
|
674
|
-
{vector_labels[idx]}
|
|
675
|
-
</span>
|
|
676
|
-
</extras.HTML>
|
|
677
|
-
{/each}
|
|
536
|
+
<ReciprocalVectors
|
|
537
|
+
k_lattice={fermi_data.k_lattice}
|
|
538
|
+
{vector_scale}
|
|
539
|
+
size={scene_size}
|
|
540
|
+
/>
|
|
678
541
|
{/if}
|
|
679
542
|
|
|
680
543
|
<!-- Fermi surfaces (with optional symmetry tiling) -->
|
|
@@ -700,9 +563,7 @@
|
|
|
700
563
|
{renderOrder}
|
|
701
564
|
onpointermove={(event: ThreltePointerEvent) =>
|
|
702
565
|
handle_pointer_move(event, surface, surface_color, sym_idx, sym_matrix)}
|
|
703
|
-
onpointerleave={
|
|
704
|
-
hover_data = null
|
|
705
|
-
}}
|
|
566
|
+
onpointerleave={clear_hover}
|
|
706
567
|
>
|
|
707
568
|
<T.MeshBasicMaterial
|
|
708
569
|
color={surface_color}
|
|
@@ -723,9 +584,7 @@
|
|
|
723
584
|
renderOrder={renderOrder * 2}
|
|
724
585
|
onpointermove={(event: ThreltePointerEvent) =>
|
|
725
586
|
handle_pointer_move(event, surface, surface_color, sym_idx, sym_matrix)}
|
|
726
|
-
onpointerleave={
|
|
727
|
-
hover_data = null
|
|
728
|
-
}}
|
|
587
|
+
onpointerleave={clear_hover}
|
|
729
588
|
>
|
|
730
589
|
<T.MeshStandardMaterial
|
|
731
590
|
{...get_material_props(surface_color, use_vertex_colors, surface_idx, `back`)}
|
|
@@ -742,9 +601,7 @@
|
|
|
742
601
|
renderOrder={renderOrder * 2 + 1}
|
|
743
602
|
onpointermove={(event: ThreltePointerEvent) =>
|
|
744
603
|
handle_pointer_move(event, surface, surface_color, sym_idx, sym_matrix)}
|
|
745
|
-
onpointerleave={
|
|
746
|
-
hover_data = null
|
|
747
|
-
}}
|
|
604
|
+
onpointerleave={clear_hover}
|
|
748
605
|
>
|
|
749
606
|
<T.MeshStandardMaterial
|
|
750
607
|
{...get_material_props(
|
|
@@ -767,9 +624,7 @@
|
|
|
767
624
|
{renderOrder}
|
|
768
625
|
onpointermove={(event: ThreltePointerEvent) =>
|
|
769
626
|
handle_pointer_move(event, surface, surface_color, sym_idx, sym_matrix)}
|
|
770
|
-
onpointerleave={
|
|
771
|
-
hover_data = null
|
|
772
|
-
}}
|
|
627
|
+
onpointerleave={clear_hover}
|
|
773
628
|
>
|
|
774
629
|
<T.MeshStandardMaterial
|
|
775
630
|
{...get_material_props(
|
|
@@ -788,10 +643,3 @@
|
|
|
788
643
|
{/if}
|
|
789
644
|
{/each}
|
|
790
645
|
</T.Group>
|
|
791
|
-
|
|
792
|
-
<style>
|
|
793
|
-
:global(.fermi-surface .responsive-gizmo) {
|
|
794
|
-
width: clamp(70px, 18cqmin, 100px) !important;
|
|
795
|
-
height: clamp(70px, 18cqmin, 100px) !important;
|
|
796
|
-
}
|
|
797
|
-
</style>
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import type { BrillouinZoneData } from '../brillouin';
|
|
2
2
|
import type { Vec3 } from '../math';
|
|
3
|
-
import type {
|
|
4
|
-
import * as extras from '@threlte/extras';
|
|
5
|
-
import type { ComponentProps } from 'svelte';
|
|
6
|
-
import type { Camera, Scene } from 'three';
|
|
3
|
+
import type { SceneControlProps } from '../scene';
|
|
7
4
|
import type { ColorProperty, FermiHoverData, FermiSurfaceData, RepresentationMode } from './types';
|
|
8
|
-
type $$ComponentProps = {
|
|
5
|
+
type $$ComponentProps = SceneControlProps & {
|
|
9
6
|
fermi_data?: FermiSurfaceData;
|
|
10
7
|
bz_data?: BrillouinZoneData;
|
|
11
8
|
camera_position?: Vec3 | undefined;
|
|
12
|
-
camera_projection?: CameraProjection;
|
|
13
9
|
color_property?: ColorProperty;
|
|
14
10
|
color_scale?: string;
|
|
15
11
|
representation?: RepresentationMode;
|
|
@@ -27,24 +23,8 @@ type $$ComponentProps = {
|
|
|
27
23
|
clip_position?: number;
|
|
28
24
|
clip_flip?: boolean;
|
|
29
25
|
vector_scale?: number;
|
|
30
|
-
rotation_damping?: number;
|
|
31
|
-
max_zoom?: number;
|
|
32
|
-
min_zoom?: number;
|
|
33
|
-
rotate_speed?: number;
|
|
34
|
-
zoom_speed?: number;
|
|
35
|
-
pan_speed?: number;
|
|
36
|
-
zoom_to_cursor?: boolean;
|
|
37
|
-
fov?: number;
|
|
38
|
-
initial_zoom?: number;
|
|
39
|
-
ambient_light?: number;
|
|
40
|
-
directional_light?: number;
|
|
41
|
-
gizmo?: boolean | ComponentProps<typeof extras.Gizmo>;
|
|
42
|
-
auto_rotate?: number;
|
|
43
|
-
camera_is_moving?: boolean;
|
|
44
|
-
scene?: Scene;
|
|
45
|
-
camera?: Camera;
|
|
46
26
|
hover_data?: FermiHoverData | null;
|
|
47
27
|
};
|
|
48
|
-
declare const FermiSurfaceScene: import("svelte").Component<$$ComponentProps, {}, "
|
|
28
|
+
declare const FermiSurfaceScene: import("svelte").Component<$$ComponentProps, {}, "scene" | "camera" | "camera_projection" | "camera_position" | "surface_opacity" | "bz_data" | "hover_data" | "fermi_data">;
|
|
49
29
|
type FermiSurfaceScene = ReturnType<typeof FermiSurfaceScene>;
|
|
50
30
|
export default FermiSurfaceScene;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as math from '../math';
|
|
3
3
|
import { EPS } from '../math';
|
|
4
4
|
import { CLOSED_CONTOUR_TOLERANCE, IRREDUCIBLE_BZ_MIN_VERTICES, IRREDUCIBLE_BZ_TOLERANCE, SPANNING_THRESHOLD, } from './constants';
|
|
5
|
-
import { marching_cubes } from '
|
|
5
|
+
import { marching_cubes } from '../marching-cubes';
|
|
6
6
|
const safe_mod = (val, dim) => ((val % dim) + dim) % dim;
|
|
7
7
|
// Precompute Catmull-Rom coefficients for a given t value
|
|
8
8
|
// Returns [c0, c1, c2, c3] where result = c0*p0 + c1*p1 + c2*p2 + c3*p3
|
|
@@ -29,7 +29,7 @@ function tricubic_interpolate(grid, fx, fy, fz, px, py, pz) {
|
|
|
29
29
|
const [cz0, cz1, cz2, cz3] = catmull_rom_coeffs(fz - iz);
|
|
30
30
|
// Wrapped stencil indices (modulo hoisted out of the inner loop); a zero period
|
|
31
31
|
// (single-point axis) has no neighbours, so collapse the stencil onto index 0
|
|
32
|
-
const stencil = (idx, period) => [idx - 1, idx, idx + 1, idx + 2].map((
|
|
32
|
+
const stencil = (idx, period) => [idx - 1, idx, idx + 1, idx + 2].map((stencil_idx) => period > 0 ? ((stencil_idx % period) + period) % period : 0);
|
|
33
33
|
const [wx, wy, wz] = [stencil(ix, px), stencil(iy, py), stencil(iz, pz)];
|
|
34
34
|
// Interpolate along z, then y, then x (fully inlined)
|
|
35
35
|
let result = 0;
|
|
@@ -60,8 +60,8 @@ function upsample_grid(grid, factor, periodic = false) {
|
|
|
60
60
|
// period (count of unique points) doubles as the resampling span numerator
|
|
61
61
|
const endpoint = periodic ? 0 : 1;
|
|
62
62
|
const dims = [grid.length, grid[0]?.length || 0, grid[0]?.[0]?.length || 0];
|
|
63
|
-
const [px, py, pz] = dims.map((
|
|
64
|
-
const [new_nx, new_ny, new_nz] = [px, py, pz].map((
|
|
63
|
+
const [px, py, pz] = dims.map((dim) => dim - endpoint);
|
|
64
|
+
const [new_nx, new_ny, new_nz] = [px, py, pz].map((period) => Math.round(period * factor) + endpoint);
|
|
65
65
|
// Map new index → source coordinate; a single-point axis (span 0) pins its lone
|
|
66
66
|
// output to source 0 to avoid 0/0 = NaN
|
|
67
67
|
const src_coords = (new_n, period) => {
|
|
@@ -142,7 +142,8 @@ export function extract_fermi_surface(band_data, options = {}) {
|
|
|
142
142
|
if (compute_velocities && band_data.velocities) {
|
|
143
143
|
isosurface.properties = compute_fermi_velocities(isosurface, band_data.velocities[spin_idx][band_idx], band_data.k_lattice, band_data.k_grid, periodic);
|
|
144
144
|
isosurface.avg_velocity =
|
|
145
|
-
isosurface.properties.reduce((
|
|
145
|
+
isosurface.properties.reduce((sum, velocity) => sum + velocity, 0) /
|
|
146
|
+
isosurface.properties.length;
|
|
146
147
|
}
|
|
147
148
|
// Compute dimensionality if requested
|
|
148
149
|
if (compute_dimensionality) {
|
|
@@ -348,19 +349,19 @@ function compute_edge_intersection(surface, vertex_distances, v0_idx, v1_idx) {
|
|
|
348
349
|
// Edge must cross the plane (opposite signs)
|
|
349
350
|
if (d0 * d1 >= 0)
|
|
350
351
|
return null;
|
|
351
|
-
const
|
|
352
|
+
const frac = d0 / (d0 - d1);
|
|
352
353
|
const v0 = surface.vertices[v0_idx];
|
|
353
354
|
const v1 = surface.vertices[v1_idx];
|
|
354
355
|
const point = [
|
|
355
|
-
v0[0] +
|
|
356
|
-
v0[1] +
|
|
357
|
-
v0[2] +
|
|
356
|
+
v0[0] + frac * (v1[0] - v0[0]),
|
|
357
|
+
v0[1] + frac * (v1[1] - v0[1]),
|
|
358
|
+
v0[2] + frac * (v1[2] - v0[2]),
|
|
358
359
|
];
|
|
359
360
|
let property;
|
|
360
361
|
if (surface.properties) {
|
|
361
362
|
property =
|
|
362
363
|
surface.properties[v0_idx] +
|
|
363
|
-
|
|
364
|
+
frac * (surface.properties[v1_idx] - surface.properties[v0_idx]);
|
|
364
365
|
}
|
|
365
366
|
return { point, property };
|
|
366
367
|
}
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
+
import { download } from '../io/fetch';
|
|
1
2
|
import { to_error } from '../utils';
|
|
2
|
-
// Helper to trigger file download
|
|
3
|
-
function download_file(content, filename, mime_type) {
|
|
4
|
-
const blob = new Blob([content], { type: mime_type });
|
|
5
|
-
const url = URL.createObjectURL(blob);
|
|
6
|
-
const link = document.createElement(`a`);
|
|
7
|
-
link.href = url;
|
|
8
|
-
link.download = filename;
|
|
9
|
-
document.body.append(link);
|
|
10
|
-
link.click();
|
|
11
|
-
document.body.removeChild(link);
|
|
12
|
-
URL.revokeObjectURL(url);
|
|
13
|
-
}
|
|
14
3
|
// Export scene to STL format (good for 3D printing)
|
|
15
4
|
export async function export_to_stl(scene, filename) {
|
|
16
5
|
const { STLExporter } = await import(`three/addons/exporters/STLExporter.js`);
|
|
@@ -18,14 +7,14 @@ export async function export_to_stl(scene, filename) {
|
|
|
18
7
|
const result = exporter.parse(scene, { binary: true });
|
|
19
8
|
// Binary STL returns DataView, convert to ArrayBuffer for Blob
|
|
20
9
|
const buffer = result instanceof DataView ? result.buffer : result;
|
|
21
|
-
|
|
10
|
+
download(buffer, `${filename}.stl`, `application/octet-stream`);
|
|
22
11
|
}
|
|
23
12
|
// Export scene to OBJ format (widely compatible)
|
|
24
13
|
export async function export_to_obj(scene, filename) {
|
|
25
14
|
const { OBJExporter } = await import(`three/addons/exporters/OBJExporter.js`);
|
|
26
15
|
const exporter = new OBJExporter();
|
|
27
16
|
const result = exporter.parse(scene);
|
|
28
|
-
|
|
17
|
+
download(result, `${filename}.obj`, `text/plain`);
|
|
29
18
|
}
|
|
30
19
|
// Export scene to GLTF format (modern web/AR standard)
|
|
31
20
|
export async function export_to_gltf(scene, filename) {
|
|
@@ -34,7 +23,7 @@ export async function export_to_gltf(scene, filename) {
|
|
|
34
23
|
return new Promise((resolve, reject) => {
|
|
35
24
|
exporter.parse(scene, (gltf) => {
|
|
36
25
|
const output = JSON.stringify(gltf, null, 2);
|
|
37
|
-
|
|
26
|
+
download(output, `${filename}.gltf`, `application/json`);
|
|
38
27
|
resolve();
|
|
39
28
|
}, (error) => reject(to_error(error)), { binary: false });
|
|
40
29
|
});
|
|
@@ -6,7 +6,6 @@ export { default as FermiSurfaceTooltip } from './FermiSurfaceTooltip.svelte';
|
|
|
6
6
|
export * from './compute';
|
|
7
7
|
export * from './constants';
|
|
8
8
|
export * from './export';
|
|
9
|
-
export * from './marching-cubes';
|
|
10
9
|
export * from './parse';
|
|
11
10
|
export * from './symmetry';
|
|
12
11
|
export * from './types';
|
|
@@ -7,7 +7,6 @@ export { default as FermiSurfaceTooltip } from './FermiSurfaceTooltip.svelte';
|
|
|
7
7
|
export * from './compute';
|
|
8
8
|
export * from './constants';
|
|
9
9
|
export * from './export';
|
|
10
|
-
export * from './marching-cubes';
|
|
11
10
|
export * from './parse';
|
|
12
11
|
export * from './symmetry';
|
|
13
12
|
export * from './types';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { BandGridData, FermiSurfaceData } from './types';
|
|
2
|
-
export declare function parse_fermi_file(content: string, filename?: string): BandGridData | FermiSurfaceData
|
|
2
|
+
export declare function parse_fermi_file(content: string, filename?: string): BandGridData | FermiSurfaceData;
|