Skip to content

Add interactive 3D views: evidence helix, genome map and locus - #13

Merged
4waiz merged 2 commits into
mainfrom
feat/3d-visuals
Sep 29, 2026
Merged

4waiz merged 2 commits into
mainfrom
feat/3d-visuals

Conversation

@4waiz

@4waiz 4waiz commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds three interactive three.js views. Every shape is generated in code: no model, texture or image files are shipped or fetched. The earlier GLB was licensed CC BY-NC, which is why it was removed.

  • Home: evidence helix. A B-form double helix with real proportions (10.5 base pairs a turn, 150° minor groove). Each of the 15 monitored findings is a nucleotide coloured by what its evidence did: vermilion for reclassified, amber for conflict or regional, slate for unchanged. Findings are in genome order, and the figure says it is not to scale.
    • Drag to turn it.
    • Hover, or tab in and use the arrow keys, to see the change.
    • Select a finding to open its variant.
    • A ring scans along the axis while an evidence sync runs, and each finding pings as it is reached.
  • /variants: genome map. All 24 GRCh38 chromosomes to scale, centromeres aligned. Each variant is a lollipop at the position its ClinVar record gives.
    • The map is linked both ways to the filters and the list: hovering a row lights its marker, and hovering a marker highlights its row.
    • On phones, only the six chromosomes that carry a variant are shown.
  • /variants/[key]: "Where it sits". The variant's own chromosome laid on its side, with the band and exact position.

Colour meanings live in src/lib/signal.ts, and the variant filters now derive from them, so a filter and its colour always agree.

Data and honesty

  • Chromosome lengths are the UCSC hg38 sizes.
  • Centromeres are the p11/q11 boundary in the hg38 cytoBand table.
  • tests/genome.test.ts checks every monitored variant's arm against ClinVar's own cytogenetic band.
  • The map draws only what it can place on GRCh38, and its description counts only those.

Cost

  • three.js is loaded with a dynamic import, only once a 3D view takes up space on screen.
  • No route's first-load JS grows: / stays at 154 kB.
  • The lazy chunks are about 140 kB gzipped.
  • The home helix is hidden on phones, so nothing downloads there.
  • The worker upload is 1.37 MB gzipped.
  • The render loop sleeps when the view is offscreen, the tab is hidden or nothing moves.
  • Reduced motion stops the idle spin, parallax, drift and pulses.

Independent review

A separate review of the first commit found real defects, and the second commit fixes all of them:

  • A lost WebGL context kept rendering behind the fallback.
  • A drag that started on a finding snapped back to it.
  • A press released outside the view could later drag with no button held.
  • Releasing after a pause still flung the helix.
  • The genome map put role="img" around links (WCAG 4.1.2).
  • A marker's front/back test was measured at the centromere, which blocked markers on a turned arm.
  • Clustered variants fanned out in reverse order.
  • Smaller fixes: the map description overcounted, and a resize reset the view and drew a blank frame.

Press, drag and hover are now shared by both scenes (attachPointer in stage.ts), and tests/pointer.test.ts covers those rules.

Already in production

Awaiz asked for this to be live before review, so the branch is deployed to variantpulse.kanbanstudios.ae (Worker version 90fcf007).

  • Until this is merged, main is behind production, and a deploy from main would remove these views.
  • The pre-3D rollback version is 5c1deee8.

Test plan

  • npm run verify: tree, type-check, lint, data, history and contrast all pass
  • npm test: 179 pass, including the new genome and pointer tests
  • npm run cf:build, then a wrangler deploy --dry-run size check
  • Local browser checks at 1440, 1100, 800 and 375 px widths:
    • helix hover, focus and sync pings
    • genome filters, row linking and hover cards
    • locus views for BRCA1, MYBPC3, PTEN and HBB
    • a phone loads no WebGL on the home page
    • no console errors
  • Live after deploy: all 17 routes return 200, the new markup is served, and evidence mode is live with 13 review cases

🤖 Generated with Claude Code

4waiz and others added 2 commits September 29, 2026 14:29
The home hero's helix is now a three.js B-form double helix built in code.
Each monitored finding is a nucleotide coloured by what its evidence did
(vermilion reclassified, amber conflict or regional, slate unchanged), in
genome order and labelled as not to scale. Drag turns it, hover or the
arrow keys bring up what changed, and a ring scans along it during an
evidence sync. The SVG helix stays as the fallback.

The variants page stands all 24 GRCh38 chromosomes to scale, each variant
pinned at its ClinVar position, linked both ways to the filters and the
list; phones keep only the chromosomes that carry a variant. Each variant
page shows its own chromosome with the band and position.

Chromosome lengths and centromeres are fixed GRCh38 values, and a test
checks every variant's arm against ClinVar's own band. three.js loads
only when a 3D view is on screen, so no page's first load grows, and
nothing is fetched beyond the code: no model, texture or image files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A lost WebGL context stops the loop at once and the view is disposed,
  falling back to the illustration, instead of rendering behind it.
- Press, drag and hover are shared by both scenes. A press released
  outside the view is dropped when the pointer returns with no button
  held, so it can no longer drag on its own; lost capture ends a drag;
  and letting go after holding still no longer flings the helix.
- Only keyboard focus turns the helix to a finding, so a drag that
  starts on one no longer snaps back to it.
- The genome map's image role sits on the drawing, not on the figure
  holding its links (WCAG 4.1.2).
- A marker's front/back test uses the chromosome axis at its own locus,
  so markers on a turned arm stay clickable.
- Variants sharing a locus fan out in coordinate order.
- The map's description counts only what it can place on GRCh38.
- A resize keeps the reader's turn and redraws at once, with no blank
  frame.

Adds tests for the pointer rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@4waiz
4waiz merged commit bf0d547 into main Sep 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant