3D Reaction Viewer
Interactive 3D visualization of chemical reactions using React Three Fiber.
Features
- 5 pre-computed reactions: H₂ dissociation, SN2 (CH₃F + Cl⁻), acid deprotonation, ketone reduction, Diels-Alder
- Algorithm selection: UFF, PM3, GFN0-xTB, GFN1-xTB, GFN2-xTB, HF-3c — UI placeholder only, see below
- Playback controls: Play/Pause, speed adjustment, frame slider
- Energy profile: energy vs. reaction coordinate overlay
- Interactive 3D: Rotate, zoom, and pan with mouse/touch (OrbitControls)
- CPK coloring: Standard atomic colors and covalent radii for ball-and-stick rendering
How It Works
Each reaction is defined by a hand-authored pair of molecular geometries (reactant and product). Intermediate frames are generated by linear interpolation of the atomic positions along the reaction coordinate, and the energy of each frame comes from a hard-coded analytic 1-D potential written directly in examples/reaction-viewer/src/data/reactions.ts — for example a Gaussian barrier plus a linear term for SN2, or a symmetric double well for H₂ dissociation.
Those analytic curves are illustrative: they are not computed from a quantum-mechanical or force-field potential, and their barrier heights are hand-chosen constants in the source (for example 15 kcal/mol for SN2, 25 kcal/mol for the ketone reduction, 30 kcal/mol for the Diels-Alder).
Bond detection is purely geometric and uses covalent radii — atoms closer than 1.3 × the sum of their covalent radii are connected (BOND_FACTOR = 1.3 in examples/reaction-viewer/src/data/elements.ts). This is what allows bonds to appear and disappear during the animation.
Known limitation: the live sci-form backends are not wired in
The example does not import sci-form-wasm, and it has no dependency on the sci-form packages (examples/reaction-viewer/package.json lists only React, Three.js and the React Three Fiber stack). Nothing in it calls into the sci-form engine.
Consequently:
- The algorithm selector in the control panel has no effect on the computation. The
Regeneratebutton inexamples/reaction-viewer/src/App.tsxcarries the comment "In a real integration, this would call WASM NEB"; today it only resets the animation to the first frame. Choosing UFF, PM3 or HF-3c changes nothing about the geometries or the energies that are displayed. - The energy profile is the hard-coded analytic curve described above, not a single-point energy from any of the backends the selector names.
Wiring the real backends (NEB paths and energy evaluation through the WASM bindings) is an open item, not a shipped feature of this example.
Building from Source
cd examples/reaction-viewer
npm install
npm run dev # development server
npm run build # production build → docs/public/reaction-viewer/Technology
- React Three Fiber — React renderer for Three.js
- @react-three/drei — Useful helpers (OrbitControls, Environment, ContactShadows)
- sci-form WASM — the intended computation engine (not yet integrated in this example)