feat: draw the Brillouin zone from geometry instead of a per-lattice image - #5
Open
timurbazhirov wants to merge 1 commit into
Open
feat: draw the Brillouin zone from geometry instead of a per-lattice image#5timurbazhirov wants to merge 1 commit into
timurbazhirov wants to merge 1 commit into
Conversation
…image Adds a BrillouinZone component that renders the zone as inline SVG from face geometry (made's ReciprocalLattice.brillouinZone), superseding BrillouinZoneImage. BrillouinZoneImage points an <img> at /images/brillouin_zone/<type>.png, an asset that ships with the web app rather than any package, so other consumers render a broken image; the absolute path also cannot resolve under a non-root deployment base. One image per lattice type is lossy besides: a graphene monolayer and bulk GaN are both HEX, but the monolayer's vacuum padding flattens its zone. Faces are typed structurally so this view layer does not pin a made version, and imgSrc still renders when no faces are supplied, keeping hosts with their own artwork working. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FFFpkKD3zHysJXgAbT2uYV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
BrillouinZonecomponent that draws the zone as inline SVG, superseding the<img>-basedBrillouinZoneImage.Why
BrillouinZoneImagepoints an<img>at/images/brillouin_zone/<lattice>.png(the path@mat3ra/wovederives from the material). Two problems:HEX, but the monolayer's vacuum padding shrinks its third reciprocal vector and flattens the zone — a per-type image shows them identically.What
src/components/BrillouinZone.tsx— projects zone faces with a fixed three-quarter view, sorts them back-to-front (painter's algorithm, valid because the zone is convex), shades by face orientation, and scales to fit the requested size.exports.tsalongside the existing component;BrillouinZoneImageis untouched.Faces are typed structurally (
BrillouinZoneFaceLike) rather than imported from@mat3ra/made, so this view layer does not pin amadeversion — passnew ReciprocalLattice(material.lattice).brillouinZonestraight in once mat3ra/made#295 lands. AndimgSrcstill renders when nofacesare given, so hosts with their own artwork keep working and this can be dropped in as wove's injected component today.Validation
tests/brillouinZone.tests.ts(5 new, run bynpm test) covers the projection against a unit cube: every face keeps its vertex count, nothing is drawn outside the viewport, faces come out ordered back-to-front, shading varies by orientation and never goes negative, and output scales withsize. Suite: 12 passing.tsc --noEmitclean.exports.tsare clean.BrillouinZone.tsxreports 3 errors, all@mui/material should be listed in dependencies, not devDependencies— a repo-wide condition every existing component shares (Model.tsxalone has 4 of them;srctotals 130 errors before this change). Prettier clean on all three files.Note for maintainers:
npm run lintcannot run from a clean checkoutpackage.jsondeclares noeslint,prettier, or@exabyte-io/eslint-configdependencies, though.eslintrc.jsonextends that config and thelintscript invokes both. The working combination is eslint 8 + eslint-plugin-prettier 5 + prettier 3 (plugin-prettier 4 breaks on prettier 3, and eslint 9+ rejects.eslintrc.json). Happy to open a follow-up PR adding those devDependencies.Related
ReciprocalLattice.brillouinZone, the geometry this consumes.facesto the injected component.🤖 Generated with Claude Code
https://claude.ai/code/session_01FFFpkKD3zHysJXgAbT2uYV