Repository navigation
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
After #377 unified integer tiling and fractional bounds through range extraction, the range fully determines a volume's prepared grid: it encodes tiling and halo for periodic volumes and both are irrelevant for finite ones. Remove the now-redundant tiling_key/halo fields from PreparedGrid and geometry_key — also stops finite-volume caches from needlessly invalidating on supercell changes.
|
thanks for the sharp catch and the clean fix! verified the drift empirically (finite marching cubes on a tiled periodic 8-point grid put vertices up to 0.75 off the requested isovalue — your self-sampling test recovers it to 1e-5) and merged into the feature branch via a19c657, with a small follow-up commit dropping the tiling/halo cache-key fields your range unification made redundant. this will ship with #376 |
* Add multi-volume sampling and vertex-coloring core for isosurfaces Lay the engine groundwork for #375 (multi-volume isosurfaces with cross-volume scalar coloring): - sampling.ts: world-coordinate volume sampler (origin offsets, non-orthogonal lattices, periodic wrap, clamp/fallback out-of-bounds policies), strict VESTA-style grid compatibility check with mismatch diagnostics, and fractional display-range extraction for non-integer supercells that clip exactly at fractional bounds - coloring.ts: linear-RGB colormap LUTs (d3 sRGB converted for Three.js vertex colors), scalar-to-vertex-color mapping with inverted-range and non-finite handling, auto colormap/range selection with symmetric ranges for signed fields - types.ts: IsosurfaceLayer gains volume_idx/color_volume_idx/colormap/ color_range, IsosurfaceSettings gains display_range; helpers for layer materialization, volume removal with index remapping, and source-file based import merging (append same-cell fields, replace reimports) - file-drop.ts: process all dropped files sequentially; one corrupt file no longer aborts the batch trilinear_interpolate moved from slice.ts to sampling.ts (public export path unchanged). * Render multi-volume isosurfaces with cross-volume vertex coloring Rework the isosurface renderer and controls for #375: - Isosurface.svelte renders all loaded volumes at once: each layer picks a geometry-source volume and optionally a different color-source volume sampled per vertex through a colormap (e.g. density colored by ESP). Geometry is cached per layer signature so colormap/color-range changes never rerun marching cubes; sampled scalars are cached and only remapped through the LUT. Supercell tiling moved into the renderer so colors sample the untiled full-res volume and stay continuous across cell boundaries and tiles. Fractional display ranges (VESTA-style non-integer supercells) clip surfaces exactly at the requested bounds, independent of the atom supercell. - IsosurfaceControls groups surfaces under their geometry volume with add/remove-surface and remove-volume buttons, per-surface color-source select, colormap picker, min/max range inputs (empty = auto-fit to surface values) with inline colorbar, grid-compatibility warning, and per-axis fractional display-range inputs. - Structure.svelte appends volumes from files describing the same cell (in-place replace on reimport of the same source file) instead of replacing the scene; supports multi-file drops; volumetric_data prop stays backward compatible (single volume or array). Vitest controls suite renamed to .svelte.ts for $state props and extended to the new multi-volume UI. * Add multi-volume demo page, paired fixtures, and e2e coverage Complete #375 with testable demos: - /structure/multi-volume demo page with seven scenarios: glycine density colored by ESP (strictly matching 50^3 cube pair), caffeine HOMO+LUMO rendered together, Fe charge colored by magnetization (2x2x2 supercell), Al(111) slab density colored by LOCPOT (3x3x1), hBN density colored by ELF on a non-orthogonal lattice, a VESTA-style fractional display range (a, b in [-0.15, 2.15]) with an independent integer atom supercell, and an 80x80x96 grid-pair perf stress test. Clicking picker files appends same-cell volumes; scenario loads are race-guarded and URL-addressable. - New matching-grid fixtures: glycine density+ESP cubes (softened Coulomb potential of neutral partial charges), Al-slab-CHGCAR pairing the existing LOCPOT, hBN-ELFCAR pairing hBN-CHGCAR, and a large-grid LOCPOT for perf testing. Fixture generator gained per-file CLI args, a slab fix (zero lattice vectors no longer triple-count images), and shared Al slab geometry. - Playwright suite covering every scenario plus controls interactions (volume grouping, color-source-only note, add-surface). * Address review: empty-file errors, stale scenario label, dedupe, strict zip - file-drop: report empty decompressed content as a batch failure with the filename instead of silently skipping the file - multi-volume demo: leave preset-scenario mode (overlay label + URL param) after any user file import, not just scene replacement - sampling: reuse exported create_cart_to_frac_matrix from math.ts instead of duplicating the inverse-transpose construction - generate_examples: zip(..., strict=True) in pbc_gaussian_sum to fail loudly on mismatched center/weight/sigma lists (no fixture changes) * Remove accidentally committed __pycache__ and gitignore it * Fix scenario clicks, drop serialization, and same-cell import edge cases Second review round on #375: - multi-volume demo: the URL-sync effect tracked active_scenario, so clicking a scenario card reran the effect against the still-old URL and reloaded the previous scenario, discarding the click as a stale load. Track only the URL, fall back to the first scenario when no preset is loaded, and absorb the old onMount. Playwright regression test clicks a card and asserts the switch. - file-drop: queue overlapping drop batches so concurrent on_drop state mutations can't interleave; capture DataTransfer contents synchronously (only readable during event dispatch) via a new dropped_file_url helper split out of handle_url_drop - Structure: parse errors propagate to the batch aggregator instead of last-write-wins; dropping the first volumetric file onto an existing same-cell structure appends instead of replacing the scene; structure files describing the same cell keep loaded volumes and camera (mixed CHGCAR + POSCAR batches survive either drop order) - merge_imported_volumes: pin implicit layers to active_volume_idx before index remapping instead of assuming volume 0 - Isosurface: cancel pending debounced rebuild when volumes clear; cache samplers per volume object - generate_examples.py: friendly unknown-filename CLI error, rename shadowed single-letter var - tests: drop-queue serialization, plural failure aggregation, merge active-index regression, six new controls interactions; Playwright suites drop flaky networkidle waits for wait_for_3d_canvas and share open_settings_pane via helpers.ts * Runtime-check dropped URL payload instead of trusting FileInfo cast Drop payloads are external input: a JSON body with a truthy non-string url (number, object) previously flowed through dropped_file_url's type assertion into fetch(). Return the url only when it is a non-empty string; cover empty-string, numeric, and object urls in the handle_url_drop suite and assert fetch is never reached. * Fold URL-drop failures into the batch failure report A drop carrying both a URL payload and plain files silently swallowed the URL error when the URL fetch failed — the files were processed but the failure never reached on_error. The URL failure now joins the aggregated failures message alongside per-file errors, with a test covering the mixed URL+files failure path. * Dedupe color-volume lookups and lattice extraction, compact tests Simplification sweep across the branch: - Isosurface + IsosurfaceControls: one color_vol_of helper each replaces four hand-rolled color_volume_idx lookups (plus a template condition) - Structure: current_lattice_matrix helper replaces the twice-repeated lattice extraction ternary in the import seam - controls tests: three tests that manually mounted with $state props now use the mount_controls helper's returned reactive props No behavior changes; 495 unit + 18 e2e tests pass. * Replace manual signature tracking with derived strings, dedupe load guards Deeper simplification pass: - Isosurface: geometry and color signatures are now $derived strings — Svelte only notifies dependents when a derived value changes, so the rebuild/recolor effects skip unrelated updates natively, replacing three module-level last-signature/last-entries trackers and their compare-and-store choreography. Recolor-without-marching-cubes contract verified in the browser (colormap switch recolors the glycine ESP surface without a rebuild). - multi-volume demo: run_load() centralizes the stale-load token, loading flag, and error handling shared by scenario loads and file imports (was duplicated try/catch/finally in both). - generate_examples: hBN geometry (lattice, frac→cart, site fractions) shared between the CHGCAR and ELFCAR generators via hbn_geometry(), mirroring the Al slab helper. Generator output verified byte-identical via content hashes before/after. * Fix periodic isosurface supercell coordinates * Drop cache-key fields subsumed by the extraction range After #377 unified integer tiling and fractional bounds through range extraction, the range fully determines a volume's prepared grid: it encodes tiling and halo for periodic volumes and both are irrelevant for finite ones. Remove the now-redundant tiling_key/halo fields from PreparedGrid and geometry_key — also stops finite-volume caches from needlessly invalidating on supercell changes. * fix CmdPalette with search text not navigating on option click * Inline single-use halo helper and tiling-range construction effective_halo had one caller left after the range unification (the resolver already clamps and gates halo on periodicity), and the integer-tiling DisplayRange collapses to a map over the tiling factors. * Tighten demo scenario descriptions and make card text selectable Scenario blurbs cut to their essentials (what renders + what it demonstrates); user-select: text on the card buttons since browsers suppress selection inside <button> by default. * Clarify that cache reuse rebinds entry identity to current loop values * Harden 3D viewer overlays and WebGL lifecycle for desktop embedders - Overlay chrome that must stack above WebGL canvases (atom legend, cell-select dropdown, glass chips, carousel pager, viewer controls, draggable panes) now gets its own compositing layer: WKWebView (Tauri) reattaches canvas layers above non-composited overlays after its window is hidden and re-shown, ignoring z-index. - Document the in-viewer overlay stack as --z-index-viewer-* custom properties in app.css and wire components to them (values unchanged). - Pause auto-rotation while the page is hidden: desktop embedders disable background throttling, which left hidden windows re-rendering every auto-rotating canvas indefinitely. - StructureViewport remounts its <Canvas> when the browser evicts the WebGL context without restoring it (bounded retries), so blank carousel cards self-heal. - CellSelect opens on sustained hover (200ms) instead of instantly on mouseenter, so scrubbing the pointer across compact embeds no longer pops the menu open. * Add arbitrary volume slices and scalable isosurface rendering Generalize plane sampling with reusable filled and contour rendering, and move geometry extraction to an instrumented worker for responsive large-volume updates. Add benchmark and regression coverage while hardening related file-drop and UI state handling. * Polish slice responsiveness and WebGL recovery Render high-resolution slices without deep-proxy or contour stalls, surface exhausted WebGL recovery, and strengthen portable performance and cache regression coverage. * Fix packaged isosurface worker resolution Use an extensionless worker URL so source and compiled package layouts both resolve correctly. * Stabilize isosurface E2E tests under CI load Serialize the CPU-heavy suite while preserving four-worker parallelism for unrelated tests. * Preserve structure camera rotation across hover Keep the orientation gizmo mounted so hover visibility changes do not reinitialize orbit controls. * Refine file picker chip corners * Simplify isosurface pipeline and tests Centralize geometry preparation and remove duplicated control, demo, and test setup while preserving performance-sensitive paths. * Polish isosurface controls and viewer defaults Use compact labeled color controls, simplify file picking behavior, and improve initial structure framing. * Fix CI E2E hangs on unstable canvas screenshots Playwright locator.screenshot waits for element stability; under CI load continuous WebGL/layout updates never settle and burn the test timeout. Capture canvases via clipped page screenshots instead. * Avoid Playwright screenshots for 2D canvas E2E checks page.screenshot still hung on the busy isosurface demo under CI load. Read 2D canvas pixels via toDataURL; keep clipped page screenshots only for WebGL where blit would be blank without preserveDrawingBuffer. * Polish file-picker clicks, isosurface controls, and viewer chrome Key pending clicks by URL so same-name files stay distinct, restore hover/focus gizmo gating, and tighten labeled isosurface layer controls plus theme-aware UI. * Require matching pending click for HeatmapMatrix dblclick Align delayed click/dblclick disambiguation with FilePicker so orphaned or cross-cell dblclicks schedule a single-click instead of firing ondblclick. * Drop underscore prefixes on isosurface internal modules. Prefer plain names and keep internals out of the package barrel instead of _* marking; also remove the unused bench:isosurface script. * Fold page_visibility into scene props and cut low-value test fat. Merge the tiny visibility module into props.svelte.ts and drop redundant FilePicker, controls, types, and perf harness coverage that mostly restated defaults. * Keep Structure gizmo mounted across hover cycles Gate visibility with the gizmo-visible CSS class only. Tying the gizmo prop to viewer_active remounted Threlte Gizmo on every leave and broke the hover-chrome E2E regression test. --------- Co-authored-by: Stardust0831 <169599847+Stardust0831@users.noreply.github.com>
* Add multi-volume sampling and vertex-coloring core for isosurfaces Lay the engine groundwork for #375 (multi-volume isosurfaces with cross-volume scalar coloring): - sampling.ts: world-coordinate volume sampler (origin offsets, non-orthogonal lattices, periodic wrap, clamp/fallback out-of-bounds policies), strict VESTA-style grid compatibility check with mismatch diagnostics, and fractional display-range extraction for non-integer supercells that clip exactly at fractional bounds - coloring.ts: linear-RGB colormap LUTs (d3 sRGB converted for Three.js vertex colors), scalar-to-vertex-color mapping with inverted-range and non-finite handling, auto colormap/range selection with symmetric ranges for signed fields - types.ts: IsosurfaceLayer gains volume_idx/color_volume_idx/colormap/ color_range, IsosurfaceSettings gains display_range; helpers for layer materialization, volume removal with index remapping, and source-file based import merging (append same-cell fields, replace reimports) - file-drop.ts: process all dropped files sequentially; one corrupt file no longer aborts the batch trilinear_interpolate moved from slice.ts to sampling.ts (public export path unchanged). * Render multi-volume isosurfaces with cross-volume vertex coloring Rework the isosurface renderer and controls for #375: - Isosurface.svelte renders all loaded volumes at once: each layer picks a geometry-source volume and optionally a different color-source volume sampled per vertex through a colormap (e.g. density colored by ESP). Geometry is cached per layer signature so colormap/color-range changes never rerun marching cubes; sampled scalars are cached and only remapped through the LUT. Supercell tiling moved into the renderer so colors sample the untiled full-res volume and stay continuous across cell boundaries and tiles. Fractional display ranges (VESTA-style non-integer supercells) clip surfaces exactly at the requested bounds, independent of the atom supercell. - IsosurfaceControls groups surfaces under their geometry volume with add/remove-surface and remove-volume buttons, per-surface color-source select, colormap picker, min/max range inputs (empty = auto-fit to surface values) with inline colorbar, grid-compatibility warning, and per-axis fractional display-range inputs. - Structure.svelte appends volumes from files describing the same cell (in-place replace on reimport of the same source file) instead of replacing the scene; supports multi-file drops; volumetric_data prop stays backward compatible (single volume or array). Vitest controls suite renamed to .svelte.ts for $state props and extended to the new multi-volume UI. * Add multi-volume demo page, paired fixtures, and e2e coverage Complete #375 with testable demos: - /structure/multi-volume demo page with seven scenarios: glycine density colored by ESP (strictly matching 50^3 cube pair), caffeine HOMO+LUMO rendered together, Fe charge colored by magnetization (2x2x2 supercell), Al(111) slab density colored by LOCPOT (3x3x1), hBN density colored by ELF on a non-orthogonal lattice, a VESTA-style fractional display range (a, b in [-0.15, 2.15]) with an independent integer atom supercell, and an 80x80x96 grid-pair perf stress test. Clicking picker files appends same-cell volumes; scenario loads are race-guarded and URL-addressable. - New matching-grid fixtures: glycine density+ESP cubes (softened Coulomb potential of neutral partial charges), Al-slab-CHGCAR pairing the existing LOCPOT, hBN-ELFCAR pairing hBN-CHGCAR, and a large-grid LOCPOT for perf testing. Fixture generator gained per-file CLI args, a slab fix (zero lattice vectors no longer triple-count images), and shared Al slab geometry. - Playwright suite covering every scenario plus controls interactions (volume grouping, color-source-only note, add-surface). * Address review: empty-file errors, stale scenario label, dedupe, strict zip - file-drop: report empty decompressed content as a batch failure with the filename instead of silently skipping the file - multi-volume demo: leave preset-scenario mode (overlay label + URL param) after any user file import, not just scene replacement - sampling: reuse exported create_cart_to_frac_matrix from math.ts instead of duplicating the inverse-transpose construction - generate_examples: zip(..., strict=True) in pbc_gaussian_sum to fail loudly on mismatched center/weight/sigma lists (no fixture changes) * Remove accidentally committed __pycache__ and gitignore it * Fix scenario clicks, drop serialization, and same-cell import edge cases Second review round on #375: - multi-volume demo: the URL-sync effect tracked active_scenario, so clicking a scenario card reran the effect against the still-old URL and reloaded the previous scenario, discarding the click as a stale load. Track only the URL, fall back to the first scenario when no preset is loaded, and absorb the old onMount. Playwright regression test clicks a card and asserts the switch. - file-drop: queue overlapping drop batches so concurrent on_drop state mutations can't interleave; capture DataTransfer contents synchronously (only readable during event dispatch) via a new dropped_file_url helper split out of handle_url_drop - Structure: parse errors propagate to the batch aggregator instead of last-write-wins; dropping the first volumetric file onto an existing same-cell structure appends instead of replacing the scene; structure files describing the same cell keep loaded volumes and camera (mixed CHGCAR + POSCAR batches survive either drop order) - merge_imported_volumes: pin implicit layers to active_volume_idx before index remapping instead of assuming volume 0 - Isosurface: cancel pending debounced rebuild when volumes clear; cache samplers per volume object - generate_examples.py: friendly unknown-filename CLI error, rename shadowed single-letter var - tests: drop-queue serialization, plural failure aggregation, merge active-index regression, six new controls interactions; Playwright suites drop flaky networkidle waits for wait_for_3d_canvas and share open_settings_pane via helpers.ts * Runtime-check dropped URL payload instead of trusting FileInfo cast Drop payloads are external input: a JSON body with a truthy non-string url (number, object) previously flowed through dropped_file_url's type assertion into fetch(). Return the url only when it is a non-empty string; cover empty-string, numeric, and object urls in the handle_url_drop suite and assert fetch is never reached. * Fold URL-drop failures into the batch failure report A drop carrying both a URL payload and plain files silently swallowed the URL error when the URL fetch failed — the files were processed but the failure never reached on_error. The URL failure now joins the aggregated failures message alongside per-file errors, with a test covering the mixed URL+files failure path. * Dedupe color-volume lookups and lattice extraction, compact tests Simplification sweep across the branch: - Isosurface + IsosurfaceControls: one color_vol_of helper each replaces four hand-rolled color_volume_idx lookups (plus a template condition) - Structure: current_lattice_matrix helper replaces the twice-repeated lattice extraction ternary in the import seam - controls tests: three tests that manually mounted with $state props now use the mount_controls helper's returned reactive props No behavior changes; 495 unit + 18 e2e tests pass. * Replace manual signature tracking with derived strings, dedupe load guards Deeper simplification pass: - Isosurface: geometry and color signatures are now $derived strings — Svelte only notifies dependents when a derived value changes, so the rebuild/recolor effects skip unrelated updates natively, replacing three module-level last-signature/last-entries trackers and their compare-and-store choreography. Recolor-without-marching-cubes contract verified in the browser (colormap switch recolors the glycine ESP surface without a rebuild). - multi-volume demo: run_load() centralizes the stale-load token, loading flag, and error handling shared by scenario loads and file imports (was duplicated try/catch/finally in both). - generate_examples: hBN geometry (lattice, frac→cart, site fractions) shared between the CHGCAR and ELFCAR generators via hbn_geometry(), mirroring the Al slab helper. Generator output verified byte-identical via content hashes before/after. * Fix periodic isosurface supercell coordinates * Drop cache-key fields subsumed by the extraction range After #377 unified integer tiling and fractional bounds through range extraction, the range fully determines a volume's prepared grid: it encodes tiling and halo for periodic volumes and both are irrelevant for finite ones. Remove the now-redundant tiling_key/halo fields from PreparedGrid and geometry_key — also stops finite-volume caches from needlessly invalidating on supercell changes. * fix CmdPalette with search text not navigating on option click * Inline single-use halo helper and tiling-range construction effective_halo had one caller left after the range unification (the resolver already clamps and gates halo on periodicity), and the integer-tiling DisplayRange collapses to a map over the tiling factors. * Tighten demo scenario descriptions and make card text selectable Scenario blurbs cut to their essentials (what renders + what it demonstrates); user-select: text on the card buttons since browsers suppress selection inside <button> by default. * Clarify that cache reuse rebinds entry identity to current loop values * Harden 3D viewer overlays and WebGL lifecycle for desktop embedders - Overlay chrome that must stack above WebGL canvases (atom legend, cell-select dropdown, glass chips, carousel pager, viewer controls, draggable panes) now gets its own compositing layer: WKWebView (Tauri) reattaches canvas layers above non-composited overlays after its window is hidden and re-shown, ignoring z-index. - Document the in-viewer overlay stack as --z-index-viewer-* custom properties in app.css and wire components to them (values unchanged). - Pause auto-rotation while the page is hidden: desktop embedders disable background throttling, which left hidden windows re-rendering every auto-rotating canvas indefinitely. - StructureViewport remounts its <Canvas> when the browser evicts the WebGL context without restoring it (bounded retries), so blank carousel cards self-heal. - CellSelect opens on sustained hover (200ms) instead of instantly on mouseenter, so scrubbing the pointer across compact embeds no longer pops the menu open. * Add arbitrary volume slices and scalable isosurface rendering Generalize plane sampling with reusable filled and contour rendering, and move geometry extraction to an instrumented worker for responsive large-volume updates. Add benchmark and regression coverage while hardening related file-drop and UI state handling. * Polish slice responsiveness and WebGL recovery Render high-resolution slices without deep-proxy or contour stalls, surface exhausted WebGL recovery, and strengthen portable performance and cache regression coverage. * Fix packaged isosurface worker resolution Use an extensionless worker URL so source and compiled package layouts both resolve correctly. * Stabilize isosurface E2E tests under CI load Serialize the CPU-heavy suite while preserving four-worker parallelism for unrelated tests. * Preserve structure camera rotation across hover Keep the orientation gizmo mounted so hover visibility changes do not reinitialize orbit controls. * Refine file picker chip corners * Simplify isosurface pipeline and tests Centralize geometry preparation and remove duplicated control, demo, and test setup while preserving performance-sensitive paths. * Polish isosurface controls and viewer defaults Use compact labeled color controls, simplify file picking behavior, and improve initial structure framing. * Fix CI E2E hangs on unstable canvas screenshots Playwright locator.screenshot waits for element stability; under CI load continuous WebGL/layout updates never settle and burn the test timeout. Capture canvases via clipped page screenshots instead. * Avoid Playwright screenshots for 2D canvas E2E checks page.screenshot still hung on the busy isosurface demo under CI load. Read 2D canvas pixels via toDataURL; keep clipped page screenshots only for WebGL where blit would be blank without preserveDrawingBuffer. * Polish file-picker clicks, isosurface controls, and viewer chrome Key pending clicks by URL so same-name files stay distinct, restore hover/focus gizmo gating, and tighten labeled isosurface layer controls plus theme-aware UI. * Require matching pending click for HeatmapMatrix dblclick Align delayed click/dblclick disambiguation with FilePicker so orphaned or cross-cell dblclicks schedule a single-click instead of firing ondblclick. * Drop underscore prefixes on isosurface internal modules. Prefer plain names and keep internals out of the package barrel instead of _* marking; also remove the unused bench:isosurface script. * Fold page_visibility into scene props and cut low-value test fat. Merge the tiny visibility module into props.svelte.ts and drop redundant FilePicker, controls, types, and perf harness coverage that mostly restated defaults. * Keep Structure gizmo mounted across hover cycles Gate visibility with the gizmo-visible CSS class only. Tying the gizmo prop to viewer_active remounted Threlte Gizmo on every leave and broke the hover-chrome E2E regression test. --------- Co-authored-by: Stardust0831 <169599847+Stardust0831@users.noreply.github.com>
* Add multi-volume sampling and vertex-coloring core for isosurfaces Lay the engine groundwork for #375 (multi-volume isosurfaces with cross-volume scalar coloring): - sampling.ts: world-coordinate volume sampler (origin offsets, non-orthogonal lattices, periodic wrap, clamp/fallback out-of-bounds policies), strict VESTA-style grid compatibility check with mismatch diagnostics, and fractional display-range extraction for non-integer supercells that clip exactly at fractional bounds - coloring.ts: linear-RGB colormap LUTs (d3 sRGB converted for Three.js vertex colors), scalar-to-vertex-color mapping with inverted-range and non-finite handling, auto colormap/range selection with symmetric ranges for signed fields - types.ts: IsosurfaceLayer gains volume_idx/color_volume_idx/colormap/ color_range, IsosurfaceSettings gains display_range; helpers for layer materialization, volume removal with index remapping, and source-file based import merging (append same-cell fields, replace reimports) - file-drop.ts: process all dropped files sequentially; one corrupt file no longer aborts the batch trilinear_interpolate moved from slice.ts to sampling.ts (public export path unchanged). * Render multi-volume isosurfaces with cross-volume vertex coloring Rework the isosurface renderer and controls for #375: - Isosurface.svelte renders all loaded volumes at once: each layer picks a geometry-source volume and optionally a different color-source volume sampled per vertex through a colormap (e.g. density colored by ESP). Geometry is cached per layer signature so colormap/color-range changes never rerun marching cubes; sampled scalars are cached and only remapped through the LUT. Supercell tiling moved into the renderer so colors sample the untiled full-res volume and stay continuous across cell boundaries and tiles. Fractional display ranges (VESTA-style non-integer supercells) clip surfaces exactly at the requested bounds, independent of the atom supercell. - IsosurfaceControls groups surfaces under their geometry volume with add/remove-surface and remove-volume buttons, per-surface color-source select, colormap picker, min/max range inputs (empty = auto-fit to surface values) with inline colorbar, grid-compatibility warning, and per-axis fractional display-range inputs. - Structure.svelte appends volumes from files describing the same cell (in-place replace on reimport of the same source file) instead of replacing the scene; supports multi-file drops; volumetric_data prop stays backward compatible (single volume or array). Vitest controls suite renamed to .svelte.ts for $state props and extended to the new multi-volume UI. * Add multi-volume demo page, paired fixtures, and e2e coverage Complete #375 with testable demos: - /structure/multi-volume demo page with seven scenarios: glycine density colored by ESP (strictly matching 50^3 cube pair), caffeine HOMO+LUMO rendered together, Fe charge colored by magnetization (2x2x2 supercell), Al(111) slab density colored by LOCPOT (3x3x1), hBN density colored by ELF on a non-orthogonal lattice, a VESTA-style fractional display range (a, b in [-0.15, 2.15]) with an independent integer atom supercell, and an 80x80x96 grid-pair perf stress test. Clicking picker files appends same-cell volumes; scenario loads are race-guarded and URL-addressable. - New matching-grid fixtures: glycine density+ESP cubes (softened Coulomb potential of neutral partial charges), Al-slab-CHGCAR pairing the existing LOCPOT, hBN-ELFCAR pairing hBN-CHGCAR, and a large-grid LOCPOT for perf testing. Fixture generator gained per-file CLI args, a slab fix (zero lattice vectors no longer triple-count images), and shared Al slab geometry. - Playwright suite covering every scenario plus controls interactions (volume grouping, color-source-only note, add-surface). * Address review: empty-file errors, stale scenario label, dedupe, strict zip - file-drop: report empty decompressed content as a batch failure with the filename instead of silently skipping the file - multi-volume demo: leave preset-scenario mode (overlay label + URL param) after any user file import, not just scene replacement - sampling: reuse exported create_cart_to_frac_matrix from math.ts instead of duplicating the inverse-transpose construction - generate_examples: zip(..., strict=True) in pbc_gaussian_sum to fail loudly on mismatched center/weight/sigma lists (no fixture changes) * Remove accidentally committed __pycache__ and gitignore it * Fix scenario clicks, drop serialization, and same-cell import edge cases Second review round on #375: - multi-volume demo: the URL-sync effect tracked active_scenario, so clicking a scenario card reran the effect against the still-old URL and reloaded the previous scenario, discarding the click as a stale load. Track only the URL, fall back to the first scenario when no preset is loaded, and absorb the old onMount. Playwright regression test clicks a card and asserts the switch. - file-drop: queue overlapping drop batches so concurrent on_drop state mutations can't interleave; capture DataTransfer contents synchronously (only readable during event dispatch) via a new dropped_file_url helper split out of handle_url_drop - Structure: parse errors propagate to the batch aggregator instead of last-write-wins; dropping the first volumetric file onto an existing same-cell structure appends instead of replacing the scene; structure files describing the same cell keep loaded volumes and camera (mixed CHGCAR + POSCAR batches survive either drop order) - merge_imported_volumes: pin implicit layers to active_volume_idx before index remapping instead of assuming volume 0 - Isosurface: cancel pending debounced rebuild when volumes clear; cache samplers per volume object - generate_examples.py: friendly unknown-filename CLI error, rename shadowed single-letter var - tests: drop-queue serialization, plural failure aggregation, merge active-index regression, six new controls interactions; Playwright suites drop flaky networkidle waits for wait_for_3d_canvas and share open_settings_pane via helpers.ts * Runtime-check dropped URL payload instead of trusting FileInfo cast Drop payloads are external input: a JSON body with a truthy non-string url (number, object) previously flowed through dropped_file_url's type assertion into fetch(). Return the url only when it is a non-empty string; cover empty-string, numeric, and object urls in the handle_url_drop suite and assert fetch is never reached. * Fold URL-drop failures into the batch failure report A drop carrying both a URL payload and plain files silently swallowed the URL error when the URL fetch failed — the files were processed but the failure never reached on_error. The URL failure now joins the aggregated failures message alongside per-file errors, with a test covering the mixed URL+files failure path. * Dedupe color-volume lookups and lattice extraction, compact tests Simplification sweep across the branch: - Isosurface + IsosurfaceControls: one color_vol_of helper each replaces four hand-rolled color_volume_idx lookups (plus a template condition) - Structure: current_lattice_matrix helper replaces the twice-repeated lattice extraction ternary in the import seam - controls tests: three tests that manually mounted with $state props now use the mount_controls helper's returned reactive props No behavior changes; 495 unit + 18 e2e tests pass. * Replace manual signature tracking with derived strings, dedupe load guards Deeper simplification pass: - Isosurface: geometry and color signatures are now $derived strings — Svelte only notifies dependents when a derived value changes, so the rebuild/recolor effects skip unrelated updates natively, replacing three module-level last-signature/last-entries trackers and their compare-and-store choreography. Recolor-without-marching-cubes contract verified in the browser (colormap switch recolors the glycine ESP surface without a rebuild). - multi-volume demo: run_load() centralizes the stale-load token, loading flag, and error handling shared by scenario loads and file imports (was duplicated try/catch/finally in both). - generate_examples: hBN geometry (lattice, frac→cart, site fractions) shared between the CHGCAR and ELFCAR generators via hbn_geometry(), mirroring the Al slab helper. Generator output verified byte-identical via content hashes before/after. * Fix periodic isosurface supercell coordinates * Drop cache-key fields subsumed by the extraction range After #377 unified integer tiling and fractional bounds through range extraction, the range fully determines a volume's prepared grid: it encodes tiling and halo for periodic volumes and both are irrelevant for finite ones. Remove the now-redundant tiling_key/halo fields from PreparedGrid and geometry_key — also stops finite-volume caches from needlessly invalidating on supercell changes. * fix CmdPalette with search text not navigating on option click * Inline single-use halo helper and tiling-range construction effective_halo had one caller left after the range unification (the resolver already clamps and gates halo on periodicity), and the integer-tiling DisplayRange collapses to a map over the tiling factors. * Tighten demo scenario descriptions and make card text selectable Scenario blurbs cut to their essentials (what renders + what it demonstrates); user-select: text on the card buttons since browsers suppress selection inside <button> by default. * Clarify that cache reuse rebinds entry identity to current loop values * Harden 3D viewer overlays and WebGL lifecycle for desktop embedders - Overlay chrome that must stack above WebGL canvases (atom legend, cell-select dropdown, glass chips, carousel pager, viewer controls, draggable panes) now gets its own compositing layer: WKWebView (Tauri) reattaches canvas layers above non-composited overlays after its window is hidden and re-shown, ignoring z-index. - Document the in-viewer overlay stack as --z-index-viewer-* custom properties in app.css and wire components to them (values unchanged). - Pause auto-rotation while the page is hidden: desktop embedders disable background throttling, which left hidden windows re-rendering every auto-rotating canvas indefinitely. - StructureViewport remounts its <Canvas> when the browser evicts the WebGL context without restoring it (bounded retries), so blank carousel cards self-heal. - CellSelect opens on sustained hover (200ms) instead of instantly on mouseenter, so scrubbing the pointer across compact embeds no longer pops the menu open. * Add arbitrary volume slices and scalable isosurface rendering Generalize plane sampling with reusable filled and contour rendering, and move geometry extraction to an instrumented worker for responsive large-volume updates. Add benchmark and regression coverage while hardening related file-drop and UI state handling. * Polish slice responsiveness and WebGL recovery Render high-resolution slices without deep-proxy or contour stalls, surface exhausted WebGL recovery, and strengthen portable performance and cache regression coverage. * Fix packaged isosurface worker resolution Use an extensionless worker URL so source and compiled package layouts both resolve correctly. * Stabilize isosurface E2E tests under CI load Serialize the CPU-heavy suite while preserving four-worker parallelism for unrelated tests. * Preserve structure camera rotation across hover Keep the orientation gizmo mounted so hover visibility changes do not reinitialize orbit controls. * Refine file picker chip corners * Simplify isosurface pipeline and tests Centralize geometry preparation and remove duplicated control, demo, and test setup while preserving performance-sensitive paths. * Polish isosurface controls and viewer defaults Use compact labeled color controls, simplify file picking behavior, and improve initial structure framing. * Fix CI E2E hangs on unstable canvas screenshots Playwright locator.screenshot waits for element stability; under CI load continuous WebGL/layout updates never settle and burn the test timeout. Capture canvases via clipped page screenshots instead. * Avoid Playwright screenshots for 2D canvas E2E checks page.screenshot still hung on the busy isosurface demo under CI load. Read 2D canvas pixels via toDataURL; keep clipped page screenshots only for WebGL where blit would be blank without preserveDrawingBuffer. * Polish file-picker clicks, isosurface controls, and viewer chrome Key pending clicks by URL so same-name files stay distinct, restore hover/focus gizmo gating, and tighten labeled isosurface layer controls plus theme-aware UI. * Require matching pending click for HeatmapMatrix dblclick Align delayed click/dblclick disambiguation with FilePicker so orphaned or cross-cell dblclicks schedule a single-click instead of firing ondblclick. * Drop underscore prefixes on isosurface internal modules. Prefer plain names and keep internals out of the package barrel instead of _* marking; also remove the unused bench:isosurface script. * Fold page_visibility into scene props and cut low-value test fat. Merge the tiny visibility module into props.svelte.ts and drop redundant FilePicker, controls, types, and perf harness coverage that mostly restated defaults. * Keep Structure gizmo mounted across hover cycles Gate visibility with the gizmo-visible CSS class only. Tying the gizmo prop to viewer_active remounted Threlte Gizmo on every leave and broke the hover-chrome E2E regression test. --------- Co-authored-by: Stardust0831 <169599847+Stardust0831@users.noreply.github.com>
Thank you for the remarkably comprehensive implementation in #376. While testing the integer-supercell and cross-volume coloring paths, I noticed a coordinate-consistency edge case and prepared this small follow-up on top of the feature branch.
What changes
N - 1source intervals when cropping finite grids.Why
A periodic grid with
Nsamples spans[0, 1). Repeating itStimes producesN * Ssamples ending atS - 1/N. Passing that array to marching cubes as finite maps it over[0, S], changing the voxel spacing from1/NtoS / (N*S - 1). Repeated surfaces can therefore drift relative to the atomic supercell, while cross-volume coloring still samples in the correct Cartesian frame.Using the existing
extract_volume_range()path for both integer and fractional ranges producesN*S + 1endpoint-inclusive samples and keeps geometry and scalar sampling in the same frame.